Egglib 2.1.11
C++ library reference manual
Mutator.hpp
1 /*
2  Copyright 2009, 2010, 2012 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_MUTATOR_HPP
21 #define EGGLIB_MUTATOR_HPP
22 
23 
24 #include "DataMatrix.hpp"
25 #include "Random.hpp"
26 #include "Arg.hpp"
27 #include "Mutation.hpp"
28 
29 
30 namespace egglib {
31 
32 
97  class Mutator {
98 
99  public:
100 
112  Mutator();
113 
114 
118  ~Mutator();
119 
120 
124  Mutator(const Mutator&);
125 
126 
130  Mutator& operator=(const Mutator&);
131 
132 
136  void reset();
137 
138 
142  unsigned int fixedNumberOfMutations() const;
143 
144 
152  void fixedNumberOfMutations(unsigned int);
153 
154 
158  double mutationRate() const;
159 
160 
168  void mutationRate(double);
169 
170 
177  char mutationModel() const;
178 
179 
186  void mutationModel(char);
187 
188 
192  unsigned int numberOfAlleles() const;
193 
194 
202  void numberOfAlleles(unsigned int);
203 
204 
215  void transitionWeight(unsigned int i, unsigned int j, double value);
216 
217 
226  double transitionWeight(unsigned int i, unsigned int j);
227 
228 
238  void randomAncestralAllele(bool flag);
239 
240 
244  bool randomAncestralAllele() const;
245 
246 
250  double TPMproba() const;
251 
252 
263  void TPMproba(double value);
264 
265 
269  double TPMparam() const;
270 
271 
282  void TPMparam(double value);
283 
284 
292  unsigned int numberOfSites() const;
293 
294 
301  void numberOfSites(unsigned int);
302 
303 
307  double sitePosition(unsigned int siteIndex) const;
308 
309 
315  void sitePosition(unsigned int siteIndex, double position);
316 
317 
321  double siteWeight(unsigned int siteIndex) const;
322 
323 
329  void siteWeight(unsigned int siteIndex, double weight);
330 
331 
344  DataMatrix mute(Arg* arg, Random* random);
345 
346 
353  unsigned int numberOfMutations() const;
354 
355 
356  private:
357 
358  void clear();
359  void init();
360  void copy(const Mutator&);
361 
362  //int nextAllele(int allele, Random* random);
363  int TPMstep(double inTPMproba, Random* random);
364  void apply_mutation(unsigned int matrixIndex,
365  unsigned int actualSite, DataMatrix& data,
366  const Edge* edge, int allele,
367  unsigned int segment, Random* random);
368 
369 
370  char _model;
371  double _mutationRate;
372  unsigned int _fixedNumberOfMutations;
373  unsigned int _numberOfAlleles;
374  double** _transitionWeights;
375  bool _randomAncestralAllele;
376  unsigned int _numberOfSites;
377  double* _sitePositions;
378  double* _siteWeights;
379  double _TPMproba;
380  double _TPMparam;
381  int maxAllele;
382  unsigned int _numberOfMutations;
383  std::vector<Mutation> _cache_mutations;
384  unsigned int _cache_mutations_reserved;
385 
386  };
387 
388 
389  bool compare(Mutation mutation1, Mutation mutation2); // returns True if mutation1 is older
390 
391 }
392 
393 
394 
395 
396 #endif
397 
Pseudo-random number generator.
Definition: Random.hpp:41
Mutator & operator=(const Mutator &)
Assignement operator.
Definition: Mutator.cpp:45
void transitionWeight(unsigned int i, unsigned int j, double value)
Sets a transition weight.
Definition: Mutator.cpp:200
double siteWeight(unsigned int siteIndex) const
Gets the mutation weight of a given site.
Definition: Mutator.cpp:291
Data table.
Definition: DataMatrix.hpp:41
~Mutator()
Destroys the object.
Definition: Mutator.cpp:34
void reset()
Restores default values of all parameters.
Definition: Mutator.cpp:53
unsigned int fixedNumberOfMutations() const
Gets the fixed number of mutations.
Definition: Mutator.cpp:119
double mutationRate() const
Gets the mutation rate.
Definition: Mutator.cpp:137
Implements mutation models.
Definition: Mutator.hpp:97
Mutator()
Initializes with default values.
Definition: Mutator.cpp:29
char mutationModel() const
Gets the mutation model.
Definition: Mutator.cpp:149
double sitePosition(unsigned int siteIndex) const
Gets the position of a given site.
Definition: Mutator.cpp:278
double TPMparam() const
Gets the TPM distribution parameter.
Definition: Mutator.cpp:688
Edge of the ancestral recombination graph.
Definition: Edge.hpp:49
unsigned int numberOfSites() const
Gets the number of mutable sites.
Definition: Mutator.cpp:217
Definition: ABC.cpp:37
bool randomAncestralAllele() const
true if ancestral alleles must be drawn randomly
Definition: Mutator.cpp:207
unsigned int numberOfAlleles() const
Gets the fixed number of possible alleles.
Definition: Mutator.cpp:160
Very simple container of some information relative to a mutation.
Definition: Mutation.hpp:33
DataMatrix mute(Arg *arg, Random *random)
Performs mutation.
Definition: Mutator.cpp:306
double TPMproba() const
Gets the TPM probability parameter.
Definition: Mutator.cpp:683
Ancestral recombination graph.
Definition: Arg.hpp:60
unsigned int numberOfMutations() const
Gets the last number of mutations.
Definition: Mutator.cpp:124

Hosted by 
Get EggLib at SourceForge.net. Fast, secure and Free Open Source software downloads