56 std::cerr <<
"Can't allocate forward score table. OUT OF MEMORY" << std::endl;
60 std::bitset<STATE_MAX> next_states;
61 std::bitset<STATE_MAX> current_states;
63 double forward_temp(-INFINITY);
64 double emission(-INFINITY);
65 bool exDef_position(
false);
70 std::bitset<STATE_MAX>* from_trans(NULL);
76 if ((*initial_to)[st]){
78 forward_temp = (*hmm)[st]->get_emission_prob(*
seqs,0) +
getTransition(init, st, 0);
80 if (forward_temp > -INFINITY){
82 (*forward_score)[0][st] = forward_temp;
83 (*scoring_current)[st] = forward_temp;
84 next_states |= (*(*hmm)[st]->getTo());
90 for(
size_t position = 1; position <
seq_size ; ++position ){
101 current_states.reset();
102 current_states |= next_states;
111 for (
size_t st_current = 0; st_current <
state_size; ++st_current){
112 if (!current_states[st_current]){
116 emission = (*hmm)[st_current]->get_emission_prob(*
seqs, position);
122 from_trans = (*hmm)[st_current]->getFrom();
124 for (
size_t previous = 0; previous <
state_size ; ++previous) {
125 if (!(*from_trans)[previous]){
130 forward_temp = (*scoring_previous)[previous] + emission +
getTransition((*
hmm)[previous], st_current , position);
133 (*scoring_current)[st_current] = forward_temp;
134 (*forward_score)[position][st_current] = forward_temp;
138 (*forward_score)[position][st_current] = (*scoring_current)[st_current]; }
140 next_states |= (*(*hmm)[st_current]->getTo());
154 for(
size_t st_previous = 0; st_previous <
state_size ;++st_previous){
156 forward_temp = (*scoring_previous)[st_previous] + (*hmm)[st_previous]->getEndTrans();
158 if (forward_temp > -INFINITY){
181 std::cerr <<
"Can't allocate Forward table and traceback table. OUT OF MEMORY\t" << __FUNCTION__ << std::endl;
185 double emission(-INFINITY);
186 double forward_temp(-INFINITY);
187 double trans(-INFINITY);
188 double previous(-INFINITY);
189 bool exDef_position(
false);
197 (*dbl_forward_score)[0][st]=forward_temp;
201 for (
size_t position = 1 ; position <
seq_size ; ++position){
202 for (
size_t st_current = 0; st_current <
state_size; ++st_current){
204 emission = (*hmm)[st_current]->get_emission_prob(*
seqs, position);
210 if (emission == -INFINITY){
214 for (
size_t st_previous = 0; st_previous <
state_size; ++st_previous){
215 previous = (*dbl_forward_score)[position-1][st_previous];
216 if (previous == -INFINITY){
223 if (trans !=-INFINITY){
224 forward_temp = previous + emission + trans;
227 (*dbl_forward_score)[position][st_current] = forward_temp;
240 for (
size_t st_previous = 0; st_previous <
state_size; ++st_previous){
241 if ((*
hmm)[st_previous]->getEndTrans() != -INFINITY){