Nemo  2.4.2
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)
210 : _mut_rate(0), _mut_mean(0.2), _init_rate_fem(-1.0), _init_rate_mal(-1.0), _myProto(0),
211  _gender(sex)
212 {
213 // _type = (_gender == FEM ? FDISP : MDISP);
214  _sequence[0] = _sequence[1] = 0;
215 }
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:47
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:45
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:49
double _sequence[2]
The trait's type.
Definition: ttdispersal.h:60
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:56
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:51
TProtoDispersal * _myProto
Definition: ttdispersal.h:53

References _sequence.

Referenced by clone().

+ Here is the caller graph for this function:

◆ TTDispersal() [2/2]

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

◆ ~TTDispersal()

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

Member Function Documentation

◆ clone()

virtual TTDispersal* TTDispersal::clone ( )
inlinevirtual

Implements TTrait.

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

References TTDispersal().

◆ get_allele()

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

Implements TTrait.

95 {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.

96 {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.

94 {return 0;}

◆ get_type()

virtual trait_t TTDispersal::get_type ( ) const
inlinevirtual

Implements TTrait.

89 {return (_gender == FEM ? FDISP : MDISP);}
@ FEM
Definition: types.h:35
#define MDISP
Definition: types.h:67
#define FDISP
Definition: types.h:66

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.

92 {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.

305 {
306 // if(mother->get_type() != _type || father->get_type() != _type)
307 // fatal("TTDispersal::inherit::wrong parent's trait type \n");
308 
309  _sequence[0] = mother->get_allele_value(0,RAND::RandBool());
310  _sequence[1] = father->get_allele_value(0,RAND::RandBool());
311 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:170
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.

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

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

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.

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

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

◆ operator!=()

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

Implements TTrait.

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

◆ operator=()

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

Implements TTrait.

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

References _gender, _phenotype, and _sequence.

◆ operator==()

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

Implements TTrait.

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

References _gender.

◆ reset()

virtual void TTDispersal::reset ( )
inlinevirtual

Implements TTrait.

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

References init().

◆ retrieve_data()

virtual bool TTDispersal::retrieve_data ( BinaryStorageBuffer reader)
inlinevirtual

Implements StorableComponent.

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

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.

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

References _sequence.

◆ set_gender()

void TTDispersal::set_gender ( sex_t  val)
inline
78 {_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
76 {_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
77 {_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
75 {_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
74 {_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
80 {_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.

99 { }

◆ set_trait()

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

Implements TTrait.

100 {return value;}

◆ set_value()

virtual void TTDispersal::set_value ( )
inlinevirtual

Implements TTrait.

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

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

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

◆ store_data()

virtual void TTDispersal::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

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

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.2 by  doxygen 1.9.1

Catalogued on GSR