18 #ifndef _GREEDY_TUPLE_H 19 #define _GREEDY_TUPLE_H 27 #include "CigarRoller.h" 45 gapOpen = gapExtend = -1;
59 template <
typename QueryType,
typename ReferenceType,
typename ReferenceIndex>
80 const QueryType query,
81 const int queryLength,
82 const ReferenceType reference,
83 const ReferenceIndex searchStartIndex,
91 const int MAX_MISMATCH=2;
92 int bestPos = 0, bestMismatch = queryLength, bestMatchedLength = 0, bestScore=-1;
94 #if defined(DEBUG_GREEDY_ALIGNER) 95 cout <<
"searchStartIndex == " << searchStartIndex <<
", searchSize == " << searchSize << std::endl;
99 for (
int i = 0; i <= searchSize - tupleSize; i++)
103 while (j < queryLength)
105 if (searchStartIndex + i + j >= reference.getNumberBases())
107 if (query[j] != reference[searchStartIndex + i + j])
110 if (mismatch >= MAX_MISMATCH)
116 if (j>0 && (j==queryLength)) j--;
118 while (searchStartIndex +i +j < reference.getNumberBases()
119 && ((j+1) > mismatch)
121 && query[j] != reference[searchStartIndex + i+j])
129 int score = j - mismatch;
131 if (score > bestScore)
135 bestMismatch = mismatch;
136 bestMatchedLength = j+1;
142 mismatch = bestMismatch;
143 matchedLength = bestMatchedLength;
162 ReferenceType reference,
163 ReferenceIndex searchStartIndex,
166 ReferenceIndex& matchPosition)
175 int queryMatchCount = 0;
183 while (queryMatchCount < queryLength)
185 if (r1 == searchSize - 1)
190 if (queryLength - q1 < tupleSize)
200 if ((pos = MatchTuple(query+q1, queryLength-q1, reference, searchStartIndex + r1, searchSize - r1, matchedLen, mismatch))
232 queryMatchCount = q1;
242 for (
int i = 1; i < queryLength - q1 - tupleSize; i++)
247 if (searchStartIndex + r1 >= reference.getNumberBases())
249 if ((pos = MatchTuple(query+q1 + i ,
250 queryLength - q1 -i ,
252 searchStartIndex + r1,
258 if (matchPosition < 0)
259 matchPosition = pos + q1 + i ;
261 queryMatchCount += i;
266 r1 += pos + tupleSize;
270 while (searchStartIndex + r1 < reference.getNumberBases()
271 && query[q1]==reference[searchStartIndex + r1]
277 if (q1 < queryLength)
280 queryMatchCount = q1;
285 queryMatchCount = queryLength ;
297 static const int tupleSize = 3;
insertion to the reference (the query sequence contains bases that have no corresponding base in the ...
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.
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 ...
Weight includes various penalties(e.g.
void Align(QueryType query, int queryLength, ReferenceType reference, ReferenceIndex searchStartIndex, int searchSize, CigarRoller &cigarRoller, ReferenceIndex &matchPosition)
Core local alignment algorithm.
mismatch operation. Associated with CIGAR Operation "M"
Soft clip on the read (clipped sequence present in the query sequence, but not in reference)...
match/mismatch operation. Associated with CIGAR Operation "M"
deletion from the reference (the reference contains bases that have no corresponding base in the quer...
The purpose of this class is to provide accessors for setting, updating, modifying the CIGAR object...