A library for working with phylogenetic and population genetic data.
v0.32.0
PositionWindowStream< InputStreamIterator, DataType > Class Template Referencefinal

#include <genesis/population/window/position_window_stream.hpp>

Inherits BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >.

Detailed Description

template<class InputStreamIterator, class DataType = typename InputStreamIterator::value_type>
class genesis::population::PositionWindowStream< InputStreamIterator, DataType >

Stream for traversing each position along a genome individually.

With each step of the iteration, an inner Window iterator is yielded that contains exactly one position on a chromosome of the underlying input data stream. Then, when incrementing the main iterator, we move forward to the next position. Note that the entry_selection_function can be used to subset the loci that are used in the iteration. For instance, using make_default_position_window_stream() gives an instance of this class that only traverses the positions that have a Variant::status of passing.

This class is merely meant as a simplification over manually iteration, so that it can be used in line with the other window streams using the same interface of the BaseWindowStream. This class contains a quite unfortunate amount of boiler plate, but hopefully makes downstream algorithms easier to write.

The four functors

have to be set in the class prior to starting the iteration for the chromosome iterator. See make_position_window_stream() and make_default_position_window_stream() for helper functions that take care of this for most of our data types. See BaseWindowStream for more details on the first three functors, the template parameters.

See also
make_position_window_stream()
make_default_position_window_stream()

Definition at line 86 of file position_window_stream.hpp.

Public Member Functions

 PositionWindowStream (InputStreamIterator begin, InputStreamIterator end)
 
 PositionWindowStream (PositionWindowStream &&)=default
 
 PositionWindowStream (PositionWindowStream const &)=default
 
virtual ~PositionWindowStream () override=default
 
PositionWindowStreamoperator= (PositionWindowStream &&)=default
 
PositionWindowStreamoperator= (PositionWindowStream const &)=default
 
- Public Member Functions inherited from BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >
 BaseWindowStream (BaseWindowStream &&)=default
 
 BaseWindowStream (BaseWindowStream const &)=default
 
 BaseWindowStream (InputStreamIterator begin, InputStreamIterator end)
 
virtual ~BaseWindowStream ()=default
 
self_typeadd_begin_callback (std::function< void()> const &callback)
 Add a callback function that is executed when beginning the iteration. More...
 
self_typeadd_end_callback (std::function< void()> const &callback)
 Add a callback function that is executed when the end of the iteration is reached. More...
 
self_typeadd_on_enter_observer (std::function< void(typename ::genesis::population::Window< typename InputStreamIterator::value_type > const &)> const &observer)
 Add a observer function that is executed once for each window during the iteration, when entering the window during the iteration. More...
 
self_typeadd_on_leave_observer (std::function< void(typename ::genesis::population::Window< typename InputStreamIterator::value_type > const &)> const &observer)
 Add a observer function that is executed once for each window during the iteration, when leaving the window during the iteration. More...
 
Iterator begin ()
 
self_typeclear_callbacks ()
 Clear all functions that have been added via add_begin_callback() and add_end_callback(). More...
 
self_typeclear_observers ()
 Clear all functions that are executed on incrementing to the next element. More...
 
Iterator end ()
 
BaseWindowStreamoperator= (BaseWindowStream &&)=default
 
BaseWindowStreamoperator= (BaseWindowStream const &)=default
 

Public Types

using base_type = BaseWindowStream< InputStreamIterator, DataType >
 
using const_reference = value_type const &
 
using Entry = typename Window::Entry
 
using InputType = typename InputStreamIterator::value_type
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type *
 
using reference = value_type &
 
using self_type = PositionWindowStream< InputStreamIterator, DataType >
 
using value_type = Window
 
using Window = ::genesis::population::Window< DataType >
 
- Public Types inherited from BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >
using const_reference = value_type const &
 
using DataType = typename InputStreamIterator::value_type
 
using InputStreamType = InputStreamIterator
 
using InputType = typename InputStreamIterator::value_type
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type *
 
using reference = value_type &
 
using self_type = BaseWindowStream< InputStreamIterator, DataType, typename ::genesis::population::Window< typename InputStreamIterator::value_type > >
 
using value_type = typename ::genesis::population::Window< typename InputStreamIterator::value_type >
 

Public Attributes

