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