bpp-phyl3 3.0.0
PhyloTree.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_PHYLOTREE_H
6#define BPP_PHYL_TREE_PHYLOTREE_H
7
9
10#include "PhyloBranch.h"
11#include "PhyloNode.h"
12#include "TreeTemplate.h"
13
14namespace bpp
15{
22class ParametrizablePhyloTree;
23
24class PhyloTree :
25 public AssociationTreeGlobalGraphObserver<PhyloNode, PhyloBranch>
26{
27private:
28 std::string name_;
29
30public:
31 PhyloTree(bool rooted = false);
32
33 PhyloTree(const PhyloTree* tree);
34
36
37 template<class T, class U>
40 name_("")
41 {}
42
44 {
45 return new PhyloTree(*this);
46 }
47
53 std::string getName() const
54 {
55 return name_;
56 }
57
58 void setName(const std::string& name)
59 {
60 name_ = name;
61 }
62
65 std::vector<std::string> getAllLeavesNames() const;
66
67 /*
68 *@brief Get PhyloNode with given name, or null shared_ptr if the
69 * name is not present in the PhyloTree.
70 *
71 */
72 std::shared_ptr<PhyloNode> getPhyloNode(const std::string& name) const;
73
75
76 void resetNodesId();
77
78 void setBranchLengths(double l);
79
85 void scaleTree(double factor);
86
93 void pruneTree(std::vector<std::string> leaves);
94
101 void scaleTree(std::shared_ptr<PhyloNode> node, double factor);
102
110 PhyloTree& operator+=(const PhyloTree& phylotree);
111
119 PhyloTree& operator-=(const PhyloTree& phylotree);
120
128 PhyloTree& operator/=(const PhyloTree& phylotree);
129
137 PhyloTree& operator*=(const PhyloTree& phylotree);
138
143 void addSubTree(std::shared_ptr<PhyloNode> phyloNode, const Node& node);
144};
145}
146
147#endif // BPP_PHYL_TREE_PHYLOTREE_H
The phylogenetic node class.
Definition: Node.h:59
PhyloTree with Parametrizable Phylo Branches. They SHARE their branch length parameters.
PhyloTree * clone() const
Definition: PhyloTree.h:43
PhyloTree & operator*=(const PhyloTree &phylotree)
Multiplies the lengths of branches of this phylotree by the ones of another phylotree....
Definition: PhyloTree.cpp:181
void scaleTree(double factor)
Multiply all branch lengths by a given factor.
Definition: PhyloTree.cpp:77
void addSubTree(std::shared_ptr< PhyloNode > phyloNode, const Node &node)
Concatenate the subtree under a Node (in a TreeTemplate<Node>) to this PhyloTree, under the given phy...
Definition: PhyloTree.cpp:200
Vdouble getBranchLengths() const
Definition: PhyloTree.cpp:110
PhyloTree(bool rooted=false)
Definition: PhyloTree.cpp:11
void resetNodesId()
Definition: PhyloTree.cpp:26
std::vector< std::string > getAllLeavesNames() const
Definition: PhyloTree.cpp:51
PhyloTree(AssociationTreeGlobalGraphObserver< T, U > tree)
Definition: PhyloTree.h:38
std::shared_ptr< PhyloNode > getPhyloNode(const std::string &name) const
Definition: PhyloTree.cpp:38
PhyloTree & operator+=(const PhyloTree &phylotree)
Add the lengths of branches of another phylotree to this one. Just branch ids are considered,...
Definition: PhyloTree.cpp:124
PhyloTree & operator-=(const PhyloTree &phylotree)
Subtracts the lengths of branches of another phylotree to this one. Just branch ids are considered,...
Definition: PhyloTree.cpp:143
void setName(const std::string &name)
Definition: PhyloTree.h:58
void pruneTree(std::vector< std::string > leaves)
Prune a tree to a given set of leaf names.
Definition: PhyloTree.cpp:82
void setBranchLengths(double l)
Definition: PhyloTree.cpp:100
PhyloTree & operator/=(const PhyloTree &phylotree)
Divides the lengths of branches of this phylotree by the ones of another phylotree....
Definition: PhyloTree.cpp:162
std::string getName() const
Tree name.
Definition: PhyloTree.h:53
std::string name_
Definition: PhyloTree.h:28
Defines the basic types of data flow nodes.
std::vector< double > Vdouble