Skip to content

Commit feed434

Browse files
committed
Back out "Always use first syncmer as base"
This backs out commit 9fa9d41.
1 parent 2382f6c commit feed434

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/randstrobes.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ static inline syncmer_hash_t syncmer_smer_hash(uint64_t packed) {
4949
* This function combines two individual syncmer hashes into a single hash
5050
* for the randstrobe.
5151
*
52-
* One syncmer is designated as the "main", the other is the "auxiliary".
52+
* The syncmer with the smaller hash is designated as the "main", the other is
53+
* the "auxiliary".
5354
* The combined hash is obtained by setting the top bits to the bits of
5455
* the main hash and the bottom bits to the bits of the auxiliary
5556
* hash. Since entries in the index are sorted by randstrobe hash, this allows
@@ -58,6 +59,10 @@ static inline syncmer_hash_t syncmer_smer_hash(uint64_t packed) {
5859
static inline randstrobe_hash_t randstrobe_hash(
5960
syncmer_hash_t hash1, syncmer_hash_t hash2, randstrobe_hash_t main_hash_mask
6061
) {
62+
// Make the function symmetric
63+
if (hash1 > hash2) {
64+
std::swap(hash1, hash2);
65+
}
6166
return ((hash1 & main_hash_mask) | (hash2 & ~main_hash_mask)) & RANDSTROBE_HASH_MASK;
6267
}
6368

@@ -156,11 +161,12 @@ std::ostream& operator<<(std::ostream& os, const QueryRandstrobe& randstrobe) {
156161
}
157162

158163
Randstrobe make_randstrobe(Syncmer strobe1, Syncmer strobe2, randstrobe_hash_t main_hash_mask) {
164+
bool first_strobe_is_main = strobe1.hash < strobe2.hash;
159165
return Randstrobe{
160166
randstrobe_hash(strobe1.hash, strobe2.hash, main_hash_mask),
161167
static_cast<uint32_t>(strobe1.position),
162168
static_cast<uint32_t>(strobe2.position),
163-
true
169+
first_strobe_is_main
164170
};
165171
}
166172

tests/phix.mcs.se.paf

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
SRR1377138.32 301 2 293 + NC_001422.1 5386 1434 1725 47 291 255
2-
SRR1377138.33 301 2 297 + NC_001422.1 5386 3818 4113 47 295 255
3-
SRR1377138.34 301 33 299 - NC_001422.1 5386 844 1110 40 266 255
4-
SRR1377138.35 301 5 298 - NC_001422.1 5386 4041 4334 47 293 255
5-
SRR1377138.36 301 3 301 + NC_001422.1 5386 4997 5295 51 298 255
6-
SRR1377138.37 301 2 299 - NC_001422.1 5386 794 1091 42 297 255
7-
SRR1377138.38 301 32 284 - NC_001422.1 5386 4971 5223 42 252 255
8-
SRR1377138.39/1 301 1 295 - NC_001422.1 5386 1791 2085 48 294 255
9-
SRR1377138.40 301 4 293 - NC_001422.1 5386 3020 3309 44 289 255
10-
rescuable.42 301 4 293 - NC_001422.1 5386 3020 3309 44 289 255
11-
not.rescuable 301 4 293 - NC_001422.1 5386 3020 3309 44 289 255
1+
SRR1377138.32 301 2 293 + NC_001422.1 5386 1434 1725 49 291 255
2+
SRR1377138.33 301 2 297 + NC_001422.1 5386 3818 4113 51 295 255
3+
SRR1377138.34 301 33 299 - NC_001422.1 5386 844 1110 43 266 255
4+
SRR1377138.35 301 5 298 - NC_001422.1 5386 4041 4334 49 293 255
5+
SRR1377138.36 301 3 301 + NC_001422.1 5386 4997 5295 53 298 255
6+
SRR1377138.37 301 2 299 - NC_001422.1 5386 794 1091 43 297 255
7+
SRR1377138.38 301 32 284 - NC_001422.1 5386 4971 5223 44 252 255
8+
SRR1377138.39/1 301 1 295 - NC_001422.1 5386 1791 2085 50 294 255
9+
SRR1377138.40 301 4 293 - NC_001422.1 5386 3020 3309 48 289 255
10+
rescuable.42 301 4 293 - NC_001422.1 5386 3020 3309 48 289 255
11+
not.rescuable 301 4 293 - NC_001422.1 5386 3020 3309 48 289 255

0 commit comments

Comments
 (0)