Nemo  2.4.0b
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 ()
 
virtual void init ()
 
virtual void reset ()
 
virtual TTDispersalhatch ()
 
virtual TProtoDispersalclone ()
 
virtual trait_t get_type () const
 
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
bool setNonRandom ()
 
bool setRandom ()
 
bool get_init_mode ()
 
TMatrixget_init_dist_params ()
 
string get_init_dist ()
 
- 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)
45 : _mut_rate(0), _mut_mean(0.2), _init_rate_fem(-1.0), _init_rate_mal(-1.0), _gender(sex), _stats(0)
46 {
47 // _type = (_gender == FEM ? "fdisp" : "mdisp");
48 
49  set_paramset("dispersal", false, this);
50 
51  add_parameter("disp_mutation_rate",DBL,true,true,0,1);
52  add_parameter("disp_mutation_mean",DBL,true,true,0,1);
53  add_parameter("disp_init_rate",DBL,false,true,0,1);
54  add_parameter("disp_init_rate_fem",DBL,false,true,0,1);
55  add_parameter("disp_init_rate_mal",DBL,false,true,0,1);
56  add_parameter("disp_init_distribution", STR, false, false, 0, 0);
57  add_parameter("disp_init_dist_params", MAT, false, false, 0, 0);
58 }
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:86
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
TTDispersalSH * _stats
The trait's type.
Definition: ttdispersal.h:165
double _init_rate_mal
Initial allele for male dispersal.
Definition: ttdispersal.h:154
sex_t _gender
The gender of the trait, will determine its type.
Definition: ttdispersal.h:161
double _mut_mean
Mean mutation step.
Definition: ttdispersal.h:150
double _init_rate_fem
Initial allele for female dispersal.
Definition: ttdispersal.h:152
double _mut_rate
The allelic mutation rate.
Definition: ttdispersal.h:148
@ DBL
Definition: types.h:78
@ MAT
Definition: types.h:78
@ STR
Definition: types.h:78

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

Referenced by clone().

◆ TProtoDispersal() [2/2]

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

References SimComponent::_paramSet.

◆ ~TProtoDispersal()

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

References _stats.

Member Function Documentation

◆ clone()

virtual TProtoDispersal* TProtoDispersal::clone ( )
inlinevirtual

Implements TraitPrototype.

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

References TProtoDispersal().

◆ get_init_dist()

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

References _init_dist.

Referenced by TTDispersal::init_sequence().

◆ get_init_dist_params()

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

References _init_dist_param.

Referenced by TTDispersal::init_sequence().

◆ get_init_mode()

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

References _init_random.

Referenced by TTDispersal::init_sequence().

◆ get_type()

virtual trait_t TProtoDispersal::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

129 {return (_gender == FEM ? FDISP : MDISP);}
@ FEM
Definition: types.h:37
#define MDISP
Definition: types.h:69
#define FDISP
Definition: types.h:68

References _gender, FDISP, FEM, and MDISP.

◆ hatch()

TTDispersal * TProtoDispersal::hatch ( )
virtual

Implements TraitPrototype.

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

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
125 {}

◆ loadFileServices()

virtual void TProtoDispersal::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

135 {}

◆ loadStatServices()

void TProtoDispersal::loadStatServices ( StatServices loader)
virtual

Implements SimComponent.

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

References _stats, and StatServices::attach().

◆ reset()

virtual void TProtoDispersal::reset ( )
inlinevirtual

Implements TraitPrototype.

126 {}

◆ resetParameterFromSource()

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

Implements SimComponent.

137 {return false;}

◆ retrieve_data()

virtual bool TProtoDispersal::retrieve_data ( BinaryStorageBuffer reader)
inlinevirtual

Implements StorableComponent.

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

References _gender, and BinaryStorageBuffer::read().

◆ setNonRandom()

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

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

◆ setParameters()

bool TProtoDispersal::setParameters ( )
virtual

Implements SimComponent.

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

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

◆ setRandom()

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

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

Referenced by setParameters().

◆ store_data()

virtual void TProtoDispersal::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

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

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.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR