annotate egglib/egglib-2.1.5/include/egglib-cpp/Controller.hpp @ 15:31c23d943c29 draft default tip

Uploaded
author dereeper
date Tue, 08 Jan 2019 08:47:56 -0500
parents 420b57c3c185
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
1 /*
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
2 Copyright 2009-2010 Stéphane De Mita, Mathieu Siol
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
3
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
4 This file is part of the EggLib library.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
5
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
6 EggLib is free software: you can redistribute it and/or modify
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
8 the Free Software Foundation, either version 3 of the License, or
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
9 (at your option) any later version.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
10
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
11 EggLib is distributed in the hope that it will be useful,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
14 GNU General Public License for more details.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
15
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
17 along with EggLib. If not, see <http://www.gnu.org/licenses/>.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
18 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
19
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
20 #ifndef EGGLIB_CONTROLLER_HPP
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
21 #define EGGLIB_CONTROLLER_HPP
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
22
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
23 #include "Current.hpp"
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
24 #include "Arg.hpp"
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
25 #include "ParamSet.hpp"
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
26
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
27 namespace egglib {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
28
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
29 class Random;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
30
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
31 /** \brief Controls a coalescent simulation
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
32 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
33 * \ingroup coalesce
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
34 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
35 * This class generates the gene genealogy, based on the parameters
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
36 * stocked in a ParamSet object.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
37 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
38 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
39 class Controller {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
40
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
41 public:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
42
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
43 /** \brief Default constructor
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
44 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
45 * Uses a default ParamSet object that will not allow
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
46 * performing simulations.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
47 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
48 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
49 Controller();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
50
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
51 /** \brief Destructor
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
52 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
53 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
54 ~Controller();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
55
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
56 /** \brief Standard constructor
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
57 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
58 * \param paramSet a ParamSet object containing run
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
59 * parameters (it is taken as a reference and stored as this
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
60 * so it must not be modified during simulations).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
61 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
62 * \param random the address of the random number generator.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
63 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
64 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
65 Controller(const ParamSet* paramSet, Random* random);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
66
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
67 /** \brief Reset for a new simulation
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
68 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
69 * Object is reinitiliazed for a new simulation.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
70 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
71 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
72 void reset();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
73
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
74 /** \brief Increments the coalescent model
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
75 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
76 * \return The number of lineages.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
77 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
78 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
79 unsigned int step();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
80
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
81 /** \brief Gets the Ancestral Recombination Graph
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
82 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
83 * \return The address of the ARG contained in the object.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
84 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
85 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
86 Arg* getArg();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
87
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
88 /** \brief Applies a bottleneck to a given population
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
89 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
90 * The bottleneck is applied following Galtier, Depaulis and
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
91 * Barton (Genetics, 2000): the general time counter is
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
92 * stopped, and coalescence events are performed during a
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
93 * time (of normal coalescent process) given by the parameter
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
94 * strength. All coalescent events are instantaneous.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
95 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
96 * \param populationIndex index of the population concerned
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
97 * by the event.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
98 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
99 * \param strength strength of the bottleneck given by a
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
100 * number of time units (2N generations times the size of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
101 * the population).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
102 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
103 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
104 void bottleneck(unsigned int populationIndex, double strength);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
105
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
106 /** \brief Migrate a complete population
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
107 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
108 * Takes all the lineages currently present in the population
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
109 * source to the population dest.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
110 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
111 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
112 void moveAllLineages(unsigned int source, unsigned int dest);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
113
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
114 /** \brief Migrate a complete population
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
115 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
116 * Takes all the lineages currently present in the population
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
117 * source to the population dest.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
118 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
119 * \param source source population.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
120 * \param dest destination population.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
121 * \param probability the probability that a lineage of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
122 * source migrates to dest.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
123 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
124 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
125 void moveSomeLineages(unsigned int source, unsigned int dest, double probability);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
126
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
127 /// Adds an empty population
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
128 void addPopulation();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
129
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
130 private:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
131
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
132 /// The copy constructor is disabled
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
133 Controller(const Controller& source) {}
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
134
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
135 /// The assignment operator is disabled
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
136 Controller& operator=(const Controller& source) {return *this;}
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
137
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
138 void diploids();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
139 double getMigrationTime(double& migrationParameterDestination);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
140 void getCoalescenceTime(double& destTime, unsigned int& destPopIndex);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
141 double getCoalescenceTimeForPopulation(unsigned int populationIndex);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
142 double getRecombinationTime() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
143 void migrate(double migrationParameter);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
144
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
145 const ParamSet* initialParamSet;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
146 ParamSet paramSet;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
147 Current current;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
148 Arg arg;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
149
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
150 Random* random;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
151
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
152 };
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
153
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
154 }
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
155
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
156 #endif