bpp-phyl3
3.0.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) override |
Set the distance matrix to use. More... | |
bool | hasTree () const override |
const Tree & | tree () const override |
void | computeTree () override |
Compute the tree corresponding to the distance matrix. More... | |
void | setVerbose (bool yn) override |
bool | isVerbose () const override |
virtual AgglomerativeDistanceMethodInterface * | clone () const override=0 |
virtual std::string | getName () const =0 |
Protected Member Functions | |
Specific methods. | |
virtual std::vector< size_t > | getBestPair ()=0 |
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_ |
std::unique_ptr< 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 26 of file AbstractAgglomerativeDistanceMethod.h.
|
inline |
Definition at line 38 of file AbstractAgglomerativeDistanceMethod.h.
|
inline |
Definition at line 47 of file AbstractAgglomerativeDistanceMethod.h.
References setDistanceMatrix().
|
inlinevirtual |
Definition at line 60 of file AbstractAgglomerativeDistanceMethod.h.
|
inline |
Definition at line 62 of file AbstractAgglomerativeDistanceMethod.h.
References tree_.
|
overridepure virtualinherited |
Implements bpp::DistanceMethodInterface.
Implemented in bpp::PGMA, bpp::NeighborJoining, bpp::HierarchicalClustering, and bpp::BioNJ.
|
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::PGMA, bpp::NeighborJoining, 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::PGMA, bpp::NeighborJoining, bpp::HierarchicalClustering, and bpp::BioNJ.
|
overridevirtual |
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::DistanceMethodInterface.
Reimplemented in bpp::BioNJ.
Definition at line 26 of file AbstractAgglomerativeDistanceMethod.cpp.
References bpp::ApplicationTools::displayGauge(), and 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::PGMA, bpp::NeighborJoining, 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 occurred. |
Implemented in bpp::PGMA, bpp::NeighborJoining, 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 75 of file AbstractAgglomerativeDistanceMethod.cpp.
|
pure virtualinherited |
Implemented in bpp::PGMA, bpp::NeighborJoining, bpp::HierarchicalClustering, and bpp::BioNJ.
|
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 80 of file AbstractAgglomerativeDistanceMethod.cpp.
References bpp::Node::addSon().
|
inlineoverridevirtual |
Implements bpp::DistanceMethodInterface.
Definition at line 86 of file AbstractAgglomerativeDistanceMethod.h.
References tree_.
|
inlineoverridevirtual |
Implements bpp::DistanceMethodInterface.
Definition at line 114 of file AbstractAgglomerativeDistanceMethod.h.
References verbose_.
|
inline |
Definition at line 70 of file AbstractAgglomerativeDistanceMethod.h.
References currentNodes_, matrix_, rootTree_, tree_, and verbose_.
|
overridevirtual |
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::DistanceMethodInterface.
Reimplemented in bpp::PGMA, bpp::NeighborJoining, and bpp::BioNJ.
Definition at line 17 of file AbstractAgglomerativeDistanceMethod.cpp.
References bpp::DistanceMatrix::reset(), and bpp::DistanceMatrix::size().
Referenced by AbstractAgglomerativeDistanceMethod(), bpp::NeighborJoining::setDistanceMatrix(), and bpp::PGMA::setDistanceMatrix().
|
inlineoverridevirtual |
yn | Enable/Disable verbose mode. |
Implements bpp::DistanceMethodInterface.
Definition at line 113 of file AbstractAgglomerativeDistanceMethod.h.
References verbose_.
|
inlineoverridevirtual |
Implements bpp::DistanceMethodInterface.
Definition at line 91 of file AbstractAgglomerativeDistanceMethod.h.
References tree_.
|
protected |
Definition at line 33 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by operator=().
|
protected |
Definition at line 30 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by operator=().
|
protected |
Definition at line 35 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by operator=().
|
protected |
Definition at line 31 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by AbstractAgglomerativeDistanceMethod(), hasTree(), operator=(), and tree().
|
protected |
Definition at line 34 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by isVerbose(), operator=(), and setVerbose().