Gamgee
You miserable little maggot. I'll stove your head in!
|
Helper class for VariantBuilder to manage the fields belonging to the shared region of Variant records. More...
#include <variant_builder_shared_region.h>
Public Member Functions | |
VariantBuilderSharedRegion (const VariantHeader &header, const bool enable_validation) | |
VariantBuilderSharedRegion (VariantBuilderSharedRegion &&other)=default | |
VariantBuilderSharedRegion & | operator= (VariantBuilderSharedRegion &&other)=default |
VariantBuilderSharedRegion (const VariantBuilderSharedRegion &other)=delete | |
VariantBuilderSharedRegion & | operator= (const VariantBuilderSharedRegion &other)=delete |
~VariantBuilderSharedRegion () | |
void | set_enable_validation (const bool enable_validation) |
uint32_t | ref_allele_length () const |
uint32_t | num_alt_alleles () const |
uint32_t | num_present_info_fields () const |
bool | modified () const |
void | set_id (const std::string &id) |
void | set_ref_allele (const std::string &ref_allele) |
void | set_alt_allele (const std::string &alt_allele) |
void | set_alt_alleles (const std::vector< std::string > &alt_alleles) |
void | set_filters (const std::vector< std::string > &filters) |
void | set_filters (const std::vector< int32_t > &filters) |
template<class FIELD_ID_TYPE , class FIELD_VALUE_TYPE > | |
void | set_info_field (const FIELD_ID_TYPE &field_id, const FIELD_VALUE_TYPE &field_value, const int32_t provided_type, const uint32_t num_values) |
void | remove_id () |
void | remove_alt_alleles () |
void | remove_filters () |
template<class FIELD_ID_TYPE > | |
void | remove_info_field (const FIELD_ID_TYPE &field_id) |
uint32_t | estimate_total_size () const |
Produce a slight overestimate of the number of bytes required to hold all encoded data for this shared region. More... | |
void | encode_into (kstring_t *destination) const |
Copy all encoded data for all shared fields into the provided byte buffer in the proper order and format for final insertion into a Variant object. More... | |
void | clear () |
Reset the shared region to a pristine state with no field data. More... | |
Helper class for VariantBuilder to manage the fields belonging to the shared region of Variant records.
The shared region includes the ID, reference allele, alt alleles, filters, and INFO fields. This class manages the validation, encoding, and storage of these fields.
STORAGE STRATEGY: This class pre-allocates a large block of C memory (m_shared_buffer). When we set a shared field we tell htslib to encode it directly into the end of this buffer, keeping track of the buffer span used by each field. htslib can resize the buffer if needed.
Old field values remain in the buffer as unused sections (garbage). If too much garbage accumulates we compact the buffer to restore locality, but in general if the user of VariantBuilder is calling clear() regularly this won't happen.
When we encode the final shared byte buffer, we traverse the used regions of m_shared_buffer to copy the encoded data for each field into the right place in the final buffer.
This approach to storage has the advantage of performing no allocations or de-allocations in normal use, and most of the time the encoded data for all fields will be adjacent in memory, albeit possibly out-of-order, allowing for very cache-efficient encode operations.
|
explicit |
|
default |
|
delete |
gamgee::VariantBuilderSharedRegion::~VariantBuilderSharedRegion | ( | ) |
void gamgee::VariantBuilderSharedRegion::clear | ( | ) |
Reset the shared region to a pristine state with no field data.
void gamgee::VariantBuilderSharedRegion::encode_into | ( | kstring_t * | destination | ) | const |
Copy all encoded data for all shared fields into the provided byte buffer in the proper order and format for final insertion into a Variant object.
uint32_t gamgee::VariantBuilderSharedRegion::estimate_total_size | ( | ) | const |
Produce a slight overestimate of the number of bytes required to hold all encoded data for this shared region.
|
inline |
|
inline |
|
inline |
|
default |
|
delete |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void gamgee::VariantBuilderSharedRegion::set_alt_allele | ( | const std::string & | alt_allele | ) |
void gamgee::VariantBuilderSharedRegion::set_alt_alleles | ( | const std::vector< std::string > & | alt_alleles | ) |
|
inline |
void gamgee::VariantBuilderSharedRegion::set_filters | ( | const std::vector< std::string > & | filters | ) |
void gamgee::VariantBuilderSharedRegion::set_filters | ( | const std::vector< int32_t > & | filters | ) |
void gamgee::VariantBuilderSharedRegion::set_id | ( | const std::string & | id | ) |
|
inline |
void gamgee::VariantBuilderSharedRegion::set_ref_allele | ( | const std::string & | ref_allele | ) |