Skip to content

Commit f2501fe

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 a53315a commit f2501fe

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
@@ -93,26 +93,24 @@ Syncmer SyncmerIterator::next() {
9393
for (size_t j = 0; j < qs.size(); j++) {
9494
if (qs[j] <= qs_min_val) {
9595
qs_min_val = qs[j];
96-
qs_min_pos = i - k + j + 1;
9796
}
9897
}
9998
}
10099
else {
101100
// update queue and current minimum and position
101+
uint64_t front = qs.front();
102102
qs.pop_front();
103103

104-
if (qs_min_pos == i - k) { // we popped the previous minimizer, find new brute force
104+
if (front == qs_min_val) {
105+
// we popped a minimum, find new brute force
105106
qs_min_val = UINT64_MAX;
106-
qs_min_pos = i - s + 1;
107107
for (size_t j = 0; j < qs.size(); j++) {
108108
if (qs[j] <= qs_min_val) {
109109
qs_min_val = qs[j];
110-
qs_min_pos = i - k + j + 1;
111110
}
112111
}
113112
} else if (hash_s < qs_min_val) { // the new value added to queue is the new minimum
114113
qs_min_val = hash_s;
115-
qs_min_pos = i - s + 1;
116114
}
117115
}
118116
if (qs[t-1] == qs_min_val) { // occurs at t:th position in k-mer
@@ -124,7 +122,6 @@ Syncmer SyncmerIterator::next() {
124122
} else {
125123
// if there is an "N", restart
126124
qs_min_val = UINT64_MAX;
127-
qs_min_pos = -1;
128125
l = xs[0] = xs[1] = xk[0] = xk[1] = 0;
129126
qs.clear();
130127
}

src/randstrobes.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ class SyncmerIterator {
171171
const uint64_t sshift = (s - 1) * 2;
172172
std::deque<uint64_t> qs; // s-mer hashes
173173
uint64_t qs_min_val = UINT64_MAX;
174-
size_t qs_min_pos = -1;
175174
size_t l = 0;
176175
uint64_t xk[2] = {0, 0};
177176
uint64_t xs[2] = {0, 0};

0 commit comments

Comments
 (0)