Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
LCE_NtrlInit Class Reference

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

#include <ttneutralgenes.h>

+ Inheritance diagram for LCE_NtrlInit:
+ Collaboration diagram for LCE_NtrlInit:

Public Member Functions

 LCE_NtrlInit ()
 
virtual ~LCE_NtrlInit ()
 
virtual void execute ()
 
void init_allele_freq (sex_t SEX, age_idx AGE, unsigned int size, unsigned int deme, double *values)
 
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

TMatrix _init_freq
 
unsigned int _nLoci
 

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

LCE_NtrlInit::LCE_NtrlInit ( )
2274 : LifeCycleEvent("ntrl_init","ntrl"), _nLoci(0)
2275{
2276 add_parameter("ntrl_init_patch_freq",MAT,1,0,0,0);
2277}
unsigned int _nLoci
Definition: ttneutralgenes.h:531
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
@ MAT
Definition: types.h:78

References SimComponent::add_parameter(), and MAT.

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~LCE_NtrlInit()

virtual LCE_NtrlInit::~LCE_NtrlInit ( )
inlinevirtual
537{ }

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_NtrlInit::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

552{return 0;}

◆ clone()

virtual LifeCycleEvent * LCE_NtrlInit::clone ( )
inlinevirtual

Implements LifeCycleEvent.

543{return new LCE_NtrlInit();}
LCE_NtrlInit()
Definition: ttneutralgenes.cc:2274

References LCE_NtrlInit().

◆ execute()

void LCE_NtrlInit::execute ( )
virtual

Implements LifeCycleEvent.

2306{
2307 if(!(_popPtr->getCurrentGeneration() == 1)) return;
2308
2309 unsigned int patchNbr = _popPtr->getPatchNbr();
2310
2311 double *values = new double[_nLoci];
2312
2313 for (unsigned int i = 0; i < patchNbr ; i++) {
2314
2315 _init_freq.getRowView(i, _nLoci, values);
2316
2317 init_allele_freq(FEM, OFFSx, _popPtr->size(FEM, OFFSPRG, i), i, values);
2318 init_allele_freq(MAL, OFFSx, _popPtr->size(MAL, OFFSPRG, i), i, values);
2319 init_allele_freq(FEM, ADLTx, _popPtr->size(FEM, ADULTS, i), i, values);
2320 init_allele_freq(MAL, ADLTx, _popPtr->size(MAL, ADULTS, i), i, values);
2321 }
2322
2323 if(values) delete [] values;
2324}
TMatrix _init_freq
Definition: ttneutralgenes.h:530
void init_allele_freq(sex_t SEX, age_idx AGE, unsigned int size, unsigned int deme, double *values)
Definition: ttneutralgenes.cc:2329
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:310
unsigned int getPatchNbr()
Definition: metapop.h:276
unsigned int getCurrentGeneration()
Definition: metapop.h:294
void getRowView(unsigned int row, unsigned int n, double *array)
Gives access to a row of the matrix.
Definition: tmatrix.h:196
@ 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 _init_freq, _nLoci, LifeCycleEvent::_popPtr, ADLTx, ADULTS, FEM, Metapop::getCurrentGeneration(), Metapop::getPatchNbr(), TMatrix::getRowView(), init_allele_freq(), MAL, OFFSPRG, OFFSx, and Metapop::size().

◆ init_allele_freq()

