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

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

Detailed Description

Iterate an input source and parse it as a sync file.

This simple wrapper allows easy iteration through the records/lines of an sync file as defined by PoPoolation2, line by line. See SyncReader for details.

Basic usage:

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

or

for( auto it = SyncInputStream( 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, as a bool vector that is true at the indices to consider. The filter does not need to contain the same number of values as the Variant/line 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 sync_input_stream.hpp.

Public Member Functions

 SyncInputStream ()=default
 Create a default instance, with no input. More...
 
 SyncInputStream (self_type &&)=default
 
 SyncInputStream (self_type const &)=default
 
 SyncInputStream (std::shared_ptr< utils::BaseInputSource > source, std::vector< bool > const &sample_filter, SyncReader 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 SyncReader with settings to be used. More...
 
 SyncInputStream (std::shared_ptr< utils::BaseInputSource > source, SyncReader const &reader={})
 Create an instance that reads from an input source, and optionally take a SyncReader with settings to be used. More...
 
 ~SyncInputStream ()=default
 
std::vector< std::string > const & get_sample_names () const
 
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
 
Variantoperator* ()
 
Variant const & operator* () const
 
self_typeoperator++ ()
 
self_typeoperator++ (int)
 
Variantoperator-> ()
 
Variant const * operator-> () const
 
self_typeoperator= (self_type &&)=default
 
self_typeoperator= (self_type const &)=default
 
bool operator== (self_type const &it) const
 
Variantvariant ()
 
Variant const & variant () 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 = SyncInputStream
 
using value_type = Variant
 

Constructor & Destructor Documentation

◆ SyncInputStream() [1/5]

SyncInputStream ( )
default

Create a default instance, with no input.

◆ SyncInputStream() [2/5]

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

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

Definition at line 103 of file sync_input_stream.hpp.

◆ SyncInputStream() [3/5]

SyncInputStream ( std::shared_ptr< utils::BaseInputSource source,
std::vector< bool > const &  sample_filter,
SyncReader 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 SyncReader with settings to be used.

Definition at line 127 of file sync_input_stream.hpp.

◆ ~SyncInputStream()

~SyncInputStream ( )
default

◆ SyncInputStream() [4/5]

SyncInputStream ( self_type const &  )
default

◆ SyncInputStream() [5/5]

SyncInputStream ( self_type &&  )
default

Member Function Documentation

◆ get_sample_names()

std::vector<std::string> const& get_sample_names ( ) const
inline

Definition at line 172 of file sync_input_stream.hpp.

◆ good()

bool good ( ) const
inline

Definition at line 163 of file sync_input_stream.hpp.

◆ increment()

void increment ( )
inline

Definition at line 223 of file sync_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 158 of file sync_input_stream.hpp.

◆ operator!=()

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

Definition at line 255 of file sync_input_stream.hpp.

◆ operator*() [1/2]

Variant& operator* ( )
inline

Definition at line 202 of file sync_input_stream.hpp.

◆ operator*() [2/2]

Variant const& operator* ( ) const
inline

Definition at line 197 of file sync_input_stream.hpp.

◆ operator++() [1/2]

self_type& operator++ ( )
inline

Definition at line 211 of file sync_input_stream.hpp.

◆ operator++() [2/2]

self_type& operator++ ( int  )
inline

Definition at line 217 of file sync_input_stream.hpp.

◆ operator->() [1/2]

Variant* operator-> ( )
inline

Definition at line 192 of file sync_input_stream.hpp.

◆ operator->() [2/2]

Variant const* operator-> ( ) const
inline

Definition at line 187 of file sync_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 250 of file sync_input_stream.hpp.

◆ variant() [1/2]

Variant& variant ( )
inline

Definition at line 182 of file sync_input_stream.hpp.

◆ variant() [2/2]

Variant const& variant ( ) const
inline

Definition at line 177 of file sync_input_stream.hpp.

Member Typedef Documentation

◆ const_reference

using const_reference = value_type const&

Definition at line 86 of file sync_input_stream.hpp.

◆ difference_type

using difference_type = std::ptrdiff_t

Definition at line 87 of file sync_input_stream.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 88 of file sync_input_stream.hpp.

◆ pointer

using pointer = value_type*

Definition at line 84 of file sync_input_stream.hpp.

◆ reference

Definition at line 85 of file sync_input_stream.hpp.

◆ self_type

Definition at line 82 of file sync_input_stream.hpp.

◆ value_type

Definition at line 83 of file sync_input_stream.hpp.


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