Nemo  2.3.46
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 
39 class TTDispersalSH;
40 class TProtoDispersal;
41 
43 class TTDispersal : public TTrait
44 {
47  double _mut_rate;
49  double _mut_mean;
54 
56 
62  double _sequence[2];
63  double _phenotype;
64 
65 public:
67  TTDispersal (sex_t sex);
69  : _mut_rate(TP._mut_rate), _mut_mean(TP._mut_mean), _init_rate_fem(TP._init_rate_fem),
70  _init_rate_mal(TP._init_rate_mal), _myProto(TP._myProto), _gender(TP._gender), _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;}
82  void set_proto (TProtoDispersal* P){_myProto = P;}
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 _type;}
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 // ------------------------------------------------------------------------------
120 public:
121  TProtoDispersal(sex_t sex);
122  TProtoDispersal(const TProtoDispersal& TP);
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 _type;}
130  //implements StorableComponent:
131  virtual void store_data (BinaryStorageBuffer* saver) {saver->store(&_type, sizeof(trait_t));saver->store(&_gender, sizeof(sex_t));}
132  virtual bool retrieve_data (BinaryStorageBuffer* reader) {reader->read(&_type, sizeof(trait_t));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 
138  bool setNonRandom ();
139  bool setRandom ();
140 
141  bool get_init_mode () {return _init_random;}
143  string get_init_dist () {return _init_dist;}
144 
145 private:
147  double _mut_rate;
149  double _mut_mean;
154 
155  string _init_dist;
158 
165 };
166 
167 // ------------------------------------------------------------------------------
168 
169 // TTDispersalSH
170 
171 // ------------------------------------------------------------------------------
173 class TTDispersalSH: public StatHandler<TTDispersalSH> {
174 
176 
178 
180 
181 public:
182 
184  : _trait(TT),_meanFemDisp(0), _meanMalDisp(0), _meanOffFemDisp(0), _meanOffMalDisp(0), _fdispIdx(-1), _mdispIdx(-1) { }
185 
186  virtual ~TTDispersalSH ( ) { }
187  virtual void init ( )
188  {
190  _fdispIdx = _pop->getTraitIndex(FDISP);
191  _mdispIdx = _pop->getTraitIndex(MDISP);
192  }
193 
194  virtual bool setStatRecorders (std::string& token);
195 
196 
197  double getmeanOFD () {return _meanOffFemDisp;}
198  double getmeanOMD () {return _meanOffMalDisp;}
199  double getmeanFD () {return _meanFemDisp;}
200  double getmeanMD () {return _meanMalDisp;}
201  double getMeanDispRate ();
202  double getOffsprgMeanDispRate ();
203  double getMeanDispRate (bool);
204  double getOffsprgMeanDispRate (bool);
205  double getMeanFemDispRate ();
206  double getMeanMalDispRate ();
207 
208 };
209 #endif //TTDISPERSALGENE_H
210 
virtual void set_value()
Definition: ttdispersal.h:92
Prototype of the evolving dispersal trait, defines the sex-specific trait type.
Definition: ttdispersal.h:119
virtual bool retrieve_data(BinaryStorageBuffer *reader)
Definition: ttdispersal.h:132
virtual ~TTDispersalSH()
Definition: ttdispersal.h:186
int _mdispIdx
Definition: ttdispersal.h:179
void set_init_rate_fem(double val)
Definition: ttdispersal.h:78
double _meanMalDisp
Definition: ttdispersal.h:177
void set_mut_mean(double val)
Definition: ttdispersal.h:77
virtual void store_data(BinaryStorageBuffer *saver)
Definition: ttdispersal.h:131
The Service class used to manage the StatHandler objects.
Definition: statservices.h:50
virtual double get_allele_value(int loc, int all)
Definition: ttdispersal.h:97
double getmeanOMD()
Definition: ttdispersal.h:198
std::string trait_t
Trait types.
Definition: types.h:63
double _meanOffMalDisp
Definition: ttdispersal.h:177
TTDispersal(sex_t sex)
Definition: ttdispersal.cc:210
virtual bool operator==(const TTrait &TP)
Definition: ttdispersal.cc:237
void set_init_rate_mal(double val)
Definition: ttdispersal.h:79
double getMeanMalDispRate()
Definition: stats_disp.cc:183
virtual void init()
Definition: ttdispersal.h:125
#define MDISP
Definition: types.h:69
bool get_init_mode()
Definition: ttdispersal.h:141
double getmeanMD()
Definition: ttdispersal.h:200
bool setNonRandom()
Definition: ttdispersal.cc:119
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:53
double getOffsprgMeanDispRate()
Definition: stats_disp.cc:99
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:160
void set_mut_rate(double val)
Definition: ttdispersal.h:76
double _meanFemDisp
Definition: ttdispersal.h:177
virtual void * getValue() const
Definition: ttdispersal.h:94
virtual void * set_trait(void *value)
Definition: ttdispersal.h:101
Interface for all trait types, declares all basic trait operations.
Definition: ttrait.h:46
virtual bool retrieve_data(BinaryStorageBuffer *reader)
Definition: ttdispersal.h:110
double getmeanFD()
Definition: ttdispersal.h:199
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:147
double getmeanOFD()
Definition: ttdispersal.h:197
TTDispersalSH * _stats
The trait's StatHandler.
Definition: ttdispersal.h:164
TMatrix _init_dist_param
Definition: ttdispersal.h:156
virtual TTDispersal & operator=(const TTrait &TP)
Definition: ttdispersal.cc:220
The StatHandler for the evolving dispersal traits.
Definition: ttdispersal.h:173
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:130
TTDispersal(const TTDispersal &TP)
Definition: ttdispersal.h:68
trait_t _type
The trait's type.
Definition: ttdispersal.h:162
virtual void reset()
Definition: ttdispersal.h:126
virtual void reset()
Definition: ttdispersal.h:88
string _init_dist
Definition: ttdispersal.h:155
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:47
void set_gender(sex_t val)
Definition: ttdispersal.h:80
virtual bool operator!=(const TTrait &TP)
Definition: ttdispersal.cc:253
virtual TProtoDispersal * clone()
Definition: ttdispersal.h:128
virtual TTDispersal * hatch()
Definition: ttdispersal.cc:189
virtual void mutate()
Definition: ttdispersal.cc:318
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:51
virtual trait_t get_type() const
Definition: ttdispersal.h:91
virtual bool setStatRecorders(std::string &token)
Definition: ttdispersal.cc:359
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
double _meanOffFemDisp
Definition: ttdispersal.h:177
virtual TTDispersal * clone()
Definition: ttdispersal.h:103
virtual void init()
Definition: ttdispersal.h:86
Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispe...
Definition: ttdispersal.h:43
virtual void ** get_sequence() const
Definition: ttdispersal.h:96
A class to store any kind of data in a char buffer before unloading it in a binary data file...
Definition: binarystoragebuffer.h:40
virtual void init()
Definition: stathandler.cc:39
A class to compute and store the summary statistics associated with a SimComponent.
Definition: stathandler.h:110
virtual void store_data(BinaryStorageBuffer *saver)
Definition: ttdispersal.h:109
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
int _fdispIdx
Definition: ttdispersal.h:179
string get_init_dist()
Definition: ttdispersal.h:143
virtual trait_t get_type() const
Definition: ttdispersal.h:129
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:147
void set_type(trait_t val)
Definition: ttdispersal.h:81
virtual void loadStatServices(StatServices *loader)
Definition: ttdispersal.cc:179
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
TTrait setter.
Definition: ttrait.h:125
void set_proto(TProtoDispersal *P)
Definition: ttdispersal.h:82
TProtoDispersal(sex_t sex)
Definition: ttdispersal.cc:43
~TProtoDispersal()
Definition: ttdispersal.cc:70
virtual void set_sequence(void **seq)
Definition: ttdispersal.h:100
double _phenotype
Definition: ttdispersal.h:63
double getMeanFemDispRate()
Definition: stats_disp.cc:164
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:153
virtual bool setParameters()
Definition: ttdispersal.cc:77
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:151
#define FDISP
Definition: types.h:68
virtual void show_up()
Definition: ttdispersal.cc:343
virtual void set_allele_value(unsigned int locus, unsigned int allele, double value)
Definition: ttdispersal.h:98
trait_t _type
The trait's type.
Definition: ttdispersal.h:60
virtual void loadFileServices(FileServices *loader)
Definition: ttdispersal.h:135
TMatrix * get_init_dist_params()
Definition: ttdispersal.h:142
virtual void inherit(TTrait *mother, TTrait *father)
Definition: ttdispersal.cc:307
TTDispersalSH(TProtoDispersal *TT)
Definition: ttdispersal.h:183
virtual void init()
Definition: ttdispersal.h:187
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:49
virtual void init_sequence()
Definition: ttdispersal.cc:263
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:58
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:51
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
double _mut_mean
Mean mutation step.
Definition: ttdispersal.h:149
TProtoDispersal * _myProto
Definition: ttdispersal.h:55
virtual ~TTDispersal()
Definition: ttdispersal.h:72
bool _init_random
Definition: ttdispersal.h:157
TProtoDispersal * _trait
Definition: ttdispersal.h:175
bool setRandom()
Definition: ttdispersal.cc:150
double getMeanDispRate()
Definition: stats_disp.cc:40

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR