bpp-phyl3 3.0.0
GivenDataSubstitutionProcessSequenceSimulator.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
5#ifndef BPP_PHYL_SIMULATION_GIVENDATASUBSTITUTIONPROCESSSEQUENCESIMULATOR_H
6#define BPP_PHYL_SIMULATION_GIVENDATASUBSTITUTIONPROCESSSEQUENCESIMULATOR_H
7
8
10#include "SequenceSimulator.h"
11
12namespace bpp
13{
19 public virtual SequenceSimulatorInterface
20{
21private:
22 std::shared_ptr<LikelihoodCalculationSingleProcess> calcul_;
23
24 /*
25 * @brief Vector of site specific site simulators on SHRUNKED data
26 *
27 * More efficient implementation is possible (all in ona).
28 *
29 */
30
31 std::vector<std::shared_ptr<GivenDataSubstitutionProcessSiteSimulator>> vSiteSim_;
32
33 /*
34 * @brief Vector of branch indexes where the data is not used, and
35 * substitution probabilities are computed from the prior process.
36 *
37 */
38
39 std::vector<uint> vPriorBranch_;
40
41public:
42 GivenDataSubstitutionProcessSequenceSimulator(std::shared_ptr<LikelihoodCalculationSingleProcess> calcul, std::vector<uint> vPrior = std::vector<uint>()) :
43 calcul_(calcul), vSiteSim_(), vPriorBranch_(vPrior)
44 {
45 for (size_t i = 0; i < calcul_->getNumberOfDistinctSites(); i++)
46 {
47 vSiteSim_.push_back(std::make_shared<GivenDataSubstitutionProcessSiteSimulator>(calcul_, i, true, vPriorBranch_));
48 }
49 }
50
52 {}
53
56 {}
57
59 {
61 }
62
63public:
69 std::unique_ptr<SiteContainerInterface> simulate() const
70 {
71 return simulate(calcul_->getNumberOfSites());
72 }
73
74 std::unique_ptr<SiteContainerInterface> simulate(size_t numberOfSites) const override;
75
76 const SiteSimulatorInterface& siteSimulator(size_t pos) const override
77 {
78
79 return *vSiteSim_[calcul_->getRootArrayPosition(pos)];
80 }
81
87 std::shared_ptr<const Alphabet> getAlphabet() const override
88 {
89 return vSiteSim_[0]->getAlphabet();
90 }
91
92 const Alphabet& alphabet() const override
93 {
94 return vSiteSim_[0]->alphabet();
95 }
96
97 std::vector<std::string> getSequenceNames() const override
98 {
99 return vSiteSim_[0]->getSequenceNames();
100 }
101
105 size_t getNumberOfSites() const
106 {
107 return calcul_->getNumberOfSites();
108 }
109
118 void outputInternalSequences(bool yn) override
119 {
120 for (auto& siteSim : vSiteSim_)
121 {
122 siteSim->outputInternalSites(yn);
123 }
124 }
125};
126} // end of namespace bpp.
127#endif // BPP_PHYL_SIMULATION_GIVENDATASUBSTITUTIONPROCESSSEQUENCESIMULATOR_H
Sequences simulation under a unique substitution process, but with site specific posterior probabilit...
GivenDataSubstitutionProcessSequenceSimulator(std::shared_ptr< LikelihoodCalculationSingleProcess > calcul, std::vector< uint > vPrior=std::vector< uint >())
void outputInternalSequences(bool yn) override
Sets whether we will output the internal sequences or not.
std::vector< std::shared_ptr< GivenDataSubstitutionProcessSiteSimulator > > vSiteSim_
GivenDataSubstitutionProcessSequenceSimulator(const GivenDataSubstitutionProcessSequenceSimulator &nhss)
GivenDataSubstitutionProcessSequenceSimulator * clone() const override
const SiteSimulatorInterface & siteSimulator(size_t pos) const override
std::shared_ptr< LikelihoodCalculationSingleProcess > calcul_
The SequenceSimulator interface. SequenceSimulator classes can simulate whole datasets.
The SiteSimulator interface. SiteSimulator classes can simulate single sites.
Definition: SiteSimulator.h:24
Defines the basic types of data flow nodes.