28 #include <numeric/random/random.hh>
30 #include <utility/vector1.hh>
40 static numeric::random::RandomGenerator
align_RG(31882);
52 new_seq_x->insert_gap(0);
53 new_seq_y->insert_gap(0);
58 DP_Matrix scores( new_seq_x->length(), new_seq_y->length() );
70 for (
Size y = 2; y <= new_seq_y->length(); ++y ) {
71 for (
Size x = 2; x <= new_seq_x->length(); ++x ) {
74 Real l_gap_penalty( ss->gap_open() ), u_gap_penalty( ss->gap_open() );
75 if ( scores(x,y-1)->came_from() ==
above ) u_gap_penalty = ss->gap_extend();
76 if ( scores(x-1,y)->came_from() ==
left ) l_gap_penalty = ss->gap_extend();
78 Real single_mm = ss->score( new_seq_x, new_seq_y, x, y );
80 Real u_gap = scores( x, y-1 )->score() + u_gap_penalty;
81 Real l_gap = scores( x-1, y )->score() + l_gap_penalty;
82 Real mm = scores( x-1, y-1 )->score() + ss->score( new_seq_x, new_seq_y, x, y );
85 Real u_gap_prob( exp( -1 * u_gap_penalty /
kT() ) );
86 Real l_gap_prob( exp( -1 * l_gap_penalty /
kT() ) );
87 Real mm_prob ( exp( -1 * single_mm /
kT() ) );
89 Real const partition( u_gap_prob + l_gap_prob + mm_prob );
92 u_gap_prob /= partition;
93 l_gap_prob /= partition;
101 CellOP current_cell = scores(x,y);
102 if ( rand_prob < u_gap_prob ) {
104 current_cell->score( mm );
105 current_cell->next( scores(x-1,y-1) );
106 current_cell->came_from(
diagonal );
107 }
else if ( rand_prob < l_gap_prob ) {
109 current_cell->score( l_gap );
110 current_cell->next( scores(x-1,y) );
111 current_cell->came_from(
left );
114 current_cell->score( u_gap );
115 current_cell->next( scores(x,y-1) );
116 current_cell->came_from(
above );
122 best_cell = scores( scores.rows(),scores.cols() );
132 return test_alignment;