13 std::unique_ptr<ProteinSubstitutionModelInterface> pAAmodel,
14 std::unique_ptr<CodonSubstitutionModelInterface> pCodonModel,
15 std::unique_ptr<CodonFrequencySetInterface> pFreq,
16 std::shared_ptr<const GeneticCode> pgencode) :
19 pAAmodel_(std::move(pAAmodel)),
20 pCodonModel_(std::move(pCodonModel)),
21 pFreq_(std::move(pFreq)),
27 pAAmodel_->enableEigenDecomposition(
true);
34 pFreq_->setNamespace(
"SameAARate." +
pFreq_->getNamespace());
49 pAAmodel_->matchParametersValues(parameters);
53 pFreq_->matchParametersValues(parameters);
65 std::fill(
phi_.begin(),
phi_.end(), 0);
67 for (
size_t i = 0; i <
stateMap_->getNumberOfModelStates(); i++)
74 for (
size_t ai = 0; ai < 20; ai++)
79 for (
size_t i = 0; i <
stateMap_->getNumberOfModelStates(); i++)
87 for (
size_t j = 0; j <
stateMap_->getNumberOfModelStates(); j++)
92 X_i[aj] += gen(i, j) *
freq[i];
96 for (
size_t ai = 0; ai < 20; ai++)
99 for (
size_t aj = 0; aj < 20; aj++)
102 X_i[aj] =
phi_[ai] *
pAAmodel_->generator()(ai, aj) / X_i[aj];
107 for (
size_t i = 0; i <
stateMap_->getNumberOfModelStates(); i++)
113 const auto& X_i =
X_.
row(ai);
115 for (
size_t j = 0; j <
stateMap_->getNumberOfModelStates(); j++)
void addParameters_(const ParameterList ¶meters)
RowMatrix< double > generator_
The generator matrix of the model.
void setDiagonal()
set the diagonal of the generator such that sum on each line equals 0.
virtual void updateMatrices_()
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
std::shared_ptr< const StateMapInterface > stateMap_
The map of model states with alphabet states.
virtual double freq(size_t i) const override
CodonSameAARateSubstitutionModel(std::unique_ptr< ProteinSubstitutionModelInterface > pAAmodel, std::unique_ptr< CodonSubstitutionModelInterface > pCodonModel, std::unique_ptr< CodonFrequencySetInterface > pFreq, std::shared_ptr< const GeneticCode > pgencode)
Build a new CodonSameAARateSubstitutionModel object from a pointer to NucleotideSubstitutionModel.
std::unique_ptr< CodonFrequencySetInterface > pFreq_
Protein Model which will be used to get similar AA rates. Its possible parameters are not copied in t...
std::unique_ptr< CodonSubstitutionModelInterface > pCodonModel_
Codon Model which will be copied. Its possible parameters are not copied in this object.
std::shared_ptr< const GeneticCode > pgencode_
RowMatrix< double > X_
20 x 20 Matrix of the denominator of the multiplicators
std::unique_ptr< ProteinSubstitutionModelInterface > pAAmodel_
Protein Model which will be used to get similar AA rates.
Vdouble phi_
20 Vdouble for computation
void fireParameterChanged(const ParameterList ¶meters) override
Tells the model that a parameter value has changed.
Interface for codon models.
virtual const CodonFrequencySetInterface & codonFrequencySet() const =0
const std::vector< double > & getRow(size_t i) const
std::vector< double > row(size_t i) const
Defines the basic types of data flow nodes.