SeqAn3 3.4.0
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::counting_vector< value_t > Class Template Reference

A data structure that behaves like a std::vector and can be used to consolidate the results of multiple calls to seqan3::interleaved_bloom_filter::membership_agent_type::bulk_contains. More...

#include <seqan3/search/dream_index/interleaved_bloom_filter.hpp>

Inheritance diagram for seqan3::counting_vector< value_t >:

Public Member Functions

template<typename binning_bitvector_t>
requires is_binning_bitvector<binning_bitvector_t>
counting_vector & operator+= (binning_bitvector_t const &binning_bitvector)
 Bin-wise adds the bits of a seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector.
counting_vector & operator+= (counting_vector const &rhs)
 Bin-wise addition of two seqan3::counting_vectors.
template<typename binning_bitvector_t>
requires is_binning_bitvector<binning_bitvector_t>
counting_vector & operator-= (binning_bitvector_t const &binning_bitvector)
 Bin-wise subtracts the bits of a seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector.
counting_vector & operator-= (counting_vector const &rhs)
 Bin-wise substraction of two seqan3::counting_vectors.
Constructors, destructor and assignment
 counting_vector ()=default
 Defaulted.
 counting_vector (counting_vector const &)=default
 Defaulted.
counting_vector & operator= (counting_vector const &)=default
 Defaulted.
 counting_vector (counting_vector &&)=default
 Defaulted.
counting_vector & operator= (counting_vector &&)=default
 Defaulted.
 ~counting_vector ()=default
 Defaulted.
Public Member Functions inherited from std::vector< value_t >
T assign (T... args)
T at (T... args)
T back (T... args)
T begin (T... args)
T capacity (T... args)
T cbegin (T... args)
T cend (T... args)
T clear (T... args)
T crbegin (T... args)
T crend (T... args)
T data (T... args)
T emplace (T... args)
T emplace_back (T... args)
T empty (T... args)
T end (T... args)
T erase (T... args)
T front (T... args)
T get_allocator (T... args)
T insert (T... args)
T max_size (T... args)
T operator= (T... args)
T operator[] (T... args)
T pop_back (T... args)
T push_back (T... args)
T rbegin (T... args)
T rend (T... args)
T reserve (T... args)
T resize (T... args)
T shrink_to_fit (T... args)
T size (T... args)
T swap (T... args)
T vector (T... args)
T ~vector (T... args)

Detailed Description

template<std::integral value_t>
class seqan3::counting_vector< value_t >

A data structure that behaves like a std::vector and can be used to consolidate the results of multiple calls to seqan3::interleaved_bloom_filter::membership_agent_type::bulk_contains.

Template Parameters
value_tThe type of the count. Must model std::integral.

When using the seqan3::interleaved_bloom_filter::membership_agent_type::bulk_contains operation, a common use case is to add up, for example, the results for all k-mers in a query. This yields, for each bin, the number of k-mers of a query that are in the respective bin. Such information can be used to apply further filtering or abundance estimation based on the k-mer counts.

The seqan3::counting_vector offers an easy way to add up the individual seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector by offering an += operator.

The value_t template parameter should be chosen in a way that no overflow occurs if all calls to bulk_contains return a hit for a specific bin. For example, uint8_t will suffice when processing short Illumina reads, whereas long reads will require at least uint32_t.

Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
ibf.emplace(126, seqan3::bin_index{0u});
ibf.emplace(126, seqan3::bin_index{3u});
ibf.emplace(126, seqan3::bin_index{9u});
ibf.emplace(712, seqan3::bin_index{3u});
ibf.emplace(237, seqan3::bin_index{9u});
// The counting_vector must be at least as big as there are bins.
auto agent = ibf.membership_agent();
counts += agent.bulk_contains(712); // `counts` contains the number of occurrences of 712 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [0,0,0,1,0,0,0,0,0,0,0,0]
counts += agent.bulk_contains(237); // `counts` contains the number of occurrences of 712 and 237 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [0,0,0,1,0,0,0,0,0,1,0,0]
counts += agent.bulk_contains(126); // `counts` contains the number of occurrences of 712, 237 and 126 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [1,0,0,2,0,0,0,0,0,2,0,0]
counts += counts; // multiple counts can also be added together
seqan3::debug_stream << counts << '\n'; // prints [2,0,0,4,0,0,0,0,0,4,0,0]
}
A data structure that behaves like a std::vector and can be used to consolidate the results of multip...
Definition interleaved_bloom_filter.hpp:777
The IBF binning directory. A data structure that efficiently answers set-membership queries for multi...
Definition interleaved_bloom_filter.hpp:98
void emplace(size_t const value, bin_index const bin) noexcept
Inserts a value into a specific bin.
Definition interleaved_bloom_filter.hpp:261
membership_agent_type membership_agent() const
Returns a seqan3::interleaved_bloom_filter::membership_agent_type to be used for lookup.
Definition interleaved_bloom_filter.hpp:401
Provides seqan3::debug_stream and related types.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:38
Provides seqan3::interleaved_bloom_filter.
A strong type that represents the number of bins for the seqan3::interleaved_bloom_filter.
Definition bloom_filter_strong_types.hpp:31
A strong type that represents the bin index for the seqan3::interleaved_bloom_filter.
Definition bloom_filter_strong_types.hpp:52
A strong type that represents the number of bits for each bin in the seqan3::interleaved_bloom_filter...
Definition bloom_filter_strong_types.hpp:38

