A library for working with phylogenetic and population genetic data.
v0.27.0
BaseWindowIterator< ForwardIterator, DataType > Class Template Referenceabstract

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

Detailed Description

template<class ForwardIterator, class DataType = typename ForwardIterator::value_type>
class genesis::population::BaseWindowIterator< ForwardIterator, DataType >

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 ()
 
BaseWindowIteratoroperator= (BaseWindowIterator &&)=default
 
BaseWindowIteratoroperator= (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< BaseIteratorget_begin_iterator_ ()=0
 
virtual std::unique_ptr< BaseIteratorget_end_iterator_ ()=0
 

Constructor & Destructor Documentation

◆ BaseWindowIterator() [1/3]

BaseWindowIterator ( ForwardIterator  begin,
ForwardIterator  end 
)
inline

Definition at line 481 of file base_window_iterator.hpp.

◆ ~BaseWindowIterator()

~BaseWindowIterator ( )
default

◆ BaseWindowIterator() [2/3]

BaseWindowIterator ( BaseWindowIterator< ForwardIterator, DataType > const &  )
default

◆ BaseWindowIterator() [3/3]

BaseWindowIterator ( BaseWindowIterator< ForwardIterator, DataType > &&  )
default

Member Function Documentation

◆ begin()

Iterator begin ( )
inline

Definition at line 502 of file base_window_iterator.hpp.

◆ end()

Iterator end ( )
inline

Definition at line 507 of file base_window_iterator.hpp.

◆ get_begin_iterator_()

virtual std::unique_ptr<BaseIterator> get_begin_iterator_ ( )
protectedpure virtual

◆ get_end_iterator_()

virtual std::unique_ptr<BaseIterator> get_end_iterator_ ( )
protectedpure virtual

◆ operator=() [1/2]

BaseWindowIterator& operator= ( BaseWindowIterator< ForwardIterator, DataType > &&  )
default

◆ operator=() [2/2]

BaseWindowIterator& operator= ( BaseWindowIterator< ForwardIterator, DataType > const &  )
default

Member Typedef Documentation

◆ const_reference

using const_reference = value_type const&

Definition at line 124 of file base_window_iterator.hpp.

◆ Entry

using Entry = typename Window::Entry

Definition at line 117 of file base_window_iterator.hpp.

◆ InputType

using InputType = typename ForwardIterator::value_type

Definition at line 118 of file base_window_iterator.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 120 of file base_window_iterator.hpp.

◆ pointer

using pointer = value_type*

Definition at line 122 of file base_window_iterator.hpp.

◆ reference

Definition at line 123 of file base_window_iterator.hpp.

◆ self_type

using self_type = BaseWindowIterator<ForwardIterator, DataType>

Definition at line 114 of file base_window_iterator.hpp.

◆ value_type

using value_type = Window

Definition at line 121 of file base_window_iterator.hpp.

◆ Window

using Window = ::genesis::population::Window<DataType>

Definition at line 116 of file base_window_iterator.hpp.

Member Data Documentation

◆ chromosome_function

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.

◆ entry_input_function

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.

◆ Iterator

friend Iterator

Definition at line 496 of file base_window_iterator.hpp.

◆ position_function

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.


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