A library for working with phylogenetic and population genetic data.
v0.27.0
VcfInputIterator Class Reference

#include <genesis/population/formats/vcf_input_iterator.hpp>

Detailed Description

Iterate an input source and parse it as a VCF/BCF file.

This simple wrapper allows easy iteration through the records/lines of a VCF/BCF file, and takes care of setting up the HtsFile, VcfHeader, and VcfRecord.

Basic usage:

auto it = VcfInputIterator( infile );
while( it ) {
    // work with it.record() or it->...
    ++it;
}

or

for( auto it = VcfInputIterator( infile );  it; ++it ) {
    // work with it
}

For details on working with the records/lines, see VcfRecord and VcfFormatIterator.

Definition at line 76 of file vcf_input_iterator.hpp.

Public Member Functions

 VcfInputIterator ()=default
 Create a default instance, with no input. This is also the past-the-end iterator. More...
 
 VcfInputIterator (self_type &&)=default
 
 VcfInputIterator (self_type const &)=default
 
 VcfInputIterator (std::string const &filename, bool expect_ordered=true)
 Create an instance that reads from an input file name. More...
 
 VcfInputIterator (std::string const &filename, std::vector< std::string > const &sample_names, bool inverse_sample_names=false, bool expect_ordered=true)
 Create an instance that reads from an input file name. More...
 
 ~VcfInputIterator ()=default
 
std::string const & filename () const
 
bool good () const
 
VcfHeaderheader ()
 
VcfHeader const & header () const
 
HtsFilehts_file ()
 
HtsFile const & hts_file () const
 
 operator bool () const
 Return true iff dereferencing is valid, i.e., iff there is a VCF record available. More...
 
bool operator!= (self_type const &other) const
 
VcfRecordoperator* ()
 
VcfRecord const & operator* () const
 
self_typeoperator++ ()
 
self_typeoperator++ (int)
 
VcfRecordoperator-> ()
 
VcfRecord const * operator-> () const
 
self_typeoperator= (self_type &&)=default
 
self_typeoperator= (self_type const &)=default
 
bool operator== (self_type const &other) const
 
VcfRecordrecord ()
 
VcfRecord const & record () const
 

Public Types

using difference_type = std::ptrdiff_t
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type const *
 
using reference = value_type const &
 
using self_type = VcfInputIterator
 
using value_type = VcfRecord
 

Constructor & Destructor Documentation

◆ VcfInputIterator() [1/5]

VcfInputIterator ( )
default

Create a default instance, with no input. This is also the past-the-end iterator.

◆ VcfInputIterator() [2/5]

VcfInputIterator ( std::string const &  filename,
bool  expect_ordered = true 
)
inlineexplicit

Create an instance that reads from an input file name.

By default, we expect the input to be ordered by chromosome and position, and throw an exception if this is not the case. Set expect_ordered to false to deactivate this check, and instead allow VcfRecords to appear in any order of chromosomes and positions.

Definition at line 107 of file vcf_input_iterator.hpp.

◆ VcfInputIterator() [3/5]

VcfInputIterator ( std::string const &  filename,
std::vector< std::string > const &  sample_names,
bool  inverse_sample_names = false,
bool  expect_ordered = true 
)
inline

Create an instance that reads from an input file name.

Additionally, this constructor takes a list of sample_names which are used as filter so that only those samples (columns of the VCF records) are evaluated and accessible - or, if inverse_sample_names is set to true, instead all but those samples.

By default, we expect the input to be ordered by chromosome and position, and throw an exception if this is not the case. Set expect_ordered to false to deactivate this check, and instead allow VcfRecords to appear in any order of chromosomes and positions.

Definition at line 124 of file vcf_input_iterator.hpp.

◆ ~VcfInputIterator()

~VcfInputIterator ( )
default

◆ VcfInputIterator() [4/5]

VcfInputIterator ( self_type const &  )
default

◆ VcfInputIterator() [5/5]

VcfInputIterator ( self_type &&  )
default

Member Function Documentation

◆ filename()

std::string const& filename ( ) const
inline

Definition at line 174 of file vcf_input_iterator.hpp.

◆ good()

bool good ( ) const
inline

Definition at line 165 of file vcf_input_iterator.hpp.

◆ header() [1/2]

VcfHeader& header ( )
inline

Definition at line 202 of file vcf_input_iterator.hpp.

◆ header() [2/2]

VcfHeader const& header ( ) const
inline

Definition at line 196 of file vcf_input_iterator.hpp.

◆ hts_file() [1/2]

HtsFile& hts_file ( )
inline

Definition at line 190 of file vcf_input_iterator.hpp.

◆ hts_file() [2/2]

HtsFile const& hts_file ( ) const
inline

Definition at line 179 of file vcf_input_iterator.hpp.

◆ operator bool()

operator bool ( ) const
inlineexplicit

Return true iff dereferencing is valid, i.e., iff there is a VCF record available.

Definition at line 160 of file vcf_input_iterator.hpp.

◆ operator!=()

bool operator!= ( self_type const &  other) const
inline

Definition at line 268 of file vcf_input_iterator.hpp.

◆ operator*() [1/2]

VcfRecord& operator* ( )
inline

Definition at line 238 of file vcf_input_iterator.hpp.

◆ operator*() [2/2]

VcfRecord const& operator* ( ) const
inline

Definition at line 232 of file vcf_input_iterator.hpp.

◆ operator++() [1/2]

self_type& operator++ ( )
inline

Definition at line 248 of file vcf_input_iterator.hpp.

◆ operator++() [2/2]

self_type& operator++ ( int  )
inline

Definition at line 254 of file vcf_input_iterator.hpp.

◆ operator->() [1/2]

VcfRecord* operator-> ( )
inline

Definition at line 226 of file vcf_input_iterator.hpp.

◆ operator->() [2/2]

VcfRecord const* operator-> ( ) const
inline

Definition at line 220 of file vcf_input_iterator.hpp.

◆ operator=() [1/2]

self_type& operator= ( self_type &&  )
default

◆ operator=() [2/2]

self_type& operator= ( self_type const &  )
default

◆ operator==()

bool operator== ( self_type const &  other) const
inline

Definition at line 260 of file vcf_input_iterator.hpp.

◆ record() [1/2]

VcfRecord& record ( )
inline

Definition at line 214 of file vcf_input_iterator.hpp.

◆ record() [2/2]

VcfRecord const& record ( ) const
inline

Definition at line 208 of file vcf_input_iterator.hpp.

Member Typedef Documentation

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 88 of file vcf_input_iterator.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 89 of file vcf_input_iterator.hpp.

◆ pointer

using pointer = value_type const*

Definition at line 86 of file vcf_input_iterator.hpp.

◆ reference

using reference = value_type const&

Definition at line 87 of file vcf_input_iterator.hpp.

◆ self_type

Definition at line 84 of file vcf_input_iterator.hpp.

◆ value_type

Definition at line 85 of file vcf_input_iterator.hpp.


The documentation for this class was generated from the following files: