-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] counting_agent for the interleaved bloom filter #2373
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <seqan3/alphabet/nucleotide/dna4.hpp> | ||
#include <seqan3/core/debug_stream.hpp> | ||
#include <seqan3/range/views/kmer_hash.hpp> | ||
#include <seqan3/search/dream_index/interleaved_bloom_filter.hpp> | ||
|
||
using seqan3::operator""_dna4; | ||
|
||
int main() | ||
{ | ||
seqan3::interleaved_bloom_filter ibf{seqan3::bin_count{8u}, | ||
seqan3::bin_size{8192u}, | ||
seqan3::hash_function_count{2u}}; | ||
|
||
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] | ||
} |
18 changes: 18 additions & 0 deletions
18
test/snippet/search/dream_index/counting_agent_construction.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <seqan3/search/dream_index/interleaved_bloom_filter.hpp> | ||
|
||
int main() | ||
{ | ||
// Construct an Interleaved Bloom Filter to be used with the counting_agent. | ||
seqan3::interleaved_bloom_filter ibf{seqan3::bin_count{43u}, | ||
seqan3::bin_size{8192u}, | ||
seqan3::hash_function_count{3}}; | ||
|
||
// The counting_agent can now be constructed by calling `counting_agent` on the Interleaved Bloom Filter. | ||
auto agent = ibf.counting_agent(); | ||
|
||
// Calling `increase_bin_number_to` invalidates the agent. | ||
ibf.increase_bin_number_to(seqan3::bin_count{60u}); | ||
|
||
// So make sure to construct a new counting_agent. | ||
agent = ibf.counting_agent(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that we don't need any
!\brief
here