bpp-phyl3 3.0.0
KroneckerCodonDistanceFrequenciesSubstitutionModel.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
7using namespace bpp;
8
9using namespace std;
10
11/******************************************************************************/
12
13KroneckerCodonDistanceFrequenciesSubstitutionModel::KroneckerCodonDistanceFrequenciesSubstitutionModel(
14 std::shared_ptr<const GeneticCode> gCode,
15 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod,
16 std::unique_ptr<CodonFrequencySetInterface> pfreq,
17 std::shared_ptr<const AlphabetIndex2> pdist) :
18 AbstractParameterAliasable("KronCodonDistFreq."),
20 gCode->getSourceAlphabet(),
21 shared_ptr<const StateMapInterface>(new CanonicalStateMap(gCode->getSourceAlphabet(), false)),
22 "KronCodonDistFreq."),
23 AbstractKroneckerCodonSubstitutionModel(gCode, std::move(pmod), "KronCodonDistFreq."),
24 AbstractCodonDistanceSubstitutionModel(pdist, gCode, "KronCodonDistFreq."),
25 AbstractCodonFrequenciesSubstitutionModel(std::move(pfreq), "KronCodonDistFreq.")
26{
27 computeFrequencies(false);
29}
30
32 std::shared_ptr<const GeneticCode> gCode,
33 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod,
34 const std::vector<std::set<size_t>>& vPos,
35 std::unique_ptr<CodonFrequencySetInterface> pfreq,
36 std::shared_ptr<const AlphabetIndex2> pdist) :
37 AbstractParameterAliasable("KronCodonDistFreq."),
39 gCode->getSourceAlphabet(),
40 shared_ptr<const StateMapInterface>(new CanonicalStateMap(gCode->getSourceAlphabet(), false)),
41 "KronCodonDistFreq."),
42 AbstractKroneckerCodonSubstitutionModel(gCode, std::move(pmod), vPos, "KronCodonDistFreq."),
43 AbstractCodonDistanceSubstitutionModel(pdist, gCode, "KronCodonDistFreq."),
44 AbstractCodonFrequenciesSubstitutionModel(std::move(pfreq), "KronCodonDistFreq.")
45{
46 computeFrequencies(false);
48}
49
51 std::shared_ptr<const GeneticCode> gCode,
52 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod1,
53 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod2,
54 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod3,
55 std::unique_ptr<CodonFrequencySetInterface> pfreq,
56 std::shared_ptr<const AlphabetIndex2> pdist) :
57 AbstractParameterAliasable("KronCodonDistFreq."),
59 gCode->getSourceAlphabet(),
60 shared_ptr<const StateMapInterface>(new CanonicalStateMap(gCode->getSourceAlphabet(), false)),
61 "KronCodonDistFreq."),
62 AbstractKroneckerCodonSubstitutionModel(gCode, std::move(pmod1), std::move(pmod2), std::move(pmod3), "KronCodonDistFreq."),
63 AbstractCodonDistanceSubstitutionModel(pdist, gCode, "KronCodonDistFreq."),
64 AbstractCodonFrequenciesSubstitutionModel(std::move(pfreq), "KronCodonDistFreq.")
65{
66 computeFrequencies(false);
68}
69
71 std::shared_ptr<const GeneticCode> gCode,
72 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod1,
73 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod2,
74 std::unique_ptr<NucleotideSubstitutionModelInterface> pmod3,
75 const std::vector<std::set< size_t>>& vPos,
76 std::unique_ptr<CodonFrequencySetInterface> pfreq,
77 std::shared_ptr<const AlphabetIndex2> pdist) :
78 AbstractParameterAliasable("KronCodonDistFreq."),
80 gCode->getSourceAlphabet(),
81 shared_ptr<const StateMapInterface>(new CanonicalStateMap(gCode->getSourceAlphabet(), false)),
82 "KronCodonDistFreq."),
83 AbstractKroneckerCodonSubstitutionModel(gCode, std::move(pmod1), std::move(pmod2), std::move(pmod3), vPos, "KronCodonDistFreq."),
84 AbstractCodonDistanceSubstitutionModel(pdist, gCode, "KronCodonDistFreq."),
85 AbstractCodonFrequenciesSubstitutionModel(std::move(pfreq), "KronCodonDistFreq.")
86{
87 computeFrequencies(false);
89}
90
92{
93 return "KronCodonDistFreq";
94}
95
97{
100
101 // Beware: must be called last
103}
104
106{
110}
111
113{
118}
119
121{
123}
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 substitution models on codons parametrized by frequencies.
void setFreq(std::map< int, double > &frequencies) override
void fireParameterChanged(const ParameterList &parameters) override
double getCodonsMulRate(size_t, size_t) const override
Returns the multiplicative rate specific to two codons specified by their number. The respective gene...
Abstract class for substitution models on codons allowing multiple substitutions.
virtual double getCodonsMulRate(size_t i, size_t j) const override
Method inherited from CodonSubstitutionModel.
void setNamespace(const std::string &prefix)
virtual void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
void updateMatrices_()
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
This class implements a state map where all resolved states are modeled.
Definition: StateMap.h:168
KroneckerCodonDistanceFrequenciesSubstitutionModel(std::shared_ptr< const GeneticCode > gCode, std::unique_ptr< NucleotideSubstitutionModelInterface > pmod, std::unique_ptr< CodonFrequencySetInterface > pfreq, std::shared_ptr< const AlphabetIndex2 > pdist=nullptr)
Build a new KroneckerCodonDistanceFrequenciesSubstitutionModel object from three pointers to Abstract...
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...
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:25
Defines the basic types of data flow nodes.