38 double emission(-INFINITY);
39 double backward_temp(-INFINITY);
40 double trans(-INFINITY);
41 double previous(-INFINITY);
44 for(
size_t st_current = 0 ; st_current <
state_size; st_current++){
45 trans = (*hmm)[st_current]->getEndTrans();
46 if (trans != -INFINITY){
47 (*dbl_backward_score)[
seq_size-1][st_current] = trans;
52 typedef std::numeric_limits< double > dbl;
53 std::cout << std::setprecision(dbl::digits10);
57 for(
size_t st_current = 0; st_current <
state_size ; st_current++){
60 for (
size_t st_previous = 0; st_previous <
state_size; st_previous++){
63 previous = (*dbl_backward_score)[position+1][st_previous];
65 if (previous == -INFINITY){
70 emission = (*hmm)[st_previous]->get_emission_prob(*
seqs, position+1);
73 if (trans == -INFINITY || emission == -INFINITY){
77 backward_temp = previous + emission + trans;
80 (*dbl_backward_score)[position][st_current] = backward_temp;
93 for (
size_t st_current=0; st_current <
state_size; st_current++ ){
98 previous = (*dbl_backward_score)[0][st_current];
102 emission = (*hmm)[st_current]->get_emission_prob(*
seqs, 0);
104 if (trans == -INFINITY || emission == -INFINITY){
107 backward_temp = previous + emission + trans;
146 std::cerr <<
"Can't allocate Backward score table. OUT OF MEMORY" << std::endl;
150 std::bitset<STATE_MAX> next_states;
151 std::bitset<STATE_MAX> current_states;
153 double backward_temp(-INFINITY);
154 double emission(-INFINITY);
155 bool exDef_position(
false);
158 std::bitset<STATE_MAX>* from_trans(NULL);
162 for(
size_t st_current = 0; st_current <
state_size; ++st_current){
163 if ((*ending_from)[st_current]){
165 backward_temp = (*hmm)[st_current]->getEndTrans();
167 if (backward_temp > -INFINITY){
168 (*backward_score)[
seq_size-1][st_current] = backward_temp;
169 (*scoring_current)[st_current] = backward_temp;
170 next_states[st_current] = 1;
179 current_states.reset();
180 current_states |= next_states;
194 for (
size_t st_previous = 0; st_previous <
state_size; ++st_previous){
195 if (!current_states[st_previous]){
199 emission = (*hmm)[st_previous]->get_emission_prob(*
seqs, position+1);
205 if (emission == -INFINITY){
209 from_trans = (*hmm)[st_previous]->getFrom();
211 for (
size_t st_current = 0; st_current <
state_size ; ++st_current) {
212 if (!(*from_trans)[st_current]){
219 backward_temp = (*scoring_previous)[st_previous] + emission +
getTransition((*
hmm)[st_current], st_previous , position);
222 (*scoring_current)[st_current] = backward_temp;
223 (*backward_score)[position][st_current] = backward_temp;
227 (*backward_score)[position][st_current] = (*scoring_current)[st_current];
230 next_states[st_current] = 1;
241 if (backward_temp > -INFINITY){