Gamgee
You miserable little maggot. I'll stove your head in!
|
Encodes a genotype. More...
#include <genotype.h>
Public Member Functions | |
Genotype (const std::shared_ptr< bcf1_t > &body, const bcf_fmt_t *const format_ptr, const uint8_t *data_ptr) | |
Constructs a genotype. More... | |
Genotype (const Genotype &other)=delete | |
copying of the Genotype object is not allowed. More... | |
Genotype & | operator= (const Genotype &other)=delete |
copying of the Genotype object is not allowed. More... | |
Genotype (Genotype &&other)=default | |
Explicit default as recommended by many threads on stackoverflow. More... | |
Genotype & | operator= (Genotype &&other)=default |
Explicit default as recommended by many threads on stackoverflow. More... | |
~Genotype ()=default | |
Explicit default as recommended by many threads on stackoverflow. More... | |
bool | operator!= (const Genotype &other) const |
Checks if another genotype does not equal this genotype. More... | |
bool | operator== (const Genotype &other) const |
Checks if another genotype equals this genotype. More... | |
bool | het () const |
Checks if this genotype vector is any type of heterozygous call. More... | |
bool | non_ref_het () const |
Checks if this genotype vector is a heterozygous call and none of the alleles is the reference. More... | |
uint32_t | fast_diploid_key_generation () const |
A bit encoding for the first two alleles. More... | |
bool | hom_var () const |
Checks if this genotype vector is a homozygous call that is non-reference. More... | |
bool | hom_ref () const |
Checks if this genotype vector is a homozygous call that is reference. More... | |
bool | missing () const |
Checks if all alleles are missing. More... | |
std::vector< std::string > | allele_strings () const |
Returns a vector with all the allele strings. More... | |
std::vector< int32_t > | allele_keys () const |
Returns a vector with all the allele keys. More... | |
std::string | allele_string (const uint32_t index) const |
Returns the allele string at index. More... | |
int32_t | allele_key (const uint32_t index) const |
Returns the allele key within this line. More... | |
int32_t | operator[] (const uint32_t index) const |
Returns the allele key within this line. More... | |
uint32_t | size () const |
Returns the number of alleles. More... | |
bool | snp (const AlleleMask &mask) const |
whether or not this genotype represents a snp More... | |
bool | insertion (const AlleleMask &mask) const |
whether or not this genotype represents an insertion More... | |
bool | deletion (const AlleleMask &mask) const |
whether or not this genotype represents an deletion More... | |
bool | indel (const AlleleMask &mask) const |
whether or not this genotype represents an insertion or deletion More... | |
bool | biallelic () const |
whether or not this genotype has at most one alternate allele More... | |
bool | complex () const |
literally the negation of biallelic(mask) More... | |
bool | mixed () const |
identifies variants with two different types of alleles More... | |
bool | variant () const |
Static Public Member Functions | |
static void | encode_genotype (std::vector< int32_t > &alleles) |
Converts a vector of allele indices representing a genotype into BCF-encoded format suitable for passing to htslib. No phasing is added. More... | |
static void | encode_genotype (std::vector< int32_t > &alleles, bool phase_all_alleles) |
Converts a vector of allele indices representing a genotype into BCF-encoded format suitable for passing to htslib, and also allows you to phase all alleles. More... | |
static void | encode_genotypes (std::vector< std::vector< int32_t >> &multiple_genotypes) |
Converts multiple vectors of allele indices representing genotypes into BCF-encoded format suitable for passing to htslib. No phasing is added. More... | |
static void | encode_genotypes (VariantBuilderMultiSampleVector< int32_t > &multiple_genotypes) |
Converts multiple genotypes stored in a VariantBuilderMultiSampleVector into BCF-encoded format suitable for passing to htslib. No phasing is added. More... | |
Encodes a genotype.
gamgee::Genotype::Genotype | ( | const std::shared_ptr< bcf1_t > & | body, |
const bcf_fmt_t *const | format_ptr, | ||
const uint8_t * | data_ptr | ||
) |
Constructs a genotype.
body | The shared memory variant "line" from a vcf, or bcf. |
format_ptr | The GT field from the line. |
data_ptr | The GT for this sample. |
|
delete |
copying of the Genotype object is not allowed.
|
default |
Explicit default as recommended by many threads on stackoverflow.
other | Other genotype. |
|
default |
Explicit default as recommended by many threads on stackoverflow.
int32_t gamgee::Genotype::allele_key | ( | const uint32_t | index | ) | const |
Returns the allele key within this line.
index | Zero based allele index |
std::vector< int32_t > gamgee::Genotype::allele_keys | ( | ) | const |
Returns a vector with all the allele keys.
std::string gamgee::Genotype::allele_string | ( | const uint32_t | index | ) | const |
Returns the allele string at index.
index | Zero based allele index |
std::vector< std::string > gamgee::Genotype::allele_strings | ( | ) | const |
Returns a vector with all the allele strings.
bool gamgee::Genotype::biallelic | ( | ) | const |
whether or not this genotype has at most one alternate allele
This function will check whether this is a simple heterozygous or homozygous site where both alleles are either the same, or reference and one alternate allele. No two different alleles would pass.
|
inline |
literally the negation of biallelic(mask)
bool gamgee::Genotype::deletion | ( | const AlleleMask & | mask | ) | const |
whether or not this genotype represents an deletion
This function will check that at least one deletion exists and that no other type of allele (snp or insertion) is present. Multiple deletions will return true.
|
inlinestatic |
Converts a vector of allele indices representing a genotype into BCF-encoded format suitable for passing to htslib. No phasing is added.
Example: if you want to BCF-encode the genotype 0/1, create a vector with {0, 1} and then pass it to this function
|
inlinestatic |
Converts a vector of allele indices representing a genotype into BCF-encoded format suitable for passing to htslib, and also allows you to phase all alleles.
Example: if you want to BCF-encode the genotype 0|1, create a vector with {0, 1} and then pass it to this function with phase_all_alleles set to true
|
inlinestatic |
Converts multiple vectors of allele indices representing genotypes into BCF-encoded format suitable for passing to htslib. No phasing is added.
Example: if you want to BCF-encode the genotypes 0/1 and 1/1, create a vector with { {0, 1}, {1, 1} } and pass it to this function
|
inlinestatic |
Converts multiple genotypes stored in a VariantBuilderMultiSampleVector into BCF-encoded format suitable for passing to htslib. No phasing is added.
uint32_t gamgee::Genotype::fast_diploid_key_generation | ( | ) | const |
A bit encoding for the first two alleles.
bool gamgee::Genotype::het | ( | ) | const |
Checks if this genotype vector is any type of heterozygous call.
bool gamgee::Genotype::hom_ref | ( | ) | const |
Checks if this genotype vector is a homozygous call that is reference.
bool gamgee::Genotype::hom_var | ( | ) | const |
Checks if this genotype vector is a homozygous call that is non-reference.
bool gamgee::Genotype::indel | ( | const AlleleMask & | mask | ) | const |
whether or not this genotype represents an insertion or deletion
This function will check that at least one insertion or deletion exists and that no other type of allele (snp or insertion) is present. Multiple deletions will return true.
bool gamgee::Genotype::insertion | ( | const AlleleMask & | mask | ) | const |
whether or not this genotype represents an insertion
This function will check that at least one insertion exists and that no other type of allele (snp or deletion) is present. Multiple insertions will return true.
bool gamgee::Genotype::missing | ( | ) | const |
Checks if all alleles are missing.
bool gamgee::Genotype::mixed | ( | ) | const |
identifies variants with two different types of alleles
bool gamgee::Genotype::non_ref_het | ( | ) | const |
Checks if this genotype vector is a heterozygous call and none of the alleles is the reference.
bool gamgee::Genotype::operator!= | ( | const Genotype & | other | ) | const |
Checks if another genotype does not equal this genotype.
other | The other genotype to compare. |
copying of the Genotype object is not allowed.
other | Other genotype. |
Explicit default as recommended by many threads on stackoverflow.
other | Other genotype. |
bool gamgee::Genotype::operator== | ( | const Genotype & | other | ) | const |
Checks if another genotype equals this genotype.
other | The other genotype to compare. |
int32_t gamgee::Genotype::operator[] | ( | const uint32_t | index | ) | const |
Returns the allele key within this line.
index | Zero based allele index |
uint32_t gamgee::Genotype::size | ( | ) | const |
Returns the number of alleles.
bool gamgee::Genotype::snp | ( | const AlleleMask & | mask | ) | const |
whether or not this genotype represents a snp
In the true sense of the word, single nucleotide polymorphism restricts the number of loci (nucleotides) that are polymorphic, but not the number of potentially different alleles it may have (as long as they are all single nucleotide polymorphisms). This function will check that at least one of these SNPs exists and that no other type of allele (insertion or deletion) is present. Multiple SNPs will return true.
|
inline |