A library for working with phylogenetic and population genetic data.
v0.32.0
BaseWindow< D > Class Template Reference

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

Inherited by Window< D, A >, WindowView< D >, and Window< D, EmptyAccumulator >.

Detailed Description

template<class D>
class genesis::population::BaseWindow< D >

Base class for Window and WindowView, to share common functionality.

See Window for usage and details on the functions offered here.

The class also adds a special case for when we are streaming over a whole genome. In that case, we cannot use our usual notation of first and last positions on a chromosome, as we are using the whole genome instead. As the notation is however useful in all other cases, we want to keep it. A cleaner approach from a software design perspective would be to have base classes for both cases, but that would lead to having incompatible types of WindowStream classes, which would add too much complexity for the current use case.

Definition at line 60 of file base_window.hpp.

Public Member Functions

 BaseWindow ()=default
 
 BaseWindow (BaseWindow &&)=default
 
 BaseWindow (BaseWindow const &)=default
 
virtual ~BaseWindow ()=default
 
std::string const & chromosome () const
 Get the chromosome name that this Window belongs to. More...
 
void chromosome (std::string const &value)
 Set the chromosome name that this Window belongs to. More...
 
std::unordered_map< std::string, size_t > & chromosomes ()
 Get the list of all chromosomes along the genome, with their length. More...
 
std::unordered_map< std::string, size_t > const & chromosomes () const
 Get the list of all chromosomes along the genome, with their length. More...
 
void clear ()
 Clear all data from the Window. More...
 
size_t first_position () const
 Get the first position in the chromosome of the Window, that is, where the Window starts. More...
 
void first_position (size_t value)
 Set the first position in the chromosome of the Window, that is, where the Window starts. More...
 
GenomeRegion genome_region () const
 Return the genome region that this Windows is defined over. More...
 
bool is_whole_genome () const
 Return if this instance is intended to be used for a whole genome stream. More...
 
void is_whole_genome (bool value)
 Set whether this instance is intended to be used for a whole genome stream. More...
 
size_t last_position () const
 Get the last position in the chromosome of the Window, that is, where the Window ends. More...
 
void last_position (size_t value)
 Set the last position in the chromosome of the Window, that is, where the Window ends. More...
 
BaseWindowoperator= (BaseWindow &&)=default
 
BaseWindowoperator= (BaseWindow const &)=default
 
size_t width () const
 Get the width of the Window. More...
 

Public Types

using Data = D
 

Protected Member Functions

virtual void clear_ ()
 Virtual clear function for derived classes to clear their data. More...
 

Constructor & Destructor Documentation

◆ BaseWindow() [1/3]

BaseWindow ( )
default

◆ ~BaseWindow()

virtual ~BaseWindow ( )
virtualdefault

◆ BaseWindow() [2/3]

BaseWindow ( BaseWindow< D > const &  )
default

◆ BaseWindow() [3/3]

BaseWindow ( BaseWindow< D > &&  )
default

Member Function Documentation

◆ chromosome() [1/2]

std::string const& chromosome ( ) const
inline

Get the chromosome name that this Window belongs to.

Definition at line 90 of file base_window.hpp.

◆ chromosome() [2/2]

void chromosome ( std::string const &  value)
inline

Set the chromosome name that this Window belongs to.

Definition at line 98 of file base_window.hpp.

◆ chromosomes() [1/2]

std::unordered_map<std::string, size_t>& chromosomes ( )
inline

Get the list of all chromosomes along the genome, with their length.

Definition at line 222 of file base_window.hpp.

◆ chromosomes() [2/2]

std::unordered_map<std::string, size_t> const& chromosomes ( ) const
inline

Get the list of all chromosomes along the genome, with their length.

This is based on the chromsomoes and their lengths as encountered in the input data, or on the sequence dictionary if provided to the GenomeWindowStream.

Usage of this member is only valid if is_whole_genome() is set.

Definition at line 214 of file base_window.hpp.

◆ clear()

void clear ( )
inline

Clear all data from the Window.

Definition at line 234 of file base_window.hpp.

◆ clear_()

virtual void clear_ ( )
inlineprotectedvirtual

Virtual clear function for derived classes to clear their data.

Definition at line 253 of file base_window.hpp.

◆ first_position() [1/2]

size_t first_position ( ) const
inline

Get the first position in the chromosome of the Window, that is, where the Window starts.

The first and last position in the Window are determined for example by the sliding window width and stride, or by a genomic region that the window represents. They are hence independent of the actual data entries stored in the window, but obviously should be covering their positions. See the Window class documentation for an example.

We use 1-based coordinates and closed intervals, where both the first and the last position are inclusive.

Definition at line 114 of file base_window.hpp.

◆ first_position() [2/2]

void first_position ( size_t  value)
inline

Set the first position in the chromosome of the Window, that is, where the Window starts.

The first and last position in the Window are determined for example by the sliding window width and stride, or by a genomic region that the window represents. They are hence independent of the actual data entries stored in the window, but obviously should be covering their positions. See the Window class documentation for an example.

We use 1-based coordinates and closed intervals, where both the first and the last position are inclusive.

Definition at line 124 of file base_window.hpp.

◆ genome_region()

GenomeRegion genome_region ( ) const
inline

Return the genome region that this Windows is defined over.

This is a convenience function that gives the chromosome(), as well as first_position() and last_position(), combined into a GenomeRegion object, for ease of use.

Definition at line 155 of file base_window.hpp.

◆ is_whole_genome() [1/2]

bool is_whole_genome ( ) const
inline

Return if this instance is intended to be used for a whole genome stream.

Definition at line 192 of file base_window.hpp.

◆ is_whole_genome() [2/2]

void is_whole_genome ( bool  value)
inline

Set whether this instance is intended to be used for a whole genome stream.

Definition at line 201 of file base_window.hpp.

◆ last_position() [1/2]

size_t last_position ( ) const
inline

Get the last position in the chromosome of the Window, that is, where the Window ends.

The first and last position in the Window are determined for example by the sliding window width and stride, or by a genomic region that the window represents. They are hence independent of the actual data entries stored in the window, but obviously should be covering their positions. See the Window class documentation for an example.

We use 1-based coordinates and closed intervals, where both the first and the last position are inclusive.

Definition at line 134 of file base_window.hpp.

◆ last_position() [2/2]

void last_position ( size_t  value)
inline

Set the last position in the chromosome of the Window, that is, where the Window ends.

The first and last position in the Window are determined for example by the sliding window width and stride, or by a genomic region that the window represents. They are hence independent of the actual data entries stored in the window, but obviously should be covering their positions. See the Window class documentation for an example.

We use 1-based coordinates and closed intervals, where both the first and the last position are inclusive.

Definition at line 144 of file base_window.hpp.

◆ operator=() [1/2]

BaseWindow& operator= ( BaseWindow< D > &&  )
default

◆ operator=() [2/2]

BaseWindow& operator= ( BaseWindow< D > const &  )
default

◆ width()

size_t width ( ) const
inline

Get the width of the Window.

This is the distance between first_position() and last_position(), i.e., the distance between the start of the Window and its end as denoted by these positions, plus one, as we are using closed intervals where both positions are included.

See Window::span() for a function that computes the distance between the positions of the first and last entry in the window instead, which might be smaller than the width, if there are no entries in the beginning or end of the window.

See the Window class documentation for an example of the difference between the two functions.

Definition at line 173 of file base_window.hpp.

Member Typedef Documentation

◆ Data

using Data = D

Definition at line 68 of file base_window.hpp.


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