Member Function Documentation

◆ operator+=() [1/2]

template<std::integral value_t>
template<typename binning_bitvector_t>
requires is_binning_bitvector<binning_bitvector_t>
counting_vector & seqan3::counting_vector< value_t >::operator+= ( binning_bitvector_t const & binning_bitvector)
inline

Bin-wise adds the bits of a seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector.

Template Parameters
binning_bitvector_tThe type of the right-hand side. Must be seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector.
Parameters
binning_bitvectorThe seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector.
Attention
The counting_vector must be at least as big as binning_bitvector.

Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
ibf.emplace(126, seqan3::bin_index{0u});
ibf.emplace(126, seqan3::bin_index{3u});
ibf.emplace(126, seqan3::bin_index{9u});
ibf.emplace(712, seqan3::bin_index{3u});
ibf.emplace(237, seqan3::bin_index{9u});
// The counting_vector must be at least as big as there are bins.
auto agent = ibf.membership_agent();
counts += agent.bulk_contains(712); // `counts` contains the number of occurrences of 712 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [0,0,0,1,0,0,0,0,0,0,0,0]
counts += agent.bulk_contains(237); // `counts` contains the number of occurrences of 712 and 237 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [0,0,0,1,0,0,0,0,0,1,0,0]
counts += agent.bulk_contains(126); // `counts` contains the number of occurrences of 712, 237 and 126 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [1,0,0,2,0,0,0,0,0,2,0,0]
counts += counts; // multiple counts can also be added together
seqan3::debug_stream << counts << '\n'; // prints [2,0,0,4,0,0,0,0,0,4,0,0]
}

◆ operator+=() [2/2]

template<std::integral value_t>
counting_vector & seqan3::counting_vector< value_t >::operator+= ( counting_vector< value_t > const & rhs)
inline

Bin-wise addition of two seqan3::counting_vectors.

Parameters
rhsThe other seqan3::counting_vector.
Attention
The seqan3::counting_vector must be at least as big as rhs.

Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
ibf.emplace(126, seqan3::bin_index{0u});
ibf.emplace(126, seqan3::bin_index{3u});
ibf.emplace(126, seqan3::bin_index{9u});
ibf.emplace(712, seqan3::bin_index{3u});
ibf.emplace(237, seqan3::bin_index{9u});
// The counting_vector must be at least as big as there are bins.
auto agent = ibf.membership_agent();
counts += agent.bulk_contains(712); // `counts` contains the number of occurrences of 712 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [0,0,0,1,0,0,0,0,0,0,0,0]
counts += agent.bulk_contains(237); // `counts` contains the number of occurrences of 712 and 237 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [0,0,0,1,0,0,0,0,0,1,0,0]
counts += agent.bulk_contains(126); // `counts` contains the number of occurrences of 712, 237 and 126 in each bin.
seqan3::debug_stream << counts << '\n'; // prints [1,0,0,2,0,0,0,0,0,2,0,0]
counts += counts; // multiple counts can also be added together
seqan3::debug_stream << counts << '\n'; // prints [2,0,0,4,0,0,0,0,0,4,0,0]
}

◆ operator-=() [1/2]

template<std::integral value_t>
template<typename binning_bitvector_t>
requires is_binning_bitvector<binning_bitvector_t>
counting_vector & seqan3::counting_vector< value_t >::operator-= ( binning_bitvector_t const & binning_bitvector)
inline

Bin-wise subtracts the bits of a seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector.

Template Parameters
binning_bitvector_tThe type of the right-hand side. Must be seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector.
Parameters
binning_bitvectorThe seqan3::interleaved_bloom_filter::membership_agent_type::binning_bitvector.
Attention
The counting_vector must be at least as big as binning_bitvector.

◆ operator-=() [2/2]

template<std::integral value_t>
counting_vector & seqan3::counting_vector< value_t >::operator-= ( counting_vector< value_t > const & rhs)
inline

Bin-wise substraction of two seqan3::counting_vectors.

Parameters
rhsThe other seqan3::counting_vector.
Attention
The seqan3::counting_vector must be at least as big as rhs.

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