1 #ifndef gamgee__genotype_utils__guard
2 #define gamgee__genotype_utils__guard
8 #include "../missing.h"
42 inline int32_t
allele_key(
const uint8_t* data_ptr,
const uint32_t allele_index,
const TYPE
missing,
const TYPE vector_end) {
44 const auto p =
reinterpret_cast<const TYPE*
>(data_ptr);
45 if ( !(p[allele_index]>>1) || p[allele_index]==
missing ) {
48 else if ( p[allele_index] == vector_end ) {
51 return (p[allele_index]>>1)-1;
63 const bcf_fmt_t*
const format_ptr,
const uint8_t* data_ptr,
const uint32_t allele_index) {
64 switch (format_ptr->
type) {
72 throw invalid_argument(
"unknown GT field type: " + to_string(format_ptr->
type));
84 vector<int32_t>
allele_keys(
const std::shared_ptr<bcf1_t>& body,
const bcf_fmt_t*
const format_ptr,
const uint8_t* data_ptr);
95 const bcf_fmt_t*
const format_ptr,
const uint8_t* data_ptr);
#define BCF_BT_INT32
Definition: vcf.h:122
#define bcf_int8_vector_end
Definition: vcf.h:750
#define bcf_int32_missing
Definition: vcf.h:756
vector< int32_t > allele_keys(const std::shared_ptr< bcf1_t > &body, const bcf_fmt_t *const format_ptr, const uint8_t *data_ptr, const TYPE missing, const TYPE vector_end)
Definition: genotype_utils.cpp:59
#define BCF_BT_INT8
Definition: vcf.h:120
#define bcf_int16_vector_end
Definition: vcf.h:751
constexpr auto int32
missing value for an int32
Definition: missing.h:18
#define bcf_int32_vector_end
Definition: vcf.h:752
vector< string > allele_strings(const std::shared_ptr< bcf1_t > &body, const bcf_fmt_t *const format_ptr, const uint8_t *data_ptr, const TYPE missing, const TYPE vector_end)
Definition: genotype_utils.cpp:99
bool allele_missing(const uint8_t *data_ptr, const uint32_t allele_index, const TYPE missing)
Definition: genotype_utils.cpp:38
int n
Definition: vcf.h:138
Definition: exceptions.h:9
int type
Definition: vcf.h:138
uint32_t allele_count(const bcf_fmt_t *const format_ptr)
Counts the genotype alleles.
Definition: genotype_utils.h:26
#define BCF_BT_INT16
Definition: vcf.h:121
#define bcf_int16_missing
Definition: vcf.h:755
string allele_key_to_string(const std::shared_ptr< bcf1_t > &body, const int32_t allele_int)
Returns the genotype allele string from this line.
Definition: genotype_utils.cpp:125
#define bcf_int8_missing
Definition: vcf.h:754
int32_t allele_key(const uint8_t *data_ptr, const uint32_t allele_index, const TYPE missing, const TYPE vector_end)
Definition: genotype_utils.h:42
bool missing(const bool value)
Returns true if bool is false (missing).
Definition: missing.h:23