counting_bloom_filter.hpp
#ifndef BTLLIB_COUNTING_BLOOM_FILTER_HPP
#define BTLLIB_COUNTING_BLOOM_FILTER_HPP
#include "btllib/bloom_filter.hpp"
#include "btllib/counting_bloom_filter.hpp"
#include "btllib/nthash.hpp"
#include "btllib/status.hpp"
#include "cpptoml.h"
#include <atomic>
#include <cmath>
#include <cstdint>
#include <fstream>
#include <limits>
#include <memory>
#include <string>
#include <vector>
namespace btllib {
// NOLINTNEXTLINE(clang-diagnostic-unneeded-internal-declaration)
static const char* const COUNTING_BLOOM_FILTER_SIGNATURE =
"[BTLCountingBloomFilter_v5]";
// NOLINTNEXTLINE(clang-diagnostic-unneeded-internal-declaration)
static const char* const KMER_COUNTING_BLOOM_FILTER_SIGNATURE =
"[BTLKmerCountingBloomFilter_v5]";
template<typename T>
class KmerCountingBloomFilter;
template<typename T>
class CountingBloomFilter
{
public:
CountingBloomFilter() {}
CountingBloomFilter(size_t bytes,
unsigned hash_num,
std::string hash_fn = "");
explicit CountingBloomFilter(const std::string& path);
CountingBloomFilter(const CountingBloomFilter&) = delete;
CountingBloomFilter(CountingBloomFilter&&) = delete;
CountingBloomFilter& operator=(const CountingBloomFilter&) = delete;
CountingBloomFilter& operator=(CountingBloomFilter&&) = delete;
void insert(const uint64_t* hashes);
void insert(const std::vector<uint64_t>& hashes) { insert(hashes.data()); }
T contains(const uint64_t* hashes) const;
T contains(const std::vector<uint64_t>& hashes) const
{
return contains(hashes.data());
}
T contains_insert(const uint64_t* hashes);
T contains_insert(const std::vector<uint64_t>& hashes)
{
return contains_insert(hashes.data());
}
T insert_contains(const uint64_t* hashes);
T insert_contains(const std::vector<uint64_t>& hashes)
{
return insert_contains(hashes.data());
}
T insert_thresh_contains(const uint64_t* hashes, T threshold);
T insert_thresh_contains(const std::vector<uint64_t>& hashes,
const T threshold)
{
return insert_thresh_contains(hashes.data(), threshold);
}
T contains_insert_thresh(const uint64_t* hashes, T threshold);
T contains_insert_thresh(const std::vector<uint64_t>& hashes,
const T threshold)
{
return contains_insert_thresh(hashes.data(), threshold);
}
size_t get_bytes() const { return bytes; }
uint64_t get_pop_cnt(T threshold = 1) const;
double get_occupancy(T threshold = 1) const;
unsigned get_hash_num() const { return hash_num; }
double get_fpr(T threshold = 1) const;
const std::string& get_hash_fn() const { return hash_fn; }
void save(const std::string& path);
static bool is_bloom_file(const std::string& path)
{
return btllib::BloomFilter::check_file_signature(
path, COUNTING_BLOOM_FILTER_SIGNATURE);
}
private:
CountingBloomFilter(const std::shared_ptr<BloomFilterInitializer>& bfi);
void insert(const uint64_t* hashes, T min_val);
friend class KmerCountingBloomFilter<T>;
size_t bytes = 0;
size_t array_size = 0;
unsigned hash_num = 0;
std::string hash_fn;
std::unique_ptr<std::atomic<T>[]> array;
};
template<typename T>
class KmerCountingBloomFilter
{
public:
KmerCountingBloomFilter() {}
KmerCountingBloomFilter(size_t bytes, unsigned hash_num, unsigned k);
explicit KmerCountingBloomFilter(const std::string& path);
KmerCountingBloomFilter(const KmerCountingBloomFilter&) = delete;
KmerCountingBloomFilter(KmerCountingBloomFilter&&) = delete;
KmerCountingBloomFilter& operator=(const KmerCountingBloomFilter&) = delete;
KmerCountingBloomFilter& operator=(KmerCountingBloomFilter&&) = delete;
void insert(const char* seq, size_t seq_len);
void insert(const std::string& seq) { insert(seq.c_str(), seq.size()); }
void insert(const uint64_t* hashes) { counting_bloom_filter.insert(hashes); }
void insert(const std::vector<uint64_t>& hashes)
{
counting_bloom_filter.insert(hashes);
}
uint64_t contains(const char* seq, size_t seq_len) const;
uint64_t contains(const std::string& seq) const
{
return contains(seq.c_str(), seq.size());
}
T contains(const uint64_t* hashes) const
{
return counting_bloom_filter.contains(hashes);
}
T contains(const std::vector<uint64_t>& hashes) const
{
return counting_bloom_filter.contains(hashes);
}
T contains_insert(const char* seq, size_t seq_len);
T contains_insert(const std::string& seq)
{
return contains_insert(seq.c_str(), seq.size());
}
T contains_insert(const uint64_t* hashes)
{
return counting_bloom_filter.contains_insert(hashes);
}
T contains_insert(const std::vector<uint64_t>& hashes)
{
return counting_bloom_filter.contains_insert(hashes);
}
T insert_contains(const char* seq, size_t seq_len);
T insert_contains(const std::string& seq)
{
return insert_contains(seq.c_str(), seq.size());
}
T insert_contains(const uint64_t* hashes)
{
return counting_bloom_filter.insert_contains(hashes);
}
T insert_contains(const std::vector<uint64_t>& hashes)
{
return counting_bloom_filter.insert_contains(hashes);
}
T insert_thresh_contains(const char* seq, size_t seq_len, T threshold);
T insert_thresh_contains(const std::string& seq, const T threshold)
{
return insert_thresh_contains(seq.c_str(), seq.size(), threshold);
}
T insert_thresh_contains(const uint64_t* hashes, const T threshold)
{
return counting_bloom_filter.insert_thresh_contains(hashes, threshold);
}
T insert_thresh_contains(const std::vector<uint64_t>& hashes,
const T threshold)
{
return counting_bloom_filter.insert_thresh_contains(hashes, threshold);
}
T contains_insert_thresh(const char* seq, size_t seq_len, T threshold);
T contains_insert_thresh(const std::string& seq, const T threshold)
{
return contains_insert_thresh(seq.c_str(), seq.size(), threshold);
}
T contains_insert_thresh(const uint64_t* hashes, const T threshold)
{
return counting_bloom_filter.contains_insert_thresh(hashes, threshold);
}
T contains_insert_thresh(const std::vector<uint64_t>& hashes,
const T threshold)
{
return counting_bloom_filter.contains_insert_thresh(hashes, threshold);
}
size_t get_bytes() const { return counting_bloom_filter.get_bytes(); }
uint64_t get_pop_cnt(T threshold = 1) const
{
return counting_bloom_filter.get_pop_cnt(threshold);
}
double get_occupancy(T threshold = 1) const
{
return counting_bloom_filter.get_occupancy(threshold);
}
unsigned get_hash_num() const { return counting_bloom_filter.get_hash_num(); }
double get_fpr(T threshold = 1) const
{
return counting_bloom_filter.get_fpr(threshold);
}
unsigned get_k() const { return k; }
const std::string& get_hash_fn() const
{
return counting_bloom_filter.get_hash_fn();
}
CountingBloomFilter<T>& get_counting_bloom_filter()
{
return counting_bloom_filter;
}
void save(const std::string& path);
static bool is_bloom_file(const std::string& path)
{
return btllib::BloomFilter::check_file_signature(
path, KMER_COUNTING_BLOOM_FILTER_SIGNATURE);
}
private:
KmerCountingBloomFilter(const std::shared_ptr<BloomFilterInitializer>& bfi);
unsigned k = 0;
CountingBloomFilter<T> counting_bloom_filter;
};
using CountingBloomFilter8 = CountingBloomFilter<uint8_t>;
using CountingBloomFilter16 = CountingBloomFilter<uint16_t>;
using CountingBloomFilter32 = CountingBloomFilter<uint32_t>;
using KmerCountingBloomFilter8 = KmerCountingBloomFilter<uint8_t>;
using KmerCountingBloomFilter16 = KmerCountingBloomFilter<uint16_t>;
using KmerCountingBloomFilter32 = KmerCountingBloomFilter<uint32_t>;
template<typename T>
inline CountingBloomFilter<T>::CountingBloomFilter(size_t bytes,
unsigned hash_num,
std::string hash_fn)
: bytes(
size_t(std::ceil(double(bytes) / sizeof(uint64_t)) * sizeof(uint64_t)))
, array_size(get_bytes() / sizeof(array[0]))
, hash_num(hash_num)
, hash_fn(std::move(hash_fn))
, array(new std::atomic<T>[array_size])
{
check_error(bytes == 0, "CountingBloomFilter: memory budget must be >0!");
check_error(hash_num == 0,
"CountingBloomFilter: number of hash values must be >0!");
check_error(
hash_num > MAX_HASH_VALUES,
"CountingBloomFilter: number of hash values cannot be over 1024!");
check_warning(sizeof(uint8_t) != sizeof(std::atomic<uint8_t>),
"Atomic primitives take extra memory. CountingBloomFilter will "
"have less than " +
std::to_string(bytes) + " for bit array.");
std::memset((void*)array.get(), 0, array_size * sizeof(array[0]));
}
/*
* Assumes min_count is not std::numeric_limits<T>::max()
*/
template<typename T>
inline void
CountingBloomFilter<T>::insert(const uint64_t* hashes, T min_val)
{
// Update flag to track if increment is done on at least one counter
bool update_done = false;
T new_val, tmp_min_val;
while (true) {
new_val = min_val + 1;
for (size_t i = 0; i < hash_num; ++i) {
tmp_min_val = min_val;
update_done = array[hashes[i] % array_size].compare_exchange_strong(
tmp_min_val, new_val);
}
if (update_done ||
(min_val = contains(hashes)) == std::numeric_limits<T>::max()) {
break;
}
}
}
template<typename T>
inline void
CountingBloomFilter<T>::insert(const uint64_t* hashes)
{
contains_insert(hashes);
}
template<typename T>
inline T
CountingBloomFilter<T>::contains(const uint64_t* hashes) const
{
T min = array[hashes[0] % array_size];
for (size_t i = 1; i < hash_num; ++i) {
const size_t idx = hashes[i] % array_size;
if (array[idx] < min) {
min = array[idx];
}
}
return min;
}
template<typename T>
inline T
CountingBloomFilter<T>::contains_insert(const uint64_t* hashes)
{
const auto count = contains(hashes);
if (count < std::numeric_limits<T>::max()) {
insert(hashes, count);
}
return count;
}
template<typename T>
inline T
CountingBloomFilter<T>::insert_contains(const uint64_t* hashes)
{
const auto count = contains(hashes);
if (count < std::numeric_limits<T>::max()) {
insert(hashes, count);
return count + 1;
}
return std::numeric_limits<T>::max();
}
template<typename T>
inline T
CountingBloomFilter<T>::insert_thresh_contains(const uint64_t* hashes,
const T threshold)
{
const auto count = contains(hashes);
if (count < threshold) {
insert(hashes, count);
return count + 1;
}
return count;
}
template<typename T>
inline T
CountingBloomFilter<T>::contains_insert_thresh(const uint64_t* hashes,
const T threshold)
{
const auto count = contains(hashes);
if (count < threshold) {
insert(hashes, count);
}
return count;
}
template<typename T>
inline uint64_t
CountingBloomFilter<T>::get_pop_cnt(const T threshold) const
{
uint64_t pop_cnt = 0;
// OpenMP make up your mind man. Using default(none) here causes errors on
// some compilers and not others.
// NOLINTNEXTLINE(openmp-use-default-none,-warnings-as-errors)
#pragma omp parallel for reduction(+ : pop_cnt)
for (size_t i = 0; i < array_size; ++i) {
if (array[i] >= threshold) {
++pop_cnt;
}
}
return pop_cnt;
}
template<typename T>
inline double
CountingBloomFilter<T>::get_occupancy(const T threshold) const
{
return double(get_pop_cnt(threshold)) / double(array_size);
}
template<typename T>
inline double
CountingBloomFilter<T>::get_fpr(const T threshold) const
{
return std::pow(get_occupancy(threshold), double(hash_num));
}
template<typename T>
inline CountingBloomFilter<T>::CountingBloomFilter(const std::string& path)
: CountingBloomFilter<T>::CountingBloomFilter(
std::make_shared<BloomFilterInitializer>(path,
COUNTING_BLOOM_FILTER_SIGNATURE))
{}
template<typename T>
inline CountingBloomFilter<T>::CountingBloomFilter(
const std::shared_ptr<BloomFilterInitializer>& bfi)
: bytes(*bfi->table->get_as<decltype(bytes)>("bytes"))
, array_size(bytes / sizeof(array[0]))
, hash_num(*(bfi->table->get_as<decltype(hash_num)>("hash_num")))
, hash_fn(bfi->table->contains("hash_fn")
? *(bfi->table->get_as<decltype(hash_fn)>("hash_fn"))
: "")
, array(new std::atomic<T>[array_size])
{
check_warning(sizeof(uint8_t) != sizeof(std::atomic<uint8_t>),
"Atomic primitives take extra memory. CountingBloomFilter will "
"have less than " +
std::to_string(bytes) + " for bit array.");
const auto loaded_counter_bits =
*(bfi->table->get_as<size_t>("counter_bits"));
check_error(sizeof(array[0]) * CHAR_BIT != loaded_counter_bits,
"CountingBloomFilter" +
std::to_string(sizeof(array[0]) * CHAR_BIT) +
" tried to load a file of CountingBloomFilter" +
std::to_string(loaded_counter_bits));
bfi->ifs.read((char*)array.get(),
std::streamsize(array_size * sizeof(array[0])));
}
template<typename T>
inline void
CountingBloomFilter<T>::save(const std::string& path)
{
/* Initialize cpptoml root table
Note: Tables and fields are unordered
Ordering of table is maintained by directing the table
to the output stream immediately after completion */
auto root = cpptoml::make_table();
/* Initialize bloom filter section and insert fields
and output to ostream */
auto header = cpptoml::make_table();
header->insert("bytes", get_bytes());
header->insert("hash_num", get_hash_num());
if (!hash_fn.empty()) {
header->insert("hash_fn", hash_fn);
}
header->insert("counter_bits", size_t(sizeof(array[0]) * CHAR_BIT));
std::string header_string = COUNTING_BLOOM_FILTER_SIGNATURE;
header_string =
header_string.substr(1, header_string.size() - 2); // Remove [ ]
root->insert(header_string, header);
BloomFilter::save(
path, *root, (char*)array.get(), array_size * sizeof(array[0]));
}
template<typename T>
inline KmerCountingBloomFilter<T>::KmerCountingBloomFilter(size_t bytes,
unsigned hash_num,
unsigned k)
: k(k)
, counting_bloom_filter(bytes, hash_num, HASH_FN)
{}
template<typename T>
inline void
KmerCountingBloomFilter<T>::insert(const char* seq, size_t seq_len)
{
NtHash nthash(seq, seq_len, get_hash_num(), get_k());
while (nthash.roll()) {
counting_bloom_filter.insert(nthash.hashes());
}
}
template<typename T>
inline uint64_t
KmerCountingBloomFilter<T>::contains(const char* seq, size_t seq_len) const
{
uint64_t sum = 0;
NtHash nthash(seq, seq_len, get_hash_num(), get_k());
while (nthash.roll()) {
sum += counting_bloom_filter.contains(nthash.hashes());
}
return sum;
}
template<typename T>
inline T
KmerCountingBloomFilter<T>::contains_insert(const char* seq, size_t seq_len)
{
uint64_t sum = 0;
NtHash nthash(seq, seq_len, get_hash_num(), get_k());
while (nthash.roll()) {
sum += counting_bloom_filter.contains_insert(nthash.hashes());
}
return sum;
}
template<typename T>
inline T
KmerCountingBloomFilter<T>::insert_contains(const char* seq, size_t seq_len)
{
uint64_t sum = 0;
NtHash nthash(seq, seq_len, get_hash_num(), get_k());
while (nthash.roll()) {
sum += counting_bloom_filter.insert_contains(nthash.hashes());
}
return sum;
}
template<typename T>
inline T
KmerCountingBloomFilter<T>::insert_thresh_contains(const char* seq,
size_t seq_len,
const T threshold)
{
uint64_t sum = 0;
NtHash nthash(seq, seq_len, get_hash_num(), get_k());
while (nthash.roll()) {
sum +=
counting_bloom_filter.insert_thresh_contains(nthash.hashes(), threshold);
}
return sum;
}
template<typename T>
inline T
KmerCountingBloomFilter<T>::contains_insert_thresh(const char* seq,
size_t seq_len,
const T threshold)
{
uint64_t sum = 0;
NtHash nthash(seq, seq_len, get_hash_num(), get_k());
while (nthash.roll()) {
sum +=
counting_bloom_filter.contains_insert_thresh(nthash.hashes(), threshold);
}
return sum;
}
template<typename T>
inline KmerCountingBloomFilter<T>::KmerCountingBloomFilter(
const std::string& path)
: KmerCountingBloomFilter<T>::KmerCountingBloomFilter(
std::make_shared<BloomFilterInitializer>(
path,
KMER_COUNTING_BLOOM_FILTER_SIGNATURE))
{}
template<typename T>
inline KmerCountingBloomFilter<T>::KmerCountingBloomFilter(
const std::shared_ptr<BloomFilterInitializer>& bfi)
: k(*(bfi->table->get_as<decltype(k)>("k")))
, counting_bloom_filter(bfi)
{
check_error(counting_bloom_filter.hash_fn != HASH_FN,
"KmerCountingBloomFilter: loaded hash function (" +
counting_bloom_filter.hash_fn +
") is different from the one used by default (" + HASH_FN +
").");
}
template<typename T>
inline void
KmerCountingBloomFilter<T>::save(const std::string& path)
{
/* Initialize cpptoml root table
Note: Tables and fields are unordered
Ordering of table is maintained by directing the table
to the output stream immediately after completion */
auto root = cpptoml::make_table();
/* Initialize bloom filter section and insert fields
and output to ostream */
auto header = cpptoml::make_table();
header->insert("bytes", get_bytes());
header->insert("hash_num", get_hash_num());
header->insert("hash_fn", get_hash_fn());
header->insert("counter_bits",
size_t(sizeof(counting_bloom_filter.array[0]) * CHAR_BIT));
header->insert("k", k);
std::string header_string = KMER_COUNTING_BLOOM_FILTER_SIGNATURE;
header_string =
header_string.substr(1, header_string.size() - 2); // Remove [ ]
root->insert(header_string, header);
BloomFilter::save(path,
*root,
(char*)counting_bloom_filter.array.get(),
counting_bloom_filter.array_size *
sizeof(counting_bloom_filter.array[0]));
}
} // namespace btllib
#endif
btllib::BloomFilter::save
void save(const std::string &path)
btllib::CountingBloomFilter
Definition: counting_bloom_filter.hpp:39
btllib::CountingBloomFilter::insert_thresh_contains
T insert_thresh_contains(const std::vector< uint64_t > &hashes, const T threshold)
Definition: counting_bloom_filter.hpp:175
btllib::CountingBloomFilter::insert
void insert(const std::vector< uint64_t > &hashes)
Definition: counting_bloom_filter.hpp:82
btllib::CountingBloomFilter::get_occupancy
double get_occupancy(T threshold=1) const
Definition: counting_bloom_filter.hpp:793
btllib::CountingBloomFilter::get_hash_fn
const std::string & get_hash_fn() const
Definition: counting_bloom_filter.hpp:226
btllib::CountingBloomFilter::contains_insert
T contains_insert(const uint64_t *hashes)
Definition: counting_bloom_filter.hpp:728
btllib::CountingBloomFilter::is_bloom_file
static bool is_bloom_file(const std::string &path)
Definition: counting_bloom_filter.hpp:240
btllib::CountingBloomFilter::get_fpr
double get_fpr(T threshold=1) const
Definition: counting_bloom_filter.hpp:800
btllib::CountingBloomFilter::get_pop_cnt
uint64_t get_pop_cnt(T threshold=1) const
Definition: counting_bloom_filter.hpp:776
btllib::CountingBloomFilter::insert_contains
T insert_contains(const std::vector< uint64_t > &hashes)
Definition: counting_bloom_filter.hpp:146
btllib::CountingBloomFilter::save
void save(const std::string &path)
Definition: counting_bloom_filter.hpp:840
btllib::CountingBloomFilter::contains_insert_thresh
T contains_insert_thresh(const uint64_t *hashes, T threshold)
Definition: counting_bloom_filter.hpp:764
btllib::CountingBloomFilter::contains
T contains(const std::vector< uint64_t > &hashes) const
Definition: counting_bloom_filter.hpp:101
btllib::CountingBloomFilter::get_bytes
size_t get_bytes() const
Definition: counting_bloom_filter.hpp:210
btllib::CountingBloomFilter::get_hash_num
unsigned get_hash_num() const
Definition: counting_bloom_filter.hpp:217
btllib::CountingBloomFilter::contains
T contains(const uint64_t *hashes) const
Definition: counting_bloom_filter.hpp:714
btllib::CountingBloomFilter::CountingBloomFilter
CountingBloomFilter()
Definition: counting_bloom_filter.hpp:43
btllib::CountingBloomFilter::insert_contains
T insert_contains(const uint64_t *hashes)
Definition: counting_bloom_filter.hpp:739
btllib::CountingBloomFilter::insert
void insert(const uint64_t *hashes)
Definition: counting_bloom_filter.hpp:707
btllib::CountingBloomFilter::contains_insert_thresh
T contains_insert_thresh(const std::vector< uint64_t > &hashes, const T threshold)
Definition: counting_bloom_filter.hpp:203
btllib::CountingBloomFilter::insert_thresh_contains
T insert_thresh_contains(const uint64_t *hashes, T threshold)
Definition: counting_bloom_filter.hpp:751
btllib::CountingBloomFilter::contains_insert
T contains_insert(const std::vector< uint64_t > &hashes)
Definition: counting_bloom_filter.hpp:123
btllib::KmerCountingBloomFilter
Definition: counting_bloom_filter.hpp:267
btllib::KmerCountingBloomFilter::contains
uint64_t contains(const char *seq, size_t seq_len) const
Definition: counting_bloom_filter.hpp:886
btllib::KmerCountingBloomFilter::insert_contains
T insert_contains(const std::vector< uint64_t > &hashes)
Definition: counting_bloom_filter.hpp:465
btllib::KmerCountingBloomFilter::insert_thresh_contains
T insert_thresh_contains(const std::vector< uint64_t > &hashes, const T threshold)
Definition: counting_bloom_filter.hpp:523
btllib::KmerCountingBloomFilter::save
void save(const std::string &path)
Definition: counting_bloom_filter.hpp:974
btllib::KmerCountingBloomFilter::get_counting_bloom_filter
CountingBloomFilter< T > & get_counting_bloom_filter()
Definition: counting_bloom_filter.hpp:618
btllib::KmerCountingBloomFilter::insert_contains
T insert_contains(const char *seq, size_t seq_len)
Definition: counting_bloom_filter.hpp:910
btllib::KmerCountingBloomFilter::insert_thresh_contains
T insert_thresh_contains(const std::string &seq, const T threshold)
Definition: counting_bloom_filter.hpp:491
btllib::KmerCountingBloomFilter::contains_insert_thresh
T contains_insert_thresh(const uint64_t *hashes, const T threshold)
Definition: counting_bloom_filter.hpp:566
btllib::KmerCountingBloomFilter::insert_thresh_contains
T insert_thresh_contains(const char *seq, size_t seq_len, T threshold)
Definition: counting_bloom_filter.hpp:922
btllib::KmerCountingBloomFilter::contains
T contains(const uint64_t *hashes) const
Definition: counting_bloom_filter.hpp:358
btllib::KmerCountingBloomFilter::contains_insert
T contains_insert(const uint64_t *hashes)
Definition: counting_bloom_filter.hpp:405
btllib::KmerCountingBloomFilter::contains_insert
T contains_insert(const std::vector< uint64_t > &hashes)
Definition: counting_bloom_filter.hpp:417
btllib::KmerCountingBloomFilter::contains_insert
T contains_insert(const std::string &seq)
Definition: counting_bloom_filter.hpp:392
btllib::KmerCountingBloomFilter::get_bytes
size_t get_bytes() const
Definition: counting_bloom_filter.hpp:587
btllib::KmerCountingBloomFilter::contains_insert_thresh
T contains_insert_thresh(const char *seq, size_t seq_len, T threshold)
Definition: counting_bloom_filter.hpp:937
btllib::KmerCountingBloomFilter::insert_thresh_contains
T insert_thresh_contains(const uint64_t *hashes, const T threshold)
Definition: counting_bloom_filter.hpp:507
btllib::KmerCountingBloomFilter::contains_insert_thresh
T contains_insert_thresh(const std::vector< uint64_t > &hashes, const T threshold)
Definition: counting_bloom_filter.hpp:580
btllib::KmerCountingBloomFilter::insert_contains
T insert_contains(const std::string &seq)
Definition: counting_bloom_filter.hpp:439
btllib::KmerCountingBloomFilter::get_hash_fn
const std::string & get_hash_fn() const
Definition: counting_bloom_filter.hpp:613
btllib::KmerCountingBloomFilter::insert
void insert(const std::vector< uint64_t > &hashes)
Definition: counting_bloom_filter.hpp:323
btllib::KmerCountingBloomFilter::insert
void insert(const char *seq, size_t seq_len)
Definition: counting_bloom_filter.hpp:876
btllib::KmerCountingBloomFilter::get_occupancy
double get_occupancy(T threshold=1) const
Definition: counting_bloom_filter.hpp:594
btllib::KmerCountingBloomFilter::contains_insert
T contains_insert(const char *seq, size_t seq_len)
Definition: counting_bloom_filter.hpp:898
btllib::KmerCountingBloomFilter::get_hash_num
unsigned get_hash_num() const
Definition: counting_bloom_filter.hpp:599
btllib::KmerCountingBloomFilter::get_pop_cnt
uint64_t get_pop_cnt(T threshold=1) const
Definition: counting_bloom_filter.hpp:589
btllib::KmerCountingBloomFilter::insert_contains
T insert_contains(const uint64_t *hashes)
Definition: counting_bloom_filter.hpp:453
btllib::KmerCountingBloomFilter::get_fpr
double get_fpr(T threshold=1) const
Definition: counting_bloom_filter.hpp:606
btllib::KmerCountingBloomFilter::get_k
unsigned get_k() const
Definition: counting_bloom_filter.hpp:611
btllib::KmerCountingBloomFilter::insert
void insert(const std::string &seq)
Definition: counting_bloom_filter.hpp:308
btllib::KmerCountingBloomFilter::contains
uint64_t contains(const std::string &seq) const
Definition: counting_bloom_filter.hpp:345
btllib::KmerCountingBloomFilter::insert
void insert(const uint64_t *hashes)
Definition: counting_bloom_filter.hpp:316
btllib::KmerCountingBloomFilter::contains_insert_thresh
T contains_insert_thresh(const std::string &seq, const T threshold)
Definition: counting_bloom_filter.hpp:550
btllib::KmerCountingBloomFilter::is_bloom_file
static bool is_bloom_file(const std::string &path)
Definition: counting_bloom_filter.hpp:636
btllib::KmerCountingBloomFilter::KmerCountingBloomFilter
KmerCountingBloomFilter()
Definition: counting_bloom_filter.hpp:271
btllib::KmerCountingBloomFilter::contains
T contains(const std::vector< uint64_t > &hashes) const
Definition: counting_bloom_filter.hpp:370
btllib::NtHash
Definition: nthash.hpp:54
btllib::NtHash::roll
bool roll()
btllib
Definition: bloom_filter.hpp:16
btllib::check_error
void check_error(bool condition, const std::string &msg)
btllib::check_warning
void check_warning(bool condition, const std::string &msg)