friend DerivedIterator
 
std::function< bool(InputType const &)> entry_selection_function
 Functor that takes an entry of the underlying input stream and returns whether that entry should be selected as part of the data stream iterated over here. More...
 
- Public Attributes inherited from BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >
std::function< std::string(InputType const &)> chromosome_function
 Functor that yields the current chromosome, given the input stream data. More...
 
std::function< DataType(InputType const &)> entry_input_function
 Functor to convert from the underlying input stream that provides the data to fill the windows to the data that is stored per window. More...
 
friend Iterator
 
std::function< size_t(InputType const &)> position_function
 Functor that yields the current position on the chromosome, given the input stream data. More...
 

Classes

class  DerivedIterator
 Internal iterator that produces WindowViews. More...
 

Protected Member Functions

std::unique_ptr< typename base_type::BaseIteratorget_begin_iterator_ () override final
 Get the begin iterator. More...
 
std::unique_ptr< typename base_type::BaseIteratorget_end_iterator_ () override final
 Get the end iterator. More...
 
- Protected Member Functions inherited from BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >
 BaseWindowStream ()=default
 

Constructor & Destructor Documentation

◆ PositionWindowStream() [1/3]

PositionWindowStream ( InputStreamIterator  begin,
InputStreamIterator  end 
)
inline

Definition at line 295 of file position_window_stream.hpp.

◆ ~PositionWindowStream()

virtual ~PositionWindowStream ( )
overridevirtualdefault

◆ PositionWindowStream() [2/3]

PositionWindowStream ( PositionWindowStream< InputStreamIterator, DataType > const &  )
default

◆ PositionWindowStream() [3/3]

PositionWindowStream ( PositionWindowStream< InputStreamIterator, DataType > &&  )
default

Member Function Documentation

◆ get_begin_iterator_()

std::unique_ptr<typename base_type::BaseIterator> get_begin_iterator_ ( )
inlinefinaloverrideprotectedvirtual

Get the begin iterator.

Needs to be implemented by the derived class, to give the correct derived BaseIterator instance.

Implements BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >.

Definition at line 318 of file position_window_stream.hpp.

◆ get_end_iterator_()

std::unique_ptr<typename base_type::BaseIterator> get_end_iterator_ ( )
inlinefinaloverrideprotectedvirtual

Get the end iterator.

Needs to be implemented by the derived class, to give the correct derived BaseIterator instance.

Implements BaseWindowStream< InputStreamIterator, typename InputStreamIterator::value_type >.

Definition at line 327 of file position_window_stream.hpp.

◆ operator=() [1/2]

PositionWindowStream& operator= ( PositionWindowStream< InputStreamIterator, DataType > &&  )
default

◆ operator=() [2/2]

PositionWindowStream& operator= ( PositionWindowStream< InputStreamIterator, DataType > const &  )
default

Member Typedef Documentation

◆ base_type

using base_type = BaseWindowStream<InputStreamIterator, DataType>

Definition at line 95 of file position_window_stream.hpp.

◆ const_reference

using const_reference = value_type const&

Definition at line 105 of file position_window_stream.hpp.

◆ Entry

using Entry = typename Window::Entry

Definition at line 98 of file position_window_stream.hpp.

◆ InputType

using InputType = typename InputStreamIterator::value_type

Definition at line 99 of file position_window_stream.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 101 of file position_window_stream.hpp.

◆ pointer

using pointer = value_type*

Definition at line 103 of file position_window_stream.hpp.

◆ reference

Definition at line 104 of file position_window_stream.hpp.

◆ self_type

using self_type = PositionWindowStream<InputStreamIterator, DataType>

Definition at line 94 of file position_window_stream.hpp.

◆ value_type

using value_type = Window

Definition at line 102 of file position_window_stream.hpp.

◆ Window

Member Data Documentation

◆ DerivedIterator

Definition at line 309 of file position_window_stream.hpp.

◆ entry_selection_function

std::function<bool( InputType const& )> entry_selection_function

Functor that takes an entry of the underlying input stream and returns whether that entry should be selected as part of the data stream iterated over here.

Any entry that is selected (the function here returning true) will be considered here as a single window of size one. Entries for which the function returns false are skipped.

Definition at line 118 of file position_window_stream.hpp.


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