bpp-phyl3  3.0.0
WAG01.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_WAG01_H
6 #define BPP_PHYL_MODEL_PROTEIN_WAG01_H
7 
8 
9 #include "../AbstractSubstitutionModel.h"
10 #include "../FrequencySet/ProteinFrequencySet.h"
12 
13 // From SeqLib:
15 
16 namespace bpp
17 {
34 class WAG01 :
36 {
37 private:
38  std::unique_ptr<ProteinFrequencySetInterface> freqSet_;
39 
40 public:
46  WAG01(std::shared_ptr<const ProteicAlphabet> alpha);
47 
56  WAG01(
57  std::shared_ptr<const ProteicAlphabet> alpha,
58  std::unique_ptr<ProteinFrequencySetInterface> freqSet,
59  bool initFreqs = false);
60 
61  WAG01(const WAG01& model) :
64  freqSet_(model.freqSet_->clone())
65  {}
66 
67  WAG01& operator=(const WAG01& model)
68  {
71  freqSet_.reset(model.freqSet_->clone());
72  return *this;
73  }
74 
75  virtual ~WAG01() {}
76 
77  WAG01* clone() const override { return new WAG01(*this); }
78 
79 public:
80  std::string getName() const override
81  {
82  if (freqSet_->getNamespace().find("WAG01+F.") != std::string::npos)
83  return "WAG01+F";
84  else
85  return "WAG01";
86  }
87 
88  void fireParameterChanged(const ParameterList& parameters) override
89  {
90  freqSet_->matchParametersValues(parameters);
91  freq_ = freqSet_->getFrequencies();
93  }
94 
95  void setNamespace(const std::string& prefix) override
96  {
98  freqSet_->setNamespace(prefix + freqSet_->getName() + ".");
99  }
100 
102  {
103  freqSet_.reset(freqSet.clone());
105  addParameters_(freqSet_->getParameters());
106  }
107 
108  const FrequencySetInterface& frequencySet() const override
109  {
110  if (freqSet_)
111  return *freqSet_;
112  throw NullPointerException("WAG01::frequencySet(). No associated FrequencySet.");
113  }
114 
115  void setFreqFromData(const SequenceDataInterface& data, double pseudoCount = 0) override;
116 };
117 } // end of namespace bpp.
118 #endif // BPP_PHYL_MODEL_PROTEIN_WAG01_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.
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
Parametrize a set of state frequencies for proteins.
ProteinFrequencySetInterface * clone() const override=0
The Whelan and Goldman substitution model for proteins.
Definition: WAG01.h:36
void setFreqFromData(const SequenceDataInterface &data, double pseudoCount=0) override
Set equilibrium frequencies equal to the frequencies estimated from the data.
Definition: WAG01.cpp:47
std::unique_ptr< ProteinFrequencySetInterface > freqSet_
Definition: WAG01.h:38
void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
Definition: WAG01.h:88
virtual ~WAG01()
Definition: WAG01.h:75
void setFrequencySet(const ProteinFrequencySetInterface &freqSet)
Definition: WAG01.h:101
void setNamespace(const std::string &prefix) override
Definition: WAG01.h:95
WAG01(std::shared_ptr< const ProteicAlphabet > alpha)
Build a simple WAG01 model, with original equilibrium frequencies.
Definition: WAG01.cpp:15
WAG01(const WAG01 &model)
Definition: WAG01.h:61
const FrequencySetInterface & frequencySet() const override
Definition: WAG01.h:108
WAG01 * clone() const override
Definition: WAG01.h:77
WAG01 & operator=(const WAG01 &model)
Definition: WAG01.h:67
std::string getName() const override
Get the name of the model.
Definition: WAG01.h:80
Defines the basic types of data flow nodes.