comparison egglib/egglib-2.1.5/include/egglib-cpp/Controller.hpp @ 3:345f88a8f483 draft

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