|
A library for working with phylogenetic and population genetic data.
v0.27.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_POPULATION_WINDOW_FUNCTIONS_H_
2 #define GENESIS_POPULATION_WINDOW_FUNCTIONS_H_
41 namespace population {
76 template<
class D,
class A = EmptyAccumulator>
81 auto check_entries = [&](){
82 if( window.
entries().empty() ) {
83 throw std::runtime_error(
84 "Cannot use empty Window (with no variants/entries) for variant-based anchor "
85 "positions. Typically these anchor positions are used with WindowType::kVariants."
94 switch( anchor_type ) {
106 assert( ! window.
entries().empty() );
107 return window.
entries().front().position;
111 assert( ! window.
entries().empty() );
112 return window.
entries().back().position;
116 assert( ! window.
entries().empty() );
121 assert( ! window.
entries().empty() );
124 for(
auto const& e : window.
entries() ) {
131 assert( ! window.
entries().empty() );
132 return ( window.
entries().front().position + window.
entries().back().position ) / 2;
135 throw std::runtime_error(
"Invalid WindowAnchorType." );
145 #endif // include guard
double sum(const Histogram &h)
Window over the chromosomes of a genome.
size_t last_position() const
Get the last position in the chromosome of the Window, that is, where the Window ends.
container const & entries() const
Immediate container access to the Data Entries.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
size_t first_position() const
Get the first position in the chromosome of the Window, that is, where the Window starts.
WindowAnchorType
Position in the genome that is used for reporting when emitting or using a window.
size_t anchor_position(Window< D, A > const &window, WindowAnchorType anchor_type=WindowAnchorType::kIntervalBegin)
Get the position in the chromosome reported according to a specific WindowAnchorType.