Go to the documentation of this file. 1 #ifndef BIFROST_KMER_HPP
2 #define BIFROST_KMER_HPP
5 #define MAX_KMER_SIZE 32
30 class CompressedSequence;
42 friend class CompressedSequence;
60 explicit Kmer(
const char* s);
70 inline void set_empty() {
for (
size_t i = 0; i < MAX_K/32; ++i) longs[i] = 0xffffffffffffffff; }
76 for (
size_t i = 0; i < MAX_K/32; ++i) longs[i] = 0xffffffffffffffff;
80 bool operator<(
const Kmer& o)
const;
100 BFG_INLINE uint64_t
hash(
const uint64_t seed = 0)
const {
102 return (uint64_t)XXH64((
const void *)bytes, MAX_K/4, seed);
150 bool setChar(
const size_t offset,
const char b);
168 bool write(std::ostream& stream_out)
const;
176 bool read(std::istream& stream_in);
182 static void set_k(
const unsigned int _k);
184 static unsigned int k;
188 static const unsigned int MAX_K = MAX_KMER_SIZE;
192 uint8_t bytes[MAX_K/4];
193 uint64_t longs[MAX_K/32];
196 void set_kmer(
const char *s);
198 Kmer getLink(
const size_t index)
const;
200 std::string getBinary()
const;
206 size_t operator()(
const Kmer& km)
const {
221 Minimizer(
const Minimizer& o);
222 explicit Minimizer(
const char *s);
224 Minimizer& operator=(
const Minimizer& o);
229 bool operator<(
const Minimizer& o)
const;
230 bool operator==(
const Minimizer& o)
const;
231 bool operator!=(
const Minimizer& o)
const;
233 void set_minimizer(
const char *s);
235 BFG_INLINE uint64_t hash(
const uint64_t seed = 0)
const {
237 return (uint64_t)XXH64((
const void *)bytes, MAX_G/4, seed);
241 Minimizer twin()
const;
242 Minimizer rep()
const;
244 Minimizer getLink(
const size_t index)
const;
246 Minimizer forwardBase(
const char b)
const;
247 Minimizer backwardBase(
const char b)
const;
249 std::string getBinary()
const;
251 void toString(
char *s)
const;
252 std::string toString()
const;
255 static void set_g(
unsigned int _g);
257 static const unsigned int MAX_G = MAX_KMER_SIZE;
258 static unsigned int g;
265 uint8_t bytes[MAX_G/4];
266 uint64_t longs[MAX_G/32];
284 struct MinimizerHash {
286 size_t operator()(
const Minimizer& minz)
const {
293 #endif // BFG_KMER_HPP
std::string toString() const
Get the string of a k-mer.
bool setChar(const size_t offset, const char b)
Set a character at a given position in a k-mer.
uint64_t hash(const uint64_t seed=0) const
Get the hash of a k-mer.
Definition: Kmer.hpp:100
Kmer & operator=(const Kmer &o)
Copy assignment operator (copy a k-mer).
Interface to store and manipulate k-mers.
Definition: Kmer.hpp:40
static void set_k(const unsigned int _k)
Set the length of k-mers.
void selfForwardBase(const char b)
Shift the current k-mer of one base on the left with one new character on the right.
void toString(char *s) const
Get the string of a k-mer.
bool operator==(const Kmer &o) const
Equality comparison operator.
void set_empty()
Set a k-mer as "empty".
Definition: Kmer.hpp:70
bool read(std::istream &stream_in)
Read a k-mer (binary) from a stream.
bool write(std::ostream &stream_out) const
Write a k-mer (binary) to a stream.
Kmer rep() const
Get the canonical k-mer (lexicographically smallest between a k-mer and its reverse-complement).
void set_deleted()
Set a k-mer as "deleted".
Definition: Kmer.hpp:74
Kmer(const Kmer &o)
Copy constructor (copy a k-mer).
bool operator!=(const Kmer &o) const
Inequality comparison operator.
Kmer backwardBase(const char b) const
Get a new k-mer which is the shift of the current k-mer of one base on the right with one new charact...
char getChar(const size_t offset) const
Get the character at a given position in a k-mer.
Kmer forwardBase(const char b) const
Get a new k-mer which is the shift of the current k-mer of one base on the left with one new characte...
Kmer()
Constructor (initialize a k-mer with 'A' k times).
Kmer(const char *s)
Constructor.
Kmer twin() const
Get the reverse-complement of a k-mer.