bpp-phyl  2.2.0
bpp::CodonFromIndependentFrequenciesSet Class Referenceabstract

the Frequencies in codons are the product of Independent Frequencies in letters with the frequencies of stop codons set to zero. More...

#include <Bpp/Phyl/Model/FrequenciesSet/CodonFrequenciesSet.h>

+ Inheritance diagram for bpp::CodonFromIndependentFrequenciesSet:
+ Collaboration diagram for bpp::CodonFromIndependentFrequenciesSet:

Public Member Functions

 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 their lengths do not match. More...
 
 CodonFromIndependentFrequenciesSet (const CodonFromIndependentFrequenciesSet &iwfs)
 
virtual ~CodonFromIndependentFrequenciesSet ()
 
CodonFromIndependentFrequenciesSetoperator= (const CodonFromIndependentFrequenciesSet &iwfs)
 
CodonFromIndependentFrequenciesSetclone () const
 
const CodonAlphabet * getAlphabet () const
 
const GeneticCode * getGeneticCode () const
 
void updateFrequencies ()
 
virtual const StateMapgetStateMap () const =0
 
virtual const std::vector< double > getFrequencies () const =0
 
virtual const std::map< int, double > getAlphabetStatesFrequencies () const =0
 
virtual void setFrequencies (const std::vector< double > &frequencies)=0
 Set the parameters in order to match a given set of frequencies. More...
 
virtual void setFrequenciesFromAlphabetStatesFrequencies (const std::map< int, double > &frequencies)=0
 Set the Frequencies from the one of the map which keys match with a letter of the Alphabet. The frequencies are normalized so that the matching values sum 1. More...
 
virtual std::string getName () const =0
 
virtual size_t getNumberOfFrequencies () const =0
 
void fireParameterChanged (const ParameterList &pl)
 
virtual void setFrequencies (const std::vector< double > &frequencies)
 
const FrequenciesSetgetFrequenciesSetForLetter (size_t i) const
 
virtual size_t getLength () const
 
void setNamespace (const std::string &prefix)
 
std::string getDescription () const
 
const StateMapgetStateMap () const
 
const std::vector< double > getFrequencies () const
 
const std::map< int, double > getAlphabetStatesFrequencies () const
 
void setFrequenciesFromAlphabetStatesFrequencies (const std::map< int, double > &frequencies)
 Set the Frequencies from the one of the map which keys match with a letter of the Alphabet. The frequencies are normalized so that the matching values sum 1. More...
 
std::string getName () const
 
size_t getNumberOfFrequencies () const
 
void normalize ()
 

Static Public Member Functions

