bpp-phyl3  3.0.0
UserProteinSubstitutionModel.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_USERPROTEINSUBSTITUTIONMODEL_H
6 #define BPP_PHYL_MODEL_PROTEIN_USERPROTEINSUBSTITUTIONMODEL_H
7 
8 
9 #include "../AbstractSubstitutionModel.h"
10 #include "../FrequencySet/ProteinFrequencySet.h"
12 
13 // From SeqLib:
15 
16 // From the STL:
17 #include <string>
18 
19 namespace bpp
20 {
31 {
32 private:
33  std::string path_;
34  std::unique_ptr<ProteinFrequencySetInterface> freqSet_;
35 
36 public:
45  std::shared_ptr<const ProteicAlphabet> alpha,
46  const std::string& path,
47  const std::string& prefix);
48 
60  std::shared_ptr<const ProteicAlphabet> alpha,
61  const std::string& path,
62  std::unique_ptr<ProteinFrequencySetInterface> freqSet,
63  const std::string& prefix,
64  bool initFreqs = false
65  );
66 
70  path_(model.path_),
71  freqSet_(model.freqSet_->clone())
72  {}
73 
75  {
78  path_ = model.path_;
79  freqSet_.reset(model.freqSet_->clone());
80  return *this;
81  }
82 
84 
85  UserProteinSubstitutionModel* clone() const override { return new UserProteinSubstitutionModel(*this); }
86 
87 public:
88  std::string getName() const override;
89 
90  const std::string& getPath() const { return path_; }
91 
92  void fireParameterChanged(const ParameterList& parameters) override
93  {
94  freqSet_->matchParametersValues(parameters);
95  freq_ = freqSet_->getFrequencies();
97  }
98 
99  void setNamespace(const std::string& prefix) override
100  {
102  freqSet_->setNamespace(prefix + freqSet_->getName() + ".");
103  }
104 
106  {
107  freqSet_.reset(freqSet.clone());
109  addParameters_(freqSet_->getParameters());
110  }
111 
112  const FrequencySetInterface& frequencySet() const override
113  {
114  if (freqSet_)
115  return *freqSet_;
116  throw NullPointerException("UserProteinSubstitutionModel::frequencySet(). No associated FrequencySet.");
117  }
118 
119  void setFreqFromData(const SequenceDataInterface& data, double pseudoCount = 0) override;
120 
121 protected:
122  void readFromFile();
123 };
124 } // end of namespace bpp.
125 #endif // BPP_PHYL_MODEL_PROTEIN_USERPROTEINSUBSTITUTIONMODEL_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
Build an empirical protein substitution model from a file.
std::unique_ptr< ProteinFrequencySetInterface > freqSet_
void setNamespace(const std::string &prefix) override
void setFreqFromData(const SequenceDataInterface &data, double pseudoCount=0) override
Set equilibrium frequencies equal to the frequencies estimated from the data.
const FrequencySetInterface & frequencySet() const override
UserProteinSubstitutionModel(std::shared_ptr< const ProteicAlphabet > alpha, const std::string &path, const std::string &prefix)
Build a protein model from a PAML file, with original equilibrium frequencies.
UserProteinSubstitutionModel & operator=(const UserProteinSubstitutionModel &model)
void setFrequencySet(const ProteinFrequencySetInterface &freqSet)
void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
std::string getName() const override
Get the name of the model.
UserProteinSubstitutionModel * clone() const override
UserProteinSubstitutionModel(const UserProteinSubstitutionModel &model)
Defines the basic types of data flow nodes.