bpp-phyl3  3.0.0
bpp::FullCodonFrequencySet Class Referenceabstract

A generic FrequencySet for Full Codon alphabets. More...

#include <Bpp/Phyl/Model/FrequencySet/CodonFrequencySet.h>

+ Inheritance diagram for bpp::FullCodonFrequencySet:
+ Collaboration diagram for bpp::FullCodonFrequencySet:

Public Member Functions

 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 null. More...
 
 FullCodonFrequencySet (std::shared_ptr< const GeneticCode > gCode, const std::vector< double > &initFreqs, bool allowNullFreqs=false, unsigned short method=1, const std::string &name="Full")
 
 FullCodonFrequencySet (const FullCodonFrequencySet &fcfs)
 
FullCodonFrequencySetoperator= (const FullCodonFrequencySet &fcfs)
 
FullCodonFrequencySetclone () const override
 
std::shared_ptr< const GeneticCodegetGeneticCode () const override
 
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 equals 1. More...
 
std::shared_ptr< const CodonAlphabetgetCodonAlphabet () const override
 
void setNamespace (const std::string &nameSpace) override
 
unsigned short getMethod () const
 
virtual std::shared_ptr< const AlphabetgetAlphabet () const =0
 
virtual const Alphabetalphabet () const =0
 
virtual const StateMapInterfacestateMap () const =0
 
virtual std::shared_ptr< const StateMapInterfacegetStateMap () const =0
 
virtual const VdoublegetFrequencies () const =0
 
virtual const std::map< int, double > getAlphabetStatesFrequencies () const =0
 
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
 
virtual size_t getNumberOfIndependentParameters () const=0
 
virtual void aliasParameters (const std::string &p1, const std::string &p2)=0
 
virtual void aliasParameters (std::map< std::string, std::string > &unparsedParams, bool verbose)=0
 
virtual void unaliasParameters (const std::string &p1, const std::string &p2)=0
 
virtual const ParameterListgetIndependentParameters () const=0
 
virtual std::vector< std::string > getAlias (const std::string &name) const=0
 
virtual std::map< std::string, std::string > getAliases () const=0
 
virtual bool hasParameter (const std::string &name) const=0
 
virtual const ParameterListgetParameters () const=0
 
virtual const Parameterparameter (const std::string &name) const=0
 
virtual double getParameterValue (const std::string &name) const=0
 
virtual void setAllParametersValues (const ParameterList &parameters)=0
 
virtual void setParameterValue (const std::string &name, double value)=0
 
virtual void setParametersValues (const ParameterList &parameters)=0
 
virtual bool matchParametersValues (const ParameterList &parameters)=0
 
virtual void removeConstraint (const std::string &name)=0
 
virtual void setConstraint (const std::string &name, std::shared_ptr< ConstraintInterface > constraint)=0
 
virtual size_t getNumberOfParameters () const=0
 
virtual std::string getNamespace () const=0
 
virtual std::string getParameterNameWithoutNamespace (const std::string &name) const=0
 
std::shared_ptr< const AlphabetgetAlphabet () const override
 
const Alphabetalphabet () const override
 
const StateMapInterfacestateMap () const override
 
std::shared_ptr< const StateMapInterfacegetStateMap () const override
 
const VdoublegetFrequencies () const override
 
const std::map< int, double > getAlphabetStatesFrequencies () const override
 
void setFrequenciesFromAlphabetStatesFrequencies (const std::map< int, double > &frequencies) override
 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...
 
size_t getNumberOfFrequencies () const override
 
std::string getName () const override
 
void normalize ()
 
size_t getNumberOfIndependentParameters () const
 
void aliasParameters (const std::string &p1, const std::string &p2)
 
void aliasParameters (std::map< std::string, std::string > &unparsedParams, bool verbose)
 
void unaliasParameters (const std::string &p1, const std::string &p2)
 
const ParameterListgetIndependentParameters () const
 
virtual std::vector< std::string > getAlias (const std::string &name) const
 
virtual std::map< std::string, std::string > getAliases () const
 
bool hasParameter (const std::string &name) const override
 
const ParameterListgetParameters () const override
 
const Parameterparameter (const std::string &name) const override
 
double getParameterValue (const std::string &name) const override
 
void setAllParametersValues (const ParameterList &parameters) override
 
void setParameterValue (const std::string &name, double value) override
 
