48 bool recomputeHeights =
false;
49 for (
unsigned int i = 0; i < pl.size(); ++i)
51 if (pl[i].getName().substr(0, 7) ==
"HeightP" || pl[i].getName() ==
"TotalHeight")
52 recomputeHeights =
true;
54 pl2.addParameter(pl[i]);
61 tl_->setParameters(pl2);
68 for (
unsigned int i = 0; i < getNumberOfParameters(); ++i)
70 Parameter p = getParameter_(i);
71 if (p.getName().substr(0, 7) ==
"HeightP" || p.getName() ==
"TotalHeight")
81 if (!tree.isRooted())
throw Exception(
"GlobalClockTreeLikelihoodFunctionWrapper::initParameters_(). Tree is unrooted!");
83 std::map<const Node*, double> heights;
85 double totalHeight = heights[tree.getRootNode()];
86 addParameter_(
new Parameter(
"TotalHeight", totalHeight, &Parameter::R_PLUS_STAR));
87 for (std::map<const Node*, double>::iterator it = heights.begin(); it != heights.end(); it++)
89 if (!it->first->isLeaf() && it->first->hasFather())
91 double fatherHeight = heights[it->first->getFather()];
92 addParameter_(
new Parameter(
"HeightP" + TextTools::toString(it->first->getId()), it->second / fatherHeight, &Parameter::PROP_CONSTRAINT_IN));
96 ParameterList pl =
tl_->getParameters();
97 for (
unsigned int i = 0; i < pl.size(); ++i)
99 if (pl[i].getName().substr(0, 5) !=
"BrLen")
100 addParameter_(pl[i].
clone());
108 for (
unsigned int i = 0; i < node->getNumberOfSons(); i++)
113 brlenPl.addParameter(Parameter(
"BrLen" + TextTools::toString(son->
getId()), std::max(0.0000011, height),
new IntervalConstraint(1, 0.000001,
false),
true));
117 double sonHeightP = getParameter(
"HeightP" + TextTools::toString(son->
getId())).getValue();
118 double sonHeight = sonHeightP * height;
119 brlenPl.addParameter(Parameter(
"BrLen" + TextTools::toString(son->
getId()), std::max(0.0000011, height - sonHeight),
new IntervalConstraint(1, 0.000001,
false),
true));
120 computeBranchLengthsFromHeights_(son, sonHeight, brlenPl);
virtual const Node * getSon(size_t pos) const
ParameterList getHeightParameters() const
The phylogenetic tree class.
virtual bool isLeaf() const
GlobalClockTreeLikelihoodFunctionWrapper * clone() const
virtual int getId() const
Get the node's id.
virtual const Tree & getTree() const =0
Get the tree (topology and branch lengths).
void computeBranchLengthsFromHeights_(const Node *node, double height, ParameterList &brlenPl)
The phylogenetic node class.
void fireParameterChanged(const bpp::ParameterList &pl)