Skip to content

Commit 96ec0b3

Browse files
committed
Harmonize findClosestRefSeq with findClosestRefSeqEarlyStop (only compare until the end of the shortest of the variable and wildtype sequences)
1 parent 1a1cef3 commit 96ec0b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/digestFastqs.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,18 +986,20 @@ int findClosestRefSeq(std::string &varSeq, std::vector<std::string> &wtSeq,
986986
int maxsim = 0;
987987
int nbrbesthits = 0;
988988
int currsim;
989+
size_t minl;
989990
for (size_t i = 0; i < wtSeq.size(); i++) {
990991
currsim = 0;
991992
std::string currSeq = wtSeq[i];
992-
for (size_t j = 0; j < currSeq.length(); j++) {
993+
minl = std::min(varSeq.size(), currSeq.size());
994+
for (size_t j = 0; j < minl; j++) {
993995
currsim += (currSeq[j] == varSeq[j]);
994996
}
995997
if (((int)varSeq.size() - currsim <= (int)upperBoundMismatch)) {
996998
if (currsim == maxsim) {
997999
nbrbesthits++;
9981000
} else if (currsim > maxsim) {
9991001
nbrbesthits = 1;
1000-
idx = i;
1002+
idx = (int)i;
10011003
maxsim = currsim;
10021004
}
10031005
}

0 commit comments

Comments
 (0)