bpp-phyl  2.2.0
LLG08_EX2.cpp
Go to the documentation of this file.
1 //
2 // File: LLG08_EX2.cpp
3 // Created by: Laurent Gueguen
4 // Created on: mardi 12 octobre 2010, à 09h 43
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
9  This software is a computer program whose purpose is to provide classes
10  for phylogenetic data analysis.
11 
12  This software is governed by the CeCILL license under French law and
13  abiding by the rules of distribution of free software. You can use,
14  modify and/ or redistribute the software under the terms of the CeCILL
15  license as circulated by CEA, CNRS and INRIA at the following URL
16  "http://www.cecill.info".
17 
18  As a counterpart to the access to the source code and rights to copy,
19  modify and redistribute granted by the license, users are provided only
20  with a limited warranty and the software's author, the holder of the
21  economic rights, and the successive licensors have only limited
22  liability.
23 
24  In this respect, the user's attention is drawn to the risks associated
25  with loading, using, modifying and/or developing or reproducing the
26  software by the user in light of its specific status of free software,
27  that may mean that it is complicated to manipulate, and that also
28  therefore means that it is reserved for developers and experienced
29  professionals having in-depth computer knowledge. Users are therefore
30  encouraged to load and test the software's suitability as regards their
31  requirements in conditions enabling the security of their systems and/or
32  data to be ensured and, more generally, to use and operate it in the
33  same conditions as regards security.
34 
35  The fact that you are presently reading this means that you have had
36  knowledge of the CeCILL license and that you accept its terms.
37  */
38 
39 #include "LLG08_EX2.h"
40 #include "../FrequenciesSet/ProteinFrequenciesSet.h"
41 
42 #include <Bpp/Numeric/Prob/SimpleDiscreteDistribution.h>
43 
44 using namespace bpp;
45 
46 using namespace std;
47 
48 /******************************************************************************/
49 
50 LLG08_EX2::LLG08_EX2(const ProteicAlphabet* alpha) :
52  pmixmodel_(0)
53 {
54  // build the submodel
55 
56  vector<SubstitutionModel*> vpSM;
57  vpSM.push_back(new LLG08_EX2::EmbeddedModel(alpha, "Buried"));
58  vpSM.push_back(new LLG08_EX2::EmbeddedModel(alpha, "Exposed"));
59 
60  Vdouble vrate, vproba;
61 
62  for (unsigned int i = 0; i < vpSM.size(); i++)
63  {
64  vproba.push_back((dynamic_cast<LLG08_EX2::EmbeddedModel*>(vpSM[i]))->getProportion());
65  vrate.push_back(vpSM[i]->getRate());
66  }
67 
68  pmixmodel_.reset(new MixtureOfSubstitutionModels(alpha, vpSM, vproba, vrate));
69 
70  string name, st;
71  ParameterList pl = pmixmodel_->getParameters();
72  for (size_t i = 0; i < pl.size(); i++)
73  {
74  name = pl[i].getName();
75  lParPmodel_.addParameter(Parameter(pl[i]));
76  st = pmixmodel_->getParameterNameWithoutNamespace(name);
77  mapParNamesFromPmodel_[name] = st;
78  addParameter_(new Parameter("LLG08_EX2." + st,
79  pmixmodel_->getParameterValue(st),
80  pmixmodel_->getParameter(st).hasConstraint() ? pmixmodel_->getParameter(st).getConstraint()->clone() : 0, true));
81  }
82 
84 }
85 
87  pmixmodel_(new MixtureOfSubstitutionModels(*mod2.pmixmodel_))
88 {}
89 
91 {
93 
95 
96  return *this;
97 }
98 
100 
101 /**************** sub model classes */ // ////////
102 
103 LLG08_EX2::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name) :
104  AbstractParameterAliasable(name),
105  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
106  proportion_(1),
107  name_(name)
108 {
109 #include "__LLG08_EX2ExchangeabilityCode"
110 #include "__LLG08_EX2FrequenciesCode"
111 #include "__LLG08_EX2RatesProps"
112  updateMatrices();
113 }
114 
115 
std::map< std::string, std::string > mapParNamesFromPmodel_
Tools to make the link between the Parameters of the object and those of pmixmodel_.
Abstract class for mixture models based on the bibliography.
This class implements a state map where all resolved states are modeled.
Definition: StateMap.h:161
STL namespace.
The Le et al (2008) EX2 substitution model for proteins.
Definition: LLG08_EX2.h:74
virtual void updateMatrices()
Compute and diagonalize the matrix, and fill the eigenValues_, leftEigenVectors_ and rightEigenVecto...
LLG08_EX2(const ProteicAlphabet *alpha)
Build a EX2 model, with original equilibrium frequencies, probabilities and rates.
Definition: LLG08_EX2.cpp:50
Partial implementation of the ReversibleSubstitutionModel interface.
LLG08_EX2 & operator=(const LLG08_EX2 &)
Definition: LLG08_EX2.cpp:90
AbstractBiblioMixedSubstitutionModel & operator=(const AbstractBiblioMixedSubstitutionModel &model)
EmbeddedModel(const ProteicAlphabet *alpha, string name)
Definition: LLG08_EX2.cpp:103
std::auto_ptr< MixtureOfSubstitutionModels > pmixmodel_
Definition: LLG08_EX2.h:95
Substitution models defined as a mixture of several substitution models.