bpp-phyl3 3.0.0
ProcessComputationTree.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
5#ifndef BPP_PHYL_LIKELIHOOD_PROCESSCOMPUTATIONTREE_H
6#define BPP_PHYL_LIKELIHOOD_PROCESSCOMPUTATIONTREE_H
7
8
9#include "../Tree/PhyloBranchParam.h"
10#include "../Tree/PhyloTree.h"
12#include "SubstitutionProcess.h"
13
14namespace bpp
15{
26// Node specific DataFlow objects
28 public PhyloNode
29{
33 const uint speciesIndex_;
34
35public:
41 ProcessComputationNode(const PhyloNode& node, uint speciesIndex) :
42 PhyloNode(node),
43 speciesIndex_(speciesIndex) {}
44
46 PhyloNode(node),
48
49 uint getSpeciesIndex() const
50 {
51 return speciesIndex_;
52 }
53
54 bool isSpeciation() const
55 {
56 auto prop = dynamic_cast<const NodeEvent*>(getProperty("event"));
57 if (!prop)
58 throw Exception("ProcessNode::isSpeciation : Node has no event associated: Node id " + TextTools::toString(getSpeciesIndex()));
59 return prop->isSpeciation();
60 }
61
62 bool isMixture() const
63 {
64 auto prop = dynamic_cast<const NodeEvent*>(getProperty("event"));
65 if (!prop)
66 throw Exception("ProcessNode::isMixture : Node has no event associated: Node id " + TextTools::toString(getSpeciesIndex()));
67 return prop->isMixture();
68 }
69};
70
71using ProcessComputationNodeRef = std::shared_ptr<ProcessComputationNode>;
72
73// Class for the edges: In case of mixture nodes, the probability is
74// set through submodel probability
76{
77private:
81 std::shared_ptr<const BranchModelInterface> model_;
82
86 uint nmodel_;
87
94 std::vector<uint> vSubNb_;
95
102
106 const uint speciesIndex_;
107
108public:
110 std::shared_ptr<const BranchModelInterface> model,
111 uint nmodel,
112 uint speciesIndex,
113 bool useProb = false,
114 const std::vector<uint>& vNb = Vuint(0)) :
115 model_(model),
116 nmodel_(nmodel),
117 vSubNb_(vNb),
119 speciesIndex_(speciesIndex)
120 {}
121
123 model_(edge.model_),
124 nmodel_(edge.nmodel_),
125 vSubNb_(edge.vSubNb_),
126 useProb_(edge.useProb_),
128 {}
129
130 std::shared_ptr<const BranchModelInterface> getModel() const
131 {
132 return model_;
133 }
134
135 uint getModelNumber() const
136 {
137 return nmodel_;
138 }
139
140 uint getSpeciesIndex() const
141 {
142 return speciesIndex_;
143 }
144
145 const std::vector<uint>& subModelNumbers() const
146 {
147 return vSubNb_;
148 }
149
150 bool useProb() const
151 {
152 return useProb_;
153 }
154};
155
157
159 public BaseTree
160{
161private:
162 std::shared_ptr<const SubstitutionProcessInterface> process_;
163
169 std::shared_ptr<ProcessComputationNode> father,
170 const ModelPath& path);
171
173 std::shared_ptr<ProcessComputationNode> father,
174 const ModelScenario& scenario,
175 std::map<std::shared_ptr<MixedTransitionModelInterface>,
176 uint>& mMrca);
177
178public:
184 ProcessComputationTree(std::shared_ptr<const SubstitutionProcessInterface> process);
185};
186} // end of namespace bpp.
187#endif // BPP_PHYL_LIKELIHOOD_PROCESSCOMPUTATIONTREE_H
Organization of submodels in mixed substitution models in a path. See class ModelScenario for a thoro...
Definition: ModelPath.h:22
Organization of submodels in mixed substitution models as paths.
Definition: ModelScenario.h:81
Clonable * getProperty(const std::string &name)
Definition: PhyloNode.h:189
std::vector< uint > vSubNb_
numbers of the submodels used, if any.
std::shared_ptr< const BranchModelInterface > model_
Model carried by the branch.
bool useProb_
use the probability associated to the edge in case of mixture. If true, the probability is used and n...
const uint speciesIndex_
the index of the species in the phyloTree matching this node.
ProcessComputationEdge(std::shared_ptr< const BranchModelInterface > model, uint nmodel, uint speciesIndex, bool useProb=false, const std::vector< uint > &vNb=Vuint(0))
std::shared_ptr< const BranchModelInterface > getModel() const
ProcessComputationEdge(const ProcessComputationEdge &edge)
uint nmodel_
Number of the model carried by the branch.
const std::vector< uint > & subModelNumbers() const
Tree Organization of Computing Nodes.
const uint speciesIndex_
the index of the species in the phyloTree matching this node.
ProcessComputationNode(const ProcessComputationNode &node)
ProcessComputationNode(const PhyloNode &node, uint speciesIndex)
Build from a node in the phylo tree, with a specific speciesIndex (because indexes are not the same a...
void buildFollowingScenario_(std::shared_ptr< ProcessComputationNode > father, const ModelScenario &scenario, std::map< std::shared_ptr< MixedTransitionModelInterface >, uint > &mMrca)
void buildFollowingPath_(std::shared_ptr< ProcessComputationNode > father, const ModelPath &path)
Build rest of the tree under given father (event on father will be set in this method)
std::shared_ptr< const SubstitutionProcessInterface > process_
ProcessComputationTree(std::shared_ptr< const SubstitutionProcessInterface > process)
construction of a ProcessComputationTree from a SubstitutionProcess
std::string toString(T t)
Defines the basic types of data flow nodes.
std::shared_ptr< ProcessComputationNode > ProcessComputationNodeRef
std::vector< unsigned int > Vuint