bpp-phyl3 3.0.0
ParametrizablePhyloTree.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_LIKELIHOOD_PARAMETRIZABLEPHYLOTREE_H
6#define BPP_PHYL_LIKELIHOOD_PARAMETRIZABLEPHYLOTREE_H
7
10
11#include "../Tree/PhyloBranchParam.h"
12#include "../Tree/PhyloNode.h"
13#include "../Tree/PhyloTree.h"
14
15// From the stl:
16#include <string>
17
18namespace bpp
19{
25 public AssociationTreeGlobalGraphObserver<PhyloNode, PhyloBranchParam>,
27{
28private:
31 std::shared_ptr<ConstraintInterface> brLenConstraint_;
32
33public:
34 ParametrizablePhyloTree(const PhyloTree& tree, const std::string& prefix = "");
35
37
39
41
42public:
43 std::vector<std::string> getAllLeavesNames() const;
44
46
47 virtual void setMinimumBranchLength(double minimum)
48 {
49 if (minimum > maximumBrLen_)
50 throw Exception("ParametrizablePhyloTree::setMinimumBranchLength. Minimum branch length should be lower than the maximum one: " + TextTools::toString(maximumBrLen_));
51 minimumBrLen_ = minimum;
53 {
54 brLenConstraint_ = std::make_shared<IntervalConstraint>(minimumBrLen_, maximumBrLen_, true, true);
56 }
57 else
58 dynamic_cast<IntervalConstraint&>(*brLenConstraint_).setLowerBound(minimumBrLen_, false);
59 }
60
61 virtual void setMaximumBranchLength(double maximum)
62 {
63 if (maximum < minimumBrLen_)
64 throw Exception("ParametrizablePhyloTree::setMaximumBranchLength. Maximum branch length should be higher than the minimum one: " + TextTools::toString(minimumBrLen_));
65 maximumBrLen_ = maximum;
67 {
68 brLenConstraint_ = std::make_shared<IntervalConstraint>(minimumBrLen_, maximumBrLen_, true, true);
70 }
71 else
72 dynamic_cast<IntervalConstraint&>(*brLenConstraint_).setUpperBound(minimumBrLen_, false);
73 }
74
75 virtual double getMinimumBranchLength() const { return minimumBrLen_; }
76 virtual double getMaximumBranchLength() const { return maximumBrLen_; }
77
78private:
79 void fireParameterChanged (const ParameterList& parameters);
80};
81} // end of namespace bpp
82#endif // BPP_PHYL_LIKELIHOOD_PARAMETRIZABLEPHYLOTREE_H
void setLowerBound(double lowerBound, bool strict)
void setUpperBound(double upperBound, bool strict)
PhyloTree with Parametrizable Phylo Branches. They SHARE their branch length parameters.
ParametrizablePhyloTree(const PhyloTree &tree, const std::string &prefix="")
ParametrizablePhyloTree * clone() const
void fireParameterChanged(const ParameterList &parameters)
virtual double getMinimumBranchLength() const
virtual double getMaximumBranchLength() const
std::vector< std::string > getAllLeavesNames() const
ParametrizablePhyloTree & operator=(const ParametrizablePhyloTree &pTree)
virtual void setMaximumBranchLength(double maximum)
std::shared_ptr< ConstraintInterface > brLenConstraint_
virtual void setMinimumBranchLength(double minimum)
std::string toString(T t)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble