bpp-phyl3  3.0.0
bpp::NonHomogeneousSequenceSimulator Class Reference

(Legacy) Site and sequences simulation under non-homogeneous models. More...

#include <Bpp/Phyl/Legacy/Simulation/NonHomogeneousSequenceSimulator.h>

+ Inheritance diagram for bpp::NonHomogeneousSequenceSimulator:
+ Collaboration diagram for bpp::NonHomogeneousSequenceSimulator:

Public Member Functions

std::shared_ptr< const SubstitutionModelSetgetSubstitutionModelSet () const
 Get the substitution model associated to this instance. More...
 
const SubstitutionModelSetsubstitutionModelSet () const
 Get the substitution model associated to this instance. More...
 
std::shared_ptr< const DiscreteDistributionInterfacegetRateDistribution () const
 Get the rate distribution associated to this instance. More...
 
const DiscreteDistributionInterfacerateDistribution () const
 Get the rate distribution associated to this instance. More...
 
std::shared_ptr< const TreegetTree () const
 Get the tree associated to this instance. More...
 
const Treetree () const
 Get the tree associated to this instance. More...
 
void enableContinuousRates (bool yn)
 Enable the use of continuous rates instead of discrete rates. More...
 
void outputInternalSequences (bool yn) override
 Sets whether we will output the internal sequences or not. More...
 
void outputInternalSites (bool yn) override
 
The SiteSimulator interface
std::unique_ptr< SitesimulateSite () const override
 
std::unique_ptr< SitesimulateSite (size_t ancestralStateIndex) const override
 
std::unique_ptr< SitesimulateSite (size_t ancestralStateIndex, double rate) const override
 
std::unique_ptr< SitesimulateSite (double rate) const override
 
std::vector< std::string > getSequenceNames () const override
 
The DetailedSiteSimulator interface.
std::unique_ptr< SiteSimulationResultdSimulateSite () const override
 Get a detailed simulation result for one site. More...
 
std::unique_ptr< SiteSimulationResultdSimulateSite (size_t ancestralStateIndex) const override
 
std::unique_ptr< SiteSimulationResultdSimulateSite (size_t ancestralStateIndex, double rate) const override
 
std::unique_ptr< SiteSimulationResultdSimulateSite (double rate) const override
 
The SequenceSimulator interface
std::unique_ptr< SiteContainerInterfacesimulate (size_t numberOfSites) const override
 
const SiteSimulatorInterfacesiteSimulator (size_t pos) const override
 
SiteSimulator and SequenceSimulator interface
std::shared_ptr< const AlphabetgetAlphabet () const override
 
const Alphabetalphabet () const override
 
Functions with rate classes instead of absolute rates.
virtual std::unique_ptr< SitesimulateSite (size_t ancestralStateIndex, size_t rateClass) const
 
virtual std::unique_ptr< SiteSimulationResultdSimulateSite (size_t ancestralStateIndex, size_t rateClass) const
 

Protected Member Functions

size_t evolve (const SNode *node, size_t initialStateIndex, size_t rateClass) const
 Evolve from an initial state along a branch, knowing the evolutionary rate class. More...
 
size_t evolve (const SNode *node, size_t initialStateIndex, double rate) const
 Evolve from an initial state along a branch, knowing the evolutionary rate. More...
 
void multipleEvolve (const SNode *node, const std::vector< size_t > &initialStateIndices, const std::vector< size_t > &rateClasses, std::vector< size_t > &finalStates) const
 The same as the evolve(initialState, rateClass) function, but for several sites at a time. More...
 
std::unique_ptr< SiteContainerInterfacemultipleEvolve (const std::vector< size_t > &initialStates, const std::vector< size_t > &rateClasses) const
 
void dEvolve (size_t initialState, double rate, RASiteSimulationResult &rassr) const
 
The 'Internal' methods.
void evolveInternal (SNode *node, size_t rateClass) const
 
void evolveInternal (SNode *node, double rate) const
 
