A library for working with phylogenetic and population genetic data.
v0.27.0
VariantParallelInputIterator::Iterator Class Reference

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

Detailed Description

Iterator over loci of the input sources.

This is the class that does the actual work. Use the dereference operator*() and operator->() or the access functions variants() and variant_at() to get the set of variants at the current locus() of the iteration, or use joined_variant() to get one Variant that has all sample BaseCounts joined into it.

Definition at line 205 of file variant_parallel_input_iterator.hpp.

Public Member Functions

 Iterator (self_type &&)=default
 
 Iterator (self_type const &)=default
 
 ~Iterator ()=default
 
VariantInputIterator const & input_at (size_t index) const
 Get access to an input iterator that has been added to this parallel iterator. More...
 
std::vector< VariantInputIterator > const & inputs () const
 Get access to the input iterators that have been added to this parallel iterator. More...
 
Variant joined_variant (bool allow_ref_base_mismatches=false, bool allow_alt_base_mismatches=true, bool move_samples=false)
 Create a single Variant instance that combines all Variants from the input sources at the current locus. More...
 
GenomeLocus const & locus () const
 Return the current locus where the iteration is at. More...
 
 operator bool () const
 
bool operator!= (self_type const &it) const
 
std::vector< utils::Optional< Variant > > & operator* ()
 
const std::vector< utils::Optional< Variant > > & operator* () const
 
self_typeoperator++ ()
 
self_type operator++ (int)
 
std::vector< utils::Optional< Variant > > * operator-> ()
 
const std::vector< utils::Optional< Variant > > * operator-> () const
 
Iteratoroperator= (self_type &&)=default
 
Iteratoroperator= (self_type const &)=default
 
bool operator== (self_type const &it) const
 Compare two iterators for equality. More...
 
utils::Optional< Variant > & variant_at (size_t index)
 Return the data of the input iterators at the given index at the current locus. More...
 
utils::Optional< Variant > const & variant_at (size_t index) const
 Return the data of the input iterators at the given index at the current locus. More...
 
std::vector< utils::Optional< Variant > > & variants ()
 Return the data of all input iterators at the current locus. More...
 
std::vector< utils::Optional< Variant > > const & variants () const
 Return the data of all input iterators at the current locus. More...
 

Public Types

using iterator_category = std::input_iterator_tag
 
using pointer = value_type const *
 
using reference = value_type const &
 
using self_type = VariantParallelInputIterator::Iterator
 
using value_type = std::vector< utils::Optional< Variant > >
 

Public Attributes

friend VariantParallelInputIterator
 

Constructor & Destructor Documentation

◆ ~Iterator()

~Iterator ( )
default

◆ Iterator() [1/2]

Iterator ( self_type const &  )
default

◆ Iterator() [2/2]

Iterator ( self_type &&  )
default

Member Function Documentation

◆ input_at()

VariantInputIterator const& input_at ( size_t  index) const
inline

Get access to an input iterator that has been added to this parallel iterator.

This is just a concenience function that forwards the input_at() function of VariantParallelInputIterator. See there for details.

Definition at line 300 of file variant_parallel_input_iterator.hpp.

◆ inputs()

std::vector<VariantInputIterator> const& inputs ( ) const
inline

Get access to the input iterators that have been added to this parallel iterator.

This is just a concenience function that forwards the inputs() function of VariantParallelInputIterator. See there for details.

Definition at line 286 of file variant_parallel_input_iterator.hpp.

◆ joined_variant()

Variant joined_variant ( bool  allow_ref_base_mismatches = false,
bool  allow_alt_base_mismatches = true,
bool  move_samples = false 
)

Create a single Variant instance that combines all Variants from the input sources at the current locus.

This joins all BaseCounts of all Variants of the input sources at the current locus. For sources that have no data at the current position, as many empty BaseCounts (with all zero counts) are inserted as the iterator has samples; hence, the number of BaseCounts in the Variant::samples of the returned Variant (as indicated by Variant.samples.size()) is kept consistent at each locus.

