Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
ttdispersal.h
Go to the documentation of this file.
1
30#ifndef TTDISPERSALGENE_H
31#define TTDISPERSALGENE_H
32
33#include "ttrait.h"
34#include "types.h"
35#include "stathandler.h"
36#include "metapop.h"
37#include "binarystoragebuffer.h"
38
39class TTDispersalSH;
40class TProtoDispersal;
41
43class TTDispersal : public TTrait
44{
47 double _mut_rate;
49 double _mut_mean;
54
56
60// trait_t _type;
62 double _sequence[2];
63 double _phenotype;
64
65public:
67 TTDispersal (sex_t sex);
70 _init_rate_mal(TP._init_rate_mal), _myProto(TP._myProto), _gender(TP._gender), _phenotype(0) //, _type(TP._type)
71 {}
72 virtual ~TTDispersal () { }
73
76 void set_mut_rate (double val) {_mut_rate = val;}
77 void set_mut_mean (double val) {_mut_mean = val;}
78 void set_init_rate_fem (double val) {_init_rate_fem = val;}
79 void set_init_rate_mal (double val) {_init_rate_mal = val;}
80 void set_gender (sex_t val) {_gender = val;}
81// void set_type (trait_t val) {_type = val;}
86 virtual void init ( ) { _sequence[0] = 0.0; _sequence[1] = 0.0; }
87 virtual void init_sequence ( );
88 virtual void reset ( ) {init();}
89 virtual void inherit (TTrait* mother, TTrait* father);
90 virtual void mutate ( );
91 virtual trait_t get_type ( ) const {return (_gender == FEM ? FDISP : MDISP);}
92 virtual void set_value ( ) {_phenotype = (_sequence[0] + _sequence[1])/2.0;}
94 virtual void* getValue ( ) const {return (void*)&_phenotype;}
96 virtual void** get_sequence ( ) const {return 0;}
97 virtual double get_allele_value (int loc, int all) {return ( !(all<2) ? 0 : _sequence[all] );}
98 virtual void set_allele_value (unsigned int locus, unsigned int allele, double value)
99 {assert(allele < 2); _sequence[allele] = value;}
100 virtual void set_sequence (void** seq) { }
101 virtual void* set_trait (void* value) {return value;}
102 virtual void show_up ( );
103 virtual TTDispersal* clone ( ) {return new TTDispersal(*this);}
104 virtual TTDispersal& operator= (const TTrait& TP);
105 virtual bool operator== (const TTrait& TP);
106 virtual bool operator!= (const TTrait& TP);
107
108 //implements StorableComponent:
109 virtual void store_data (BinaryStorageBuffer* saver) {saver->store(&_sequence, 2 * sizeof(double));}
110 virtual bool retrieve_data (BinaryStorageBuffer* reader) {reader->read(&_sequence, 2 * sizeof(double));return true;}
112};
113// ------------------------------------------------------------------------------
114
115// TProtoDispersal
116
117// ------------------------------------------------------------------------------
120public:
123 virtual ~TProtoDispersal();
124 //implements TraitPrototype:
125 virtual void init (){}
126 virtual void reset (){}
127 virtual TTDispersal* hatch ();
128 virtual TProtoDispersal* clone () {return new TProtoDispersal(*this);}
129 virtual trait_t get_type () const {return (_gender == FEM ? FDISP : MDISP);}
130 //implements StorableComponent:
131 virtual void store_data (BinaryStorageBuffer* saver) {saver->store(&_gender, sizeof(sex_t));}
132 virtual bool retrieve_data (BinaryStorageBuffer* reader) {reader->read(&_gender, sizeof(sex_t));return true;}
133 //implements SimComponent:
134 virtual bool setParameters();
135 virtual void loadFileServices ( FileServices* loader ) {}
136 virtual void loadStatServices ( StatServices* loader );
137 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
138
139 bool setNonRandom ();
140 bool setRandom ();
141
142 bool get_init_mode () {return _init_random;}
144 string get_init_dist () {return _init_dist;}
145
146private:
148 double _mut_rate;
150 double _mut_mean;
155
159
163// trait_t _type;
166};
167
168// ------------------------------------------------------------------------------
169
170// TTDispersalSH
171
172// ------------------------------------------------------------------------------
174class TTDispersalSH: public StatHandler<TTDispersalSH> {
175
177
179
181
182public:
183
186
187 virtual ~TTDispersalSH ( ) { }
188 virtual void init ( )
189 {
193 }
194
195 virtual bool setStatRecorders (std::string& token);
196
197 void addDispPerPatch (sex_t SEX, age_t AGE);
198
199 double getmeanOFD () {return _meanOffFemDisp;}
200 double getmeanOMD () {return _meanOffMalDisp;}
201 double getmeanFD () {return _meanFemDisp;}
202 double getmeanMD () {return _meanMalDisp;}
203 double getMeanDispRate ();
204 double getOffsprgMeanDispRate ();
205 double getMeanDispRate (sex_t sex);
206 double getOffsprgMeanDispRate (sex_t sex);
207 double getMeanFemDispRate ();
208 double getMeanMalDispRate ();
209 double getMeanDispRateInPatch (sex_t SEX, age_idx age, unsigned int traitidx, unsigned int i);
210
211 double getPatchDisp_OF (unsigned int patch)
212 {
213 return getMeanDispRateInPatch(FEM, OFFSx, _fdispIdx, patch);
214 }
215
216 double getPatchDisp_OM (unsigned int patch)
217 {
218 return getMeanDispRateInPatch(MAL, OFFSx, _mdispIdx, patch);
219 }
220
221 double getPatchDisp_AF (unsigned int patch)
222 {
223 return getMeanDispRateInPatch(FEM, ADLTx, _fdispIdx, patch);
224 }
225
226 double getPatchDisp_AM (unsigned int patch)
227 {
228 return getMeanDispRateInPatch(MAL, ADLTx, _mdispIdx, patch);
229 }
230};
231#endif //TTDISPERSALGENE_H
232
A class to store any kind of data in a char buffer before unloading it in a binary data file.
Definition: binarystoragebuffer.h:44
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:162
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:52
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:45
virtual void init()
Definition: stathandler.cc:39
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
A class to compute and store the summary statistics associated with a SimComponent.
Definition: stathandler.h:110
The Service class used to manage the StatHandler objects.
Definition: statservices.h:50
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
Prototype of the evolving dispersal trait, defines the sex-specific trait type.
Definition: ttdispersal.h:119
TTDispersalSH * _stats
The trait's type.
Definition: ttdispersal.h:165
TMatrix * get_init_dist_params()
Definition: ttdispersal.h:143
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:154
bool get_init_mode()
Definition: ttdispersal.h:142
virtual void loadFileServices(FileServices *loader)
Definition: ttdispersal.h:135
string _init_dist
Definition: ttdispersal.h:156
bool setNonRandom()
Definition: ttdispersal.cc:120
string get_init_dist()
Definition: ttdispersal.h:144
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:161
virtual void reset()
Definition: ttdispersal.h:126
double _mut_mean
Mean mutation step.
Definition: ttdispersal.h:150
virtual TTDispersal * hatch()
Definition: ttdispersal.cc:190
bool _init_random
Definition: ttdispersal.h:158
virtual TProtoDispersal * clone()
Definition: ttdispersal.h:128
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:152
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: ttdispersal.h:137
TMatrix _init_dist_param
Definition: ttdispersal.h:157
virtual trait_t get_type() const
Definition: ttdispersal.h:129
virtual bool setParameters()
Definition: ttdispersal.cc:78
virtual void store_data(BinaryStorageBuffer *saver)
Definition: ttdispersal.h:131
bool setRandom()
Definition: ttdispersal.cc:151
virtual void loadStatServices(StatServices *loader)
Definition: ttdispersal.cc:180
virtual ~TProtoDispersal()
Definition: ttdispersal.cc:71
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:148
virtual bool retrieve_data(BinaryStorageBuffer *reader)
Definition: ttdispersal.h:132
virtual void init()
Definition: ttdispersal.h:125
The StatHandler for the evolving dispersal traits.
Definition: ttdispersal.h:174
double getMeanMalDispRate()
Definition: stats_disp.cc:189
virtual ~TTDispersalSH()
Definition: ttdispersal.h:187
int _mdispIdx
Definition: ttdispersal.h:180
int _fdispIdx
Definition: ttdispersal.h:180
double getPatchDisp_AF(unsigned int patch)
Definition: ttdispersal.h:221
double getMeanDispRate()
Definition: stats_disp.cc:56
double getPatchDisp_OF(unsigned int patch)
Definition: ttdispersal.h:211
double _meanOffMalDisp
Definition: ttdispersal.h:178
virtual bool setStatRecorders(std::string &token)
Definition: ttdispersal.cc:358
TProtoDispersal * _trait
Definition: ttdispersal.h:176
void addDispPerPatch(sex_t SEX, age_t AGE)
Definition: ttdispersal.cc:419
double getOffsprgMeanDispRate()
Definition: stats_disp.cc:105
double getmeanOFD()
Definition: ttdispersal.h:199
double _meanMalDisp
Definition: ttdispersal.h:178
double getmeanFD()
Definition: ttdispersal.h:201
double _meanOffFemDisp
Definition: ttdispersal.h:178
double getMeanDispRateInPatch(sex_t SEX, age_idx age, unsigned int traitidx, unsigned int i)
Definition: stats_disp.cc:39
double getMeanFemDispRate()
Definition: stats_disp.cc:170
double getmeanOMD()
Definition: ttdispersal.h:200
virtual void init()
Definition: ttdispersal.h:188
double getPatchDisp_AM(unsigned int patch)
Definition: ttdispersal.h:226
double getPatchDisp_OM(unsigned int patch)
Definition: ttdispersal.h:216
double getmeanMD()
Definition: ttdispersal.h:202
TTDispersalSH(TProtoDispersal *TT)
Definition: ttdispersal.h:184
double _meanFemDisp
Definition: ttdispersal.h:178
Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispe...
Definition: ttdispersal.h:44
void set_mut_mean(double val)
Definition: ttdispersal.h:77
void set_init_rate_fem(double val)
Definition: ttdispersal.h:78
void set_proto(TProtoDispersal *P)
Definition: ttdispersal.h:82
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:49
virtual ~TTDispersal()
Definition: ttdispersal.h:72
double _phenotype
Definition: ttdispersal.h:63
virtual void ** get_sequence() const
Definition: ttdispersal.h:96
virtual void * set_trait(void *value)
Definition: ttdispersal.h:101
void set_mut_rate(double val)
Definition: ttdispersal.h:76
virtual bool retrieve_data(BinaryStorageBuffer *reader)
Definition: ttdispersal.h:110
virtual void init_sequence()
Definition: ttdispersal.cc:262
virtual TTDispersal * clone()
Definition: ttdispersal.h:103
virtual void reset()
Definition: ttdispersal.h:88
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:47
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:51
virtual void mutate()
Definition: ttdispersal.cc:317
virtual TTDispersal & operator=(const TTrait &TP)
Definition: ttdispersal.cc:221
double _sequence[2]
The trait's type.
Definition: ttdispersal.h:62
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:58
virtual void * getValue() const
Definition: ttdispersal.h:94
virtual bool operator==(const TTrait &TP)
Definition: ttdispersal.cc:238
TTDispersal(const TTDispersal &TP)
Definition: ttdispersal.h:68
void set_gender(sex_t val)
Definition: ttdispersal.h:80
virtual trait_t get_type() const
Definition: ttdispersal.h:91
virtual void inherit(TTrait *mother, TTrait *father)
Definition: ttdispersal.cc:306
void set_init_rate_mal(double val)
Definition: ttdispersal.h:79
virtual void set_sequence(void **seq)
Definition: ttdispersal.h:100
virtual void set_value()
Definition: ttdispersal.h:92
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:53
virtual bool operator!=(const TTrait &TP)
Definition: ttdispersal.cc:252
virtual void store_data(BinaryStorageBuffer *saver)
Definition: ttdispersal.h:109
virtual double get_allele_value(int loc, int all)
Definition: ttdispersal.h:97
TProtoDispersal * _myProto
Definition: ttdispersal.h:55
virtual void init()
Definition: ttdispersal.h:86
virtual void show_up()
Definition: ttdispersal.cc:342
virtual void set_allele_value(unsigned int locus, unsigned int allele, double value)
Definition: ttdispersal.h:98
Interface for all trait types, declares all basic trait operations.
Definition: ttrait.h:46
TTrait setter.
Definition: ttrait.h:125
std::string trait_t
Trait types.
Definition: types.h:63
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37
#define MDISP
Definition: types.h:69
unsigned int age_t
Age class flags.
Definition: types.h:46
age_idx
Array index of the age classes in the patch sizes and containers arrays.
Definition: types.h:41
@ OFFSx
Definition: types.h:42
@ ADLTx
Definition: types.h:42
#define FDISP
Definition: types.h:68

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR