1#ifndef MOD_MINIMIZER_HPP
2#define MOD_MINIMIZER_HPP
4#include "digest/digester.hpp"
17 const char *what()
const throw() {
18 return "mod must be greater than congruence.";
46 ModMin(
const char *seq,
size_t len,
unsigned k, uint32_t mod,
47 uint32_t congruence = 0,
size_t start = 0,
49 :
Digester<P>(seq, len, k, start, minimized_h), mod(mod),
50 congruence(congruence) {
51 if (congruence >= mod) {
68 ModMin(
const std::string &seq,
unsigned k, uint32_t mod,
69 uint32_t congruence = 0,
size_t start = 0,
71 :
ModMin<P>(seq.c_str(), seq.size(), k, mod, congruence, start,
83 if (!this->is_valid_hash)
88 if ((uint32_t)this->chash % mod == congruence) {
89 vec.emplace_back(this->
get_pos());
91 }
while (this->
roll_one() && vec.size() < amount);
97 if ((uint32_t)this->fhash % mod == congruence) {
98 vec.emplace_back(this->
get_pos());
100 }
while (this->
roll_one() && vec.size() < amount);
106 if ((uint32_t)this->rhash % mod == congruence) {
107 vec.emplace_back(this->
get_pos());
109 }
while (this->
roll_one() && vec.size() < amount);
122 std::vector<std::pair<uint32_t, uint32_t>> &vec)
override {
123 if (!this->is_valid_hash)
128 if ((uint32_t)this->chash % mod == congruence) {
129 vec.emplace_back(this->
get_pos(), this->chash);
131 }
while (this->
roll_one() && vec.size() < amount);
137 if ((uint32_t)this->fhash % mod == congruence) {
138 vec.emplace_back(this->
get_pos(), this->fhash);
140 }
while (this->
roll_one() && vec.size() < amount);
146 if ((uint32_t)this->rhash % mod == congruence) {
147 vec.emplace_back(this->
get_pos(), this->rhash);
149 }
while (this->
roll_one() && vec.size() < amount);
Exception thrown when initializing a mod minimizer object where the target value after modding is gre...
Definition mod_minimizer.hpp:16
an abstract class for Digester objects.
Definition digester.hpp:75
bool roll_one()
moves the internal pointer to the next valid k-mer. Time Complexity: O(1)
Definition digester.hpp:138
MinimizedHashType get_minimized_h()
Definition digester.hpp:289
size_t get_pos()
Definition digester.hpp:177
Child class of Digester that defines a minimizer as a kmer whose hash is equal to some target value a...
Definition mod_minimizer.hpp:30
void roll_minimizer(unsigned amount, std::vector< std::pair< uint32_t, uint32_t > > &vec) override
adds up to amount of positions and hashes of minimizers into vec. Here a k-mer is considered a minimi...
Definition mod_minimizer.hpp:121
ModMin(const char *seq, size_t len, unsigned k, uint32_t mod, uint32_t congruence=0, size_t start=0, MinimizedHashType minimized_h=MinimizedHashType::CANON)
Definition mod_minimizer.hpp:46
uint32_t get_congruence()
Definition mod_minimizer.hpp:160
void roll_minimizer(unsigned amount, std::vector< uint32_t > &vec) override
adds up to amount of positions of minimizers into vec. Here a k-mer is considered a minimizer if its ...
Definition mod_minimizer.hpp:82
uint32_t get_mod()
Definition mod_minimizer.hpp:155
ModMin(const std::string &seq, unsigned k, uint32_t mod, uint32_t congruence=0, size_t start=0, MinimizedHashType minimized_h=MinimizedHashType::CANON)
Definition mod_minimizer.hpp:68
digest code.
Definition data_structure.hpp:27
MinimizedHashType
Enum values for the type of hash to minimize.
Definition digester.hpp:41