annotate egglib/egglib-2.1.5/include/egglib-cpp/Mutator.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, 2012 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_MUTATOR_HPP
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
21 #define EGGLIB_MUTATOR_HPP
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
22
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
23
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
24 #include "DataMatrix.hpp"
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
25 #include "Random.hpp"
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
26 #include "Arg.hpp"
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
27 #include "Mutation.hpp"
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
28
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
29
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
30 namespace egglib {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
31
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
32
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
33 /** \brief Implements mutation models
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
34 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
35 * \ingroup coalesce
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
36 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
37 * Works with a previously built Ancestral Reconbination Graph. The
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
38 * user must sets options using the setter-based interface. After
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
39 * that he or she can call the method mute() that will generates
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
40 * a DataMatrix object.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
41 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
42 * Genotype data are represented by integer numbers. Regardless of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
43 * the mutation model, the ancestral state is always 0. The user can
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
44 * set the rate of mutation (or, alternatively, fix the number of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
45 * mutations that occurred - which is the number of segregating sites
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
46 * only with an infinite site model).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
47 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
48 * Other options fall into two separate groups: the positions of the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
49 * mutated sites and the process of mutation (how new alleles are
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
50 * generated).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
51 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
52 * Concerning allele generation, several mutation models are available
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
53 * (coded by single letters):
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
54 * - F: fixed number of alleles. Among other markers, this model is
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
55 * appropriate for simulating nucleotides. The user is able
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
56 * to choose the number of alleles (where 2 is the standard
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
57 * for an infinite site model and 4 for a finite site model).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
58 * Mutator allows assigning independent weights between all
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
59 * different transition types and can draw randomly the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
60 * ancestral states, providing a way to emulate evolution of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
61 * nucleotides with multiple mutations at the same site and
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
62 * reversion.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
63 * - I: infinite number of alleles. At a given site, each mutation
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
64 * raises a new allele. The value of the alleles is therefore
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
65 * irrelevant (it only denotes its order of appearance). This
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
66 * model does not permit homoplasy.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
67 * - S: stepwise mutation model. In this model the value of the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
68 * alleles are interpreted as a size (typically for simulating
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
69 * a microsatellite marker). Each mutation either increases
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
70 * or decreases the allele size by an increment of one.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
71 * - T: two-phase mutation model. This model is a generalization
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
72 * of the stepwise mutation model (S). For a mutation, the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
73 * increment (either increase or decrease) is 1 with the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
74 * probability given by the parameter (1-TPMproba). With
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
75 * probability TPMproba, the increment is drawn from a
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
76 * geometric distribution of parameter given by the other
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
77 * parameter (TPMparam).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
78 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
79 * By default, the program will assume an infinite site model (ISM).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
80 * Each mutation will occur to a new position drawn from the interval
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
81 * [0,1]. It is possible to set any mutation model with an ISM
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
82 * (including microsatellite-like models I, S and T). Alternatively,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
83 * the user can specify a finite number of sites available for
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
84 * mutation. For a microsatellite marker, the user will want to
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
85 * specify a single site. It is possible to set a finite number of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
86 * sites for all mutation models. In all cases, the mutations will
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
87 * be forced to target these sites. It is possible to apply weights
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
88 * independently to all sites. The higher the weight value
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
89 * (comparatively to the other sites), the higher the probability
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
90 * that this site mutes. The weights needs not to be relative. In
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
91 * addition, the user can set the positions of the different sites.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
92 * Nothings forces him or her to place them in order. Note that this
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
93 * does not affect the mutation process, but on the amount of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
94 * recombination that will be allowed between sites.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
95 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
96 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
97 class Mutator {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
98
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
99 public:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
100
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
101 /** \brief Initializes with default values
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
102 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
103 * List of default values:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
104 * - theta = 0
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
105 * - fixedNumberOfMutations = 0
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
106 * - model = F (fixed number of alleles)
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
107 * - fixed number of alleles = 2
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
108 * - infinite site model
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
109 * - TPM parameters are both preset to 0.5
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
110 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
111 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
112 Mutator();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
113
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
114
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
115 /** \brief Destroys the object
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
116 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
117 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
118 ~Mutator();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
119
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
120
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
121 /** \brief Copy constructor
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
122 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
123 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
124 Mutator(const Mutator&);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
125
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
126
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
127 /** \brief Assignement operator
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
128 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
129 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
130 Mutator& operator=(const Mutator&);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
131
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
132
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
133 /** \brief Restores default values of all parameters
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
134 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
135 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
136 void reset();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
137
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
138
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
139 /** \brief Gets the fixed number of mutations
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
140 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
141 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
142 unsigned int fixedNumberOfMutations() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
143
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
144
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
145 /** \brief Sets the fixed number of mutations
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
146 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
147 * The value can be 0. It is not allowed to set both the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
148 * fixed number of mutations and the mutation rate at
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
149 * non-zero value
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
150 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
151 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
152 void fixedNumberOfMutations(unsigned int);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
153
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
154
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
155 /** \brief Gets the mutation rate
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
156 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
157 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
158 double mutationRate() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
159
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
160
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
161 /** \brief Sets the mutation rate
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
162 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
163 * The value cannot be negative. The value can be 0. It is
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
164 * not allowed to set both the fixed number of mutations and
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
165 * the mutation rate at non-zero value
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
166 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
167 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
168 void mutationRate(double);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
169
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
170
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
171 /** \brief Gets the mutation model
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
172 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
173 * See the class documentation for the signification of the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
174 * different one-letter codes.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
175 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
176 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
177 char mutationModel() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
178
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
179
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
180 /** \brief Sets the mutation model
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
181 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
182 * The passed character must be one of F, I, S and T. See the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
183 * class documentation for their signification.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
184 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
185 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
186 void mutationModel(char);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
187
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
188
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
189 /** \brief Gets the fixed number of possible alleles
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
190 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
191 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
192 unsigned int numberOfAlleles() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
193
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
194
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
195 /** \brief Sets the fixed number of possible alleles
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
196 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
197 * The value must be larger than 1. This parameter is
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
198 * meaningful only for the fixed number allele model of
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
199 * mutation, and ignored otherwise.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
200 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
201 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
202 void numberOfAlleles(unsigned int);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
203
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
204
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
205 /** \brief Sets a transition weight
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
206 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
207 * \param i row (previous allele index).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
208 * \param j column (next allele index).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
209 * \param value weight to apply.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
210 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
211 * Indices i and j must be different. Weights can be any
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
212 * strictly positive value.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
213 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
214 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
215 void transitionWeight(unsigned int i, unsigned int j, double value);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
216
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
217
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
218 /** \brief Gets a transition weight
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
219 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
220 * \param i row (previous allele index).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
221 * \param j column (next allele index).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
222 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
223 * Indices i and j must be different.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
224 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
225 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
226 double transitionWeight(unsigned int i, unsigned int j);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
227
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
228
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
229 /** \brief Set to true to draw ancestral alleles randomly
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
230 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
231 * By default, the ancestral allele is always 0. If this
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
232 * variable is set to true, the ancestral allele will be
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
233 * randomly drawn from the defined number of alleles. This
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
234 * option is always ignored unless in combination with the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
235 * Fixed Allele Number model.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
236 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
237 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
238 void randomAncestralAllele(bool flag);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
239
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
240
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
241 /** \brief true if ancestral alleles must be drawn randomly
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
242 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
243 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
244 bool randomAncestralAllele() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
245
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
246
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
247 /** \brief Gets the TPM probability parameter
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
248 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
249 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
250 double TPMproba() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
251
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
252
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
253 /** \brief Sets the TPM probability parameter
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
254 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
255 * This parameter is considered only if the mutation model
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
256 * is T (two-phase mutation model). It gives the probability
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
257 * that a mutation step is not fixed to be 1. If TPMproba is
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
258 * 0, the mutation model is SMM.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
259 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
260 * The value must be >=0. and <=1.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
261 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
262 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
263 void TPMproba(double value);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
264
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
265
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
266 /** \brief Gets the TPM distribution parameter
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
267 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
268 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
269 double TPMparam() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
270
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
271
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
272 /** \brief Sets the TPM distribution parameter
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
273 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
274 * This parameter is considered only if the mutation model
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
275 * is T (two-phase mutation model). It gives the parameter
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
276 * of the geometric distribution which is used to generate
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
277 * the mutation step (if it is not one).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
278 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
279 * The value must be >=0. and <=1.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
280 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
281 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
282 void TPMparam(double value);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
283
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
284
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
285 /** \brief Gets the number of mutable sites
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
286 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
287 * A value a zero must be interpreted as the infinite site
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
288 * model. Note that after all calls all data from the tables
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
289 * sitePositions and siteWeights will be reset.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
290 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
291 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
292 unsigned int numberOfSites() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
293
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
294
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
295 /** \brief Sets the number of mutable sites
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
296 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
297 * The value of zero is accepted and imposed the infinite
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
298 * site model.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
299 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
300 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
301 void numberOfSites(unsigned int);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
302
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
303
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
304 /** \brief Gets the position of a given site
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
305 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
306 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
307 double sitePosition(unsigned int siteIndex) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
308
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
309
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
310 /** \brief Set the position of a given site
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
311 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
312 * The position must be >=0 and <=1
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
313 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
314 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
315 void sitePosition(unsigned int siteIndex, double position);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
316
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
317
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
318 /** \brief Gets the mutation weight of a given site
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
319 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
320 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
321 double siteWeight(unsigned int siteIndex) const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
322
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
323
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
324 /** \brief Set the site weight of a given site
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
325 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
326 * The weight must be strictly positive.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
327 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
328 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
329 void siteWeight(unsigned int siteIndex, double weight);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
330
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
331
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
332 /** \brief Performs mutation
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
333 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
334 * \param arg Ancestral recombination graph instance. If the
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
335 * ARG is partially built or not a all, or improperly so,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
336 * the behaviour of this method is not defined.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
337 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
338 * \param random The address of a Random instance to be
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
339 * used for generating random numbers.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
340 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
341 * \return A DataMatrix instance containing simulated data.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
342 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
343 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
344 DataMatrix mute(Arg* arg, Random* random);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
345
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
346
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
347 /** \brief Gets the last number of mutations
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
348 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
349 * Returns the number of mutations of the last call of mute( ).
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
350 * By default, this method returns 0.
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
351 *
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
352 */
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
353 unsigned int numberOfMutations() const;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
354
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
355
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
356 private:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
357
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
358 void clear();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
359 void init();
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
360 void copy(const Mutator&);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
361
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
362 //int nextAllele(int allele, Random* random);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
363 int TPMstep(double inTPMproba, Random* random);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
364 void apply_mutation(unsigned int matrixIndex,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
365 unsigned int actualSite, DataMatrix& data,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
366 const Edge* edge, int allele,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
367 unsigned int segment, Random* random);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
368
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
369
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
370 char _model;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
371 double _mutationRate;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
372 unsigned int _fixedNumberOfMutations;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
373 unsigned int _numberOfAlleles;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
374 double** _transitionWeights;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
375 bool _randomAncestralAllele;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
376 unsigned int _numberOfSites;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
377 double* _sitePositions;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
378 double* _siteWeights;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
379 double _TPMproba;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
380 double _TPMparam;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
381 int maxAllele;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
382 unsigned int _numberOfMutations;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
383 std::vector<Mutation> _cache_mutations;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
384 unsigned int _cache_mutations_reserved;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
385
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
386 };
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
387
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
388
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
389 bool compare(Mutation mutation1, Mutation mutation2); // returns True if mutation1 is older
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
390
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
391 }
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
392
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
393
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
394
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
395
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
396 #endif
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
397