//!Perform a traceback starting at position and state given //! \param [out] traceback_path //! \param position Position to start traceback //! \param state State to begin traceback void trellis::traceback(traceback_path& path, size_t position, size_t state){ if (seq_size == 0 || traceback_table == NULL){ return; } if (path.getModel() == NULL){ path.setModel(hmm); } int16_t pointer = (*traceback_table)[position][state]; if (pointer == -1){ std::cerr << "No valid path at State: " << state << " from Position: " << position << std::endl; return; } for( size_t pos = position - 1 ; pos>0 ; pos--){ pointer = (*traceback_table)[pos][pointer]; if (pointer == -1){ std::cerr << "No valid path at State: " << state << " from Position: " << position << std::endl; return; } path.push_back(pointer); } return; }
//!Perform traceback through trellis //!\return path trackback_path void trellis::traceback(traceback_path& path){ if (seq_size==0 || traceback_table == NULL){ return; } if (path.getModel() == NULL){ path.setModel(hmm); } if (ending_viterbi_score == -INFINITY){ return; } else{ path.setScore(ending_viterbi_score); path.push_back(ending_viterbi_tb); int16_t pointer = ending_viterbi_tb; for( size_t position = seq_size -1 ; position>0 ; position--){ pointer = (*traceback_table)[position][pointer]; if (pointer == -1){ std::cerr << "No valid path at Position: " << position << std::endl; return; } path.push_back(pointer); } } return; }