@@ -64,6 +64,20 @@ fillSeed( const size_t i1min, const size_t i1max, const size_t i2min, const size
64
64
// bp=0 encodes 2 base pairs
65
65
for (bpIn=0 ; bpIn<seedE_rec.shape ()[2 ] && (i1+bpIn+1 -offset1)<seed.size1 () && (i2+bpIn+1 -offset2)<seed.size2 (); bpIn++) {
66
66
67
+ bool validLeftEnd = true ;
68
+
69
+ // if no LP : check for direct right-stacking of i
70
+ if (noLpShift > 0 ) {
71
+ // check if feasible extension
72
+ if (isFeasibleSeedBasePair (i1+1 ,i2+1 )) {
73
+ // get stacking energy
74
+ iStackE = energy.getE_interLeft (i1,i1+1 ,i2,i2+1 );
75
+ } else {
76
+ // no valid noLP extension possible
77
+ validLeftEnd = false ;
78
+ }
79
+ }
80
+
67
81
// for feasible unpaired in seq1 in increasing order
68
82
for (u1=0 ; u1<seedE_rec.shape ()[3 ] && (i1+bpIn+1 +u1-offset1) < seed.size1 (); u1++) {
69
83
@@ -76,26 +90,16 @@ fillSeed( const size_t i1min, const size_t i1max, const size_t i2min, const size
76
90
// get right seed boundaries
77
91
j1 = i1+bpIn+1 +u1;
78
92
j2 = i2+bpIn+1 +u2;
79
- // check if right boundary is complementary and feasible
80
- // check if this index range is to be considered for seed search
81
- bool validSeedSite = isFeasibleSeedBasePair (j1 ,j2,true );
82
-
83
- // if no LP : check for direct right-stacking of i
84
- if (noLpShift > 0 ) {
85
- // check if feasible extension
86
- if (isFeasibleSeedBasePair (i1+1 ,i2+1 )) {
87
- // get stacking energy
88
- iStackE = energy.getE_interLeft (i1,i1+1 ,i2,i2+1 );
89
- } else {
90
- validSeedSite = false ;
91
- }
92
- }
93
93
94
94
// init current seed energy
95
95
curE = E_INF;
96
96
97
- // check if right boundary is complementary
98
- if (validSeedSite) {
97
+ // check if this index range is to be considered for seed search
98
+ // check if boundaries are complementary
99
+ if (validLeftEnd
100
+ && isFeasibleSeedBasePair (j1 ,j2,true )
101
+ && (noLpShift==0 || isFeasibleSeedBasePair (j1 -1 ,j2-1 )))
102
+ {
99
103
100
104
// base case: only left and right base pair present
101
105
if (bpIn==0 ) {
@@ -108,8 +112,8 @@ fillSeed( const size_t i1min, const size_t i1max, const size_t i2min, const size
108
112
} else {
109
113
110
114
// explicitly check direct stacking extension in noLP mode
111
- if (noLpShift > 0 && E_isNotINF ( getSeedE ( i1+1 -offset1 , i2+1 -offset2 , bpIn-1 , u1, u2 ) )) {
112
- curE = std::min ( curE, iStackE + getSeedE ( i1+1 -offset1 , i2+1 -offset2 , bpIn-1 , u1, u2 ) );
115
+ if (noLpShift > 0 && E_isNotINF ( getSeedE ( i1+1 , i2+1 , bpIn-1 , u1, u2 ) )) {
116
+ curE = std::min ( curE, iStackE + getSeedE ( i1+1 , i2+1 , bpIn-1 , u1, u2 ) );
113
117
}
114
118
115
119
// if enough interior base pairs left
@@ -127,15 +131,15 @@ fillSeed( const size_t i1min, const size_t i1max, const size_t i2min, const size
127
131
k2 = i2+u2p+1 +noLpShift;
128
132
// check if split pair is complementary
129
133
// and recursed entry is < E_INF
130
- if (! (isFeasibleSeedBasePair (k1,k2) && E_isNotINF ( getSeedE ( k1-offset1 , k2-offset2 , bpIn-1 -noLpShift, u1-u1p, u2-u2p ) ) ) ) {
134
+ if (! (isFeasibleSeedBasePair (k1,k2) && E_isNotINF ( getSeedE ( k1, k2, bpIn-1 -noLpShift, u1-u1p, u2-u2p ) ) ) ) {
131
135
continue ; // not complementary -> skip
132
136
}
133
137
134
138
// update mfe for split at k1,k2
135
139
curE = std::min ( curE,
136
140
iStackE
137
141
+ energy.getE_interLeft (i1+noLpShift,k1,i2+noLpShift,k2)
138
- + getSeedE ( k1-offset1 , k2-offset2 , bpIn-1 -noLpShift, u1-u1p, u2-u2p )
142
+ + getSeedE ( k1, k2, bpIn-1 -noLpShift, u1-u1p, u2-u2p )
139
143
);
140
144
} // u2p
141
145
} // u1p
@@ -145,8 +149,7 @@ fillSeed( const size_t i1min, const size_t i1max, const size_t i2min, const size
145
149
} // (j1,j2) complementary
146
150
147
151
// store seed energy
148
- setSeedE ( i1-offset1, i2-offset2, bpIn, u1, u2, curE );
149
-
152
+ setSeedE ( i1, i2, bpIn, u1, u2, curE );
150
153
} // u2
151
154
} // u1
152
155
@@ -176,7 +179,7 @@ fillSeed( const size_t i1min, const size_t i1max, const size_t i2min, const size
176
179
}
177
180
178
181
// get overall interaction energy
179
- E_type curEhyb = getSeedE ( i1-offset1 , i2-offset2 , bpIn, u1, u2 ) + energy.getE_init ();
182
+ E_type curEhyb = getSeedE ( i1, i2, bpIn, u1, u2 ) + energy.getE_init ();
180
183
curE = energy.getE ( i1, j1 , i2, j2, curEhyb );
181
184
182
185
// check hybrid energy bound including Einit
@@ -195,7 +198,7 @@ fillSeed( const size_t i1min, const size_t i1max, const size_t i2min, const size
195
198
// reduce bestE to hybridization energy only (init+loops)
196
199
if (E_isNotINF ( bestE )) {
197
200
// get seed's hybridization loop energies only
198
- bestE = getSeedE ( i1-offset1 , i2-offset2 , bpIn, u1best, u2best );
201
+ bestE = getSeedE ( i1, i2, bpIn, u1best, u2best );
199
202
// count true seed
200
203
seedCountNotInf++;
201
204
}
@@ -256,13 +259,11 @@ traceBackSeed( Interaction & interaction
256
259
// trace each seed base pair (excluding right most)
257
260
for ( size_t bpIn=1 +bpInbetween; bpIn-- > 0 ; ) {
258
261
259
-
260
-
261
262
// base case: only left and right base pair present
262
263
if (bpIn==0 ) {
263
264
// add left base pair if not left seed boundary
264
265
if (i1 != i1_) {
265
- interaction.basePairs .push_back ( energy.getBasePair (i1+offset1 ,i2+offset2 ) );
266
+ interaction.basePairs .push_back ( energy.getBasePair (i1,i2) );
266
267
}
267
268
268
269
} else {
@@ -272,12 +273,16 @@ traceBackSeed( Interaction & interaction
272
273
// check if feasible extension
273
274
assert (isFeasibleSeedBasePair (i1+1 ,i2+1 ));
274
275
// get stacking energy
275
- iStackE = energy.getE_interLeft (i1+offset1 ,i1+1 +offset1 ,i2+offset2 ,i2+1 +offset2 );
276
+ iStackE = energy.getE_interLeft (i1,i1+1 ,i2,i2+1 );
276
277
// noLP : check stacking of i
277
278
if ( E_equal ( curE, iStackE + getSeedE ( i1+1 , i2+1 , bpIn-1 , u1max, u2max )) ) {
279
+ // store left base pair if not left seed boundary
280
+ if (i1 != i1_) {
281
+ interaction.basePairs .push_back ( energy.getBasePair (i1,i2) );
282
+ }
278
283
i1++;
279
284
i2++;
280
- curE = getSeedE ( i1+ 1 , i2+ 1 , bpIn-1 , u1max, u2max );
285
+ curE = getSeedE ( i1, i2, bpIn-1 , u1max, u2max );
281
286
continue ;
282
287
}
283
288
// sanity check for noLP mode
@@ -288,36 +293,36 @@ traceBackSeed( Interaction & interaction
288
293
// i1 .. i1+u1p+1 .. j1
289
294
// i2 .. i2+u2p+1 .. j2
290
295
bool traceNotFound = true ;
291
- for (u1=1 +u1max ; traceNotFound && u1-- > 0 ; ) {
292
- for (u2=1 +u2max ; traceNotFound && u2-- > 0 ; ) {
296
+ for (u1=0 ; traceNotFound && u1<=u1max ; u1++ ) {
297
+ for (u2=0 ; traceNotFound && u2<=u2max && (u1+u2)<=uMax ; u2++ ) {
293
298
// check if overall number of unpaired is not exceeded
294
299
// or skip stacked extension since covered above
295
- if (u1+u2 > uMax || u1+u2 < noLpShift) {
300
+ if (u1+u2 < noLpShift) {
296
301
continue ;
297
302
}
298
303
299
304
k1 = i1+u1+1 +noLpShift;
300
305
k2 = i2+u2+1 +noLpShift;
301
306
302
307
// check if valid trace
303
- if ( isFeasibleSeedBasePair (k1+offset1 , k2+offset2 ) && E_isNotINF ( getSeedE ( k1, k2, bpIn-1 , u1max-u1, u2max-u2 ) ) ) {
308
+ if ( isFeasibleSeedBasePair (k1, k2) && E_isNotINF ( getSeedE ( k1, k2, bpIn-1 -noLpShift , u1max-u1, u2max-u2 ) ) ) {
304
309
305
310
// check if correct trace
306
311
if ( E_equal ( curE, iStackE
307
- + energy.getE_interLeft (i1+noLpShift+offset1 ,k1+offset1 ,i2+noLpShift+offset2 ,k2+offset2 )
312
+ + energy.getE_interLeft (i1+noLpShift,k1,i2+noLpShift,k2)
308
313
+ getSeedE ( k1, k2, bpIn-1 -noLpShift, u1max-u1, u2max-u2 )) )
309
314
{
315
+ // store next energy value to trace
316
+ curE = getSeedE ( k1, k2, bpIn-1 -noLpShift, u1max-u1, u2max-u2 );
310
317
// store left base pair if not left seed boundary
311
318
if (i1 != i1_) {
312
- interaction.basePairs .push_back ( energy.getBasePair (i1+offset1 ,i2+offset2 ) );
319
+ interaction.basePairs .push_back ( energy.getBasePair (i1,i2) );
313
320
}
314
321
if (noLpShift > 0 ) {
315
- interaction.basePairs .push_back ( energy.getBasePair (i1+noLpShift+offset1 ,i2+noLpShift+offset2 ) );
322
+ interaction.basePairs .push_back ( energy.getBasePair (i1+noLpShift,i2+noLpShift) );
316
323
// reflect additional base pair
317
324
bpIn--;
318
325
}
319
- // store next energy value to trace
320
- curE = getSeedE ( k1, k2, bpIn-1 -noLpShift, u1max-u1, u2max-u2 );
321
326
// reset for next trace step
322
327
i1 = k1;
323
328
i2 = k2;
0 commit comments