bpp-phyl3  3.0.0
LLG08_EX2.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_EX2.h"
10 
11 using namespace bpp;
12 using namespace std;
13 
14 /******************************************************************************/
15 
16 LLG08_EX2::LLG08_EX2(shared_ptr<const ProteicAlphabet> alpha) :
17  AbstractParameterAliasable("LLG08_EX2."),
18  AbstractWrappedModel("LLG08_EX2."),
19  AbstractWrappedTransitionModel("LLG08_EX2."),
21  AbstractBiblioTransitionModel("LLG08_EX2."),
23 {
24  // build the submodel
25 
26  vector<unique_ptr<TransitionModelInterface>> vpSM;
27  vpSM.push_back(make_unique<LLG08_EX2::EmbeddedModel>(alpha, "Buried"));
28  vpSM.push_back(make_unique<LLG08_EX2::EmbeddedModel>(alpha, "Exposed"));
29 
30  Vdouble vrate, vproba;
31 
32  for (auto& vi : vpSM)
33  {
34  vproba.push_back(dynamic_cast<LLG08_EX2::EmbeddedModel&>(*vi).getProportion());
35  vrate.push_back(vi->getRate());
36  }
37 
38  mixedModelPtr_.reset(new MixtureOfSubstitutionModels(alpha, vpSM, vproba, vrate));
39 
40  string name, st;
41  ParameterList pl = mixedModelPtr_->getParameters();
42  for (size_t i = 0; i < pl.size(); ++i)
43  {
44  name = pl[i].getName();
46  st = mixedModelPtr_->getParameterNameWithoutNamespace(name);
47  mapParNamesFromPmodel_[name] = st;
48  addParameter_(new Parameter("LLG08_EX2." + st,
49  mixedModelPtr_->getParameterValue(st),
50  mixedModelPtr_->parameter(st).hasConstraint() ? std::shared_ptr<ConstraintInterface>(mixedModelPtr_->parameter(st).getConstraint()->clone()) : 0));
51  }
52 
54 }
55 
56 /**************** sub model classes *******************/
57 
59  shared_ptr<const ProteicAlphabet> alpha,
60  string name) :
62  AbstractReversibleProteinSubstitutionModel(alpha, make_shared<CanonicalStateMap>(alpha, false), name),
63  proportion_(1),
64  name_(name)
65 {
66 #include "__LLG08_EX2ExchangeabilityCode"
67 #include "__LLG08_EX2FrequenciesCode"
68 #include "__LLG08_EX2RatesProps"
70 }
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_EX2.cpp:58
double getProportion() const
Definition: LLG08_EX2.h:55
LLG08_EX2(std::shared_ptr< const ProteicAlphabet > alpha)
Build a EX2 model, with original equilibrium frequencies, probabilities and rates.
Definition: LLG08_EX2.cpp:16
size_t size() const
virtual void addParameter(const Parameter &param)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble