bpp-phyl3 3.0.0
AbstractCodonAARateSubstitutionModel.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
8
9using namespace bpp;
10
11using namespace std;
12
13/******************************************************************************/
14
15AbstractCodonAARateSubstitutionModel::AbstractCodonAARateSubstitutionModel(
16 std::shared_ptr<ProteinSubstitutionModelInterface> pmodel,
17 std::shared_ptr<const GeneticCode> pgencode,
18 const string& prefix,
19 bool paramSynRate) :
21 pAAmodel_(pmodel),
22 pgencode_(pgencode),
23 beta_(19),
24 gamma_(1),
25 stateMap_(new CanonicalStateMap(pgencode->getSourceAlphabet(), false))
26{
27 if (paramSynRate)
28 addParameter_(new Parameter(prefix + "gamma", 1, std::make_shared<IntervalConstraint>(NumConstants::SMALL(), 999, true, true)));
29
30 addParameter_(new Parameter(prefix + "beta", 1, Parameter::R_PLUS_STAR));
31
32 pAAmodel_->enableEigenDecomposition(false);
33
34 pAAmodel_->setNamespace(prefix + pAAmodel_->getNamespace());
35 addParameters_(pAAmodel_->getParameters());
36}
37
39{
40 pAAmodel_->matchParametersValues(parameters);
41
42 if (hasParameter("gamma"))
43 gamma_ = getParameterValue("gamma");
44
45 beta_ = getParameterValue("beta");
46}
47
49{
50 int si(stateMap_->getAlphabetStateAsInt(i)), sj(stateMap_->getAlphabetStateAsInt(j));
51
52 return pgencode_->areSynonymous(si, sj) ? gamma_ :
53 beta_* pAAmodel_->Qij(pAAmodel_->getModelStates(pgencode_->translate(si))[0],
54 pAAmodel_->getModelStates(pgencode_->translate(sj))[0]);
55}
void fireParameterChanged(const ParameterList &parameters) override
std::shared_ptr< ProteinSubstitutionModelInterface > pAAmodel_
double getCodonsMulRate(size_t i, size_t j) const override
Returns the multiplicative rate specific to two codons specified by their number. The respective gene...
std::shared_ptr< const StateMapInterface > stateMap_
void addParameters_(const ParameterList &parameters)
void addParameter_(Parameter *parameter)
bool hasParameter(const std::string &name) const override
double getParameterValue(const std::string &name) const override
This class implements a state map where all resolved states are modeled.
Definition: StateMap.h:168
static double SMALL()
static const std::shared_ptr< IntervalConstraint > R_PLUS_STAR
Defines the basic types of data flow nodes.