Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
ttwolbachia.h
Go to the documentation of this file.
1
31#ifndef TTWOLBACHIA_H
32#define TTWOLBACHIA_H
33
34#include "ttrait.h"
35#include "lifecycleevent.h"
36#include "filehandler.h"
37#include "stathandler.h"
38#include "binarystoragebuffer.h"
39#include "Uniform.h"
40#include "LCEbreed.h"
41
42class TTWolbachiaSH;
43
44// ------------------------------------------------------------------------------
45
46// TTWolbachia
47
48// ------------------------------------------------------------------------------
53class TTWolbachia : public TTrait
54{
55private:
58
59public:
60
62 : _transmit_rate(0), _is_infected(0) { }
63
66
67
68 virtual ~TTWolbachia () {}
69
70 void set_transmit_rate (double val) {_transmit_rate = val;}
71
72 virtual void init () {_is_infected = 0;}
73 virtual void init_sequence () {_is_infected = 0;}
74 virtual void reset () {_is_infected = 0;}
75 virtual void inherit (TTrait* mother, TTrait* father)
76 { _is_infected = *(bool*)mother->getValue(); }
77 virtual void mutate ()
79 virtual void* set_trait (void* value)
80 { _is_infected = *(bool*)value; return &_is_infected; }
81 virtual void set_sequence (void** seq) { }
82 virtual void set_value () { }
83 virtual void* getValue () const {return (void*)&_is_infected;}
84 virtual trait_t get_type () const {return WOLB;}
85 virtual void** get_sequence () const {return NULL;}
86 virtual double get_allele_value(int loc, int all) {return _is_infected;}
87 virtual void set_allele_value(unsigned int locus, unsigned int allele, double value) {_is_infected=(bool)value;}
88 virtual void show_up () {}
89 virtual TTWolbachia* clone () {return new TTWolbachia(*this);}
90 virtual TTWolbachia& operator= (const TTrait& T);
91 virtual bool operator== (const TTrait& T);
92 virtual bool operator!= (const TTrait& T);
93
94 virtual void store_data (BinaryStorageBuffer* saver)
95 {
96 unsigned char dummy = static_cast<unsigned char>(_is_infected);
97 saver->store(&dummy, 1);
98 }
99 virtual bool retrieve_data (BinaryStorageBuffer* reader)
100 {
101 unsigned char dummy;
102 reader->read(&dummy, 1);
103 _is_infected = dummy;
104 return true;
105 }
106
107};
108
109// ------------------------------------------------------------------------------
110
111// TProtoWolbachia
112
113// ------------------------------------------------------------------------------
116public:
120
121 virtual void init(){}
122 virtual void reset(){}
123 virtual bool setParameters()
124 { _transmit_rate = get_parameter_value("wolbachia_transmission_rate"); return true;}
125
126 virtual TTWolbachia* hatch()
127 {
128 TTWolbachia* new_trait = new TTWolbachia();
130 return new_trait;
131 }
132
133 virtual TProtoWolbachia* clone() {return new TProtoWolbachia(*this);}
134
135 virtual trait_t get_type ( ) const {return WOLB;}
136
137 virtual void store_data (BinaryStorageBuffer* saver) {/*we have nothing to save...*/}
138 virtual bool retrieve_data (BinaryStorageBuffer* reader) {return true;}
139
140 virtual void loadFileServices ( FileServices* loader ) {}
141 virtual void loadStatServices ( StatServices* loader );
142 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
143
144
145private:
146
149};
150
151// ------------------------------------------------------------------------------
152
153// TTWolbachiaSH
154
155// ------------------------------------------------------------------------------
157class TTWolbachiaSH : public TraitStatHandler<TProtoWolbachia, TTWolbachiaSH> {
158
162public:
163
166 _trait(TT), _TTidx(TT->get_index()), _Fmean(0), _Mmean(0), _var(0), _extrate(0) {}
167
168 virtual ~TTWolbachiaSH ( ) { }
169
170 virtual bool setStatRecorders (string& token);
171
172 void setInfectionStats ( );
173 double getMeanInfection (unsigned int sex) {return ((bool)sex ? _Fmean : _Mmean);}
174 double getMeanOffsprgInfection (unsigned int sex);
175 double getMeanFemaleInfection_perPatch (unsigned int patch);
176 double getMeanMaleInfection_perPatch (unsigned int patch);
177 double getMeanOffsprgFemaleInfection_perPatch (unsigned int patch);
178 double getMeanOffsprgMaleInfection_perPatch (unsigned int patch);
179 double getIcompatibleMatingFreq ( );
180 double getDemicInfectionVar ( ) {return _var;}
181 double getDemicExtinctionRate ( ) {return _extrate;}
182};
183
184
185
186class TTWolbachiaFH;
187
188
192class LCE_Breed_Wolbachia : public virtual LCE_Breed_base {
193
195 double _fec_cost;
198 unsigned int _inoculum_time;
199 unsigned int _model;
200
202
204
205 void inoculate_wolbachia();
206 double hasInfectedFemale ();
207
208public:
209
211
212 virtual ~LCE_Breed_Wolbachia ( );
213
214 void wolbachia_model_1 ();
215 void wolbachia_model_2 ();
216
217 virtual bool setParameters ();
218 virtual void execute ();
219
220 virtual LifeCycleEvent* clone ( )
221 { return new LCE_Breed_Wolbachia(); }
222
223
224 virtual void loadFileServices ( FileServices* loader );
225 virtual void loadStatServices ( StatServices* loader ) {}
226 virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
227 virtual age_t removeAgeClass ( ) {return 0;}
228 virtual age_t addAgeClass ( ) {return OFFSPRG;}
229 virtual age_t requiredAgeClass () {return ADULTS;}
230};
231
232// ------------------------------------------------------------------------------
233
234// ****** TTWolbachiaFH ******
235
236// ------------------------------------------------------------------------------
241class TTWolbachiaFH: public EventFileHandler<LCE_Breed_Wolbachia> {
242
243 map< unsigned int, unsigned int > _times;
244 vector< double > _rate;
245
246public:
247
250 { }
251
252 //TTWolbachiaFH ( ) { }
253 virtual ~TTWolbachiaFH ( ) { }
254
255 void record (unsigned int repl, unsigned int gen, double infection);
256
257 virtual void FHwrite ();
258
259 virtual void FHread (string& filename) {}
260
261};
262
263#endif //TTWOLBACHIA_H
264
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
Template class for the LCEs StatHandler classes.
Definition: filehandler.h:247
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:52
Breeding LCE when individuals carry the Wolbachia endosymbiotic parasite.
Definition: ttwolbachia.h:192
unsigned int _model
Definition: ttwolbachia.h:199
virtual void loadFileServices(FileServices *loader)
Definition: ttwolbachia.cc:233
double _fec_cost
Definition: ttwolbachia.h:195
virtual void execute()
Definition: ttwolbachia.cc:247
virtual ~LCE_Breed_Wolbachia()
Definition: ttwolbachia.cc:184
TTWolbachiaFH * _writer
Definition: ttwolbachia.h:203
TMatrix * _inoculum_size
Definition: ttwolbachia.h:197
virtual LifeCycleEvent * clone()
Definition: ttwolbachia.h:220
LCE_Breed_Wolbachia()
Definition: ttwolbachia.cc:170
void inoculate_wolbachia()
Definition: ttwolbachia.cc:378
double hasInfectedFemale()
Definition: ttwolbachia.cc:404
double _incomp_cost
Definition: ttwolbachia.h:194
virtual age_t addAgeClass()
Definition: ttwolbachia.h:228
virtual bool setParameters()
Definition: ttwolbachia.cc:191
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: ttwolbachia.h:226
void wolbachia_model_1()
Definition: ttwolbachia.cc:284
double _infected_fec
Definition: ttwolbachia.h:196
unsigned int _inoculum_time
Definition: ttwolbachia.h:198
virtual void loadStatServices(StatServices *loader)
Definition: ttwolbachia.h:225
void wolbachia_model_2()
Definition: ttwolbachia.cc:330
virtual age_t removeAgeClass()
Definition: ttwolbachia.h:227
virtual age_t requiredAgeClass()
Definition: ttwolbachia.h:229
void(LCE_Breed_Wolbachia::* _breed_func_ptr)()
Definition: ttwolbachia.h:201
Base class for the breeding (and mating) life cycle events.
Definition: LCEbreed.h:44
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:125
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:45
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
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 Wolbachia trait.
Definition: ttwolbachia.h:115
virtual void loadStatServices(StatServices *loader)
Definition: ttwolbachia.cc:65
double _transmit_rate
Definition: ttwolbachia.h:147
virtual void reset()
Definition: ttwolbachia.h:122
virtual void init()
Definition: ttwolbachia.h:121
TTWolbachiaSH * _stats
Definition: ttwolbachia.h:148
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: ttwolbachia.h:142
virtual TTWolbachia * hatch()
Definition: ttwolbachia.h:126
~TProtoWolbachia()
Definition: ttwolbachia.cc:58
virtual TProtoWolbachia * clone()
Definition: ttwolbachia.h:133
virtual void store_data(BinaryStorageBuffer *saver)
Definition: ttwolbachia.h:137
virtual bool setParameters()
Definition: ttwolbachia.h:123
virtual bool retrieve_data(BinaryStorageBuffer *reader)
Definition: ttwolbachia.h:138
virtual void loadFileServices(FileServices *loader)
Definition: ttwolbachia.h:140
virtual trait_t get_type() const
Definition: ttwolbachia.h:135
TProtoWolbachia()
Definition: ttwolbachia.cc:41
FileHandler of the Wolbachia trait.
Definition: ttwolbachia.h:241
TTWolbachiaFH(LCE_Breed_Wolbachia *TP)
Definition: ttwolbachia.h:248
virtual void FHwrite()
Definition: ttwolbachia.cc:435
virtual ~TTWolbachiaFH()
Definition: ttwolbachia.h:253
void record(unsigned int repl, unsigned int gen, double infection)
Definition: ttwolbachia.cc:427
virtual void FHread(string &filename)
Definition: ttwolbachia.h:259
map< unsigned int, unsigned int > _times
Definition: ttwolbachia.h:243
vector< double > _rate
Definition: ttwolbachia.h:244
StatHandler of the Wolbachia trait.
Definition: ttwolbachia.h:157
double _Mmean
Definition: ttwolbachia.h:161
int _TTidx
Definition: ttwolbachia.h:160
double _extrate
Definition: ttwolbachia.h:161
virtual bool setStatRecorders(string &token)
Definition: ttwolbachia.cc:114
double getDemicExtinctionRate()
Definition: ttwolbachia.h:181
double getDemicInfectionVar()
Definition: ttwolbachia.h:180
double getMeanInfection(unsigned int sex)
Definition: ttwolbachia.h:173
double getMeanOffsprgFemaleInfection_perPatch(unsigned int patch)
Definition: stats_wolbachia.cc:155
double _Fmean
Definition: ttwolbachia.h:161
double getMeanMaleInfection_perPatch(unsigned int patch)
Definition: stats_wolbachia.cc:143
virtual ~TTWolbachiaSH()
Definition: ttwolbachia.h:168
double _var
Definition: ttwolbachia.h:161
double getMeanFemaleInfection_perPatch(unsigned int patch)
Definition: stats_wolbachia.cc:131
double getIcompatibleMatingFreq()
Definition: stats_wolbachia.cc:181
double getMeanOffsprgMaleInfection_perPatch(unsigned int patch)
Definition: stats_wolbachia.cc:168
TTWolbachiaSH(TProtoWolbachia *TT)
Definition: ttwolbachia.h:164
TProtoWolbachia * _trait
Definition: ttwolbachia.h:159
double getMeanOffsprgInfection(unsigned int sex)
Definition: stats_wolbachia.cc:105
void setInfectionStats()
Definition: stats_wolbachia.cc:35
Trait used to study the dynamics of spread of Wolbachia, an endosymbiotic parasite causing cytoplasmi...
Definition: ttwolbachia.h:54
virtual bool operator==(const TTrait &T)
Definition: ttwolbachia.cc:87
virtual bool operator!=(const TTrait &T)
Definition: ttwolbachia.cc:99
bool _is_infected
Definition: ttwolbachia.h:57
virtual void ** get_sequence() const
Definition: ttwolbachia.h:85
virtual void * getValue() const
Definition: ttwolbachia.h:83
virtual void init_sequence()
Definition: ttwolbachia.h:73
TTWolbachia()
Definition: ttwolbachia.h:61
virtual void set_value()
Definition: ttwolbachia.h:82
virtual void mutate()
Definition: ttwolbachia.h:77
virtual void show_up()
Definition: ttwolbachia.h:88
virtual void init()
Definition: ttwolbachia.h:72
TTWolbachia(const TTWolbachia &T)
Definition: ttwolbachia.h:64
virtual TTWolbachia * clone()
Definition: ttwolbachia.h:89
void set_transmit_rate(double val)
Definition: ttwolbachia.h:70
virtual bool retrieve_data(BinaryStorageBuffer *reader)
Definition: ttwolbachia.h:99
virtual trait_t get_type() const
Definition: ttwolbachia.h:84
virtual void set_allele_value(unsigned int locus, unsigned int allele, double value)
Definition: ttwolbachia.h:87
virtual void store_data(BinaryStorageBuffer *saver)
Definition: ttwolbachia.h:94
virtual double get_allele_value(int loc, int all)
Definition: ttwolbachia.h:86
virtual void inherit(TTrait *mother, TTrait *father)
Definition: ttwolbachia.h:75
virtual TTWolbachia & operator=(const TTrait &T)
Definition: ttwolbachia.cc:75
virtual void * set_trait(void *value)
Definition: ttwolbachia.h:79
virtual void reset()
Definition: ttwolbachia.h:74
virtual void set_sequence(void **seq)
Definition: ttwolbachia.h:81
virtual ~TTWolbachia()
Definition: ttwolbachia.h:68
double _transmit_rate
Definition: ttwolbachia.h:56
Interface for all trait types, declares all basic trait operations.
Definition: ttrait.h:46
virtual void * getValue() const =0
Genotype to phenotype mapper.
TTrait setter.
Definition: ttrait.h:125
Template class for the trait's StatHandler.
Definition: stathandler.h:168
std::string trait_t
Trait types.
Definition: types.h:63
#define WOLB
Definition: types.h:73
unsigned int age_t
Age class flags.
Definition: types.h:46
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

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