bpp-phyl3 3.0.0
PhyloTreeTools.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
5#ifndef BPP_PHYL_TREE_PHYLOTREETOOLS_H
6#define BPP_PHYL_TREE_PHYLOTREETOOLS_H
7
8#include <Bpp/Exceptions.h>
10
11#include "PhyloBranch.h"
12#include "PhyloNode.h"
13#include "PhyloTree.h"
14#include "PhyloTreeExceptions.h"
15#include "TreeTemplate.h"
16
17// From SeqLib:
20
21#include <memory>
22
23namespace bpp
24{
35{
36public:
38 virtual ~PhyloTreeTools() {}
39
40public:
41 static std::shared_ptr<PhyloTree> buildFromTreeTemplate(const TreeTemplate<Node>& treetemp);
42
54 static double getHeight(const PhyloTree& tree, const std::shared_ptr<PhyloNode> node);
55
69 static void initBranchLengthsGrafen(PhyloTree& tree);
70
85 static void computeBranchLengthsGrafen(PhyloTree& tree, double power = 1, bool init = true);
86
87private:
88 static size_t initBranchLengthsGrafen(PhyloTree& tree, std::shared_ptr<PhyloNode> node);
89
90 static void computeBranchLengthsGrafen(PhyloTree& tree, std::shared_ptr<PhyloNode> node, double power, double total, double& height, double& heightRaised);
91
92public:
109 static double convertToClockTree(PhyloTree& tree, std::shared_ptr<PhyloNode> node);
110
124 static double convertToClockTree2(PhyloTree& tree, std::shared_ptr<PhyloNode> node);
125
126
135 static void constrainedMidPointRooting(PhyloTree& tree);
136
146 static const std::string BOOTSTRAP;
147
148private:
149 struct Moments_
150 {
151 double N;
153 Moments_() : N(0),
154 sum(0),
155 squaredSum(0) {}
156 };
157
158 static Moments_ statFromNode_(const PhyloTree& tree, const std::shared_ptr<PhyloNode> root);
159 static double bestRootPosition_(const PhyloTree& tree, const std::shared_ptr<PhyloNode> node1, const std::shared_ptr<PhyloNode> node2, double length);
160
161
163};
164} // end of namespace bpp.
165#endif // BPP_PHYL_TREE_PHYLOTREETOOLS_H
Generic utilitary methods dealing with trees.
static Moments_ statFromNode_(const PhyloTree &tree, const std::shared_ptr< PhyloNode > root)
static void constrainedMidPointRooting(PhyloTree &tree)
Determine the mid-point position of the root along the branch that already contains the root....
static void initBranchLengthsGrafen(PhyloTree &tree)
Grafen's method to initialize branch lengths.
static const std::string BOOTSTRAP
Bootstrap tag.
static std::shared_ptr< PhyloTree > buildFromTreeTemplate(const TreeTemplate< Node > &treetemp)
static double convertToClockTree2(PhyloTree &tree, std::shared_ptr< PhyloNode > node)
Modify a tree's branch lengths to make a clock tree, by rescaling subtrees.
static double getHeight(const PhyloTree &tree, const std::shared_ptr< PhyloNode > node)
Get the height of the subtree defined by node 'node', i.e. the maximum distance between leaves and th...
static void computeBranchLengthsGrafen(PhyloTree &tree, double power=1, bool init=true)
Compute branch lengths using Grafen's method.
static double bestRootPosition_(const PhyloTree &tree, const std::shared_ptr< PhyloNode > node1, const std::shared_ptr< PhyloNode > node2, double length)
static double convertToClockTree(PhyloTree &tree, std::shared_ptr< PhyloNode > node)
Modify a tree's branch lengths to make a clock tree, by rebalancing branch lengths.
virtual ~PhyloTreeTools()
The phylogenetic tree class.
Definition: TreeTemplate.h:59
Defines the basic types of data flow nodes.