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

Set patch-specifiec initial genotypes values. More...

#include <LCEquanti.h>

+ Inheritance diagram for LCE_QuantiModifier:
+ Collaboration diagram for LCE_QuantiModifier:

Public Member Functions

 LCE_QuantiModifier ()
 
virtual ~LCE_QuantiModifier ()
 
virtual void execute ()
 
void setVefromVa (Patch *patch, age_idx AGE)
 
void setIndPhenotype (Patch *patch, sex_t SEX, age_idx AGE)
 
virtual LifeCycleEventclone ()
 
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
virtual age_t removeAgeClass ()
 
virtual age_t addAgeClass ()
 
virtual age_t requiredAgeClass ()
 
- Public Member Functions inherited from LifeCycleEvent
 LifeCycleEvent (const char *name, const char *trait_link)
 Cstor. More...
 
virtual ~LifeCycleEvent ()
 
virtual void init (Metapop *popPtr)
 Sets the pointer to the current Metapop and the trait link if applicable. More...
 
virtual bool attach_trait (string trait)
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 
virtual void set_event_name (std::string &name)
 Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set. More...
 
virtual void set_event_name (const char *name)
 
virtual string & get_event_name ()
 Accessor to the LCE's name. More...
 
virtual int get_rank ()
 Accessor to the LCE rank in the life cycle. More...
 
virtual void set_pop_ptr (Metapop *popPtr)
 Accessors for the population pointer. More...
 
virtual Metapopget_pop_ptr ()
 
- 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_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

TProtoQuanti_QuantiProto
 
vector< double > _h2
 
TMatrix _occurrences
 
unsigned int _next_occurrence
 
bool _is_permanent
 
age_t _age_flag
 
vector< double >(TTQuantiSH::* _get_VA_func_ptr )(Patch *, const age_idx)
 

Additional Inherited Members

- Protected Attributes inherited from LifeCycleEvent
std::string _event_name
 The param name to be read in the init file. More...
 
Metapop_popPtr
 The ptr to the current Metapop. More...
 
std::string _LCELinkedTraitType
 The name of the linked trait. More...
 
int _LCELinkedTraitIndex
 The index in the individual's trait table of the linked trait. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Detailed Description

Set patch-specifiec initial genotypes values.

Constructor & Destructor Documentation

◆ LCE_QuantiModifier()

LCE_QuantiModifier::LCE_QuantiModifier ( )
240  : LifeCycleEvent("quanti_modifier","quant"),
241  _QuantiProto(0),
242  _next_occurrence(0),
243  _is_permanent(0),
244  _age_flag(0),
246  {
248 
249  add_parameter("quanti_modifier_at_generation", INT, true, false, 0, 0, NULL);
250  add_parameter("quanti_modifier_at_age", STR, true, false, 0, 0, updater);
251  add_parameter("quanti_modifier_is_permanent", BOOL, false, false, 0, 0, updater);
252 
253 // add_parameter("quanti_modifier_target", STR, false, false, 0, 0, updater); // what to affect
254 // add_parameter("quanti_modifier_values", MAT, false, false, 0, 0, updater); // how to affect target
255 
256  }
vector< double >(TTQuantiSH::* _get_VA_func_ptr)(Patch *, const age_idx)
Definition: LCEquanti.h:89
virtual bool setParameters()
Definition: LCEquanti.cc:260
bool _is_permanent
Definition: LCEquanti.h:85
age_t _age_flag
Definition: LCEquanti.h:87
unsigned int _next_occurrence
Definition: LCEquanti.h:83
TProtoQuanti * _QuantiProto
Definition: LCEquanti.h:77
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98
Implementation of the ParamUpdaterBase interface.
Definition: param.h:363
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
@ BOOL
Definition: types.h:78
@ STR
Definition: types.h:78
@ INT
Definition: types.h:78

References SimComponent::add_parameter(), BOOL, INT, setParameters(), and STR.

Referenced by clone().

◆ ~LCE_QuantiModifier()

virtual LCE_QuantiModifier::~LCE_QuantiModifier ( )
inlinevirtual
96 { }

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_QuantiModifier::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

114 {return 0;}

◆ clone()

virtual LifeCycleEvent* LCE_QuantiModifier::clone ( )
inlinevirtual

Implements LifeCycleEvent.

105 {return new LCE_QuantiModifier();}
LCE_QuantiModifier()
Definition: LCEquanti.cc:240

References LCE_QuantiModifier().

◆ execute()

void LCE_QuantiModifier::execute ( )
virtual

Implements LifeCycleEvent.

