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