Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
TTDispersal Class Reference

Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispersal rates. More...

#include <ttdispersal.h>

+ Inheritance diagram for TTDispersal:
+ Collaboration diagram for TTDispersal:

Public Member Functions

 TTDispersal (sex_t sex)
 
 TTDispersal (const TTDispersal &TP)
 
virtual ~TTDispersal ()
 
Setters
void set_mut_rate (double val)
 
void set_mut_mean (double val)
 
void set_init_rate_fem (double val)
 
void set_init_rate_mal (double val)
 
void set_gender (sex_t val)
 
void set_proto (TProtoDispersal *P)
 
Implementations
virtual void init ()
 
virtual void init_sequence ()
 
virtual void reset ()
 
virtual void inherit (TTrait *mother, TTrait *father)
 
virtual void mutate ()
 
virtual trait_t get_type () const
 
virtual void set_value ()
 
virtual void * getValue () const
 
virtual void ** get_sequence () const
 
virtual double get_allele_value (int loc, int all)
 
virtual void set_allele_value (unsigned int locus, unsigned int allele, double value)
 
virtual void set_sequence (void **seq)
 
virtual void * set_trait (void *value)
 
virtual void show_up ()
 
virtual TTDispersalclone ()
 
virtual TTDispersaloperator= (const TTrait &TP)
 
virtual bool operator== (const TTrait &TP)
 
virtual bool operator!= (const TTrait &TP)
 
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
- Public Member Functions inherited from TTrait
virtual void init ()=0
 Called to allocate the trait's genotypic sequences. More...
 
virtual void init_sequence ()=0
 Called at the start of each replicate, sets the initial genotypes. More...
 
virtual void reset ()=0
 Called at the end of each simulation/replicate, deallocates sequence memory. More...
 
virtual void inherit (TTrait *mother, TTrait *father)=0
 Inheritance procedure, creates a new trait from mother's and father's traits. More...
 
virtual void mutate ()=0
 Mutation procedure, perform mutations on the genes sequence. More...
 
virtual void * set_trait (void *value)=0
 Called to set the phenotypic to a particular value or to give context-dependant value(s) to the trait. More...
 
virtual void set_sequence (void **seq)=0
 Called to set the sequence pointer to an existing trait. More...
 
virtual double get_allele_value (int loc, int all)=0
 Called to read one allele value at a particular locus. More...
 
virtual void set_allele_value (unsigned int locus, unsigned int allele, double value)=0
 Called to change the allelic value at a particular locus. More...
 
virtual void set_value ()=0
 Tells the trait to set its phenotype from genotype, should be used instead of getValue(). More...
 
virtual void * getValue () const =0
 Genotype to phenotype mapper. More...
 
virtual trait_t get_type () const =0
 type accessor. More...
 
virtual void ** get_sequence () const =0
 sequence accessor. More...
 
virtual void show_up ()=0
 Writes some info to stdout. More...
 
virtual TTraitclone ()=0
 Returns a copy of itself. More...
 
virtual ~TTrait ()
 
- Public Member Functions inherited from StorableComponent
virtual void store_data (BinaryStorageBuffer *saver)=0
 Interface to store the component data (e.g. gene values) into a binary buffer. More...
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)=0
 Interface to retrieve the same data from the binary buffer. More...
 
virtual ~StorableComponent ()
 

Private Attributes

double _mut_rate
 The allelic mutation rate. More...
 
double _mut_mean
 The mean mutation step. More...
 
double _init_rate_fem
 Initial allele for female dispersal. More...
 
double _init_rate_mal
 Initial allele for male dispersal. More...
 
TProtoDispersal_myProto
 
sex_t _gender
 the gender of the trait, will determine its type. More...
 
double _sequence [2]
 The trait's type. More...
 
double _phenotype
 

Detailed Description

Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispersal rates.

Constructor & Destructor Documentation

◆ TTDispersal() [1/2]

