48 std::bitset<STATE_MAX> next_states;
49 std::bitset<STATE_MAX> current_states;
51 double viterbi_temp(-INFINITY);
52 double emission(-INFINITY);
53 bool exDef_position(
false);
59 std::bitset<STATE_MAX>* from_trans(NULL);
63 if ((*initial_to)[st]){
65 viterbi_temp = (*hmm)[st]->get_emission_prob(*
seqs,0) +
getTransition(init, st, 0);;
67 if (viterbi_temp > -INFINITY){
69 (*scoring_current)[st] = viterbi_temp;
71 next_states |= (*(*hmm)[st]->getTo());
76 for(
size_t position = 1; position <
seq_size ; ++position ){
85 current_states.reset();
86 current_states |= next_states;
93 for (
size_t st_current = 0; st_current <
state_size; ++st_current){
96 if (!current_states[st_current]){
100 emission = (*hmm)[st_current]->get_emission_prob(*
seqs, position);
107 if (emission == -INFINITY){
112 from_trans = (*hmm)[st_current]->getFrom();
114 for (
size_t st_previous = 0; st_previous <
state_size ; ++st_previous) {
115 if (!(*from_trans)[st_previous]){
120 viterbi_temp =
getTransition((*
hmm)[st_previous], st_current , position) + emission + (*scoring_previous)[st_previous];
122 if (viterbi_temp == -INFINITY){
130 (*scoring_current)[st_current] = viterbi_temp;
131 (*traceback_table)[position][st_current] = st_previous;
134 next_states |= (*(*hmm)[st_current]->getTo());
147 for(
size_t st_previous = 0; st_previous <
state_size ;++st_previous){
149 viterbi_temp = (*scoring_previous)[st_previous] + (*hmm)[st_previous]->getEndTrans();
150 if (viterbi_temp == -INFINITY){
186 double emission(-INFINITY);
187 double viterbi_temp(-INFINITY);
188 double trans(-INFINITY);
189 double previous(-INFINITY);
190 bool exDef_position(
false);
199 (*dbl_viterbi_score)[0][st]=viterbi_temp;
200 (*traceback_table)[0][st]=-1;
204 for (
size_t position = 1 ; position <
seq_size ; ++position){
210 for (
size_t st_current = 0; st_current <
state_size; ++st_current){
212 emission = (*hmm)[st_current]->get_emission_prob(*
seqs, position);
218 if (emission == -INFINITY){
222 for (
size_t st_previous = 0; st_previous <
state_size; ++st_previous){
223 previous = (*dbl_viterbi_score)[position-1][st_previous];
224 if (previous == -INFINITY){
230 if (trans !=-INFINITY){
231 viterbi_temp = emission + trans + previous;
237 (*dbl_viterbi_score)[position][st_current] = viterbi_temp;
238 (*traceback_table)[position][st_current] = previous;
248 for (
size_t st_previous = 0; st_previous <
state_size; ++st_previous){
250 if ((*
hmm)[st_previous]->getEndTrans() != -INFINITY){
253 viterbi_temp = (*dbl_viterbi_score)[seq_size-1][st_previous] + (*hmm)[st_previous]->getEndTrans();
419 std::bitset<STATE_MAX> next_states;
420 std::bitset<STATE_MAX> current_states;
422 double viterbi_temp(-INFINITY);
423 double emission(-INFINITY);
424 bool exDef_position(
false);
430 std::bitset<STATE_MAX>* from_trans(NULL);
434 if ((*initial_to)[st]){
436 viterbi_temp = (*hmm)[st]->get_emission_prob(*
seqs,0) +
getTransition(init, st, 0);;
438 if (viterbi_temp > -INFINITY){
440 (*scoring_current)[st] = viterbi_temp;
442 next_states |= (*(*hmm)[st]->getTo());
447 for(
size_t position = 1; position <
seq_size ; ++position ){
456 current_states.reset();
457 current_states |= next_states;
464 for (
size_t st_current = 0; st_current <
state_size; ++st_current){
467 if (!current_states[st_current]){
471 emission = (*hmm)[st_current]->get_emission_prob(*
seqs, position);
478 if (emission == -INFINITY){
483 from_trans = (*hmm)[st_current]->getFrom();
485 for (
size_t st_previous = 0; st_previous <
state_size ; ++st_previous) {
486 if (!(*from_trans)[st_previous]){
491 viterbi_temp =
getTransition((*
hmm)[st_previous], st_current , position) + emission + (*scoring_previous)[st_previous];
493 if (viterbi_temp == -INFINITY){
501 (*scoring_current)[st_current] = viterbi_temp;
502 (*traceback_table)[position][st_current] = st_previous;
505 next_states |= (*(*hmm)[st_current]->getTo());
518 for(
size_t st_previous = 0; st_previous <
state_size ;++st_previous){
520 viterbi_temp = (*scoring_previous)[st_previous] + (*hmm)[st_previous]->getEndTrans();
521 if (viterbi_temp == -INFINITY){