bpp-phyl3 3.0.0
OneProcessSequenceSubstitutionMapping.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
6
7using namespace bpp;
8using namespace std;
9
10OneProcessSequenceSubstitutionMapping::OneProcessSequenceSubstitutionMapping(
11 std::shared_ptr<OneProcessSequencePhyloLikelihood> spp,
12 std::shared_ptr<SubstitutionRegisterInterface> reg,
13 std::shared_ptr<const AlphabetIndex2> weights,
14 std::shared_ptr<const AlphabetIndex2> distances) :
16 spp->substitutionProcess().parametrizablePhyloTree().getGraph(),
17 reg,
18 weights,
19 distances),
20 pOPSP_(spp)
21{
23
24 // assigns edge indexes
25 const auto tree = spp->tree();
26
27 unique_ptr<modelTree::EdgeIterator> eIT = allEdgesIterator();
28
29 for ( ; !eIT->end(); eIT->next())
30 {
31 auto edge1 = tree->getEdgeFromGraphid(getEdgeGraphid(**eIT));
32 if (tree->hasEdgeIndex(edge1))
33 setEdgeIndex(**eIT, tree->getEdgeIndex(edge1));
34 }
35
36 // assigns node indexes
37 unique_ptr<modelTree::NodeIterator> nIT = allNodesIterator();
38
39 for ( ; !nIT->end(); nIT->next())
40 {
41 auto node1 = tree->getNodeFromGraphid(getNodeGraphid(**nIT));
42 if (tree->hasNodeIndex(node1))
43 setNodeIndex(**nIT, tree->getNodeIndex(node1));
44 }
45}
46
48 const ParameterList& nullParams,
49 short unresolvedOption,
50 bool verbose)
51{
52 matchParametersValues(nullParams);
53
56 shared_from_this(),
59 unresolvedOption,
60 verbose);
61}
62
64{
65 const SubstitutionProcessInterface& sp = pOPSP_->substitutionProcess();
66
67 vector<size_t> vId = sp.getModelNumbers();
68
69 for (auto id : vId)
70 {
71 addModel(id, dynamic_cast<const TransitionModelInterface&>(sp.model(id)), sp.getNodesWithModel(id));
72 }
73}
The AbstractSinglePhyloSubstitutionMapping class: substitution mapping linked with a Single Process P...
std::shared_ptr< const SubstitutionRegisterInterface > getSubstitutionRegister() const
bool matchParametersValues(const ParameterList &nullParams) override
Checks and sets the models with given parameters.
void addModel(size_t index, const TransitionModelInterface &model, Vuint brIds)
add a Substitution Model in the map, and on all branches with given Ids.
std::unique_ptr< ProbabilisticSubstitutionMapping > factors_
std::shared_ptr< const AlphabetIndex2 > getDistances() const
virtual std::unique_ptr< EdgeIterator > allEdgesIterator()=0
virtual NodeGraphid getNodeGraphid(const std::shared_ptr< N > nodeObject) const=0
virtual NodeIndex setNodeIndex(const std::shared_ptr< N > nodeObject, NodeIndex index)=0
virtual EdgeGraphid getEdgeGraphid(const std::shared_ptr< E > edgeObject) const=0
virtual EdgeIndex setEdgeIndex(const std::shared_ptr< E > edgeObject, EdgeIndex index)=0
virtual std::unique_ptr< NodeIterator > allNodesIterator()=0
void setBranchedModelSet_()
Set the models of the BranchedModelSet to the adhoc branches, for normalization.
LikelihoodCalculationSingleProcess & getLikelihoodCalculationSingleProcess()
void computeNormalizations(const ParameterList &nullParams, short unresolvedOption=SubstitutionMappingTools::UNRESOLVED_ZERO, bool verbose=true) override
compute Normalizations
std::shared_ptr< OneProcessSequencePhyloLikelihood > pOPSP_
static std::unique_ptr< ProbabilisticSubstitutionMapping > computeNormalizations(LikelihoodCalculationSingleProcess &rltc, const std::vector< uint > &edgeIds, std::shared_ptr< const BranchedModelSet > nullModels, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > distances=0, short unresolvedOption=UNRESOLVED_ZERO, bool verbose=true)
Compute the normalizations tree due to the models of "null" process on each branch,...
This interface describes the substitution process along the tree and sites of the alignment.
virtual const std::vector< unsigned int > getNodesWithModel(size_t i) const =0
Get a list of nodes id for which the given model is associated.
virtual const BranchModelInterface & model(size_t i) const =0
virtual std::vector< size_t > getModelNumbers() const =0
Interface for all transition models.
Defines the basic types of data flow nodes.