Nemo  2.2.0
Public Member Functions | Private Attributes
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:

List of all members.

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 TTDispersalclone ()
 Returns a copy of itself.
virtual TTDispersaloperator= (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

Detailed Description

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

Definition at line 43 of file ttdispersal.h.


Constructor & Destructor Documentation

TTDispersal::TTDispersal ( sex_t  sex)
Parameters:
sexdetermines the type of this trait (FDISP for female dispersal, MDISP for male dispersal)

Definition at line 211 of file ttdispersal.cc.

Referenced by clone().

: _mut_rate(0), _mut_mean(0.2), _init_rate_fem(-1.0), _init_rate_mal(-1.0), _myProto(0), 
  _gender(sex)
{
  _type = (_gender == FEM ? FDISP : MDISP);
  sequence[0] = sequence[1] = 0;
}
TTDispersal::TTDispersal ( const TTDispersal TP) [inline]
virtual TTDispersal::~TTDispersal ( ) [inline, virtual]

Definition at line 72 of file ttdispersal.h.

{ }

Member Function Documentation

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.

Returns:
the allelic value at position 'all' at locus 'loc'
Parameters:
loclocus position in the sequence
allwhich 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]
Returns:
NULL, here the sequence is not a dble ptr.

Implements TTrait.

Definition at line 96 of file ttdispersal.h.

{return 0;}
virtual trait_t TTDispersal::get_type ( ) const [inline, virtual]

type accessor.

Returns:
the trait's type

Implements TTrait.

Definition at line 91 of file ttdispersal.h.

References _type.

{return _type;}
virtual void* TTDispersal::getValue ( ) [inline, virtual]
Returns:
the dispersal rate, mean of the 2 alleles beared at this dispersal locus.

Implements TTrait.

Definition at line 94 of file ttdispersal.h.

References _phenotype.

{return &_phenotype;}
void TTDispersal::inherit ( TTrait mother,
TTrait father 
) [virtual]

Inheritance procedure, creates a new trait from mother's and father's traits.

Parameters:
motherthe mother's trait
fatherthe 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().

{ sequence[0] = 0.0; sequence[1] = 0.0; }
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.

{reader->read(&sequence, 2 * sizeof(double));return true;}
void TTDispersal::set_gender ( sex_t  val) [inline]

Definition at line 80 of file ttdispersal.h.

References _gender.

{_gender = val;}
void TTDispersal::set_init_rate_fem ( double  val) [inline]

Definition at line 78 of file ttdispersal.h.

References _init_rate_fem.

{_init_rate_fem = val;}
void TTDispersal::set_init_rate_mal ( double  val) [inline]

Definition at line 79 of file ttdispersal.h.

References _init_rate_mal.

{_init_rate_mal = val;}
void TTDispersal::set_mut_mean ( double  val) [inline]

Definition at line 77 of file ttdispersal.h.

References _mut_mean.

{_mut_mean = val;}
void TTDispersal::set_mut_rate ( double  val) [inline]

Definition at line 76 of file ttdispersal.h.

References _mut_rate.

{_mut_rate = val;}
void TTDispersal::set_proto ( TProtoDispersal P) [inline]

Definition at line 82 of file ttdispersal.h.

References _myProto.

{_myProto = P;}
virtual void TTDispersal::set_sequence ( void **  seq) [inline, virtual]

Called to set the sequence pointer to an existing trait.

Parameters:
seqthe 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.

Parameters:
valuethe value passed to the trait
Returns:
the argument passed

Implements TTrait.

Definition at line 99 of file ttdispersal.h.

{return value;}
void TTDispersal::set_type ( trait_t  val) [inline]

Definition at line 81 of file ttdispersal.h.

References _type.

{_type = val;}
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]

Writes some info to stdout.

Implements TTrait.

Definition at line 347 of file ttdispersal.cc.

{
  set_value();
  message("\n  Trait type: %s\n\
       value: %f\n\
    sequence: \n\
%f\n\
%f\n",get_type().c_str(), *(double*)getValue(), sequence[0], sequence[1]);
}
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().

{saver->store(&sequence, 2 * sizeof(double));}

Member Data Documentation

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]

The mean mutation step.

Definition at line 49 of file ttdispersal.h.

Referenced by set_mut_mean().

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().

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().

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().


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

Generated for Nemo v2.2.0 by  doxygen 1.7.5.1 -- Nemo is hosted by  SourceForge.net Logo