By default, we expect that the Variants of each iterator have the same Variant::reference_base; if not, the function throws an exception. For the Variant::alternative_base, by default we allow different bases, as not every file format contains alternative bases, meaning that it might be set to ‘'N’` instead of the actual value in those file formats. To change the default behaviour, use allow_ref_base_mismatches and/or allow_alt_base_mismatches as needed. When a mismatch is allowed, in cases of a mismatch, the returned Variant will contain an ‘'N’` as the base.

Lastly, by default, we copy the BaseCounts of all Variant::samples into the resulting Variant. If however these are not needed at the current iterator position any more (that is, if this iterator is not dereferenced or the variants() function is not called) after calling this function, we can instead move them, for efficiency.

Definition at line 125 of file variant_parallel_input_iterator.cpp.

◆ locus()

GenomeLocus const& locus ( ) const
inline

Return the current locus where the iteration is at.

Definition at line 362 of file variant_parallel_input_iterator.hpp.

◆ operator bool()

operator bool ( ) const
inline

Definition at line 384 of file variant_parallel_input_iterator.hpp.

◆ operator!=()

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

Definition at line 402 of file variant_parallel_input_iterator.hpp.

◆ operator*() [1/2]

std::vector<utils::Optional<Variant> >& operator* ( )
inline

Definition at line 255 of file variant_parallel_input_iterator.hpp.

◆ operator*() [2/2]

const std::vector<utils::Optional<Variant> >& operator* ( ) const
inline

Definition at line 250 of file variant_parallel_input_iterator.hpp.

◆ operator++() [1/2]

self_type& operator++ ( )
inline

Definition at line 371 of file variant_parallel_input_iterator.hpp.

◆ operator++() [2/2]

self_type operator++ ( int  )
inline

Definition at line 377 of file variant_parallel_input_iterator.hpp.

◆ operator->() [1/2]

std::vector<utils::Optional<Variant> >* operator-> ( )
inline

Definition at line 245 of file variant_parallel_input_iterator.hpp.

◆ operator->() [2/2]

const std::vector<utils::Optional<Variant> >* operator-> ( ) const
inline

Definition at line 240 of file variant_parallel_input_iterator.hpp.

◆ operator=() [1/2]

Iterator& operator= ( self_type &&  )
default

◆ operator=() [2/2]

Iterator& operator= ( self_type const &  )
default

◆ operator==()

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

Compare two iterators for equality.

Any two iterators that are created by calling begin() on the same LambdaIterator instance will compare equal, as long as neither of them is past-the-end. A valid (not past-the-end) iterator and an end() iterator will not compare equal, no matter from which LambdaIterator they were created.

Definition at line 397 of file variant_parallel_input_iterator.hpp.

◆ variant_at() [1/2]

utils::Optional<Variant>& variant_at ( size_t  index)
inline

Return the data of the input iterators at the given index at the current locus.

The indexing follows the order in which inputs have been added to the VariantParallelInputIterator. See also VariantParallelInputIterator::input_size() to get their count.

An input source that do not have data at the current locus() has an empty optional.

Definition at line 323 of file variant_parallel_input_iterator.hpp.

◆ variant_at() [2/2]

utils::Optional<Variant> const& variant_at ( size_t  index) const
inline

Return the data of the input iterators at the given index at the current locus.

The indexing follows the order in which inputs have been added to the VariantParallelInputIterator. See also VariantParallelInputIterator::input_size() to get their count.

An input source that do not have data at the current locus() has an empty optional.

Definition at line 314 of file variant_parallel_input_iterator.hpp.

◆ variants() [1/2]

std::vector<utils::Optional<Variant> >& variants ( )
inline

Return the data of all input iterators at the current locus.

Any input sources that do not have data at the current locus() have an empty optional in the vector.

Definition at line 274 of file variant_parallel_input_iterator.hpp.

◆ variants() [2/2]

std::vector<utils::Optional<Variant> > const& variants ( ) const
inline

Return the data of all input iterators at the current locus.

Any input sources that do not have data at the current locus() have an empty optional in the vector.

Definition at line 266 of file variant_parallel_input_iterator.hpp.

Member Typedef Documentation

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 217 of file variant_parallel_input_iterator.hpp.

◆ pointer

using pointer = value_type const*

Definition at line 215 of file variant_parallel_input_iterator.hpp.

◆ reference

using reference = value_type const&

Definition at line 216 of file variant_parallel_input_iterator.hpp.

◆ self_type

◆ value_type

using value_type = std::vector<utils::Optional<Variant> >

Definition at line 214 of file variant_parallel_input_iterator.hpp.

Member Data Documentation

◆ VariantParallelInputIterator


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