43 std::cerr <<
"Can't allocate forward score table. OUT OF MEMORY" << std::endl;
47 std::bitset<STATE_MAX> next_states;
48 std::bitset<STATE_MAX> current_states;
50 double forward_temp(-INFINITY);
51 double emission(-INFINITY);
52 bool exDef_position(
false);
57 std::bitset<STATE_MAX>* from_trans(NULL);
63 if ((*initial_to)[st]){
65 forward_temp = (*hmm)[st]->get_emission_prob(*
seqs,0) +
getTransition(init, st, 0);
67 if (forward_temp > -INFINITY){
68 (*scoring_current)[st] = forward_temp;
69 next_states |= (*(*hmm)[st]->getTo());
75 for(
size_t position = 1; position <
seq_size ; ++position ){
86 current_states.reset();
87 current_states |= next_states;
96 for (
size_t st_current = 0; st_current <
state_size; ++st_current){
97 if (!current_states[st_current]){
101 emission = (*hmm)[st_current]->get_emission_prob(*
seqs, position);
107 from_trans = (*hmm)[st_current]->getFrom();
109 for (
size_t st_previous = 0; st_previous <
state_size ; ++st_previous) {
110 if (!(*from_trans)[st_previous]){
115 forward_temp = (*scoring_previous)[st_previous] + emission +
getTransition((*
hmm)[st_previous], st_current , position);
117 if (forward_temp == -INFINITY){
124 (*scoring_current)[st_current] = forward_temp;
130 next_states |= (*(*hmm)[st_current]->getTo());
143 for(
size_t st_previous = 0; st_previous <
state_size ;++st_previous){
145 forward_temp = (*scoring_previous)[st_previous] + (*hmm)[st_previous]->getEndTrans();
147 if (forward_temp == -INFINITY){
152 if (forward_temp > -INFINITY){
180 std::cerr <<
"Can't allocate Forward table and traceback table. OUT OF MEMORY\t" << __FUNCTION__ << std::endl;
184 double emission(-INFINITY);
185 double forward_temp(-INFINITY);
186 double trans(-INFINITY);
187 double previous(-INFINITY);
188 bool exDef_position(
false);
195 (*dbl_forward_score)[0][st]=forward_temp;
199 for (
size_t position = 1 ; position <
seq_size ; ++position){
200 for (
size_t st_current = 0; st_current <
state_size; ++st_current){
202 emission = (*hmm)[st_current]->get_emission_prob(*
seqs, position);
208 if (emission == -INFINITY){
212 for (
size_t st_previous = 0; st_previous <
state_size; ++st_previous){
213 previous = (*dbl_forward_score)[position-1][st_previous];
215 if (previous == -INFINITY){
222 if (trans !=-INFINITY ){
223 forward_temp = previous + emission + trans;
229 (*dbl_forward_score)[position][st_current] = forward_temp;
242 for (
size_t st_previous = 0; st_previous <
state_size; ++st_previous){
244 if ((*
hmm)[st_previous]->getEndTrans() != -INFINITY){
247 forward_temp = (*dbl_forward_score)[seq_size-1][st_previous] + (*hmm)[st_previous]->getEndTrans();