bpp-phyl  2.2.0
LG08.h
Go to the documentation of this file.
1 //
2 // File: LG08.h
3 // Created by: Laurent Gueguen
4 // Created on: Wed lundi 13 septembre 2010, à 13h 26
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
9 
10  This software is a computer program whose purpose is to provide classes
11  for phylogenetic data analysis.
12 
13  This software is governed by the CeCILL license under French law and
14  abiding by the rules of distribution of free software. You can use,
15  modify and/ or redistribute the software under the terms of the CeCILL
16  license as circulated by CEA, CNRS and INRIA at the following URL
17  "http://www.cecill.info".
18 
19  As a counterpart to the access to the source code and rights to copy,
20  modify and redistribute granted by the license, users are provided only
21  with a limited warranty and the software's author, the holder of the
22  economic rights, and the successive licensors have only limited
23  liability.
24 
25  In this respect, the user's attention is drawn to the risks associated
26  with loading, using, modifying and/or developing or reproducing the
27  software by the user in light of its specific status of free software,
28  that may mean that it is complicated to manipulate, and that also
29  therefore means that it is reserved for developers and experienced
30  professionals having in-depth computer knowledge. Users are therefore
31  encouraged to load and test the software's suitability as regards their
32  requirements in conditions enabling the security of their systems and/or
33  data to be ensured and, more generally, to use and operate it in the
34  same conditions as regards security.
35 
36  The fact that you are presently reading this means that you have had
37  knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _LG08_H_
41 #define _LG08_H_
42 
44 #include "../AbstractSubstitutionModel.h"
45 #include "../FrequenciesSet/ProteinFrequenciesSet.h"
46 
47 // From SeqLib:
48 #include <Bpp/Seq/Alphabet/ProteicAlphabet.h>
49 
50 namespace bpp
51 {
52 
64  class LG08 :
65  public virtual ProteinSubstitutionModel,
67  {
68  private:
70 
71  public:
77  LG08(const ProteicAlphabet* alpha);
78 
87  LG08(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs=false);
88 
89  LG08(const LG08& model) :
90  AbstractParameterAliasable(model),
91  //AbstractSubstitutionModel(model),
93  freqSet_(dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone()))
94  {}
95 
96  LG08& operator=(const LG08& model)
97  {
98  AbstractParameterAliasable::operator=(model);
101  if (freqSet_) delete freqSet_;
102  freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone());
103  return *this;
104  }
105 
106  virtual ~LG08() { delete freqSet_; }
107 
108 #ifndef NO_VIRTUAL_COV
109  LG08*
110 #else
111  Clonable*
112 #endif
113  clone() const { return new LG08(*this); }
114 
115  public:
116  std::string getName() const
117  {
118  if (freqSet_->getNamespace().find("LG08+F.")!=std::string::npos)
119  return "LG08+F";
120  else
121  return "LG08";
122  }
123 
124  void fireParameterChanged(const ParameterList& parameters)
125  {
126  freqSet_->matchParametersValues(parameters);
129  }
130 
132  {
133  delete freqSet_;
134  freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(freqSet.clone());
135  resetParameters_();
136  addParameters_(freqSet_->getParameters());
137  }
138 
139  const FrequenciesSet* getFrequenciesSet() const { return freqSet_; }
140 
141  void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0);
142 
143  };
144 
145 } //end of namespace bpp.
146 
147 #endif //_LG08_H_
148 
std::string getName() const
Get the name of the model.
Definition: LG08.h:116
virtual void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
Specialized interface for protein substitution model.
The Le and Gascuel substitution model for proteins.
Definition: LG08.h:64
virtual const std::vector< double > getFrequencies() const =0
Vdouble freq_
The vector of equilibrium frequencies.
Parametrize a set of state frequencies.
void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)
Set equilibrium frequencies equal to the frequencies estimated from the data.
Definition: LG08.cpp:80
ProteinFrequenciesSet * clone() const =0
AbstractSubstitutionModel & operator=(const AbstractSubstitutionModel &model)
Partial implementation of the ReversibleSubstitutionModel interface.
ProteinFrequenciesSet * freqSet_
Definition: LG08.h:69
LG08 & operator=(const LG08 &model)
Definition: LG08.h:96
virtual ~LG08()
Definition: LG08.h:106
Parametrize a set of state frequencies for proteins.
void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
Definition: LG08.h:124
LG08 * clone() const
Definition: LG08.h:113
const FrequenciesSet * getFrequenciesSet() const
If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0.
Definition: LG08.h:139
LG08(const ProteicAlphabet *alpha)
Build a simple LG08 model, with original equilibrium frequencies.
Definition: LG08.cpp:53
void setFrequenciesSet(const ProteinFrequenciesSet &freqSet)
Definition: LG08.h:131
LG08(const LG08 &model)
Definition: LG08.h:89