bpp-phyl3 3.0.0
PhyloDAG.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_PHYLODAG_H
6#define BPP_PHYL_TREE_PHYLODAG_H
7
9
10#include "PhyloBranch.h"
11#include "PhyloNode.h"
12
13namespace bpp
14{
21class ParametrizablePhyloDAG;
22
23class PhyloDAG :
24 public AssociationDAGlobalGraphObserver<PhyloNode, PhyloBranch>
25{
26private:
27 std::string name_;
28
29public:
30 PhyloDAG();
31
32 PhyloDAG(const PhyloDAG* dag);
33
34 PhyloDAG(const ParametrizablePhyloDAG& dag);
35
36 template<class T, class U>
39 name_("")
40 {}
41
42 PhyloDAG* clone() const
43 {
44 return new PhyloDAG(*this);
45 }
46
52 std::string getName() const
53 {
54 return name_;
55 }
56
57 void setName(const std::string& name)
58 {
59 name_ = name;
60 }
61
64 std::vector<std::string> getAllLeavesNames() const;
65
66 /*
67 *@brief Get PhyloNode with given name, or null shared_ptr if the
68 * name is not present in the PhyloDAG.
69 *
70 */
71 std::shared_ptr<PhyloNode> getPhyloNode(const std::string& name) const;
72
74
75 /*
76 *@brief set indexes to nodes & edges.
77 * For each node, one (arbitrary) edge has the same index.
78 */
79
80 void resetNodesId();
81
82 void setBranchLengths(double l);
83
89 void scaleDAG(double factor);
90
97 void pruneDAG(std::vector<std::string> leaves);
98
105 void scaleDAG(std::shared_ptr<PhyloNode> node, double factor);
106
114 PhyloDAG& operator+=(const PhyloDAG& phylotree);
115
123 PhyloDAG& operator-=(const PhyloDAG& phylotree);
124
132 PhyloDAG& operator/=(const PhyloDAG& phylotree);
133
141 PhyloDAG& operator*=(const PhyloDAG& phylotree);
142
143 // /**
144 // * @brief Concatenate the subtree under a Node (in a
145 // * DAGTemplate<Node>) to this PhyloTree, under the given phylonode.
146 // */
147 // void addSubTree(std::shared_ptr<PhyloNode> phyloNode, const Node& node);
148};
149}
150
151#endif // BPP_PHYL_TREE_PHYLOTREE_H
void scaleDAG(double factor)
Multiply all branch lengths by a given factor.
Definition: PhyloDAG.cpp:91
PhyloDAG * clone() const
Definition: PhyloDAG.h:42
PhyloDAG(AssociationDAGlobalGraphObserver< T, U > dag)
Definition: PhyloDAG.h:37
std::vector< std::string > getAllLeavesNames() const
Definition: PhyloDAG.cpp:65
PhyloDAG & operator+=(const PhyloDAG &phylotree)
Add the lengths of branches of another phylotree to this one. Just branch ids are considered,...
Definition: PhyloDAG.cpp:145
PhyloDAG & operator-=(const PhyloDAG &phylotree)
Subtracts the lengths of branches of another phylotree to this one. Just branch ids are considered,...
Definition: PhyloDAG.cpp:164
Vdouble getBranchLengths() const
Definition: PhyloDAG.cpp:131
PhyloDAG & operator/=(const PhyloDAG &phylotree)
Divides the lengths of branches of this phylotree by the ones of another phylotree....
Definition: PhyloDAG.cpp:183
void resetNodesId()
Definition: PhyloDAG.cpp:26
PhyloDAG(const ParametrizablePhyloDAG &dag)
PhyloDAG & operator*=(const PhyloDAG &phylotree)
Multiplies the lengths of branches of this phylotree by the ones of another phylotree....
Definition: PhyloDAG.cpp:202
void setName(const std::string &name)
Definition: PhyloDAG.h:57
std::string getName() const
DAG name.
Definition: PhyloDAG.h:52
std::shared_ptr< PhyloNode > getPhyloNode(const std::string &name) const
Definition: PhyloDAG.cpp:52
void setBranchLengths(double l)
Definition: PhyloDAG.cpp:121
void pruneDAG(std::vector< std::string > leaves)
Prune a tree to a given set of leaf names.
Definition: PhyloDAG.cpp:96
std::string name_
Definition: PhyloDAG.h:27
Defines the basic types of data flow nodes.
std::vector< double > Vdouble