Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
variant_field_type.h
Go to the documentation of this file.
1 #ifndef gamgee__variant_field_utils__guard
2 #define gamgee__variant_field_utils__guard
3 
4 #include "htslib/vcf.h"
5 
6 #include <string>
7 #include <iostream>
8 
9 namespace gamgee {
10 namespace utils {
11 
16 enum class VariantFieldType {NIL = 0, INT8 = 1, INT16 = 2, INT32 = 3, FLOAT = 5, STRING = 7};
17 
18 
32 int32_t convert_data_to_integer(const uint8_t* data_ptr, const int index, const uint8_t num_bytes_per_value, const VariantFieldType& type);
33 
38 float convert_data_to_float(const uint8_t* data_ptr, const int index, const uint8_t num_bytes_per_value, const VariantFieldType& type);
39 
44 std::string convert_data_to_string(const uint8_t* data_ptr, const int index, const uint8_t num_bytes_per_value, const VariantFieldType& type);
45 
49 uint8_t size_for_type(const VariantFieldType& type, const bcf_fmt_t* const format_ptr);
50 
54 uint8_t size_for_type(const VariantFieldType& type, const bcf_info_t* const info_ptr);
55 
59 inline bool is_string_type(const int32_t& type) {
60  return (static_cast<utils::VariantFieldType>(type) == VariantFieldType::STRING);
61 }
62 
63 } // end namespace utils
64 } // end namespace gamgee
65 
66 #endif // gamgee__variant_field_utils__guard
VariantFieldType
an enumeration of the types in htslib for the format field values
Definition: variant_field_type.h:16
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
bool is_string_type(const int32_t &type)
check if type is of type string
Definition: variant_field_type.h:59
Definition: vcf.h:136
Definition: vcf.h:144
Definition: exceptions.h:9
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
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
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