18static const char*
const NTHASH_FN_NAME =
"ntHash_v2";
25using NUM_HASHES_TYPE = uint8_t;
26using K_TYPE = uint16_t;
27using SpacedSeedBlocks = std::vector<std::array<unsigned, 2>>;
28using SpacedSeedMonomers = std::vector<unsigned>;
59std::vector<std::vector<unsigned>>
60parse_seeds(
const std::vector<std::string>& seed_strings);
76 typedefs::NUM_HASHES_TYPE num_hashes,
88 typedefs::NUM_HASHES_TYPE num_hashes,
91 :
NtHash(seq.data(), seq.size(), num_hashes, k, pos)
97 , num_hashes(obj.num_hashes)
100 , initialized(obj.initialized)
101 , fwd_hash(obj.fwd_hash)
102 , rev_hash(obj.rev_hash)
103 , hash_arr(new uint64_t[obj.num_hashes])
106 hash_arr.get(), obj.hash_arr.get(), num_hashes *
sizeof(uint64_t));
109 NtHash(NtHash&&) =
default;
163 const uint64_t*
hashes()
const {
return hash_arr.get(); }
182 typedefs::K_TYPE
get_k()
const {
return k; }
197 std::string_view seq;
198 typedefs::NUM_HASHES_TYPE num_hashes;
202 uint64_t fwd_hash = 0;
203 uint64_t rev_hash = 0;
204 std::unique_ptr<uint64_t[]> hash_arr;
226 typedefs::NUM_HASHES_TYPE num_hashes,
232 , num_hashes(obj.num_hashes)
234 , fwd_hash(obj.fwd_hash)
235 , rev_hash(obj.rev_hash)
236 , hash_arr(new uint64_t[obj.num_hashes])
239 hash_arr.get(), obj.hash_arr.get(), num_hashes *
sizeof(uint64_t));
271 const uint64_t*
hashes()
const {
return hash_arr.get(); }
290 typedefs::K_TYPE
get_k()
const {
return seq.size(); }
305 std::deque<char> seq;
306 typedefs::NUM_HASHES_TYPE num_hashes;
308 uint64_t fwd_hash = 0;
309 uint64_t rev_hash = 0;
310 std::unique_ptr<uint64_t[]> hash_arr;
329 const std::vector<std::string>& seeds,
330 typedefs::NUM_HASHES_TYPE num_hashes_per_seed,
344 const std::vector<std::string>& seeds,
345 typedefs::NUM_HASHES_TYPE num_hashes_per_seed,
348 :
SeedNtHash(seq.data(), seq.size(), seeds, num_hashes_per_seed, k, pos)
364 const std::vector<std::vector<unsigned>>& seeds,
365 typedefs::NUM_HASHES_TYPE num_hashes_per_seed,
379 const std::vector<std::vector<unsigned>>& seeds,
380 typedefs::NUM_HASHES_TYPE num_hashes_per_seed,
383 :
SeedNtHash(seq.data(), seq.size(), seeds, num_hashes_per_seed, k, pos)
389 , num_hashes_per_seed(obj.num_hashes_per_seed)
392 , initialized(obj.initialized)
394 , monomers(obj.monomers)
395 , fwd_hash_nomonos(new uint64_t[obj.blocks.size()])
396 , rev_hash_nomonos(new uint64_t[obj.blocks.size()])
397 , fwd_hash(new uint64_t[obj.blocks.size()])
398 , rev_hash(new uint64_t[obj.blocks.size()])
399 , hash_arr(new uint64_t[obj.num_hashes_per_seed * obj.blocks.size()])
401 std::memcpy(fwd_hash_nomonos.get(),
402 obj.fwd_hash_nomonos.get(),
403 obj.blocks.size() *
sizeof(uint64_t));
404 std::memcpy(rev_hash_nomonos.get(),
405 obj.rev_hash_nomonos.get(),
406 obj.blocks.size() *
sizeof(uint64_t));
408 fwd_hash.get(), obj.fwd_hash.get(), obj.blocks.size() *
sizeof(uint64_t));
410 rev_hash.get(), obj.rev_hash.get(), obj.blocks.size() *
sizeof(uint64_t));
411 std::memcpy(hash_arr.get(),
413 obj.num_hashes_per_seed * obj.blocks.size() *
sizeof(uint64_t));
416 SeedNtHash(SeedNtHash&&) =
default;
460 const uint64_t*
hashes()
const {
return hash_arr.get(); }
473 unsigned get_hash_num()
const {
return num_hashes_per_seed * blocks.size(); }
481 return num_hashes_per_seed;
488 typedefs::K_TYPE
get_k()
const {
return k; }
503 std::string_view seq;
504 typedefs::NUM_HASHES_TYPE num_hashes_per_seed;
508 std::vector<typedefs::SpacedSeedBlocks> blocks;
509 std::vector<typedefs::SpacedSeedMonomers> monomers;
510 std::unique_ptr<uint64_t[]> fwd_hash_nomonos;
511 std::unique_ptr<uint64_t[]> rev_hash_nomonos;
512 std::unique_ptr<uint64_t[]> fwd_hash;
513 std::unique_ptr<uint64_t[]> rev_hash;
514 std::unique_ptr<uint64_t[]> hash_arr;
538 const std::vector<std::string>& seeds,
539 typedefs::NUM_HASHES_TYPE num_hashes_per_seed,
544 : seq(seed_nthash.seq)
545 , num_hashes_per_seed(seed_nthash.num_hashes_per_seed)
547 , pos(seed_nthash.pos)
548 , blocks(seed_nthash.blocks)
549 , monomers(seed_nthash.monomers)
550 , fwd_hash_nomonos(new uint64_t[seed_nthash.blocks.size()])
551 , rev_hash_nomonos(new uint64_t[seed_nthash.blocks.size()])
552 , fwd_hash(new uint64_t[seed_nthash.blocks.size()])
553 , rev_hash(new uint64_t[seed_nthash.blocks.size()])
554 , hash_arr(new uint64_t[num_hashes_per_seed * seed_nthash.blocks.size()])
556 std::memcpy(fwd_hash_nomonos.get(),
557 seed_nthash.fwd_hash_nomonos.get(),
558 seed_nthash.blocks.size() *
sizeof(uint64_t));
559 std::memcpy(rev_hash_nomonos.get(),
560 seed_nthash.rev_hash_nomonos.get(),
561 seed_nthash.blocks.size() *
sizeof(uint64_t));
562 std::memcpy(fwd_hash.get(),
563 seed_nthash.fwd_hash.get(),
564 seed_nthash.blocks.size() *
sizeof(uint64_t));
565 std::memcpy(rev_hash.get(),
566 seed_nthash.rev_hash.get(),
567 seed_nthash.blocks.size() *
sizeof(uint64_t));
568 std::memcpy(hash_arr.get(),
569 seed_nthash.hash_arr.get(),
570 num_hashes_per_seed * seed_nthash.blocks.size() *
592 const uint64_t*
hashes()
const {
return hash_arr.get(); }
605 unsigned get_hash_num()
const {
return num_hashes_per_seed * blocks.size(); }
613 return num_hashes_per_seed;
620 typedefs::K_TYPE
get_k()
const {
return k; }
635 std::deque<char> seq;
636 typedefs::NUM_HASHES_TYPE num_hashes_per_seed;
639 std::vector<typedefs::SpacedSeedBlocks> blocks;
640 std::vector<typedefs::SpacedSeedMonomers> monomers;
641 std::unique_ptr<uint64_t[]> fwd_hash_nomonos;
642 std::unique_ptr<uint64_t[]> rev_hash_nomonos;
643 std::unique_ptr<uint64_t[]> fwd_hash;
644 std::unique_ptr<uint64_t[]> rev_hash;
645 std::unique_ptr<uint64_t[]> hash_arr;
Definition nthash.hpp:214
void roll_back(char char_in)
typedefs::NUM_HASHES_TYPE get_hash_num() const
Definition nthash.hpp:284
void peek_back(char char_in)
uint64_t get_reverse_hash() const
Definition nthash.hpp:302
BlindNtHash(const char *seq, typedefs::NUM_HASHES_TYPE num_hashes, typedefs::K_TYPE k, ssize_t pos=0)
ssize_t get_pos() const
Definition nthash.hpp:278
uint64_t get_forward_hash() const
Definition nthash.hpp:296
typedefs::K_TYPE get_k() const
Definition nthash.hpp:290
const uint64_t * hashes() const
Definition nthash.hpp:271
Definition nthash.hpp:524
const uint64_t * hashes() const
Definition nthash.hpp:592
ssize_t get_pos() const
Definition nthash.hpp:599
unsigned get_hash_num() const
Definition nthash.hpp:605
typedefs::K_TYPE get_k() const
Definition nthash.hpp:620
void roll_back(char char_in)
uint64_t * get_reverse_hash() const
Definition nthash.hpp:632
BlindSeedNtHash(const char *seq, const std::vector< std::string > &seeds, typedefs::NUM_HASHES_TYPE num_hashes_per_seed, typedefs::K_TYPE k, ssize_t pos=0)
uint64_t * get_forward_hash() const
Definition nthash.hpp:626
typedefs::NUM_HASHES_TYPE get_hash_num_per_seed() const
Definition nthash.hpp:611
typedefs::NUM_HASHES_TYPE get_hash_num() const
Definition nthash.hpp:176
uint64_t get_forward_hash() const
Definition nthash.hpp:188
uint64_t get_reverse_hash() const
Definition nthash.hpp:194
NtHash(const std::string &seq, typedefs::NUM_HASHES_TYPE num_hashes, typedefs::K_TYPE k, size_t pos=0)
Definition nthash.hpp:87
NtHash(const char *seq, size_t seq_len, typedefs::NUM_HASHES_TYPE num_hashes, typedefs::K_TYPE k, size_t pos=0)
const uint64_t * hashes() const
Definition nthash.hpp:163
typedefs::K_TYPE get_k() const
Definition nthash.hpp:182
bool peek_back(char char_in)
size_t get_pos() const
Definition nthash.hpp:170
Definition nthash.hpp:314
size_t get_pos() const
Definition nthash.hpp:467
SeedNtHash(const std::string &seq, const std::vector< std::vector< unsigned > > &seeds, typedefs::NUM_HASHES_TYPE num_hashes_per_seed, typedefs::K_TYPE k, size_t pos=0)
Definition nthash.hpp:378
SeedNtHash(const char *seq, size_t seq_len, const std::vector< std::string > &seeds, typedefs::NUM_HASHES_TYPE num_hashes_per_seed, typedefs::K_TYPE k, size_t pos=0)
bool peek_back(char char_in)
uint64_t * get_forward_hash() const
Definition nthash.hpp:494
const uint64_t * hashes() const
Definition nthash.hpp:460
unsigned get_hash_num() const
Definition nthash.hpp:473
SeedNtHash(const char *seq, size_t seq_len, const std::vector< std::vector< unsigned > > &seeds, typedefs::NUM_HASHES_TYPE num_hashes_per_seed, typedefs::K_TYPE k, size_t pos=0)
typedefs::K_TYPE get_k() const
Definition nthash.hpp:488
SeedNtHash(const std::string &seq, const std::vector< std::string > &seeds, typedefs::NUM_HASHES_TYPE num_hashes_per_seed, typedefs::K_TYPE k, size_t pos=0)
Definition nthash.hpp:343
uint64_t * get_reverse_hash() const
Definition nthash.hpp:500
typedefs::NUM_HASHES_TYPE get_hash_num_per_seed() const
Definition nthash.hpp:479