18 name_(dag ? dag->name_ :
"")
28 std::vector<shared_ptr<PhyloNode>> nodes =
getAllNodes();
29 std::vector<shared_ptr<PhyloBranch>> branches =
getAllEdges();
31 for (
unsigned int i = 0; i < nodes.size(); i++)
44 for (
auto j = nodes.size(); j < branches.size(); j++)
58 if (it->hasName() && it->getName() == name)
62 return std::make_shared<PhyloNode>();
71 for (vector<shared_ptr<PhyloNode>>::const_iterator it = vpn.begin(); it != vpn.end(); it++)
73 vn.push_back((*it)->getName());
81 vector<shared_ptr<PhyloBranch>> branches =
getBelowEdges(node);
82 for (vector<shared_ptr<PhyloBranch>>::iterator currBranch = branches.begin(); currBranch != branches.end(); currBranch++)
84 if ((*currBranch)->hasLength())
85 (*currBranch)->setLength((*currBranch)->getLength() * factor);
102 if (std::find(leaves.begin(), leaves.end(), leaf->getName()) == leaves.end())
104 std::vector<shared_ptr<PhyloNode>> vfat({leaf});
106 std::vector<shared_ptr<PhyloNode>>::iterator vfatit;
108 for (vfatit = vfat.begin(); vfatit != vfat.end();)
113 vfat.insert(vfat.end(), vfat2.begin(), vfat2.end() );
123 vector<shared_ptr<PhyloBranch>> vpn =
getAllEdges();
135 vector<shared_ptr<PhyloBranch>> vpn =
getAllEdges();
139 vl.push_back(it->getLength());
147 vector<shared_ptr<PhyloBranch>> vpn =
getAllEdges();
155 if (!it->hasLength() || !phylodag.
getEdge(ei)->hasLength())
156 throw Exception(
"Phylodag::operator+= : no summing of branches without length.");
158 it->setLength(it->getLength() + phylodag.
getEdge(ei)->getLength());
166 vector<shared_ptr<PhyloBranch>> vpn =
getAllEdges();
174 if (!it->hasLength() || !phylodag.
getEdge(ei)->hasLength())
175 throw Exception(
"Phylodag::operator+= : no summing of branches without length.");
177 it->setLength(it->getLength() - phylodag.
getEdge(ei)->getLength());
185 vector<shared_ptr<PhyloBranch>> vpn =
getAllEdges();
193 if (!it->hasLength() || !phylodag.
getEdge(ei)->hasLength())
194 throw Exception(
"Phylodag::operator/= : no summing of branches without length.");
196 it->setLength(it->getLength() / phylodag.
getEdge(ei)->getLength());
204 vector<shared_ptr<PhyloBranch>> vpn =
getAllEdges();
212 if (!it->hasLength() || !phylodag.
getEdge(ei)->hasLength())
213 throw Exception(
"Phylodag::operator/= : no summing of branches without length.");
215 it->setLength(it->getLength() * phylodag.
getEdge(ei)->getLength());
std::vector< std::shared_ptr< N > > getFathers(const std::shared_ptr< N > node) const
bool hasFather(const std::shared_ptr< N > nodeObject) const
std::vector< std::shared_ptr< E > > getBelowEdges(const std::shared_ptr< N > localRoot)
bool isLeaf(const Nref node) const
virtual std::vector< std::shared_ptr< E > > getIncomingEdges(const std::shared_ptr< N > node) const=0
virtual std::vector< std::shared_ptr< N > > getAllLeaves() const=0
virtual std::vector< std::shared_ptr< E > > getAllEdges() const=0
virtual NodeIndex setNodeIndex(const std::shared_ptr< N > nodeObject, NodeIndex index)=0
virtual void deleteNode(std::shared_ptr< N > nodeObject)=0
virtual std::shared_ptr< N > getRoot() const=0
virtual EdgeIndex getEdgeIndex(const std::shared_ptr< E > edgeObject) const=0
virtual std::vector< std::shared_ptr< N > > getAllNodes() const=0
virtual EdgeIndex setEdgeIndex(const std::shared_ptr< E > edgeObject, EdgeIndex index)=0
virtual bool hasEdgeIndex(const std::shared_ptr< E > edgeObject) const=0
virtual bool hasNode(NodeIndex nodeIndex) const=0
virtual std::shared_ptr< E > getEdge(EdgeIndex edgeIndex) const=0
virtual bool hasEdge(EdgeIndex edgeIndex) const=0
General exception thrown when something is wrong with a particular branch.
void scaleDAG(double factor)
Multiply all branch lengths by a given factor.
std::vector< std::string > getAllLeavesNames() const
PhyloDAG & operator+=(const PhyloDAG &phylotree)
Add the lengths of branches of another phylotree to this one. Just branch ids are considered,...
PhyloDAG & operator-=(const PhyloDAG &phylotree)
Subtracts the lengths of branches of another phylotree to this one. Just branch ids are considered,...
Vdouble getBranchLengths() const
PhyloDAG & operator/=(const PhyloDAG &phylotree)
Divides the lengths of branches of this phylotree by the ones of another phylotree....
PhyloDAG & operator*=(const PhyloDAG &phylotree)
Multiplies the lengths of branches of this phylotree by the ones of another phylotree....
std::shared_ptr< PhyloNode > getPhyloNode(const std::string &name) const
void setBranchLengths(double l)
void pruneDAG(std::vector< std::string > leaves)
Prune a tree to a given set of leaf names.
std::string toString(T t)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble