bpp-phyl3  3.0.0
LLG08_UL3.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 #include "../FrequencySet/ProteinFrequencySet.h"
8 #include "../MixtureOfSubstitutionModels.h"
9 #include "LLG08_UL3.h"
10 
11 using namespace bpp;
12 using namespace std;
13 
14 /******************************************************************************/
15 
17  shared_ptr<const ProteicAlphabet> alpha) :
18  AbstractParameterAliasable("LLG08_UL3."),
19  AbstractWrappedModel("LLG08_UL3."),
20  AbstractWrappedTransitionModel("LLG08_UL3."),
22  AbstractBiblioTransitionModel("LLG08_UL3."),
24 {
25  // build the submodel
26 
27  vector<unique_ptr<TransitionModelInterface>> vpSM;
28  vpSM.push_back(make_unique<LLG08_UL3::EmbeddedModel>(alpha, "Q1"));
29  vpSM.push_back(make_unique<LLG08_UL3::EmbeddedModel>(alpha, "Q2"));
30  vpSM.push_back(make_unique<LLG08_UL3::EmbeddedModel>(alpha, "Q3"));
31 
32  Vdouble vrate, vproba;
33 
34  for (auto& vi : vpSM)
35  {
36  vproba.push_back(dynamic_cast<LLG08_UL3::EmbeddedModel&>(*vi).getProportion());
37  vrate.push_back(vi->getRate());
38  }
39 
40  mixedModelPtr_.reset(new MixtureOfSubstitutionModels(alpha, vpSM, vproba, vrate));
41 
42  string name, st;
43  ParameterList pl = mixedModelPtr_->getParameters();
44  for (size_t i = 0; i < pl.size(); ++i)
45  {
46  name = pl[i].getName();
48  st = mixedModelPtr_->getParameterNameWithoutNamespace(name);
49  mapParNamesFromPmodel_[name] = st;
50  addParameter_(new Parameter("LLG08_UL3." + st,
51  mixedModelPtr_->getParameterValue(st),
52  mixedModelPtr_->parameter(st).hasConstraint() ? std::shared_ptr<ConstraintInterface>(mixedModelPtr_->parameter(st).getConstraint()->clone()) : 0));
53  }
54 
56 }
57 
58 
59 /**************** sub model classes ********************/
60 
62  shared_ptr<const ProteicAlphabet> alpha,
63  string name) :
65  AbstractReversibleProteinSubstitutionModel(alpha, make_shared<CanonicalStateMap>(alpha, false), name),
66  proportion_(1),
67  name_(name)
68 {
69 #include "__LLG08_UL3ExchangeabilityCode"
70 #include "__LLG08_UL3FrequenciesCode"
71 #include "__LLG08_UL3RatesProps"
73 }
Abstract class for mixture models based on the bibliography.
std::unique_ptr< MixedTransitionModelInterface > mixedModelPtr_
Partial implementation of the SubstitutionModel interface for models that are set for matching the bi...
std::map< std::string, std::string > mapParNamesFromPmodel_
Tools to make the link between the Parameters of the object and those of pmixmodel_.
void addParameter_(Parameter *parameter)
Specialisation abstract class for reversible protein substitution model.
virtual void updateMatrices_() override
Compute and diagonalize the matrix, and fill the eigenValues_, leftEigenVectors_ and rightEigenVecto...
Abstract class of Wrapping model class, where all methods are redirected from model().
This class implements a state map where all resolved states are modeled.
Definition: StateMap.h:168
EmbeddedModel(std::shared_ptr< const ProteicAlphabet > alpha, string name)
Definition: LLG08_UL3.cpp:61
double getProportion() const
Definition: LLG08_UL3.h:58
LLG08_UL3(std::shared_ptr< const ProteicAlphabet > alpha)
Build a UL3 model, with original equilibrium frequencies, probabilities and rates.
Definition: LLG08_UL3.cpp:16
size_t size() const
virtual void addParameter(const Parameter &param)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble