bpp-phyl  2.1.0
bpp::Tree Class Reference

Interface for phylogenetic tree objects. More...

#include <Bpp/Phyl/Tree.h>

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

List of all members.

Public Member Functions

 Tree ()
virtual ~Tree ()
Treeclone () const =0
virtual TreecloneSubtree (int newRootId) const =0
 clones a Subtree rooted at given node Id
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.
virtual void newOutGroup (int nodeId)=0 throw (NodeNotFoundException)
 Root a tree by specifying an outgroup.
virtual bool isRooted () const =0
 Tell if the tree is rooted.
virtual bool unroot ()=0 throw (UnrootedTreeException)
 Unroot a rooted tree.
virtual void resetNodesId ()=0
 Number nodes.
virtual bool isMultifurcating () const =0
 Tell if the tree is multifurcating.
virtual std::vector< double > getBranchLengths ()=0 throw (NodeException)
 Get all the branch lengths of a tree.
virtual double getTotalLength ()=0 throw (NodeException)
 Get the total length (sum of all branch lengths) of a tree.
virtual void setBranchLengths (double brLen)=0
 Set all the branch lengths of a tree.
virtual void setVoidBranchLengths (double brLen)=0
 Give a length to branches that don't have one in a tree.
virtual void scaleTree (double factor)=0 throw (NodeException)
 Scale a given tree.
virtual int getNextId ()=0
 Get an id.
virtual std::string getName () const =0
 Tree name.
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.
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 ClonablegetNodeProperty (int nodeId, const std::string &name)=0 throw (NodeNotFoundException)
virtual const ClonablegetNodeProperty (int nodeId, const std::string &name) const =0 throw (NodeNotFoundException)
virtual ClonableremoveNodeProperty (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 ClonablegetBranchProperty (int nodeId, const std::string &name)=0 throw (NodeNotFoundException)
virtual const ClonablegetBranchProperty (int nodeId, const std::string &name) const =0 throw (NodeNotFoundException)
virtual ClonableremoveBranchProperty (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

bpp::Tree::Tree ( ) [inline]

Definition at line 154 of file Tree.h.

virtual bpp::Tree::~Tree ( ) [inline, virtual]

Definition at line 155 of file Tree.h.


Member Function Documentation

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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

virtual std::vector<int> bpp::Tree::getAncestorsId ( int  nodeId) const throw (NodeNotFoundException) [pure virtual]
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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

virtual const Clonable* bpp::Tree::getBranchProperty ( int  nodeId,
const std::string &  name 
) const throw (NodeNotFoundException) [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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

virtual const Clonable* bpp::Tree::getNodeProperty ( int  nodeId,
const std::string &  name 
) const throw (NodeNotFoundException) [pure virtual]
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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

virtual bool bpp::Tree::hasNodeProperty ( int  nodeId,
const std::string &  name 
) const throw (NodeNotFoundException) [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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

Referenced by bpp::TreeTools::constrainedMidPointRooting().

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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

Referenced by bpp::TreeTools::midpointRooting().

virtual Clonable* bpp::Tree::removeBranchProperty ( int  nodeId,
const std::string &  name 
) throw (NodeNotFoundException) [pure virtual]
virtual Clonable* bpp::Tree::removeNodeProperty ( int  nodeId,
const std::string &  name 
) throw (NodeNotFoundException) [pure virtual]
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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

virtual void bpp::Tree::setBranchProperty ( int  nodeId,
const std::string &  name,
const Clonable property 
) throw (NodeNotFoundException) [pure virtual]
virtual void bpp::Tree::setName ( const std::string &  name) [pure virtual]
virtual void bpp::Tree::setNodeName ( int  nodeId,
const std::string &  name 
) throw (NodeNotFoundException) [pure virtual]
virtual void bpp::Tree::setNodeProperty ( int  nodeId,
const std::string &  name,
const Clonable property 
) throw (NodeNotFoundException) [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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

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
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< Node >, bpp::TreeTemplate< INode >, and bpp::TreeTemplate< SNode >.

Referenced by bpp::TreeTools::midpointRooting().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends