53 std::vector<double> temp_columns(columns,pseudocount);
54 counts=
new(std::nothrow) std::vector<std::vector<double> > (rows,temp_columns);
57 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
71 counts =
new(std::nothrow) std::vector<std::vector<double> >;
74 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
86 prob =
new(std::nothrow) std::vector<std::vector<double> >;
89 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
101 logProb =
new(std::nothrow) std::vector<std::vector<double> >;
104 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
126 std::cerr <<
"Index is out of range of lookup table in lexicalTable" << std::endl;
147 std::cerr <<
"Index is out of range of lookup table in lexicalTable" << std::endl;
159 trcks.push_back(trk);
161 order.push_back(orderValue);
188 size_t tracks_size =
trcks.size();
191 std::cerr <<
"Can't print out table without track and order being set for lexicalTable\n";
198 std::vector<std::vector<std::string> > complete_alphabet(tracks_size, std::vector<std::string>());
201 std::vector<size_t> alphaSizes;
204 for(
size_t i = 0;i<
trcks.size();i++){
205 size_t alphaSz = (
trcks[i]->isAmbiguousSet()) ?
trcks[i]->getMaxAmbiguous()+1 :
trcks[i]->getAlphaSize();
207 alphaSizes.push_back(alphaSz);
210 for(
size_t j=0; j < alphaSz; ++j){
211 complete_alphabet[i].push_back(
trcks[i]->getAlpha(j));
215 reverse(alphaSizes.begin(),alphaSizes.end());
217 std::string colHeader(
"@");
220 for(
size_t i = 0; i < columns; ++i){
221 size_t indexValue = i;
222 for(
size_t tr=0;tr<
trcks.size();tr++){
229 if (tr<
trcks.size()-1){
230 val= floor(indexValue/alphaSizes[tr]);
231 indexValue-=val*alphaSizes[tr];
237 colHeader+=complete_alphabet[tr][val];
242 tbl+=colHeader +
"\n";
299 size_t tracks_size =
trcks.size();
302 std::cerr <<
"Can't print out table without track and order being set for lexicalTable\n";
308 std::vector<size_t> alphaSizes;
311 for(
size_t i = 0;i<
trcks.size();i++){
312 size_t alphaSz =
trcks[i]->getAlphaSize();
314 alphaSizes.push_back(alphaSz);
318 reverse(alphaSizes.begin(),alphaSizes.end());
320 std::string colHeader(
"@");
322 for(
size_t i = 0;i<columns;i++){
323 size_t indexValue = i;
324 for(
size_t tr=0;tr<
trcks.size();tr++){
331 if (tr<
trcks.size()-1){
332 val= floor(indexValue/alphaSizes[tr]);
333 indexValue-=val*alphaSizes[tr];
339 colHeader+=
trcks[tr]->convertIndexToWord(val, 1);
344 tbl+=colHeader +
"\n";
346 std::vector<std::vector<double> >* temp;
351 else if (
prob!=NULL){
358 std::cerr <<
"No table is defined\n";
363 bool rowHeader = (temp->size()>1) ?
true :
false;
364 for(
size_t i=0;i<temp->size();i++){
365 std::string header(
"");
368 size_t indexValue = i;
370 for(
size_t tr=0;tr<
trcks.size();tr++){
372 if (tr>0 &&
order[tr]>0){
378 if (tr<
trcks.size()-1){
380 val= floor(indexValue/pwr);
387 header+=
trcks[tr]->convertIndexToWord(val,
order[tr]);
389 tbl+=
"@" + header +
"\t";
393 for(
size_t j=0;j<(*temp)[i].size();j++){
428 for(
size_t i=1;i<
order.size();i++){
429 for(
size_t j=0;j<
order[i];j++){
434 for (
size_t i=0;i<
y_dim;i++){
436 for(
size_t j=i+1;j<
y_dim;j++){
463 std::vector<size_t> complete_alphabet_size;
464 size_t current_dim(0);
468 size_t alpha_size =
trcks[i]->getTotalAlphabetSize();
469 complete_alphabet_size.push_back(alpha_size);
472 for(
size_t j=0;j<=
order[i];++j){
480 for (
size_t j=0;j<=
order[i];++j){
488 std::vector<size_t> decompose_index;
490 for(
size_t j=0;j<
order[i];++j){
491 decompose_index.push_back(complete_alphabet_size[i]);
495 decompose_index.push_back(complete_alphabet_size[i]);
510 size_t array_index(0);
513 for(
size_t j=0;j<
order[i];++j){
524 std::vector<size_t> temp;
526 for(
size_t j=0;j<
order[i];++j){
546 for(
size_t row=0;row<
logProb->size();++row){
547 for(
size_t column=0;column<(*logProb)[row].size();++column){
548 std::vector<uint8_t> alphabet;
551 (*log_emission)[index] = (*logProb)[row][column];
552 transferred[index] =
true;
557 for(
size_t i=0;i<transferred.size();i++){
571 std::vector<uint8_t> letters;
621 subtotal+=seqs[seq][position-pos];
630 for(
size_t i=0;i<indices.
size();i++){
633 temp /= indices.
size();
638 double temp(INFINITY);
639 for(
size_t i=0;i<indices.
size();i++){
640 double val = (*log_emission)[indices[i]];
648 double temp(-INFINITY);
649 for(
size_t i=0;i<indices.
size();i++){
650 double val = (*log_emission)[indices[i]];
678 subtotal+=seq[position-pos];
687 for(
size_t i=0;i<indices.
size();i++){
690 temp /= indices.
size();
695 double temp(INFINITY);
696 for(
size_t i=0;i<indices.
size();i++){
697 double val = (*log_emission)[indices[i]];
705 double temp(-INFINITY);
706 for(
size_t i=0;i<indices.
size();i++){
707 double val = (*log_emission)[indices[i]];
726 subtotal+= letters[i];
735 for(
size_t i=0;i<indices.
size();i++){
738 temp /= indices.
size();
744 double temp(INFINITY);
745 for(
size_t i=0;i<indices.
size();i++){
746 double val = (*log_emission)[indices[i]];
754 double temp(-INFINITY);
755 for(
size_t i=0;i<indices.
size();i++){
756 double val = (*log_emission)[indices[i]];
824 for(
size_t i=0;i<
y_dim;++i){
827 letters.push_back(val);
834 letters.push_back(val);
847 letters.push_back(val);
858 std::cerr <<
"Cannot initialize emission table until after the tables have been assigned";
876 std::vector<bool> transferred (
array_size,
false);