1#ifndef WINDOW_MINIMIZER_HPP
2#define WINDOW_MINIMIZER_HPP
4#include "data_structure.hpp"
5#include "digest/digester.hpp"
18 const char *what()
const throw() {
19 return "Number of kmers in large window cannot be 0";
46 WindowMin(
const char *seq,
size_t len,
unsigned k,
unsigned large_window,
49 :
Digester<P>(seq, len, k, start, minimized_h), ds(large_window),
50 large_window(large_window), ds_size(0), is_minimized(false) {
51 if (large_window == 0) {
66 WindowMin(
const std::string &seq,
unsigned k,
unsigned large_window,
69 :
WindowMin<P, T>(seq.c_str(), seq.size(), k, large_window, start,
83 while (ds_size + 1 < large_window and this->is_valid_hash) {
85 ds.insert(this->
get_pos(), this->chash);
88 ds.insert(this->
get_pos(), this->fhash);
90 ds.insert(this->
get_pos(), this->rhash);
97 while (this->is_valid_hash and vec.size() < amount) {
112 std::vector<std::pair<uint32_t, uint32_t>> &vec)
override {
113 amount += vec.size();
115 while (ds_size + 1 < large_window and this->is_valid_hash) {
117 ds.insert(this->
get_pos(), this->chash);
120 ds.insert(this->
get_pos(), this->fhash);
122 ds.insert(this->
get_pos(), this->rhash);
129 while (this->is_valid_hash and vec.size() < amount) {
134 void new_seq(
const char *seq,
size_t len,
size_t start)
override {
135 ds = T(large_window);
139 void new_seq(
const std::string &seq,
size_t pos)
override {
140 ds = T(large_window);
172 uint32_t large_window;
193 void roll_ds_wind(std::vector<uint32_t> &vec) {
195 ds.insert(this->
get_pos(), this->chash);
198 ds.insert(this->
get_pos(), this->fhash);
200 ds.insert(this->
get_pos(), this->rhash);
212 void roll_ds_wind(std::vector<std::pair<uint32_t, uint32_t>> &vec) {
214 ds.insert(this->
get_pos(), this->chash);
217 ds.insert(this->
get_pos(), this->fhash);
219 ds.insert(this->
get_pos(), this->rhash);
232 void check(std::vector<uint32_t> &vec) {
234 if (ds.min() != prev_mini) {
235 prev_mini = ds.min();
236 vec.emplace_back(prev_mini);
240 prev_mini = ds.min();
241 vec.emplace_back(prev_mini);
251 void check(std::vector<std::pair<uint32_t, uint32_t>> &vec) {
253 if (ds.min() != prev_mini) {
254 prev_mini = ds.min();
255 vec.emplace_back(prev_mini, ds.min_hash());
259 prev_mini = ds.min();
260 vec.emplace_back(prev_mini, ds.min_hash());
Exception thrown when initializing a Window Minimizer or Syncmer with a large window size of 0.
Definition window_minimizer.hpp:17
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
virtual void new_seq(const char *seq, size_t len, size_t start)
replaces the current sequence with the new one. It's like starting over with a completely new seqeunc...
Definition digester.hpp:209
Child class of Digester that defines a minimizer as a kmer whose hash is minimal among those in the l...
Definition window_minimizer.hpp:33
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 window_minimizer.hpp:80
void new_seq(const char *seq, size_t len, size_t start) override
replaces the current sequence with the new one. It's like starting over with a completely new seqeunc...
Definition window_minimizer.hpp:134
WindowMin(const std::string &seq, unsigned k, unsigned large_window, size_t start=0, MinimizedHashType minimized_h=MinimizedHashType::CANON)
Definition window_minimizer.hpp:66
void new_seq(const std::string &seq, size_t pos) override
replaces the current sequence with the new one. It's like starting over with a completely new sequenc...
Definition window_minimizer.hpp:139
size_t get_ds_size()
gets the size of the internal rmq data structure being used. Mainly used to help with tests (so you p...
Definition window_minimizer.hpp:157
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 window_minimizer.hpp:111
unsigned get_large_wind_kmer_am()
Definition window_minimizer.hpp:148
bool get_is_minimized()
checks if we have generated the first minimizer. Mainly used to help with tests (so you probably shou...
Definition window_minimizer.hpp:166
WindowMin(const char *seq, size_t len, unsigned k, unsigned large_window, size_t start=0, MinimizedHashType minimized_h=MinimizedHashType::CANON)
Definition window_minimizer.hpp:46
digest code.
Definition data_structure.hpp:27
MinimizedHashType
Enum values for the type of hash to minimize.
Definition digester.hpp:41