A library for working with phylogenetic and population genetic data.
v0.32.0
SimplePileupInputStream< T > Class Template Reference

#include <genesis/population/format/simple_pileup_input_stream.hpp>

Detailed Description

template<class T = SimplePileupReader::Record>
class genesis::population::SimplePileupInputStream< T >

Iterate an input source and parse it as a (m)pileup file.

This simple wrapper allows easy iteration through the records/lines of an (m)pileup file line by line. See SimplePileupReader for details. The class is templated, so that it can be either used to produce SimplePileupReader::Record or Variant objects per line of the input mpileup file.

Basic usage:

auto it = SimplePileupInputStream<>( utils::from_file( infile ));
while( it ) {
    // work with it.record() or it->...
    ++it;
}

or

for( auto it = SimplePileupInputStream<Variant>( utils::from_file( infile )); it; ++it ) {
    // work with it
}

both allow to iterate each line in the file. The first instanciates an iterator over SimplePileupReader::Record, while the second over Variant.

Additionally, filtering of which samples (by index) to include can be provided, either as a vector of indices to consider, or as a bool vector that is true at the indices to consider. The latter filter does not need to contain the same number of values as the record has samples. If it is shorter, all samples after its last index will be ignored. If it is longer, the remaining entries are not used as a filter.

Definition at line 79 of file simple_pileup_input_stream.hpp.

Public Member Functions

 SimplePileupInputStream ()=default
 Create a default instance, with no input. More...
 
 SimplePileupInputStream (self_type &&)=default
 
 SimplePileupInputStream (self_type const &)=default
 
 SimplePileupInputStream (std::shared_ptr< utils::BaseInputSource > source, SimplePileupReader const &reader={})
 Create an instance that reads from an input source, and optionally take a SimplePileupReader with settings to be used. More...
 
 SimplePileupInputStream (std::shared_ptr< utils::BaseInputSource > source, std::vector< bool > const &sample_filter, SimplePileupReader const &reader={})
 Create an instance that reads from an input source, using only the samples at the indices where the sample_filter is true, and optionally take a SimplePileupReader with settings to be used. More...
 
 ~SimplePileupInputStream ()=default
 
bool good () const
 
void increment ()
 
 operator bool () const
 Return true iff dereferencing is valid, i.e., iff there is a line/record available. More...
 
bool operator!= (self_type const &it) const
 
T & operator* ()
 
T const & operator* () const
 
self_typeoperator++ ()
 
self_typeoperator++ (int)
 
T * operator-> ()
 
T const * operator-> () const
 
self_typeoperator= (self_type &&)=default
 
self_typeoperator= (self_type const &)=default
 
bool operator== (self_type const &it) const
 
SimplePileupReader const & reader () const
 
T & record ()
 
T const & record () const
 

Public Types

using const_reference = value_type const &
 
using difference_type = std::ptrdiff_t
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type *
 
using reference = value_type &
 
using self_type = SimplePileupInputStream
 
using value_type = T
 

Constructor & Destructor Documentation

◆ SimplePileupInputStream() [1/5]

Create a default instance, with no input.

◆ SimplePileupInputStream() [2/5]

SimplePileupInputStream ( std::shared_ptr< utils::BaseInputSource source,
SimplePileupReader const &  reader = {} 
)
inlineexplicit

Create an instance that reads from an input source, and optionally take a SimplePileupReader with settings to be used.

Definition at line 108 of file simple_pileup_input_stream.hpp.

◆ SimplePileupInputStream() [3/5]

SimplePileupInputStream ( std::shared_ptr< utils::BaseInputSource source,
std::vector< bool > const &  sample_filter,
SimplePileupReader const &  reader = {} 
)
inline

Create an instance that reads from an input source, using only the samples at the indices where the sample_filter is true, and optionally take a SimplePileupReader with settings to be used.

Definition at line 145 of file simple_pileup_input_stream.hpp.

◆ ~SimplePileupInputStream()

◆ SimplePileupInputStream() [4/5]

SimplePileupInputStream ( self_type const &  )
default

◆ SimplePileupInputStream() [5/5]

Member Function Documentation

◆ good()

bool good ( ) const
inline

Definition at line 179 of file simple_pileup_input_stream.hpp.

◆ increment()

void increment ( )
inline

Definition at line 239 of file simple_pileup_input_stream.hpp.

◆ operator bool()

operator bool ( ) const
inlineexplicit

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

Definition at line 174 of file simple_pileup_input_stream.hpp.

◆ operator!=()

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

Definition at line 249 of file simple_pileup_input_stream.hpp.

◆ operator*() [1/2]

T& operator* ( )
inline

Definition at line 218 of file simple_pileup_input_stream.hpp.

◆ operator*() [2/2]

T const& operator* ( ) const
inline

Definition at line 213 of file simple_pileup_input_stream.hpp.

◆ operator++() [1/2]

self_type& operator++ ( )
inline

Definition at line 227 of file simple_pileup_input_stream.hpp.

◆ operator++() [2/2]

self_type& operator++ ( int  )
inline

Definition at line 233 of file simple_pileup_input_stream.hpp.

◆ operator->() [1/2]

T* operator-> ( )
inline

Definition at line 208 of file simple_pileup_input_stream.hpp.

◆ operator->() [2/2]

T const* operator-> ( ) const
inline

Definition at line 203 of file simple_pileup_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 &  it) const
inline

Definition at line 244 of file simple_pileup_input_stream.hpp.

◆ reader()

SimplePileupReader const& reader ( ) const
inline

Definition at line 188 of file simple_pileup_input_stream.hpp.

◆ record() [1/2]

T& record ( )
inline

Definition at line 198 of file simple_pileup_input_stream.hpp.

◆ record() [2/2]

T const& record ( ) const
inline

Definition at line 193 of file simple_pileup_input_stream.hpp.

Member Typedef Documentation

◆ const_reference

using const_reference = value_type const&

Definition at line 91 of file simple_pileup_input_stream.hpp.

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 92 of file simple_pileup_input_stream.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 93 of file simple_pileup_input_stream.hpp.

◆ pointer

using pointer = value_type*

Definition at line 89 of file simple_pileup_input_stream.hpp.

◆ reference

Definition at line 90 of file simple_pileup_input_stream.hpp.

◆ self_type

◆ value_type

using value_type = T

Definition at line 88 of file simple_pileup_input_stream.hpp.


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