bpp-phyl3 3.0.0
ParametrizablePhyloTree.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
6
7using namespace bpp;
8using namespace std;
9
10ParametrizablePhyloTree::ParametrizablePhyloTree(const PhyloTree& tree, const std::string& prefix) :
13 minimumBrLen_(0.000001),
14 maximumBrLen_(10000),
15 brLenConstraint_(new IntervalConstraint(minimumBrLen_, maximumBrLen_, true, true))
16{
17 vector<shared_ptr<PhyloBranchParam>> vB = getAllEdges();
18
19 for (auto& it:vB)
20 {
21 if (hasEdgeIndex(it))
22 it->getParameter_(0).setName("BrLen" + TextTools::toString(getEdgeIndex(it)));
23 shareParameter_(it->getParameter(0));
24 }
25}
26
30 minimumBrLen_(pTree.minimumBrLen_),
31 maximumBrLen_(pTree.maximumBrLen_),
32 brLenConstraint_(pTree.brLenConstraint_ ? pTree.brLenConstraint_->clone() : 0)
33{}
34
35
37{
39 AbstractParametrizable::operator=(pTree);
42 if (pTree.brLenConstraint_)
43 brLenConstraint_.reset(pTree.brLenConstraint_->clone());
44 else
46
47
48 return *this;
49}
50
51std::vector<std::string> ParametrizablePhyloTree::getAllLeavesNames() const
52{
53 vector<string> vn;
54
55 vector<shared_ptr<PhyloNode>> vpn = getAllLeaves();
56
57 for (vector<shared_ptr<PhyloNode>>::const_iterator it = vpn.begin(); it != vpn.end(); it++)
58 {
59 vn.push_back((*it)->getName());
60 }
61
62 return vn;
63}
64
66{
67 Vdouble vl;
68
69 vector<shared_ptr<PhyloBranchParam>> vpn = getAllEdges();
70
71 for (auto& it: vpn)
72 {
73 vl.push_back(it->getLength());
74 }
75 return vl;
76}
77
79{}
virtual void shareParameter_(const std::shared_ptr< Parameter > &parameter)
virtual std::vector< std::shared_ptr< N > > getAllLeaves() const=0
virtual std::vector< std::shared_ptr< E > > getAllEdges() const=0
virtual EdgeIndex getEdgeIndex(const std::shared_ptr< E > edgeObject) const=0
virtual bool hasEdgeIndex(const std::shared_ptr< E > edgeObject) const=0
AssociationTreeGraphImplObserver< N, E, TreeGraphImpl > & operator=(bpp::AssociationTreeGraphImplObserver< N, E, TreeGraphImpl > const &treeGraphObserver)
PhyloTree with Parametrizable Phylo Branches. They SHARE their branch length parameters.
ParametrizablePhyloTree(const PhyloTree &tree, const std::string &prefix="")
void fireParameterChanged(const ParameterList &parameters)
std::vector< std::string > getAllLeavesNames() const
ParametrizablePhyloTree & operator=(const ParametrizablePhyloTree &pTree)
std::shared_ptr< ConstraintInterface > brLenConstraint_
std::string toString(T t)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble