5 #include "../Tree/NodeTemplate.h"
6 #include "../Tree/Tree.h"
7 #include "../Tree/TreeTemplate.h"
8 #include "../Tree/TreeTemplateTools.h"
21 vector<size_t> bestPair(2);
23 for (map<size_t, Node*>::iterator i = currentNodes_.begin(); i != currentNodes_.end(); i++)
26 map<size_t, Node*>::iterator j = i;
28 for ( ; j != currentNodes_.end(); j++)
31 double dist = matrix_(
id, jd);
43 throw Exception(
"Unexpected error: no minimum found in the distance matrix.");
52 double dist = matrix_(pair[0], pair[1]) / 2.;
68 w1 =
static_cast<double>(
dynamic_cast<NodeTemplate<PGMAInfos>*
>(currentNodes_[pair[0]])->getInfos().numberOfLeaves);
69 w2 =
static_cast<double>(
dynamic_cast<NodeTemplate<PGMAInfos>*
>(currentNodes_[pair[1]])->getInfos().numberOfLeaves);
71 return (w1 * matrix_(pair[0], pos) + w2 * matrix_(pair[1], pos)) / (w1 + w2);
77 map<size_t, Node*>::iterator it = currentNodes_.begin();
78 size_t i1 = it->first;
79 Node* n1 = it->second;
81 size_t i2 = it->first;
82 Node* n2 = it->second;
83 double d = matrix_(i1, i2) / 2;
virtual void setInfos(const NodeInfos &infos)
Set the information to be associated to this node.
The phylogenetic node class.
virtual void setDistanceToFather(double distance)
Set or update the distance toward the father node.
virtual void addSon(size_t pos, Node *node)
virtual double getDistanceToFather() const
Get the distance to the father node is there is one, otherwise throw a NodeException.
std::vector< double > computeBranchLengthsForPair(const std::vector< size_t > &pair)
Compute the branch lengths for two nodes to agglomerate.
virtual Node * getParentNode(int id, Node *son1, Node *son2)
Get an inner node.
double computeDistancesFromPair(const std::vector< size_t > &pair, const std::vector< double > &branchLengths, size_t pos)
Actualizes the distance matrix according to a given pair and the corresponding branch lengths.
std::vector< size_t > getBestPair()
Get the best pair of nodes to agglomerate.
virtual Node * getLeafNode(int id, const std::string &name)
Get a leaf node.
void finalStep(int idRoot)
Method called when there ar eonly three remaining node to agglomerate, and creates the root node of t...
The phylogenetic tree class.
Defines the basic types of data flow nodes.
Inner data structure for WPGMA and UPGMA distance methods.