TTDispersal::TTDispersal ( sex_t  sex)
Parameters
sexdetermines the type of this trait (FDISP for female dispersal, MDISP for male dispersal)
212: _mut_rate(0), _mut_mean(0.2), _init_rate_fem(-1.0), _init_rate_mal(-1.0), _myProto(0),
213 _gender(sex)
214{
215// _type = (_gender == FEM ? FDISP : MDISP);
216 _sequence[0] = _sequence[1] = 0;
217}
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:49
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:47
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:51
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
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:53
TProtoDispersal * _myProto
Definition: ttdispersal.h:55

References _sequence.

◆ TTDispersal() [2/2]

TTDispersal::TTDispersal ( const TTDispersal TP)
inline
70 _init_rate_mal(TP._init_rate_mal), _myProto(TP._myProto), _gender(TP._gender), _phenotype(0) //, _type(TP._type)
71 {}
double _phenotype
Definition: ttdispersal.h:63

◆ ~TTDispersal()

virtual TTDispersal::~TTDispersal ( )
inlinevirtual
72{ }

Member Function Documentation

◆ clone()

virtual TTDispersal * TTDispersal::clone ( )
inlinevirtual

Implements TTrait.

103{return new TTDispersal(*this);}
Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispe...
Definition: ttdispersal.h:44

◆ get_allele_value()

virtual double TTDispersal::get_allele_value ( int  loc,
int  all 
)
inlinevirtual

Implements TTrait.

97{return ( !(all<2) ? 0 : _sequence[all] );}

References _sequence.

◆ get_sequence()

virtual void ** TTDispersal::get_sequence ( ) const
inlinevirtual
Returns
NULL, here the _sequence is not a dble ptr.

Implements TTrait.

96{return 0;}

◆ get_type()

virtual trait_t TTDispersal::get_type ( ) const
inlinevirtual

Implements TTrait.

91{return (_gender == FEM ? FDISP : MDISP);}
@ FEM
Definition: types.h:37
#define MDISP
Definition: types.h:69
#define FDISP
Definition: types.h:68

References _gender, FDISP, FEM, and MDISP.

Referenced by show_up().

+ Here is the caller graph for this function:

◆ getValue()

virtual void * TTDispersal::getValue ( ) const
inlinevirtual
Returns
the dispersal rate, mean of the 2 alleles beard at this dispersal locus.

Implements TTrait.

94{return (void*)&_phenotype;}

References _phenotype.

Referenced by show_up().

+ Here is the caller graph for this function:

◆ inherit()

void TTDispersal::inherit ( TTrait mother,
TTrait father 
)
virtual

Implements TTrait.

307{
308// if(mother->get_type() != _type || father->get_type() != _type)
309// fatal("TTDispersal::inherit::wrong parent's trait type \n");
310
311 _sequence[0] = mother->get_allele_value(0,RAND::RandBool());
312 _sequence[1] = father->get_allele_value(0,RAND::RandBool());
313}
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:163
virtual double get_allele_value(int loc, int all)=0
Called to read one allele value at a particular locus.

References _sequence, TTrait::get_allele_value(), and RAND::RandBool().

◆ init()

virtual void TTDispersal::init ( )
inlinevirtual

Implements TTrait.

86{ _sequence[0] = 0.0; _sequence[1] = 0.0; }

References _sequence.

Referenced by reset().

+ Here is the caller graph for this function:

◆ init_sequence()

void TTDispersal::init_sequence ( )
virtual

Implements TTrait.

263{
264 TMatrix *params;
265 unsigned int row;
266
267 if ( _myProto->get_init_mode() ) { //this is random mode
268
269 params = _myProto->get_init_dist_params();
270
271 if (params->getNbRows() == 2) // means different mean/sd for each sex
272 row = _gender;
273 else
274 row = 0;
275
276 string option = _myProto->get_init_dist() ;
277
278 if (option == "normal") {
279
280 do { _sequence[0] = params->get(row, 0) + RAND::Gaussian(params->get(row, 1)); }
281 while (_sequence[0] < 0.0 || _sequence[0] > 1.0);
282
283 do { _sequence[1] = params->get(row, 0) + RAND::Gaussian(params->get(row, 1)); }
284 while (_sequence[1] < 0.0 || _sequence[1] > 1.0);
285
286 } else if (option == "uniform") {
287
290
291 } else {
292 fatal("dispersal init distribution \"%s\" is not implemented\n",_myProto->get_init_dist().c_str());
293 }
294
295
296 } else {
297
300
301 }
302}
static double Gaussian(double sigma)
Definition: Uniform.h:262
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:125
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
double get(unsigned int i, unsigned int j)
Accessor to element at row i and column j.
Definition: tmatrix.h:147
unsigned int getNbRows()
Gives the number of rows.
Definition: tmatrix.h:166
TMatrix * get_init_dist_params()
Definition: ttdispersal.h:143
bool get_init_mode()
Definition: ttdispersal.h:142
string get_init_dist()
Definition: ttdispersal.h:144
void fatal(const char *str,...)
Definition: output.cc:96

