|
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_WINDOW_H_
2 #define GENESIS_POPULATION_WINDOW_WINDOW_H_
44 namespace population {
104 template<
class D,
class A = EmptyAccumulator>
210 virtual ~Window()
override =
default;
229 return entries_.size();
239 return entries_.size();
248 return entries_.empty();
256 double const es =
static_cast<double>( entries_.size() );
257 double const wd =
static_cast<double>( this->
width() );
258 double const frac = es / wd;
260 assert( this->
width() > 0 );
261 assert( frac >= 0.0 );
262 assert( frac <= 1.0 );
279 if( entries_.empty() ) {
282 return entries_.back().position - entries_.front().position + 1;
296 assert( index < entries_.size() );
297 return entries_[ index ];
307 assert( index < entries_.size() );
308 return entries_[ index ];
316 return entries_.at( index );
324 return entries_.at( index );
332 return entries_.begin();
340 return entries_.begin();
348 return entries_.end();
356 return entries_.end();
406 throw std::runtime_error(
"Invalid Window with first_position() == 0." );
409 throw std::runtime_error(
"Invalid Window with last_position() < first_position()." );
411 for(
auto const& entry : entries_ ) {
412 if( entry.position < this->first_position() || entry.position > this->last_position() ) {
413 throw std::runtime_error(
414 "Invalid Window::Entry in chromosome " + this->
chromosome() +
" at position " +
416 ", which is not between the window boundaries [" +
430 virtual void clear_()
override
450 #endif // include guard
Accumulator & accumulator()
Get the Accumulator data that can be used for speeding up certain window computations.
reference operator[](size_t index)
Return a reference to the element at specified location index.
const_reference at(size_t index) const
Return a reference to the element at specified location pos, with bounds checking.
Window over the chromosomes of a genome.
size_t position
Genomic position (1-based) of the entry along a chromosome.
void validate() const
Validate the window data.
size_t index
Index of the entry, that is, how many other entries have there been in total in the underlying data f...
size_t entry_count() const
Get the number of D/Data Entries that are stored in the Window.
size_t size() const
Get the number of D/Data Entries that are stored in the Window.
virtual ~Window() override=default
Accumulator const & accumulator() const
Get the Accumulator data that can be used for speeding up certain window computations.
std::string to_string(GenomeLocus const &locus)
Entry(size_t index, size_t position, Data const &data)
Contructor that takes data by reference.
Data data
Data stored in the Window for this entry.
iterator end()
Iterator to the end of the Data Entries.
typename container::const_reverse_iterator const_reverse_iterator
size_t width() const
Get the width of the Window.
std::string const & chromosome() const
Get the chromosome name that this Window belongs to.
bool empty() const
Return whether the Window is empty, that is, if it does not contain any Entries.
container const & entries() const
Immediate container access to the Data Entries.
size_t span() const
Get the distance that is spanned by the first and the last variant (entry) in the Window,...
const_reference operator[](size_t index) const
Return a reference to the element at specified location index.
Empty helper data struct to serve as a dummy for Window.
typename container::size_type size_type
std::deque< Entry > container
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Data that is stored per entry that was enqueued in a window.
Entry(size_t index, size_t position, Data &&data)
Contructor that takes data by r-value reference (i.e., moved data); preferred if possible to use,...
reference at(size_t index)
Return a reference to the element at specified location pos, with bounds checking.
typename container::difference_type difference_type
container & entries()
Immediate container access to the Data Entries.
const_iterator begin() const
Const iterator to the begin of the Data Entries.
const_iterator end() const
Const iterator to the end of the Data Entries.
Window & operator=(Window const &)=default
typename container::const_iterator const_iterator
size_t first_position() const
Get the first position in the chromosome of the Window, that is, where the Window starts.
iterator begin()
Iterator to the begin of the Data Entries.
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.
typename container::reverse_iterator reverse_iterator
double saturation() const
Get the fraction of entries to window width.
typename container::iterator iterator
value_type const & const_reference