Skip to content

Commit 77bbb7e

Browse files
committed
Get rid of qs_min_pos
We do not need to track the position of the minimum, only its value
1 parent 22eb635 commit 77bbb7e

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/randstrobes.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,24 @@ Syncmer SyncmerIterator::next() {
9595
for (size_t j = 0; j < qs.size(); j++) {
9696
if (qs[j] <= qs_min_val) {
9797
qs_min_val = qs[j];
98-
qs_min_pos = i - parameters.k + j + 1;
9998
}
10099
}
101100
}
102101
else {
103102
// update queue and current minimum and position
103+
uint64_t front = qs.front();
104104
qs.pop_front();
105105

106-
if (qs_min_pos == i - parameters.k) { // we popped the previous minimizer, find new brute force
106+
if (front == qs_min_val) {
107+
// we popped a minimum, find new brute force
107108
qs_min_val = UINT64_MAX;
108-
qs_min_pos = i - parameters.s + 1;
109109
for (size_t j = 0; j < qs.size(); j++) {
110110
if (qs[j] <= qs_min_val) {
111111
qs_min_val = qs[j];
112-
qs_min_pos = i - parameters.k + j + 1;
113112
}
114113
}
115114
} else if (hash_s < qs_min_val) { // the new value added to queue is the new minimum
116115
qs_min_val = hash_s;
117-
qs_min_pos = i - parameters.s + 1;
118116
}
119117
}
120118
if (qs[parameters.t_syncmer - 1] == qs_min_val) { // occurs at t:th position in k-mer
@@ -126,7 +124,6 @@ Syncmer SyncmerIterator::next() {
126124
} else {
127125
// if there is an "N", restart
128126
qs_min_val = UINT64_MAX;
129-
qs_min_pos = -1;
130127
l = xs[0] = xs[1] = xk[0] = xk[1] = 0;
131128
qs.clear();
132129
}

src/randstrobes.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class SyncmerIterator {
161161
const uint64_t sshift = (parameters.s - 1) * 2;
162162
std::deque<uint64_t> qs; // s-mer hashes
163163
uint64_t qs_min_val = UINT64_MAX;
164-
size_t qs_min_pos = -1;
165164
size_t l = 0;
166165
uint64_t xk[2] = {0, 0};
167166
uint64_t xs[2] = {0, 0};

0 commit comments

Comments
 (0)