bpp-phyl3  3.0.0
CodonFrequencySet.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #include "../StateMap.h"
6 #include "CodonFrequencySet.h"
8 
9 // From bpp-core:
11 
12 using namespace bpp;
13 using namespace std;
14 
15 // ////////////////////////////
16 // FullCodonFrequencySet
17 
19  std::shared_ptr<const GeneticCode> gCode,
20  bool allowNullFreqs,
21  unsigned short method,
22  const string& name) :
24  make_shared<CanonicalStateMap>(gCode->getSourceAlphabet(), false),
25  "Full.",
26  name),
27  pgc_(gCode),
28  sFreq_(gCode->sourceAlphabet().getSize() - gCode->getNumberOfStopCodons(), method, allowNullFreqs, "Full.")
29 {
30  vector<double> vd;
31  double r = 1. / static_cast<double>(sFreq_.dimension());
32 
33  for (size_t i = 0; i < sFreq_.dimension(); ++i)
34  {
35  vd.push_back(r);
36  }
37 
40  updateFreq_();
41 }
42 
44  std::shared_ptr<const GeneticCode> gCode,
45  const vector<double>& initFreqs,
46  bool allowNullFreqs,
47  unsigned short method,
48  const string& name) :
50  make_shared<CanonicalStateMap>(gCode->getSourceAlphabet(), false),
51  "Full.",
52  name),
53  pgc_(gCode),
54  sFreq_(gCode->sourceAlphabet().getSize() - gCode->getNumberOfStopCodons(), method, allowNullFreqs, "Full.")
55 {
56  if (initFreqs.size() != getCodonAlphabet()->getSize())
57  throw Exception("FullCodonFrequencySet(constructor). There must be " + TextTools::toString(gCode->getSourceAlphabet()->getSize()) + " frequencies.");
58 
59  double sum = 0;
60  for (size_t i = 0; i < getCodonAlphabet()->getSize(); i++)
61  {
62  if (!pgc_->isStop(static_cast<int>(i)))
63  sum += initFreqs[i];
64  }
65 
66  vector<double> vd;
67  for (size_t i = 0; i < getCodonAlphabet()->getSize(); i++)
68  {
69  if (!gCode->isStop(static_cast<int>(i)))
70  vd.push_back(initFreqs[i] / sum);
71  }
72 
75  updateFreq_();
76 }
77 
80  pgc_(fcfs.pgc_),
81  sFreq_(fcfs.sFreq_)
82 {}
83 
85 {
87  pgc_ = fcfs.pgc_;
88  sFreq_ = fcfs.sFreq_;
89 
90  return *this;
91 }
92 
93 void FullCodonFrequencySet::setNamespace(const std::string& nameSpace)
94 {
95  sFreq_.setNamespace(nameSpace);
97 }
98 
99 void FullCodonFrequencySet::setFrequencies(const vector<double>& frequencies)
100 {
101  if (frequencies.size() != getCodonAlphabet()->getSize())
102  throw DimensionException("FullFrequencySet::setFrequencies", frequencies.size(), getAlphabet()->getSize());
103 
104  double sum = 0;
105  for (size_t i = 0; i < getCodonAlphabet()->getSize(); i++)
106  {
107  if (!pgc_->isStop(static_cast<int>(i)))
108  sum += frequencies[i];
109  }
110 
111  vector<double> vd;
112  for (size_t i = 0; i < getCodonAlphabet()->getSize(); i++)
113  {
114  if (!pgc_->isStop(static_cast<int>(i)))
115  vd.push_back(frequencies[i] / sum);
116  }
117 
120  updateFreq_();
121 }
122 
124 {
125  sFreq_.matchParametersValues(parameters);
126  updateFreq_();
127 }
128 
130 {
131  size_t nbstop = 0;
132 
133  for (size_t j = 0; j < getCodonAlphabet()->getSize(); j++)
134  {
135  if (pgc_->isStop(static_cast<int>(j)))
136  {
137  getFreq_(j) = 0;
138  nbstop++;
139  }
140  else
141  getFreq_(j) = sFreq_.prob(j - nbstop);
142  }
143 }
144 
145 
146 // ////////////////////////////
147 // FullPerAACodonFrequencySet
148 
150  std::shared_ptr<const GeneticCode> gencode,
151  std::unique_ptr<ProteinFrequencySetInterface> ppfs,
152  unsigned short method) :
154  make_shared<CanonicalStateMap>(gencode->getSourceAlphabet(), false),
155  "FullPerAA.",
156  "FullPerAA"),
157  pgc_(gencode),
158  ppfs_(std::move(ppfs)),
159  vS_()
160 {
161  auto& ppa = pgc_->proteicAlphabet();
162  auto& aaStates = ppfs_->stateMap();
163  for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
164  {
165  int aa = aaStates.getAlphabetStateAsInt(i);
166  vector<int> vc = pgc_->getSynonymous(aa);
167  vS_.push_back(Simplex(vc.size(), method, 0, ""));
168 
169  Simplex& si = vS_[i];
170 
171  si.setNamespace("FullPerAA." + ppa.getAbbr(aa) + "_");
173  }
174 
175  ppfs_->setNamespace("FullPerAA." + ppfs_->getName() + ".");
176  addParameters_(ppfs_->getParameters());
177 
179 }
180 
182  std::shared_ptr<const GeneticCode> gencode,
183  unsigned short method) :
185  make_shared<CanonicalStateMap>(gencode->getSourceAlphabet(), false),
186  "FullPerAA.",
187  "FullPerAA"),
188  pgc_(gencode),
189  ppfs_(new FixedProteinFrequencySet(gencode->getProteicAlphabet(), "FullPerAA.")),
190  vS_()
191 {
192  auto ppa = pgc_->getProteicAlphabet();
193  auto& aaStates = ppfs_->stateMap();
194  for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
195  {
196  int aa = aaStates.getAlphabetStateAsInt(i);
197  vector<int> vc = pgc_->getSynonymous(aa);
198  vS_.push_back(Simplex(vc.size(), method, 0, ""));
199 
200  Simplex& si = vS_[i];
201  si.setNamespace("FullPerAA." + ppa->getAbbr(aa) + "_");
203  }
204 
206 }
207 
210  pgc_(ffs.pgc_),
211  ppfs_(ffs.ppfs_->clone()),
212  vS_(ffs.vS_)
213 {
215 }
216 
218 {
220  pgc_ = ffs.pgc_;
221  ppfs_.reset(ffs.ppfs_->clone());
222  vS_ = ffs.vS_;
223 
224  return *this;
225 }
226 
228 {
229  if (dynamic_cast<AbstractFrequencySet*>(ppfs_.get()))
230  (dynamic_cast<AbstractFrequencySet*>(ppfs_.get()))->matchParametersValues(parameters);
231  for (size_t i = 0; i < vS_.size(); i++)
232  {
233  vS_[i].matchParametersValues(parameters);
234  }
236 }
237 
239 {
240  auto& aaStates = ppfs_->stateMap();
241  for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
242  {
243  int aa = aaStates.getAlphabetStateAsInt(i);
244  std::vector<int> vc = pgc_->getSynonymous(aa);
245  for (size_t j = 0; j < vc.size(); j++)
246  {
247  // NB: only one alphabet state per model state here, as it is a CodonFreqSet.
248  getFreq_(stateMap().getModelStates(vc[j])[0]) =
249  static_cast<double>(vc.size()) * ppfs_->getFrequencies()[i] * vS_[i].prob(j);
250  }
251  }
252  normalize();
253 }
254 
255 void FullPerAACodonFrequencySet::setFrequencies(const vector<double>& frequencies)
256 {
257  if (frequencies.size() != getCodonAlphabet()->getSize())
258  throw DimensionException("FullPerAAFrequencySet::setFrequencies", frequencies.size(), getCodonAlphabet()->getSize());
259 
260  double bigS = 0;
261  Vdouble vaa;
262 
263  auto& aaStates = ppfs_->stateMap();
264  for (size_t i = 0; i < aaStates.getNumberOfModelStates(); ++i)
265  {
266  int aa = aaStates.getAlphabetStateAsInt(i);
267  std::vector<int> vc = pgc_->getSynonymous(aa);
268  Vdouble vp;
269  double s = 0;
270 
271  for (size_t j = 0; j < vc.size(); j++)
272  {
273  size_t index = pgc_->getSourceAlphabet()->getStateIndex(vc[j]);
274  vp.push_back(frequencies[index - 1]);
275  s += frequencies[index - 1];
276  }
277 
278  vp /= s;
279  vS_[i].setFrequencies(vp);
280 
282 
283  bigS += s / static_cast<double>(vc.size());
284  vaa.push_back(s / static_cast<double>(vc.size()));
285  }
286 
287  vaa /= bigS; // to avoid counting of stop codons
288  ppfs_->setFrequencies(vaa);
289  matchParametersValues(ppfs_->getParameters());
291 }
292 
293 void FullPerAACodonFrequencySet::setNamespace(const std::string& prefix)
294 {
295  auto ppa = pgc_->getProteicAlphabet();
296 
298  ppfs_->setNamespace(prefix + ppfs_->getName() + ".");
299  for (size_t i = 0; i < vS_.size(); ++i)
300  {
301  vS_[i].setNamespace(prefix + ppa->getAbbr(static_cast<int>(i)) + "_");
302  }
303 }
304 
305 
306 // ///////////////////////////////////////////
307 // / FixedCodonFrequencySet
308 
310  std::shared_ptr<const GeneticCode> gCode,
311  const vector<double>& initFreqs,
312  const string& name) :
314  make_shared<CanonicalStateMap>(gCode->getSourceAlphabet(), false),
315  "Fixed.",
316  name),
317  pgc_(gCode)
318 {
319  setFrequencies(initFreqs);
320 }
321 
323  std::shared_ptr<const GeneticCode> gCode,
324  const string& name) :
326  make_shared<CanonicalStateMap>(gCode->getSourceAlphabet(), false),
327  "Fixed.",
328  name),
329  pgc_(gCode)
330 {
331  size_t size = gCode->sourceAlphabet().getSize() - gCode->getNumberOfStopCodons();
332 
333  for (size_t i = 0; i < gCode->sourceAlphabet().getSize(); i++)
334  {
335  getFreq_(i) = (gCode->isStop(static_cast<int>(i))) ? 0 : 1. / static_cast<double>(size);
336  }
337 }
338 
339 void FixedCodonFrequencySet::setFrequencies(const vector<double>& frequencies)
340 {
341  auto ca = getCodonAlphabet();
342  if (frequencies.size() != ca->getSize())
343  throw DimensionException("FixedFrequencySet::setFrequencies", frequencies.size(), ca->getSize());
344  double sum = 0.0;
345 
346  for (size_t i = 0; i < frequencies.size(); ++i)
347  {
348  if (!(pgc_->isStop(static_cast<int>(i))))
349  sum += frequencies[i];
350  }
351 
352  for (size_t i = 0; i < ca->getSize(); ++i)
353  {
354  getFreq_(i) = (pgc_->isStop(static_cast<int>(i))) ? 0 : frequencies[i] / sum;
355  }
356 }
357 
358 
359 // ///////////////////////////////////////////
360 // / UserCodonFrequencySet
361 
363  std::shared_ptr<const GeneticCode> gCode,
364  const std::string& path,
365  size_t nCol) :
367  make_shared<CanonicalStateMap>(gCode->getSourceAlphabet(), false),
368  path,
369  nCol),
370  pgc_(gCode)
371 {}
372 
373 void UserCodonFrequencySet::setFrequencies(const vector<double>& frequencies)
374 {
375  auto ca = getCodonAlphabet();
376  if (frequencies.size() != ca->getSize())
377  throw DimensionException("UserFrequencySet::setFrequencies", frequencies.size(), ca->getSize());
378  double sum = 0.0;
379 
380  for (size_t i = 0; i < frequencies.size(); ++i)
381  {
382  if (!(pgc_->isStop(static_cast<int>(i))))
383  sum += frequencies[i];
384  }
385 
386  for (size_t i = 0; i < ca->getSize(); ++i)
387  {
388  getFreq_(i) = (pgc_->isStop(static_cast<int>(i))) ? 0 : frequencies[i] / sum;
389  }
390 }
391 
392 
393 // ///////////////////////////////////////////////////////////////////
394 // // CodonFromIndependentFrequencySet
395 
396 
398  std::shared_ptr<const GeneticCode> gCode,
399  vector<std::unique_ptr<FrequencySetInterface>>& freqvector,
400  const string& name,
401  const string& mgmtStopCodon) :
403  gCode->getCodonAlphabet(),
404  freqvector,
405  "",
406  name),
407  mStopNeigh_(),
408  mgmtStopCodon_(2),
409  pgc_(gCode)
410 {
411  if (mgmtStopCodon == "uniform")
412  mgmtStopCodon_ = 0;
413  else if (mgmtStopCodon == "linear")
414  mgmtStopCodon_ = 1;
415 
416  // fill the map of the stop codons
417 
418  vector<int> vspcod = gCode->getStopCodonsAsInt();
419  for (size_t ispcod = 0; ispcod < vspcod.size(); ispcod++)
420  {
421  size_t pow = 1;
422  int nspcod = vspcod[ispcod];
423  for (size_t ph = 0; ph < 3; ph++)
424  {
425  size_t nspcod0 = static_cast<size_t>(nspcod) - pow * static_cast<size_t>(getCodonAlphabet()->getNPosition(nspcod, 2 - ph));
426  for (size_t dec = 0; dec < 4; dec++)
427  {
428  size_t vois = nspcod0 + pow * dec;
429  if (!pgc_->isStop(static_cast<int>(vois)))
430  mStopNeigh_[nspcod].push_back(static_cast<int>(vois));
431  }
432  pow *= 4;
433  }
434  }
436 }
437 
438 shared_ptr<const CodonAlphabet> CodonFromIndependentFrequencySet::getCodonAlphabet() const
439 {
440  return dynamic_pointer_cast<const CodonAlphabet>(WordFromIndependentFrequencySet::getAlphabet());
441 }
442 
445  mStopNeigh_(iwfs.mStopNeigh_),
446  mgmtStopCodon_(iwfs.mgmtStopCodon_),
447  pgc_(iwfs.pgc_)
448 {
450 }
451 
453 {
455  mStopNeigh_ = iwfs.mStopNeigh_;
457  pgc_ = iwfs.pgc_;
458  return *this;
459 }
460 
462 {
464 
465  size_t s = getCodonAlphabet()->getSize();
466 
467  if (mgmtStopCodon_ != 0)
468  {
469  // The frequencies of the stop codons are distributed to all
470  // neighbour non-stop codons
471  double f[64];
472  for (size_t i = 0; i < s; i++)
473  {
474  f[i] = 0;
475  }
476 
477  std::map<int, Vint>::iterator mStopNeigh_it(mStopNeigh_.begin());
478  while (mStopNeigh_it != mStopNeigh_.end())
479  {
480  int stNb = mStopNeigh_it->first;
481  Vint vneigh = mStopNeigh_it->second;
482  double sneifreq = 0;
483  for (size_t vn = 0; vn < vneigh.size(); vn++)
484  {
485  sneifreq += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopCodon_);
486  }
487  double x = getFreq_(static_cast<size_t>(stNb)) / sneifreq;
488  for (size_t vn = 0; vn < vneigh.size(); vn++)
489  {
490  f[vneigh[vn]] += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopCodon_) * x;
491  }
492  getFreq_(static_cast<size_t>(stNb)) = 0;
493  mStopNeigh_it++;
494  }
495 
496  for (size_t i = 0; i < s; i++)
497  {
498  getFreq_(i) += f[i];
499  }
500  }
501  else
502  {
503  double sum = 0.;
504  for (size_t i = 0; i < s; i++)
505  {
506  if (!pgc_->isStop(static_cast<int>(i)))
507  sum += getFreq_(i);
508  }
509 
510  for (size_t i = 0; i < s; i++)
511  {
512  if (pgc_->isStop(static_cast<int>(i)))
513  getFreq_(i) = 0;
514  else
515  getFreq_(i) /= sum;
516  }
517  }
518 }
519 
520 // ///////////////////////////////////////////////////////////////////
521 // // CodonFromUniqueFrequencySet
522 
523 
525  std::shared_ptr<const GeneticCode> gCode,
526  std::unique_ptr<FrequencySetInterface> pfreq,
527  const string& name,
528  const string& mgmtStopCodon) :
529  WordFromUniqueFrequencySet(gCode->getCodonAlphabet(), std::move(pfreq), "", name),
530  mStopNeigh_(),
531  mgmtStopCodon_(2),
532  pgc_(gCode)
533 {
534  if (mgmtStopCodon == "uniform")
535  mgmtStopCodon_ = 0;
536  else if (mgmtStopCodon == "linear")
537  mgmtStopCodon_ = 1;
538 
539  // fill the map of the stop codons
540 
541  vector<int> vspcod = gCode->getStopCodonsAsInt();
542  for (size_t ispcod = 0; ispcod < vspcod.size(); ispcod++)
543  {
544  size_t pow = 1;
545  int nspcod = vspcod[ispcod];
546  for (int ph = 0; ph < 3; ph++)
547  {
548  size_t nspcod0 = static_cast<size_t>(nspcod) - pow * static_cast<size_t>(getCodonAlphabet()->getNPosition(nspcod, static_cast<unsigned int>(2 - ph)));
549  for (size_t dec = 0; dec < 4; dec++)
550  {
551  size_t vois = nspcod0 + pow * dec;
552  if (!pgc_->isStop(static_cast<int>(vois)))
553  mStopNeigh_[nspcod].push_back(static_cast<int>(vois));
554  }
555  pow *= 4;
556  }
557  }
558 
560 }
561 
562 shared_ptr<const CodonAlphabet> CodonFromUniqueFrequencySet::getCodonAlphabet() const
563 {
564  return dynamic_pointer_cast<const CodonAlphabet>(WordFromUniqueFrequencySet::getWordAlphabet());
565 }
566 
567 
570  mStopNeigh_(iwfs.mStopNeigh_),
571  mgmtStopCodon_(iwfs.mgmtStopCodon_),
572  pgc_(iwfs.pgc_)
573 {
575 }
576 
578 {
580  mStopNeigh_ = iwfs.mStopNeigh_;
582  pgc_ = iwfs.pgc_;
583  return *this;
584 }
585 
587 {
589 
590  size_t s = getCodonAlphabet()->getSize();
591 
592  if (mgmtStopCodon_ != 0)
593  {
594  // The frequencies of the stop codons are distributed to all
595  // neighbour non-stop codons
596  double f[64] = {0};
597 
598  for (const auto& mStopNeigh_it : mStopNeigh_)
599  {
600  int stNb = mStopNeigh_it.first;
601  Vint vneigh = mStopNeigh_it.second;
602  double sneifreq = 0;
603  for (size_t vn = 0; vn < vneigh.size(); vn++)
604  {
605  sneifreq += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopCodon_);
606  }
607  double x = getFreq_(static_cast<size_t>(stNb)) / sneifreq;
608  for (size_t vn = 0; vn < vneigh.size(); vn++)
609  {
610  f[vneigh[vn]] += pow(getFreq_(static_cast<size_t>(vneigh[vn])), mgmtStopCodon_) * x;
611  }
612  getFreq_(static_cast<size_t>(stNb)) = 0;
613  }
614 
615  for (size_t i = 0; i < s; i++)
616  {
617  getFreq_(i) += f[i];
618  }
619  }
620  else
621  {
622  double sum = 0.;
623  for (size_t i = 0; i < s; i++)
624  {
625  if (!pgc_->isStop(static_cast<int>(i)))
626  sum += getFreq_(i);
627  }
628 
629  for (unsigned int i = 0; i < s; i++)
630  {
631  if (pgc_->isStop(static_cast<int>(i)))
632  getFreq_(i) = 0;
633  else
634  getFreq_(i) /= sum;
635  }
636  }
637 }
638 
639 /*********************************************************************/
640 
641 unique_ptr<CodonFrequencySetInterface> CodonFrequencySetInterface::getFrequencySetForCodons(
642  short option,
643  std::shared_ptr<const GeneticCode> gCode,
644  const string& mgmtStopCodon,
645  unsigned short method)
646 {
647  unique_ptr<CodonFrequencySetInterface> codonFreqs;
648 
649  if (option == F0)
650  {
651  codonFreqs.reset(new FixedCodonFrequencySet(gCode, "F0"));
652  }
653  else if (option == F1X4)
654  {
655  codonFreqs.reset(new CodonFromUniqueFrequencySet(gCode, make_unique<FullNucleotideFrequencySet>(gCode->codonAlphabet().getNucleicAlphabet()), "F1X4", mgmtStopCodon));
656  }
657  else if (option == F3X4)
658  {
659  vector<unique_ptr<FrequencySetInterface>> v_AFS(3);
660  v_AFS[0] = make_unique<FullNucleotideFrequencySet>(gCode->codonAlphabet().getNucleicAlphabet());
661  v_AFS[1] = make_unique<FullNucleotideFrequencySet>(gCode->codonAlphabet().getNucleicAlphabet());
662  v_AFS[2] = make_unique<FullNucleotideFrequencySet>(gCode->codonAlphabet().getNucleicAlphabet());
663  codonFreqs = make_unique<CodonFromIndependentFrequencySet>(gCode, v_AFS, "F3X4", mgmtStopCodon);
664  }
665  else if (option == F61)
666  codonFreqs.reset(new FullCodonFrequencySet(gCode, false, method, "F61"));
667  else
668  throw Exception("FrequencySet::getFrequencySetForCodons(). Invalid codon frequency set argument.");
669 
670  return codonFreqs;
671 }
672 
673 /******************************************************************************/
674 
675 const short CodonFrequencySetInterface::F0 = 0;
676 const short CodonFrequencySetInterface::F1X4 = 1;
677 const short CodonFrequencySetInterface::F3X4 = 2;
678 const short CodonFrequencySetInterface::F61 = 3;
679 
680 /******************************************************************************/
Basic implementation of the FrequencySet interface.
Definition: FrequencySet.h:102
std::shared_ptr< const Alphabet > getAlphabet() const override
Definition: FrequencySet.h:140
double & getFreq_(size_t i)
Definition: FrequencySet.h:179
AbstractFrequencySet & operator=(const AbstractFrequencySet &af)
Definition: FrequencySet.h:129
const StateMapInterface & stateMap() const override
Definition: FrequencySet.h:144
void addParameters_(const ParameterList &parameters)
void setNamespace(const std::string &prefix)
void setParametersValues(const ParameterList &parameters) override
bool matchParametersValues(const ParameterList &parameters) override
const ParameterList & getParameters() const override
std::shared_ptr< const CoreWordAlphabet > getWordAlphabet() const override
This class implements a state map where all resolved states are modeled.
Definition: StateMap.h:168
static std::unique_ptr< CodonFrequencySetInterface > getFrequencySetForCodons(short option, std::shared_ptr< const GeneticCode > gCode, const std::string &mgmtStopCodon="quadratic", unsigned short method=1)
A helper function that provide frequencies set for codon models according to PAML option.
the Frequencies in codons are the product of Independent Frequencies in letters with the frequencies ...
std::shared_ptr< const CodonAlphabet > getCodonAlphabet() const override
void updateFrequencies() override
Update the frequencies given the parameters.
std::shared_ptr< const GeneticCode > pgc_
CodonFromIndependentFrequencySet(std::shared_ptr< const GeneticCode > gCode, std::vector< std::unique_ptr< FrequencySetInterface >> &freqvector, const std::string &name="Codon", const std::string &mgmtStopCodon="quadratic")
Constructor from a CodonAlphabet* and a vector of different std::shared_ptr<FrequencySet>....
CodonFromIndependentFrequencySet & operator=(const CodonFromIndependentFrequencySet &iwfs)
the Frequencies in codons are the product of the frequencies for a unique FrequencySet in letters,...
void updateFrequencies() override
Update the frequencies given the parameters.
CodonFromUniqueFrequencySet(std::shared_ptr< const GeneticCode > gCode, std::unique_ptr< FrequencySetInterface > pfreq, const std::string &name="Codon", const std::string &mgmtStopCodon="quadratic")
Constructor from a CodonAlphabet* and a std::shared_ptr<FrequencySet> repeated three times.
std::shared_ptr< const GeneticCode > pgc_
CodonFromUniqueFrequencySet & operator=(const CodonFromUniqueFrequencySet &iwfs)
std::shared_ptr< const CodonAlphabet > getCodonAlphabet() const override
FrequencySet useful for homogeneous and stationary models, codon implementation.
void setFrequencies(const std::vector< double > &frequencies) override
the given frequencies are normalized such thaat the sum of the frequencies on the non-stop codons equ...
std::shared_ptr< const CodonAlphabet > getCodonAlphabet() const override
std::shared_ptr< const GeneticCode > pgc_
FixedCodonFrequencySet(std::shared_ptr< const GeneticCode > gCode, const std::vector< double > &initFreqs, const std::string &name="Fixed")
FrequencySet useful for homogeneous and stationary models, protein implementation.
A generic FrequencySet for Full Codon alphabets.
FullCodonFrequencySet & operator=(const FullCodonFrequencySet &fcfs)
FullCodonFrequencySet(std::shared_ptr< 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 ...
Simplex sFreq_
Simplex to handle the probabilities and the parameters.
std::shared_ptr< const GeneticCode > pgc_
void setFrequencies(const std::vector< double > &frequencies) override
the given frequencies are normalized such that the sum of the frequencies on the non-stop codons equa...
void fireParameterChanged(const ParameterList &parameters) override
void setNamespace(const std::string &nameSpace) override
std::shared_ptr< const CodonAlphabet > getCodonAlphabet() const override
FrequencySet integrating ProteinFrequencySet inside CodonFrequencySet. In this case,...
std::unique_ptr< ProteinFrequencySetInterface > ppfs_
std::shared_ptr< const GeneticCode > pgc_
std::shared_ptr< const CodonAlphabet > getCodonAlphabet() const override
void setFrequencies(const std::vector< double > &frequencies) override
the given frequencies are normalized such thaat the sum of the frequencies on the non-stop codons equ...
void setNamespace(const std::string &prefix) override
std::vector< Simplex > vS_
vector of the simplexes, one for each AA
FullPerAACodonFrequencySet(std::shared_ptr< const GeneticCode > gencode, std::unique_ptr< ProteinFrequencySetInterface > ppfs, unsigned short method=1)
Create a new FullPerAACodonFrequencySet object.
FullPerAACodonFrequencySet & operator=(const FullPerAACodonFrequencySet &ffs)
void fireParameterChanged(const ParameterList &parameters) override
size_t dimension() const
double prob(size_t i) const
void setFrequencies(const std::vector< double > &)
UserCodonFrequencySet(std::shared_ptr< const GeneticCode > gCode, const std::string &path, size_t nCol=1)
std::shared_ptr< const GeneticCode > pgc_
std::shared_ptr< const CodonAlphabet > getCodonAlphabet() const override
void setFrequencies(const std::vector< double > &frequencies) override
the given frequencies are normalized such thaat the sum of the frequencies on the non-stop codons equ...
FrequencySet to be read in a file. More specifically, a frequency set is read in a column of a given ...
Definition: FrequencySet.h:386
the Frequencies in words are the product of Independent Frequencies in letters
WordFromIndependentFrequencySet & operator=(const WordFromIndependentFrequencySet &iwfs)
WordFromUniqueFrequencySet & operator=(const WordFromUniqueFrequencySet &iwfs)
std::string toString(T t)
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
ExtendedFloat pow(const ExtendedFloat &ef, double exp)
std::vector< int > Vint