bpp-phyl  2.2.0
WAG01.h
Go to the documentation of this file.
1 //
2 // File: WAG01.h
3 // Created by: Laurent Gueguen
4 // Created on: mardi 28 septembre 2010, à 14h 43
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 _WAG01_H_
41 #define _WAG01_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 
71  class WAG01 :
72  public virtual ProteinSubstitutionModel,
74  {
75  private:
77 
78  public:
84  WAG01(const ProteicAlphabet* alpha);
85 
94  WAG01(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs=false);
95 
96  WAG01(const WAG01& model) :
97  AbstractParameterAliasable(model),
98  //AbstractSubstitutionModel(model),
100  freqSet_(dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone()))
101  {}
102 
103  WAG01& operator=(const WAG01& model)
104  {
105  AbstractParameterAliasable::operator=(model);
108  if (freqSet_) delete freqSet_;
109  freqSet_ = dynamic_cast<ProteinFrequenciesSet *>(model.freqSet_->clone());
110  return *this;
111  }
112 
113  virtual ~WAG01() { delete freqSet_; }
114 
115 #ifndef NO_VIRTUAL_COV
116  WAG01*
117 #else
118  Clonable*
119 #endif
120  clone() const { return new WAG01(*this); }
121 
122  public:
123  std::string getName() const
124  {
125  if (freqSet_->getNamespace().find("WAG01+F.")!=std::string::npos)
126  return "WAG01+F";
127  else
128  return "WAG01";
129  }
130 
131  void fireParameterChanged(const ParameterList& parameters)
132  {
133  freqSet_->matchParametersValues(parameters);
136  }
137 
139  {
140  delete freqSet_;
141  freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(freqSet.clone());
142  resetParameters_();
143  addParameters_(freqSet_->getParameters());
144  }
145 
146  const FrequenciesSet* getFrequenciesSet() const { return freqSet_; }
147 
148  void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0);
149 
150  };
151 
152 } //end of namespace bpp.
153 
154 #endif //_WAG01_H_
155 
virtual void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
The Whelan and Goldman substitution model for proteins.
Definition: WAG01.h:71
void setFrequenciesSet(const ProteinFrequenciesSet &freqSet)
Definition: WAG01.h:138
WAG01 * clone() const
Definition: WAG01.h:120
Specialized interface for protein substitution model.
virtual const std::vector< double > getFrequencies() const =0
Vdouble freq_
The vector of equilibrium frequencies.
Parametrize a set of state frequencies.
ProteinFrequenciesSet * clone() const =0
AbstractSubstitutionModel & operator=(const AbstractSubstitutionModel &model)
Partial implementation of the ReversibleSubstitutionModel interface.
WAG01 & operator=(const WAG01 &model)
Definition: WAG01.h:103
Parametrize a set of state frequencies for proteins.
void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)
Set equilibrium frequencies equal to the frequencies estimated from the data.
Definition: WAG01.cpp:77
WAG01(const ProteicAlphabet *alpha)
Build a simple WAG01 model, with original equilibrium frequencies.
Definition: WAG01.cpp:50
ProteinFrequenciesSet * freqSet_
Definition: WAG01.h:76
void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
Definition: WAG01.h:131
const FrequenciesSet * getFrequenciesSet() const
If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0.
Definition: WAG01.h:146
virtual ~WAG01()
Definition: WAG01.h:113
std::string getName() const
Get the name of the model.
Definition: WAG01.h:123
WAG01(const WAG01 &model)
Definition: WAG01.h:96