void multipleEvolveInternal (SNode *node, const std::vector< size_t > &rateClasses) const
 
void dEvolveInternal (SNode *node, double rate, RASiteSimulationResult &rassr) const
 

Private Attributes

std::shared_ptr< const SubstitutionModelSetmodelSet_
 
std::shared_ptr< const Alphabetalphabet_
 
std::vector< int > supportedStates_
 
std::shared_ptr< const DiscreteDistributionInterfacerate_
 
std::shared_ptr< const TreetemplateTree_
 
TreeTemplate< SNodetree_
 
std::shared_ptr< const ParametrizablePhyloTreephyloTree_
 
std::vector< SNode * > leaves_
 This stores once for all all leaves in a given order. This order will be used during site creation. More...
 
std::vector< std::string > seqNames_
 
size_t nbNodes_
 
size_t nbClasses_
 
size_t nbStates_
 
bool continuousRates_
 
bool outputInternalSequences_
 

Stores intermediate results.

 NonHomogeneousSequenceSimulator (std::shared_ptr< const SubstitutionModelSet > modelSet, std::shared_ptr< const DiscreteDistributionInterface > rate, std::shared_ptr< const Tree > tree)
 
 NonHomogeneousSequenceSimulator (std::shared_ptr< const TransitionModelInterface > model, std::shared_ptr< const DiscreteDistributionInterface > rate, std::shared_ptr< const Tree > tree)
 
virtual ~NonHomogeneousSequenceSimulator ()
 
 NonHomogeneousSequenceSimulator (const NonHomogeneousSequenceSimulator &nhss)=default
 
NonHomogeneousSequenceSimulatoroperator= (const NonHomogeneousSequenceSimulator &nhss)=default
 
NonHomogeneousSequenceSimulatorclone () const override
 
void init ()
 Init all probabilities. More...
 

Detailed Description

(Legacy) Site and sequences simulation under non-homogeneous models.

Former class maintained for backward compatibility only. The old class has been ported to the new interfaces, but some methods are left unimplemented.

Rate across sites variation is supported, using a DiscreteDistribution object or by specifying explicitly the rate of the sites to simulate.

Definition at line 62 of file NonHomogeneousSequenceSimulator.h.

Constructor & Destructor Documentation

◆ NonHomogeneousSequenceSimulator() [1/3]

NonHomogeneousSequenceSimulator::NonHomogeneousSequenceSimulator ( std::shared_ptr< const SubstitutionModelSet modelSet,
std::shared_ptr< const DiscreteDistributionInterface rate,
std::shared_ptr< const Tree tree 
)

Definition at line 22 of file NonHomogeneousSequenceSimulator.cpp.

References init(), and tree().

Referenced by clone().

◆ NonHomogeneousSequenceSimulator() [2/3]

NonHomogeneousSequenceSimulator::NonHomogeneousSequenceSimulator ( std::shared_ptr< const TransitionModelInterface model,
std::shared_ptr< const DiscreteDistributionInterface rate,
std::shared_ptr< const Tree tree 
)

◆ ~NonHomogeneousSequenceSimulator()

virtual bpp::NonHomogeneousSequenceSimulator::~NonHomogeneousSequenceSimulator ( )
inlinevirtual

Definition at line 111 of file NonHomogeneousSequenceSimulator.h.

◆ NonHomogeneousSequenceSimulator() [3/3]

bpp::NonHomogeneousSequenceSimulator::NonHomogeneousSequenceSimulator ( const NonHomogeneousSequenceSimulator nhss)
default

Member Function Documentation

◆ alphabet()

const Alphabet& bpp::NonHomogeneousSequenceSimulator::alphabet ( ) const
inlineoverridevirtual

Implements bpp::SequenceSimulatorInterface.

Definition at line 182 of file NonHomogeneousSequenceSimulator.h.

References alphabet_.

◆ clone()

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

◆ dEvolve()

void NonHomogeneousSequenceSimulator::dEvolve ( size_t  initialState,
double  rate,
RASiteSimulationResult rassr 
) const
protected

◆ dEvolveInternal()

◆ dSimulateSite() [1/5]

std::unique_ptr< SiteSimulationResult > NonHomogeneousSequenceSimulator::dSimulateSite ( ) const
overridevirtual

Get a detailed simulation result for one site.

Returns
A SiteSimulationResult object with all ancestral states for all nodes and branches.

Implements bpp::DetailedSiteSimulatorInterface.

Definition at line 332 of file NonHomogeneousSequenceSimulator.cpp.

References bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), modelSet_, and nbStates_.

Referenced by dSimulateSite().

◆ dSimulateSite() [2/5]

unique_ptr< SiteSimulationResult > NonHomogeneousSequenceSimulator::dSimulateSite ( double  rate) const
overridevirtual

◆ dSimulateSite() [3/5]

std::unique_ptr< SiteSimulationResult > NonHomogeneousSequenceSimulator::dSimulateSite ( size_t  ancestralStateIndex) const
overridevirtual

◆ dSimulateSite() [4/5]

unique_ptr< SiteSimulationResult > NonHomogeneousSequenceSimulator::dSimulateSite ( size_t  ancestralStateIndex,
double  rate 
) const
overridevirtual

◆ dSimulateSite() [5/5]

unique_ptr< SiteSimulationResult > NonHomogeneousSequenceSimulator::dSimulateSite ( size_t  ancestralStateIndex,
size_t  rateClass 
) const
virtual

Definition at line 382 of file NonHomogeneousSequenceSimulator.cpp.

References dSimulateSite(), and rate_.

◆ enableContinuousRates()

void bpp::NonHomogeneousSequenceSimulator::enableContinuousRates ( bool  yn)
inline

Enable the use of continuous rates instead of discrete rates.

To work, the DiscreteDistribution object used should implement the randC method.

Parameters
ynTell if we should use continuous rates.

Definition at line 243 of file NonHomogeneousSequenceSimulator.h.

References continuousRates_.

◆ evolve() [1/2]

size_t NonHomogeneousSequenceSimulator::evolve ( const SNode node,
size_t  initialStateIndex,
double  rate 
) const
protected

Evolve from an initial state along a branch, knowing the evolutionary rate.

This method is slower than the previous one since exponential terms must be computed. This method is used for the implementation of the SiteSimulator interface.

Definition at line 424 of file NonHomogeneousSequenceSimulator.cpp.

References bpp::Node::getDistanceToFather(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), nbStates_, bpp::MatrixTools::print(), and bpp::TextTools::toString().

◆ evolve() [2/2]

size_t NonHomogeneousSequenceSimulator::evolve ( const SNode node,
size_t  initialStateIndex,
size_t  rateClass 
) const
protected

Evolve from an initial state along a branch, knowing the evolutionary rate class.

This method is fast since all pijt have been computed in the constructor of the class. This method is used for the implementation of the SiteSimulator interface.

Definition at line 410 of file NonHomogeneousSequenceSimulator.cpp.

References bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), nbStates_, and bpp::TextTools::toString().

Referenced by evolveInternal().

◆ evolveInternal() [1/2]

void NonHomogeneousSequenceSimulator::evolveInternal ( SNode node,
double  rate 
) const
protected

◆ evolveInternal() [2/2]

void NonHomogeneousSequenceSimulator::evolveInternal ( SNode node,
size_t  rateClass 
) const
protected

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::NonHomogeneousSequenceSimulator::getAlphabet ( ) const
inlineoverridevirtual

Implements bpp::SequenceSimulatorInterface.

Definition at line 180 of file NonHomogeneousSequenceSimulator.h.

References alphabet_.

◆ getRateDistribution()

std::shared_ptr<const DiscreteDistributionInterface> bpp::NonHomogeneousSequenceSimulator::getRateDistribution ( ) const
inline

Get the rate distribution associated to this instance.