317 {
318  unsigned int gen = _popPtr->getCurrentGeneration();
319 
320  if(!(
321  gen == _occurrences.get(0, _next_occurrence) ||
323  ))
324  return;
325 
326  // update the next occurrence:
329 
330 
331  // for now only implementing the heritability setting
332  _h2 = _QuantiProto->get_heritability(); //may have been reset during a run
333 
334  // we have to make sure that the phenotype will be calculated with Ve
335  // this is not guaranteed if Ve was not given in input
337 
338  Patch *patch;
339 
340  // compute Va in each patch to set Ve to match the h2 required
341  for(unsigned int i = 0; i < _popPtr->getPatchNbr(); ++i)
342  {
343 
344  patch = _popPtr->getPatch(i);
345 
346  if(_age_flag & OFFSPRG) {
347  setVefromVa(patch, OFFSx);
348  setIndPhenotype(patch, FEM, OFFSx);
349  setIndPhenotype(patch, MAL, OFFSx);
350  }
351 
352  if(_age_flag & ADULTS) {
353  setVefromVa(patch, ADLTx);
354  setIndPhenotype(patch, FEM, ADLTx);
355  setIndPhenotype(patch, MAL, ADLTx);
356  }
357  }
358 
359 }
TMatrix _occurrences
Definition: LCEquanti.h:81
vector< double > _h2
Definition: LCEquanti.h:79
void setIndPhenotype(Patch *patch, sex_t SEX, age_idx AGE)
Definition: LCEquanti.cc:386
void setVefromVa(Patch *patch, age_idx AGE)
Definition: LCEquanti.cc:363
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
unsigned int getPatchNbr()
Definition: metapop.h:276
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
unsigned int getCurrentGeneration()
Definition: metapop.h:296
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:432
unsigned int ncols() const
Definition: tmatrix.h:216
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:193
void set_trait_value_func_ptr(bool withVe)
Definition: ttquanti.cc:698
vector< double > get_heritability()
Definition: ttquanti.h:425
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
@ OFFSx
Definition: types.h:42
@ ADLTx
Definition: types.h:42

References _age_flag, _h2, _is_permanent, _next_occurrence, _occurrences, LifeCycleEvent::_popPtr, _QuantiProto, ADLTx, ADULTS, FEM, TMatrix::get(), TProtoQuanti::get_heritability(), Metapop::getCurrentGeneration(), Metapop::getPatch(), Metapop::getPatchNbr(), MAL, TMatrix::ncols(), OFFSPRG, OFFSx, TProtoQuanti::set_trait_value_func_ptr(), setIndPhenotype(), and setVefromVa().

◆ loadFileServices()

virtual void LCE_QuantiModifier::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

110 {}

◆ loadStatServices()

virtual void LCE_QuantiModifier::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

111 {}

◆ removeAgeClass()

virtual age_t LCE_QuantiModifier::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

113 {return 0;}

◆ requiredAgeClass()

virtual age_t LCE_QuantiModifier::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

115 {return 0;}

◆ resetParameterFromSource()

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

Implements SimComponent.

112 {return false;}

◆ setIndPhenotype()

void LCE_QuantiModifier::setIndPhenotype ( Patch patch,
sex_t  SEX,
age_idx  AGE 
)
387 {
388  for(unsigned int i = 0; i < patch->size(SEX, AGE); ++i)
389  {
390  patch->get(SEX, AGE, i)->setTraitValue(_LCELinkedTraitIndex);
391  }
392 }
void setTraitValue(IDX T)
Calls the value setting procedure of a particular trait.
Definition: individual.h:261
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:89
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:498
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:534

References LifeCycleEvent::_LCELinkedTraitIndex, Patch::get(), Individual::setTraitValue(), and Patch::size().

Referenced by execute().

◆ setParameters()

bool LCE_QuantiModifier::setParameters ( )
virtual

Implements SimComponent.

