Nemo  2.4.0
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
TProtoDispersal Class Reference

Prototype of the evolving dispersal trait, defines the sex-specific trait type. More...

#include <ttdispersal.h>

+ Inheritance diagram for TProtoDispersal:
+ Collaboration diagram for TProtoDispersal:

Public Member Functions

 TProtoDispersal (sex_t sex)
 
 TProtoDispersal (const TProtoDispersal &TP)
 
virtual ~TProtoDispersal ()
 
bool setNonRandom ()
 
bool setRandom ()
 
bool get_init_mode ()
 
TMatrixget_init_dist_params ()
 
string get_init_dist ()
 
TraitPrototype implementations
virtual void init ()
 
virtual void reset ()
 
virtual TTDispersalhatch ()
 
virtual TProtoDispersalclone ()
 
virtual trait_t get_type () const
 
virtual int get_phenotype_dimension ()
 Returns the dimension of the phenotype of the trait (size of the array accessed with TTrait::getValue() More...
 
virtual int get_allele_number ()
 Returns the number of allele per locus. More...
 
virtual int get_locus_number ()
 Returns the number of locus. More...
 
virtual bool is_mappable ()
 Checks if the trait is mappable, i.e., if the loci can be placed on a genetic map. More...
 
virtual bool is_mapped ()
 Checks if the trait's loci are placed on a genetic map. More...
 
virtual vector< unsigned int > get_locus_map_positions ()
 Returns the map positions of the loci in vector. More...
 
StorableComponent implementation
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
SimComponent implementation
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
- Public Member Functions inherited from TraitPrototype
virtual void set_index (int idx)
 Sets the traits index. More...
 
virtual int get_index ()
 Index getter. More...
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 Sets a new ParamSet and name it. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 

Private Attributes

double _mut_rate
 The allelic mutation rate. More...
 
double _mut_mean
 Mean mutation step. More...
 
double _init_rate_fem
 Initial allele for female dispersal. More...
 
double _init_rate_mal
 Initial allele for male dispersal. More...
 
string _init_dist
 
TMatrix _init_dist_param
 
bool _init_random
 
sex_t _gender
 The gender of the trait, will determine its type. More...
 
TTDispersalSH_stats
 The trait's type. More...
 

Additional Inherited Members

- Protected Attributes inherited from TraitPrototype
int _index
 The trait index in the Individual traits table. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Detailed Description

Prototype of the evolving dispersal trait, defines the sex-specific trait type.

Constructor & Destructor Documentation

◆ TProtoDispersal() [1/2]

TProtoDispersal::TProtoDispersal ( sex_t  sex)
44 : _mut_rate(0), _mut_mean(0.2), _init_rate_fem(-1.0), _init_rate_mal(-1.0), _gender(sex), _stats(0)
45 {
46 // _type = (_gender == FEM ? "fdisp" : "mdisp");
47 
48  set_paramset("dispersal", false, this);
49 
50  add_parameter("disp_mutation_rate",DBL,true,true,0,1);
51  add_parameter("disp_mutation_mean",DBL,true,true,0,1);
52  add_parameter("disp_init_rate",DBL,false,true,0,1);
53  add_parameter("disp_init_rate_fem",DBL,false,true,0,1);
54  add_parameter("disp_init_rate_mal",DBL,false,true,0,1);
55  add_parameter("disp_init_distribution", STR, false, false, 0, 0);
56  add_parameter("disp_init_dist_params", MAT, false, false, 0, 0);
57 }
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:85
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:111
TTDispersalSH * _stats
The trait's type.
Definition: ttdispersal.h:187
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:176
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:183
double _mut_mean
Mean mutation step.
Definition: ttdispersal.h:172
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:174
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:170
@ DBL
Definition: types.h:77
@ MAT
Definition: types.h:77
@ STR
Definition: types.h:77

References SimComponent::add_parameter(), DBL, MAT, SimComponent::set_paramset(), and STR.

Referenced by clone().

+ Here is the caller graph for this function:

◆ TProtoDispersal() [2/2]

TProtoDispersal::TProtoDispersal ( const TProtoDispersal TP)
64 {
65  _paramSet = new ParamSet( *(TP._paramSet) ) ;
66 }
Parameters container, implemented in each SimComponent.
Definition: param.h:205
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:47

References SimComponent::_paramSet.

◆ ~TProtoDispersal()

TProtoDispersal::~TProtoDispersal ( )
virtual
71 {
72  if(_stats != NULL) delete _stats;
73 }

References _stats.

Member Function Documentation

◆ clone()

virtual TProtoDispersal* TProtoDispersal::clone ( )
inlinevirtual

Implements TraitPrototype.

133 {return new TProtoDispersal(*this);}
TProtoDispersal(sex_t sex)
Definition: ttdispersal.cc:43

References TProtoDispersal().

◆ get_allele_number()

virtual int TProtoDispersal::get_allele_number ( )
inlinevirtual

Returns the number of allele per locus.

Implements TraitPrototype.

138 {return 3;} // 3 > 2 means it's not di-allelic

◆ get_init_dist()

string TProtoDispersal::get_init_dist ( )
inline
166 {return _init_dist;}
string _init_dist
Definition: ttdispersal.h:178

References _init_dist.

Referenced by TTDispersal::init_sequence().

+ Here is the caller graph for this function:

◆ get_init_dist_params()

TMatrix* TProtoDispersal::get_init_dist_params ( )
inline
165 {return &_init_dist_param;}
TMatrix _init_dist_param
Definition: ttdispersal.h:179

References _init_dist_param.

Referenced by TTDispersal::init_sequence().

+ Here is the caller graph for this function:

◆ get_init_mode()

bool TProtoDispersal::get_init_mode ( )
inline
164 {return _init_random;}
bool _init_random
Definition: ttdispersal.h:180

References _init_random.

Referenced by TTDispersal::init_sequence().

+ Here is the caller graph for this function:

◆ get_locus_map_positions()

virtual vector< unsigned int > TProtoDispersal::get_locus_map_positions ( )
inlinevirtual

Returns the map positions of the loci in vector.

Implements TraitPrototype.

146 {return vector<unsigned int>(2,0);}

◆ get_locus_number()

virtual int TProtoDispersal::get_locus_number ( )
inlinevirtual

Returns the number of locus.

Implements TraitPrototype.

140 {return 2;}

◆ get_phenotype_dimension()

virtual int TProtoDispersal::get_phenotype_dimension ( )
inlinevirtual

Returns the dimension of the phenotype of the trait (size of the array accessed with TTrait::getValue()

Implements TraitPrototype.

136 {return 1;}

◆ get_type()

virtual trait_t TProtoDispersal::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

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

◆ hatch()

TTDispersal * TProtoDispersal::hatch ( )
virtual

Implements TraitPrototype.

190 {
191  TTDispersal* new_trait = new TTDispersal(_gender);
192 
193  new_trait->set_mut_rate(_mut_rate);
194  new_trait->set_mut_mean(_mut_mean);
195  new_trait->set_init_rate_fem(_init_rate_fem);
196  new_trait->set_init_rate_mal(_init_rate_mal);
197  new_trait->set_gender(_gender);
198 // new_trait->set_type(_type);
199  new_trait->set_proto(this);
200 
201  return new_trait;
202 }
Evolving dispersal trait, codes for female (_type = FDISP) or male (_type = MDISP) sex-specific dispe...
Definition: ttdispersal.h:43
void set_mut_mean(double val)
Definition: ttdispersal.h:76
void set_init_rate_fem(double val)
Definition: ttdispersal.h:77
void set_proto(TProtoDispersal *P)
Definition: ttdispersal.h:81
void set_mut_rate(double val)
Definition: ttdispersal.h:75
void set_gender(sex_t val)
Definition: ttdispersal.h:79
void set_init_rate_mal(double val)
Definition: ttdispersal.h:78

References _gender, _init_rate_fem, _init_rate_mal, _mut_mean, _mut_rate, TTDispersal::set_gender(), TTDispersal::set_init_rate_fem(), TTDispersal::set_init_rate_mal(), TTDispersal::set_mut_mean(), TTDispersal::set_mut_rate(), and TTDispersal::set_proto().

◆ init()

virtual void TProtoDispersal::init ( )
inlinevirtual
130 {}

◆ is_mappable()

virtual bool TProtoDispersal::is_mappable ( )
inlinevirtual

Checks if the trait is mappable, i.e., if the loci can be placed on a genetic map.

Implements TraitPrototype.

142 {return false;}

◆ is_mapped()

virtual bool TProtoDispersal::is_mapped ( )
inlinevirtual

Checks if the trait's loci are placed on a genetic map.

Implements TraitPrototype.

144 {return false;}

◆ loadFileServices()

virtual void TProtoDispersal::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

156 {}

◆ loadStatServices()

void TProtoDispersal::loadStatServices ( StatServices loader)
virtual

Implements SimComponent.

180 {
181  //allocate the stat handler
182  if(_stats == NULL)
183  _stats = new TTDispersalSH(this);
184  if(_stats != NULL) loader->attach(_stats);
185 }
virtual void attach(Handler *H)
attach the StatHandler to the current list (_statHandlers) of the StatServices
Definition: statservices.cc:176
The StatHandler for the evolving dispersal traits.
Definition: ttdispersal.h:196

References _stats, and StatServices::attach().

◆ reset()

virtual void TProtoDispersal::reset ( )
inlinevirtual

Implements TraitPrototype.

131 {}

◆ resetParameterFromSource()

virtual bool TProtoDispersal::resetParameterFromSource ( std::string  param,
SimComponent cmpt 
)
inlinevirtual

Implements SimComponent.

158 {return false;}

◆ retrieve_data()

virtual bool TProtoDispersal::retrieve_data ( BinaryStorageBuffer reader)
inlinevirtual

Implements StorableComponent.

151 {reader->read(&_gender, sizeof(sex_t));return true;}
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:220
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:35

References _gender, and BinaryStorageBuffer::read().

◆ setNonRandom()

bool TProtoDispersal::setNonRandom ( )
120 {
121 
122  Param* init_param = get_parameter("disp_init_rate");
123 
124  if(init_param->isSet()) {
125 
126  _init_rate_fem = init_param->getValue();
127 
128  _init_rate_mal = init_param->getValue();
129 
130  } else if (get_parameter("disp_init_rate_fem")->isSet() &&
131  get_parameter("disp_init_rate_mal")->isSet()) {
132 
133  _init_rate_fem = get_parameter_value("disp_init_rate_fem");
134 
135  _init_rate_mal = get_parameter_value("disp_init_rate_mal");
136 
137  } else {
138  error("dispersal trait init parameters not correctly set\n");
139  error("note that \"disp_init_rate_fem\" and \"disp_init_rate_mal\" must be set together\n");
140  return false;
141  }
142 
143  _init_random = false;
144 
145  return true;
146 }
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
double getValue()
Returns the argument value according to its type.
Definition: param.cc:367
bool isSet()
Definition: param.h:139
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:142
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:138
int error(const char *str,...)
Definition: output.cc:78

References _init_random, _init_rate_fem, _init_rate_mal, error(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getValue(), and Param::isSet().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ setParameters()

bool TProtoDispersal::setParameters ( )
virtual

Implements SimComponent.

78 {
79  _mut_rate = get_parameter_value("disp_mutation_rate");
80  _mut_mean = get_parameter_value("disp_mutation_mean");
81 
82  if (( get_parameter("disp_init_rate")->isSet() ||
83  get_parameter("disp_init_rate_fem")->isSet() ||
84  get_parameter("disp_init_rate_mal")->isSet() ) )
85  {
86 
87  if(get_parameter("disp_init_distribution")->isSet()) {
88  warning("both \"disp_init_rate[...]\" and \"disp_init_distribution\" are set\n");
89  warning("discarding \"disp_init_rate[...]\" parameters\n");
90  return setRandom();
91  }
92 
93  return setNonRandom();
94 
95  } else if (get_parameter("disp_init_distribution")->isSet()) {
96 
97  return setRandom();
98 
99  } else { //no init parameter specified
100 
101  Param* init_param = get_parameter("disp_init_distribution");
102 
103  init_param->setArg("uniform");
104  init_param->setIsSet(true);
105 
106  init_param = get_parameter("disp_init_dist_params");
107 
108  init_param->setArg("{{0,0}}");
109  init_param->setIsSet(true);
110 
111  return setRandom();
112 
113  }
114  return true;
115 }
void setArg(string value)
Sets the parameter's argument.
Definition: param.h:117
void setIsSet(bool value)
Sets the _isSet flag.
Definition: param.h:121
bool setNonRandom()
Definition: ttdispersal.cc:119
bool setRandom()
Definition: ttdispersal.cc:150
void warning(const char *str,...)
Definition: output.cc:57

References _mut_mean, _mut_rate, SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::setArg(), Param::setIsSet(), setNonRandom(), setRandom(), and warning().

◆ setRandom()

bool TProtoDispersal::setRandom ( )
151 {
152 
153  Param *init_param = get_parameter("disp_init_distribution");
154 
155  if (init_param->isSet()) {
156 
157  if (!get_parameter("disp_init_dist_params")->isSet()) {
158  error("parameter \"disp_init_distribution\" requires \"disp_init_dist_params\" to be set as well.\n");
159  return false;
160  } else {
161  get_parameter("disp_init_dist_params")->getMatrix(&_init_dist_param);
162  }
163 
164  _init_dist = init_param->getArg();
165 
166 
167  } else { //this should not happen...
168  error("something got wrong with the dispersal trait init distribution parameters\n");
169  return false;
170  }
171 
172  _init_random = true;
173 
174  return true;
175 }
string getArg()
Definition: param.h:137
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:377

References _init_dist, _init_dist_param, _init_random, error(), SimComponent::get_parameter(), Param::getArg(), Param::getMatrix(), and Param::isSet().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ store_data()

virtual void TProtoDispersal::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

150 {saver->store(&_gender, sizeof(sex_t));}
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:37

References _gender, and BinaryStorageBuffer::store().

Member Data Documentation

◆ _gender

sex_t TProtoDispersal::_gender
private

The gender of the trait, will determine its type.

Referenced by get_type(), hatch(), retrieve_data(), and store_data().

◆ _init_dist

string TProtoDispersal::_init_dist
private

Referenced by get_init_dist(), and setRandom().

◆ _init_dist_param

TMatrix TProtoDispersal::_init_dist_param
private

Referenced by get_init_dist_params(), and setRandom().

◆ _init_random

bool TProtoDispersal::_init_random
private

◆ _init_rate_fem

double TProtoDispersal::_init_rate_fem
private

Initial allele for female dispersal.

Referenced by hatch(), and setNonRandom().

◆ _init_rate_mal

double TProtoDispersal::_init_rate_mal
private

Initial allele for male dispersal.

Referenced by hatch(), and setNonRandom().

◆ _mut_mean

double TProtoDispersal::_mut_mean
private

Mean mutation step.

Referenced by hatch(), and setParameters().

◆ _mut_rate

double TProtoDispersal::_mut_rate
private

The allelic mutation rate.

Referenced by hatch(), and setParameters().

◆ _stats

TTDispersalSH* TProtoDispersal::_stats
private

The trait's type.

The trait's StatHandler.

Referenced by loadStatServices(), and ~TProtoDispersal().


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