Gamgee
You miserable little maggot. I'll stove your head in!
|
A class template to hold the values of a specific Variant's format field for all samples. More...
#include <individual_field.h>
Public Member Functions | |
IndividualField () | |
default constructor of an empty IndividualField More... | |
IndividualField (const std::shared_ptr< bcf1_t > &body, bcf_fmt_t *format_ptr) | |
creates a new format field object pointing to the shared byte array inside the Variant object More... | |
IndividualField (const IndividualField &other)=delete | |
copying of the IndividualField object is not allowed. Use move constructor instead. More... | |
IndividualField (IndividualField &&other)=default | |
safely moves the data from one IndividualField to a new one without making any copies More... | |
IndividualField & | operator= (const IndividualField &other)=delete |
copying of the IndividualField object is not allowed. Use move constructor instead. More... | |
IndividualField & | operator= (IndividualField &&other)=default |
safely moves the data from one IndividualField to the other without making any copies More... | |
bool | operator== (const IndividualField &other) const |
compares two IndividualField objects in the following order: memory address, size and values. More... | |
bool | operator!= (const IndividualField &other) const |
compares two IndividualField objects in the following order: memory address, size and values. More... | |
TYPE | operator[] (const uint32_t sample) const |
random access to the value of a given sample for reading or writing More... | |
IndividualFieldIterator< TYPE > | begin () const |
an iterator to the beginning of the object More... | |
IndividualFieldIterator< TYPE > | end () const |
an iterator to the end of the object More... | |
uint32_t | size () const |
the number of values in this IndividualField More... | |
uint32_t | n_samples () const |
just an alias to size() to simplify interfaces More... | |
uint32_t | empty () const |
checks if the object is empty. More... | |
uint32_t | missing () const |
checks if the object is empty. More... | |
TYPE | front () const |
convenience function to access the first element More... | |
TYPE | back () const |
convenience function to access the last element More... | |
A class template to hold the values of a specific Variant's format field for all samples.
The role of this class is to perform the pointer manipulations behind the scenes that permit the user to navigate the values of a field without making any copies and benefiting from data locality (all the data is stored contiguously in memory).
For example, the genotype quality field (GQ) will hold one uint8_t value for each sample. The PL field will hold at least three values per sample. The IndividualField will hold all these values per sample in a random access (and random access iterator compatible) way. The IndividualField can be used in any algorithm of the stl that requires random access iterators.
A typical use of the IndividualField can be exemplified by the genotype quality accessor in Variant:
IndividualField objects can also be used in for loops like so:
For a field with multiple values, you can also iterate on the resulting IndividualFieldValue like so:
While the IndividualField objects are not really intended to be created by the user, they are the returned by many accessors in the Variant API like the integer_individual_field("GQ") example above. Utilizing them correctly can really simplify your work by leveraging the power of the STL functions.
TYPE | the type desired for the given tag. For example for GQ's typically you would request an int32. |
|
inline |
default constructor of an empty IndividualField
|
inlineexplicit |
creates a new format field object pointing to the shared byte array inside the Variant object
body | the full Variant object where all the values of the field are stored (shared ownership) |
format_ptr | a structure with a pointer to the location in the raw byte array (m_body->indiv) where the format field starts and information about the values (size, type, number,...) |
|
delete |
copying of the IndividualField object is not allowed. Use move constructor instead.
|
default |
safely moves the data from one IndividualField to a new one without making any copies
other | another IndividualField object |
|
inline |
convenience function to access the last element
|
inline |
an iterator to the beginning of the object
|
inline |
checks if the object is empty.
|
inline |
an iterator to the end of the object
|
inline |
convenience function to access the first element
|
inline |
checks if the object is empty.
|
inline |
just an alias to size() to simplify interfaces
|
inline |
compares two IndividualField objects in the following order: memory address, size and values.
other | something to compare to |
|
delete |
copying of the IndividualField object is not allowed. Use move constructor instead.
|
default |
safely moves the data from one IndividualField to the other without making any copies
other | another IndividualField object |
|
inline |
compares two IndividualField objects in the following order: memory address, size and values.
other | something to compare to |
|
inline |
random access to the value of a given sample for reading or writing
sample | must be between 0 and the number of samples for this record |
std::out_of_range | if sample is out of range or entire field is missing and trying to access invalid memory |
|
inline |
the number of values in this IndividualField