~ubuntu-branches/ubuntu/saucy/libbpp-phyl/saucy

« back to all changes in this revision

Viewing changes to src/Bpp/Phyl/Model/YNGKP_M8.cpp

  • Committer: Package Import Robot
  • Author(s): Julien Dutheil
  • Date: 2013-02-09 16:00:00 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130209160000-5v65ba68z8032nzj
Tags: 2.0.3-1
* Reorganized model hierarchy
* New pairwise models
* Several bugs fixed

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
 
50
50
/******************************************************************************/
51
51
 
52
 
YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbclass) :
53
 
  AbstractMixedSubstitutionModel(gc->getSourceAlphabet(), "YNGKP_M8."), pmixmodel_(0),
54
 
  synfrom_(-1), synto_(-1),
55
 
  mapParNamesFromPmodel_(), lParPmodel_()
 
52
YNGKP_M8::YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nclass) :
 
53
  AbstractBiblioMixedSubstitutionModel("YNGKP_M8."),
 
54
  pmixmodel_(0),
 
55
  synfrom_(-1), synto_(-1)
56
56
{
57
 
  if (nbclass<=0)
58
 
    throw Exception("Bad number of classes for model YNGKP_M8: " + TextTools::toString(nbclass));
 
57
  if (nclass<=0)
 
58
    throw Exception("Bad number of classes for model YNGKP_M8: " + TextTools::toString(nclass));
59
59
 
60
60
  // build the submodel
61
61
  
62
 
  BetaDiscreteDistribution* pbdd=new BetaDiscreteDistribution(nbclass,2,2);
 
62
  BetaDiscreteDistribution* pbdd=new BetaDiscreteDistribution(nclass,2,2);
63
63
 
64
64
  vector<double> val; val.push_back(2);
65
65
  vector<double> prob; prob.push_back(1);
126
126
  updateMatrices();
127
127
}
128
128
 
129
 
YNGKP_M8::YNGKP_M8(const YNGKP_M8& mod2) : AbstractMixedSubstitutionModel(mod2),
 
129
YNGKP_M8::YNGKP_M8(const YNGKP_M8& mod2) : AbstractBiblioMixedSubstitutionModel(mod2),
130
130
                                           pmixmodel_(new MixtureOfASubstitutionModel(*mod2.pmixmodel_)),
131
 
                                           synfrom_(mod2.synfrom_), synto_(mod2.synto_),
132
 
                                           mapParNamesFromPmodel_(mod2.mapParNamesFromPmodel_),
133
 
                                           lParPmodel_(mod2.lParPmodel_)
 
131
                                           synfrom_(mod2.synfrom_), synto_(mod2.synto_)
134
132
{
135
133
  
136
134
}
137
135
 
138
136
YNGKP_M8& YNGKP_M8::operator=(const YNGKP_M8& mod2)
139
137
{
140
 
  AbstractMixedSubstitutionModel::operator=(mod2);
 
138
  AbstractBiblioMixedSubstitutionModel::operator=(mod2);
141
139
 
 
140
  if (pmixmodel_)
 
141
    delete pmixmodel_;
142
142
  pmixmodel_=new MixtureOfASubstitutionModel(*mod2.pmixmodel_);
143
 
  mapParNamesFromPmodel_=mod2.mapParNamesFromPmodel_;
144
 
  lParPmodel_=mod2.lParPmodel_;
145
143
  synfrom_=mod2.synfrom_;
146
144
  synto_=mod2.synto_;
147
145
  
156
154
 
157
155
void YNGKP_M8::updateMatrices()
158
156
{
159
 
  map<string,string>::iterator it;
160
 
  
161
 
  for (it=mapParNamesFromPmodel_.begin();it!=mapParNamesFromPmodel_.end();it++)
162
 
    lParPmodel_.setParameterValue(it->first,getParameter(it->second).getValue());
163
 
  
164
 
  pmixmodel_->matchParametersValues(lParPmodel_);
 
157
  AbstractBiblioSubstitutionModel::updateMatrices();
165
158
 
166
159
  // homogeneization of the synonymous substittion rates
167
160
 
173
166
  pmixmodel_->setVRates(vd);
174
167
}
175
168
 
176
 
void YNGKP_M8::setFreq(std::map<int,double>& m)
177
 
{
178
 
  pmixmodel_->setFreq(m);
179
 
  map<string,string>::iterator it;
180
 
 
181
 
  ParameterList pl;
182
 
  for (it=mapParNamesFromPmodel_.begin();it!=mapParNamesFromPmodel_.end();it++)
183
 
    pl.addParameter(Parameter(getNamespace()+it->second,pmixmodel_->getParameterValue(it->first)));
184
 
 
185
 
  matchParametersValues(pl);
186
 
}