Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends | List of all members
gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE > Class Template Reference

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
 
VariantBuilderMultiSampleVectoroperator= (const VariantBuilderMultiSampleVector &other)=default
 
 VariantBuilderMultiSampleVector (VariantBuilderMultiSampleVector &&other)=default
 
VariantBuilderMultiSampleVectoroperator= (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
 

Detailed Description

template<class ELEMENT_TYPE>
class gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >

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));

Constructor & Destructor Documentation

template<class ELEMENT_TYPE>
gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::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 
)
inline

Construct a VariantBuilderMultiSampleVector.

Parameters
num_samplesnumber of samples we will be storing in this vector
max_values_per_samplemaximum number of values across all samples
missing_valuethe BCF missing value for this type
end_of_vector_valuethe BCF end of vector value for this type
Note
: DO NOT INSTANTIATE THIS CLASS DIRECTLY! ALWAYS GET AN INSTANCE FROM A VARIANTBUILDER OBJECT
template<class ELEMENT_TYPE>
gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::VariantBuilderMultiSampleVector ( const VariantBuilderMultiSampleVector< ELEMENT_TYPE > &  other)
default
template<class ELEMENT_TYPE>
gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::VariantBuilderMultiSampleVector ( VariantBuilderMultiSampleVector< ELEMENT_TYPE > &&  other)
default
template<class ELEMENT_TYPE>
gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::~VariantBuilderMultiSampleVector ( )
default

Member Function Documentation

template<class ELEMENT_TYPE>
const std::vector<ELEMENT_TYPE>& gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::get_vector ( ) const
inline

Get a reference to the internal one-dimensional vector used for value storage.

template<class ELEMENT_TYPE>
uint32_t gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::max_values_per_sample ( ) const
inline

Return the maximum number of values across all samples.

template<class ELEMENT_TYPE>
uint32_t gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::num_samples ( ) const
inline

Return the number of samples whose values we are storing.

template<class ELEMENT_TYPE>
VariantBuilderMultiSampleVector& gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::operator= ( const VariantBuilderMultiSampleVector< ELEMENT_TYPE > &  other)
default
template<class ELEMENT_TYPE>
VariantBuilderMultiSampleVector& gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::operator= ( VariantBuilderMultiSampleVector< ELEMENT_TYPE > &&  other)
default
template<class ELEMENT_TYPE>
void gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::set_sample_value ( const uint32_t  sample_index,
const uint32_t  value_index,
const ELEMENT_TYPE  value 
)
inline

Set a single value for one sample.

Parameters
sample_indexindex of the sample (from a VariantHeader lookup)
value_indexindex of the value we are setting for this sample (values for EACH sample start at index 0)
valuevalue to set
Note
MUCH more efficient than set_sample_values() below, since it doesn't require a vector construction/destruction for each call.
Warning
Bounds checking is performed only in debug builds (for the sake of performance), so be sure that sample_index is < num_samples and value_index < max_values_per_sample
template<class ELEMENT_TYPE>
void gamgee::VariantBuilderMultiSampleVector< ELEMENT_TYPE >::set_sample_values ( const uint32_t  sample_index,
const std::vector< ELEMENT_TYPE > &  values 
)
inline

Set all values for one sample at once.

Parameters
sample_indexindex of the sample (from a VariantHeader lookup)
valuesvector of values for this sample
Note
LESS efficient than setting one value at a time using set_sample_value(), since this function involves creating/destroying a vector for each sample.
Warning
Bounds checking is performed only in debug builds (for the sake of performance), so be sure that sample_index is < num_samples and values.size() <= max_values_per_sample

Friends And Related Function Documentation

template<class ELEMENT_TYPE>
friend class VariantBuilder
friend

The documentation for this class was generated from the following file: