|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_POPULATION_FORMAT_VCF_RECORD_H_
2 #define GENESIS_POPULATION_FORMAT_VCF_RECORD_H_
57 namespace population {
149 return (
static_cast<int>(a) &
static_cast<int>(b) );
261 std::string
get_id()
const;
270 std::string
at()
const;
410 bool has_filter( std::string
const& filter )
const;
441 bool has_info( std::string
const&
id )
const;
446 bool has_info(
char const*
id )
const;
477 void get_info_string( std::string
const&
id, std::string& destination )
const;
486 std::vector<double>
get_info_float( std::string
const&
id )
const;
497 void get_info_float( std::string
const&
id, std::vector<double>& destination )
const;
504 std::vector<int32_t>
get_info_int( std::string
const&
id )
const;
514 void get_info_int( std::string
const&
id, std::vector<int32_t>& destination )
const;
543 bool has_format( std::string
const&
id )
const;
717 int get_info_ptr_( std::string
const&
id,
int ht_type,
void** dest,
int* ndest )
const;
728 mutable ::bcf1_t* record_ =
nullptr;
731 mutable char* info_dest_string_ =
nullptr;
732 mutable float* info_dest_float_ =
nullptr;
733 mutable int32_t* info_dest_int_ =
nullptr;
734 mutable int info_ndest_string_ = 0;
735 mutable int info_ndest_float_ = 0;
736 mutable int info_ndest_int_ = 0;
742 #endif // htslib guard
743 #endif // include guard
bool is_snp() const
Return whether this variant is a SNP.
std::string at() const
Return a textual representation of the current record chromosome position.
VcfFormatIteratorFloat begin_format_float(std::string const &id) const
Get the begin iterator over the samples that accesses a certain FORMAT id as a float value.
VariantType get_variant_type(size_t alt_index) const
Get the variant type of a particular alternative allele/sequence.
VcfHeader & header()
Return the VcfHeader instance associated with this record.
std::vector< std::string > get_format_ids() const
Get the list of all format IDs (FORMAT column) that the record contains.
friend bool operator&(VcfRecord::VariantType a, VcfRecord::VariantType b)
And-operator for VariantTypes.
void assert_info(std::string const &id) const
Assert that an INFO entry with a given id is present in the record.
VcfRecord & operator=(VcfRecord const &)=delete
VcfHeader const & header() const
Return the VcfHeader instance associated with this record.
VcfFormatIteratorGenotype begin_format_genotype() const
Get the begin iterator over the samples that accesses the FORMAT genotype (GT field/key/id) as a set ...
std::string get_info_string(std::string const &id) const
Return the info value for the given key id as a string.
void assert_format(std::string const &id) const
Assert that an FORMAT entry with a given id is present in the record.
bool get_info_flag(std::string const &id) const
Return whehter an INFO flag is set, that is, whether the info value for a given key id is present in ...
std::string get_id() const
Get the ID string of the variant (ID, third column of the line).
VcfFormatIteratorInt begin_format_int(std::string const &id) const
Get the begin iterator over the samples that accesses a certain FORMAT id as an int value.
VcfFormatIteratorString end_format_string() const
Get the end iterator over the samples that accesses a certain FORMAT id as a string value.
std::string get_alternative(size_t index) const
Get a particular alternative allele (ALT, fifth column of the line).
std::vector< std::string > get_alternatives() const
Get the alternative alleles/sequences of the variant (ALT, fifth column of the line).
VcfFormatIteratorInt end_format_int() const
Get the end iterator over the samples that accesses a certain FORMAT id as an int value.
bool pass_filter() const
Return whether the record passes the filters, that is, whether PASS is set, or no filters were applie...
std::vector< std::string > get_variants() const
Shortcut to get both the reference (REF, fourth column of the line) and the alternative (ALT,...
::bcf1_t * data()
Return the internal htslib bcf1_t record data struct pointer.
void swap(VcfRecord &other)
std::vector< std::string > get_info_ids() const
Get the list of all info IDs (INFO column) that the record contains.
bool read_next(HtsFile &source)
Read the next record/line from the given source, and replace the content of this VcfRecord instance.
VcfFormatIteratorString begin_format_string(std::string const &id) const
Get the begin iterator over the samples that accesses a certain FORMAT id as a string value.
VariantType get_variant_types() const
Get the or'ed (union) value of all variant types of the alternative alleles/sequences of the record.
VcfRecord()
Create a default (empty) instance.
std::string get_chromosome() const
Get the name of a chromosome/contig/sequence (CHROM, first column of the line).
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops.
genesis::utils::Range< VcfFormatIteratorGenotype > get_format_genotype() const
Get an iterator pair over the samples that accesses the FORMAT genotype (GT field/key/id) as a set of...
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
std::string get_reference() const
Get the reference allele/sequence of the variant (REF, fourth column of the line).
bool has_format(std::string const &id) const
Return whether the record has a given FORMAT id present.
genesis::utils::Range< VcfFormatIteratorString > get_format_string(std::string const &id) const
Get an iterator pair over the samples that accesses a certain FORMAT id as a string value.
bool has_info(std::string const &id) const
Return whether the record has a given INFO id present.
genesis::utils::Range< VcfFormatIteratorFloat > get_format_float(std::string const &id) const
Get an iterator pair over the samples that accesses a certain FORMAT id as an float value.
size_t get_position() const
Get the position within the chromosome/contig (POS, second column of the line).
VcfFormatIteratorGenotype end_format_genotype() const
Get the end iterator over the samples that accesses the FORMAT genotype (GT field/key/id) as a set of...
size_t get_variant_count() const
Get the total number of variants (REF and ALT alleles) in the record/line.
std::vector< std::string > get_filter_ids() const
Get the list of all filter values (PASS or the names of the non-passing filters) that are applied to ...
bool is_snp_or_alt_del() const
Return whether this variant is a SNP, or a deletion in the alternative.
Capture the information of a single SNP/variant line in a VCF/BCF file.
std::vector< int32_t > get_info_int(std::string const &id) const
Return the info value for the given key id as a vector of int.
size_t get_alternatives_count() const
Get the number of alternative alleles/sequences of the variant (ALT, fifth column of the line).
VcfFormatIteratorFloat end_format_float() const
Get the end iterator over the samples that accesses a certain FORMAT id as a float value.
VariantType
Types of variants of alleles that can occur in a record.
void unpack() const
Unpack the htslib bcf1_t record data.
genesis::utils::Range< VcfFormatIteratorInt > get_format_int(std::string const &id) const
Get an iterator pair over the samples that accesses a certain FORMAT id as an int value.
::bcf1_t const * data() const
Return the internal htslib bcf1_t record data struct pointer.
std::vector< double > get_info_float(std::string const &id) const
Return the info value for the given key id as a vector of float/double.
std::string get_variant(size_t index) const
Get a particular variant (REF or ALT allele).
Wrap an ::htsFile struct.
double get_quality() const
Get the quality score (QUAL, sixth column of the line).
bool has_filter(std::string const &filter) const
Return whether the record has a given filter set.