bpp-phyl3 3.0.0
SENCA.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
5#include "SENCA.h"
6
7using namespace bpp;
8using namespace std;
9
10SENCA::SENCA(
11 std::shared_ptr<const GeneticCode> gCode,
12 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod,
13 std::unique_ptr<FrequencySetInterface> pfit,
14 std::shared_ptr<const AlphabetIndex2> pdist) :
16 AbstractCodonSubstitutionModel(gCode, std::move(pmod), "SENCA."),
17 AbstractCodonDistanceSubstitutionModel(pdist, gCode, "SENCA."),
18 AbstractCodonFitnessSubstitutionModel(std::move(pfit), gCode, "SENCA.")
19{
22}
23
25 std::shared_ptr<const GeneticCode> gCode,
26 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod1,
27 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod2,
28 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod3,
29 std::unique_ptr<FrequencySetInterface> pfit,
30 std::shared_ptr<const AlphabetIndex2> pdist) :
32 AbstractCodonSubstitutionModel(gCode, std::move(pmod1), std::move(pmod2), std::move(pmod3), "SENCA."),
33 AbstractCodonDistanceSubstitutionModel(pdist, gCode, "SENCA."),
34 AbstractCodonFitnessSubstitutionModel(std::move(pfit), gCode, "SENCA.")
35{
38}
39
41{
44
46}
47
48double SENCA::getCodonsMulRate(size_t i, size_t j) const
49{
52}
53
54void SENCA::setNamespace(const std::string& st)
55{
60}
61
62void SENCA::setFreq(map<int, double>& frequencies)
63{
66 auto alphabet = getAlphabet();
67
68 map<int, double> freq2;
69 double s = 0;
70
71 for (auto& it : frequencies)
72 {
73 freq2[it.first] = (freq1[alphabet->getStateIndex(it.first) - 1] != 0 ? it.second / freq1[alphabet->getStateIndex(it.first) - 1] : 0);
74 s += freq2[it.first];
75 }
76
77 for (auto& it : freq2)
78 {
79 freq2[it.first] /= s;
80 }
81
83
85}
Abstract class for modelling of non-synonymous and synonymous substitution rates in codon models.
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 fireParameterChanged(const ParameterList &parameters) override
Abstract class for modelling of ratios of substitution rates between codons, whatever they are synony...
void setFreq(std::map< int, double > &frequencies) override
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...
Abstract class for substitution models on codons.
void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
void setNamespace(const std::string &prefix) override
void setNamespace(const std::string &prefix)
virtual void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
const Vdouble & getFrequencies() const override
virtual void setFreq(std::map< int, double > &freqs) override
Set equilibrium frequencies.
virtual size_t getStateIndex(int state) const=0
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
virtual const Alphabet & alphabet() const =0
void setNamespace(const std::string &) override
Definition: SENCA.cpp:54
void setFreq(std::map< int, double > &frequencies) override
set the fitness of the model from given frequencies, such that the equilibrium frequencies of the mod...
Definition: SENCA.cpp:62
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...
Definition: SENCA.cpp:48
SENCA(std::shared_ptr< const GeneticCode > gCode, std::unique_ptr< NucleotideSubstitutionModelInterface > pmod, std::unique_ptr< FrequencySetInterface > pfit, std::shared_ptr< const AlphabetIndex2 > pdist=nullptr)
Definition: SENCA.cpp:10
void fireParameterChanged(const ParameterList &parameterlist) override
Definition: SENCA.cpp:40
virtual bool computeFrequencies() const =0
Defines the basic types of data flow nodes.
std::vector< double > Vdouble