generated from seqan/library-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] separate sketching and layouting. (#129)
* [FEATURE] separate sketching and layouting. * [MISC] automatic linting * fix * doc * [MISC] automatic linting --------- Co-authored-by: seqan-actions[bot] <[email protected]>
- Loading branch information
1 parent
49c2bd5
commit 570264f
Showing
6 changed files
with
84 additions
and
42 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <cstddef> // for size_t | ||
#include <vector> // for vector | ||
|
||
#include <hibf/config.hpp> // for config | ||
#include <hibf/sketch/hyperloglog.hpp> // for hyperloglog | ||
|
||
namespace seqan::hibf::sketch | ||
{ | ||
|
||
/*!\brief Computes the kmer_counts and sketches and stores them in the respective vectors for further use. | ||
* \ingroup hibf_layout | ||
* \param[in] config The configuration to compute the layout with. | ||
* \param[in,out] kmer_counts The vector that will store the kmer counts (estimations). | ||
* \param[in,out] sketches The vector that will store the sketches. | ||
*/ | ||
void compute_sketches(config const & config, | ||
std::vector<size_t> & kmer_counts, | ||
std::vector<sketch::hyperloglog> & sketches); | ||
|
||
} // namespace seqan::hibf::sketch |
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,44 @@ | ||
#include <algorithm> // for __sort_fn, sort | ||
#include <cinttypes> // for uint64_t | ||
#include <cstddef> // for size_t | ||
#include <functional> // for identity, function | ||
#include <iterator> // for inserter | ||
#include <sstream> // for basic_stringstream, stringstream | ||
#include <utility> // for addressof | ||
#include <vector> // for vector | ||
|
||
#include <hibf/contrib/robin_hood.hpp> // for unordered_flat_set | ||
#include <hibf/sketch/compute_sketches.hpp> // for compute_sketches | ||
#include <hibf/sketch/estimate_kmer_counts.hpp> // for estimate_kmer_counts | ||
|
||
namespace seqan::hibf::sketch | ||
{ | ||
|
||
void compute_sketches(config const & config, | ||
std::vector<size_t> & kmer_counts, | ||
std::vector<sketch::hyperloglog> & sketches) | ||
{ | ||
// compute sketches | ||
sketches.resize(config.number_of_user_bins); | ||
kmer_counts.resize(config.number_of_user_bins); | ||
|
||
robin_hood::unordered_flat_set<uint64_t> kmers; | ||
#pragma omp parallel for schedule(dynamic) num_threads(config.threads) private(kmers) | ||
for (size_t i = 0; i < config.number_of_user_bins; ++i) | ||
{ | ||
seqan::hibf::sketch::hyperloglog sketch(config.sketch_bits); | ||
|
||
kmers.clear(); | ||
config.input_fn(i, std::inserter(kmers, kmers.begin())); | ||
|
||
for (auto k_hash : kmers) | ||
sketch.add(k_hash); | ||
|
||
// #pragma omp critical | ||
sketches[i] = sketch; | ||
} | ||
|
||
sketch::estimate_kmer_counts(sketches, kmer_counts); | ||
} | ||
|
||
} // namespace seqan::hibf::sketch |
570264f
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.
Successfully deployed to the following URLs:
hibf – ./
hibf.vercel.app
hibf-git-main-seqan.vercel.app
hibf-seqan.vercel.app