generated from seqan/library-template
-
Notifications
You must be signed in to change notification settings - Fork 2
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] Track occupancy in IBF #257
Open
eseiler
wants to merge
2
commits into
seqan:main
Choose a base branch
from
eseiler:feature/dynamic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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,33 @@ | ||
// SPDX-FileCopyrightText: 2006-2024, Knut Reinert & Freie Universität Berlin | ||
// SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cassert> | ||
#include <cstddef> | ||
|
||
#include <hibf/platform.hpp> | ||
|
||
namespace seqan::hibf | ||
{ | ||
|
||
/*!\brief Returns the number of technical bins available for use. | ||
* \param[in] tmax The total number of bins. | ||
* \param[in] fraction The fraction of the total number of bins that should be empty. | ||
* \ingroup hibf | ||
* \sa https://godbolt.org/z/cMjbM39vj | ||
*/ | ||
[[nodiscard]] constexpr size_t subtract_empty_bins(size_t const tmax, double const fraction) noexcept | ||
{ | ||
// There must be at least 2 technical bins available without empty bins. | ||
// Otherwise, there would only ever be one technical bin available. | ||
if (fraction == 0.0 || tmax <= 2u) | ||
return tmax; | ||
|
||
size_t const number_of_empty_bins = std::clamp<size_t>(tmax * fraction, 1, tmax - 2); | ||
return tmax - number_of_empty_bins; | ||
} | ||
|
||
} // namespace seqan::hibf |
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 | ||||
---|---|---|---|---|---|---|
|
@@ -34,14 +34,34 @@ void insert_into_ibf(robin_hood::unordered_flat_set<uint64_t> const & kmers, | |||||
|
||||||
serial_timer local_fill_ibf_timer{}; | ||||||
local_fill_ibf_timer.start(); | ||||||
for (auto chunk : kmers | seqan::stl::views::chunk(chunk_size)) | ||||||
auto chunk_view = seqan::stl::views::chunk(kmers, chunk_size); | ||||||
for (auto && chunk : chunk_view) | ||||||
{ | ||||||
assert(chunk_number < number_of_bins); | ||||||
seqan::hibf::bin_index const bin_idx{bin_index + chunk_number}; | ||||||
++chunk_number; | ||||||
for (size_t const value : chunk) | ||||||
for (auto && value : chunk) | ||||||
ibf.emplace(value, bin_idx); | ||||||
} | ||||||
|
||||||
assert(chunk_view.size() <= number_of_bins); | ||||||
// Edge case: If there are not enough k-mers to emplace at least one value into each bin, set the occupancy of | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
// the left over bins to 1. | ||||||
// GCOVR_EXCL_START | ||||||
if (ibf.track_occupancy && chunk_view.size() < number_of_bins) | ||||||
{ | ||||||
size_t const diff = number_of_bins - chunk_view.size(); | ||||||
auto it = ibf.occupancy.begin() + bin_index + chunk_view.size(); | ||||||
assert(std::ranges::all_of(it, | ||||||
it + diff, | ||||||
[](size_t value) | ||||||
{ | ||||||
return value == 0u; | ||||||
})); | ||||||
std::ranges::fill_n(it, diff, 1u); | ||||||
} | ||||||
// GCOVR_EXCL_STOP | ||||||
|
||||||
local_fill_ibf_timer.stop(); | ||||||
fill_ibf_timer += local_fill_ibf_timer; | ||||||
} | ||||||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.