261 {
262  _QuantiProto = dynamic_cast<TProtoQuanti*> ( _popPtr->getTraitPrototype("quant") );
263 
264  if(!get_parameter("quanti_modifier_at_generation")->isMatrix()) {
265 
266  _occurrences.reset(1, 1, get_parameter_value("quanti_modifier_at_generation"));
267 
268  } else {
269 
270  get_parameter("quanti_modifier_at_generation")->getMatrix(&_occurrences);
271 
272  if(_occurrences.nrows()>1)
273  return error("LCE quanti_modifier:: multiple generations must be provided in a 1D array, with a single row\n");
274 
275  }
276 
277  _next_occurrence = 0; //this is the index in the array
278 
279  string flag = get_parameter("quanti_modifier_at_age")->getArg();
280 
281  std::for_each(flag.begin(), flag.end(), [](char& c){c = ::tolower(c);});
282 
283  if (flag == "adults" || flag == "adult" || flag == "4") {
284 
285  _age_flag = ADULTS;
286 
287  } else if (flag == "offsprings" || flag == "offspring" || flag == "1" ) {
288 
289  _age_flag = OFFSPRG;
290 
291  } else if (flag == "all" || flag == "7") {
292 
293  _age_flag = ALL;
294 
295  } else {
296 
297  fatal("LCE quanti_modifier:: targeted age class must be specified as \"adults\", \"offspring\", or \"all\" (%s)\n", flag.c_str());
298  }
299 
300  if(get_parameter("quanti_modifier_is_permanent")->isSet())
301  _is_permanent = true;
302  else
303  _is_permanent = false;
304 
305  //check for allele model
308  else
310 
311  return true;
312 }
TraitPrototype * getTraitPrototype(trait_t type)
Accessor to a TraitPrototype.
Definition: indfactory.cc:140
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:172
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
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
void reset(unsigned int rows, unsigned int cols)
Re-allocate the existing matrix with assigned rows and cols dimensions and all elements to 0.
Definition: tmatrix.h:161
unsigned int nrows() const
Definition: tmatrix.h:213
TProtoQuanti.
Definition: ttquanti.h:409
unsigned int get_dominance_model()
Definition: ttquanti.h:461
vector< double > getVaNoDominance(Patch *curPop, const age_idx AGE)
Definition: ttquanti.cc:5625
vector< double > getVaWithDominance(Patch *curPop, const age_idx AGE)
computation of the additive genetic variance from the average excess of each allele exact under rando...
Definition: ttquanti.cc:5724
void fatal(const char *str,...)
Definition: output.cc:96
int error(const char *str,...)
Definition: output.cc:77
#define ALL
All ages age class flag.
Definition: types.h:56

References _age_flag, _get_VA_func_ptr, _is_permanent, _next_occurrence, _occurrences, LifeCycleEvent::_popPtr, _QuantiProto, ADULTS, ALL, error(), fatal(), TProtoQuanti::get_dominance_model(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getArg(), Param::getMatrix(), IndFactory::getTraitPrototype(), TTQuantiSH::getVaNoDominance(), TTQuantiSH::getVaWithDominance(), Param::isMatrix(), TMatrix::nrows(), OFFSPRG, and TMatrix::reset().

Referenced by LCE_QuantiModifier().

◆ setVefromVa()

void LCE_QuantiModifier::setVefromVa ( Patch patch,
age_idx  AGE 
)
364 {
365  vector<double> Va;
366 
367  Va = (_QuantiProto->get_stater()->*_get_VA_func_ptr)(patch, AGE); // compute Va, and Vg
368 
369 // cout << "LCE_QuantiModifier::setVefromVa("<<AGE<<"):: Va/Ve = ";
370 
371 
372  // set Ve to match h2 given computed value of Va
373  // Vg has been set during the process, its value is accessible via the stater's interface
374  for(unsigned int j = 0; j < _QuantiProto->get_num_traits(); ++j) {
375 
376 // cout << Va[j] <<"/"<< Va[j]/_h2[j] - _QuantiProto->get_stater()->getVg(j) <<" ";
377 
378  _QuantiProto->set_eVarianceSD( j, sqrt( Va[j]/_h2[j] - _QuantiProto->get_stater()->getVg(j) ) );
379  }
380 
381 // cout<<endl;
382 }
TTQuantiSH * get_stater()
Definition: ttquanti.h:437
unsigned int get_num_traits()
Definition: ttquanti.h:417
void set_eVarianceSD(unsigned int trait, double SD)
Definition: ttquanti.cc:2345
double getVg(unsigned int i)
Definition: ttquanti.h:767

References _get_VA_func_ptr, _h2, _QuantiProto, TProtoQuanti::get_num_traits(), TProtoQuanti::get_stater(), TTQuantiSH::getVg(), and TProtoQuanti::set_eVarianceSD().

Referenced by execute().

Member Data Documentation

◆ _age_flag

age_t LCE_QuantiModifier::_age_flag
private

Referenced by execute(), and setParameters().

◆ _get_VA_func_ptr

vector<double>(TTQuantiSH::* LCE_QuantiModifier::_get_VA_func_ptr) (Patch *, const age_idx)
private

Referenced by setParameters(), and setVefromVa().

◆ _h2

vector<double> LCE_QuantiModifier::_h2
private

Referenced by execute(), and setVefromVa().

◆ _is_permanent

bool LCE_QuantiModifier::_is_permanent
private

Referenced by execute(), and setParameters().

◆ _next_occurrence

unsigned int LCE_QuantiModifier::_next_occurrence
private

Referenced by execute(), and setParameters().

◆ _occurrences

TMatrix LCE_QuantiModifier::_occurrences
private

Referenced by execute(), and setParameters().

◆ _QuantiProto

TProtoQuanti* LCE_QuantiModifier::_QuantiProto
private

Referenced by execute(), setParameters(), and setVefromVa().


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