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