bpp-phyl  2.2.0
CodonFrequenciesSet.cpp
Go to the documentation of this file.
1 //
2 // File: CodonFrequenciesSet.cpp
3 // Created by: Laurent Gueguen
4 // Created on: lundi 2 avril 2012, à 14h 15
5 //
6 
7 /*
8  Copyright or (c) 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 #include "CodonFrequenciesSet.h"
42 #include "../StateMap.h"
43 
44 // From bpp-core:
45 #include <Bpp/Numeric/Prob/Simplex.h>
46 
47 using namespace bpp;
48 using namespace std;
49 
50 // ////////////////////////////
51 // FullCodonFrequenciesSet
52 
53 FullCodonFrequenciesSet::FullCodonFrequenciesSet(const GeneticCode* gCode, bool allowNullFreqs, unsigned short method, const string& name) :
55  new CanonicalStateMap(gCode->getSourceAlphabet(), false),
56  "Full.",
57  name),
58  pgc_(gCode),
59  sFreq_(gCode->getSourceAlphabet()->getSize() - gCode->getNumberOfStopCodons(), method, allowNullFreqs, "Full.")
60 {
61  vector<double> vd;
62  double r = 1. / static_cast<double>(sFreq_.dimension());
63 
64  for (size_t i = 0; i < sFreq_.dimension(); i++)
65  {
66  vd.push_back(r);
67  }
68 
69  sFreq_.setFrequencies(vd);
70  addParameters_(sFreq_.getParameters());
71  updateFreq_();
72 }
73 
75  const GeneticCode* gCode,
76  const vector<double>& initFreqs,
77  bool allowNullFreqs,
78  unsigned short method,
79  const string& name) :
80  AbstractFrequenciesSet(new CanonicalStateMap(gCode->getSourceAlphabet(), false), "Full.", name),
81  pgc_(gCode),
82  sFreq_(gCode->getSourceAlphabet()->getSize() - gCode->getNumberOfStopCodons(), method, allowNullFreqs, "Full.")
83 {
84  if (initFreqs.size() != getAlphabet()->getSize())
85  throw Exception("FullCodonFrequenciesSet(constructor). There must be " + TextTools::toString(gCode->getSourceAlphabet()->getSize()) + " frequencies.");
86 
87  double sum = 0;
88  for (size_t i = 0; i < getAlphabet()->getSize(); i++)
89  {
90  if (!pgc_->isStop(static_cast<int>(i)))
91  sum += initFreqs[i];
92  }
93 
94  vector<double> vd;
95  for (size_t i = 0; i < getAlphabet()->getSize(); i++)
96  {
97  if (!gCode->isStop(static_cast<int>(i)))
98  vd.push_back(initFreqs[i] / sum);
99  }
100 
101  sFreq_.setFrequencies(vd);
102  addParameters_(sFreq_.getParameters());
103  updateFreq_();
104 }
105 
108  pgc_(fcfs.pgc_),
109  sFreq_(fcfs.sFreq_)
110 {}
111 
113 {
115  pgc_ = fcfs.pgc_;
116  sFreq_ = fcfs.sFreq_;
117 
118  return *this;
119 }
120 
121 void FullCodonFrequenciesSet::setNamespace(const std::string& nameSpace)
122 {
123  sFreq_.setNamespace(nameSpace);
124  AbstractFrequenciesSet::setNamespace(nameSpace);
125 }
126 
127 void FullCodonFrequenciesSet::setFrequencies(const vector<double>& frequencies)
128 {
129  if (frequencies.size() != getAlphabet()->getSize())
130  throw DimensionException("FullFrequenciesSet::setFrequencies", frequencies.size(), getAlphabet()->getSize());
131 
132  double sum = 0;
133  for (size_t i = 0; i < getAlphabet()->getSize(); i++)
134  {
135  if (!pgc_->isStop(static_cast<int>(i)))
136  sum += frequencies[i];
137  }
138 
139  vector<double> vd;
140  for (size_t i = 0; i < getAlphabet()->getSize(); i++)
141  {
142  if (!pgc_->isStop(static_cast<int>(i)))
143  vd.push_back(frequencies[i] / sum);
144  }
145 
146  sFreq_.setFrequencies(vd);
147  setParametersValues(sFreq_.getParameters());
148  updateFreq_();
149 }
150 
151 void FullCodonFrequenciesSet::fireParameterChanged(const ParameterList& parameters)
152 {
153  sFreq_.matchParametersValues(parameters);
154  updateFreq_();
155 }
156 
158 {
159  size_t nbstop = 0;
160 
161  for (size_t j = 0; j < getAlphabet()->getSize(); j++)
162  {
163  if (pgc_->isStop(static_cast<int>(j)))
164  {
165  getFreq_(j) = 0;
166  nbstop++;
167  }
168  else
169  getFreq_(j) = sFreq_.prob(j - nbstop);
170  }
171 }
172 
173 
174 // ////////////////////////////
175 // FullPerAACodonFrequenciesSet
176 
178  const GeneticCode* gencode,
179  ProteinFrequenciesSet* ppfs,
180  unsigned short method) :
181  AbstractFrequenciesSet(new CanonicalStateMap(gencode->getSourceAlphabet(), false), "FullPerAA.", "FullPerAA"),
182  pgc_(gencode),
183  ppfs_(ppfs),
184  vS_()
185 {
186  const ProteicAlphabet* ppa = dynamic_cast<const ProteicAlphabet*>(pgc_->getTargetAlphabet());
187  const StateMap& aaStates = ppfs_->getStateMap();
188  for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
189  {
190  int aa = aaStates.getAlphabetStateAsInt(i);
191  vector<int> vc = pgc_->getSynonymous(aa);
192  vS_.push_back(Simplex(vc.size(), method, 0, ""));
193 
194  Simplex& si = vS_[i];
195 
196  si.setNamespace("FullPerAA." + ppa->getAbbr(aa) + "_");
197  addParameters_(si.getParameters());
198  }
199 
200  ppfs_->setNamespace("FullPerAA." + ppfs_->getName() + ".");
201  addParameters_(ppfs_->getParameters());
202 
204 }
205 
206 FullPerAACodonFrequenciesSet::FullPerAACodonFrequenciesSet(const GeneticCode* gencode, unsigned short method) :
207  AbstractFrequenciesSet(new CanonicalStateMap(gencode->getSourceAlphabet(), false), "FullPerAA.", "FullPerAA"),
208  pgc_(gencode),
209  ppfs_(new FixedProteinFrequenciesSet(dynamic_cast<const ProteicAlphabet*>(gencode->getTargetAlphabet()), "FullPerAA.")),
210  vS_()
211 {
212  const ProteicAlphabet* ppa = dynamic_cast<const ProteicAlphabet*>(pgc_->getTargetAlphabet());
213  const StateMap& aaStates = ppfs_->getStateMap();
214  for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
215  {
216  int aa = aaStates.getAlphabetStateAsInt(i);
217  vector<int> vc = pgc_->getSynonymous(aa);
218  vS_.push_back(Simplex(vc.size(), method, 0, ""));
219 
220  Simplex& si = vS_[i];
221  si.setNamespace("FullPerAA." + ppa->getAbbr(aa) + "_");
222  addParameters_(si.getParameters());
223  }
224 
226 }
227 
229  CodonFrequenciesSet(ffs),
231  pgc_(ffs.pgc_),
232  ppfs_(ffs.ppfs_->clone()),
233  vS_(ffs.vS_)
234 {
236 }
237 
239 {
240  CodonFrequenciesSet::operator=(ffs);
242  pgc_ = ffs.pgc_;
243  ppfs_.reset(ffs.ppfs_->clone());
244  vS_ = ffs.vS_;
245 
246  return *this;
247 }
248 
249 void FullPerAACodonFrequenciesSet::fireParameterChanged(const ParameterList& parameters)
250 {
251  if (dynamic_cast<AbstractFrequenciesSet*>(ppfs_.get()))
252  (dynamic_cast<AbstractFrequenciesSet*>(ppfs_.get()))->matchParametersValues(parameters);
253  for (size_t i = 0; i < vS_.size(); i++)
254  {
255  vS_[i].matchParametersValues(parameters);
256  }
258 }
259 
261 {
262  const StateMap& aaStates = ppfs_->getStateMap();
263  for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
264  {
265  int aa = aaStates.getAlphabetStateAsInt(i);
266  std::vector<int> vc = pgc_->getSynonymous(aa);
267  for (size_t j = 0; j < vc.size(); j++)
268  {
269  //NB: only one alphabet state per model state here, as it is a CodonFreqSet.
270  getFreq_(getStateMap().getModelStates(vc[j])[0]) =
271  static_cast<double>(vc.size()) * ppfs_->getFrequencies()[i] * vS_[i].prob(j);
272  }
273  }
274  normalize();
275 }
276 
277 void FullPerAACodonFrequenciesSet::setFrequencies(const vector<double>& frequencies)
278 {
279  if (frequencies.size() != getAlphabet()->getSize())
280  throw DimensionException("FullPerAAFrequenciesSet::setFrequencies", frequencies.size(), getAlphabet()->getSize());
281 
282  double bigS = 0;
283  Vdouble vaa;
284 
285  const StateMap& aaStates = ppfs_->getStateMap();
286  for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
287  {
288  int aa = aaStates.getAlphabetStateAsInt(i);
289  std::vector<int> vc = pgc_->getSynonymous(aa);
290  Vdouble vp;
291  double s = 0;
292 
293  for (size_t j = 0; j < vc.size(); j++)
294  {
295  size_t index = pgc_->getSourceAlphabet()->getStateIndex(vc[j]);
296  vp.push_back(frequencies[index-1]);
297  s += frequencies[index-1];
298  }
299 
300  vp /= s;
301  vS_[i].setFrequencies(vp);
302 
303  matchParametersValues(vS_[i].getParameters());
304 
305  bigS += s / static_cast<double>(vc.size());
306  vaa.push_back(s / static_cast<double>(vc.size()));
307  }
308 
309  vaa /= bigS; // to avoid counting of stop codons
310  ppfs_->setFrequencies(vaa);
311  matchParametersValues(ppfs_->getParameters());
313 }
314 
315 void FullPerAACodonFrequenciesSet::setNamespace(const std::string& prefix)
316 {
317  const ProteicAlphabet* ppa = dynamic_cast<const ProteicAlphabet*>(pgc_->getTargetAlphabet());
318 
319  AbstractFrequenciesSet::setNamespace(prefix);
320  ppfs_->setNamespace(prefix + ppfs_->getName() + ".");
321  for (size_t i = 0; i < vS_.size(); i++)
322  {
323  vS_[i].setNamespace(prefix + ppa->getAbbr(static_cast<int>(i)) + "_");
324  }
325 }
326 
327 
328 // ///////////////////////////////////////////
329 // / FixedCodonFrequenciesSet
330 
332  const GeneticCode* gCode,
333  const vector<double>& initFreqs,
334  const string& name) :
335  AbstractFrequenciesSet(new CanonicalStateMap(gCode->getSourceAlphabet(), false), "Fixed.", name),
336  pgc_(gCode)
337 {
338  setFrequencies(initFreqs);
339 }
340 
341 FixedCodonFrequenciesSet::FixedCodonFrequenciesSet(const GeneticCode* gCode, const string& name) :
342  AbstractFrequenciesSet(new CanonicalStateMap(gCode->getSourceAlphabet(), false), "Fixed.", name),
343  pgc_(gCode)
344 {
345  size_t size = gCode->getSourceAlphabet()->getSize() - gCode->getNumberOfStopCodons();
346 
347  for (size_t i = 0; i < gCode->getSourceAlphabet()->getSize(); i++)
348  {
349  getFreq_(i) = (gCode->isStop(static_cast<int>(i))) ? 0 : 1. / static_cast<double>(size);
350  }
351 }
352 
353 void FixedCodonFrequenciesSet::setFrequencies(const vector<double>& frequencies)
354 {
355  const CodonAlphabet* ca = dynamic_cast<const CodonAlphabet*>(getAlphabet());
356  if (frequencies.size() != ca->getSize())
357  throw DimensionException("FixedFrequenciesSet::setFrequencies", frequencies.size(), ca->getSize());
358  double sum = 0.0;
359 
360  for (size_t i = 0; i < frequencies.size(); i++)
361  {
362  if (!(pgc_->isStop(static_cast<int>(i))))
363  sum += frequencies[i];
364  }
365 
366  for (size_t i = 0; i < ca->getSize(); i++)
367  {
368  getFreq_(i) = (pgc_->isStop(static_cast<int>(i))) ? 0 : frequencies[i] / sum;
369  }
370 }
371 
372 
373 // ///////////////////////////////////////////////////////////////////
374 // // CodonFromIndependentFrequenciesSet
375 
376 
378  const GeneticCode* gCode,
379  const std::vector<FrequenciesSet*>& freqvector,
380  const string& name,
381  const string& mgmtStopFreq) :
382  WordFromIndependentFrequenciesSet(gCode->getSourceAlphabet(), freqvector, "", name),
383  mStopNeigh_(),
384  mgmtStopFreq_(2),
385  pgc_(gCode)
386 {
387  if (mgmtStopFreq == "uniform")
388  mgmtStopFreq_ = 0;
389  else if (mgmtStopFreq == "linear")
390  mgmtStopFreq_ = 1;
391 
392  // fill the map of the stop codons
393 
394  vector<int> vspcod = gCode->getStopCodonsAsInt();
395  for (size_t ispcod = 0; ispcod < vspcod.size(); ispcod++)
396  {
397  size_t pow = 1;
398  int nspcod = vspcod[ispcod];
399  for (size_t ph = 0; ph < 3; ph++)
400  {
401  size_t nspcod0 = static_cast<size_t>(nspcod) - pow * static_cast<size_t>(getAlphabet()->getNPosition(nspcod, 2 - ph));
402  for (size_t dec = 0; dec < 4; dec++)
403  {
404  size_t vois = nspcod0 + pow * dec;
405  if (!pgc_->isStop(static_cast<int>(vois)))
406  mStopNeigh_[nspcod].push_back(static_cast<int>(vois));
407  }
408  pow *= 4;
409  }
410  }
412 }
413 
415 {
416  return dynamic_cast<const CodonAlphabet*>(WordFromIndependentFrequenciesSet::getAlphabet());
417 }
418 
421  mStopNeigh_(iwfs.mStopNeigh_),
422  mgmtStopFreq_(iwfs.mgmtStopFreq_),
423  pgc_(iwfs.pgc_)
424 {
426 }
427 
429 {
431  mStopNeigh_ = iwfs.mStopNeigh_;
433  pgc_ = iwfs.pgc_;
434  return *this;
435 }
436 
438 {
440 
441  size_t s = getAlphabet()->getSize();
442 
443  if (mgmtStopFreq_ != 0)
444  {
445  // The frequencies of the stop codons are distributed to all
446  // neighbour non-stop codons
447  double f[64];
448  for (size_t i = 0; i < s; i++)
449  {
450  f[i] = 0;
451  }
452 
453  std::map<int, Vint>::iterator mStopNeigh_it(mStopNeigh_.begin());
454  while (mStopNeigh_it != mStopNeigh_.end())
455  {
456  int stNb = mStopNeigh_it->first;
457  Vint vneigh = mStopNeigh_it->second;
458  double sneifreq = 0;
459  for (size_t vn = 0; vn < vneigh.size(); vn++)
460  {
461  sneifreq += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopFreq_);
462  }
463  double x = getFreq_(static_cast<size_t>(stNb)) / sneifreq;
464  for (size_t vn = 0; vn < vneigh.size(); vn++)
465  {
466  f[vneigh[vn]] += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopFreq_) * x;
467  }
468  getFreq_(static_cast<size_t>(stNb)) = 0;
469  mStopNeigh_it++;
470  }
471 
472  for (size_t i = 0; i < s; i++)
473  {
474  getFreq_(i) += f[i];
475  }
476  }
477  else
478  {
479  double sum = 0.;
480  for (size_t i = 0; i < s; i++)
481  {
482  if (!pgc_->isStop(static_cast<int>(i)))
483  sum += getFreq_(i);
484  }
485 
486  for (size_t i = 0; i < s; i++)
487  {
488  if (pgc_->isStop(static_cast<int>(i)))
489  getFreq_(i) = 0;
490  else
491  getFreq_(i) /= sum;
492  }
493  }
494 }
495 
496 // ///////////////////////////////////////////////////////////////////
497 // // CodonFromUniqueFrequenciesSet
498 
499 
501  const GeneticCode* gCode,
502  FrequenciesSet* pfreq,
503  const string& name,
504  const string& mgmtStopFreq) :
505  WordFromUniqueFrequenciesSet(gCode->getSourceAlphabet(), pfreq, "", name),
506  mStopNeigh_(),
507  mgmtStopFreq_(2),
508  pgc_(gCode)
509 {
510  if (mgmtStopFreq == "uniform")
511  mgmtStopFreq_ = 0;
512  else if (mgmtStopFreq == "linear")
513  mgmtStopFreq_ = 1;
514 
515  // fill the map of the stop codons
516 
517  vector<int> vspcod = gCode->getStopCodonsAsInt();
518  for (size_t ispcod = 0; ispcod < vspcod.size(); ispcod++)
519  {
520  size_t pow = 1;
521  int nspcod = vspcod[ispcod];
522  for (int ph = 0; ph < 3; ph++)
523  {
524  size_t nspcod0 = static_cast<size_t>(nspcod) - pow * static_cast<size_t>(getAlphabet()->getNPosition(nspcod, static_cast<unsigned int>(2 - ph)));
525  for (size_t dec = 0; dec < 4; dec++)
526  {
527  size_t vois = nspcod0 + pow * dec;
528  if (!pgc_->isStop(static_cast<int>(vois)))
529  mStopNeigh_[nspcod].push_back(static_cast<int>(vois));
530  }
531  pow *= 4;
532  }
533  }
534 
536 }
537 
538 const CodonAlphabet* CodonFromUniqueFrequenciesSet::getAlphabet() const
539 {
540  return dynamic_cast<const CodonAlphabet*>(WordFromUniqueFrequenciesSet::getAlphabet());
541 }
542 
543 
546  mStopNeigh_(iwfs.mStopNeigh_),
547  mgmtStopFreq_(iwfs.mgmtStopFreq_),
548  pgc_(iwfs.pgc_)
549 {
551 }
552 
554 {
556  mStopNeigh_ = iwfs.mStopNeigh_;
558  pgc_ = iwfs.pgc_;
559  return *this;
560 }
561 
563 {
565 
566  size_t s = getAlphabet()->getSize();
567 
568  if (mgmtStopFreq_ != 0)
569  {
570  // The frequencies of the stop codons are distributed to all
571  // neighbour non-stop codons
572  double f[64];
573  for (size_t i = 0; i < s; i++)
574  {
575  f[i] = 0;
576  }
577 
578  std::map<int, Vint>::iterator mStopNeigh_it(mStopNeigh_.begin());
579  while (mStopNeigh_it != mStopNeigh_.end())
580  {
581  int stNb = mStopNeigh_it->first;
582  Vint vneigh = mStopNeigh_it->second;
583  double sneifreq = 0;
584  for (size_t vn = 0; vn < vneigh.size(); vn++)
585  {
586  sneifreq += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopFreq_);
587  }
588  double x = getFreq_(static_cast<size_t>(stNb)) / sneifreq;
589  for (size_t vn = 0; vn < vneigh.size(); vn++)
590  {
591  f[vneigh[vn]] += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopFreq_) * x;
592  }
593  getFreq_(static_cast<size_t>(stNb)) = 0;
594  mStopNeigh_it++;
595  }
596 
597  for (size_t i = 0; i < s; i++)
598  {
599  getFreq_(i) += f[i];
600  }
601  }
602  else
603  {
604  double sum = 0.;
605  for (size_t i = 0; i < s; i++)
606  {
607  if (!pgc_->isStop(static_cast<int>(i)))
608  sum += getFreq_(i);
609  }
610 
611  for (unsigned int i = 0; i < s; i++)
612  {
613  if (pgc_->isStop(static_cast<int>(i)))
614  getFreq_(i) = 0;
615  else
616  getFreq_(i) /= sum;
617  }
618  }
619 }
620 
621 /*********************************************************************/
622 
623 FrequenciesSet* CodonFrequenciesSet::getFrequenciesSetForCodons(short option, const GeneticCode* gCode, const string& mgmtStopFreq, unsigned short method)
624 {
625  FrequenciesSet* codonFreqs;
626 
627  if (option == F0)
628  codonFreqs = new FixedCodonFrequenciesSet(gCode, "F0");
629  else if (option == F1X4)
630  codonFreqs = new CodonFromUniqueFrequenciesSet(gCode, new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet()), "F1X4", mgmtStopFreq);
631  else if (option == F3X4)
632  {
633  vector<FrequenciesSet*> v_AFS(3);
634  v_AFS[0] = new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet());
635  v_AFS[1] = new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet());
636  v_AFS[2] = new FullNucleotideFrequenciesSet(gCode->getSourceAlphabet()->getNucleicAlphabet());
637  codonFreqs = new CodonFromIndependentFrequenciesSet(gCode, v_AFS, "F3X4", mgmtStopFreq);
638  }
639  else if (option == F61)
640  codonFreqs = new FullCodonFrequenciesSet(gCode, false, method, "F61");
641  else
642  throw Exception("FrequenciesSet::getFrequencySetForCodons(). Unvalid codon frequency set argument.");
643 
644  return codonFreqs;
645 }
646 
647 /******************************************************************************/
648 
649 const short CodonFrequenciesSet::F0 = 0;
650 const short CodonFrequenciesSet::F1X4 = 1;
651 const short CodonFrequenciesSet::F3X4 = 2;
652 const short CodonFrequenciesSet::F61 = 3;
653 
654 /******************************************************************************/
virtual int getAlphabetStateAsInt(size_t index) const =0
A generic FrequenciesSet for Full Codon alphabets.
void setNamespace(const std::string &prefix)
CodonFromUniqueFrequenciesSet & operator=(const CodonFromUniqueFrequenciesSet &iwfs)
This class implements a state map where all resolved states are modeled.
Definition: StateMap.h:161
const CodonAlphabet * getAlphabet() const
FullCodonFrequenciesSet(const GeneticCode *gCode, bool allowNullFreqs=false, unsigned short method=1, const std::string &name="Full")
Construction with uniform frequencies on the letters of the alphabet. The stop codon frequencies are ...
the Frequencies in codons are the product of Independent Frequencies in letters with the frequencies ...
FrequenciesSet integrating ProteinFrequenciesSet inside CodonFrequenciesSet. In this case...
virtual size_t getNumberOfModelStates() const =0
const WordAlphabet * getAlphabet() const
CodonFromIndependentFrequenciesSet(const GeneticCode *gCode, const std::vector< FrequenciesSet *> &freqvector, const std::string &name="Codon", const std::string &mgmtStopFreq="quadratic")
Constructor from a CodonAlphabet* and a vector of different FrequenciesSet*. Throws an Exception if t...
FrequenciesSet useful for homogeneous and stationary models, protein implementation.
FullPerAACodonFrequenciesSet & operator=(const FullPerAACodonFrequenciesSet &ffs)
CodonFromUniqueFrequenciesSet(const GeneticCode *gCode, FrequenciesSet *pfreq, const std::string &name="Codon", const std::string &mgmtStopFreq="quadratic")
Constructor from a CodonAlphabet* and a FrequenciesSet* repeated three times.
STL namespace.
void setFrequencies(const std::vector< double > &frequencies)
the given frequencies are normalized such thaat the sum of the frequencies on the non-stop codons equ...
FixedCodonFrequenciesSet(const GeneticCode *gCode, const std::vector< double > &initFreqs, const std::string &name="Fixed")
void setFrequencies(const std::vector< double > &frequencies)
the given frequencies are normalized such that the sum of the frequencies on the non-stop codons equa...
void fireParameterChanged(const ParameterList &parameters)
Parametrize a set of state frequencies.
WordFromIndependentFrequenciesSet & operator=(const WordFromIndependentFrequenciesSet &iwfs)
Parametrize a set of state frequencies for codons.
CodonFromIndependentFrequenciesSet & operator=(const CodonFromIndependentFrequenciesSet &iwfs)
Nucleotide FrequenciesSet using three independent parameters (theta, theta1, theta2) to modelize the ...
const CodonAlphabet * getAlphabet() const
FrequenciesSet useful for homogeneous and stationary models, codon implementation.
Parametrize a set of state frequencies for proteins.
const CodonAlphabet * getAlphabet() const
void updateFrequencies()
Update the frequencies given the parameters.
const StateMap & getStateMap() const
FullCodonFrequenciesSet & operator=(const FullCodonFrequenciesSet &fcfs)
double & getFreq_(size_t i)
FullPerAACodonFrequenciesSet(const GeneticCode *gencode, ProteinFrequenciesSet *ppfs, unsigned short method=1)
Create a new FullPerAACodonFrequenciesSet object.
void setFrequencies(const std::vector< double > &frequencies)
the given frequencies are normalized such thaat the sum of the frequencies on the non-stop codons equ...
void fireParameterChanged(const ParameterList &parameters)
static FrequenciesSet * getFrequenciesSetForCodons(short option, const GeneticCode *gCode, const std::string &mgmtStopFreq="quadratic", unsigned short method=1)
A helper function that provide frequencies set for codon models according to PAML option...
void setNamespace(const std::string &nameSpace)
const CodonAlphabet * getAlphabet() const
the Frequencies in words are the product of Independent Frequencies in letters
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:58
AbstractFrequenciesSet & operator=(const AbstractFrequenciesSet &af)
Simplex sFreq_
Simplex to handle the probabilities and the parameters.
std::auto_ptr< ProteinFrequenciesSet > ppfs_
WordFromUniqueFrequenciesSet & operator=(const WordFromUniqueFrequenciesSet &iwfs)
the Frequencies in codons are the product of the frequencies for a unique FrequenciesSet in letters...
Basic implementation of the FrequenciesSet interface.
const CodonAlphabet * getAlphabet() const