|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
45 #include <unordered_set>
53 auto& tree = sample.
tree();
56 throw std::invalid_argument{
"Cannot root a PlacementTree that is already rooted." };
59 throw std::invalid_argument{
"The given edge does not belong to the tree." };
68 assert( &new_node.primary_link() == &target_edge.
primary_link() );
69 assert(
degree( new_node ) == 2 );
97 std::unordered_set<PlacementTreeEdge*> edges_to_adjust;
98 for(
auto link_ptr :
path ) {
103 for(
auto& pq : sample ) {
104 for(
auto& p : pq.placements() ) {
105 auto place_edge_ptr = &( p.edge() );
108 if ( place_edge_ptr == &target_edge ) {
109 p.reset_edge( new_edge );
114 assert( edges_to_adjust.count( place_edge_ptr ) > 0 );
115 place_edge_ptr = &( p.edge() );
116 assert( edges_to_adjust.count( place_edge_ptr ) == 0 );
120 assert( place_edge_ptr != &target_edge );
123 if( edges_to_adjust.count( place_edge_ptr ) > 0 ) {
125 p.proximal_length = full_length - p.proximal_length;
TreeLink & primary_link()
Return the TreeLink of this TreeEdge that points towards the root.
PlacementTree & tree()
Get the PlacementTree of this Sample.
Header of PqueryPlacement class.
Manage a set of Pqueries along with the PlacementTree where the PqueryPlacements are placed on.
TreeLink & next()
Return the next TreeLink within the TreeNode of this link.
bool belongs_to(Tree const &tree, TreeNode const &node)
Return whether the TreeNode belongs to the Tree, i.e., whether it is owned by the Tree.
size_t degree(TreeLink const &link)
Return the degree of the node for a given TreeLink, i.e. how many neighbouring nodes it has.
TreeNode & root_node()
Return the TreeNode at the current root of the Tree.
void make_rooted(Sample &sample, PlacementTreeEdge &target_edge)
Root the underlying PlacementTree of a Sample at a specified TreeEdge.
std::vector< TreeLink const * > path_to_root(TreeNode const &node)
Helper function that finds all TreeLinks between a given TreeNode and the root of the Tree.
utils::Range< IteratorPath< true > > path(ElementType const &start, ElementType const &finish)
Data class for PlacementTreeEdges. Stores the branch length of the edge, and the edge_num,...
double branch_length
Branch length of the edge.
bool is_root(TreeLink const &link)
Return whether the link belongs to the root node of its Tree.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
bool is_rooted(Tree const &tree)
Return whether the Tree is rooted, that is, whether the root node has two neighbors.
void reset_edge_nums(PlacementTree &tree)
Reset all edge nums of a PlacementTree.
TreeEdge & edge()
Return the TreeEdge of this TreeLink.