Nemo  2.4.0
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 (const TTrait *mother, const 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 unsigned int get_allele (int loc, int all) const
 
virtual double get_allele_value (int loc, int all) const
 
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 ~TTrait ()
 
- Public Member Functions inherited from StorableComponent
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)
211 : _mut_rate(0), _mut_mean(0.2), _init_rate_fem(-1.0), _init_rate_mal(-1.0), _myProto(0),
212  _gender(sex)
213 {
214 // _type = (_gender == FEM ? FDISP : MDISP);
215  _sequence[0] = _sequence[1] = 0;
216 }
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:48
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:46
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:50
double _sequence[2]
The trait's type.
Definition: ttdispersal.h:61
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:57
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:52
TProtoDispersal * _myProto
Definition: ttdispersal.h:54

References _sequence.

Referenced by clone().

+ Here is the caller graph for this function:

◆ TTDispersal() [2/2]

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

◆ ~TTDispersal()

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

Member Function Documentation

◆ clone()

virtual TTDispersal* TTDispersal::clone ( )
inlinevirtual

Implements TTrait.

103 {return new TTDispersal(*this);}
TTDispersal(sex_t sex)
Definition: ttdispersal.cc:210

References TTDispersal().

◆ get_allele()

virtual unsigned int TTDispersal::get_allele ( int  loc,
int  all 
) const
inlinevirtual

Implements TTrait.

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

References _sequence.

◆ get_allele_value()

virtual double TTDispersal::get_allele_value ( int  loc,
int  all 
) const
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.

95 {return 0;}

◆ get_type()

virtual trait_t TTDispersal::get_type ( ) const
inlinevirtual

Implements TTrait.

90 {return (_gender == FEM ? FDISP : MDISP);}
@ FEM
Definition: types.h:36
#define MDISP
Definition: types.h:68
#define FDISP
Definition: types.h:67

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.

93 {return (void*)&_phenotype;}

References _phenotype.

Referenced by show_up().

+ Here is the caller graph for this function:

◆ inherit()

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

Implements TTrait.

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

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

◆ init()

virtual void TTDispersal::init ( )
inlinevirtual

Implements TTrait.

85 { _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.

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

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.

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

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

◆ operator!=()

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

Implements TTrait.

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

◆ operator=()

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

Implements TTrait.

221 {
222  const TTDispersal& TD = dynamic_cast<const TTDispersal&> (T);
223 
224  if(this != &TD) {
225  _gender = TD._gender;
226 // _type = TD._type;
227  _sequence[0] = TD._sequence[0];
228  _sequence[1] = TD._sequence[1];
229  _phenotype = TD._phenotype;
230  }
231 
232  return *this;
233 }
Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispe...
Definition: ttdispersal.h:43

References _gender, _phenotype, and _sequence.

◆ operator==()

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

Implements TTrait.

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

References _gender.

◆ reset()

virtual void TTDispersal::reset ( )
inlinevirtual

Implements TTrait.

87 {init();}
virtual void init()
Definition: ttdispersal.h:85

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:220

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
79 {_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
77 {_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
78 {_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
76 {_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
75 {_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
81 {_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.

91 {_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.

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

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:37

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(), 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.4.0 by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR