bpp-phyl3  3.0.0
bpp::TreeTemplate< N > Class Template Reference

The phylogenetic tree class. More...

#include <Bpp/Phyl/Tree/TreeTemplate.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
 
size_t getNumberOfBranches () const
 
int getLeafId (const std::string &name) const
 
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
 
std::vector< int > getAncestorsId (int nodeId) const
 
int getFatherId (int parentId) const
 
bool hasFather (int nodeId) const
 
std::string getNodeName (int nodeId) const
 
bool hasNodeName (int nodeId) const
 
void setNodeName (int nodeId, const std::string &name)
 
void deleteNodeName (int nodeId)
 
bool hasNode (int nodeId) const
 
bool isLeaf (int nodeId) const
 
bool hasNoSon (int nodeId) const
 
bool isRoot (int nodeId) const
 
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
 
void setNodeProperty (int nodeId, const std::string &name, const Clonable &property)
 
ClonablegetNodeProperty (int nodeId, const std::string &name)
 
const ClonablegetNodeProperty (int nodeId, const std::string &name) const
 
ClonableremoveNodeProperty (int nodeId, const std::string &name)
 
std::vector< std::string > getNodePropertyNames (int nodeId) const
 
bool hasBranchProperty (int nodeId, const std::string &name) const
 
void setBranchProperty (int nodeId, const std::string &name, const Clonable &property)
 
ClonablegetBranchProperty (int nodeId, const std::string &name)
 
const ClonablegetBranchProperty (int nodeId, const std::string &name) const
 
ClonableremoveBranchProperty (int nodeId, const std::string &name)
 
std::vector< std::string > getBranchPropertyNames (int nodeId) const
 
void rootAt (int nodeId)
 Change the root node. More...
 
void newOutGroup (int nodeId)
 Root a tree by specifying an outgroup. More...
 
bool isRooted () const
 Tell if the tree is rooted. More...
 
bool unroot ()
 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 ()
 Get all the branch lengths of a tree. More...
 
double getTotalLength ()
 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)
 Scale a given tree. More...
 
int getNextId ()
 Get an id. More...
 
void swapNodes (int parentId, size_t i1, size_t i2)
 
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)
 
virtual const N * getNode (int id, bool checkId=false) const
 
virtual N * getNode (const std::string &name)
 
virtual const N * getNode (const std::string &name) const
 
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)
 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);
TreeTemplate< N > * cloneSubtree(int newRootId) const
clones a Subtree rooted at given node Id
Definition: TreeTemplate.h:104
virtual N * getRootNode()
Definition: TreeTemplate.h:389
Tree()
Definition: Tree.h:119

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 57 of file TreeTemplate.h.

Constructor & Destructor Documentation

◆ TreeTemplate() [1/4]

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

Definition at line 70 of file TreeTemplate.h.

◆ TreeTemplate() [2/4]

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

◆ TreeTemplate() [3/4]

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

Definition at line 81 of file TreeTemplate.h.

References bpp::Tree::getRootId(), and bpp::TreeTemplate< N >::root_.

◆ TreeTemplate() [4/4]

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

Definition at line 89 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::root_.

◆ ~TreeTemplate()

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

Member Function Documentation

◆ clone()

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

Implements bpp::Tree.

Definition at line 116 of file TreeTemplate.h.

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

◆ cloneSubtree()

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 104 of file TreeTemplate.h.

◆ deleteDistanceToFather()

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

Implements bpp::Tree.

Definition at line 192 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ deleteNodeName()

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

Implements bpp::Tree.

Definition at line 178 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getAncestorsId()

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

◆ getBranchesId()

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

◆ getBranchLengths() [1/2]

template<class N >
std::vector<double> bpp::TreeTemplate< N >::getBranchLengths ( )
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 329 of file TreeTemplate.h.

References bpp::TreeTemplateTools::getBranchLengths(), and bpp::TreeTemplate< N >::root_.

◆ getBranchLengths() [2/2]

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

◆ getBranchProperty() [1/2]

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

Implements bpp::Tree.

Definition at line 212 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

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

◆ getBranchProperty() [2/2]

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

Implements bpp::Tree.

Definition at line 214 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getBranchPropertyNames()

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

Implements bpp::Tree.

Definition at line 218 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getDistanceToFather()

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

Implements bpp::Tree.

Definition at line 188 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

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

◆ getFatherId()

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

