Skip to content

Commit 57af16a

Browse files
committed
nthash.hpp: added mask function for spaced seed
1 parent 07e3f4d commit 57af16a

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

nthash.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,4 +425,23 @@ inline void NTMC64(const unsigned char charOut, const unsigned char charIn, cons
425425
}
426426
}
427427

428+
// masking canonical ntHash using spaced seed pattern
429+
inline uint64_t maskHash(uint64_t &fkVal, uint64_t &rkVal, const char * seedSeq, const char * kmerSeq, const unsigned k) {
430+
uint64_t fsVal=fkVal, rsVal=rkVal;
431+
for(unsigned i=0; i<k; i++) {
432+
if(seedSeq[i]!='1') {
433+
uint64_t lfBits = seedTab[(unsigned char)kmerSeq[i]] >> 33;
434+
uint64_t rfBits = seedTab[(unsigned char)kmerSeq[i]] & 0x1FFFFFFFF;
435+
uint64_t sfMask = (rol31(lfBits,k-1-i) << 33) | (rol33(rfBits,k-1-i));
436+
fsVal ^= sfMask;
437+
438+
uint64_t lrBits = seedTab[(unsigned char)kmerSeq[i]&cpOff] >> 33;
439+
uint64_t rrBits = seedTab[(unsigned char)kmerSeq[i]&cpOff] & 0x1FFFFFFFF;
440+
uint64_t srMask = (rol31(lrBits,i) << 33) | (rol33(rrBits,i));
441+
rsVal ^= srMask;
442+
}
443+
}
444+
return (rsVal<fsVal)? rsVal : fsVal;
445+
}
446+
428447
#endif

0 commit comments

Comments
 (0)