|
Nemo
2.2.0
|
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 () |
| Called to allocate the trait's genotypic sequences. | |
| virtual void | init_sequence () |
| Called at the start of each replicate, sets the initial genotypes. | |
| virtual void | reset () |
| Called at the end of each simulation/replicate, deallocates sequence memory. | |
| virtual void | inherit (TTrait *mother, TTrait *father) |
| Inheritance procedure, creates a new trait from mother's and father's traits. | |
| virtual void | mutate () |
| Mutation procedure, perform mutations on the genes sequence. | |
| virtual trait_t | get_type () const |
| type accessor. | |
| virtual void | set_value () |
| Tells the trait to set its phenotype from genotype, should be used instead of getValue(). | |
| virtual void * | getValue () |
| virtual void ** | get_sequence () const |
| virtual void * | get_allele (int loc, int all) const |
| Called to read one allele value at a particular locus. | |
| virtual void | set_sequence (void **seq) |
| Called to set the sequence pointer to an existing trait. | |
| virtual void * | set_trait (void *value) |
| Called to set the phenotypic to a particular value or to give context-dependant value(s) to the trait. | |
| virtual void | show_up () |
| Writes some info to stdout. | |
| virtual TTDispersal * | clone () |
| Returns a copy of itself. | |
| virtual TTDispersal & | operator= (const TTrait &TP) |
| Copies the complete state of the trait from right to left side of the operator, sequence data included. | |
| virtual bool | operator== (const TTrait &TP) |
| Checks for parameters equivalence, not genetic equivalence. | |
| virtual bool | operator!= (const TTrait &TP) |
| virtual void | store_data (BinaryStorageBuffer *saver) |
| Interface to store the component data (e.g. gene values) into a binary buffer. | |
| virtual bool | retrieve_data (BinaryStorageBuffer *reader) |
| Interface to retrieve the same data from the binary buffer. | |
Private Attributes | |
| double | _mut_rate |
| The allelic mutation rate. | |
| double | _mut_mean |
| The mean mutation step. | |
| double | _init_rate_fem |
| Initial allele for female dispersal. | |
| double | _init_rate_mal |
| Initial allele for male dispersal. | |
| TProtoDispersal * | _myProto |
| sex_t | _gender |
| the gender of the trait, will determine its type. | |
| trait_t | _type |
| The trait's type. | |
| double | sequence [2] |
| One diploid locus coding for a sex-specific dispersal rate. | |
| double | _phenotype |
Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispersal rates.
Definition at line 43 of file ttdispersal.h.
| TTDispersal::TTDispersal | ( | sex_t | sex | ) |
| sex | determines the type of this trait (FDISP for female dispersal, MDISP for male dispersal) |
Definition at line 211 of file ttdispersal.cc.
Referenced by clone().
| TTDispersal::TTDispersal | ( | const TTDispersal & | TP | ) | [inline] |
Definition at line 68 of file ttdispersal.h.
: _mut_rate(TP._mut_rate), _mut_mean(TP._mut_mean), _init_rate_fem(TP._init_rate_fem), _init_rate_mal(TP._init_rate_mal), _myProto(TP._myProto), _gender(TP._gender), _type(TP._type) {}
| virtual TTDispersal::~TTDispersal | ( | ) | [inline, virtual] |
Definition at line 72 of file ttdispersal.h.
{ }
| virtual TTDispersal* TTDispersal::clone | ( | ) | [inline, virtual] |
Returns a copy of itself.
Note: call the copy constructor of the trait which should only copy the parameters values not the complete state of the trait (i.e. shallow copy). The copy of the sequence data is made through the assignement operator!
Implements TTrait.
Definition at line 101 of file ttdispersal.h.
References TTDispersal().
{return new TTDispersal(*this);}
| virtual void* TTDispersal::get_allele | ( | int | loc, |
| int | all | ||
| ) | const [inline, virtual] |
Called to read one allele value at a particular locus.
| loc | locus position in the sequence |
| all | which allele we want to read the value from |
Implements TTrait.
Definition at line 97 of file ttdispersal.h.
References sequence.
{return ( !(all<2) ? NULL : (void*)&sequence[all] );}
| virtual void** TTDispersal::get_sequence | ( | ) | const [inline, virtual] |
Implements TTrait.
Definition at line 96 of file ttdispersal.h.
{return 0;}
| virtual trait_t TTDispersal::get_type | ( | ) | const [inline, virtual] |
type accessor.
Implements TTrait.
Definition at line 91 of file ttdispersal.h.
References _type.
{return _type;}
| virtual void* TTDispersal::getValue | ( | ) | [inline, virtual] |
Implements TTrait.
Definition at line 94 of file ttdispersal.h.
References _phenotype.
{return &_phenotype;}
Inheritance procedure, creates a new trait from mother's and father's traits.
| mother | the mother's trait |
| father | the father's trait |
Implements TTrait.
Definition at line 315 of file ttdispersal.cc.
{
if(mother->get_type() != _type || father->get_type() != _type)
fatal("TTDispersal::inherit::wrong parent's trait type \n");
sequence[0] = *(double*)mother->get_allele(0,RAND::RandBool());
sequence[1] = *(double*)father->get_allele(0,RAND::RandBool());
}
| virtual void TTDispersal::init | ( | ) | [inline, virtual] |
Called to allocate the trait's genotypic sequences.
Called each time a new Individual is created (Individual::init())
Implements TTrait.
Definition at line 86 of file ttdispersal.h.
References sequence.
Referenced by reset().
| void TTDispersal::init_sequence | ( | ) | [virtual] |
Called at the start of each replicate, sets the initial genotypes.
Called by Individual::create().
Implements TTrait.
Definition at line 271 of file ttdispersal.cc.
{
TMatrix *params;
unsigned int row;
if ( _myProto->get_init_mode() ) { //this is random mode
params = _myProto->get_init_dist_params();
if (params->getNbRows() == 2) // means different mean/sd for each sex
row = _gender;
else
row = 0;
string option = _myProto->get_init_dist() ;
if (option == "normal") {
do { sequence[0] = params->get(row, 0) + RAND::Gaussian(params->get(row, 1)); }
while (sequence[0] < 0.0 || sequence[0] > 1.0);
do { sequence[1] = params->get(row, 0) + RAND::Gaussian(params->get(row, 1)); }
while (sequence[1] < 0.0 || sequence[1] > 1.0);
} else if (option == "uniform") {
sequence[0] = RAND::Uniform();
sequence[1] = RAND::Uniform();
} else {
fatal("dispersal init distribution \"%s\" is not implemented\n",_myProto->get_init_dist().c_str());
}
} else {
sequence[0] = (_gender == FEM ? _init_rate_fem : _init_rate_mal);
sequence[1] = (_gender == FEM ? _init_rate_fem : _init_rate_mal);
}
}
| void TTDispersal::mutate | ( | ) | [virtual] |
Mutation procedure, perform mutations on the genes sequence.
Implements TTrait.
Definition at line 326 of file ttdispersal.cc.
{
double step;
unsigned int nbMut = (unsigned int)RAND::Poisson(2*_mut_rate);
for(unsigned int i = 0; i < nbMut; i++) {
step = -1.0 * _mut_mean * log(1 - RAND::Uniform());
if(RAND::RandBool())
sequence[i] = ((sequence[i] + step) >= 1.0 ? 1.0 : sequence[i] + step);
else
sequence[i] = ((sequence[i] - step) <= 0.0 ? 0.0 : sequence[i] - step);
}
}
| bool TTDispersal::operator!= | ( | const TTrait & | TP | ) | [virtual] |
Implements TTrait.
Definition at line 261 of file ttdispersal.cc.
{
if( !((*this) == T) )
return true;
else
return false;
}
| TTDispersal & TTDispersal::operator= | ( | const TTrait & | ) | [virtual] |
Copies the complete state of the trait from right to left side of the operator, sequence data included.
Implements TTrait.
Definition at line 221 of file ttdispersal.cc.
{
const TTDispersal& TD = dynamic_cast<const TTDispersal&> (T);
if(this != &TD) {
_mut_rate = TD._mut_rate;
_mut_mean = TD._mut_mean;
_init_rate_fem = TD._init_rate_fem;
_init_rate_mal = TD._init_rate_mal;
_gender = TD._gender;
_type = TD._type;
sequence[0] = TD.sequence[0];
sequence[1] = TD.sequence[1];
_phenotype = TD._phenotype;
_myProto = TD._myProto;
}
return *this;
}
| bool TTDispersal::operator== | ( | const TTrait & | ) | [virtual] |
Checks for parameters equivalence, not genetic equivalence.
Implements TTrait.
Definition at line 243 of file ttdispersal.cc.
{
if(_type.compare(T.get_type()) != 0) return false;
const TTDispersal& TD = dynamic_cast<const TTDispersal&> (T);
if(this != &TD) {
// if(_mut_rate != TD._mut_rate)return false;
// if(_mut_mean != TD._mut_mean)return false;
if(_gender != TD._gender) return false;
if(_type != TD._type) return false;
}
return true;
}
| virtual void TTDispersal::reset | ( | ) | [inline, virtual] |
Called at the end of each simulation/replicate, deallocates sequence memory.
Implements TTrait.
Definition at line 88 of file ttdispersal.h.
References init().
{init();}
| virtual bool TTDispersal::retrieve_data | ( | BinaryStorageBuffer * | reader | ) | [inline, virtual] |
Interface to retrieve the same data from the binary buffer.
Implements StorableComponent.
Definition at line 108 of file ttdispersal.h.
References BinaryStorageBuffer::read(), and sequence.
| void TTDispersal::set_gender | ( | sex_t | val | ) | [inline] |
| void TTDispersal::set_init_rate_fem | ( | double | val | ) | [inline] |
| void TTDispersal::set_init_rate_mal | ( | double | val | ) | [inline] |
| void TTDispersal::set_mut_mean | ( | double | val | ) | [inline] |
| void TTDispersal::set_mut_rate | ( | double | val | ) | [inline] |
| void TTDispersal::set_proto | ( | TProtoDispersal * | P | ) | [inline] |
| virtual void TTDispersal::set_sequence | ( | void ** | seq | ) | [inline, virtual] |
Called to set the sequence pointer to an existing trait.
| seq | the existing sequence pointer |
Implements TTrait.
Definition at line 98 of file ttdispersal.h.
{ }
| virtual void* TTDispersal::set_trait | ( | void * | value | ) | [inline, virtual] |
Called to set the phenotypic to a particular value or to give context-dependant value(s) to the trait.
| value | the value passed to the trait |
Implements TTrait.
Definition at line 99 of file ttdispersal.h.
{return value;}
| void TTDispersal::set_type | ( | trait_t | val | ) | [inline] |
| virtual void TTDispersal::set_value | ( | ) | [inline, virtual] |
Tells the trait to set its phenotype from genotype, should be used instead of getValue().
Implements TTrait.
Definition at line 92 of file ttdispersal.h.
References _phenotype, and sequence.
{_phenotype = (sequence[0] + sequence[1])/2.0;}
| void TTDispersal::show_up | ( | ) | [virtual] |
| virtual void TTDispersal::store_data | ( | BinaryStorageBuffer * | saver | ) | [inline, virtual] |
Interface to store the component data (e.g. gene values) into a binary buffer.
Implements StorableComponent.
Definition at line 107 of file ttdispersal.h.
References sequence, and BinaryStorageBuffer::store().
sex_t TTDispersal::_gender [private] |
the gender of the trait, will determine its type.
Definition at line 58 of file ttdispersal.h.
Referenced by set_gender().
double TTDispersal::_init_rate_fem [private] |
Initial allele for female dispersal.
Definition at line 51 of file ttdispersal.h.
Referenced by set_init_rate_fem().
double TTDispersal::_init_rate_mal [private] |
Initial allele for male dispersal.
Definition at line 53 of file ttdispersal.h.
Referenced by set_init_rate_mal().
double TTDispersal::_mut_mean [private] |
double TTDispersal::_mut_rate [private] |
The allelic mutation rate.
The mutation distribution is exponential, centered on the allelic value.
Definition at line 47 of file ttdispersal.h.
Referenced by set_mut_rate().
TProtoDispersal* TTDispersal::_myProto [private] |
Definition at line 55 of file ttdispersal.h.
Referenced by set_proto().
double TTDispersal::_phenotype [private] |
Definition at line 63 of file ttdispersal.h.
Referenced by getValue(), and set_value().
trait_t TTDispersal::_type [private] |
The trait's type.
Definition at line 60 of file ttdispersal.h.
Referenced by get_type(), and set_type().
double TTDispersal::sequence[2] [private] |
One diploid locus coding for a sex-specific dispersal rate.
Definition at line 62 of file ttdispersal.h.
Referenced by get_allele(), init(), retrieve_data(), set_value(), and store_data().
1.7.5.1 -- Nemo is hosted by