void setParametersValues (const ParameterList &parameters) override
 
bool matchParametersValues (const ParameterList &parameters) override
 
void removeConstraint (const std::string &name) override
 
void setConstraint (const std::string &name, std::shared_ptr< ConstraintInterface > constraint) override
 
size_t getNumberOfParameters () const override
 
std::string getNamespace () const override
 
std::string getParameterNameWithoutNamespace (const std::string &name) const override
 
bool hasIndependentParameter (const std::string &name) const
 
ParameterList getAliasedParameters (const ParameterList &pl) const
 
ParameterList getFromParameters (const ParameterList &pl) const
 
std::string getFrom (const std::string &name) const
 
const std::shared_ptr< Parameter > & getParameter (const std::string &name) const
 

Static Public Member Functions

static std::unique_ptr< CodonFrequencySetInterfacegetFrequencySetForCodons (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. 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 std::shared_ptr< IntervalConstraintFREQUENCE_CONSTRAINT_SMALL
 
static std::shared_ptr< IntervalConstraintFREQUENCE_CONSTRAINT_MILLI
 
static std::shared_ptr< IntervalConstraintFREQUENCE_CONSTRAINT_CENTI
 

Protected Member Functions

void fireParameterChanged (const ParameterList &parameters) override
 
void updateFreq_ ()
 
virtual ParameterListgetParameters_ ()=0
 
std::vector< double > & getFrequencies_ ()
 
double & getFreq_ (size_t i)
 
const double & getFreq_ (size_t i) const
 
void setFrequencies_ (const std::vector< double > &frequencies)
 
ParameterListgetParameters_ () override
 
const std::shared_ptr< Parameter > & getParameter (size_t i) const
 
std::shared_ptr< Parameter > & getParameter (size_t i)
 
void addParameter_ (Parameter *parameter)
 
void addParameters_ (const ParameterList &parameters)
 
void shareParameter_ (const std::shared_ptr< Parameter > &parameter)
 
void shareParameters_ (const ParameterList &parameters)
 
void includeParameters_ (const ParameterList &parameters)
 
void deleteParameter_ (size_t index)
 
void deleteParameter_ (std::string &name)
 
void deleteParameters_ (const std::vector< std::string > &names)
 
void resetParameters_ ()
 
ParametergetParameter_ (const std::string &name)
 
ParametergetParameter_ (size_t index)
 
const ParametergetParameter_ (size_t index) const
 
ParametergetParameterWithNamespace_ (const std::string &name)
 
const ParametergetParameterWithNamespace_ (const std::string &name) const
 

Protected Attributes

std::shared_ptr< const GeneticCodepgc_
 

Private Attributes

Simplex sFreq_
 Simplex to handle the probabilities and the parameters. More...
 
std::shared_ptr< const Alphabetalphabet_
 
std::shared_ptr< const StateMapInterfacestateMap_
 
std::vector< double > freq_
 
std::string name_
 
ParameterList independentParameters_
 
std::map< std::string, std::shared_ptr< AliasParameterListener > > aliasListenersRegister_
 
ParameterList parameters_
 
std::string prefix_
 

Detailed Description

A generic FrequencySet for Full Codon alphabets.

It is very similar to FullFrequencySet, but only the non-stop codon frequencies are parameterized.

Definition at line 75 of file CodonFrequencySet.h.

Constructor & Destructor Documentation

◆ FullCodonFrequencySet() [1/3]

FullCodonFrequencySet::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 null.

Definition at line 18 of file CodonFrequencySet.cpp.

References bpp::AbstractParameterAliasable::addParameters_(), bpp::Simplex::dimension(), bpp::Simplex::getParameters(), bpp::Simplex::setFrequencies(), sFreq_, and updateFreq_().

Referenced by clone().

◆ FullCodonFrequencySet() [2/3]

FullCodonFrequencySet::FullCodonFrequencySet ( std::shared_ptr< const GeneticCode gCode,
const std::vector< double > &  initFreqs,
bool  allowNullFreqs = false,
unsigned short  method = 1,
const std::string &  name = "Full" 
)

◆ FullCodonFrequencySet() [3/3]

FullCodonFrequencySet::FullCodonFrequencySet ( const FullCodonFrequencySet fcfs)

Definition at line 78 of file CodonFrequencySet.cpp.

Member Function Documentation

◆ alphabet() [1/2]

virtual const Alphabet& bpp::FrequencySetInterface::alphabet ( ) const
pure virtualinherited
Returns
The alphabet associated to this set.

Implemented in bpp::AbstractFrequencySet.

◆ alphabet() [2/2]

const Alphabet& bpp::AbstractFrequencySet::alphabet ( ) const
inlineoverridevirtualinherited
Returns
The alphabet associated to this set.

Implements bpp::FrequencySetInterface.

Definition at line 142 of file FrequencySet.h.

References bpp::AbstractFrequencySet::alphabet_.

◆ clone()

FullCodonFrequencySet* bpp::FullCodonFrequencySet::clone ( ) const
inlineoverridevirtual

Implements bpp::CodonFrequencySetInterface.

Definition at line 109 of file CodonFrequencySet.h.

References FullCodonFrequencySet().

◆ fireParameterChanged()

void FullCodonFrequencySet::fireParameterChanged ( const ParameterList parameters)
overrideprotectedvirtual

◆ getAlphabet() [1/2]

◆ getAlphabet() [2/2]

◆ getAlphabetStatesFrequencies() [1/2]

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

Implemented in bpp::AbstractFrequencySet.

◆ getAlphabetStatesFrequencies() [2/2]

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

Implements bpp::FrequencySetInterface.

Definition at line 57 of file FrequencySet.cpp.

◆ getCodonAlphabet()

std::shared_ptr<const CodonAlphabet> bpp::FullCodonFrequencySet::getCodonAlphabet ( ) const
inlineoverridevirtual

◆ getFreq_() [1/2]

◆ getFreq_() [2/2]

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

Definition at line 180 of file FrequencySet.h.

References bpp::AbstractFrequencySet::freq_.

◆ getFrequencies() [1/2]

◆ getFrequencies() [2/2]

const Vdouble& bpp::AbstractFrequencySet::getFrequencies ( ) const
inlineoverridevirtualinherited
Returns
The frequencies values of the set.

Implements bpp::FrequencySetInterface.

Definition at line 148 of file FrequencySet.h.

References bpp::AbstractFrequencySet::freq_.

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

◆ getFrequencies_()

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

Definition at line 178 of file FrequencySet.h.

References bpp::AbstractFrequencySet::freq_.

Referenced by bpp::UserFrequencySet::readFromFile_().

◆ getFrequencySetForCodons()

unique_ptr< CodonFrequencySetInterface > CodonFrequencySetInterface::getFrequencySetForCodons ( short  option,
std::shared_ptr< const GeneticCode gCode,
const std::string &  mgmtStopCodon = "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 FrequencySet instance.
mgmtStopCodonthe 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 641 of file CodonFrequencySet.cpp.

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

Referenced by bpp::BppOFrequencySetFormat::readFrequencySet().

◆ getGeneticCode()

std::shared_ptr<const GeneticCode> bpp::FullCodonFrequencySet::getGeneticCode ( ) const
inlineoverridevirtual
Returns
The associated genetic code.

Implements bpp::CodonFrequencySetInterface.

Definition at line 112 of file CodonFrequencySet.h.

References pgc_.

◆ getMethod()

unsigned short bpp::FullCodonFrequencySet::getMethod ( ) const
inline

◆ getName() [1/2]

virtual std::string bpp::FrequencySetInterface::getName ( ) const
pure virtualinherited

◆ getName() [2/2]

std::string bpp::AbstractFrequencySet::getName ( ) const
inlineoverridevirtualinherited

◆ getNumberOfFrequencies() [1/2]

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

Implemented in bpp::AbstractFrequencySet.

◆ getNumberOfFrequencies() [2/2]

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

Implements bpp::FrequencySetInterface.

Definition at line 163 of file FrequencySet.h.

References bpp::AbstractFrequencySet::freq_.

Referenced by bpp::FromModelFrequencySet::setFrequencies(), bpp::FixedFrequencySet::setFrequencies(), and bpp::UserFrequencySet::setFrequencies().

◆ getStateMap() [1/2]

virtual std::shared_ptr<const StateMapInterface> bpp::FrequencySetInterface::getStateMap ( ) const
pure virtualinherited
Returns
A shared_ptr toward the mapping of model states with alphabet states.

Implemented in bpp::AbstractFrequencySet.

◆ getStateMap() [2/2]

std::shared_ptr<const StateMapInterface> bpp::AbstractFrequencySet::getStateMap ( ) const
inlineoverridevirtualinherited
Returns
A shared_ptr toward the mapping of model states with alphabet states.

Implements bpp::FrequencySetInterface.

Definition at line 146 of file FrequencySet.h.

References bpp::AbstractFrequencySet::stateMap_.

◆ normalize()

void bpp::AbstractFrequencySet::normalize ( )
inlineinherited

◆ operator=()

FullCodonFrequencySet & FullCodonFrequencySet::operator= ( const FullCodonFrequencySet fcfs)

Definition at line 84 of file CodonFrequencySet.cpp.

References bpp::AbstractFrequencySet::operator=(), pgc_, and sFreq_.

◆ setFrequencies()

void FullCodonFrequencySet::setFrequencies ( const std::vector< double > &  frequencies)
overridevirtual

the given frequencies are normalized such that the sum of the frequencies on the non-stop codons equals 1.

Implements bpp::FrequencySetInterface.

Definition at line 99 of file CodonFrequencySet.cpp.

References bpp::AbstractFrequencySet::getAlphabet(), getCodonAlphabet(), bpp::Simplex::getParameters(), pgc_, bpp::Simplex::setFrequencies(), bpp::AbstractParameterAliasable::setParametersValues(), sFreq_, and updateFreq_().

◆ setFrequencies_()

◆ setFrequenciesFromAlphabetStatesFrequencies() [1/2]

void AbstractFrequencySet::setFrequenciesFromAlphabetStatesFrequencies ( const std::map< int, double > &  frequencies)
overridevirtualinherited

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::FrequencySetInterface.

Definition at line 28 of file FrequencySet.cpp.

◆ setFrequenciesFromAlphabetStatesFrequencies() [2/2]

virtual void bpp::FrequencySetInterface::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::AbstractFrequencySet.

Referenced by bpp::BppOFrequencySetFormat::initialize_().

◆ setNamespace()

void FullCodonFrequencySet::setNamespace ( const std::string &  nameSpace)
overridevirtual

◆ stateMap() [1/2]

virtual const StateMapInterface& bpp::FrequencySetInterface::stateMap ( ) const
pure virtualinherited
Returns
The mapping of model states with alphabet states.

Implemented in bpp::AbstractFrequencySet.

◆ stateMap() [2/2]

const StateMapInterface& bpp::AbstractFrequencySet::stateMap ( ) const
inlineoverridevirtualinherited

◆ updateFreq_()

void FullCodonFrequencySet::updateFreq_ ( )
protected

Member Data Documentation

◆ alphabet_

std::shared_ptr<const Alphabet> bpp::AbstractFrequencySet::alphabet_
privateinherited

◆ F0

const short CodonFrequencySetInterface::F0 = 0
staticinherited

◆ F1X4

const short CodonFrequencySetInterface::F1X4 = 1
staticinherited

◆ F3X4

const short CodonFrequencySetInterface::F3X4 = 2
staticinherited

◆ F61

const short CodonFrequencySetInterface::F61 = 3
staticinherited

◆ freq_

◆ FREQUENCE_CONSTRAINT_CENTI

std::shared_ptr< IntervalConstraint > FrequencySetInterface::FREQUENCE_CONSTRAINT_CENTI
staticinherited

◆ FREQUENCE_CONSTRAINT_MILLI

std::shared_ptr< IntervalConstraint > FrequencySetInterface::FREQUENCE_CONSTRAINT_MILLI
staticinherited

Definition at line 91 of file FrequencySet.h.

◆ FREQUENCE_CONSTRAINT_SMALL

std::shared_ptr< IntervalConstraint > FrequencySetInterface::FREQUENCE_CONSTRAINT_SMALL
staticinherited

◆ name_

std::string bpp::AbstractFrequencySet::name_
privateinherited

◆ pgc_

std::shared_ptr<const GeneticCode> bpp::FullCodonFrequencySet::pgc_
protected

◆ sFreq_

Simplex bpp::FullCodonFrequencySet::sFreq_
private

Simplex to handle the probabilities and the parameters.

Definition at line 86 of file CodonFrequencySet.h.

Referenced by fireParameterChanged(), FullCodonFrequencySet(), getMethod(), operator=(), setFrequencies(), setNamespace(), and updateFreq_().

◆ stateMap_

std::shared_ptr<const StateMapInterface> bpp::AbstractFrequencySet::stateMap_
privateinherited

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