bpp-phyl3  3.0.0
DSO78.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_PROTEIN_DSO78_H
6 #define BPP_PHYL_MODEL_PROTEIN_DSO78_H
7 
8 
9 #include "../AbstractSubstitutionModel.h"
10 #include "../FrequencySet/ProteinFrequencySet.h"
12 
13 // From SeqLib:
15 
16 namespace bpp
17 {
31 class DSO78 :
33 {
34 private:
35  std::unique_ptr<ProteinFrequencySetInterface> freqSet_;
36 
37 public:
43  DSO78(std::shared_ptr<const ProteicAlphabet> alpha);
44 
53  DSO78(std::shared_ptr<const ProteicAlphabet> alpha,
54  std::unique_ptr<ProteinFrequencySetInterface> freqSet,
55  bool initFreqs = false);
56 
57  DSO78(const DSO78& model) :
60  freqSet_(model.freqSet_->clone())
61  {}
62 
63  DSO78& operator=(const DSO78& model)
64  {
67  freqSet_.reset(model.freqSet_->clone());
68  return *this;
69  }
70 
71  virtual ~DSO78() {}
72 
73  DSO78* clone() const override { return new DSO78(*this); }
74 
75 public:
76  std::string getName() const override
77  {
78  if (freqSet_->getNamespace().find("DSO78+F.") != std::string::npos)
79  return "DSO78+F";
80  else
81  return "DSO78";
82  }
83 
84  void fireParameterChanged(const ParameterList& parameters) override
85  {
86  freqSet_->matchParametersValues(parameters);
87  freq_ = freqSet_->getFrequencies();
89  }
90 
91  void setNamespace(const std::string& prefix) override
92  {
94  freqSet_->setNamespace(prefix + freqSet_->getName() + ".");
95  }
96 
98  {
99  freqSet_.reset(freqSet.clone());
101  addParameters_(freqSet_->getParameters());
102  }
103 
104  const FrequencySetInterface& frequencySet() const override
105  {
106  if (freqSet_)
107  return *freqSet_;
108  throw NullPointerException("DSO78::frequencySet(). No associated FrequencySet.");
109  }
110 
111  void setFreqFromData(const SequenceDataInterface& data, double pseudoCount = 0) override;
112 };
113 } // end of namespace bpp.
114 #endif // BPP_PHYL_MODEL_PROTEIN_DSO78_H
void addParameters_(const ParameterList &parameters)
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
void setNamespace(const std::string &prefix)
Specialisation abstract class for reversible protein substitution model.
AbstractSubstitutionModel & operator=(const AbstractSubstitutionModel &model)
virtual void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
Vdouble freq_
The vector of equilibrium frequencies.
The Dayhoff, Schwartz and Orcutt substitution model for proteins.
Definition: DSO78.h:33
std::string getName() const override
Get the name of the model.
Definition: DSO78.h:76
const FrequencySetInterface & frequencySet() const override
Definition: DSO78.h:104
std::unique_ptr< ProteinFrequencySetInterface > freqSet_
Definition: DSO78.h:35
void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
Definition: DSO78.h:84
void setFrequencySet(const ProteinFrequencySetInterface &freqSet)
Definition: DSO78.h:97
DSO78 & operator=(const DSO78 &model)
Definition: DSO78.h:63
DSO78(std::shared_ptr< const ProteicAlphabet > alpha)
Build a simple DSO78 model, with original equilibrium frequencies.
Definition: DSO78.cpp:18
void setNamespace(const std::string &prefix) override
Definition: DSO78.h:91
virtual ~DSO78()
Definition: DSO78.h:71
DSO78(const DSO78 &model)
Definition: DSO78.h:57
DSO78 * clone() const override
Definition: DSO78.h:73
void setFreqFromData(const SequenceDataInterface &data, double pseudoCount=0) override
Set equilibrium frequencies equal to the frequencies estimated from the data.
Definition: DSO78.cpp:50
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
Parametrize a set of state frequencies for proteins.
ProteinFrequencySetInterface * clone() const override=0
Defines the basic types of data flow nodes.