forqs module reference
Forward simulation of Recombination, Quantitative traits, and Selection
 All Classes Groups Pages
MutationGeneratorImplementation.hpp
1 //
2 // MutationGeneratorImplementation.hpp
3 //
4 // Created by Darren Kessner with John Novembre
5 //
6 // Copyright (c) 2013 Regents of the University of California
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // * Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // * Neither UCLA nor the names of its contributors may be used to endorse or
20 // promote products derived from this software without specific prior
21 // written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34 
35 
36 #ifndef _MUTATIONGENERATORIMPLEMENTATION_HPP_
37 #define _MUTATIONGENERATORIMPLEMENTATION_HPP_
38 
39 
40 #include "MutationGenerator.hpp"
41 #include "Trajectory.hpp"
42 
43 
49 
50 
51 //
52 // MutationGenerator_SingleLocus
53 //
54 
55 
72 
73 
74 class MutationGenerator_SingleLocus : public MutationGenerator
75 {
76  public:
77 
78  MutationGenerator_SingleLocus(const std::string& id,
79  const Locus& locus = Locus("id_dummy"),
80  double mu = 0.)
81  : MutationGenerator(id), locus_(locus), mu_(mu)
82  {}
83 
84  virtual MutationInfos generate_mutations(const Population& population,
85  size_t generation_index,
86  size_t population_index) const;
87  // Configurable interface
88 
89  virtual std::string class_name() const {return "MutationGenerator_SingleLocus";}
90  virtual Parameters parameters() const;
91  virtual void configure(const Parameters& parameters, const Registry& registry);
92  virtual void write_child_configurations(std::ostream& os, std::set<std::string>& ids_written) const;
93 
94  private:
95 
96  Locus locus_;
97  double mu_;
98 };
99 
100 
101 //
102 // MutationGenerator_Regions
103 //
104 
105 
121 
122 
123 class MutationGenerator_Regions : public MutationGenerator
124 {
125  public:
126 
127  struct RegionInfo
128  {
129  Locus locus;
130  size_t length;
131  TrajectoryPtr mutation_rate;
132 
133  RegionInfo(const Locus& _locus = Locus("id_dummy"),
134  size_t _length = 0,
135  TrajectoryPtr _mutation_rate = TrajectoryPtr())
136  : locus(_locus), length(_length), mutation_rate(_mutation_rate)
137  {}
138 
139  std::string configuration() const;
140  };
141 
142  typedef std::vector<RegionInfo> RegionInfos;
143 
144  MutationGenerator_Regions(const std::string& id,
145  const RegionInfos& region_infos = RegionInfos())
146  : MutationGenerator(id), region_infos_(region_infos)
147  {}
148 
149  virtual MutationInfos generate_mutations(const Population& population,
150  size_t generation_index,
151  size_t population_index) const;
152  // Configurable interface
153 
154  virtual std::string class_name() const {return "MutationGenerator_Regions";}
155  virtual Parameters parameters() const;
156  virtual void configure(const Parameters& parameters, const Registry& registry);
157  virtual void write_child_configurations(std::ostream& os, std::set<std::string>& ids_written) const;
158 
159  private:
160 
161  RegionInfos region_infos_;
162 };
163 
164 
165 #endif // _MUTATIONGENERATORIMPLEMENTATION_HPP_
166