bpp-phyl3  3.0.0
AbstractCodonFitnessSubstitutionModel.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_PHYL_MODEL_CODON_ABSTRACTCODONFITNESSSUBSTITUTIONMODEL_H
6 #define BPP_PHYL_MODEL_CODON_ABSTRACTCODONFITNESSSUBSTITUTIONMODEL_H
7 
8 
9 # ifndef _ABSTRACTCODONFITNESSSUBSTITUTIONMODEL_H_
10 # define _ABSTRACTCODONFITNESSSUBSTITUTIONMODEL_H_
11 
12 # include "CodonSubstitutionModel.h"
13 #include "../FrequencySet/CodonFrequencySet.h"
14 namespace bpp
15 {
35  public virtual AbstractParameterAliasable
36 {
37 private:
38  std::unique_ptr<FrequencySetInterface> pfitset_;
39 
40  std::shared_ptr<const GeneticCode> pgencode_;
41 
42  std::string fitName_;
43 
44 public:
46  std::unique_ptr<FrequencySetInterface> pfitset,
47  std::shared_ptr<const GeneticCode> pgencode,
48  const std::string& prefix);
49 
52  pfitset_(model.pfitset_->clone()),
53  pgencode_(model.pgencode_),
54  fitName_(model.fitName_)
55  {}
56 
58  {
60  pfitset_.reset(model.pfitset_->clone());
61  pgencode_ = model.pgencode_;
62  fitName_ = model.fitName_;
63  return *this;
64  }
65 
67  {
68  return new AbstractCodonFitnessSubstitutionModel(*this);
69  }
70 
72 
73 public:
74  void fireParameterChanged (const ParameterList& parameters) override;
75 
76  void setFreq(std::map<int, double>& frequencies) override;
77 
78  // const FrequencySet& getFreq() const { return *pfitset_; }
79 
80  void setNamespace (const std::string& prefix) override
81  {
83  pfitset_->setNamespace(prefix + fitName_);
84  }
85 
86  double getCodonsMulRate(size_t i, size_t j) const override;
87 
88  const FrequencySetInterface& fitness() const { return *pfitset_; }
89 
90  // TODO (jdutheil 30/12/22) not allowed if fully encapsulated.
91  // std::shared_ptr<const FrequencySetInterface> getFitness() const { return pfitset_; }
92 
94  {
95  throw NullPointerException("AbstractCodonFitnessSubstitutionModel::frequencySet. No associated FrequencySet.");
96  }
97 
98  bool hasCodonFrequencySet() const override
99  {
100  return false;
101  }
102 };
103 } // end of namespace bpp
104 # endif
105 #endif // BPP_PHYL_MODEL_CODON_ABSTRACTCODONFITNESSSUBSTITUTIONMODEL_H
Abstract class for modelling of ratios of substitution rates between codons, whatever they are synony...
AbstractCodonFitnessSubstitutionModel * clone() const override
AbstractCodonFitnessSubstitutionModel(const AbstractCodonFitnessSubstitutionModel &model)
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...
AbstractCodonFitnessSubstitutionModel & operator=(const AbstractCodonFitnessSubstitutionModel &model)
const CodonFrequencySetInterface & codonFrequencySet() const override
AbstractCodonFitnessSubstitutionModel(std::unique_ptr< FrequencySetInterface > pfitset, std::shared_ptr< const GeneticCode > pgencode, const std::string &prefix)
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
void setNamespace(const std::string &prefix)
Parametrize a set of state frequencies for codons.
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
Defines the basic types of data flow nodes.