static FrequenciesSetgetFrequenciesSetForCodons (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. More...
 

Static Public Attributes

static const short F0 = 0
 
static const short F1X4 = 1
 
static const short F3X4 = 2
 
static const short F61 = 3
 
static IntervalConstraint FREQUENCE_CONSTRAINT_SMALL
 
static IntervalConstraint FREQUENCE_CONSTRAINT_MILLI
 

Protected Member Functions

size_t getSizeFromVector (const std::vector< FrequenciesSet *> &freqVector)
 
std::vector< double > & getFrequencies_ ()
 
double & getFreq_ (size_t i)
 
const double & getFreq_ (size_t i) const
 
void setFrequencies_ (const std::vector< double > &frequencies)
 

Protected Attributes

std::vector< FrequenciesSet * > vFreq_
 
std::vector< std::string > vNestedPrefix_
 

Private Attributes

std::map< int, Vint > mStopNeigh_
 
unsigned short mgmtStopFreq_
 
const GeneticCode * pgc_
 

Detailed Description

the Frequencies in codons are the product of Independent Frequencies in letters with the frequencies of stop codons set to zero.

Author
Laurent Guéguen

Definition at line 338 of file CodonFrequenciesSet.h.

Constructor & Destructor Documentation

◆ CodonFromIndependentFrequenciesSet() [1/2]

CodonFromIndependentFrequenciesSet::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 their lengths do not match.

Parameters
gCodea pointer to the genetic code to use.
freqvectora vector of pointers to the phase specific FrequenciesSets
namethe optional name of the FrequenciesSet (default codon)
mgmtStopFreqthe optional way the frequencies assigned to the stop codons are redistributed to the other codons. The available values are:
  • uniform : each stop frequency is distributed evenly
  • linear : each stop frequency is distributed to the neighbour codons (ie 1 substitution away), in proportion to each target codon frequency.
  • quadratic (default): each stop frequency is distributed to the neighbour codons (ie 1 substitution away), in proportion to the square of each target codon frequency.

Definition at line 377 of file CodonFrequenciesSet.cpp.

References getAlphabet(), mgmtStopFreq_, mStopNeigh_, pgc_, and updateFrequencies().

Referenced by clone().

◆ CodonFromIndependentFrequenciesSet() [2/2]

CodonFromIndependentFrequenciesSet::CodonFromIndependentFrequenciesSet ( const CodonFromIndependentFrequenciesSet iwfs)

Definition at line 419 of file CodonFrequenciesSet.cpp.

References updateFrequencies().

◆ ~CodonFromIndependentFrequenciesSet()

virtual bpp::CodonFromIndependentFrequenciesSet::~CodonFromIndependentFrequenciesSet ( )
inlinevirtual

Definition at line 374 of file CodonFrequenciesSet.h.

Member Function Documentation

◆ clone()

CodonFromIndependentFrequenciesSet* bpp::CodonFromIndependentFrequenciesSet::clone ( ) const
inlinevirtual

Implements bpp::CodonFrequenciesSet.

Definition at line 378 of file CodonFrequenciesSet.h.

References CodonFromIndependentFrequenciesSet().

◆ fireParameterChanged()

void WordFromIndependentFrequenciesSet::fireParameterChanged ( const ParameterList &  pl)
inherited

◆ getAlphabet()

const CodonAlphabet * CodonFromIndependentFrequenciesSet::getAlphabet ( ) const
virtual
Returns
The alphabet associated to this set.

Implements bpp::CodonFrequenciesSet.

Definition at line 414 of file CodonFrequenciesSet.cpp.

References bpp::AbstractWordFrequenciesSet::getAlphabet().

Referenced by CodonFromIndependentFrequenciesSet(), and updateFrequencies().

◆ getAlphabetStatesFrequencies() [1/2]

virtual const std::map<int, double> bpp::FrequenciesSet::getAlphabetStatesFrequencies ( ) const
pure virtualinherited
Returns
The frequencies of each alphabet states according to this model.

Implemented in bpp::AbstractFrequenciesSet.

Referenced by bpp::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::setFreq().

◆ getAlphabetStatesFrequencies() [2/2]

const std::map< int, double > AbstractFrequenciesSet::getAlphabetStatesFrequencies ( ) const
virtualinherited
Returns
The frequencies of each alphabet states according to this model.

Implements bpp::FrequenciesSet.

Definition at line 79 of file FrequenciesSet.cpp.

◆ getDescription()

std::string WordFromIndependentFrequenciesSet::getDescription ( ) const
inherited

◆ getFreq_() [1/2]

◆ getFreq_() [2/2]

const double& bpp::AbstractFrequenciesSet::getFreq_ ( size_t  i) const
inlineprotectedinherited

Definition at line 204 of file FrequenciesSet.h.

References bpp::AbstractFrequenciesSet::freq_.

◆ getFrequencies() [1/2]

◆ getFrequencies() [2/2]

const std::vector<double> bpp::AbstractFrequenciesSet::getFrequencies ( ) const
inlinevirtualinherited
Returns
The frequencies values of the set.

Implements bpp::FrequenciesSet.

Definition at line 174 of file FrequenciesSet.h.

References bpp::AbstractFrequenciesSet::freq_.

Referenced by bpp::MvaFrequenciesSet::updateFrequencies().

◆ getFrequencies_()

std::vector<double>& bpp::AbstractFrequenciesSet::getFrequencies_ ( )
inlineprotectedinherited

Definition at line 202 of file FrequenciesSet.h.

References bpp::AbstractFrequenciesSet::freq_.

◆ getFrequenciesSetForCodons()

FrequenciesSet * CodonFrequenciesSet::getFrequenciesSetForCodons ( short  option,
const GeneticCode *  gCode,
const std::string &  mgmtStopFreq = "quadratic",
unsigned short  method = 1 
)
staticinherited

A helper function that provide frequencies set for codon models according to PAML option.

Parameters
optionA code describing the option, one of F61, F1X4 or F3X4.
gCodeThe genetic code to use. The underlying codon alphabet object will be passed to the FrequenciesSet instance.
mgmtStopFreqthe optional way the frequencies assigned to the stop codons are redistributed to the other codons, with F1X4 and F3X4 options. The available values are:
  • uniform : each stop frequency is distributed evenly
  • linear : each stop frequency is distributed to the neighbour codons (ie 1 substitution away), in proportion to each target codon frequency.
  • quadratic (default): each stop frequency is distributed to the neighbour codons (ie 1 substitution away), in proportion to the square of each target codon frequency.
methodThe parametrization used for F61. Default method is 1 (ie global ratio).
See also
Simplex

Definition at line 623 of file CodonFrequenciesSet.cpp.

References bpp::CodonFrequenciesSet::F0, bpp::CodonFrequenciesSet::F1X4, bpp::CodonFrequenciesSet::F3X4, and bpp::CodonFrequenciesSet::F61.

Referenced by bpp::BppOFrequenciesSetFormat::read().

◆ getFrequenciesSetForLetter()

const FrequenciesSet& bpp::WordFromIndependentFrequenciesSet::getFrequenciesSetForLetter ( size_t  i) const
inlinevirtualinherited

@ brief Return the n-th FrequenciesSet&

Implements bpp::WordFrequenciesSet.

Definition at line 177 of file WordFrequenciesSet.h.

References bpp::WordFromIndependentFrequenciesSet::vFreq_.

Referenced by bpp::BppOFrequenciesSetFormat::write().

◆ getGeneticCode()

const GeneticCode* bpp::CodonFromIndependentFrequenciesSet::getGeneticCode ( ) const
inlinevirtual
Returns
The associated genetic code.

Implements bpp::CodonFrequenciesSet.

Definition at line 382 of file CodonFrequenciesSet.h.

References pgc_.

◆ getLength()

size_t WordFromIndependentFrequenciesSet::getLength ( ) const
virtualinherited

@ brief Return the length of the words

Reimplemented from bpp::AbstractWordFrequenciesSet.

Definition at line 225 of file WordFrequenciesSet.cpp.

References bpp::WordFromIndependentFrequenciesSet::vFreq_.

Referenced by bpp::BppOFrequenciesSetFormat::write().

◆ getName() [1/2]

◆ getName() [2/2]

std::string bpp::AbstractFrequenciesSet::getName ( ) const
inlinevirtualinherited

◆ getNumberOfFrequencies() [1/2]

virtual size_t bpp::FrequenciesSet::getNumberOfFrequencies ( ) const
pure virtualinherited
Returns
The number of frequencies in the set. This is equivalent to getStateMap().getNumberOfModelStates().

Implemented in bpp::AbstractFrequenciesSet.

◆ getNumberOfFrequencies() [2/2]

size_t bpp::AbstractFrequenciesSet::getNumberOfFrequencies ( ) const
inlinevirtualinherited
Returns
The number of frequencies in the set. This is equivalent to getStateMap().getNumberOfModelStates().

Implements bpp::FrequenciesSet.

Definition at line 189 of file FrequenciesSet.h.

References bpp::AbstractFrequenciesSet::freq_.

Referenced by bpp::FixedFrequenciesSet::setFrequencies().

◆ getSizeFromVector()

size_t AbstractWordFrequenciesSet::getSizeFromVector ( const std::vector< FrequenciesSet *> &  freqVector)
protectedvirtualinherited

◆ getStateMap() [1/2]

virtual const StateMap& bpp::FrequenciesSet::getStateMap ( ) const
pure virtualinherited
Returns
The mapping of model states with alphabet states.

Implemented in bpp::AbstractFrequenciesSet.

◆ getStateMap() [2/2]

const StateMap& bpp::AbstractFrequenciesSet::getStateMap ( ) const
inlinevirtualinherited
Returns
The mapping of model states with alphabet states.

Implements bpp::FrequenciesSet.

Definition at line 172 of file FrequenciesSet.h.

References bpp::AbstractFrequenciesSet::stateMap_.

Referenced by bpp::FullPerAACodonFrequenciesSet::updateFrequencies().

◆ normalize()

void bpp::AbstractFrequenciesSet::normalize ( )
inlineinherited

◆ operator=()

CodonFromIndependentFrequenciesSet & CodonFromIndependentFrequenciesSet::operator= ( const CodonFromIndependentFrequenciesSet iwfs)

◆ setFrequencies() [1/2]

◆ setFrequencies() [2/2]

void WordFromIndependentFrequenciesSet::setFrequencies ( const std::vector< double > &  frequencies)
virtualinherited

@ brief Independent letter frequencies from given word frequencies. The frequencies of a letter at a position is the sum of the frequencies of the words that have this letter at this position.

Implements bpp::FrequenciesSet.

Definition at line 183 of file WordFrequenciesSet.cpp.

References bpp::AbstractWordFrequenciesSet::getAlphabet(), bpp::WordFromIndependentFrequenciesSet::updateFrequencies(), and bpp::WordFromIndependentFrequenciesSet::vFreq_.

◆ setFrequencies_()

◆ setFrequenciesFromAlphabetStatesFrequencies() [1/2]

virtual void bpp::FrequenciesSet::setFrequenciesFromAlphabetStatesFrequencies ( const std::map< int, double > &  frequencies)
pure virtualinherited

Set the Frequencies from the one of the map which keys match with a letter of the Alphabet. The frequencies are normalized so that the matching values sum 1.

Parameters
frequenciesThe set of frequencies to match.

Implemented in bpp::AbstractFrequenciesSet.

Referenced by bpp::BppOFrequenciesSetFormat::initialize_(), bpp::AbstractCodonFitnessSubstitutionModel::setFreq(), bpp::AbstractCodonFrequenciesSubstitutionModel::setFreq(), and bpp::AbstractCodonPhaseFrequenciesSubstitutionModel::setFreq().

◆ setFrequenciesFromAlphabetStatesFrequencies() [2/2]

void AbstractFrequenciesSet::setFrequenciesFromAlphabetStatesFrequencies ( const std::map< int, double > &  frequencies)
virtualinherited

Set the Frequencies from the one of the map which keys match with a letter of the Alphabet. The frequencies are normalized so that the matching values sum 1.

In this implementation, all model states with the same alphabet state are given the same frequency.

Parameters
frequenciesThe set of frequencies to match.

Implements bpp::FrequenciesSet.

Definition at line 58 of file FrequenciesSet.cpp.

◆ setNamespace()

void WordFromIndependentFrequenciesSet::setNamespace ( const std::string &  prefix)
inherited

◆ updateFrequencies()

void CodonFromIndependentFrequenciesSet::updateFrequencies ( )
virtual

Member Data Documentation

◆ F0

const short CodonFrequenciesSet::F0 = 0
staticinherited

◆ F1X4

const short CodonFrequenciesSet::F1X4 = 1
staticinherited

◆ F3X4

const short CodonFrequenciesSet::F3X4 = 2
staticinherited

◆ F61

const short CodonFrequenciesSet::F61 = 3
staticinherited

◆ FREQUENCE_CONSTRAINT_MILLI

IntervalConstraint FrequenciesSet::FREQUENCE_CONSTRAINT_MILLI
staticinherited

Definition at line 118 of file FrequenciesSet.h.

◆ FREQUENCE_CONSTRAINT_SMALL

IntervalConstraint FrequenciesSet::FREQUENCE_CONSTRAINT_SMALL
staticinherited

◆ mgmtStopFreq_

unsigned short bpp::CodonFromIndependentFrequenciesSet::mgmtStopFreq_
private

◆ mStopNeigh_

std::map<int, Vint> bpp::CodonFromIndependentFrequenciesSet::mStopNeigh_
private

◆ pgc_

const GeneticCode* bpp::CodonFromIndependentFrequenciesSet::pgc_
private

◆ vFreq_

◆ vNestedPrefix_

std::vector<std::string> bpp::WordFromIndependentFrequenciesSet::vNestedPrefix_
protectedinherited

The documentation for this class was generated from the following files: