#include <genesis/population/window/base_window_iterator.hpp>
Base iterator class for Windows over the chromosomes of a genome.
This base class serves for sliding windows, windows over regions of a genome, etc.
The template parameters are:
ForwardIterator
: The type of the underlying iterator over the genome data (that is, the input iterator from which the windows take their data). Needs to have a member type value_type
that specifies the actual input type that the iterator produces, which we here call the InputType
(and typedef it as that).DataType
: The data type of the Window::Data that is stored in Window::Entry. The functor entry_input_function needs to be provided to convert from InputType
to this DataType
. By default, we take this to be the same as the InputType
, meaning that the Window contains the same data type as the underlying iterator that we get our data from.The three functors
have to be set in the class prior to starting the iteration.
The general usage of the derived classes that actually implement this iterator is as follows, on the example of the SlidingIntervalWindowIterator:
// Make an iterator using some underlying data iterator // that yields data for one position in the genome at a time. auto win_it = SlidingIntervalWindowIterator<ForwardIterator>( data_begin, data_end ); // Set functors to access the underlying data. win_it.entry_input_function = []( DataType const& variant ) { return variant; }; win_it.chromosome_function = []( DataType const& variant ) { return variant.chromosome; }; win_it.position_function = []( DataType const& variant ) { return variant.position; }; // Set properties specific to the derived class. win_it.width( width ); win_it.stride( stride ); // Iterate over Windows. for( auto it = win_it.begin(); it != win_it.end(); ++it ) { ... }
Other derived classes work accordingly.
Definition at line 106 of file base_window_iterator.hpp.
Public Member Functions | |
BaseWindowIterator (BaseWindowIterator &&)=default | |
BaseWindowIterator (BaseWindowIterator const &)=default | |
BaseWindowIterator (ForwardIterator begin, ForwardIterator end) | |
~BaseWindowIterator ()=default | |
Iterator | begin () |
Iterator | end () |
BaseWindowIterator & | operator= (BaseWindowIterator &&)=default |
BaseWindowIterator & | operator= (BaseWindowIterator const &)=default |
Public Types | |
using | const_reference = value_type const & |
using | Entry = typename Window::Entry |
using | InputType = typename ForwardIterator::value_type |
using | iterator_category = std::input_iterator_tag |
using | pointer = value_type * |
using | reference = value_type & |
using | self_type = BaseWindowIterator< ForwardIterator, DataType > |
using | value_type = Window |
using | Window = ::genesis::population::Window< DataType > |
Public Attributes | |
std::function< std::string(InputType const &)> | chromosome_function |
Functor that yields the current chromosome, given the input iterator data. More... | |
std::function< DataType(InputType const &)> | entry_input_function |
Functor to convert from the underlying input iterator 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 iterator data. More... | |
Classes | |
class | BaseIterator |
Internal PIMPL-like implementation of the iterator that produces Windows. More... | |
class | Iterator |
Internal public iterator that produces Windows. More... | |
Protected Member Functions | |
virtual std::unique_ptr< BaseIterator > | get_begin_iterator_ ()=0 |
virtual std::unique_ptr< BaseIterator > | get_end_iterator_ ()=0 |
|
inline |
Definition at line 481 of file base_window_iterator.hpp.
|
default |
|
default |
|
default |
|
inline |
Definition at line 502 of file base_window_iterator.hpp.
|
inline |
Definition at line 507 of file base_window_iterator.hpp.
|
protectedpure virtual |
|
protectedpure virtual |
|
default |
|
default |
using const_reference = value_type const& |
Definition at line 124 of file base_window_iterator.hpp.
using Entry = typename Window::Entry |
Definition at line 117 of file base_window_iterator.hpp.
using InputType = typename ForwardIterator::value_type |
Definition at line 118 of file base_window_iterator.hpp.
using iterator_category = std::input_iterator_tag |
Definition at line 120 of file base_window_iterator.hpp.
using pointer = value_type* |
Definition at line 122 of file base_window_iterator.hpp.
using reference = value_type& |
Definition at line 123 of file base_window_iterator.hpp.
using self_type = BaseWindowIterator<ForwardIterator, DataType> |
Definition at line 114 of file base_window_iterator.hpp.
using value_type = Window |
Definition at line 121 of file base_window_iterator.hpp.
using Window = ::genesis::population::Window<DataType> |
Definition at line 116 of file base_window_iterator.hpp.
std::function<std::string( InputType const& )> chromosome_function |
Functor that yields the current chromosome, given the input iterator data.
Definition at line 139 of file base_window_iterator.hpp.
std::function<DataType( InputType const& )> entry_input_function |
Functor to convert from the underlying input iterator that provides the data to fill the windows to the data that is stored per window.
Definition at line 134 of file base_window_iterator.hpp.
friend Iterator |
Definition at line 496 of file base_window_iterator.hpp.
std::function<size_t( InputType const& )> position_function |
Functor that yields the current position on the chromosome, given the input iterator data.
Definition at line 145 of file base_window_iterator.hpp.