bpp-phyl  2.2.0
LG10_EX_EHO.cpp
Go to the documentation of this file.
1 //
2 // File: LG10_EX_EHO.cpp
3 // Created by: Mathieu Groussin
4 // Created on: jeudi 21 octobre 2010, à 14h 35
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 "LG10_EX_EHO.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 LG10_EX_EHO::LG10_EX_EHO(const ProteicAlphabet* alpha) :
52  pmixmodel_(0)
53 {
54  // build the submodel
55 
56  vector<SubstitutionModel*> vpSM;
57  vpSM.push_back(new LG10_EX_EHO::EmbeddedModel(alpha,"BUR_EXT"));
58  vpSM.push_back(new LG10_EX_EHO::EmbeddedModel(alpha,"BUR_HEL"));
59  vpSM.push_back(new LG10_EX_EHO::EmbeddedModel(alpha,"BUR_OTH"));
60  vpSM.push_back(new LG10_EX_EHO::EmbeddedModel(alpha,"EXP_EXT"));
61  vpSM.push_back(new LG10_EX_EHO::EmbeddedModel(alpha,"EXP_HEL"));
62  vpSM.push_back(new LG10_EX_EHO::EmbeddedModel(alpha,"EXP_OTH"));
63 
64  Vdouble vrate, vproba;
65 
66  for (unsigned int i=0;i<vpSM.size();i++)
67  {
68  vproba.push_back((dynamic_cast<LG10_EX_EHO::EmbeddedModel*> (vpSM[i]))->getProportion());
69  vrate.push_back(vpSM[i]->getRate());
70  }
71 
72  pmixmodel_.reset(new MixtureOfSubstitutionModels(alpha, vpSM, vproba, vrate));
73 
74  string name,st;
75  ParameterList pl=pmixmodel_->getParameters();
76  for (unsigned int i=0;i<pl.size();i++)
77  {
78  name=pl[i].getName();
79  lParPmodel_.addParameter(Parameter(pl[i]));
80  st=pmixmodel_->getParameterNameWithoutNamespace(name);
81  mapParNamesFromPmodel_[name]=st;
82  addParameter_(new Parameter("LG10_EX_EHO."+st,
83  pmixmodel_->getParameterValue(st),
84  pmixmodel_->getParameter(st).hasConstraint()? pmixmodel_->getParameter(st).getConstraint()->clone():0,true));
85  }
86 
87  updateMatrices();
88 }
89 
91 pmixmodel_(new MixtureOfSubstitutionModels(*mod2.pmixmodel_))
92 {}
93 
95 {
97 
99 
100  return *this;
101 }
102 
104 {}
105 
106 /**************** sub model classes */
107 
108 LG10_EX_EHO::EmbeddedModel::EmbeddedModel(const ProteicAlphabet* alpha, string name) :
109  AbstractParameterAliasable(name),
110  AbstractReversibleSubstitutionModel(alpha, new CanonicalStateMap(alpha, false), name),
111  proportion_(1),
112  name_(name)
113 {
114 #include "__LG10_EX_EHOExchangeabilityCode"
115 #include "__LG10_EX_EHOFrequenciesCode"
116 #include "__LG10_EX_EHORatesProps"
117  updateMatrices();
118 }
119 
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.
EmbeddedModel(const ProteicAlphabet *alpha, string name)
virtual void updateMatrices()
Compute and diagonalize the matrix, and fill the eigenValues_, leftEigenVectors_ and rightEigenVecto...
Partial implementation of the ReversibleSubstitutionModel interface.
The Le and Gascuel (2010) EX_EHO substitution model for proteins.
Definition: LG10_EX_EHO.h:75
AbstractBiblioMixedSubstitutionModel & operator=(const AbstractBiblioMixedSubstitutionModel &model)
std::auto_ptr< MixtureOfSubstitutionModels > pmixmodel_
Definition: LG10_EX_EHO.h:96
LG10_EX_EHO & operator=(const LG10_EX_EHO &)
Definition: LG10_EX_EHO.cpp:94
LG10_EX_EHO(const ProteicAlphabet *alpha)
Build a EX_EHO model, with original equilibrium frequencies, probabilities and rates.
Definition: LG10_EX_EHO.cpp:50
Substitution models defined as a mixture of several substitution models.