Nemo  2.4.2
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 ( )
238  : LifeCycleEvent("quanti_modifier","quant"),
239  _QuantiProto(0),
240  _next_occurrence(0),
241  _is_permanent(0),
242  _age_flag(0),
244  {
246 
247  add_parameter("quanti_modifier_at_generation", INT, true, false, 0, 0, NULL);
248  add_parameter("quanti_modifier_at_age", STR, true, false, 0, 0, updater);
249  add_parameter("quanti_modifier_is_permanent", BOOL, false, false, 0, 0, updater);
250 
251 // add_parameter("quanti_modifier_target", STR, false, false, 0, 0, updater); // what to affect
252 // add_parameter("quanti_modifier_values", MAT, false, false, 0, 0, updater); // how to affect target
253 
254  }
vector< double >(TTQuantiSH::* _get_VA_func_ptr)(Patch *, const age_idx)
Definition: LCEquanti.h:87
virtual bool setParameters()
Definition: LCEquanti.cc:258
bool _is_permanent
Definition: LCEquanti.h:83
age_t _age_flag
Definition: LCEquanti.h:85
unsigned int _next_occurrence
Definition: LCEquanti.h:81
TProtoQuanti * _QuantiProto
Definition: LCEquanti.h:75
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:96
Implementation of the ParamUpdaterBase interface.
Definition: param.h:371
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:110
@ BOOL
Definition: types.h:76
@ STR
Definition: types.h:76
@ INT
Definition: types.h:76

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

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~LCE_QuantiModifier()

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

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_QuantiModifier::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

112 {return 0;}

◆ clone()

virtual LifeCycleEvent* LCE_QuantiModifier::clone ( )
inlinevirtual

Implements LifeCycleEvent.

103 {return new LCE_QuantiModifier();}
LCE_QuantiModifier()
Definition: LCEquanti.cc:238

References LCE_QuantiModifier().

◆ execute()

void LCE_QuantiModifier::execute ( )
virtual

Implements LifeCycleEvent.

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

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.

108 {}

◆ loadStatServices()

virtual void LCE_QuantiModifier::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

109 {}

◆ removeAgeClass()

virtual age_t LCE_QuantiModifier::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

111 {return 0;}

◆ requiredAgeClass()

virtual age_t LCE_QuantiModifier::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

113 {return 0;}

◆ resetParameterFromSource()

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

Implements SimComponent.

110 {return false;}

◆ setIndPhenotype()

void LCE_QuantiModifier::setIndPhenotype ( Patch patch,
sex_t  SEX,
age_idx  AGE 
)
385 {
386  for(unsigned int i = 0; i < patch->size(SEX, AGE); ++i)
387  {
388  patch->get(SEX, AGE, i)->setTraitValue(_LCELinkedTraitIndex);
389  }
390 }
void setTraitValue(IDX T)
Calls the value setting procedure of a particular trait.
Definition: individual.h:259
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:87
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:496
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:532

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

Referenced by execute().

+ Here is the caller graph for this function:

◆ setParameters()

bool LCE_QuantiModifier::setParameters ( )
virtual

Implements SimComponent.

259 {
260  _QuantiProto = dynamic_cast<TProtoQuanti*> ( _popPtr->getTraitPrototype("quant") );
261 
262  if(!get_parameter("quanti_modifier_at_generation")->isMatrix()) {
263 
264  _occurrences.reset(1, 1, get_parameter_value("quanti_modifier_at_generation"));
265 
266  } else {
267 
268  get_parameter("quanti_modifier_at_generation")->getMatrix(&_occurrences);
269 
270  if(_occurrences.nrows()>1)
271  return error("LCE quanti_modifier:: multiple generations must be provided in a 1D array, with a single row\n");
272 
273  }
274 
275  _next_occurrence = 0; //this is the index in the array
276 
277  string flag = get_parameter("quanti_modifier_at_age")->getArg();
278 
279  std::for_each(flag.begin(), flag.end(), [](char& c){c = ::tolower(c);});
280 
281  if (flag == "adults" || flag == "adult" || flag == "4") {
282 
283  _age_flag = ADULTS;
284 
285  } else if (flag == "offsprings" || flag == "offspring" || flag == "1" ) {
286 
287  _age_flag = OFFSPRG;
288 
289  } else if (flag == "all" || flag == "7") {
290 
291  _age_flag = ALL;
292 
293  } else {
294 
295  fatal("LCE quanti_modifier:: targeted age class must be specified as \"adults\", \"offspring\", or \"all\" (%s)\n", flag.c_str());
296  }
297 
298  if(get_parameter("quanti_modifier_is_permanent")->isSet())
299  _is_permanent = true;
300  else
301  _is_permanent = false;
302 
303  //check for allele model
306  else
308 
309  return true;
310 }
TraitPrototype * getTraitPrototype(trait_t type)
Accessor to a TraitPrototype.
Definition: indfactory.cc:138
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:180
string getArg()
Definition: param.h:142
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:396
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:141
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:137
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:159
unsigned int nrows() const
Definition: tmatrix.h:211
TProtoQuanti.
Definition: ttquanti.h:413
unsigned int get_dominance_model()
Definition: ttquanti.h:476
vector< double > getVaNoDominance(Patch *curPop, const age_idx AGE)
Definition: ttquanti.cc:5386
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:5485
void fatal(const char *str,...)
Definition: output.cc:98
int error(const char *str,...)
Definition: output.cc:77
#define ALL
All ages age class flag.
Definition: types.h:54

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

+ Here is the caller graph for this function:

◆ setVefromVa()

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

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

Referenced by execute().

+ Here is the caller graph for this function:

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.2 by  doxygen 1.9.1

Catalogued on GSR