ntHash
Loading...
Searching...
No Matches
nthash::NtHash Class Reference

Public Member Functions

 NtHash (const char *seq, size_t seq_len, typedefs::NUM_HASHES_TYPE num_hashes, typedefs::K_TYPE k, size_t pos=0)
 
 NtHash (const std::string &seq, typedefs::NUM_HASHES_TYPE num_hashes, typedefs::K_TYPE k, size_t pos=0)
 
 NtHash (const NtHash &obj)
 
 NtHash (NtHash &&)=default
 
bool roll ()
 
bool roll_back ()
 
bool peek ()
 
bool peek_back ()
 
bool peek (char char_in)
 
bool peek_back (char char_in)
 
const uint64_t * hashes () const
 
size_t get_pos () const
 
typedefs::NUM_HASHES_TYPE get_hash_num () const
 
typedefs::K_TYPE get_k () const
 
uint64_t get_forward_hash () const
 
uint64_t get_reverse_hash () const
 

Constructor & Destructor Documentation

◆ NtHash() [1/2]

nthash::NtHash::NtHash ( const char *  seq,
size_t  seq_len,
typedefs::NUM_HASHES_TYPE  num_hashes,
typedefs::K_TYPE  k,
size_t  pos = 0 
)

Construct an ntHash object for k-mers.

Parameters
seqC-string containing sequence data
seq_lenLength of the sequence
num_hashesNumber of hashes to generate per k-mer
kK-mer size
posPosition in the sequence to start hashing from

◆ NtHash() [2/2]

nthash::NtHash::NtHash ( const std::string &  seq,
typedefs::NUM_HASHES_TYPE  num_hashes,
typedefs::K_TYPE  k,
size_t  pos = 0 
)
inline

Construct an ntHash object for k-mers.

Parameters
seqSequence string
num_hashesNumber of hashes to produce per k-mer
kK-mer size
posPosition in sequence to start hashing from

Member Function Documentation

◆ get_forward_hash()

uint64_t nthash::NtHash::get_forward_hash ( ) const
inline

Get the hash value of the forward strand.

Returns
Forward hash value

◆ get_hash_num()

typedefs::NUM_HASHES_TYPE nthash::NtHash::get_hash_num ( ) const
inline

Get the number of hashes generated per k-mer.

Returns
Number of hashes per k-mer

◆ get_k()

typedefs::K_TYPE nthash::NtHash::get_k ( ) const
inline

Get the length of the k-mers.

Returns
k

◆ get_pos()

size_t nthash::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.

Returns
Position of the most recently hashed k-mer's first base-pair

◆ get_reverse_hash()

uint64_t nthash::NtHash::get_reverse_hash ( ) const
inline

Get the hash value of the reverse strand.

Returns
Reverse-complement hash value

◆ hashes()

const uint64_t * nthash::NtHash::hashes ( ) const
inline

Get the array of current canonical hash values (length = get_hash_num())

Returns
Pointer to the hash array

◆ peek() [1/2]

bool nthash::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 nthash::NtHash::peek ( char  char_in)

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

Returns
true on success and false otherwise

◆ peek_back() [1/2]

bool nthash::NtHash::peek_back ( )

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

Returns
true on success and false otherwise

◆ peek_back() [2/2]

bool nthash::NtHash::peek_back ( char  char_in)

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

Returns
true on success and false otherwise

◆ roll()

bool nthash::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 (ACGTU) and skips over those with invalid characters (non-ACGTU, 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's or invalid characters in the hashed sequence.

Returns
true on success and false otherwise

◆ roll_back()

bool nthash::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: