5 #ifndef _NONHOMOGENEOUSSEQUENCESIMULATOR_H_
6 #define _NONHOMOGENEOUSSEQUENCESIMULATOR_H_
8 #include "../../Simulation/DetailedSiteSimulator.h"
9 #include "../../Simulation/SequenceSimulator.h"
10 #include "../../Tree/TreeTemplate.h"
11 #include "../../Tree/NodeTemplate.h"
12 #include "../../Model/SubstitutionModel.h"
13 #include "../../Likelihood/ParametrizablePhyloTree.h"
27 #include "../Model/SubstitutionModelSet.h"
37 std::shared_ptr<const TransitionModelInterface>
model;
67 std::shared_ptr<const SubstitutionModelSet>
modelSet_;
70 std::shared_ptr<const DiscreteDistributionInterface>
rate_;
73 mutable std::shared_ptr<const ParametrizablePhyloTree>
phyloTree_;
100 std::shared_ptr<const SubstitutionModelSet> modelSet,
101 std::shared_ptr<const DiscreteDistributionInterface> rate,
102 std::shared_ptr<const Tree>
tree
106 std::shared_ptr<const TransitionModelInterface> model,
107 std::shared_ptr<const DiscreteDistributionInterface> rate,
108 std::shared_ptr<const Tree>
tree
138 std::unique_ptr<Site>
simulateSite(
size_t ancestralStateIndex)
const override;
140 std::unique_ptr<Site>
simulateSite(
size_t ancestralStateIndex,
double rate)
const override;
142 std::unique_ptr<Site>
simulateSite(
double rate)
const override;
153 std::unique_ptr<SiteSimulationResult>
dSimulateSite()
const override;
155 std::unique_ptr<SiteSimulationResult>
dSimulateSite(
size_t ancestralStateIndex)
const override;
157 std::unique_ptr<SiteSimulationResult>
dSimulateSite(
size_t ancestralStateIndex,
double rate)
const override;
159 std::unique_ptr<SiteSimulationResult>
dSimulateSite(
double rate)
const override;
167 std::unique_ptr<SiteContainerInterface>
simulate(
size_t numberOfSites)
const override;
171 throw Exception(
"NonHomogeneousSequenceSimulator::siteSimulator: not implemented.");
190 virtual std::unique_ptr<Site>
simulateSite(
size_t ancestralStateIndex,
size_t rateClass)
const;
191 virtual std::unique_ptr<SiteSimulationResult>
dSimulateSite(
size_t ancestralStateIndex,
size_t rateClass)
const;
254 throw Exception(
"NonHomogeneousSequenceSimulator::outputInternalSites: not implemented.");
264 size_t evolve(
const SNode* node,
size_t initialStateIndex,
size_t rateClass)
const;
272 size_t evolve(
const SNode* node,
size_t initialStateIndex,
double rate)
const;
281 const std::vector<size_t>& initialStateIndices,
282 const std::vector<size_t>& rateClasses,
283 std::vector<size_t>& finalStates)
const;
286 const std::vector<size_t>& initialStates,
287 const std::vector<size_t>& rateClasses)
const;
This interface adds the dSimulate method to the SiteSimulator interface.
(Legacy) Site and sequences simulation under non-homogeneous models.
std::shared_ptr< const Alphabet > alphabet_
bool outputInternalSequences_
NonHomogeneousSequenceSimulator * clone() const override
std::vector< int > supportedStates_
NonHomogeneousSequenceSimulator & operator=(const NonHomogeneousSequenceSimulator &nhss)=default
const SubstitutionModelSet & substitutionModelSet() const
Get the substitution model associated to this instance.
std::shared_ptr< const Tree > getTree() const
Get the tree associated to this instance.
const DiscreteDistributionInterface & rateDistribution() const
Get the rate distribution associated to this instance.
std::vector< std::string > seqNames_
std::vector< std::string > getSequenceNames() const override
std::shared_ptr< const SubstitutionModelSet > modelSet_
std::unique_ptr< SiteContainerInterface > simulate(size_t numberOfSites) const override
std::shared_ptr< const DiscreteDistributionInterface > rate_
const SiteSimulatorInterface & siteSimulator(size_t pos) const override
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.
std::unique_ptr< Site > simulateSite() const override
std::shared_ptr< const Alphabet > getAlphabet() const override
void outputInternalSequences(bool yn) override
Sets whether we will output the internal sequences or not.
void multipleEvolveInternal(SNode *node, const std::vector< size_t > &rateClasses) const
const Tree & tree() const
Get the tree associated to this instance.
std::shared_ptr< const DiscreteDistributionInterface > getRateDistribution() const
Get the rate distribution associated to this instance.
std::vector< SNode * > leaves_
This stores once for all all leaves in a given order. This order will be used during site creation.
void dEvolve(size_t initialState, double rate, RASiteSimulationResult &rassr) const
std::shared_ptr< const Tree > templateTree_
void dEvolveInternal(SNode *node, double rate, RASiteSimulationResult &rassr) const
NonHomogeneousSequenceSimulator(std::shared_ptr< const SubstitutionModelSet > modelSet, std::shared_ptr< const DiscreteDistributionInterface > rate, std::shared_ptr< const Tree > tree)
std::shared_ptr< const SubstitutionModelSet > getSubstitutionModelSet() const
Get the substitution model associated to this instance.
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.
void init()
Init all probabilities.
const Alphabet & alphabet() const override
std::unique_ptr< SiteSimulationResult > dSimulateSite() const override
Get a detailed simulation result for one site.
NonHomogeneousSequenceSimulator(const NonHomogeneousSequenceSimulator &nhss)=default
void enableContinuousRates(bool yn)
Enable the use of continuous rates instead of discrete rates.
void outputInternalSites(bool yn) override
std::shared_ptr< const ParametrizablePhyloTree > phyloTree_
virtual ~NonHomogeneousSequenceSimulator()
void evolveInternal(SNode *node, size_t rateClass) const
TreeTemplate< SNode > tree_
Data structure to store the result of a DetailedSiteSimulator.
The SequenceSimulator interface. SequenceSimulator classes can simulate whole datasets.
SimData(const SimData &sd)
std::vector< size_t > states
std::shared_ptr< const TransitionModelInterface > model
SimData & operator=(const SimData &sd)
The SiteSimulator interface. SiteSimulator classes can simulate single sites.
Substitution models manager for non-homogeneous / non-reversible models of evolution.
The phylogenetic tree class.
Interface for phylogenetic tree objects.
Defines the basic types of data flow nodes.
NodeTemplate< SimData > SNode
std::vector< VVdouble > VVVdouble