bpp-phyl  2.4.0
bpp::Tree Class Referenceabstract

Interface for phylogenetic tree objects. More...

#include <Bpp/Phyl/Tree.h>

+ Inheritance diagram for bpp::Tree:
+ Collaboration diagram for bpp::Tree:

Public Member Functions

 Tree ()
 
virtual ~Tree ()
 
Treeclone () const =0
 
virtual TreecloneSubtree (int newRootId) const =0
 clones a Subtree rooted at given node Id More...
 
virtual size_t getNumberOfLeaves () const =0
 
virtual size_t getNumberOfNodes () const =0
 
virtual std::vector< double > getBranchLengths () const =0
 
virtual std::vector< std::string > getLeavesNames () const =0
 
virtual void rootAt (int nodeId)=0
 Change the root node. More...
 
virtual void newOutGroup (int nodeId)=0
 Root a tree by specifying an outgroup. More...
 
virtual bool isRooted () const =0
 Tell if the tree is rooted. More...
 
virtual bool unroot ()=0
 Unroot a rooted tree. More...
 
virtual void resetNodesId ()=0
 Number nodes. More...
 
virtual bool isMultifurcating () const =0
 Tell if the tree is multifurcating. More...
 
virtual std::vector< double > getBranchLengths ()=0
 Get all the branch lengths of a tree. More...
 
virtual double getTotalLength ()=0
 Get the total length (sum of all branch lengths) of a tree. More...
 
virtual void setBranchLengths (double brLen)=0
 Set all the branch lengths of a tree. More...
 
virtual void setVoidBranchLengths (double brLen)=0
 Give a length to branches that don't have one in a tree. More...
 
virtual void scaleTree (double factor)=0
 Scale a given tree. More...
 
virtual int getNextId ()=0
 Get an id. More...
 
virtual std::string getName () const =0
 Tree name. More...
 
virtual void setName (const std::string &name)=0
 
Retrieving ids.
virtual int getRootId () const =0
 
virtual int getLeafId (const std::string &name) const =0
 
virtual std::vector< int > getLeavesId () const =0
 
virtual std::vector< int > getNodesId () const =0
 
virtual std::vector< int > getInnerNodesId () const =0
 
virtual std::vector< int > getBranchesId () const =0
 
virtual std::vector< int > getSonsId (int parentId) const =0
 
virtual std::vector< int > getAncestorsId (int nodeId) const =0
 
virtual int getFatherId (int parentId) const =0
 
virtual bool hasFather (int nodeId) const =0
 
Dealing with node names.
virtual std::string getNodeName (int nodeId) const =0
 
virtual void setNodeName (int nodeId, const std::string &name)=0
 
virtual void deleteNodeName (int nodeId)=0
 
virtual bool hasNodeName (int nodeId) const =0
 
Several tests.
virtual bool hasNode (int nodeId) const =0
 
virtual bool isLeaf (int nodeId) const =0
 
virtual bool isRoot (int nodeId) const =0
 
Acting on topology.
void swapNodes (const Tree &tree, int nodeId, size_t i1=0, size_t i2=1)
 Swap two son nodes. More...
 
Dealing with branch lengths.
virtual double getDistanceToFather (int nodeId) const =0
 
virtual void setDistanceToFather (int nodeId, double length)=0
 
virtual void deleteDistanceToFather (int nodeId)=0
 
virtual bool hasDistanceToFather (int nodeId) const =0
 
Node properties.
virtual bool hasNodeProperty (int nodeId, const std::string &name) const =0
 
virtual void setNodeProperty (int nodeId, const std::string &name, const Clonable &property)=0
 
virtual ClonablegetNodeProperty (int nodeId, const std::string &name)=0
 
virtual const ClonablegetNodeProperty (int nodeId, const std::string &name) const =0
 
virtual ClonableremoveNodeProperty (int nodeId, const std::string &name)=0
 
virtual std::vector< std::string > getNodePropertyNames (int nodeId) const =0
 
Branch properties.
virtual bool hasBranchProperty (int nodeId, const std::string &name) const =0
 
virtual void setBranchProperty (int nodeId, const std::string &name, const Clonable &property)=0
 
virtual ClonablegetBranchProperty (int nodeId, const std::string &name)=0
 
virtual const ClonablegetBranchProperty (int nodeId, const std::string &name) const =0
 
virtual ClonableremoveBranchProperty (int nodeId, const std::string &name)=0
 
virtual std::vector< std::string > getBranchPropertyNames (int nodeId) const =0
 

Detailed Description

Interface for phylogenetic tree objects.

Definition at line 148 of file Tree.h.

Constructor & Destructor Documentation

bpp::Tree::Tree ( )
inline

Definition at line 154 of file Tree.h.

Member Function Documentation

Tree* bpp::Tree::clone ( ) const
pure virtual
virtual Tree* bpp::Tree::cloneSubtree ( int  newRootId) const
pure virtual

clones a Subtree rooted at given node Id

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by ~Tree().

virtual void bpp::Tree::deleteDistanceToFather ( int  nodeId)
pure virtual
virtual void bpp::Tree::deleteNodeName ( int  nodeId)
pure virtual
virtual std::vector<int> bpp::Tree::getAncestorsId ( int  nodeId) const
pure virtual
virtual std::vector<int> bpp::Tree::getBranchesId ( ) const
pure virtual
virtual std::vector<double> bpp::Tree::getBranchLengths ( ) const
pure virtual
virtual std::vector<double> bpp::Tree::getBranchLengths ( )
pure virtual

Get all the branch lengths of a tree.

Returns
A vector with all branch lengths.
Exceptions
NodeExceptionIf a branch length is lacking.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

virtual const Clonable* bpp::Tree::getBranchProperty ( int  nodeId,
const std::string &  name 
) const
pure virtual
virtual std::vector<std::string> bpp::Tree::getBranchPropertyNames ( int  nodeId) const
pure virtual
virtual std::vector<int> bpp::Tree::getInnerNodesId ( ) const
pure virtual
virtual int bpp::Tree::getLeafId ( const std::string &  name) const
pure virtual
virtual std::vector<int> bpp::Tree::getLeavesId ( ) const
pure virtual
virtual std::string bpp::Tree::getName ( ) const
pure virtual
virtual int bpp::Tree::getNextId ( )
pure virtual

Get an id.

Returns
an unused node id.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by ~Tree().

virtual Clonable* bpp::Tree::getNodeProperty ( int  nodeId,
const std::string &  name 
)
pure virtual
virtual const Clonable* bpp::Tree::getNodeProperty ( int  nodeId,
const std::string &  name 
) const
pure virtual
virtual std::vector<std::string> bpp::Tree::getNodePropertyNames ( int  nodeId) const
pure virtual
virtual size_t bpp::Tree::getNumberOfLeaves ( ) const
pure virtual
virtual size_t bpp::Tree::getNumberOfNodes ( ) const
pure virtual
virtual double bpp::Tree::getTotalLength ( )
pure virtual

Get the total length (sum of all branch lengths) of a tree.

Returns
The total length of the subtree.
Exceptions
NodeExceptionIf a branch length is lacking.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by ~Tree().

virtual bool bpp::Tree::hasBranchProperty ( int  nodeId,
const std::string &  name 
) const
pure virtual
virtual bool bpp::Tree::hasNodeProperty ( int  nodeId,
const std::string &  name 
) const
pure virtual
virtual bool bpp::Tree::isMultifurcating ( ) const
pure virtual

Tell if the tree is multifurcating.

Returns
True if the tree is multifurcating.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by bpp::TreeTools::constrainedMidPointRooting(), and ~Tree().

virtual bool bpp::Tree::isRoot ( int  nodeId) const
pure virtual
virtual bool bpp::Tree::isRooted ( ) const
pure virtual
virtual void bpp::Tree::newOutGroup ( int  nodeId)
pure virtual

Root a tree by specifying an outgroup.

If the tree is rooted, unroot it first, change the root node and then reroot the tree using the previous root id. If the tree is unrooted, change the root node and then create a new root node.

Parameters
nodeIdThe id of the node that will be the new root.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by bpp::TreeTools::midpointRooting(), and ~Tree().

virtual Clonable* bpp::Tree::removeBranchProperty ( int  nodeId,
const std::string &  name 
)
pure virtual
virtual Clonable* bpp::Tree::removeNodeProperty ( int  nodeId,
const std::string &  name 
)
pure virtual
virtual void bpp::Tree::resetNodesId ( )
pure virtual
virtual void bpp::Tree::rootAt ( int  nodeId)
pure virtual

Change the root node.

Works on unrooted tree. If the tree is rooted, the method unroots it first.

Parameters
nodeIdThe id of the node that will be the new root.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by ~Tree().

virtual void bpp::Tree::scaleTree ( double  factor)
pure virtual

Scale a given tree.

Multiply all branch lengths by a given factor.

Parameters
factorThe factor to multiply all branch lengths with.
Exceptions
NodeExceptionIf a branch length is lacking.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by ~Tree().

virtual void bpp::Tree::setBranchLengths ( double  brLen)
pure virtual

Set all the branch lengths of a tree.

Parameters
brLenThe branch length to apply.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by ~Tree().

virtual void bpp::Tree::setBranchProperty ( int  nodeId,
const std::string &  name,
const Clonable property 
)
pure virtual
virtual void bpp::Tree::setName ( const std::string &  name)
pure virtual
virtual void bpp::Tree::setNodeName ( int  nodeId,
const std::string &  name 
)
pure virtual
virtual void bpp::Tree::setNodeProperty ( int  nodeId,
const std::string &  name,
const Clonable property 
)
pure virtual
virtual void bpp::Tree::setVoidBranchLengths ( double  brLen)
pure virtual

Give a length to branches that don't have one in a tree.

Parameters
brLenThe branch length to apply.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by ~Tree().

void bpp::Tree::swapNodes ( const Tree tree,
int  nodeId,
size_t  i1 = 0,
size_t  i2 = 1 
)

Swap two son nodes.

Parameters
treeThe tree.
nodeIdThe node.
i1First son node index.
i2Second son node index.
Exceptions
NodeNotFoundExceptionIf the node is not found.
IndexOutOfBoundsExceptionIf one node index is not valid, or if the node

Referenced by ~Tree().

virtual bool bpp::Tree::unroot ( )
pure virtual

Unroot a rooted tree.

Returns
True if the tree has been unrooted.
Exceptions
UnrootedTreeExceptionIf the tree is already rooted.

Implemented in bpp::TreeTemplate< N >, bpp::TreeTemplate< bpp::Node >, and bpp::TreeTemplate< bpp::NodeTemplate >.

Referenced by bpp::TreeTools::midpointRooting(), and ~Tree().


The documentation for this class was generated from the following file: