bpp-phyl3
3.0.0
|
(Legacy) Site and sequences simulation under non-homogeneous models. More...
#include <Bpp/Phyl/Legacy/Simulation/NonHomogeneousSequenceSimulator.h>
Public Member Functions | |
std::shared_ptr< const SubstitutionModelSet > | getSubstitutionModelSet () const |
Get the substitution model associated to this instance. More... | |
const SubstitutionModelSet & | substitutionModelSet () const |
Get the substitution model associated to this instance. More... | |
std::shared_ptr< const DiscreteDistributionInterface > | getRateDistribution () const |
Get the rate distribution associated to this instance. More... | |
const DiscreteDistributionInterface & | rateDistribution () const |
Get the rate distribution associated to this instance. More... | |
std::shared_ptr< const Tree > | getTree () const |
Get the tree associated to this instance. More... | |
const Tree & | tree () 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< Site > | simulateSite () const override |
std::unique_ptr< Site > | simulateSite (size_t ancestralStateIndex) const override |
std::unique_ptr< Site > | simulateSite (size_t ancestralStateIndex, double rate) const override |
std::unique_ptr< Site > | simulateSite (double rate) const override |
std::vector< std::string > | getSequenceNames () const override |
The DetailedSiteSimulator interface. | |
std::unique_ptr< SiteSimulationResult > | dSimulateSite () const override |
Get a detailed simulation result for one site. More... | |
std::unique_ptr< SiteSimulationResult > | dSimulateSite (size_t ancestralStateIndex) const override |
std::unique_ptr< SiteSimulationResult > | dSimulateSite (size_t ancestralStateIndex, double rate) const override |
std::unique_ptr< SiteSimulationResult > | dSimulateSite (double rate) const override |
The SequenceSimulator interface | |
std::unique_ptr< SiteContainerInterface > | simulate (size_t numberOfSites) const override |
const SiteSimulatorInterface & | siteSimulator (size_t pos) const override |
SiteSimulator and SequenceSimulator interface | |
std::shared_ptr< const Alphabet > | getAlphabet () const override |
const Alphabet & | alphabet () const override |
Functions with rate classes instead of absolute rates. | |
virtual std::unique_ptr< Site > | simulateSite (size_t ancestralStateIndex, size_t rateClass) const |
virtual std::unique_ptr< SiteSimulationResult > | dSimulateSite (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< SiteContainerInterface > | multipleEvolve (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 SubstitutionModelSet > | modelSet_ |
std::shared_ptr< const Alphabet > | alphabet_ |
std::vector< int > | supportedStates_ |
std::shared_ptr< const DiscreteDistributionInterface > | rate_ |
std::shared_ptr< const Tree > | templateTree_ |
TreeTemplate< SNode > | tree_ |
std::shared_ptr< const ParametrizablePhyloTree > | phyloTree_ |
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 | |
NonHomogeneousSequenceSimulator & | operator= (const NonHomogeneousSequenceSimulator &nhss)=default |
NonHomogeneousSequenceSimulator * | clone () const override |
void | init () |
Init all probabilities. More... | |
(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.
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::NonHomogeneousSequenceSimulator | ( | std::shared_ptr< const TransitionModelInterface > | model, |
std::shared_ptr< const DiscreteDistributionInterface > | rate, | ||
std::shared_ptr< const Tree > | tree | ||
) |
Definition at line 48 of file NonHomogeneousSequenceSimulator.cpp.
References bpp::SubstitutionModelSetTools::createHomogeneousModelSet(), init(), modelSet_, and templateTree_.
|
inlinevirtual |
Definition at line 111 of file NonHomogeneousSequenceSimulator.h.
|
default |
|
inlineoverridevirtual |
Implements bpp::SequenceSimulatorInterface.
Definition at line 182 of file NonHomogeneousSequenceSimulator.h.
References alphabet_.
|
inlineoverridevirtual |
Implements bpp::DetailedSiteSimulatorInterface.
Definition at line 117 of file NonHomogeneousSequenceSimulator.h.
References NonHomogeneousSequenceSimulator().
|
protected |
Definition at line 585 of file NonHomogeneousSequenceSimulator.cpp.
References dEvolveInternal(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::getNumberOfSons(), bpp::NodeTemplate< NodeInfos >::getSon(), and tree_.
Referenced by dSimulateSite().
|
protected |
This method uses the states_ variable for saving ancestral states.
Definition at line 598 of file NonHomogeneousSequenceSimulator.cpp.
References bpp::SiteSimulationResult::addNode(), bpp::AbstractMutationProcess::detailedEvolve(), bpp::Node::getDistanceToFather(), bpp::NodeTemplate< NodeInfos >::getFather(), bpp::MutationPath::getFinalState(), bpp::Node::getId(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::getNumberOfSons(), bpp::NodeTemplate< NodeInfos >::getSon(), and bpp::Node::hasFather().
Referenced by dEvolve().
|
overridevirtual |
Get a detailed simulation result for one site.
Implements bpp::DetailedSiteSimulatorInterface.
Definition at line 332 of file NonHomogeneousSequenceSimulator.cpp.
References bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), modelSet_, and nbStates_.
Referenced by dSimulateSite().
|
overridevirtual |
Implements bpp::DetailedSiteSimulatorInterface.
Definition at line 389 of file NonHomogeneousSequenceSimulator.cpp.
References dSimulateSite(), bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), modelSet_, and nbStates_.
|
overridevirtual |
Implements bpp::DetailedSiteSimulatorInterface.
Definition at line 354 of file NonHomogeneousSequenceSimulator.cpp.
References continuousRates_, dSimulateSite(), and rate_.
|
overridevirtual |
Implements bpp::DetailedSiteSimulatorInterface.
Definition at line 372 of file NonHomogeneousSequenceSimulator.cpp.
References dEvolve(), modelSet_, and phyloTree_.
|
virtual |
Definition at line 382 of file NonHomogeneousSequenceSimulator.cpp.
References dSimulateSite(), and rate_.
|
inline |
Enable the use of continuous rates instead of discrete rates.
To work, the DiscreteDistribution object used should implement the randC method.
yn | Tell if we should use continuous rates. |
Definition at line 243 of file NonHomogeneousSequenceSimulator.h.
References continuousRates_.
|
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().
|
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().
|
protected |
This method uses the states_ variable for saving ancestral states.
Definition at line 482 of file NonHomogeneousSequenceSimulator.cpp.
References evolve(), evolveInternal(), bpp::NodeTemplate< NodeInfos >::getFather(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::getNumberOfSons(), bpp::NodeTemplate< NodeInfos >::getSon(), and bpp::Node::hasFather().
|
protected |
This method uses the states_ variable for saving ancestral states.
Definition at line 466 of file NonHomogeneousSequenceSimulator.cpp.
References evolve(), bpp::NodeTemplate< NodeInfos >::getFather(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::getNumberOfSons(), bpp::NodeTemplate< NodeInfos >::getSon(), and bpp::Node::hasFather().
Referenced by evolveInternal(), and simulateSite().
|
inlineoverridevirtual |
Implements bpp::SequenceSimulatorInterface.
Definition at line 180 of file NonHomogeneousSequenceSimulator.h.
References alphabet_.
|
inline |
Get the rate distribution associated to this instance.
Definition at line 213 of file NonHomogeneousSequenceSimulator.h.
References rate_.
|
inlineoverridevirtual |
Implements bpp::SequenceSimulatorInterface.
Definition at line 144 of file NonHomogeneousSequenceSimulator.h.
References seqNames_.
|
inline |
Get the substitution model associated to this instance.
Definition at line 199 of file NonHomogeneousSequenceSimulator.h.
References modelSet_.
|
inline |
Get the tree associated to this instance.
Definition at line 227 of file NonHomogeneousSequenceSimulator.h.
References templateTree_.
|
private |
Init all probabilities.
Method called by constructors.
Definition at line 75 of file NonHomogeneousSequenceSimulator.cpp.
References bpp::Node::getDistanceToFather(), bpp::Node::getId(), bpp::NodeTemplate< NodeInfos >::getInfos(), leaves_, modelSet_, nbClasses_, nbNodes_, nbStates_, outputInternalSequences_, rate_, seqNames_, bpp::TextTools::toString(), and tree_.
Referenced by NonHomogeneousSequenceSimulator().
|
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().
|
protected |
Definition at line 517 of file NonHomogeneousSequenceSimulator.cpp.
References alphabet_, bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::getNumberOfSons(), bpp::NodeTemplate< NodeInfos >::getSon(), leaves_, multipleEvolveInternal(), nbNodes_, outputInternalSequences_, bpp::TextTools::toString(), and tree_.
|
protected |
This method uses the multipleStates_ variable for saving ancestral states.
Definition at line 498 of file NonHomogeneousSequenceSimulator.cpp.
References bpp::NodeTemplate< NodeInfos >::getFather(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::getNumberOfSons(), bpp::NodeTemplate< NodeInfos >::getSon(), bpp::Node::hasFather(), and multipleEvolve().
Referenced by multipleEvolve().
|
default |
|
overridevirtual |
Sets whether we will output the internal sequences or not.
yn | Tell 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_.
|
inlineoverridevirtual |
Implements bpp::SiteSimulatorInterface.
Definition at line 252 of file NonHomogeneousSequenceSimulator.h.
|
inline |
Get the rate distribution associated to this instance.
Definition at line 220 of file NonHomogeneousSequenceSimulator.h.
References rate_.
|
overridevirtual |
Implements bpp::SequenceSimulatorInterface.
Definition at line 285 of file NonHomogeneousSequenceSimulator.cpp.
References alphabet_, continuousRates_, bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), modelSet_, multipleEvolve(), nbStates_, rate_, seqNames_, and simulateSite().
|
overridevirtual |
Implements bpp::SiteSimulatorInterface.
Definition at line 134 of file NonHomogeneousSequenceSimulator.cpp.
References bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), modelSet_, and nbStates_.
Referenced by simulate(), and simulateSite().
|
overridevirtual |
Implements bpp::SiteSimulatorInterface.
Definition at line 263 of file NonHomogeneousSequenceSimulator.cpp.
References bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), modelSet_, nbStates_, and simulateSite().
|
overridevirtual |
Implements bpp::SiteSimulatorInterface.
Definition at line 155 of file NonHomogeneousSequenceSimulator.cpp.
References continuousRates_, rate_, and simulateSite().
|
overridevirtual |
Implements bpp::SiteSimulatorInterface.
Definition at line 219 of file NonHomogeneousSequenceSimulator.cpp.
References alphabet_, evolveInternal(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::getNumberOfSons(), bpp::NodeTemplate< NodeInfos >::getSon(), leaves_, nbNodes_, outputInternalSequences_, and tree_.
|
virtual |
Definition at line 175 of file NonHomogeneousSequenceSimulator.cpp.
References alphabet_, evolveInternal(), bpp::NodeTemplate< NodeInfos >::getInfos(), bpp::Node::getNumberOfSons(), bpp::NodeTemplate< NodeInfos >::getSon(), leaves_, nbNodes_, outputInternalSequences_, and tree_.
|
inlineoverridevirtual |
Implements bpp::SequenceSimulatorInterface.
Definition at line 169 of file NonHomogeneousSequenceSimulator.h.
|
inline |
Get the substitution model associated to this instance.
Definition at line 206 of file NonHomogeneousSequenceSimulator.h.
References modelSet_.
|
inline |
Get the tree associated to this instance.
Definition at line 234 of file NonHomogeneousSequenceSimulator.h.
References templateTree_.
Referenced by NonHomogeneousSequenceSimulator().
|
mutableprivate |
Definition at line 68 of file NonHomogeneousSequenceSimulator.h.
Referenced by alphabet(), getAlphabet(), multipleEvolve(), simulate(), and simulateSite().
|
private |
Definition at line 87 of file NonHomogeneousSequenceSimulator.h.
Referenced by dSimulateSite(), enableContinuousRates(), simulate(), and simulateSite().
|
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().
|
private |
Definition at line 67 of file NonHomogeneousSequenceSimulator.h.
Referenced by dSimulateSite(), getSubstitutionModelSet(), init(), NonHomogeneousSequenceSimulator(), simulate(), simulateSite(), and substitutionModelSet().
|
private |
Definition at line 84 of file NonHomogeneousSequenceSimulator.h.
Referenced by init().
|
private |
Definition at line 83 of file NonHomogeneousSequenceSimulator.h.
Referenced by init(), multipleEvolve(), and simulateSite().
|
private |
Definition at line 85 of file NonHomogeneousSequenceSimulator.h.
Referenced by dSimulateSite(), evolve(), init(), multipleEvolve(), simulate(), and simulateSite().
|
private |
Definition at line 90 of file NonHomogeneousSequenceSimulator.h.
Referenced by init(), multipleEvolve(), outputInternalSequences(), and simulateSite().
|
mutableprivate |
Definition at line 73 of file NonHomogeneousSequenceSimulator.h.
Referenced by dSimulateSite().
|
private |
Definition at line 70 of file NonHomogeneousSequenceSimulator.h.
Referenced by dSimulateSite(), getRateDistribution(), init(), rateDistribution(), simulate(), and simulateSite().
|
private |
Definition at line 81 of file NonHomogeneousSequenceSimulator.h.
Referenced by getSequenceNames(), init(), outputInternalSequences(), and simulate().
|
private |
Definition at line 69 of file NonHomogeneousSequenceSimulator.h.
|
private |
Definition at line 71 of file NonHomogeneousSequenceSimulator.h.
Referenced by getTree(), NonHomogeneousSequenceSimulator(), and tree().
|
mutableprivate |
Definition at line 72 of file NonHomogeneousSequenceSimulator.h.
Referenced by dEvolve(), init(), multipleEvolve(), outputInternalSequences(), and simulateSite().