btllib
Loading...
Searching...
No Matches
btllib::KmerBloomFilter Class Reference

#include <bloom_filter.hpp>

Public Member Functions

 KmerBloomFilter ()
 
 KmerBloomFilter (size_t bytes, unsigned hash_num, unsigned k)
 
 KmerBloomFilter (const std::string &path)
 
 KmerBloomFilter (const KmerBloomFilter &)=delete
 
 KmerBloomFilter (KmerBloomFilter &&)=delete
 
KmerBloomFilteroperator= (const KmerBloomFilter &)=delete
 
KmerBloomFilteroperator= (KmerBloomFilter &&)=delete
 
void insert (const char *seq, size_t seq_len)
 
void insert (const std::string &seq)
 
void insert (const uint64_t *hashes)
 
void insert (const std::vector< uint64_t > &hashes)
 
unsigned contains (const char *seq, size_t seq_len) const
 
unsigned contains (const std::string &seq) const
 
bool contains (const uint64_t *hashes) const
 
bool contains (const std::vector< uint64_t > &hashes) const
 
unsigned contains_insert (const char *seq, size_t seq_len)
 
unsigned contains_insert (const std::string &seq)
 
bool contains_insert (const uint64_t *hashes)
 
bool contains_insert (const std::vector< uint64_t > &hashes)
 
size_t get_bytes () const
 
uint64_t get_pop_cnt () const
 
double get_occupancy () const
 
unsigned get_hash_num () const
 
double get_fpr () const
 
unsigned get_k () const
 
const std::string & get_hash_fn () const
 
BloomFilterget_bloom_filter ()
 
void save (const std::string &path)
 

Static Public Member Functions

static bool is_bloom_file (const std::string &path)
 

Friends

class SeedBloomFilter
 

Detailed Description

Bloom filter data structure stores k-mers.

Constructor & Destructor Documentation

◆ KmerBloomFilter() [1/3]

btllib::KmerBloomFilter::KmerBloomFilter ( )
inline

Construct a dummy Kmer Bloom filter (e.g. as a default argument).

◆ KmerBloomFilter() [2/3]

btllib::KmerBloomFilter::KmerBloomFilter ( size_t bytes,
unsigned hash_num,
unsigned k )

Construct an empty Kmer Bloom filter of given size.

Parameters
bytesFilter size in bytes.
hash_numNumber of hash values per element.
kK-mer size.

◆ KmerBloomFilter() [3/3]

btllib::KmerBloomFilter::KmerBloomFilter ( const std::string & path)
explicit

Load a Kmer Bloom filter from a file.

Parameters
pathFilepath to load from.

Member Function Documentation

◆ contains() [1/4]

unsigned btllib::KmerBloomFilter::contains ( const char * seq,
size_t seq_len ) const

Query the presence of k-mers of a sequence.

Parameters
seqSequence to k-merize.
seq_lenLength of seq.
Returns
The number of seq's k-mers found in the filter.

◆ contains() [2/4]

unsigned btllib::KmerBloomFilter::contains ( const std::string & seq) const
inline

Query the presence of k-mers of a sequence.

Parameters
seqSequence to k-merize.
Returns
The number of seq's k-mers found in the filter.

◆ contains() [3/4]

bool btllib::KmerBloomFilter::contains ( const std::vector< uint64_t > & hashes) const
inline

Check for the presence of an element's hash values.

Parameters
hashesInteger vector of hash values.

◆ contains() [4/4]

bool btllib::KmerBloomFilter::contains ( const uint64_t * hashes) const
inline

Check for the presence of an element's hash values.

Parameters
hashesInteger array of hash values. Array size should equal the hash_num argument used when the Bloom filter was constructed.

◆ contains_insert() [1/4]

unsigned btllib::KmerBloomFilter::contains_insert ( const char * seq,
size_t seq_len )

Query the presence of k-mers of a sequence and insert if missing.

Parameters
seqSequence to k-merize.
seq_lenLength of seq.
Returns
The number of seq's k-mers found in the filter before insertion.

◆ contains_insert() [2/4]

unsigned btllib::KmerBloomFilter::contains_insert ( const std::string & seq)
inline

Query the presence of k-mers of a sequence and insert if missing.

Parameters
seqSequence to k-merize.
Returns
The number of seq's k-mers found in the filter before insertion.

◆ contains_insert() [3/4]

bool btllib::KmerBloomFilter::contains_insert ( const std::vector< uint64_t > & hashes)
inline

Check for the presence of an element's hash values and insert if missing.

Parameters
hashesInteger vector of hash values.
Returns
True if present before insertion, false otherwise.

◆ contains_insert() [4/4]

bool btllib::KmerBloomFilter::contains_insert ( const uint64_t * hashes)
inline

Check for the presence of an element's hash values and insert if missing.

Parameters
hashesInteger array of hash values. Array size should equal the hash_num argument used when the Bloom filter was constructed.
Returns
True if present before insertion, false otherwise.

◆ get_bloom_filter()

BloomFilter & btllib::KmerBloomFilter::get_bloom_filter ( )
inline

Get a reference to the underlying vanilla Bloom filter.

◆ get_bytes()

size_t btllib::KmerBloomFilter::get_bytes ( ) const
inline

Get filter size in bytes.

◆ get_fpr()

double btllib::KmerBloomFilter::get_fpr ( ) const
inline

Get the query false positive rate.

◆ get_hash_fn()

const std::string & btllib::KmerBloomFilter::get_hash_fn ( ) const
inline

Get the name of the hash function used.

◆ get_hash_num()

unsigned btllib::KmerBloomFilter::get_hash_num ( ) const
inline

Get the number of hash values per element.

◆ get_k()

unsigned btllib::KmerBloomFilter::get_k ( ) const
inline

Get the k-mer size used.

◆ get_occupancy()

double btllib::KmerBloomFilter::get_occupancy ( ) const
inline

Get the fraction of the filter occupied by 1 bits.

◆ get_pop_cnt()

uint64_t btllib::KmerBloomFilter::get_pop_cnt ( ) const
inline

Get population count, i.e. the number of 1 bits in the filter.

◆ insert() [1/4]

void btllib::KmerBloomFilter::insert ( const char * seq,
size_t seq_len )

Insert a sequence's k-mers into the filter.

Parameters
seqSequence to k-merize.
seq_lenLength of seq.

◆ insert() [2/4]

void btllib::KmerBloomFilter::insert ( const std::string & seq)
inline

Insert a sequence's k-mers into the filter.

Parameters
seqSequence to k-merize.

◆ insert() [3/4]

void btllib::KmerBloomFilter::insert ( const std::vector< uint64_t > & hashes)
inline

Insert an element's hash values.

Parameters
hashesInteger vector of hash values.

◆ insert() [4/4]

void btllib::KmerBloomFilter::insert ( const uint64_t * hashes)
inline

Insert an element's hash values.

Parameters
hashesInteger array of hash values. Array size should equal the hash_num argument used when the Bloom filter was constructed.

◆ is_bloom_file()

static bool btllib::KmerBloomFilter::is_bloom_file ( const std::string & path)
inlinestatic

Check whether the file at the given path is a saved Kmer Bloom filter.

Parameters
pathFilepath to check.

◆ save()

void btllib::KmerBloomFilter::save ( const std::string & path)

Save the Bloom filter to a file that can be loaded in the future.

Parameters
pathFilepath to store filter at.

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