A library for working with phylogenetic data.
v0.25.0
SimplePileupInputIterator Class Reference

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

Detailed Description

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.

Basic usage:

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

or

for( auto it = SimplePileupInputIterator( utils::from_file( infile )); it; ++it ) {
    // work with it
}

both allow to iterate each line in the file.

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 74 of file simple_pileup_input_iterator.hpp.

Public Member Functions

 SimplePileupInputIterator ()=default
 Create a default instance, with no input. More...
 
 SimplePileupInputIterator (self_type &&)=default
 
 SimplePileupInputIterator (self_type const &)=default
 
 SimplePileupInputIterator (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...
 
 SimplePileupInputIterator (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...
 
 SimplePileupInputIterator (std::shared_ptr< utils::BaseInputSource > source, std::vector< size_t > const &sample_indices, SimplePileupReader const &reader={})
 Create an instance that reads from an input source, using only the samples at the indices given in the sample_indices, and optionally take a SimplePileupReader with settings to be used. More...
 
 ~SimplePileupInputIterator ()=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
 
SimplePileupReader::Recordoperator* ()
 
SimplePileupReader::Record const & operator* () const
 
self_typeoperator++ ()
 
self_typeoperator++ (int)
 
SimplePileupReader::Recordoperator-> ()
 
SimplePileupReader::Record const * operator-> () const
 
self_typeoperator= (self_type &&)=default
 
self_typeoperator= (self_type const &)=default
 
bool operator== (self_type const &it) const
 
SimplePileupReader::Recordrecord ()
 
SimplePileupReader::Record 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 = SimplePileupInputIterator
 
using value_type = SimplePileupReader::Record
 

Constructor & Destructor Documentation

◆ SimplePileupInputIterator() [1/6]

Create a default instance, with no input.

◆ SimplePileupInputIterator() [2/6]

SimplePileupInputIterator ( 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 103 of file simple_pileup_input_iterator.hpp.

◆ SimplePileupInputIterator() [3/6]

SimplePileupInputIterator ( std::shared_ptr< utils::BaseInputSource source,
std::vector< size_t > const &  sample_indices,
SimplePileupReader const &  reader = {} 
)
inline

Create an instance that reads from an input source, using only the samples at the indices given in the sample_indices, and optionally take a SimplePileupReader with settings to be used.

Definition at line 119 of file simple_pileup_input_iterator.hpp.

◆ SimplePileupInputIterator() [4/6]

SimplePileupInputIterator ( 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 140 of file simple_pileup_input_iterator.hpp.

◆ ~SimplePileupInputIterator()

◆ SimplePileupInputIterator() [5/6]

SimplePileupInputIterator ( self_type const &  )
default

◆ SimplePileupInputIterator() [6/6]

Member Function Documentation

◆ good()

bool good ( ) const
inline

Definition at line 174 of file simple_pileup_input_iterator.hpp.

◆ increment()

void increment ( )
inline

Definition at line 229 of file simple_pileup_input_iterator.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 169 of file simple_pileup_input_iterator.hpp.

◆ operator!=()

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

Definition at line 243 of file simple_pileup_input_iterator.hpp.

◆ operator*() [1/2]

SimplePileupReader::Record& operator* ( )
inline

Definition at line 208 of file simple_pileup_input_iterator.hpp.

◆ operator*() [2/2]

SimplePileupReader::Record const& operator* ( ) const
inline

Definition at line 203 of file simple_pileup_input_iterator.hpp.

◆ operator++() [1/2]

self_type& operator++ ( )
inline

Definition at line 217 of file simple_pileup_input_iterator.hpp.

◆ operator++() [2/2]

self_type& operator++ ( int  )
inline

Definition at line 223 of file simple_pileup_input_iterator.hpp.

◆ operator->() [1/2]

SimplePileupReader::Record* operator-> ( )
inline

Definition at line 198 of file simple_pileup_input_iterator.hpp.

◆ operator->() [2/2]

SimplePileupReader::Record const* operator-> ( ) const
inline

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

Definition at line 238 of file simple_pileup_input_iterator.hpp.

◆ record() [1/2]

SimplePileupReader::Record& record ( )
inline

Definition at line 188 of file simple_pileup_input_iterator.hpp.

◆ record() [2/2]

SimplePileupReader::Record const& record ( ) const
inline

Definition at line 183 of file simple_pileup_input_iterator.hpp.

Member Typedef Documentation

◆ const_reference

using const_reference = value_type const&

Definition at line 86 of file simple_pileup_input_iterator.hpp.

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 87 of file simple_pileup_input_iterator.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 88 of file simple_pileup_input_iterator.hpp.

◆ pointer

using pointer = value_type*

Definition at line 84 of file simple_pileup_input_iterator.hpp.

◆ reference

Definition at line 85 of file simple_pileup_input_iterator.hpp.

◆ self_type

◆ value_type


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