Returns
The DiscreteDistribution object associated to this instance.

Definition at line 213 of file NonHomogeneousSequenceSimulator.h.

References rate_.

◆ getSequenceNames()

std::vector<std::string> bpp::NonHomogeneousSequenceSimulator::getSequenceNames ( ) const
inlineoverridevirtual

Implements bpp::SequenceSimulatorInterface.

Definition at line 144 of file NonHomogeneousSequenceSimulator.h.

References seqNames_.

◆ getSubstitutionModelSet()

std::shared_ptr<const SubstitutionModelSet> bpp::NonHomogeneousSequenceSimulator::getSubstitutionModelSet ( ) const
inline

Get the substitution model associated to this instance.

Returns
The substitution model associated to this instance.

Definition at line 199 of file NonHomogeneousSequenceSimulator.h.

References modelSet_.

◆ getTree()

std::shared_ptr<const Tree> bpp::NonHomogeneousSequenceSimulator::getTree ( ) const
inline

Get the tree associated to this instance.

Returns
The Tree object associated to this instance.

Definition at line 227 of file NonHomogeneousSequenceSimulator.h.

References templateTree_.

◆ init()

void NonHomogeneousSequenceSimulator::init ( )
private

◆ multipleEvolve() [1/2]

void NonHomogeneousSequenceSimulator::multipleEvolve ( const SNode node,
const std::vector< size_t > &  initialStateIndices,
const std::vector< size_t > &  rateClasses,
std::vector< size_t > &  finalStates 
) const
protected

The same as the evolve(initialState, rateClass) function, but for several sites at a time.

This method is used for the implementation of the SequenceSimulator interface.

Definition at line 442 of file NonHomogeneousSequenceSimulator.cpp.

References bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), and nbStates_.

Referenced by multipleEvolveInternal(), and simulate().

◆ multipleEvolve() [2/2]

unique_ptr< SiteContainerInterface > NonHomogeneousSequenceSimulator::multipleEvolve ( const std::vector< size_t > &  initialStates,
const std::vector< size_t > &  rateClasses 
) const
protected

◆ multipleEvolveInternal()

void NonHomogeneousSequenceSimulator::multipleEvolveInternal ( SNode node,
const std::vector< size_t > &  rateClasses 
) const
protected

◆ operator=()

NonHomogeneousSequenceSimulator& bpp::NonHomogeneousSequenceSimulator::operator= ( const NonHomogeneousSequenceSimulator nhss)
default

◆ outputInternalSequences()

void NonHomogeneousSequenceSimulator::outputInternalSequences ( bool  yn)
overridevirtual

Sets whether we will output the internal sequences or not.

Parameters
ynTell if we should output internal sequences.

Implements bpp::SequenceSimulatorInterface.

Definition at line 626 of file NonHomogeneousSequenceSimulator.cpp.

References leaves_, outputInternalSequences_, seqNames_, bpp::TextTools::toString(), and tree_.

◆ outputInternalSites()

void bpp::NonHomogeneousSequenceSimulator::outputInternalSites ( bool  yn)
inlineoverridevirtual

Implements bpp::SiteSimulatorInterface.

Definition at line 252 of file NonHomogeneousSequenceSimulator.h.

◆ rateDistribution()

const DiscreteDistributionInterface& bpp::NonHomogeneousSequenceSimulator::rateDistribution ( ) const
inline

Get the rate distribution associated to this instance.

Returns
The DiscreteDistribution object associated to this instance.

Definition at line 220 of file NonHomogeneousSequenceSimulator.h.

References rate_.

◆ simulate()

unique_ptr< SiteContainerInterface > NonHomogeneousSequenceSimulator::simulate ( size_t  numberOfSites) const
overridevirtual

◆ simulateSite() [1/5]

unique_ptr< Site > NonHomogeneousSequenceSimulator::simulateSite ( ) const
overridevirtual

◆ simulateSite() [2/5]

unique_ptr< Site > NonHomogeneousSequenceSimulator::simulateSite ( double  rate) const
overridevirtual

