bpp-phyl3 3.0.0
LGL08_CAT.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 "LGL08_CAT.h"
10
11using namespace bpp;
12using namespace std;
13
14/******************************************************************************/
15
16LGL08_CAT::LGL08_CAT(
17 std::shared_ptr<const ProteicAlphabet> alpha,
18 unsigned int nbCat) :
19 AbstractParameterAliasable("LGL08_CAT."),
20 AbstractWrappedModel("LGL08_CAT."),
25{
26 // build the submodel
27
28 vector<unique_ptr<TransitionModelInterface>> vpSM;
29 for (unsigned int i = 1; i < nbCat + 1; ++i)
30 {
31 vpSM.push_back(make_unique<LGL08_CAT::EmbeddedModel>(alpha, "C" + TextTools::toString(i), nbCat));
32 }
33
34 Vdouble vrate, vproba;
35
36 for (auto& vi : vpSM)
37 {
38 vproba.push_back((dynamic_cast<LGL08_CAT::EmbeddedModel&>(*vi)).getProportion());
39 vrate.push_back(vi->getRate());
40 }
41
42 mixedModelPtr_.reset(new MixtureOfSubstitutionModels(alpha, vpSM, vproba, vrate));
43
44 string name, st;
45 ParameterList pl = mixedModelPtr_->getParameters();
46 for (unsigned int i = 0; i < pl.size(); ++i)
47 {
48 name = pl[i].getName();
50 st = mixedModelPtr_->getParameterNameWithoutNamespace(name);
51 mapParNamesFromPmodel_[name] = st;
52 addParameter_(new Parameter("LGL08_CAT." + st,
53 mixedModelPtr_->getParameterValue(st),
54 mixedModelPtr_->parameter(st).hasConstraint() ? shared_ptr<ConstraintInterface>(mixedModelPtr_->parameter(st).getConstraint()->clone()) : 0));
55 }
56
58}
59
60/**************** sub model classes */ // ////////
61
63 std::shared_ptr<const ProteicAlphabet> alpha,
64 string name,
65 unsigned int nbCat) :
67 AbstractReversibleProteinSubstitutionModel(alpha, make_shared<CanonicalStateMap>(alpha, false), name),
68 proportion_(1),
69 name_(name)
70{
71 // Exchangeabilities:
72 for (unsigned int i = 0; i < 20; ++i)
73 {
74 for (unsigned int j = 0; j < 20; ++j)
75 {
76 if (i == j)
77 exchangeability_(i, i) = -19.;
78 else
79 exchangeability_(i, j) = 1.;
80 }
81 }
82
83 // Equilibrium frequencies, rates and proportions:
84 if (nbCat == 10)
85 {
86#include "__CATC10FrequenciesCode"
87#include "__CATC10RatesProps"
88 }
89 else if (nbCat == 20)
90 {
91#include "__CATC20FrequenciesCode"
92#include "__CATC20RatesProps"
93 }
94 else if (nbCat == 30)
95 {
96#include "__CATC30FrequenciesCode"
97#include "__CATC30RatesProps"
98 }
99 else if (nbCat == 40)
100 {
101#include "__CATC40FrequenciesCode"
102#include "__CATC40RatesProps"
103 }
104 else if (nbCat == 50)
105 {
106#include "__CATC50FrequenciesCode"
107#include "__CATC50RatesProps"
108 }
109 else if (nbCat == 60)
110 {
111#include "__CATC60FrequenciesCode"
112#include "__CATC60RatesProps"
113 }
114 else
115 throw Exception("LGL08_CAT.cpp: incorrect number of profiles. This number has to be 10, 20, 30, 40, 50 or 60.");
116
118}
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...
RowMatrix< double > exchangeability_
The exchangeability matrix of the model, defined as . When the model is reversible,...
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, std::string name, unsigned int nbCat=10)
Definition: LGL08_CAT.cpp:62
size_t size() const
virtual void addParameter(const Parameter &param)
std::string toString(T t)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble