A library for working with phylogenetic and population genetic data.
v0.32.0
VcfInputStream Class Reference

#include <genesis/population/format/vcf_input_stream.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 = VcfInputStream( infile );
while( it ) {
    // work with it.record() or it->...
    ++it;
}

or

for( auto it = VcfInputStream( 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_stream.hpp.

Public Member Functions

 VcfInputStream ()=default
 Create a default instance, with no input. This is also the past-the-end iterator. More...
 
 VcfInputStream (self_type &&)=default
 
 VcfInputStream (self_type const &)=default
 
 VcfInputStream (std::string const &filename, bool expect_ordered=true)
 Create an instance that reads from an input file name. More...
 
 VcfInputStream (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...
 
 ~VcfInputStream ()=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 = VcfInputStream
 
using value_type = VcfRecord
 

Constructor & Destructor Documentation

◆ VcfInputStream() [1/5]

VcfInputStream ( )
default

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

◆ VcfInputStream() [2/5]

VcfInputStream ( 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_stream.hpp.

◆ VcfInputStream() [3/5]

VcfInputStream ( 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_stream.hpp.

◆ ~VcfInputStream()

~VcfInputStream ( )
default

◆ VcfInputStream() [4/5]

VcfInputStream ( self_type const &  )
default

◆ VcfInputStream() [5/5]

VcfInputStream ( self_type &&  )
default

Member Function Documentation

◆ filename()

std::string const& filename ( ) const
inline

Definition at line 174 of file vcf_input_stream.hpp.

◆ good()

bool good ( ) const
inline

Definition at line 165 of file vcf_input_stream.hpp.

◆ header() [1/2]

VcfHeader& header ( )
inline

Definition at line 202 of file vcf_input_stream.hpp.

◆ header() [2/2]

VcfHeader const& header ( ) const
inline

Definition at line 196 of file vcf_input_stream.hpp.

◆ hts_file() [1/2]

HtsFile& hts_file ( )
inline

Definition at line 190 of file vcf_input_stream.hpp.

◆ hts_file() [2/2]

HtsFile const& hts_file ( ) const
inline

Definition at line 179 of file vcf_input_stream.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_stream.hpp.

◆ operator!=()

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

Definition at line 268 of file vcf_input_stream.hpp.

◆ operator*() [1/2]

VcfRecord& operator* ( )
inline

Definition at line 238 of file vcf_input_stream.hpp.

◆ operator*() [2/2]

VcfRecord const& operator* ( ) const
inline

Definition at line 232 of file vcf_input_stream.hpp.

◆ operator++() [1/2]

self_type& operator++ ( )
inline

Definition at line 248 of file vcf_input_stream.hpp.

◆ operator++() [2/2]

self_type& operator++ ( int  )
inline

Definition at line 254 of file vcf_input_stream.hpp.

◆ operator->() [1/2]

VcfRecord* operator-> ( )
inline

Definition at line 226 of file vcf_input_stream.hpp.

◆ operator->() [2/2]

VcfRecord const* operator-> ( ) const
inline

Definition at line 220 of file vcf_input_stream.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_stream.hpp.

◆ record() [1/2]

VcfRecord& record ( )
inline

Definition at line 214 of file vcf_input_stream.hpp.

◆ record() [2/2]

VcfRecord const& record ( ) const
inline

Definition at line 208 of file vcf_input_stream.hpp.

Member Typedef Documentation

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 88 of file vcf_input_stream.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 89 of file vcf_input_stream.hpp.

◆ pointer

using pointer = value_type const*

Definition at line 86 of file vcf_input_stream.hpp.

◆ reference

using reference = value_type const&

Definition at line 87 of file vcf_input_stream.hpp.

◆ self_type

Definition at line 84 of file vcf_input_stream.hpp.

◆ value_type

Definition at line 85 of file vcf_input_stream.hpp.


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