Implements bpp::Tree.

Definition at line 168 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getInnerNodes() [1/2]

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

◆ getInnerNodes() [2/2]

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

◆ getInnerNodesId()

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

◆ getLeafId()

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

Implements bpp::Tree.

Definition at line 135 of file TreeTemplate.h.

References bpp::TreeTemplateTools::getLeafId(), and bpp::TreeTemplate< N >::root_.

◆ getLeaves() [1/2]

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

◆ getLeaves() [2/2]

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

◆ getLeavesId()

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

Implements bpp::Tree.

Definition at line 137 of file TreeTemplate.h.

References bpp::TreeTemplateTools::getLeavesId(), and bpp::TreeTemplate< N >::root_.

◆ getLeavesNames()

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

◆ getName()

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

Methods:

Implements bpp::Tree.

Definition at line 123 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::name_.

◆ getNextId()

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

Get an id.

Returns
an unused node id.

Implements bpp::Tree.

Definition at line 369 of file TreeTemplate.h.

References bpp::TreeTools::getMPNUId(), and bpp::TreeTemplate< N >::root_.

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

◆ getNode() [1/4]

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

◆ getNode() [2/4]

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

Definition at line 454 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::root_.

◆ getNode() [3/4]

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

Definition at line 405 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::root_, bpp::TreeTemplateTools::searchFirstNodeWithId(), and bpp::TextTools::toString().

Referenced by bpp::LegacySubstitutionMappingTools::computeCountsPerSitePerBranchPerType(), bpp::LegacySubstitutionMappingTools::computeCountsPerSitePerType(), bpp::LegacySubstitutionMappingTools::computeCountsPerTypePerBranch(), bpp::TreeTemplate< N >::deleteDistanceToFather(), bpp::TreeTemplate< N >::deleteNodeName(), bpp::TreeTemplateTools::dropLeaf(), bpp::TreeTemplate< N >::getAncestorsId(), bpp::TreeTemplate< N >::getBranchProperty(), bpp::TreeTemplate< N >::getBranchPropertyNames(), bpp::TreeTemplate< N >::getDistanceToFather(), bpp::TreeTemplate< N >::getFatherId(), bpp::TreeTemplate< N >::getNodeName(), bpp::TreeTemplate< N >::getNodeProperty(), bpp::TreeTemplate< N >::getNodePropertyNames(), bpp::TreeTemplate< N >::getSonsId(), bpp::TreeTemplate< N >::hasBranchProperty(), bpp::TreeTemplate< N >::hasDistanceToFather(), bpp::TreeTemplate< N >::hasFather(), bpp::TreeTemplate< N >::hasNodeName(), bpp::TreeTemplate< N >::hasNodeProperty(), bpp::TreeTemplate< N >::hasNoSon(), bpp::TreeTemplate< N >::isLeaf(), bpp::TreeTemplate< N >::isRoot(), bpp::TreeTemplate< N >::newOutGroup(), bpp::TreeTemplate< N >::removeBranchProperty(), bpp::TreeTemplate< N >::removeNodeProperty(), bpp::TreeTemplate< N >::rootAt(), bpp::TreeTemplate< N >::setBranchProperty(), bpp::TreeTemplate< N >::setDistanceToFather(), bpp::TreeTemplate< N >::setNodeName(), and bpp::TreeTemplate< N >::setNodeProperty().

◆ getNode() [4/4]

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

◆ getNodeName()

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

Implements bpp::Tree.

Definition at line 172 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getNodeProperty() [1/2]

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

Implements bpp::Tree.

Definition at line 200 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getNodeProperty() [2/2]

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

Implements bpp::Tree.

Definition at line 202 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getNodePropertyNames()

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

Implements bpp::Tree.

Definition at line 206 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getNodes() [1/2]

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

◆ getNodes() [2/2]

◆ getNodesId()

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

Implements bpp::Tree.

Definition at line 139 of file TreeTemplate.h.

References bpp::TreeTemplateTools::getNodesId(), and bpp::TreeTemplate< N >::root_.

◆ getNumberOfBranches()

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

◆ getNumberOfLeaves()

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

◆ getNumberOfNodes()

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

◆ getRootId()

◆ getRootNode() [1/2]

◆ getRootNode() [2/2]

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

Definition at line 391 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::root_.

◆ getSonsId()

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

Implements bpp::Tree.

