|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
45 #include <unordered_map>
58 if( ! tree::tree_data_is< PlacementNodeData, PlacementEdgeData >( tree_ ) ) {
59 throw std::runtime_error(
"Tree for constructing the Sample is no PlacementTree." );
69 pqueries_ = other.pqueries_;
74 for(
auto& pqry : pqueries_ ) {
75 for(
auto& place : pqry.placements() ) {
78 auto index = place.edge().index();
81 place.reset_edge( tree_.
edge_at( index ) );
91 auto tmp =
Sample( other );
99 swap( pqueries_, other.pqueries_ );
100 swap( tree_, other.tree_ );
140 return pqueries_.size();
145 return tree_.
empty() || pqueries_.empty();
154 pqueries_.push_back(
Pquery() );
155 return pqueries_.back();
160 pqueries_.push_back( other );
163 for(
auto& place : pqueries_.back().placements() ) {
167 auto const edge_index = place.edge().index();
168 auto const old_edge_num = old_edge_data.
edge_num();
169 auto const rel_pos = place.proximal_length / old_edge_data.branch_length;
175 if( old_edge_num != edge_data.edge_num() ) {
176 throw std::runtime_error(
177 "Trees are incompatible for copying Pqueries between Samples."
180 place.proximal_length = rel_pos * edge_data.branch_length;
183 return pqueries_.back();
192 return pqueries_.at( index );
197 return pqueries_.at( index );
206 pqueries_.erase( pqueries_.begin() + index );
211 if( first_index >= pqueries_.size()
212 || last_index >= pqueries_.size()
213 || first_index >= last_index
215 throw std::out_of_range(
"Invalid indices for removing from SequenceSet." );
218 pqueries_.erase( pqueries_.begin() + first_index, pqueries_.begin() + last_index );
223 pqueries_.erase( position );
228 pqueries_.erase( first, last );
246 return pqueries_.begin();
251 return pqueries_.begin();
256 return pqueries_.end();
261 return pqueries_.end();
266 return { pqueries_ };
271 return { pqueries_ };
void swap(Sample &lhs, Sample &rhs)
PlacementTree & tree()
Get the PlacementTree of this Sample.
size_t size() const
Return the number of Pqueries that are stored in this Sample.
iterator_pqueries end()
Return an iterator to the end of the Pqueries of this Sample.
EdgeNumType edge_num() const
Return the edge_num of this edge. This value is defined by the jplace standard.
void clear_pqueries()
Clear all Pqueries of this Sample.
Manage a set of Pqueries along with the PlacementTree where the PqueryPlacements are placed on.
std::vector< Pquery >::const_iterator const_iterator_pqueries
TreeEdge & edge_at(size_t index)
Return the TreeEdge at a certain index.
bool empty() const
Return whether the tree or the set of Pqueries is empty.
Pquery & add()
Create an empty Pquery, add it to the Sample and return it.
Sample & operator=(Sample const &)
Copy assignment.
Provides some valuable additions to STD.
Data class for PlacementTreeEdges. Stores the branch length of the edge, and the edge_num,...
Class for representing phylogenetic trees.
std::vector< Pquery >::iterator iterator_pqueries
iterator_pqueries begin()
Return an iterator to the beginning of the Pqueries of this Sample.
A pquery holds a set of PqueryPlacements and a set of PqueryNames.
bool empty() const
Return whether the Tree is empty (i.e., has no nodes, edges and links).
Pquery & at(size_t index)
Return the Pquery at a certain index.
Sample()=default
Default constructor.
tree::Tree PlacementTree
Alias for a tree::Tree used for a tree with information needed for storing Pqueries....
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
void clear()
Clears all data of this object.
void swap(Sample &other)
Swap the contents of this Sample with the contents of another Sample.
void remove(size_t index)
Remove the Pquery at a given index from the Sample.
utils::Range< iterator_pqueries > pqueries()
Return a Range iterator to the Pqueries .
std::unordered_map< std::string, std::string > metadata