Nemo  2.4.0
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 ( )
239  : LifeCycleEvent("quanti_modifier","quant"),
240  _QuantiProto(0),
241  _next_occurrence(0),
242  _is_permanent(0),
243  _age_flag(0),
245  {
247 
248  add_parameter("quanti_modifier_at_generation", INT, true, false, 0, 0, NULL);
249  add_parameter("quanti_modifier_at_age", STR, true, false, 0, 0, updater);
250  add_parameter("quanti_modifier_is_permanent", BOOL, false, false, 0, 0, updater);
251 
252 // add_parameter("quanti_modifier_target", STR, false, false, 0, 0, updater); // what to affect
253 // add_parameter("quanti_modifier_values", MAT, false, false, 0, 0, updater); // how to affect target
254 
255  }
vector< double >(TTQuantiSH::* _get_VA_func_ptr)(Patch *, const age_idx)
Definition: LCEquanti.h:88
virtual bool setParameters()
Definition: LCEquanti.cc:259
bool _is_permanent
Definition: LCEquanti.h:84
age_t _age_flag
Definition: LCEquanti.h:86
unsigned int _next_occurrence
Definition: LCEquanti.h:82
TProtoQuanti * _QuantiProto
Definition: LCEquanti.h:76
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:97
Implementation of the ParamUpdaterBase interface.
Definition: param.h:362
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:111
@ BOOL
Definition: types.h:77
@ STR
Definition: types.h:77
@ INT
Definition: types.h:77

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

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_QuantiModifier::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

113 {return 0;}

◆ clone()

virtual LifeCycleEvent* LCE_QuantiModifier::clone ( )
inlinevirtual

Implements LifeCycleEvent.

104 {return new LCE_QuantiModifier();}
LCE_QuantiModifier()
Definition: LCEquanti.cc:239

References LCE_QuantiModifier().

◆ execute()

void LCE_QuantiModifier::execute ( )
virtual

Implements LifeCycleEvent.

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

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.

109 {}

◆ loadStatServices()

virtual void LCE_QuantiModifier::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

110 {}

◆ removeAgeClass()

virtual age_t LCE_QuantiModifier::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

112 {return 0;}

◆ requiredAgeClass()

virtual age_t LCE_QuantiModifier::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

114 {return 0;}

◆ resetParameterFromSource()

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

Implements SimComponent.

111 {return false;}

◆ setIndPhenotype()

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

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.

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

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

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

Locations of visitors to this page
Catalogued on GSR