1 #ifndef gamgee__individual_field_value__guard 
    2 #define gamgee__individual_field_value__guard 
    6 #include "../missing.h" 
    7 #include "../utils/hts_memory.h" 
    8 #include "../utils/utils.h" 
    9 #include "../utils/variant_field_type.h" 
   52 template<
class VALUE_TYPE>
 
   65     m_format_ptr {format_ptr},
 
   66     m_data_ptr {data_ptr},
 
   67     m_num_bytes {
utils::size_for_type(static_cast<utils::VariantFieldType>(format_ptr->type), format_ptr)}
 
   81     m_body {std::move(other.m_body)},
 
   82     m_format_ptr {other.m_format_ptr},
 
   83     m_data_ptr {other.m_data_ptr},
 
   84     m_num_bytes {other.m_num_bytes}
 
   99     m_body = std::move(other.m_body);
 
  100     m_format_ptr = other.m_format_ptr;
 
  101     m_data_ptr = other.m_data_ptr;
 
  102     m_num_bytes = other.m_num_bytes;
 
  115     auto other_iter = other.
begin();
 
  116     auto other_end = other.
end();
 
  117     for(
const auto& curr_val : *
this)
 
  119       if(other_iter == other_end) 
 
  126     if(other_iter != other_end)
 
  137     return !(*
this == other);
 
  149     return convert_from_byte_array(index); 
 
  166   uint32_t 
size()
 const { 
return m_format_ptr->
n; } 
 
  175     for (
const auto& value : *
this) {
 
  184   std::shared_ptr<bcf1_t> m_body;
 
  189   VALUE_TYPE convert_from_byte_array(
int index) 
const;
 
  196 int32_t IndividualFieldValue<int32_t>::convert_from_byte_array(
int index)
 const {
 
  204 float IndividualFieldValue<float>::convert_from_byte_array(
int index)
 const {
 
  212 std::string IndividualFieldValue<std::string>::convert_from_byte_array(
int index)
 const {
 
  224   auto prefix_msg = 
"";
 
  228     prefix_msg = 
"FORMAT fields of type string in VCFs have only 1 element per sample :: ";
 
  231   return convert_from_byte_array(index); 
 
  236 #endif // gamgee__individual_field_value__guard 
VALUE_TYPE operator[](const uint32_t index) const 
random access to the value of a given sample for reading or writing 
Definition: individual_field_value.h:147
VariantFieldType
an enumeration of the types in htslib for the format field values 
Definition: variant_field_type.h:16
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
VALUE_TYPE back() const 
convenience function to access the last element 
Definition: individual_field_value.h:168
std::string convert_data_to_string(const uint8_t *data_ptr, const int index, const uint8_t num_bytes_per_value, const VariantFieldType &type)
converts the value in an index from the byte array into string 
Definition: variant_field_type.cpp:77
IndividualFieldValue & operator=(const IndividualFieldValue &other)=delete
bool missing() const 
returns true if all of the values are missing 
Definition: individual_field_value.h:173
VALUE_TYPE front() const 
convenience function to access the first element 
Definition: individual_field_value.h:167
bool is_string_type(const int32_t &type)
check if type is of type string 
Definition: variant_field_type.h:59
IndividualFieldValue(const std::shared_ptr< bcf1_t > &body, const bcf_fmt_t *const format_ptr, uint8_t *const data_ptr)
creates a new IndividualFieldValue poiinting to the shared byte array inside the variant object ...
Definition: individual_field_value.h:63
bool operator!=(const IndividualFieldValue &other) const 
compares two IndividualFieldValue objects in the following order: memory address, size and values...
Definition: individual_field_value.h:136
uint32_t size() const 
the number of values in this IndividualFieldValue (values per sample) 
Definition: individual_field_value.h:166
IndividualFieldValueIterator< VALUE_TYPE > end() const 
create a new end iterator over the values for this sample 
Definition: individual_field_value.h:162
int n
Definition: vcf.h:138
bool bcf_check_equal_element(const TYPE &x, const TYPE &y)
Check whether two values from VCF fields of primitive types (for which the == operator is defined) * ...
Definition: utils.h:85
Definition: exceptions.h:9
IndividualFieldValueIterator< VALUE_TYPE > begin() const 
create a new begin iterator over the values for this sample 
Definition: individual_field_value.h:155
int type
Definition: vcf.h:138
iterator for FormatFieldGenericValue objects. 
Definition: individual_field_value_iterator.h:31
uint8_t size_for_type(const VariantFieldType &type, const bcf_fmt_t *const format_ptr)
returns the number of bytes for a given VariantFieldType 
Definition: variant_field_type.cpp:102
IndividualFieldValue(IndividualFieldValue &&other)
safely moves the data from one IndividualFieldValue to a new one without making any copies ...
Definition: individual_field_value.h:80
int size
Definition: vcf.h:138
IndividualFieldValue & operator=(IndividualFieldValue &&other)
safely moves the data from one IndividualField to the other without making any copies ...
Definition: individual_field_value.h:96
int32_t convert_data_to_integer(const uint8_t *data_ptr, const int index, const uint8_t num_bytes_per_value, const VariantFieldType &type)
converts the value in an index from the byte array into int32_t 
Definition: variant_field_type.cpp:11
A class template to hold the values a format field for a particular sample. 
Definition: individual_field_value.h:53
bool missing(const bool value)
Returns true if bool is false (missing). 
Definition: missing.h:23
bool operator==(const IndividualFieldValue &other) const 
compares two IndividualFieldValue objects in the following order: memory address, size and values...
Definition: individual_field_value.h:111
float convert_data_to_float(const uint8_t *data_ptr, const int index, const uint8_t num_bytes_per_value, const VariantFieldType &type)
converts the value in an index from the byte array into float 
Definition: variant_field_type.cpp:41