bpp-phyl3 3.0.0
AbstractCodonClusterAASubstitutionModel.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
15AbstractCodonClusterAASubstitutionModel::AbstractCodonClusterAASubstitutionModel(
16 std::shared_ptr<const GeneticCode> pgencode,
17 const string& prefix,
18 const vector<uint>& assign) :
20 pgencode_(pgencode),
21 omegaR_(1),
22 omegaC_(1),
23 assign_(assign),
24 stateMap_(new CanonicalStateMap(pgencode->getSourceAlphabet(), false))
25{
26 if (assign_.size() != 20)
27 throw BadSizeException("AbstractCodonClusterAASubstitutionModel::AbstractCodonClusterAASubstitutionModel: assign_", assign_.size(), 20);
28
29 addParameter_(new Parameter(prefix + "omegaR", 1, std::make_shared<IntervalConstraint>(NumConstants::SMALL(), 999, true, true)));
30 addParameter_(new Parameter(prefix + "omegaC", 1, std::make_shared<IntervalConstraint>(NumConstants::SMALL(), 999, true, true)));
31}
32
34{
35 omegaR_ = getParameterValue("omegaR");
36 omegaC_ = getParameterValue("omegaC");
37}
38
40{
41 int si(stateMap_->getAlphabetStateAsInt(i)), sj(stateMap_->getAlphabetStateAsInt(j));
42
43 return pgencode_->areSynonymous(si, sj) ? 1 :
44 (assign_[static_cast<size_t>(pgencode_->translate(si))] == assign_[static_cast<size_t>(pgencode_->translate(sj))] ? omegaC_ :
45 omegaR_);
46}
void fireParameterChanged(const ParameterList &parameters) override
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...
void addParameter_(Parameter *parameter)
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()
Defines the basic types of data flow nodes.