bpp-phyl  2.2.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 throw (NodeNotFoundException)
 Change the root node. More...
 
virtual void newOutGroup (int nodeId)=0 throw (NodeNotFoundException)
 Root a tree by specifying an outgroup. More...
 
virtual bool isRooted () const =0
 Tell if the tree is rooted. More...
 
virtual bool unroot ()=0 throw (UnrootedTreeException)
 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 throw (NodeException)
 Get all the branch lengths of a tree. More...
 
virtual double getTotalLength ()=0 throw (NodeException)
 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 throw (NodeException)
 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 throw (NodeNotFoundException)
 
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 throw (NodeNotFoundException)
 
virtual std::vector< int > getAncestorsId (int nodeId) const =0 throw (NodeNotFoundException)
 
virtual int getFatherId (int parentId) const =0 throw (NodeNotFoundException)
 
virtual bool hasFather (int nodeId) const =0 throw (NodeNotFoundException)
 
Dealing with node names.
virtual std::string getNodeName (int nodeId) const =0 throw (NodeNotFoundException)
 
virtual void setNodeName (int nodeId, const std::string &name)=0 throw (NodeNotFoundException)
 
virtual void deleteNodeName (int nodeId)=0 throw (NodeNotFoundException)
 
virtual bool hasNodeName (int nodeId) const =0 throw (NodeNotFoundException)
 
Several tests.
virtual bool hasNode (int nodeId) const =0
 
virtual bool isLeaf (int nodeId) const =0 throw (NodeNotFoundException)
 
virtual bool isRoot (int nodeId) const =0 throw (NodeNotFoundException)
 
Acting on topology.
void swapNodes (const Tree &tree, int nodeId, size_t i1=0, size_t i2=1) throw (NodeNotFoundException,IndexOutOfBoundsException)
 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 throw (NodeNotFoundException)
 
virtual void setNodeProperty (int nodeId, const std::string &name, const Clonable &property)=0 throw (NodeNotFoundException)
 
virtual Clonable * getNodeProperty (int nodeId, const std::string &name)=0 throw (NodeNotFoundException)
 
virtual const Clonable * getNodeProperty (int nodeId, const std::string &name) const =0 throw (NodeNotFoundException)
 
virtual Clonable * removeNodeProperty (int nodeId, const std::string &name)=0 throw (NodeNotFoundException)
 
virtual std::vector< std::string > getNodePropertyNames (int nodeId) const =0 throw (NodeNotFoundException)
 
Branch properties.
virtual bool hasBranchProperty (int nodeId, const std::string &name) const =0 throw (NodeNotFoundException)
 
virtual void setBranchProperty (int nodeId, const std::string &name, const Clonable &property)=0 throw (NodeNotFoundException)
 
virtual Clonable * getBranchProperty (int nodeId, const std::string &name)=0 throw (NodeNotFoundException)
 
virtual const Clonable * getBranchProperty (int nodeId, const std::string &name) const =0 throw (NodeNotFoundException)
 
virtual Clonable * removeBranchProperty (int nodeId, const std::string &name)=0 throw (NodeNotFoundException)
 
virtual std::vector< std::string > getBranchPropertyNames (int nodeId) const =0 throw (NodeNotFoundException)
 

Detailed Description

Interface for phylogenetic tree objects.

Definition at line 148 of file Tree.h.

Constructor & Destructor Documentation

◆ Tree()

bpp::Tree::Tree ( )
inline

Definition at line 154 of file Tree.h.

◆ ~Tree()

virtual bpp::Tree::~Tree ( )
inlinevirtual

Definition at line 155 of file Tree.h.

Member Function Documentation

◆ clone()

Tree* bpp::Tree::clone ( ) const
pure virtual

◆ cloneSubtree()

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 >.

◆ deleteDistanceToFather()

virtual void bpp::Tree::deleteDistanceToFather ( int  nodeId)
pure virtual

◆ deleteNodeName()

virtual void bpp::Tree::deleteNodeName ( int  nodeId)
throw (NodeNotFoundException
)
pure virtual

◆ getAncestorsId()

virtual std::vector<int> bpp::Tree::getAncestorsId ( int  nodeId) const
throw (NodeNotFoundException
)
pure virtual

◆ getBranchesId()

virtual std::vector<int> bpp::Tree::getBranchesId ( ) const
pure virtual

◆ getBranchLengths() [1/2]

virtual std::vector<double> bpp::Tree::getBranchLengths ( ) const
pure virtual

◆ getBranchLengths() [2/2]

virtual std::vector<double> bpp::Tree::getBranchLengths ( )
throw (NodeException
)
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 >.

◆ getBranchProperty() [1/2]

virtual Clonable* bpp::Tree::getBranchProperty ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
pure virtual

◆ getBranchProperty() [2/2]

virtual const Clonable* bpp::Tree::getBranchProperty ( int  nodeId,
const std::string &  name 
) const
throw (NodeNotFoundException
)
pure virtual

◆ getBranchPropertyNames()

virtual std::vector<std::string> bpp::Tree::getBranchPropertyNames ( int  nodeId) const
throw (NodeNotFoundException
)
pure virtual

◆ getDistanceToFather()

◆ getFatherId()

virtual int bpp::Tree::getFatherId ( int  parentId) const
throw (NodeNotFoundException
)
pure virtual

◆ getInnerNodesId()

virtual std::vector<int> bpp::Tree::getInnerNodesId ( ) const
pure virtual

◆ getLeafId()

virtual int bpp::Tree::getLeafId ( const std::string &  name) const
throw (NodeNotFoundException
)
pure virtual

◆ getLeavesId()

virtual std::vector<int> bpp::Tree::getLeavesId ( ) const
pure virtual

◆ getLeavesNames()

virtual std::vector<std::string> bpp::Tree::getLeavesNames ( ) const
pure virtual

◆ getName()

virtual std::string bpp::Tree::getName ( ) const
pure virtual

◆ getNextId()

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 >.

◆ getNodeName()

◆ getNodeProperty() [1/2]

virtual Clonable* bpp::Tree::getNodeProperty ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
pure virtual

◆ getNodeProperty() [2/2]

virtual const Clonable* bpp::Tree::getNodeProperty ( int  nodeId,
const std::string &  name 
) const
throw (NodeNotFoundException
)
pure virtual

◆ getNodePropertyNames()

virtual std::vector<std::string> bpp::Tree::getNodePropertyNames ( int  nodeId) const
throw (NodeNotFoundException
)
pure virtual

◆ getNodesId()

virtual std::vector<int> bpp::Tree::getNodesId ( ) const
pure virtual

◆ getNumberOfLeaves()

virtual size_t bpp::Tree::getNumberOfLeaves ( ) const
pure virtual

◆ getNumberOfNodes()

virtual size_t bpp::Tree::getNumberOfNodes ( ) const
pure virtual

◆ getRootId()

◆ getSonsId()

◆ getTotalLength()

virtual double bpp::Tree::getTotalLength ( )
throw (NodeException
)
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 >.

◆ hasBranchProperty()

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

◆ hasDistanceToFather()

◆ hasFather()

virtual bool bpp::Tree::hasFather ( int  nodeId) const
throw (NodeNotFoundException
)
pure virtual

◆ hasNode()

◆ hasNodeName()

◆ hasNodeProperty()

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

◆ isLeaf()

◆ isMultifurcating()

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().

◆ isRoot()

virtual bool bpp::Tree::isRoot ( int  nodeId) const
throw (NodeNotFoundException
)
pure virtual

◆ isRooted()

virtual bool bpp::Tree::isRooted ( ) const
pure virtual

◆ newOutGroup()

virtual void bpp::Tree::newOutGroup ( int  nodeId)
throw (NodeNotFoundException
)
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().

◆ removeBranchProperty()

virtual Clonable* bpp::Tree::removeBranchProperty ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
pure virtual

◆ removeNodeProperty()

virtual Clonable* bpp::Tree::removeNodeProperty ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
pure virtual

◆ resetNodesId()

virtual void bpp::Tree::resetNodesId ( )
pure virtual

◆ rootAt()

virtual void bpp::Tree::rootAt ( int  nodeId)
throw (NodeNotFoundException
)
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 >.

◆ scaleTree()

virtual void bpp::Tree::scaleTree ( double  factor)
throw (NodeException
)
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 >.

◆ setBranchLengths()

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 >.

◆ setBranchProperty()

virtual void bpp::Tree::setBranchProperty ( int  nodeId,
const std::string &  name,
const Clonable &  property 
)
throw (NodeNotFoundException
)
pure virtual

◆ setDistanceToFather()

virtual void bpp::Tree::setDistanceToFather ( int  nodeId,
double  length 
)
pure virtual

◆ setName()

virtual void bpp::Tree::setName ( const std::string &  name)
pure virtual

◆ setNodeName()

virtual void bpp::Tree::setNodeName ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
pure virtual

◆ setNodeProperty()

virtual void bpp::Tree::setNodeProperty ( int  nodeId,
const std::string &  name,
const Clonable &  property 
)
throw (NodeNotFoundException
)
pure virtual

◆ setVoidBranchLengths()

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 >.

◆ swapNodes()

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

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

◆ unroot()

virtual bool bpp::Tree::unroot ( )
throw (UnrootedTreeException
)
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().


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