SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::interleaved_bloom_filter< data_layout_mode_ >::counting_agent_type< value_t > Class Template Reference

Manages counting ranges of values for the seqan3::interleaved_bloom_filter. More...

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

Public Member Functions

Counting
template<std::ranges::range value_range_t>
counting_vector< value_t > const & bulk_count (value_range_t &&values) &noexcept
 Counts the occurrences in each bin for all values in a range.
 
template<std::ranges::range value_range_t>
counting_vector< value_t > const & bulk_count (value_range_t &&values) &&noexcept=delete
 Counts the occurrences in each bin for all values in a range.
 

Public Attributes

counting_vector< value_t > result_buffer
 Stores the result of bulk_count().
 

Constructors, destructor and assignment

 counting_agent_type ()=default
 Defaulted.
 
 counting_agent_type (counting_agent_type const &)=default
 Defaulted.
 
counting_agent_typeoperator= (counting_agent_type const &)=default
 Defaulted.
 
 counting_agent_type (counting_agent_type &&)=default
 Defaulted.
 
counting_agent_typeoperator= (counting_agent_type &&)=default
 Defaulted.
 
 ~counting_agent_type ()=default
 Defaulted.
 

Detailed Description

template<data_layout data_layout_mode_ = data_layout::uncompressed>
template<std::integral value_t>
class seqan3::interleaved_bloom_filter< data_layout_mode_ >::counting_agent_type< value_t >

Manages counting ranges of values for the seqan3::interleaved_bloom_filter.

Attention
Calling seqan3::interleaved_bloom_filter::increase_bin_number_to invalidates the counting_agent_type.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
using namespace seqan3::literals;
int main()
{
auto const sequence1 = "ACTGACTGACTGATC"_dna4;
auto const sequence2 = "GTGACTGACTGACTCG"_dna4;
auto const sequence3 = "AAAAAAACGATCGACA"_dna4;
auto hash_adaptor = seqan3::views::kmer_hash(seqan3::ungapped{5u});
// Insert all 5-mers of sequence1 into bin 0
for (auto && value : sequence1 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{0u});
// Insert all 5-mers of sequence2 into bin 4
for (auto && value : sequence2 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{4u});
// Insert all 5-mers of sequence3 into bin 7
for (auto && value : sequence3 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{7u});
auto agent = ibf.counting_agent();
// Count all 5-mers of sequence1 for all bins
seqan3::debug_stream << agent.bulk_count(sequence1 | hash_adaptor) << '\n'; // [11,0,0,0,9,0,0,0]
// Search for specific values
std::vector<size_t> const values{92, 1238, 812, 81273};
seqan3::debug_stream << agent.bulk_count(values) << '\n'; // [0,0,0,0,0,0,0,0]
seqan3::debug_stream << agent.bulk_count(std::views::iota(0u, 1024u)) << '\n'; // [6,0,0,0,7,0,0,10]
// The default counters are 16 bit unsigned integer.
// An optional template parameter can be used to specify the counter type
auto agent2 = ibf.counting_agent<uint8_t>();
// The returned counts are now 8 bit unsigned integers.
seqan3::debug_stream << agent.bulk_count(sequence1 | hash_adaptor) << '\n'; // [11,0,0,0,9,0,0,0]
}
The IBF binning directory. A data structure that efficiently answers set-membership queries for multi...
Definition interleaved_bloom_filter.hpp:131
void emplace(size_t const value, bin_index const bin) noexcept
Inserts a value into a specific bin.
Definition interleaved_bloom_filter.hpp:293
Provides seqan3::debug_stream and related types.
Provides seqan3::dna4, container aliases and string literals.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:37
constexpr auto kmer_hash
Computes hash values for each position of a range via a given shape.
Definition kmer_hash.hpp:766
Provides seqan3::interleaved_bloom_filter.
Provides seqan3::views::kmer_hash.
The SeqAn namespace for literals.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
A strong type that represents the number of bins for the seqan3::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:33
A strong type that represents the bin index for the seqan3::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:54
A strong type that represents the number of bits for each bin in the seqan3::interleaved_bloom_filter...
Definition interleaved_bloom_filter.hpp:40
A strong type that represents the number of hash functions for the seqan3::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:47
A strong type of underlying type uint8_t that represents the ungapped shape size.
Definition shape.hpp:22

Member Function Documentation

◆ bulk_count() [1/2]

template<data_layout data_layout_mode_ = data_layout::uncompressed>
template<std::integral value_t>
template<std::ranges::range value_range_t>
counting_vector< value_t > const & seqan3::interleaved_bloom_filter< data_layout_mode_ >::counting_agent_type< value_t >::bulk_count ( value_range_t &&  values) &&
deletenoexcept

Counts the occurrences in each bin for all values in a range.

Template Parameters
value_range_tThe type of the range of values. Must model std::ranges::input_range. The reference type must model std::unsigned_integral.
Parameters
[in]valuesThe range of values to process.
Attention
The result of this function must always be bound via reference, e.g. auto &, to prevent copying.
Sequential calls to this function invalidate the previously returned reference.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
using namespace seqan3::literals;
int main()
{
auto const sequence1 = "ACTGACTGACTGATC"_dna4;
auto const sequence2 = "GTGACTGACTGACTCG"_dna4;
auto const sequence3 = "AAAAAAACGATCGACA"_dna4;
auto hash_adaptor = seqan3::views::kmer_hash(seqan3::ungapped{5u});
// Insert all 5-mers of sequence1 into bin 0
for (auto && value : sequence1 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{0u});
// Insert all 5-mers of sequence2 into bin 4
for (auto && value : sequence2 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{4u});
// Insert all 5-mers of sequence3 into bin 7
for (auto && value : sequence3 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{7u});
auto agent = ibf.counting_agent();
// Count all 5-mers of sequence1 for all bins
seqan3::debug_stream << agent.bulk_count(sequence1 | hash_adaptor) << '\n'; // [11,0,0,0,9,0,0,0]
// Search for specific values
std::vector<size_t> const values{92, 1238, 812, 81273};
seqan3::debug_stream << agent.bulk_count(values) << '\n'; // [0,0,0,0,0,0,0,0]
seqan3::debug_stream << agent.bulk_count(std::views::iota(0u, 1024u)) << '\n'; // [6,0,0,0,7,0,0,10]
// The default counters are 16 bit unsigned integer.
// An optional template parameter can be used to specify the counter type
auto agent2 = ibf.counting_agent<uint8_t>();
// The returned counts are now 8 bit unsigned integers.
seqan3::debug_stream << agent.bulk_count(sequence1 | hash_adaptor) << '\n'; // [11,0,0,0,9,0,0,0]
}

Thread safety

Concurrent invocations of this function are not thread safe, please create a seqan3::interleaved_bloom_filter::counting_agent_type for each thread.

◆ bulk_count() [2/2]

template<data_layout data_layout_mode_ = data_layout::uncompressed>
template<std::integral value_t>
template<std::ranges::range value_range_t>
counting_vector< value_t > const & seqan3::interleaved_bloom_filter< data_layout_mode_ >::counting_agent_type< value_t >::bulk_count ( value_range_t &&  values) &
inlinenoexcept

Counts the occurrences in each bin for all values in a range.

Template Parameters
value_range_tThe type of the range of values. Must model std::ranges::input_range. The reference type must model std::unsigned_integral.
Parameters
[in]valuesThe range of values to process.
Attention
The result of this function must always be bound via reference, e.g. auto &, to prevent copying.
Sequential calls to this function invalidate the previously returned reference.

Example

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
using namespace seqan3::literals;
int main()
{
auto const sequence1 = "ACTGACTGACTGATC"_dna4;
auto const sequence2 = "GTGACTGACTGACTCG"_dna4;
auto const sequence3 = "AAAAAAACGATCGACA"_dna4;
auto hash_adaptor = seqan3::views::kmer_hash(seqan3::ungapped{5u});
// Insert all 5-mers of sequence1 into bin 0
for (auto && value : sequence1 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{0u});
// Insert all 5-mers of sequence2 into bin 4
for (auto && value : sequence2 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{4u});
// Insert all 5-mers of sequence3 into bin 7
for (auto && value : sequence3 | hash_adaptor)
ibf.emplace(value, seqan3::bin_index{7u});
auto agent = ibf.counting_agent();
// Count all 5-mers of sequence1 for all bins
seqan3::debug_stream << agent.bulk_count(sequence1 | hash_adaptor) << '\n'; // [11,0,0,0,9,0,0,0]
// Search for specific values
std::vector<size_t> const values{92, 1238, 812, 81273};
seqan3::debug_stream << agent.bulk_count(values) << '\n'; // [0,0,0,0,0,0,0,0]
seqan3::debug_stream << agent.bulk_count(std::views::iota(0u, 1024u)) << '\n'; // [6,0,0,0,7,0,0,10]
// The default counters are 16 bit unsigned integer.
// An optional template parameter can be used to specify the counter type
auto agent2 = ibf.counting_agent<uint8_t>();
// The returned counts are now 8 bit unsigned integers.
seqan3::debug_stream << agent.bulk_count(sequence1 | hash_adaptor) << '\n'; // [11,0,0,0,9,0,0,0]
}

Thread safety

Concurrent invocations of this function are not thread safe, please create a seqan3::interleaved_bloom_filter::counting_agent_type for each thread.


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