References _gender, _init_rate_fem, _init_rate_mal, _myProto, _sequence, fatal(), FEM, RAND::Gaussian(), TMatrix::get(), TProtoDispersal::get_init_dist(), TProtoDispersal::get_init_dist_params(), TProtoDispersal::get_init_mode(), TMatrix::getNbRows(), and RAND::Uniform().

◆ mutate()

void TTDispersal::mutate ( )
virtual

Implements TTrait.

318{
319 double step;
320
321 unsigned int nbMut = (unsigned int)RAND::Poisson(2*_mut_rate);
322
323 unsigned int mut_allele;
324
325 for(unsigned int i = 0; i < nbMut; i++) {
326
327 step = -1.0 * _mut_mean * log(1 - RAND::Uniform());
328
329 mut_allele = RAND::RandBool();
330
331 if(RAND::RandBool())
332 _sequence[mut_allele] = ((_sequence[i] + step) > 1.0 ? 1.0 : _sequence[mut_allele] + step);
333 else
334 _sequence[mut_allele] = ((_sequence[i] - step) < 0.0 ? 0.0 : _sequence[mut_allele] - step);
335
336 }
337
338}
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:220

References _mut_mean, _mut_rate, _sequence, RAND::Poisson(), RAND::RandBool(), and RAND::Uniform().

◆ operator!=()

bool TTDispersal::operator!= ( const TTrait TP)
virtual

Implements TTrait.

253{
254 if( !((*this) == T) )
255 return true;
256 else
257 return false;
258}

◆ operator=()

TTDispersal & TTDispersal::operator= ( const TTrait TP)
virtual

Implements TTrait.

222{
223 const TTDispersal& TD = dynamic_cast<const TTDispersal&> (T);
224
225 if(this != &TD) {
226 _gender = TD._gender;
227// _type = TD._type;
228 _sequence[0] = TD._sequence[0];
229 _sequence[1] = TD._sequence[1];
231 }
232
233 return *this;
234}

References _gender, _phenotype, and _sequence.

◆ operator==()

bool TTDispersal::operator== ( const TTrait TP)
virtual

Implements TTrait.

239{
240 const TTDispersal& TD = dynamic_cast<const TTDispersal&> (T);
241
242 if(this != &TD) {
243 if(_gender != TD._gender) return false;
244// if(_type != TD._type) return false;
245 }
246
247 return true;
248}

References _gender.

◆ reset()

virtual void TTDispersal::reset ( )
inlinevirtual

Implements TTrait.

88{init();}
virtual void init()
Definition: ttdispersal.h:86

References init().

◆ retrieve_data()

virtual bool TTDispersal::retrieve_data ( BinaryStorageBuffer reader)
inlinevirtual

Implements StorableComponent.

110{reader->read(&_sequence, 2 * sizeof(double));return true;}
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:162

References _sequence, and BinaryStorageBuffer::read().

◆ set_allele_value()

virtual void TTDispersal::set_allele_value ( unsigned int  locus,
unsigned int  allele,
double  value 
)
inlinevirtual

Implements TTrait.

99 {assert(allele < 2); _sequence[allele] = value;}

References _sequence.

◆ set_gender()

void TTDispersal::set_gender ( sex_t  val)
inline
80{_gender = val;}

References _gender.

Referenced by TProtoDispersal::hatch().

+ Here is the caller graph for this function:

