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

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

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

Detailed Description

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

Stream for sliding Windows of fixed sized intervals over the chromosomes of a genome.

The three functors

have to be set in the class prior to starting the iteration, as well as the width(). All other settings are optional and/or defaulted to reasonable values. See make_interval_window_stream() and make_default_interval_window_stream() for helper functions that take care of this for most of our data types.

See BaseWindowStream for more details on the three functors, the template parameters, and general usage examples of the class.

See also
make_interval_window_stream()
make_default_interval_window_stream()

Definition at line 74 of file interval_window_stream.hpp.

Public Member Functions

 IntervalWindowStream (InputStreamIterator begin, InputStreamIterator end, size_t width=0, size_t stride=0)
 
 IntervalWindowStream (IntervalWindowStream &&)=default
 
 IntervalWindowStream (IntervalWindowStream const &)=default
 
virtual ~IntervalWindowStream () override=default
 
bool emit_leading_empty_windows () const
 
self_typeemit_leading_empty_windows (bool value)
 Select whether the iterator produces empty windows in the beginning of each chromosome, before the first actual position that is reported by the underlying data. More...
 
IntervalWindowStreamoperator= (IntervalWindowStream &&)=default
 
IntervalWindowStreamoperator= (IntervalWindowStream const &)=default
 
size_t stride () const
 
self_typestride (size_t value)
 Stride of the Window, that is, how many positions to move forward with each iteration. More...
 
size_t width () const
 
self_typewidth (size_t value)
 Width of the Window, that is, the fixed length along the chromosome. More...
 
- 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 = IntervalWindowStream< 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
 
- 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 Windows. More...
 

Protected Member Functions

std::unique_ptr< typename BaseWindowStream< InputStreamIterator, DataType >::BaseIterator > get_begin_iterator_ () override final
 Get the begin iterator. More...
 
std::unique_ptr< typename BaseWindowStream< InputStreamIterator, DataType >::BaseIterator > get_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

◆ IntervalWindowStream() [1/3]

IntervalWindowStream ( InputStreamIterator  begin,
InputStreamIterator  end,
size_t  width = 0,
size_t  stride = 0 
)
inline

Definition at line 368 of file interval_window_stream.hpp.

◆ ~IntervalWindowStream()

virtual ~IntervalWindowStream ( )
overridevirtualdefault

◆ IntervalWindowStream() [2/3]

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

◆ IntervalWindowStream() [3/3]

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

Member Function Documentation

◆ emit_leading_empty_windows() [1/2]

bool emit_leading_empty_windows ( ) const
inline

Definition at line 442 of file interval_window_stream.hpp.

◆ emit_leading_empty_windows() [2/2]

self_type& emit_leading_empty_windows ( bool  value)
inline

Select whether the iterator produces empty windows in the beginning of each chromosome, before the first actual position that is reported by the underlying data.

Say the underlying iterator has the first Variant (or whatever datatype it iterates over) at position 1020 for a chromosome, and we use a window size of 100. If this setting is set to true, the iterator will emit 10 empty windows before reaching this position. If set to false, it will skip these, and start at position 1001, which is the first one that would have been reached by striding along the chromosome.

Definition at line 436 of file interval_window_stream.hpp.

◆ get_begin_iterator_()

std::unique_ptr<typename BaseWindowStream<InputStreamIterator, DataType>::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 454 of file interval_window_stream.hpp.

◆ get_end_iterator_()

std::unique_ptr<typename BaseWindowStream<InputStreamIterator, DataType>::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 463 of file interval_window_stream.hpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ stride() [1/2]

size_t stride ( ) const
inline

Definition at line 421 of file interval_window_stream.hpp.

◆ stride() [2/2]

self_type& stride ( size_t  value)
inline

Stride of the Window, that is, how many positions to move forward with each iteration.

The stride his is the shift towards the next interval, determining how the first and last position in each Window change. It has to be <= width. If stride is set to 0 (default), it is set automatically to the width when starting the iteration.

Definition at line 415 of file interval_window_stream.hpp.

◆ width() [1/2]

size_t width ( ) const
inline

Definition at line 403 of file interval_window_stream.hpp.

◆ width() [2/2]

self_type& width ( size_t  value)
inline

Width of the Window, that is, the fixed length along the chromosome.

The width has to be > 0. This is the length of the interval, determining the first and last position in each Window.

Definition at line 397 of file interval_window_stream.hpp.

Member Typedef Documentation

◆ base_type

using base_type = BaseWindowStream<InputStreamIterator, DataType>

Definition at line 83 of file interval_window_stream.hpp.

◆ const_reference

using const_reference = value_type const&

Definition at line 93 of file interval_window_stream.hpp.

◆ Entry

using Entry = typename Window::Entry

Definition at line 86 of file interval_window_stream.hpp.

◆ InputType

using InputType = typename InputStreamIterator::value_type

Definition at line 87 of file interval_window_stream.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 89 of file interval_window_stream.hpp.

◆ pointer

using pointer = value_type*

Definition at line 91 of file interval_window_stream.hpp.

◆ reference

Definition at line 92 of file interval_window_stream.hpp.

◆ self_type

using self_type = IntervalWindowStream<InputStreamIterator, DataType>

Definition at line 82 of file interval_window_stream.hpp.

◆ value_type

using value_type = Window

Definition at line 90 of file interval_window_stream.hpp.

◆ Window

Member Data Documentation

◆ DerivedIterator

Definition at line 385 of file interval_window_stream.hpp.


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