5#ifndef BPP_PHYL_TREE_NODE_H
6#define BPP_PHYL_TREE_NODE_H
99 Node(
const std::string& name) :
101 name_(new std::string(name)),
112 Node(
int id,
const std::string& name) :
114 name_(new std::string(name)),
181 std::vector<int> sonsId(
sons_.size());
182 for (
size_t i = 0; i <
sons_.size(); i++)
184 sonsId[i] =
sons_[i]->getId();
217 name_ =
new std::string(name);
253 throw NodePException(
"Node::getDistanceToFather: Node has no distance.",
this);
327 if (find(node->
sons_.begin(), node->
sons_.end(),
this) == node->
sons_.end())
328 node->
sons_.push_back(
this);
330 std::cerr <<
"DEVEL warning: Node::setFather. Son node already registered! No pb here, but could be a bug in your implementation..." << std::endl;
391 sons_.insert(
sons_.begin() +
static_cast<ptrdiff_t
>(pos), node);
393 std::cerr <<
"DEVEL warning: Node::addSon. Son node already registered! No pb here, but could be a bug in your implementation..." << std::endl;
403 sons_.push_back(node);
405 throw NodePException(
"Node::addSon. Trying to add a node which is already present.");
413 if (pos >=
sons_.size())
415 std::vector<Node*>::iterator search = find(
sons_.begin(),
sons_.end(), node);
416 if (search ==
sons_.end() || search ==
sons_.begin() +
static_cast<ptrdiff_t
>(pos))
419 throw NodePException(
"Node::setSon. Trying to set a node which is already present.");
425 if (pos >=
sons_.size())
428 sons_.erase(
sons_.begin() +
static_cast<ptrdiff_t
>(pos));
437 for (
size_t i = 0; i <
sons_.size(); i++)
439 if (
sons_[i] == node)
441 sons_.erase(
sons_.begin() +
static_cast<ptrdiff_t
>(i));
451 while (
sons_.size() != 0)
455 virtual void swap(
size_t branch1,
size_t branch2);
Exception thrown when something is wrong with a particular node.
General exception thrown when something is wrong with a particular node.
The phylogenetic node class.
Node(int id)
Build a new Node with specified id.
virtual void deleteNodeProperties()
Delete all node properties.
virtual void setSon(size_t pos, Node *node)
virtual void deleteName()
Delete the name associated to this node (do nothing if there is no name).
virtual std::string getName() const
Get the name associated to this node, if there is one, otherwise throw a NodeException.
Node(const std::string &name)
Build a new Node with specified name.
virtual Node * removeFather()
Remove the father of this node.
virtual void setDistanceToFather(double distance)
Set or update the distance toward the father node.
virtual void deleteDistanceToFather()
Delete the distance to the father node.
virtual Node * removeSon(size_t pos)
virtual int getId() const
Get the node's id.
virtual bool hasBranchProperty(const std::string &name) const
virtual void setId(int id)
Set this node's id.
std::map< std::string, Clonable * > branchProperties_
virtual Clonable * getNodeProperty(const std::string &name)
virtual Node * getFather()
Get the father of this node is there is one.
virtual Clonable * getBranchProperty(const std::string &name)
virtual void addSon(size_t pos, Node *node)
virtual std::vector< std::string > getNodePropertyNames() const
Node(int id, const std::string &name)
Build a new Node with specified id and name.
virtual const Node & son(size_t pos) const
Node & operator=(const Node &node)
Assignation operator.
virtual bool hasBootstrapValue() const
virtual void setBranchProperty(const std::string &name, const Clonable &property)
Set/add a branch property.
virtual bool hasDistanceToFather() const
Tell is this node has a distance to the father.
Node()
Build a new void Node object.
std::vector< Node * > sons_
virtual void setNodeProperty(const std::string &name, const Clonable &property)
Set/add a node property.
const Node * operator[](int i) const
virtual void removeSons()
virtual bool hasNoSon() const
virtual std::vector< int > getSonsId() const
virtual void removeSon(Node *node)
virtual const Node * getFather() const
Get the father of this node is there is one.
virtual const Node * getSon(size_t pos) const
virtual bool isLeaf() const
virtual std::vector< Node * > & getSons()
virtual size_t getSonPosition(const Node *son) const
virtual const Clonable * getBranchProperty(const std::string &name) const
virtual Clonable * removeNodeProperty(const std::string &name)
virtual void deleteNodeProperty(const std::string &name)
void addSubTree(const PhyloTree &tree, std::shared_ptr< PhyloNode > phyloNode)
virtual bool operator==(const Node &node) const
virtual Node & son(size_t pos)
std::vector< const Node * > getNeighbors() const
virtual void swap(size_t branch1, size_t branch2)
virtual void removeNodeProperties()
Remove all node properties.
virtual void deleteBranchProperty(const std::string &name)
virtual bool hasFather() const
Tell if this node has a father node.
virtual void setName(const std::string &name)
Give a name or update the name associated to the node.
virtual const Clonable * getNodeProperty(const std::string &name) const
double * distanceToFather_
virtual Node * getSon(size_t pos)
virtual double getBootstrapValue() const
virtual void deleteBranchProperties()
Delete all branch properties.
virtual void addSon(Node *node)
virtual bool hasName() const
Tell is this node has a name.
virtual void setFather(Node *node)
Set the father node of this node.
virtual bool hasNodeProperty(const std::string &name) const
std::map< std::string, Clonable * > nodeProperties_
virtual Clonable * removeBranchProperty(const std::string &name)
virtual double getDistanceToFather() const
Get the distance to the father node is there is one, otherwise throw a NodeException.
virtual void removeBranchProperties()
Remove all branch properties.
virtual int getFatherId() const
virtual size_t getNumberOfSons() const
virtual size_t degree() const
virtual std::vector< std::string > getBranchPropertyNames() const
General exception thrown if a property could not be found.
Defines the basic types of data flow nodes.