Gamgee
You miserable little maggot. I'll stove your head in!
|
Class that allows you to efficiently prepare multi-sample data for setting individual fields in VariantBuilder. More...
#include <variant_builder_multi_sample_vector.h>
Public Member Functions | |
VariantBuilderMultiSampleVector (const uint32_t num_samples, const uint32_t max_values_per_sample, const ELEMENT_TYPE missing_value, const ELEMENT_TYPE end_of_vector_value) | |
Construct a VariantBuilderMultiSampleVector. More... | |
VariantBuilderMultiSampleVector (const VariantBuilderMultiSampleVector &other)=default | |
VariantBuilderMultiSampleVector & | operator= (const VariantBuilderMultiSampleVector &other)=default |
VariantBuilderMultiSampleVector (VariantBuilderMultiSampleVector &&other)=default | |
VariantBuilderMultiSampleVector & | operator= (VariantBuilderMultiSampleVector &&other)=default |
~VariantBuilderMultiSampleVector ()=default | |
void | set_sample_value (const uint32_t sample_index, const uint32_t value_index, const ELEMENT_TYPE value) |
Set a single value for one sample. More... | |
void | set_sample_values (const uint32_t sample_index, const std::vector< ELEMENT_TYPE > &values) |
Set all values for one sample at once. More... | |
const std::vector< ELEMENT_TYPE > & | get_vector () const |
Get a reference to the internal one-dimensional vector used for value storage. More... | |
uint32_t | num_samples () const |
Return the number of samples whose values we are storing. More... | |
uint32_t | max_values_per_sample () const |
Return the maximum number of values across all samples. More... | |
Friends | |
class | VariantBuilder |
Class that allows you to efficiently prepare multi-sample data for setting individual fields in VariantBuilder.
For those who want higher performance than is possible with the vector<vector> individual field setters in VariantBuilder, this class is available as an alternative. Internally it uses a flattened, pre-padded one-dimensional vector that can be passed directly to htslib for encoding, and so has much better data locality and cache performance than a two-dimensional vector.
To use, first determine the number of samples and the maximum number of values per sample for the field. Then get a pre-initialized VariantBuilderMultiSampleVector from your VariantBuilder instance. Eg.,
auto multi_sample_vector = builder.get_integer_multi_sample_vector(num_samples, max_values_per_sample);
(NOTE: DO NOT INSTANTIATE THIS CLASS DIRECTLY! ALWAYS GET AN INSTANCE FROM A VARIANTBUILDER OBJECT)
This multi_sample_vector will have missing values for all samples, with appropriate padding to the maximum field width.
Then, fill in the values for each non-missing sample by invoking the set_sample_value() and/or set_sample_values() functions on your multi-sample vector (NOTE: set_sample_value() is MUCH more efficient than set_sample_values() since it doesn't require a vector construction/destruction for each call). You don't have to worry about samples with no values, since all samples start out with missing values.
Finally, pass your multi-sample vector into a VariantBuilder setter function (favoring the functions that take field indices and use move semantics for high performance). Eg.,
builder.set_integer_individual_field(field_index, std::move(multi_sample_vector));
|
inline |
Construct a VariantBuilderMultiSampleVector.
num_samples | number of samples we will be storing in this vector |
max_values_per_sample | maximum number of values across all samples |
missing_value | the BCF missing value for this type |
end_of_vector_value | the BCF end of vector value for this type |
|
default |
|
default |
|
default |
|
inline |
Get a reference to the internal one-dimensional vector used for value storage.
|
inline |
Return the maximum number of values across all samples.
|
inline |
Return the number of samples whose values we are storing.
|
default |
|
default |
|
inline |
Set a single value for one sample.
sample_index | index of the sample (from a VariantHeader lookup) |
value_index | index of the value we are setting for this sample (values for EACH sample start at index 0) |
value | value to set |
|
inline |
Set all values for one sample at once.
sample_index | index of the sample (from a VariantHeader lookup) |
values | vector of values for this sample |
|
friend |