|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_POPULATION_WINDOW_FUNCTIONS_H_
2 #define GENESIS_POPULATION_WINDOW_FUNCTIONS_H_
44 namespace population {
81 template<
class D,
class A = EmptyAccumulator>
86 auto check_entries = [&](){
87 if( window.
entries().empty() ) {
88 throw std::runtime_error(
89 "Cannot use empty Window (with no variants/entries) for variant-based anchor "
90 "positions. Typically these anchor positions are used with WindowType::kVariants."
99 switch( anchor_type ) {
111 assert( ! window.
entries().empty() );
112 return window.
entries().front().position;
116 assert( ! window.
entries().empty() );
117 return window.
entries().back().position;
121 assert( ! window.
entries().empty() );
126 assert( ! window.
entries().empty() );
129 for(
auto const& e : window.
entries() ) {
136 assert( ! window.
entries().empty() );
137 return ( window.
entries().front().position + window.
entries().back().position ) / 2;
140 throw std::runtime_error(
"Invalid WindowAnchorType." );
162 auto const downcast =
dynamic_cast<Window<D> const*
>( &window );
168 switch( anchor_type ) {
183 throw std::runtime_error(
"Cannot use variant-based WindowAnchorType on BaseWindow." );
186 throw std::runtime_error(
"Invalid WindowAnchorType." );
196 #endif // include guard
double sum(const Histogram &h)
Window over the chromosomes of a genome.
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.
size_t last_position() const
Get the last position in the chromosome of the Window, that is, where the Window ends.
Base class for Window and WindowView, to share common functionality.
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.