bpp-phyl3  3.0.0
SingleProcessSubstitutionMapping.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 
7 using namespace bpp;
8 using namespace std;
9 
11  std::shared_ptr<SingleProcessPhyloLikelihood> spp,
12  std::shared_ptr<SubstitutionRegisterInterface> reg,
13  std::shared_ptr<const AlphabetIndex2> weights,
14  std::shared_ptr<const AlphabetIndex2> distances,
15  double threshold,
16  bool verbose) :
17  AbstractSinglePhyloSubstitutionMapping(spp->tree()->getGraph(), reg, weights, distances),
18  pSPP_(spp)
19 {
21 
22  // assigns edge indexes
23  const auto tree = spp->tree();
24 
25  unique_ptr<modelTree::EdgeIterator> eIT = allEdgesIterator();
26 
27  for ( ; !eIT->end(); eIT->next())
28  {
29  auto edge1 = tree->getEdgeFromGraphid(getEdgeGraphid(**eIT));
30  if (tree->hasEdgeIndex(edge1))
31  setEdgeIndex(**eIT, tree->getEdgeIndex(edge1));
32  }
33 
34  // assigns node indexes
35  unique_ptr<modelTree::NodeIterator> nIT = allNodesIterator();
36 
37  for ( ; !nIT->end(); nIT->next())
38  {
39  auto node1 = tree->getNodeFromGraphid(getNodeGraphid(**nIT));
40  if (tree->hasNodeIndex(node1))
41  setNodeIndex(**nIT, tree->getNodeIndex(node1));
42  }
43 }
44 
45 
47  short unresolvedOption,
48  bool verbose)
49 {
50  matchParametersValues(nullParams);
51 
54  shared_from_this(),
56  getDistances(),
57  unresolvedOption,
58  verbose);
59 }
60 
62 {
63  const SubstitutionProcessInterface& sp = pSPP_->substitutionProcess();
64 
65  vector<size_t> vId = sp.getModelNumbers();
66 
67  for (auto id : vId)
68  {
69  addModel(id, dynamic_cast<const TransitionModelInterface&>(sp.model(id)), sp.getNodesWithModel(id));
70  }
71 }
The AbstractSinglePhyloSubstitutionMapping class: substitution mapping linked with a Single Process P...
bool matchParametersValues(const ParameterList &nullParams) override
Checks and sets the models with given parameters.
std::shared_ptr< const SubstitutionRegisterInterface > getSubstitutionRegister() const
std::shared_ptr< const AlphabetIndex2 > getDistances() const
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_
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
SingleProcessSubstitutionMapping(std::shared_ptr< SingleProcessPhyloLikelihood > spp, std::shared_ptr< SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights, std::shared_ptr< const AlphabetIndex2 > distances, double threshold=-1, bool verbose=true)
std::shared_ptr< SingleProcessPhyloLikelihood > pSPP_
LikelihoodCalculationSingleProcess & getLikelihoodCalculationSingleProcess()
void setBranchedModelSet_()
Set the models of the BranchedModelSet to the adhoc branches, for normalization.
void computeNormalizations(const ParameterList &nullParams, short unresolvedOption=SubstitutionMappingTools::UNRESOLVED_ZERO, bool verbose=true)
compute Normalizations
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 std::vector< size_t > getModelNumbers() const =0
virtual const BranchModelInterface & model(size_t i) const =0
Interface for all transition models.
Defines the basic types of data flow nodes.