Nemo  2.3.56
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 ( )
221 : LifeCycleEvent("quanti_modifier","quant"),
222 _QuantiProto(0),
224 _is_permanent(0),
225 _age_flag(0),
227 {
229
230 add_parameter("quanti_modifier_at_generation", INT, true, false, 0, 0, NULL);
231 add_parameter("quanti_modifier_at_age", STR, true, false, 0, 0, updater);
232 add_parameter("quanti_modifier_is_permanent", BOOL, false, false, 0, 0, updater);
233
234 add_parameter("quanti_modifier_target", STR, false, false, 0, 0, updater); // what to affect
235 add_parameter("quanti_modifier_values", MAT, false, false, 0, 0, updater); // how to affect target
236
237 }
virtual bool setParameters()
Definition: LCEquanti.cc:241
bool _is_permanent
Definition: LCEquanti.h:85
age_t _age_flag
Definition: LCEquanti.h:87
unsigned int _next_occurrence
Definition: LCEquanti.h:83
vector< double >(TTQuantiSH::* _get_VA_func_ptr)(Patch *, const age_idx)
Definition: LCEquanti.h:89
TProtoQuanti * _QuantiProto
Definition: LCEquanti.h:77
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
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
@ MAT
Definition: types.h:78
@ BOOL
Definition: types.h:78
@ STR
Definition: types.h:78
@ INT
Definition: types.h:78

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

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~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:221

References LCE_QuantiModifier().

◆ execute()

void LCE_QuantiModifier::execute ( )
virtual

Implements LifeCycleEvent.

298{
299 unsigned int gen = _popPtr->getCurrentGeneration();
300
301 if(!(
302 gen == _occurrences.get(0, _next_occurrence) ||
304 ))
305 return;
306
307 // update the next occurrence:
310
311
312 // for now only implementing the heritability setting
313 _h2 = _QuantiProto->get_heritability(); //may have been reset during a run
314
315 // we have to make sure that the phenotype will be calculated with Ve
316 // this is not guaranteed if Ve was not given in input
318
319 Patch *patch;
320
321 // compute Va in each patch to set Ve to match the h2 required
322 for(unsigned int i = 0; i < _popPtr->getPatchNbr(); ++i)
323 {
324
325 patch = _popPtr->getPatch(i);
326
327 if(_age_flag & OFFSPRG) {
328 setVefromVa(patch, OFFSx);
329 setIndPhenotype(patch, FEM, OFFSx);
330 setIndPhenotype(patch, MAL, OFFSx);
331 }
332
333 if(_age_flag & ADULTS) {
334 setVefromVa(patch, ADLTx);
335 setIndPhenotype(patch, FEM, ADLTx);
336 setIndPhenotype(patch, MAL, ADLTx);
337 }
338 }
339
340}
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:367
void setVefromVa(Patch *patch, age_idx AGE)
Definition: LCEquanti.cc:344
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
unsigned int getPatchNbr()
Definition: metapop.h:276
unsigned int getCurrentGeneration()
Definition: metapop.h:294
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
unsigned int ncols()
Definition: tmatrix.h:170
double get(unsigned int i, unsigned int j)
Accessor to element at row i and column j.
Definition: tmatrix.h:147
void set_trait_value_func_ptr(bool withVe)
Definition: ttquanti.cc:456
vector< double > get_heritability()
Definition: ttquanti.h:125
@ 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 
)
368{
369 for(unsigned int i = 0; i < patch->size(SEX, AGE); ++i)
370 {
371 patch->get(SEX, AGE, i)->setTraitValue(_LCELinkedTraitIndex);
372 }
373}
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: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.

242{
243 _QuantiProto = dynamic_cast<TProtoQuanti*> ( _popPtr->getTraitPrototype("quant") );
244
245 if(!get_parameter("quanti_modifier_at_generation")->isMatrix()) {
246
247 _occurrences.reset(1, 1, get_parameter_value("quanti_modifier_at_generation"));
248
249 } else {
250
251 get_parameter("quanti_modifier_at_generation")->getMatrix(&_occurrences);
252
253 if(_occurrences.nrows()>1)
254 return error("LCE quanti_modifier:: multiple generations must be provided in a 1D array, with a single row\n");
255
256 }
257
258 _next_occurrence = 0; //this is the index in the array
259
260 string flag = get_parameter("quanti_modifier_at_age")->getArg();
261
262 std::for_each(flag.begin(), flag.end(), [](char& c){c = ::tolower(c);});
263
264 if (flag == "adults" || flag == "adult" || flag == "4") {
265
267
268 } else if (flag == "offsprings" || flag == "offspring" || flag == "1" ) {
269
271
272 } else if (flag == "all" || flag == "7") {
273
274 _age_flag = ALL;
275
276 } else {
277
278 fatal("LCE quanti_modifier:: targeted age class must be specified as \"adults\", \"offspring\", or \"all\" (%s)\n", flag.c_str());
279 }
280
281 if(get_parameter("quanti_modifier_is_permanent")->isSet())
282 _is_permanent = true;
283 else
284 _is_permanent = false;
285
286 //check for allele model
289 else
291
292 return true;
293}
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:357
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.
Definition: tmatrix.h:116
unsigned int nrows()
Definition: tmatrix.h:167
TProtoQuanti.
Definition: ttquanti.h:113
unsigned int get_dominance_model()
Definition: ttquanti.h:146
vector< double > getVaNoDominance(Patch *curPop, const age_idx AGE)
Definition: ttquanti.cc:2684
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:2782
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().

+ Here is the caller graph for this function:

◆ setVefromVa()

void LCE_QuantiModifier::setVefromVa ( Patch patch,
age_idx  AGE 
)
345{
346 vector<double> Va;
347
348 Va = (_QuantiProto->get_stater()->*_get_VA_func_ptr)(patch, AGE); // compute Va, and Vg
349
350// cout << "LCE_QuantiModifier::setVefromVa("<<AGE<<"):: Va/Ve = ";
351
352
353 // set Ve to match h2 given computed value of Va
354 // Vg has been set during the process, its value is accessible via the stater's interface
355 for(unsigned int j = 0; j < _QuantiProto->get_nb_traits(); ++j) {
356
357// cout << Va[j] <<"/"<< Va[j]/_h2[j] - _QuantiProto->get_stater()->getVg(j) <<" ";
358
359 _QuantiProto->set_eVarianceSD( j, sqrt( Va[j]/_h2[j] - _QuantiProto->get_stater()->getVg(j) ) );
360 }
361
362// cout<<endl;
363}
unsigned int get_nb_traits()
Definition: ttquanti.h:121
TTQuantiSH * get_stater()
Definition: ttquanti.h:133
void set_eVarianceSD(unsigned int trait, double SD)
Definition: ttquanti.cc:917
double getVg(unsigned int i)
Definition: ttquanti.h:309

References _get_VA_func_ptr, _h2, _QuantiProto, TProtoQuanti::get_nb_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.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR