bpp-phyl
2.2.0
|
Partial implementation of the AgglomerativeDistanceMethod interface. More...
#include <Bpp/Phyl/Distance/AbstractAgglomerativeDistanceMethod.h>
Public Member Functions | |
AbstractAgglomerativeDistanceMethod (bool verbose=true, bool rootTree=false) | |
AbstractAgglomerativeDistanceMethod (const DistanceMatrix &matrix, bool verbose=true, bool rootTree=false) | |
virtual | ~AbstractAgglomerativeDistanceMethod () |
AbstractAgglomerativeDistanceMethod (const AbstractAgglomerativeDistanceMethod &a) | |
AbstractAgglomerativeDistanceMethod & | operator= (const AbstractAgglomerativeDistanceMethod &a) |
virtual void | setDistanceMatrix (const DistanceMatrix &matrix) throw (Exception) |
Set the distance matrix to use. More... | |
virtual TreeTemplate< Node > * | getTree () const |
Get the computed tree, if there is one. More... | |
virtual void | computeTree () throw (Exception) |
Compute the tree corresponding to the distance matrix. More... | |
void | setVerbose (bool yn) |
bool | isVerbose () const |
virtual std::string | getName () const =0 |
Protected Member Functions | |
Specific methods. | |
virtual std::vector< size_t > | getBestPair ()=0 throw (Exception) |
Get the best pair of nodes to agglomerate. More... | |
virtual std::vector< double > | computeBranchLengthsForPair (const std::vector< size_t > &pair)=0 |
Compute the branch lengths for two nodes to agglomerate. More... | |
virtual double | computeDistancesFromPair (const std::vector< size_t > &pair, const std::vector< double > &branchLengths, size_t pos)=0 |
Actualizes the distance matrix according to a given pair and the corresponding branch lengths. More... | |
virtual void | finalStep (int idRoot)=0 |
Method called when there ar eonly three remaining node to agglomerate, and creates the root node of the tree. More... | |
virtual Node * | getLeafNode (int id, const std::string &name) |
Get a leaf node. More... | |
virtual Node * | getParentNode (int id, Node *son1, Node *son2) |
Get an inner node. More... | |
Protected Attributes | |
DistanceMatrix | matrix_ |
Tree * | tree_ |
std::map< size_t, Node * > | currentNodes_ |
bool | verbose_ |
bool | rootTree_ |
Partial implementation of the AgglomerativeDistanceMethod interface.
This class provides a DistanceMatrix object for computations, and a map with pivot indices and a pointer toward the corresponding subtree.
Several methods, commons to several algorithm are provided.
Definition at line 62 of file AbstractAgglomerativeDistanceMethod.h.
|
inline |
Definition at line 77 of file AbstractAgglomerativeDistanceMethod.h.
|
inline |
Definition at line 80 of file AbstractAgglomerativeDistanceMethod.h.
References setDistanceMatrix().
|
inlinevirtual |
Definition at line 86 of file AbstractAgglomerativeDistanceMethod.h.
References tree_.
|
inline |
Definition at line 92 of file AbstractAgglomerativeDistanceMethod.h.
References tree_.
|
protectedpure virtual |
Compute the branch lengths for two nodes to agglomerate.
This method compute l1 and l2 given N1 and N2.
pair | The indices of the nodes to be agglomerated. |
Implemented in bpp::NeighborJoining, bpp::PGMA, and bpp::HierarchicalClustering.
|
protectedpure virtual |
Actualizes the distance matrix according to a given pair and the corresponding branch lengths.
pair | The indices of the nodes to be agglomerated. |
branchLengths | The corresponding branch lengths. |
pos | The index of the node whose distance ust be updated. |
Implemented in bpp::NeighborJoining, bpp::PGMA, bpp::BioNJ, and bpp::HierarchicalClustering.
|
virtual |
Compute the tree corresponding to the distance matrix.
This method implements the following algorithm: 1) Build all leaf nodes (getLeafNode method) 2) Get the best pair to agglomerate (getBestPair method) 3) Compute the branch lengths for this pair (computeBranchLengthsForPair method) 4) Build the parent node of the pair (getParentNode method) 5) For each remaining node, update distances from the pair (computeDistancesFromPair method) 6) Return to step 2 while there are more than 3 remaining nodes. 7) Perform the final step, and send a rooted or unrooted tree.
Implements bpp::DistanceMethod.
Reimplemented in bpp::BioNJ.
Definition at line 62 of file AbstractAgglomerativeDistanceMethod.cpp.
References bpp::Node::setDistanceToFather().
Referenced by bpp::HierarchicalClustering::HierarchicalClustering(), bpp::NeighborJoining::NeighborJoining(), and bpp::PGMA::PGMA().
|
protectedpure virtual |
Method called when there ar eonly three remaining node to agglomerate, and creates the root node of the tree.
idRoot | The id of the root node. |
Implemented in bpp::NeighborJoining, bpp::PGMA, and bpp::HierarchicalClustering.
|
protectedpure virtual |
Get the best pair of nodes to agglomerate.
Define the criterion to chose the next pair of nodes to agglomerate. This criterion uses the matrix_ distance matrix.
Exception | If an error occured. |
Implemented in bpp::NeighborJoining, bpp::PGMA, and bpp::HierarchicalClustering.
|
protectedvirtual |
Get a leaf node.
Create a new node with the given id and name.
id | The id of the node. |
name | The name of the node. |
Reimplemented in bpp::PGMA, and bpp::HierarchicalClustering.
Definition at line 111 of file AbstractAgglomerativeDistanceMethod.cpp.
|
pure virtualinherited |
Implemented in bpp::HierarchicalClustering, bpp::BioNJ, bpp::NeighborJoining, and bpp::PGMA.
|
protectedvirtual |
Get an inner node.
Create a new node with the given id, and set its sons.
id | The id of the node. |
son1 | The first son of the node. |
son2 | The second son of the node. |
Reimplemented in bpp::PGMA, and bpp::HierarchicalClustering.
Definition at line 116 of file AbstractAgglomerativeDistanceMethod.cpp.
References bpp::Node::addSon().
|
inlinevirtual |
Get the computed tree, if there is one.
Implements bpp::DistanceMethod.
Reimplemented in bpp::HierarchicalClustering, and bpp::PGMA.
Definition at line 127 of file AbstractAgglomerativeDistanceMethod.h.
References tree_.
Referenced by bpp::TreeTools::MRP(), and bpp::TreeTools::MRPMultilabel().
|
inlinevirtual |
Implements bpp::DistanceMethod.
Definition at line 149 of file AbstractAgglomerativeDistanceMethod.h.
References verbose_.
|
inline |
Definition at line 100 of file AbstractAgglomerativeDistanceMethod.h.
References currentNodes_, matrix_, rootTree_, tree_, and verbose_.
|
virtual |
Set the distance matrix to use.
matrix | The matrix to use. |
Exception | In case an incorrect matrix is provided (eg smaller than 3). |
Implements bpp::DistanceMethod.
Reimplemented in bpp::BioNJ, bpp::NeighborJoining, and bpp::PGMA.
Definition at line 53 of file AbstractAgglomerativeDistanceMethod.cpp.
Referenced by AbstractAgglomerativeDistanceMethod(), bpp::PGMA::setDistanceMatrix(), and bpp::NeighborJoining::setDistanceMatrix().
|
inlinevirtual |
yn | Enable/Disable verbose mode. |
Implements bpp::DistanceMethod.
Definition at line 148 of file AbstractAgglomerativeDistanceMethod.h.
References verbose_.
|
protected |
Definition at line 69 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by operator=().
|
protected |
Definition at line 66 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by operator=().
|
protected |
Definition at line 71 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by operator=().
|
protected |
Definition at line 67 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by AbstractAgglomerativeDistanceMethod(), getTree(), operator=(), and ~AbstractAgglomerativeDistanceMethod().
|
protected |
Definition at line 70 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by isVerbose(), operator=(), and setVerbose().