Definition at line 164 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ getTotalLength()

template<class N >
double bpp::TreeTemplate< N >::getTotalLength ( )
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 340 of file TreeTemplate.h.

References bpp::TreeTemplateTools::getTotalLength(), and bpp::TreeTemplate< N >::root_.

◆ hasBranchProperty()

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

Implements bpp::Tree.

Definition at line 208 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ hasDistanceToFather()

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

Implements bpp::Tree.

Definition at line 194 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

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

◆ hasFather()

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

Implements bpp::Tree.

Definition at line 170 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ hasNode()

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

Implements bpp::Tree.

Definition at line 180 of file TreeTemplate.h.

References bpp::TreeTemplateTools::hasNodeWithId(), and bpp::TreeTemplate< N >::root_.

◆ hasNodeName()

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

Implements bpp::Tree.

Definition at line 174 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ hasNodeProperty()

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

Implements bpp::Tree.

Definition at line 196 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ hasNoSon()

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

Implements bpp::Tree.

Definition at line 184 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ hasSameTopologyAs()

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 permitted. 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 302 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::clone(), bpp::TreeTemplate< N >::getRootNode(), bpp::TreeTemplateTools::haveSameOrderedTopology(), and bpp::TreeTemplateTools::orderTree().

◆ isLeaf()

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

Implements bpp::Tree.

Definition at line 182 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ isMultifurcating()

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 277 of file TreeTemplate.h.

References bpp::TreeTemplateTools::isMultifurcating(), and bpp::TreeTemplate< N >::root_.

◆ isRoot()

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

Implements bpp::Tree.

Definition at line 186 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode(), and bpp::TreeTemplateTools::isRoot().

◆ isRooted()

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

◆ newOutGroup() [1/2]

template<class N >
void bpp::TreeTemplate< N >::newOutGroup ( int  nodeId)
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 222 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode(), and bpp::TreeTemplate< N >::newOutGroup().

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

◆ newOutGroup() [2/2]

◆ operator=()

◆ removeBranchProperty()

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

Implements bpp::Tree.

Definition at line 216 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ removeNodeProperty()

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

Implements bpp::Tree.

Definition at line 204 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ resetNodesId()

template<class N >
void bpp::TreeTemplate< N >::resetNodesId ( )
inlinevirtual

Number nodes.

Implements bpp::Tree.

Definition at line 268 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNodes().

◆ rootAt() [1/2]

template<class N >
void bpp::TreeTemplate< N >::rootAt ( int  nodeId)
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 220 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode(), and bpp::TreeTemplate< N >::rootAt().

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

◆ rootAt() [2/2]

◆ scaleTree()

template<class N >
void bpp::TreeTemplate< N >::scaleTree ( double  factor)
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 361 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::root_, and bpp::TreeTemplateTools::scaleTree().

◆ setBranchLengths()

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 345 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::root_, and bpp::TreeTemplateTools::setBranchLengths().

◆ setBranchProperty()

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

Implements bpp::Tree.

Definition at line 210 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ setDistanceToFather()

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

Implements bpp::Tree.

Definition at line 190 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ setName()

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

Implements bpp::Tree.

Definition at line 125 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::name_.

◆ setNodeName()

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

Implements bpp::Tree.

Definition at line 176 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ setNodeProperty()

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

Implements bpp::Tree.

Definition at line 198 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::getNode().

◆ setRootNode()

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

◆ setVoidBranchLengths()

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 353 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::root_, and bpp::TreeTemplateTools::setVoidBranchLengths().

◆ swapNodes() [1/2]

void bpp::Tree::swapNodes ( const Tree tree,
int  nodeId,
size_t  i1 = 0,
size_t  i2 = 1 
)
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

◆ swapNodes() [2/2]

template<class N >
void bpp::TreeTemplate< N >::swapNodes ( int  parentId,
size_t  i1,
size_t  i2 
)
inline

Definition at line 374 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::root_, and bpp::TextTools::toString().

◆ unroot()

template<class N >
bool bpp::TreeTemplate< N >::unroot ( )
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 226 of file TreeTemplate.h.

References bpp::TreeTemplate< N >::isRooted(), bpp::TreeTemplate< N >::root_, and bpp::TreeTemplate< N >::setRootNode().

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

Member Data Documentation

◆ name_

template<class N >
std::string bpp::TreeTemplate< N >::name_
private

◆ root_


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