◆ set_init_rate_fem()

void TTDispersal::set_init_rate_fem ( double  val)
inline
78{_init_rate_fem = val;}

References _init_rate_fem.

Referenced by TProtoDispersal::hatch().

+ Here is the caller graph for this function:

◆ set_init_rate_mal()

void TTDispersal::set_init_rate_mal ( double  val)
inline
79{_init_rate_mal = val;}

References _init_rate_mal.

Referenced by TProtoDispersal::hatch().

+ Here is the caller graph for this function:

◆ set_mut_mean()

void TTDispersal::set_mut_mean ( double  val)
inline
77{_mut_mean = val;}

References _mut_mean.

Referenced by TProtoDispersal::hatch().

+ Here is the caller graph for this function:

◆ set_mut_rate()

void TTDispersal::set_mut_rate ( double  val)
inline
76{_mut_rate = val;}

References _mut_rate.

Referenced by TProtoDispersal::hatch().

+ Here is the caller graph for this function:

◆ set_proto()

void TTDispersal::set_proto ( TProtoDispersal P)
inline
82{_myProto = P;}

References _myProto.

Referenced by TProtoDispersal::hatch().

+ Here is the caller graph for this function:

◆ set_sequence()

virtual void TTDispersal::set_sequence ( void **  seq)
inlinevirtual

Implements TTrait.

100{ }

◆ set_trait()

virtual void * TTDispersal::set_trait ( void *  value)
inlinevirtual

Implements TTrait.

101{return value;}

◆ set_value()

virtual void TTDispersal::set_value ( )
inlinevirtual

Implements TTrait.

92{_phenotype = (_sequence[0] + _sequence[1])/2.0;}

References _phenotype, and _sequence.

Referenced by show_up().

+ Here is the caller graph for this function:

◆ show_up()

void TTDispersal::show_up ( )
virtual

Implements TTrait.

343{
344 set_value();
345 message("\n Trait type: %s\n\
346 value: %f\n\
347 _sequence: \n\
348%f\n\
349%f\n",get_type().c_str(), *(double*)getValue(), _sequence[0], _sequence[1]);
350}
virtual void * getValue() const
Definition: ttdispersal.h:94
virtual trait_t get_type() const
Definition: ttdispersal.h:91
virtual void set_value()
Definition: ttdispersal.h:92
void message(const char *message,...)
Definition: output.cc:40

References _sequence, get_type(), getValue(), message(), and set_value().

◆ store_data()

virtual void TTDispersal::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

109{saver->store(&_sequence, 2 * sizeof(double));}
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16

References _sequence, and BinaryStorageBuffer::store().

Member Data Documentation

◆ _gender

sex_t TTDispersal::_gender
private

the gender of the trait, will determine its type.

Referenced by get_type(), init_sequence(), operator=(), operator==(), and set_gender().

◆ _init_rate_fem

double TTDispersal::_init_rate_fem
private

Initial allele for female dispersal.

Referenced by init_sequence(), and set_init_rate_fem().

◆ _init_rate_mal

double TTDispersal::_init_rate_mal
private

Initial allele for male dispersal.

Referenced by init_sequence(), and set_init_rate_mal().

◆ _mut_mean

double TTDispersal::_mut_mean
private

The mean mutation step.

Referenced by mutate(), and set_mut_mean().

◆ _mut_rate

double TTDispersal::_mut_rate
private

The allelic mutation rate.

The mutation distribution is exponential, centered on the allelic value.

Referenced by mutate(), and set_mut_rate().

◆ _myProto

TProtoDispersal* TTDispersal::_myProto
private

Referenced by init_sequence(), and set_proto().

◆ _phenotype

double TTDispersal::_phenotype
private

Referenced by getValue(), operator=(), and set_value().

◆ _sequence

double TTDispersal::_sequence[2]
private

The trait's type.

One diploid locus coding for a sex-specific dispersal rate.

Referenced by get_allele_value(), inherit(), init(), init_sequence(), mutate(), operator=(), retrieve_data(), set_allele_value(), set_value(), show_up(), store_data(), and TTDispersal().


The documentation for this class was generated from the following files:

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