Nemo  2.3.46
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_type (trait_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 ~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...
 
trait_t _type
 The trait's type. More...
 
double _sequence [2]
 One diploid locus coding for a sex-specific dispersal rate. 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::TTDispersal ( sex_t  sex)
Parameters
sexdetermines the type of this trait (FDISP for female dispersal, MDISP for male dispersal)

Referenced by clone().

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 }
#define MDISP
Definition: types.h:69
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:53
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:47
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:51
#define FDISP
Definition: types.h:68
trait_t _type
The trait's type.
Definition: ttdispersal.h:60
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:49
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:58
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
TProtoDispersal * _myProto
Definition: ttdispersal.h:55
Definition: types.h:37
TTDispersal::TTDispersal ( const TTDispersal TP)
inline
71  {}
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:53
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:47
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:51
trait_t _type
The trait's type.
Definition: ttdispersal.h:60
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:49
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:58
TProtoDispersal * _myProto
Definition: ttdispersal.h:55
virtual TTDispersal::~TTDispersal ( )
inlinevirtual
72 { }

Member Function Documentation

virtual TTDispersal* TTDispersal::clone ( )
inlinevirtual

Implements TTrait.

References TTDispersal().

103 {return new TTDispersal(*this);}
TTDispersal(sex_t sex)
Definition: ttdispersal.cc:210
virtual double TTDispersal::get_allele_value ( int  loc,
int  all 
)
inlinevirtual

Implements TTrait.

97 {return ( !(all<2) ? 0 : _sequence[all] );}
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
virtual void** TTDispersal::get_sequence ( ) const
inlinevirtual
Returns
NULL, here the _sequence is not a dble ptr.

Implements TTrait.

96 {return 0;}
virtual trait_t TTDispersal::get_type ( ) const
inlinevirtual

Implements TTrait.

References _type.

91 {return _type;}
trait_t _type
The trait's type.
Definition: ttdispersal.h:60
virtual void* TTDispersal::getValue ( ) const
inlinevirtual
Returns
the dispersal rate, mean of the 2 alleles beared at this dispersal locus.

Implements TTrait.

References _phenotype.

94 {return (void*)&_phenotype;}
double _phenotype
Definition: ttdispersal.h:63
void TTDispersal::inherit ( TTrait mother,
TTrait father 
)
virtual

Implements TTrait.

308 {
309  if(mother->get_type() != _type || father->get_type() != _type)
310  fatal("TTDispersal::inherit::wrong parent's trait type \n");
311 
312  _sequence[0] = mother->get_allele_value(0,RAND::RandBool());
313  _sequence[1] = father->get_allele_value(0,RAND::RandBool());
314 }
virtual double get_allele_value(int loc, int all)=0
Called to read one allele value at a particular locus.
void fatal(const char *str,...)
Definition: output.cc:90
virtual trait_t get_type() const =0
type accessor.
trait_t _type
The trait's type.
Definition: ttdispersal.h:60
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:139
virtual void TTDispersal::init ( )
inlinevirtual

Implements TTrait.

Referenced by reset().

86 { _sequence[0] = 0.0; _sequence[1] = 0.0; }
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
void TTDispersal::init_sequence ( )
virtual

Implements TTrait.

264 {
265  TMatrix *params;
266  unsigned int row;
267 
268  if ( _myProto->get_init_mode() ) { //this is random mode
269 
270  params = _myProto->get_init_dist_params();
271 
272  if (params->getNbRows() == 2) // means different mean/sd for each sex
273  row = _gender;
274  else
275  row = 0;
276 
277  string option = _myProto->get_init_dist() ;
278 
279  if (option == "normal") {
280 
281  do { _sequence[0] = params->get(row, 0) + RAND::Gaussian(params->get(row, 1)); }
282  while (_sequence[0] < 0.0 || _sequence[0] > 1.0);
283 
284  do { _sequence[1] = params->get(row, 0) + RAND::Gaussian(params->get(row, 1)); }
285  while (_sequence[1] < 0.0 || _sequence[1] > 1.0);
286 
287  } else if (option == "uniform") {
288 
289  _sequence[0] = RAND::Uniform();
290  _sequence[1] = RAND::Uniform();
291 
292  } else {
293  fatal("dispersal init distribution \"%s\" is not implemented\n",_myProto->get_init_dist().c_str());
294  }
295 
296 
297  } else {
298 
301 
302  }
303 }
unsigned int getNbRows()
Gives the number of rows.
Definition: tmatrix.h:139
bool get_init_mode()
Definition: ttdispersal.h:141
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:53
double get(unsigned int i, unsigned int j)
Accessor to element at row i and column j.
Definition: tmatrix.h:120
void fatal(const char *str,...)
Definition: output.cc:90
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:51
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
static double Gaussian(double sigma)
Definition: Uniform.h:238
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:101
string get_init_dist()
Definition: ttdispersal.h:143
TMatrix * get_init_dist_params()
Definition: ttdispersal.h:142
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:58
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
TProtoDispersal * _myProto
Definition: ttdispersal.h:55
Definition: types.h:37
void TTDispersal::mutate ( )
virtual

Implements TTrait.

319 {
320  double step;
321 
322  unsigned int nbMut = (unsigned int)RAND::Poisson(2*_mut_rate);
323 
324  unsigned int mut_allele;
325 
326  for(unsigned int i = 0; i < nbMut; i++) {
327 
328  step = -1.0 * _mut_mean * log(1 - RAND::Uniform());
329 
330  mut_allele = RAND::RandBool();
331 
332  if(RAND::RandBool())
333  _sequence[mut_allele] = ((_sequence[i] + step) >= 1.0 ? 1.0 : _sequence[mut_allele] + step);
334  else
335  _sequence[mut_allele] = ((_sequence[i] - step) <= 0.0 ? 0.0 : _sequence[mut_allele] - step);
336 
337  }
338 
339 }
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:196
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:47
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:101
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:49
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:139
bool TTDispersal::operator!= ( const TTrait TP)
virtual

Implements TTrait.

254 {
255  if( !((*this) == T) )
256  return true;
257  else
258  return false;
259 }
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
double _phenotype
Definition: ttdispersal.h:63
trait_t _type
The trait's type.
Definition: ttdispersal.h:60
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:58
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
bool TTDispersal::operator== ( const TTrait TP)
virtual

Implements TTrait.

238 {
239  if(_type.compare(T.get_type()) != 0) return false;
240 
241  const TTDispersal& TD = dynamic_cast<const TTDispersal&> (T);
242 
243  if(this != &TD) {
244  if(_gender != TD._gender) return false;
245  if(_type != TD._type) return false;
246  }
247 
248  return true;
249 }
Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispe...
Definition: ttdispersal.h:43
trait_t _type
The trait's type.
Definition: ttdispersal.h:60
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:58
virtual void TTDispersal::reset ( )
inlinevirtual

Implements TTrait.

References init().

88 {init();}
virtual void init()
Definition: ttdispersal.h:86
virtual bool TTDispersal::retrieve_data ( BinaryStorageBuffer reader)
inlinevirtual

Implements StorableComponent.

References BinaryStorageBuffer::read().

110 {reader->read(&_sequence, 2 * sizeof(double));return true;}
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:147
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
virtual void TTDispersal::set_allele_value ( unsigned int  locus,
unsigned int  allele,
double  value 
)
inlinevirtual

Implements TTrait.

99  {assert(allele < 2); _sequence[allele] = value;}
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
void TTDispersal::set_gender ( sex_t  val)
inline
80 {_gender = val;}
sex_t _gender
the gender of the trait, will determine its type.
Definition: ttdispersal.h:58
void TTDispersal::set_init_rate_fem ( double  val)
inline
78 {_init_rate_fem = val;}
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:51
void TTDispersal::set_init_rate_mal ( double  val)
inline
79 {_init_rate_mal = val;}
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:53
void TTDispersal::set_mut_mean ( double  val)
inline
77 {_mut_mean = val;}
double _mut_mean
The mean mutation step.
Definition: ttdispersal.h:49
void TTDispersal::set_mut_rate ( double  val)
inline
76 {_mut_rate = val;}
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:47
void TTDispersal::set_proto ( TProtoDispersal P)
inline
82 {_myProto = P;}
TProtoDispersal * _myProto
Definition: ttdispersal.h:55
virtual void TTDispersal::set_sequence ( void **  seq)
inlinevirtual

Implements TTrait.

100 { }
virtual void* TTDispersal::set_trait ( void *  value)
inlinevirtual

Implements TTrait.

101 {return value;}
void TTDispersal::set_type ( trait_t  val)
inline
81 {_type = val;}
trait_t _type
The trait's type.
Definition: ttdispersal.h:60
virtual void TTDispersal::set_value ( )
inlinevirtual

Implements TTrait.

92 {_phenotype = (_sequence[0] + _sequence[1])/2.0;}
double _phenotype
Definition: ttdispersal.h:63
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
void TTDispersal::show_up ( )
virtual

Implements TTrait.

344 {
345  set_value();
346  message("\n Trait type: %s\n\
347  value: %f\n\
348  _sequence: \n\
349 %f\n\
350 %f\n",get_type().c_str(), *(double*)getValue(), _sequence[0], _sequence[1]);
351 }
virtual void set_value()
Definition: ttdispersal.h:92
void message(const char *message,...)
Definition: output.cc:40
virtual void * getValue() const
Definition: ttdispersal.h:94
virtual trait_t get_type() const
Definition: ttdispersal.h:91
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62
virtual void TTDispersal::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

References BinaryStorageBuffer::store().

109 {saver->store(&_sequence, 2 * sizeof(double));}
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:130
double _sequence[2]
One diploid locus coding for a sex-specific dispersal rate.
Definition: ttdispersal.h:62

Member Data Documentation

sex_t TTDispersal::_gender
private

the gender of the trait, will determine its type.

double TTDispersal::_init_rate_fem
private

Initial allele for female dispersal.

double TTDispersal::_init_rate_mal
private

Initial allele for male dispersal.

double TTDispersal::_mut_mean
private

The mean mutation step.

double TTDispersal::_mut_rate
private

The allelic mutation rate.

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

TProtoDispersal* TTDispersal::_myProto
private
double TTDispersal::_phenotype
private

Referenced by getValue().

double TTDispersal::_sequence[2]
private

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

trait_t TTDispersal::_type
private

The trait's type.

Referenced by get_type().


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

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