void LCE_NtrlInit::init_allele_freq ( sex_t  SEX,
age_idx  AGE,
unsigned int  size,
unsigned int  deme,
double *  values 
)
2330{
2331 if(!size) return;
2332
2333 Individual* ind;
2334 TTNeutralGenes* trait;
2335 unsigned int num_A, num_a;
2336 unsigned int *ind_A = 0, *ind_a = 0;
2337
2338 for(unsigned a = 0; a < 2; a++) {
2339 for(unsigned l = 0; l < _nLoci; l++) {
2340
2341 num_A = (unsigned int)(size * values[l]); //number of '0' allele
2342 num_a = size - num_A; //number of '1' allele
2343
2344 ind_A = new unsigned int [num_A];
2345 ind_a = new unsigned int [num_a];
2346
2347 RAND::SampleSeqWithReciprocal(0, size, 1, num_A, (int*)ind_A, num_a, (int*)ind_a); //sample individuals within deme, without replacement
2348
2349 for (unsigned int i = 0; i < num_A ; i++) {
2350 ind = _popPtr->get(SEX, age, ind_A[i], deme);
2351 trait = dynamic_cast<TTNeutralGenes*> ( ind->getTrait(_LCELinkedTraitIndex) );
2352 trait->set_allele(l, a, 0);
2353 }
2354
2355 for (unsigned int i = 0; i < num_a ; i++) {
2356 ind = _popPtr->get(SEX, age, ind_a[i], deme);
2357 trait = dynamic_cast<TTNeutralGenes*> ( ind->getTrait(_LCELinkedTraitIndex) );
2358 trait->set_allele(l, a, 1);
2359 }
2360
2361 delete [] ind_A;
2362 delete [] ind_a;
2363 }
2364 }
2365}
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:89
Individual * get(sex_t SEX, age_idx AGE, unsigned int at, unsigned int deme)
Returns a pointer to the appropriate individual.
Definition: metapop.h:792
static void SampleSeqWithReciprocal(int from, int to, int by, unsigned int num1, int *result1, unsigned int num2, int *result2)
Definition: Uniform.h:783
Microsatellites genome.
Definition: ttneutralgenes.h:54
void set_allele(unsigned int loc, unsigned int al, unsigned char val)
Definition: ttneutralgenes.h:107

References LifeCycleEvent::_LCELinkedTraitIndex, _nLoci, LifeCycleEvent::_popPtr, Metapop::get(), Individual::getTrait(), RAND::SampleSeqWithReciprocal(), and TTNeutralGenes::set_allele().

Referenced by execute().

+ Here is the caller graph for this function:

◆ loadFileServices()

virtual void LCE_NtrlInit::loadFileServices ( FileServices loader)
inlinevirtual

Implements SimComponent.

548{}

◆ loadStatServices()

virtual void LCE_NtrlInit::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

549{}

◆ removeAgeClass()

virtual age_t LCE_NtrlInit::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

551{return 0;}

◆ requiredAgeClass()

virtual age_t LCE_NtrlInit::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

553{return 0;}

◆ resetParameterFromSource()

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

Implements SimComponent.

550{return false;}

◆ setParameters()

bool LCE_NtrlInit::setParameters ( )
virtual

Implements SimComponent.

2282{
2283 TMatrix pat_mat;
2284 unsigned int patchNbr = _popPtr->getPatchNbr();
2285 TProtoNeutralGenes* proto = dynamic_cast<TProtoNeutralGenes*> ( _popPtr->getTraitPrototype("ntrl") );
2286
2287 if(proto->get_allele_num() > 2) {
2288 error("LCE ntrl_init only works for di-allelic neutral loci, sorry.\n\
2289 Please consider using an FSTAT input file for more complex cases.\n");
2290 return false;
2291 }
2292
2293 _nLoci = proto->get_locus_num();
2294
2295 _paramSet->getMatrix("ntrl_init_patch_freq", &pat_mat);
2296
2297 if( !setSpatialMatrix("ntrl_init_patch_freq", "num of neutral loci", &pat_mat, &_init_freq, _nLoci, patchNbr) )
2298 return false;
2299
2300 return true;
2301}
TraitPrototype * getTraitPrototype(trait_t type)
Accessor to a TraitPrototype.
Definition: indfactory.cc:140
void getMatrix(string name, TMatrix *mat)
Accessor to the parameters matrix.
Definition: param.h:304
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
Prototype class for the TTNeutralGenes trait class.
Definition: ttneutralgenes.h:164
unsigned int get_locus_num()
Definition: ttneutralgenes.h:190
unsigned int get_allele_num()
Definition: ttneutralgenes.h:191
int error(const char *str,...)
Definition: output.cc:77
bool setSpatialMatrix(string param, string numColCondition, TMatrix *inMat, TMatrix *outMat, unsigned int nVal, unsigned int patchNbr, bool doRandomize)
Definition: utils.cc:114

References _init_freq, _nLoci, SimComponent::_paramSet, LifeCycleEvent::_popPtr, error(), TProtoNeutralGenes::get_allele_num(), TProtoNeutralGenes::get_locus_num(), ParamSet::getMatrix(), Metapop::getPatchNbr(), IndFactory::getTraitPrototype(), and setSpatialMatrix().

Member Data Documentation

◆ _init_freq

TMatrix LCE_NtrlInit::_init_freq
private

Referenced by execute(), and setParameters().

◆ _nLoci

unsigned int LCE_NtrlInit::_nLoci
private

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