1 #ifndef gamgee__individual_field__guard
2 #define gamgee__individual_field__guard
8 #include "../utils/hts_memory.h"
9 #include "../utils/utils.h"
82 m_body {body}, m_format_ptr {format_ptr}
116 for (
auto i=0u; i !=
size(); ++i) {
117 if (
operator[](i) != other[i])
129 return !(*
this == other);
141 throw std::out_of_range(
"Tried to index an individual field that is missing with operator[]");
143 return TYPE{m_body, m_format_ptr, m_format_ptr->
p + (sample * m_format_ptr->size)};
160 uint32_t
size()
const {
return empty() ? 0 : m_body->n_sample; }
162 uint32_t
empty()
const {
return m_body ==
nullptr; }
168 std::shared_ptr<bcf1_t> m_body;
175 #endif // gamgee__individual_field__guard
bool operator==(const IndividualField &other) const
compares two IndividualField objects in the following order: memory address, size and values...
Definition: individual_field.h:111
uint32_t missing() const
checks if the object is empty.
Definition: individual_field.h:163
IndividualField & operator=(const IndividualField &other)=delete
copying of the IndividualField object is not allowed. Use move constructor instead.
TYPE operator[](const uint32_t sample) const
random access to the value of a given sample for reading or writing
Definition: individual_field.h:139
TYPE front() const
convenience function to access the first element
Definition: individual_field.h:164
uint8_t * p
Definition: vcf.h:139
void check_max_boundary(const uint32_t index, const uint32_t size, const std::string &prefix_msg)
checks that an index is greater than or equal to size
Definition: utils.h:63
bool operator!=(const IndividualField &other) const
compares two IndividualField objects in the following order: memory address, size and values...
Definition: individual_field.h:128
uint32_t n_samples() const
just an alias to size() to simplify interfaces
Definition: individual_field.h:161
uint32_t empty() const
checks if the object is empty.
Definition: individual_field.h:162
IndividualFieldIterator< TYPE > end() const
an iterator to the end of the object
Definition: individual_field.h:156
IndividualField()
default constructor of an empty IndividualField
Definition: individual_field.h:73
TYPE back() const
convenience function to access the last element
Definition: individual_field.h:165
A class template to hold the values of a specific Variant's format field for all samples.
Definition: individual_field.h:65
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 ...
Definition: individual_field.h:81
Definition: exceptions.h:9
IndividualFieldIterator< TYPE > begin() const
an iterator to the beginning of the object
Definition: individual_field.h:149
iterator for VariantField objects.
Definition: individual_field_iterator.h:28
uint32_t size() const
the number of values in this IndividualField
Definition: individual_field.h:160