#include <genesis/population/function/diversity_pool_processor.hpp>
Helper class to iterate over Variants and process the samples (SampleCounts), using a set of DiversityPoolCalculator instances, one for each sample.
This mainly serves as a convenience tools that takes care of iterating the samples, and also offers parallelization for larger datasets.
Definition at line 67 of file diversity_pool_processor.hpp.
Public Member Functions | |
DiversityPoolProcessor ()=default | |
Default constructor. More... | |
DiversityPoolProcessor (DiversityPoolProcessor &&)=default | |
DiversityPoolProcessor (DiversityPoolProcessor const &)=default | |
DiversityPoolProcessor (WindowAveragePolicy window_average_policy, std::shared_ptr< utils::ThreadPool > thread_pool=nullptr, size_t threading_threshold=4096) | |
Construct a processor. More... | |
~DiversityPoolProcessor ()=default | |
void | add_calculators (DiversityPoolSettings const &settings, std::vector< size_t > const &pool_sizes) |
Create and add a set of calculators for a given list of samples. More... | |
std::vector< DiversityPoolCalculator >::iterator | begin () |
std::vector< DiversityPoolCalculator > const & | calculators () const |
std::vector< DiversityPoolCalculator >::iterator | end () |
VariantFilterStats | get_filter_stats () const |
Get the sum of filter statistics of all Variants processed here. More... | |
std::vector< DiversityPoolCalculator::Result > const & | get_result () const |
Get a list of all resulting values for all samples. More... | |
template<class D > | |
std::vector< DiversityPoolCalculator::Result > const & | get_result (BaseWindow< D > const &window, std::shared_ptr< GenomeLocusSet > provided_loci) const |
Get a list of all resulting values for all samples. More... | |
DiversityPoolProcessor & | operator= (DiversityPoolProcessor &&)=default |
DiversityPoolProcessor & | operator= (DiversityPoolProcessor const &)=default |
void | process (Variant const &variant) |
void | reset () |
size_t | size () const |
std::shared_ptr< utils::ThreadPool > | thread_pool () const |
Get the thread pool used for processing, if enough sample pairs are being processed. More... | |
DiversityPoolProcessor & | thread_pool (std::shared_ptr< utils::ThreadPool > value) |
Set the thread pool used for processing, if enough sample pairs are being processed. More... | |
size_t | threading_threshold () const |
DiversityPoolProcessor & | threading_threshold (size_t value) |
Set the threshold of calculators after which the processing is done in threads. More... | |
|
default |
Default constructor.
We always want to make sure that the user provides a WindowAveragePolicy, so using this default constructor leads to an unusable instance. We provide it so that dummy processors can be constructed, but they have to be replaced by non-default-constructed instances befor usage.
|
inline |
Construct a processor.
This defaults to using the global thread pool of Options::get().global_thread_pool() If this is not desired, either pass a different thread_pool
here, or, if no thread pool is to be used, deactivate by explicitly setting the thread_pool() function here to nullptr
after construction.
Definition at line 93 of file diversity_pool_processor.hpp.
|
default |
|
default |
|
default |
|
inline |
Create and add a set of calculators for a given list of samples.
The function takes the settings, as well as a list of pool sizes, which are forwarded to a DiversityPoolCalculator each. We expect that the number of elements in pool_sizes
is the number of samples expected when calling process() later.
Definition at line 165 of file diversity_pool_processor.hpp.
|
inline |
Definition at line 302 of file diversity_pool_processor.hpp.
|
inline |
Definition at line 293 of file diversity_pool_processor.hpp.
|
inline |
Definition at line 307 of file diversity_pool_processor.hpp.
|
inline |
Get the sum of filter statistics of all Variants processed here.
With each call to process(), the filter stats are increased according to the filter status of the provided Variant. Here, we offer to read out the total of all filter tags that occurred in these Variants.
Definition at line 288 of file diversity_pool_processor.hpp.
|
inline |
Get a list of all resulting values for all samples.
This overload does not consider the window averaging, and simply returns the sum of all per site values.
Definition at line 272 of file diversity_pool_processor.hpp.
|
inline |
Get a list of all resulting values for all samples.
This always takes the window
and provided_loci
as input, even if the WindowAveragePolicy does not require it. This is meant to make sure that we at least keep track of the right things when doing any computations, and cannot forget about this. For cases where the result is needed without averaging over windows (that is, just the sum of all per site values), there is an overload of this function.
Definition at line 252 of file diversity_pool_processor.hpp.
|
default |
|
default |
|
inline |
Definition at line 199 of file diversity_pool_processor.hpp.
|
inline |
Definition at line 189 of file diversity_pool_processor.hpp.
|
inline |
Definition at line 184 of file diversity_pool_processor.hpp.
|
inline |
Get the thread pool used for processing, if enough sample pairs are being processed.
Definition at line 121 of file diversity_pool_processor.hpp.
|
inline |
Set the thread pool used for processing, if enough sample pairs are being processed.
See threading_threshold() for details on when we use the thread pool. Shall not be changed after calling process().
Definition at line 132 of file diversity_pool_processor.hpp.
|
inline |
Definition at line 138 of file diversity_pool_processor.hpp.
|
inline |
Set the threshold of calculators after which the processing is done in threads.
For small numbers of processors (small number of sample pairs), starting threads for each call of process() is more expensive than just doing the computation directly in the main thread. Hence, we only want to use the thread pool if the overhead is justified.
With this setting the number of sample pairs can be set after which we use the thread pool.
Definition at line 152 of file diversity_pool_processor.hpp.