btllib

Public Member Functions | Friends | List of all members
btllib::NtHash Class Reference

## Public Member Functions
| NtHash (const char *seq, size_t seq_len, unsigned hash_num, unsigned k, size_t pos=0)
| NtHash (const std::string &seq, unsigned hash_num, unsigned k, size_t pos=0)
| NtHash (const NtHash &nthash)
| NtHash (NtHash &&)=default
bool | roll ()
bool | roll_back ()
bool | peek ()
bool | peek_back ()
bool | peek (char char_in)
bool | peek_back (char char_in)
void | sub (const std::vector< unsigned > &positions, const std::vector< unsigned char > &new_bases)
const uint64_t * | hashes () const
size_t | get_pos () const
bool | forward () const
unsigned | get_hash_num () const
unsigned | get_k () const
uint64_t | get_forward_hash () const
uint64_t | get_reverse_hash () const
void | change_seq (const std::string &new_seq, size_t new_pos=0)

## Friends
class | SeedNtHash

## Constructor & Destructor Documentation

## ◆ NtHash() [1/2]

btllib::NtHash::NtHash | ( | const char * | seq,
|  | size_t | seq_len,
|  | unsigned | hash_num,
|  | unsigned | k,
|  | size_t | pos = `0`
| ) |  |

Constructor.

Parameters

  seq | C string of DNA sequence to be hashed.
  seq_len | Length of seq.
  hash_num | Number of hashes to produce per k-mer.
  k | K-mer size.
  pos | Position in seq to start hashing from.

## ◆ NtHash() [2/2]

btllib::NtHash::NtHash | ( | const std::string & | seq,
|  | unsigned | hash_num,
|  | unsigned | k,
|  | size_t | pos = `0`
| ) |  |

Constructor.

Parameters

  seq | String of DNA sequence to be hashed.
  hash_num | Number of hashes to produce per k-mer.
  k | K-mer size.
  pos | Position in seq to start hashing from.

## Member Function Documentation

## ◆ get_pos()

size_t btllib::NtHash::get_pos | ( |  | ) | const
| inline

Get the position of last hashed k-mer or the k-mer to be hashed if roll() has never been called on this NtHash object.

## ◆ peek() [1/2]

bool btllib::NtHash::peek | ( |  | ) |

Peeks the hash values as if roll() was called (without advancing the NtHash object. The peeked hash values can be obtained through the hashes() method.

Returns
  true on success and false otherwise.

## ◆ peek() [2/2]

bool btllib::NtHash::peek | ( | char | char_in | ) |

Like peek(), but as if roll(char char_in) was called.

Returns
  true on success and false otherwise.

## ◆ peek_back() [1/2]

bool btllib::NtHash::peek_back | ( |  | ) |

Like peek(), but as if roll_back() was called.

Returns
  true on success and false otherwise.

## ◆ peek_back() [2/2]

bool btllib::NtHash::peek_back | ( | char | char_in | ) |

Like peek(), but as if roll_back(char char_in) was called.

Returns
  true on success and false otherwise.

## ◆ roll()

bool btllib::NtHash::roll | ( |  | ) |

Calculate the hash values of current k-mer and advance to the next k-mer. NtHash advances one nucleotide at a time until it finds a k-mer with valid characters (ACTG) and skips over those with invalid characters (non-ACTG, including N). This method must be called before hashes() is accessed, for the first and every subsequent hashed kmer. get_pos() may be called at any time to obtain the position of last hashed k-mer or the k-mer to be hashed if roll() has never been called on this NtHash object. It is important to note that the number of roll() calls is NOT necessarily equal to get_pos(), if there are N or invalid characters in the hashed sequence.

Returns
  true on success and false otherwise.

## ◆ roll_back()

bool btllib::NtHash::roll_back | ( |  | ) |

Like the roll() function, but advance backwards.

Returns
  true on success and false otherwise.

The documentation for this class was generated from the following file:

- include/btllib/nthash.hpp