#include <genesis/population/format/vcf_common.hpp>
Simple wrapper class for one genotype field for a sample.
The FORMAT GT genotype field in VCF contains entries such as
0/1 to mark an unphased diploid genotype call, where one allele is the reference (index 0), and on alelle is the first alternative (index 1) in the ALT column of the record line.2|1 to mark a phased diploid genotype call, where the first phased allele is the second (index 2) alternative allele of the ALT column, and the second phased allele is the first (index 1) alternative allele.Here, we model exactly one such entry, that is, one such index. For diploid calls, a sample hence needs two such values (two instances of this class); for triploic calls, three instances, and so forth.
For simplicity, the VcfFormatIterator::get_values() function returns all genotype entries for a given sample of a record/line. This can for example be used with vcf_genotype_string() to get a similar string representation of all called genotypes of a record than VCF uses.
The function variant_index() returns the index of the referenec (0) or alternative allele (>0) as exemplified above. The corresponding allele can be obtained via VcfRecord::get_variant() and VcfRecord::get_variants().
Definition at line 328 of file vcf_common.hpp.
Public Member Functions | |
| VcfGenotype (int32_t genotype) | |
| VcfGenotype (VcfGenotype &&)=default | |
| VcfGenotype (VcfGenotype const &)=default | |
| ~VcfGenotype ()=default | |
| int32_t | data () const |
| Return the raw genotype value as used by htslib. More... | |
| bool | is_alternative () const |
True iff the called variant of this genotype is not the REF, but one of the ALT alleles. More... | |
| bool | is_missing () const |
| True iff the variant call is missing for this genotype. More... | |
| bool | is_phased () const |
| True iff the called variant is phased. More... | |
| bool | is_reference () const |
True iff the called variant of this genotype is the REF allele. More... | |
| VcfGenotype & | operator= (VcfGenotype &&)=default |
| VcfGenotype & | operator= (VcfGenotype const &)=default |
| int32_t | variant_index () const |
| Return the index of the variant set for this genotype call. More... | |
|
inlineexplicit |
Definition at line 336 of file vcf_common.hpp.
|
default |
|
default |
|
default |
| int32_t data | ( | ) | const |
Return the raw genotype value as used by htslib.
Definition at line 727 of file vcf_common.cpp.
| bool is_alternative | ( | ) | const |
True iff the called variant of this genotype is not the REF, but one of the ALT alleles.
In VCF, this corresponds to any integer entry > 0.
Definition at line 712 of file vcf_common.cpp.
| bool is_missing | ( | ) | const |
True iff the variant call is missing for this genotype.
In VCF, this corresponds to an entry of ..
Definition at line 717 of file vcf_common.cpp.
| bool is_phased | ( | ) | const |
True iff the called variant is phased.
Note that in the VCF specification 4.2 and htslib this seems to be handled differently: While the former required every genotype call to be marked as phased/unphased, the htslib implementation does not set the phased information for the first genotype call. Hence, if the GT field of a sample is 0|1|1, only the second and the third genotype call will return true in htslib using their bcf_gt_is_phased() macro. We here currently do not fix this, and hence propagate the htslib behaviour.
Definition at line 722 of file vcf_common.cpp.
| bool is_reference | ( | ) | const |
True iff the called variant of this genotype is the REF allele.
In VCF, this corresponds to an entry of 0.
Definition at line 707 of file vcf_common.cpp.
|
default |
|
default |
| int32_t variant_index | ( | ) | const |
Return the index of the variant set for this genotype call.
This corresponds to the indices of the result of VcfRecord::get_variants(). If the call is missing (. in VCF), -1 is returned instead.
Definition at line 702 of file vcf_common.cpp.