bpp-phyl  2.2.0
UserProteinSubstitutionModel.h
Go to the documentation of this file.
1 //
2 // File: UserProteinSubstitutionModel.h
3 // Created by: Julien Dutheil
4 // Created on: Wed Aug 26 16:27 2005
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 _USERPROTEINSUBSTITUTIONMODEL_H_
41 #define _USERPROTEINSUBSTITUTIONMODEL_H_
42 
44 #include "../AbstractSubstitutionModel.h"
45 #include "../FrequenciesSet/ProteinFrequenciesSet.h"
46 
47 // From SeqLib:
48 #include <Bpp/Seq/Alphabet/ProteicAlphabet.h>
49 
50 // From the STL:
51 #include <string>
52 
53 namespace bpp
54 {
55 
65  public virtual ProteinSubstitutionModel,
67  {
68  private:
69  std::string path_;
71 
72  public:
81  const ProteicAlphabet* alpha,
82  const std::string& path,
83  const std::string& prefix);
84 
96  const ProteicAlphabet* alpha,
97  const std::string& path,
98  ProteinFrequenciesSet* freqSet,
99  const std::string& prefix,
100  bool initFreqs = false
101  );
102 
104  AbstractParameterAliasable(model),
105  //AbstractSubstitutionModel(model),
107  path_(model.path_),
108  freqSet_(dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone()))
109  {}
110 
112  {
113  AbstractParameterAliasable::operator=(model);
116  path_ = model.path_;
117  freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone());
118  return *this;
119  }
120 
122 
123 #ifndef NO_VIRTUAL_COV
125 #else
126  Clonable*
127 #endif
128  clone() const { return new UserProteinSubstitutionModel(*this); }
129 
130  public:
131  std::string getName() const;
132  const std::string& getPath() const { return path_; }
133 
134  void fireParameterChanged(const ParameterList& parameters)
135  {
136  freqSet_->matchParametersValues(parameters);
139  }
140 
142  {
143  delete freqSet_;
144  freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(freqSet.clone());
145  resetParameters_();
146  addParameters_(freqSet_->getParameters());
147  }
148 
149  const FrequenciesSet* getFrequenciesSet() const { return freqSet_; }
150 
151  void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0);
152 
153  protected:
154  void readFromFile();
155 
156  };
157 
158 } //end of namespace bpp.
159 
160 #endif //_USERPROTEINSUBSTITUTIONMODEL_H_
161 
std::string getName() const
Get the name of the model.
virtual void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
void setFrequenciesSet(const ProteinFrequenciesSet &freqSet)
UserProteinSubstitutionModel & operator=(const UserProteinSubstitutionModel &model)
void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
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)
UserProteinSubstitutionModel(const ProteicAlphabet *alpha, const std::string &path, const std::string &prefix)
Build a protein model from a PAML file, with original equilibrium frequencies.
Partial implementation of the ReversibleSubstitutionModel interface.
Parametrize a set of state frequencies for proteins.
const FrequenciesSet * getFrequenciesSet() const
If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0.
UserProteinSubstitutionModel * clone() const
UserProteinSubstitutionModel(const UserProteinSubstitutionModel &model)
void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)
Set equilibrium frequencies equal to the frequencies estimated from the data.
Build an empirical protein substitution model from a file.