◆ simulateSite() [3/5]

unique_ptr< Site > NonHomogeneousSequenceSimulator::simulateSite ( size_t  ancestralStateIndex) const
overridevirtual

◆ simulateSite() [4/5]

std::unique_ptr< Site > NonHomogeneousSequenceSimulator::simulateSite ( size_t  ancestralStateIndex,
double  rate 
) const
overridevirtual

◆ simulateSite() [5/5]

std::unique_ptr< Site > NonHomogeneousSequenceSimulator::simulateSite ( size_t  ancestralStateIndex,
size_t  rateClass 
) const
virtual

◆ siteSimulator()

const SiteSimulatorInterface& bpp::NonHomogeneousSequenceSimulator::siteSimulator ( size_t  pos) const
inlineoverridevirtual

◆ substitutionModelSet()

const SubstitutionModelSet& bpp::NonHomogeneousSequenceSimulator::substitutionModelSet ( ) const
inline

Get the substitution model associated to this instance.

Returns
The substitution model associated to this instance.

Definition at line 206 of file NonHomogeneousSequenceSimulator.h.

References modelSet_.

◆ tree()

const Tree& bpp::NonHomogeneousSequenceSimulator::tree ( ) const
inline

Get the tree associated to this instance.

Returns
The Tree object associated to this instance.

Definition at line 234 of file NonHomogeneousSequenceSimulator.h.

References templateTree_.

Referenced by NonHomogeneousSequenceSimulator().

Member Data Documentation

◆ alphabet_

std::shared_ptr<const Alphabet> bpp::NonHomogeneousSequenceSimulator::alphabet_
mutableprivate

◆ continuousRates_

bool bpp::NonHomogeneousSequenceSimulator::continuousRates_
private

◆ leaves_

std::vector<SNode*> bpp::NonHomogeneousSequenceSimulator::leaves_
private

This stores once for all all leaves in a given order. This order will be used during site creation.

Definition at line 79 of file NonHomogeneousSequenceSimulator.h.

Referenced by init(), multipleEvolve(), outputInternalSequences(), and simulateSite().

◆ modelSet_

std::shared_ptr<const SubstitutionModelSet> bpp::NonHomogeneousSequenceSimulator::modelSet_
private

◆ nbClasses_

size_t bpp::NonHomogeneousSequenceSimulator::nbClasses_
private

Definition at line 84 of file NonHomogeneousSequenceSimulator.h.

Referenced by init().

◆ nbNodes_

size_t bpp::NonHomogeneousSequenceSimulator::nbNodes_
private

Definition at line 83 of file NonHomogeneousSequenceSimulator.h.

Referenced by init(), multipleEvolve(), and simulateSite().

◆ nbStates_

size_t bpp::NonHomogeneousSequenceSimulator::nbStates_
private

◆ outputInternalSequences_

bool bpp::NonHomogeneousSequenceSimulator::outputInternalSequences_
private

◆ phyloTree_

std::shared_ptr<const ParametrizablePhyloTree> bpp::NonHomogeneousSequenceSimulator::phyloTree_
mutableprivate

Definition at line 73 of file NonHomogeneousSequenceSimulator.h.

Referenced by dSimulateSite().

◆ rate_

std::shared_ptr<const DiscreteDistributionInterface> bpp::NonHomogeneousSequenceSimulator::rate_
private

◆ seqNames_

std::vector<std::string> bpp::NonHomogeneousSequenceSimulator::seqNames_
private

◆ supportedStates_

std::vector<int> bpp::NonHomogeneousSequenceSimulator::supportedStates_
private

Definition at line 69 of file NonHomogeneousSequenceSimulator.h.

◆ templateTree_

std::shared_ptr<const Tree> bpp::NonHomogeneousSequenceSimulator::templateTree_
private

◆ tree_

TreeTemplate<SNode> bpp::NonHomogeneousSequenceSimulator::tree_
mutableprivate

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