bpp-phyl  2.2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
bpp::TreeTemplate< N > Class Template Reference

The phylogenetic tree class. More...

#include <Bpp/Phyl/BipartitionList.h>

+ Inheritance diagram for bpp::TreeTemplate< N >:
+ Collaboration diagram for bpp::TreeTemplate< N >:

Public Member Functions

 TreeTemplate ()
 
 TreeTemplate (const TreeTemplate< N > &t)
 
 TreeTemplate (const Tree &t)
 
 TreeTemplate (N *root)
 
TreeTemplate< N > & operator= (const TreeTemplate< N > &t)
 
TreeTemplate< N > * cloneSubtree (int newRootId) const
 clones a Subtree rooted at given node Id More...
 
virtual ~TreeTemplate ()
 
TreeTemplate< N > * clone () const
 
std::string getName () const
 
void setName (const std::string &name)
 
int getRootId () const
 
size_t getNumberOfLeaves () const
 
size_t getNumberOfNodes () const
 
int getLeafId (const std::string &name) const throw (NodeNotFoundException)
 
std::vector< int > getLeavesId () const
 
std::vector< int > getNodesId () const
 
std::vector< int > getInnerNodesId () const
 
std::vector< int > getBranchesId () const
 
std::vector< double > getBranchLengths () const
 
std::vector< std::string > getLeavesNames () const
 
std::vector< int > getSonsId (int parentId) const throw (NodeNotFoundException)
 
std::vector< int > getAncestorsId (int nodeId) const throw (NodeNotFoundException)
 
int getFatherId (int parentId) const throw (NodeNotFoundException)
 
bool hasFather (int nodeId) const throw (NodeNotFoundException)
 
std::string getNodeName (int nodeId) const throw (NodeNotFoundException)
 
bool hasNodeName (int nodeId) const throw (NodeNotFoundException)
 
void setNodeName (int nodeId, const std::string &name) throw (NodeNotFoundException)
 
void deleteNodeName (int nodeId) throw (NodeNotFoundException)
 
bool hasNode (int nodeId) const
 
bool isLeaf (int nodeId) const throw (NodeNotFoundException)
 
bool isRoot (int nodeId) const throw (NodeNotFoundException)
 
double getDistanceToFather (int nodeId) const
 
void setDistanceToFather (int nodeId, double length)
 
void deleteDistanceToFather (int nodeId)
 
bool hasDistanceToFather (int nodeId) const
 
bool hasNodeProperty (int nodeId, const std::string &name) const throw (NodeNotFoundException)
 
void setNodeProperty (int nodeId, const std::string &name, const Clonable &property) throw (NodeNotFoundException)
 
ClonablegetNodeProperty (int nodeId, const std::string &name) throw (NodeNotFoundException)
 
const ClonablegetNodeProperty (int nodeId, const std::string &name) const throw (NodeNotFoundException)
 
ClonableremoveNodeProperty (int nodeId, const std::string &name) throw (NodeNotFoundException)
 
std::vector< std::string > getNodePropertyNames (int nodeId) const throw (NodeNotFoundException)
 
bool hasBranchProperty (int nodeId, const std::string &name) const throw (NodeNotFoundException)
 
void setBranchProperty (int nodeId, const std::string &name, const Clonable &property) throw (NodeNotFoundException)
 
ClonablegetBranchProperty (int nodeId, const std::string &name) throw (NodeNotFoundException)
 
const ClonablegetBranchProperty (int nodeId, const std::string &name) const throw (NodeNotFoundException)
 
ClonableremoveBranchProperty (int nodeId, const std::string &name) throw (NodeNotFoundException)
 
std::vector< std::string > getBranchPropertyNames (int nodeId) const throw (NodeNotFoundException)
 
void rootAt (int nodeId) throw (NodeNotFoundException)
 Change the root node. More...
 
void newOutGroup (int nodeId) throw (NodeNotFoundException)
 Root a tree by specifying an outgroup. More...
 
bool isRooted () const
 Tell if the tree is rooted. More...
 
bool unroot () throw (UnrootedTreeException)
 Unroot a rooted tree. More...
 
void resetNodesId ()
 Number nodes. More...
 
bool isMultifurcating () const
 Tell if the tree is multifurcating. More...
 
template<class N2 >
bool hasSameTopologyAs (const TreeTemplate< N2 > &tree, bool ordered=false) const
 Tells if this tree has the same topology as the one given for comparison. More...
 
std::vector< double > getBranchLengths () throw (NodeException)
 Get all the branch lengths of a tree. More...
 
double getTotalLength () throw (NodeException)
 Get the total length (sum of all branch lengths) of a tree. More...
 
void setBranchLengths (double brLen)
 Set all the branch lengths of a tree. More...
 
void setVoidBranchLengths (double brLen)
 Give a length to branches that don't have one in a tree. More...
 
void scaleTree (double factor) throw (NodeException)
 Scale a given tree. More...
 
int getNextId ()
 Get an id. More...
 
void swapNodes (int parentId, size_t i1, size_t i2) throw (NodeNotFoundException, IndexOutOfBoundsException)
 
Specific methods
virtual void setRootNode (N *root)
 
virtual N * getRootNode ()
 
virtual const N * getRootNode () const
 
virtual std::vector< const N * > getLeaves () const
 
virtual std::vector< N * > getLeaves ()
 
virtual std::vector< const N * > getNodes () const
 
virtual std::vector< N * > getNodes ()
 
virtual std::vector< const N * > getInnerNodes () const
 
virtual std::vector< N * > getInnerNodes ()
 
virtual N * getNode (int id, bool checkId=false) throw (NodeNotFoundException, Exception)
 
virtual const N * getNode (int id, bool checkId=false) const throw (NodeNotFoundException, Exception)
 
virtual N * getNode (const std::string &name) throw (NodeNotFoundException, Exception)
 
virtual const N * getNode (const std::string &name) const throw (NodeNotFoundException, Exception)
 
void rootAt (N *newRoot)
 
void newOutGroup (N *outGroup)
 
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...
 

Private Attributes

N * root_
 
std::string name_
 

Detailed Description

template<class N>
class bpp::TreeTemplate< N >

The phylogenetic tree class.

This class is part of the object implementation of phylogenetic trees. Tree are made made of nodes, instances of the class Node. It is possible to use a tree with more complexe Node classes, but currently all nodes of a tree have to be of the same class.

Trees are oriented (rooted), i.e. each node has one father node and possibly many son nodes. Leaves are nodes without descendant and root is defined has the without father. Inner nodes will generally contain two descendants (the tree is then called bifurcating), but mutlifurcating trees are also allowed with this kind of description. In the rooted case, each inner node also defines a subtree. This allows to work recursively on trees, which is very convenient in most cases. To deal with non-rooted trees, we place an artificial root at a particular node: hence the root node appears to be trifurcated. This is the way unrooted trees are described in the parenthetic description, the so called Newick format.

To clone a tree from from another tree with a different template, consider using the TreeTools::cloneSutree<N>() method:

Tree * t = new Tree<Node>(...)
NodeTemplate<int> * newRoot = TreeTools::cloneSubtree< NodeTemplate<int> >(* (t -> getRootNode()))
Tree< NodeTemplate<int> > * tt = new Tree< NodeTemplate<int> >(* newRoot);

The getNextId() method sends a id value which is not used in the tree. In the current implementation, it uses the TreeTools::getMPNUId() method. This avoids to use duplicated ids, but is time consuming. In most cases, it is of better efficiency if the user deal with the ids himself, by using the Node::setId() method. The TreeTools::getMaxId() method may also prove useful in this respect. The resetNodesId() method can also be used to re-initialize all ids.

See Also
Node
NodeTemplate
TreeTools

Definition at line 56 of file BipartitionList.h.

Constructor & Destructor Documentation

template<class N>
bpp::TreeTemplate< N >::TreeTemplate ( )
inline

Definition at line 105 of file TreeTemplate.h.

template<class N>
bpp::TreeTemplate< N >::TreeTemplate ( const TreeTemplate< N > &  t)
inline

Definition at line 108 of file TreeTemplate.h.

template<class N>
bpp::TreeTemplate< N >::TreeTemplate ( const Tree t)
inline

Definition at line 116 of file TreeTemplate.h.

template<class N>
bpp::TreeTemplate< N >::TreeTemplate ( N *  root)
inline

Definition at line 124 of file TreeTemplate.h.

template<class N>
virtual bpp::TreeTemplate< N >::~TreeTemplate ( )
inlinevirtual

Definition at line 145 of file TreeTemplate.h.

Member Function Documentation

template<class N>
TreeTemplate<N>* bpp::TreeTemplate< N >::clone ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 151 of file TreeTemplate.h.

Referenced by bpp::TreeTemplate< bpp::NodeTemplate >::hasSameTopologyAs().

template<class N>
TreeTemplate<N>* bpp::TreeTemplate< N >::cloneSubtree ( int  newRootId) const
inlinevirtual

clones a Subtree rooted at given node Id

Implements bpp::Tree.

Definition at line 139 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::deleteDistanceToFather ( int  nodeId)
inlinevirtual

Implements bpp::Tree.

Definition at line 208 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::deleteNodeName ( int  nodeId)
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 196 of file TreeTemplate.h.

template<class N>
std::vector<int> bpp::TreeTemplate< N >::getAncestorsId ( int  nodeId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 184 of file TreeTemplate.h.

template<class N>
std::vector<int> bpp::TreeTemplate< N >::getBranchesId ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 176 of file TreeTemplate.h.

template<class N>
std::vector<double> bpp::TreeTemplate< N >::getBranchLengths ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 178 of file TreeTemplate.h.

template<class N>
std::vector<double> bpp::TreeTemplate< N >::getBranchLengths ( )
throw (NodeException
)
inlinevirtual

Get all the branch lengths of a tree.

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

Implements bpp::Tree.

Definition at line 343 of file TreeTemplate.h.

template<class N>
Clonable* bpp::TreeTemplate< N >::getBranchProperty ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 228 of file TreeTemplate.h.

Referenced by bpp::TreeTemplate< bpp::NodeTemplate >::rootAt().

template<class N>
const Clonable* bpp::TreeTemplate< N >::getBranchProperty ( int  nodeId,
const std::string &  name 
) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 230 of file TreeTemplate.h.

template<class N>
std::vector<std::string> bpp::TreeTemplate< N >::getBranchPropertyNames ( int  nodeId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 234 of file TreeTemplate.h.

template<class N>
double bpp::TreeTemplate< N >::getDistanceToFather ( int  nodeId) const
inlinevirtual

Implements bpp::Tree.

Definition at line 204 of file TreeTemplate.h.

Referenced by bpp::TreeTemplate< bpp::NodeTemplate >::rootAt().

template<class N>
int bpp::TreeTemplate< N >::getFatherId ( int  parentId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 186 of file TreeTemplate.h.

template<class N>
virtual std::vector<const N*> bpp::TreeTemplate< N >::getInnerNodes ( ) const
inlinevirtual

Definition at line 415 of file TreeTemplate.h.

template<class N>
virtual std::vector<N*> bpp::TreeTemplate< N >::getInnerNodes ( )
inlinevirtual

Definition at line 417 of file TreeTemplate.h.

template<class N>
std::vector<int> bpp::TreeTemplate< N >::getInnerNodesId ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 174 of file TreeTemplate.h.

template<class N>
int bpp::TreeTemplate< N >::getLeafId ( const std::string &  name) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 168 of file TreeTemplate.h.

template<class N>
virtual std::vector<const N*> bpp::TreeTemplate< N >::getLeaves ( ) const
inlinevirtual

Definition at line 407 of file TreeTemplate.h.

Referenced by bpp::NexusIOTree::read().

template<class N>
virtual std::vector<N*> bpp::TreeTemplate< N >::getLeaves ( )
inlinevirtual

Definition at line 409 of file TreeTemplate.h.

template<class N>
std::vector<int> bpp::TreeTemplate< N >::getLeavesId ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 170 of file TreeTemplate.h.

template<class N>
std::vector<std::string> bpp::TreeTemplate< N >::getLeavesNames ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 180 of file TreeTemplate.h.

Referenced by bpp::TreeTemplateTools::getDistanceMatrix().

template<class N>
std::string bpp::TreeTemplate< N >::getName ( ) const
inlinevirtual

Methods:

Implements bpp::Tree.

Definition at line 158 of file TreeTemplate.h.

template<class N>
int bpp::TreeTemplate< N >::getNextId ( )
inlinevirtual

Get an id.

Returns
an unused node id.

Implements bpp::Tree.

Definition at line 383 of file TreeTemplate.h.

Referenced by bpp::TreeTemplate< bpp::NodeTemplate >::newOutGroup().

template<class N>
virtual N* bpp::TreeTemplate< N >::getNode ( int  id,
bool  checkId = false 
)
throw (NodeNotFoundException,
Exception
)
inlinevirtual

Definition at line 419 of file TreeTemplate.h.

Referenced by bpp::TreeTemplate< bpp::NodeTemplate >::deleteDistanceToFather(), bpp::TreeTemplate< bpp::NodeTemplate >::deleteNodeName(), bpp::TreeTemplate< bpp::NodeTemplate >::getAncestorsId(), bpp::TreeTemplate< bpp::NodeTemplate >::getBranchProperty(), bpp::TreeTemplate< bpp::NodeTemplate >::getBranchPropertyNames(), bpp::TreeTemplate< bpp::NodeTemplate >::getDistanceToFather(), bpp::TreeTemplate< bpp::NodeTemplate >::getFatherId(), bpp::TreeTemplate< bpp::NodeTemplate >::getNodeName(), bpp::TreeTemplate< bpp::NodeTemplate >::getNodeProperty(), bpp::TreeTemplate< bpp::NodeTemplate >::getNodePropertyNames(), bpp::SubstitutionMappingTools::getNormalizedCountsPerBranch(), bpp::TreeTemplate< bpp::NodeTemplate >::getSonsId(), bpp::TreeTemplate< bpp::NodeTemplate >::hasBranchProperty(), bpp::TreeTemplate< bpp::NodeTemplate >::hasDistanceToFather(), bpp::TreeTemplate< bpp::NodeTemplate >::hasFather(), bpp::TreeTemplate< bpp::NodeTemplate >::hasNodeName(), bpp::TreeTemplate< bpp::NodeTemplate >::hasNodeProperty(), bpp::TreeTemplate< bpp::NodeTemplate >::isLeaf(), bpp::TreeTemplate< bpp::NodeTemplate >::isRoot(), bpp::TreeTemplate< bpp::NodeTemplate >::newOutGroup(), bpp::TreeTemplate< bpp::NodeTemplate >::removeBranchProperty(), bpp::TreeTemplate< bpp::NodeTemplate >::removeNodeProperty(), bpp::TreeTemplate< bpp::NodeTemplate >::rootAt(), bpp::TreeTemplate< bpp::NodeTemplate >::setBranchProperty(), bpp::TreeTemplate< bpp::NodeTemplate >::setDistanceToFather(), bpp::TreeTemplate< bpp::NodeTemplate >::setNodeName(), bpp::TreeTemplate< bpp::NodeTemplate >::setNodeProperty(), bpp::DRASRTreeLikelihoodData::setTree(), and bpp::DRASDRTreeLikelihoodData::setTree().

template<class N>
virtual const N* bpp::TreeTemplate< N >::getNode ( int  id,
bool  checkId = false 
) const
throw (NodeNotFoundException,
Exception
)
inlinevirtual

Definition at line 436 of file TreeTemplate.h.

template<class N>
virtual N* bpp::TreeTemplate< N >::getNode ( const std::string &  name)
throw (NodeNotFoundException,
Exception
)
inlinevirtual

Definition at line 453 of file TreeTemplate.h.

template<class N>
virtual const N* bpp::TreeTemplate< N >::getNode ( const std::string &  name) const
throw (NodeNotFoundException,
Exception
)
inlinevirtual

Definition at line 462 of file TreeTemplate.h.

template<class N>
std::string bpp::TreeTemplate< N >::getNodeName ( int  nodeId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 190 of file TreeTemplate.h.

template<class N>
Clonable* bpp::TreeTemplate< N >::getNodeProperty ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 216 of file TreeTemplate.h.

template<class N>
const Clonable* bpp::TreeTemplate< N >::getNodeProperty ( int  nodeId,
const std::string &  name 
) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 218 of file TreeTemplate.h.

template<class N>
std::vector<std::string> bpp::TreeTemplate< N >::getNodePropertyNames ( int  nodeId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 222 of file TreeTemplate.h.

template<class N>
virtual std::vector<const N*> bpp::TreeTemplate< N >::getNodes ( ) const
inlinevirtual
template<class N>
virtual std::vector<N*> bpp::TreeTemplate< N >::getNodes ( )
inlinevirtual

Definition at line 413 of file TreeTemplate.h.

template<class N>
std::vector<int> bpp::TreeTemplate< N >::getNodesId ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 172 of file TreeTemplate.h.

template<class N>
size_t bpp::TreeTemplate< N >::getNumberOfLeaves ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 164 of file TreeTemplate.h.

template<class N>
size_t bpp::TreeTemplate< N >::getNumberOfNodes ( ) const
inlinevirtual

Implements bpp::Tree.

Definition at line 166 of file TreeTemplate.h.

template<class N>
int bpp::TreeTemplate< N >::getRootId ( ) const
inlinevirtual
template<class N>
virtual const N* bpp::TreeTemplate< N >::getRootNode ( ) const
inlinevirtual

Definition at line 405 of file TreeTemplate.h.

template<class N>
std::vector<int> bpp::TreeTemplate< N >::getSonsId ( int  parentId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 182 of file TreeTemplate.h.

template<class N>
double bpp::TreeTemplate< N >::getTotalLength ( )
throw (NodeException
)
inlinevirtual

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.

Implements bpp::Tree.

Definition at line 354 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::hasBranchProperty ( int  nodeId,
const std::string &  name 
) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 224 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::hasDistanceToFather ( int  nodeId) const
inlinevirtual

Implements bpp::Tree.

Definition at line 210 of file TreeTemplate.h.

Referenced by bpp::TreeTemplate< bpp::NodeTemplate >::rootAt().

template<class N>
bool bpp::TreeTemplate< N >::hasFather ( int  nodeId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 188 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::hasNode ( int  nodeId) const
inlinevirtual

Implements bpp::Tree.

Definition at line 198 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::hasNodeName ( int  nodeId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 192 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::hasNodeProperty ( int  nodeId,
const std::string &  name 
) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 212 of file TreeTemplate.h.

template<class N>
template<class N2 >
bool bpp::TreeTemplate< N >::hasSameTopologyAs ( const TreeTemplate< N2 > &  tree,
bool  ordered = false 
) const
inline

Tells if this tree has the same topology as the one given for comparison.

This method compares recursively all subtrees. The comparison is performed only on the nodes names and the parental relationships. Nodes ids are ignored, and so are branch lengths and any branch/node properties. The default is to ignore the ordering of the descendants, that is (A,B),C) will be considered as having the same topology as (B,A),C). Multifurcations are permited. If ordering is ignored, a copy of the two trees to be compared is performed and are ordered before comparison, making the whole comparison slower and more memory greedy.

Parameters
treeThe tree to be compared with.
orderedShould the ordering of the branching be taken into account?
Returns
True if the input tree has the same topology as this one.

Definition at line 316 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::isLeaf ( int  nodeId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 200 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::isMultifurcating ( ) const
inlinevirtual

Tell if the tree is multifurcating.

Returns
True if the tree is multifurcating.

Implements bpp::Tree.

Definition at line 293 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::isRoot ( int  nodeId) const
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 202 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::isRooted ( ) const
inlinevirtual
template<class N>
void bpp::TreeTemplate< N >::newOutGroup ( int  nodeId)
throw (NodeNotFoundException
)
inlinevirtual

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.

Implements bpp::Tree.

Definition at line 238 of file TreeTemplate.h.

Referenced by bpp::TreeTemplate< bpp::NodeTemplate >::newOutGroup().

template<class N>
void bpp::TreeTemplate< N >::newOutGroup ( N *  outGroup)
inline

Definition at line 503 of file TreeTemplate.h.

template<class N>
TreeTemplate<N>& bpp::TreeTemplate< N >::operator= ( const TreeTemplate< N > &  t)
inline

Definition at line 130 of file TreeTemplate.h.

template<class N>
Clonable* bpp::TreeTemplate< N >::removeBranchProperty ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 232 of file TreeTemplate.h.

template<class N>
Clonable* bpp::TreeTemplate< N >::removeNodeProperty ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 220 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::resetNodesId ( )
inlinevirtual
template<class N>
void bpp::TreeTemplate< N >::rootAt ( int  nodeId)
throw (NodeNotFoundException
)
inlinevirtual

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.

Implements bpp::Tree.

Definition at line 236 of file TreeTemplate.h.

Referenced by bpp::TreeTemplateTools::getBestRootInSubtree_(), bpp::TreeTemplateTools::midRoot(), bpp::TreeTemplate< bpp::NodeTemplate >::newOutGroup(), and bpp::TreeTemplate< bpp::NodeTemplate >::rootAt().

template<class N>
void bpp::TreeTemplate< N >::rootAt ( N *  newRoot)
inline

Definition at line 471 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::scaleTree ( double  factor)
throw (NodeException
)
inlinevirtual

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.

Implements bpp::Tree.

Definition at line 375 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::setBranchLengths ( double  brLen)
inlinevirtual

Set all the branch lengths of a tree.

Parameters
brLenThe branch length to apply.

Implements bpp::Tree.

Definition at line 359 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::setBranchProperty ( int  nodeId,
const std::string &  name,
const Clonable property 
)
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 226 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::setDistanceToFather ( int  nodeId,
double  length 
)
inlinevirtual

Implements bpp::Tree.

Definition at line 206 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::setName ( const std::string &  name)
inlinevirtual

Implements bpp::Tree.

Definition at line 160 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::setNodeName ( int  nodeId,
const std::string &  name 
)
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 194 of file TreeTemplate.h.

template<class N>
void bpp::TreeTemplate< N >::setNodeProperty ( int  nodeId,
const std::string &  name,
const Clonable property 
)
throw (NodeNotFoundException
)
inlinevirtual

Implements bpp::Tree.

Definition at line 214 of file TreeTemplate.h.

template<class N>
virtual void bpp::TreeTemplate< N >::setRootNode ( N *  root)
inlinevirtual
template<class N>
void bpp::TreeTemplate< N >::setVoidBranchLengths ( double  brLen)
inlinevirtual

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

Parameters
brLenThe branch length to apply.

Implements bpp::Tree.

Definition at line 367 of file TreeTemplate.h.

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

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
template<class N>
void bpp::TreeTemplate< N >::swapNodes ( int  parentId,
size_t  i1,
size_t  i2 
)
throw (NodeNotFoundException,
IndexOutOfBoundsException
)
inline

Definition at line 388 of file TreeTemplate.h.

template<class N>
bool bpp::TreeTemplate< N >::unroot ( )
throw (UnrootedTreeException
)
inlinevirtual

Unroot a rooted tree.

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

Implements bpp::Tree.

Definition at line 242 of file TreeTemplate.h.

Referenced by bpp::TreeTemplateTools::midRoot(), bpp::TreeTemplate< bpp::NodeTemplate >::newOutGroup(), and bpp::TreeTemplate< bpp::NodeTemplate >::rootAt().

Member Data Documentation

template<class N>
N* bpp::TreeTemplate< N >::root_
private

Fields:

Definition at line 100 of file TreeTemplate.h.

Referenced by bpp::TreeTemplate< bpp::NodeTemplate >::getBranchesId(), bpp::TreeTemplate< bpp::NodeTemplate >::getBranchLengths(), bpp::TreeTemplate< bpp::NodeTemplate >::getInnerNodes(), bpp::TreeTemplate< bpp::NodeTemplate >::getInnerNodesId(), bpp::TreeTemplate< bpp::NodeTemplate >::getLeafId(), bpp::TreeTemplate< bpp::NodeTemplate >::getLeaves(), bpp::TreeTemplate< bpp::NodeTemplate >::getLeavesId(), bpp::TreeTemplate< bpp::NodeTemplate >::getLeavesNames(), bpp::TreeTemplate< bpp::NodeTemplate >::getNextId(), bpp::TreeTemplate< bpp::NodeTemplate >::getNode(), bpp::TreeTemplate< bpp::NodeTemplate >::getNodes(), bpp::TreeTemplate< bpp::NodeTemplate >::getNodesId(), bpp::TreeTemplate< bpp::NodeTemplate >::getNumberOfLeaves(), bpp::TreeTemplate< bpp::NodeTemplate >::getNumberOfNodes(), bpp::TreeTemplate< bpp::NodeTemplate >::getRootId(), bpp::TreeTemplate< bpp::NodeTemplate >::getRootNode(), bpp::TreeTemplate< bpp::NodeTemplate >::getTotalLength(), bpp::TreeTemplate< bpp::NodeTemplate >::hasNode(), bpp::TreeTemplate< bpp::NodeTemplate >::isMultifurcating(), bpp::TreeTemplate< bpp::NodeTemplate >::isRooted(), bpp::TreeTemplate< bpp::NodeTemplate >::newOutGroup(), bpp::TreeTemplate< bpp::NodeTemplate >::operator=(), bpp::TreeTemplate< bpp::NodeTemplate >::rootAt(), bpp::TreeTemplate< bpp::NodeTemplate >::scaleTree(), bpp::TreeTemplate< bpp::NodeTemplate >::setBranchLengths(), bpp::TreeTemplate< bpp::NodeTemplate >::setRootNode(), bpp::TreeTemplate< bpp::NodeTemplate >::setVoidBranchLengths(), bpp::TreeTemplate< bpp::NodeTemplate >::swapNodes(), bpp::TreeTemplate< bpp::NodeTemplate >::TreeTemplate(), bpp::TreeTemplate< bpp::NodeTemplate >::unroot(), and bpp::TreeTemplate< bpp::NodeTemplate >::~TreeTemplate().


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