Core local alignment algorithm.
167 {
168
169
170
171
172
173
174 int r1 = 0;
175 int queryMatchCount = 0;
176 int q1 = 0;
177 int pos = -1;
178 int lastR1 = -1;
179
181 matchPosition = -1;
182
183 while (queryMatchCount < queryLength)
184 {
185 if (r1 == searchSize - 1)
186 {
188 break;
189 }
190 if (queryLength - q1 < tupleSize)
191 {
192
193
194
196 break;
197 }
198 int mismatch = 0;
199 int matchedLen = 0;
200 if ((pos =
MatchTuple(query+q1, queryLength-q1, reference, searchStartIndex + r1, searchSize - r1, matchedLen, mismatch))
201
202 >= 0)
203 {
204
205
206 if (lastR1<0)
207 matchPosition = pos;
208
209
210
211
212 if (lastR1>=0)
213 {
214 if (pos > 0)
215 {
217 }
218 }
219 else
220 {
221 lastR1 = pos;
222 }
223
224 r1 += pos;
225 r1 += matchedLen;
226 q1 += matchedLen;
227
228
229
230
232 queryMatchCount = q1;
233 lastR1 = r1;
234
235 continue;
236 }
237
238
239
240
241
242 for (int i = 1; i < queryLength - q1 - tupleSize; i++)
243 {
244 int mismatch = 0;
245 int matchedLen = 0;
246
247 if (searchStartIndex + r1 >= reference.getNumberBases())
248 return;
250 queryLength - q1 -i ,
251 reference,
252 searchStartIndex + r1,
253 searchSize - r1,
254 matchedLen,
255 mismatch))
256 >= 0)
257 {
258 if (matchPosition < 0)
259 matchPosition = pos + q1 + i ;
260 }
261 queryMatchCount += i;
262 q1 += i;
264
265 lastR1 = r1 + pos;
266 r1 += pos + tupleSize;
267 q1 += tupleSize;
268
269
270 while (searchStartIndex + r1 < reference.getNumberBases()
271 && query[q1]==reference[searchStartIndex + r1]
272 && q1 < queryLength)
273 {
274 r1++;
275 q1++;
276 }
277 if (q1 < queryLength)
278 {
280 queryMatchCount = q1;
281 }
282 else
283 {
285 queryMatchCount = queryLength ;
286 break ;
287 }
288 }
289
290 r1++;
291 q1++;
292
293
294 }
295 }
void Add(Operation operation, int count)
Append the specified operation with the specified count to this object.
void clear()
Clear this object so that it has no Cigar Operations.
@ del
deletion from the reference (the reference contains bases that have no corresponding base in the quer...
@ mismatch
mismatch operation. Associated with CIGAR Operation "M"
@ match
match/mismatch operation. Associated with CIGAR Operation "M"
@ insert
insertion to the reference (the query sequence contains bases that have no corresponding base in the ...
@ softClip
Soft clip on the read (clipped sequence present in the query sequence, but not in reference)....
int MatchTuple(const QueryType query, const int queryLength, const ReferenceType reference, const ReferenceIndex searchStartIndex, const int searchSize, int &matchedLength, int &mismatch)
Match 'query' to the 'reference' from 'searchStartIndex' up to 'searchSize', store matched length to ...