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

This class contains traits along with other individual information (sex, pedigree, etc. ). More...

#include <individual.h>

+ Collaboration diagram for Individual:

Public Types

typedef int IDX
 

Public Member Functions

 Individual ()
 
 ~Individual ()
 
Individualinit ()
 Inits parameters and traits. More...
 
void reset ()
 Resets parameters and traits values. More...
 
void show_up ()
 Write some info to stdout. More...
 
Individualclone ()
 Cloning procedure, clones all the traits present in the individual. More...
 
Setters
void setID (unsigned long value)
 
void setAge (unsigned short value)
 
void Aging ()
 
void setFatherID (unsigned long value)
 
void setMotherID (unsigned long value)
 
void setFather (Individual *f)
 
void setMother (Individual *m)
 
void setHome (unsigned short value)
 
void setSex (sex_t sex)
 
void setCurrentID (unsigned long value)
 
void setIsSelfed (bool s)
 
void setPedigreeClass (Individual *mother, Individual *father)
 
void setPedigreeClass (unsigned char ped)
 
Getters
unsigned long getID ()
 
unsigned short getAge ()
 
unsigned long getFatherID ()
 
unsigned long getMotherID ()
 
IndividualgetFather ()
 
IndividualgetMother ()
 
unsigned short getHome ()
 
sex_t getSex ()
 
bool isFemale ()
 
bool getIsSelfed ()
 
unsigned long getcurrentID ()
 
double getFecundity ()
 
unsigned short getMatings (unsigned int cat)
 Gives the number of matings that individual had with mates from a given pedigree class. More...
 
unsigned short getLocalMatings ()
 Gives the number of times an individual mated with an individual from the same patch. More...
 
unsigned int getTotMatings ()
 Gives the total number of matings of an individual. More...
 
unsigned short getRealizedFecundity (unsigned int cat)
 Gives the number of surviving offspring for a given pedigree class of mating. More...
 
unsigned int getLocalRealizedFecundity ()
 Gives the total number of surviving offspring when mating occures with mates of the same patch. More...
 
unsigned int getTotRealizedFecundity ()
 Gives the total number of surviving offspring for all categories of mating. More...
 
unsigned int getPedigreeClass ()
 Returns the pedigree class of the individual, as set during offspring creation. More...
 
unsigned int getPedigreeClass (Individual *mother, Individual *father)
 Returns the pedigree class of two individuals. More...
 
implementation
void store_data (BinaryStorageBuffer *saver)
 
void retrieve_data (BinaryStorageBuffer *reader)
 
Matings and Fecundity
double setFecundity (double value)
 Sets the fecundity to the value given and returns it. More...
 
void reset_counters ()
 Resets the mating and fecundity counters. More...
 
void addMating (unsigned int category)
 Increments the mating counter according to the pedigree class of the offspring. More...
 
void DidHaveABaby (unsigned int category)
 Increments the mating and realized fecundity counters according to the pedigree class of the offspring. More...
 
double getFecWithHomePatchMate ()
 Returns the proportion of succesfull local matings (i.e. More...
 
double getFecWithOtherPatchMate ()
 Returns the proportion of successfull remote matings. More...
 
Trait interface
unsigned int getTraitNumber ()
 Accessor to the size of the traits table. More...
 
std::deque< TTrait * > & getTraits ()
 Accessot to the traits table itself. More...
 
void * setTrait (IDX T, void *value)
 Sets the phenotype/value of a trait to a particular value. More...
 
void setTraitValue (IDX T)
 Calls the value setting procedure of a particular trait. More...
 
void setTraitValue ()
 Calls the value setting procedure of all traits present in an individual. More...
 
void * getTraitValue (IDX T)
 Accessor to the value (phenotype) of a particular trait. More...
 
TTraitgetTrait (IDX T)
 Trait accessor. More...
 
void addTrait (TTrait *theTrait, IDX pos)
 Adds a trait to the table. More...
 
void removeTrait (IDX T)
 Removes a trait from the table. More...
 
void clearTraits ()
 Clears the traits container. More...
 
void inheritTrait (IDX T, Individual *mother, Individual *father)
 Calls the inheritance procedure of a particular trait. More...
 
void mutateTrait (IDX T)
 Calls the mutation procedure of a particular trait. More...
 
void createTrait (IDX i, Individual *mother, Individual *father)
 Sets a particular trait's genotype and phenotype values from the two parents. More...
 
IndividualcreateTrait (IDX i, bool do_inherit, bool do_mutate)
 Creates an individual's genotypes and phenotypes with optional recombination or mutations on one trait only. More...
 
Individualcreate_first_gen ()
 Creates an individual's genotypes and phenotypes for first generation. More...
 
Individualcreate ()
 Creates an individual's genotypes and phenotypes with recombination and mutations. More...
 
Individualcreate (bool do_inherit, bool do_mutate)
 Creates an individual's genotypes and phenotypes with optional recombination or mutations. More...
 
Individualcreate (Individual *mother, Individual *father)
 Creates an individual, inherit, mutate and set all its trait's values. More...
 
void inherit (Individual *mother, Individual *father)
 Calls the inheritance procedure of all the traits present in the individual. More...
 
void mutate ()
 Calls the mutation procedure of all the traits present in the individual. More...
 
void recombine (unsigned long ID)
 
Operators
Individualoperator= (const Individual &i)
 Assignment, make a deep copy of the parameter values and traits. More...
 
bool operator== (const Individual &i)
 Only checks for traits equivalence. More...
 
bool operator!= (const Individual &i)
 

Public Attributes

std::deque< TTrait * > Traits
 The traits table. More...
 

Static Public Attributes

static unsigned long currentID = 0
 The ID counter, reset at the beginning of each simulation. More...
 

Private Attributes

unsigned long _id
 ID tag, unique for one simulation. More...
 
unsigned short _age
 Age. More...
 
sex_t _sex
 Sex tag. More...
 
unsigned long _motherID
 Parents ID tags. More...
 
unsigned long _fatherID
 
Individual_mother
 Parents pointers. More...
 
Individual_father
 
unsigned short _home
 Natal Patch tag. More...
 
unsigned char _pedigreeClass
 Pedigree class of the individual. More...
 
double _fecundity
 Assigned fecundity. More...
 
unsigned short _matings [5]
 Mating counter. More...
 
unsigned short _realizedFecundity [5]
 Number of surviving offspring from the different mating categories (see matings). More...
 
unsigned int _trait_nb
 Number of traits in the table. More...
 

Detailed Description

This class contains traits along with other individual information (sex, pedigree, etc. ).

The Individual class can be view as a trait container. It encapsulates the basic interface to manipulate the traits an individual is carrying like initialization, inheritance, mutation and phenotype getter. It also stores the basic individual info like its sex, pedigree (home Patch, mather and father id, etc.) and its mating and fecundity values. It is not a StorableComponent but declares a similar interface to store and retrieve all the previous info to/from a binary file. All individuals in a simulation are instantiated by a call to the IndFactory class (through its derived class Metapop) which contains the individual and traits prototypes.

Member Typedef Documentation

◆ IDX

Constructor & Destructor Documentation

◆ Individual()

Individual::Individual ( )
42: _age(0), _sex(MAL),_motherID(0),_fatherID(0),_mother(NULL),_father(NULL),
44{
45 _id = currentID++;
46 for(unsigned int i = 0; i < 5; i++) {
47 _matings[i] = 0; _realizedFecundity[i] = 0;
48 }
49}
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
unsigned long _fatherID
Definition: individual.h:58
Individual * _mother
Parents pointers.
Definition: individual.h:60
static unsigned long currentID
The ID counter, reset at the beginning of each simulation.
Definition: individual.h:83
sex_t _sex
Sex tag.
Definition: individual.h:56
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:70
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings).
Definition: individual.h:76
unsigned short _home
Natal Patch tag.
Definition: individual.h:62
double _fecundity
Assigned fecundity.
Definition: individual.h:72
unsigned short _age
Age.
Definition: individual.h:54
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
Individual * _father
Definition: individual.h:60
@ MAL
Definition: types.h:37

References _id, _matings, _realizedFecundity, and currentID.

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~Individual()

Individual::~Individual ( )
inline
91{clearTraits();}
void clearTraits()
Clears the traits container.
Definition: individual.h:300

References clearTraits().

Member Function Documentation

◆ addMating()

void Individual::addMating ( unsigned int  category)
inline

Increments the mating counter according to the pedigree class of the offspring.

Parameters
categorythe pedigree class of the offspring
220 { _matings[category]++; }

References _matings.

Referenced by LCE_Breed_Selection::makeOffspringWithSelection().

+ Here is the caller graph for this function:

◆ addTrait()

void Individual::addTrait ( TTrait theTrait,
IDX  pos 
)
inline

Adds a trait to the table.

Parameters
theTraitpointer to the trait to add
posthe position where the trait should be added in the traits table. Used to check that the index of the trait in the table is correctly set.
See also
IndFactory::makePrototype
289 { if((int)_trait_nb != pos)
290 fatal("Individual::adding a trait to the wrong position (at %i, size %i)!\n",pos,_trait_nb);
291 Traits.push_back(theTrait); _trait_nb++;
292 }
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
void fatal(const char *str,...)
Definition: output.cc:96

References _trait_nb, fatal(), and Traits.

Referenced by clone(), and IndFactory::makePrototype().

+ Here is the caller graph for this function:

◆ Aging()

void Individual::Aging ( )
inline
106{_age++;}

References _age.

◆ clearTraits()

void Individual::clearTraits ( )
inline

Clears the traits container.

301 { if(_trait_nb != 0) {for(unsigned int i = 0; i < Traits.size(); ++i) delete Traits[i];
302 Traits.clear(); _trait_nb = 0;}
303 }

References _trait_nb, and Traits.

Referenced by IndFactory::clearPrototype(), IndFactory::~IndFactory(), and ~Individual().

+ Here is the caller graph for this function:

◆ clone()

Individual * Individual::clone ( )

Cloning procedure, clones all the traits present in the individual.

150{
151 Individual* myClone = new Individual();
152
153 for(unsigned int i = 0; i < _trait_nb; i++)
154 myClone->addTrait(Traits[i]->clone(), i);
155
156 return myClone;
157}
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
Individual()
Definition: individual.cc:41
void addTrait(TTrait *theTrait, IDX pos)
Adds a trait to the table.
Definition: individual.h:288

References _trait_nb, addTrait(), Individual(), and Traits.

Referenced by IndFactory::getPrototypeClone(), and IndFactory::makeNewIndividual().

+ Here is the caller graph for this function:

◆ create() [1/3]

Individual * Individual::create ( )
inline

Creates an individual's genotypes and phenotypes with recombination and mutations.

363 {
365 mutate();
367 return this;
368 }
void mutate()
Calls the mutation procedure of all the traits present in the individual.
Definition: individual.h:409
void inherit(Individual *mother, Individual *father)
Calls the inheritance procedure of all the traits present in the individual.
Definition: individual.h:401
void setTraitValue()
Calls the value setting procedure of all traits present in an individual.
Definition: individual.h:265

References _father, _mother, inherit(), mutate(), and setTraitValue().

Referenced by LCE_Cross::create_individual_ancestors(), IndFactory::makeOffsprg(), and LCE_Breed_base::makeOffspring().

+ Here is the caller graph for this function:

◆ create() [2/3]

Individual * Individual::create ( bool  do_inherit,
bool  do_mutate 
)
inline

Creates an individual's genotypes and phenotypes with optional recombination or mutations.

Parameters
do_inheritif true, do traits inheritance and recombination
do_mutateif true, performs mutation of the traits
373 {
374 if(do_inherit) inherit(_mother, _father);
375 if(do_mutate) mutate();
377 return this;
378 }

References _father, _mother, inherit(), mutate(), and setTraitValue().

◆ create() [3/3]

Individual * Individual::create ( Individual mother,
Individual father 
)
inline

Creates an individual, inherit, mutate and set all its trait's values.

Parameters
motherthe mother
fatherthe father
384 {
385 if(!(mother && father))
386 fatal("Individual::create::received null parents pointer!!!\n");
387 TTrait *TT;
388 recombine(_id);
389 for(unsigned int i = 0; i < _trait_nb; i++) {
390 TT = Traits[i];
391 TT->inherit(mother->getTrait(i), father->getTrait(i));
392 TT->mutate();
393 TT->set_value();
394 }
395 return this;
396 }
void recombine(unsigned long ID)
Definition: individual.h:412
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
Interface for all trait types, declares all basic trait operations.
Definition: ttrait.h:46
virtual void inherit(TTrait *mother, TTrait *father)=0
Inheritance procedure, creates a new trait from mother's and father's traits.
virtual void mutate()=0
Mutation procedure, perform mutations on the genes sequence.
virtual void set_value()=0
Tells the trait to set its phenotype from genotype, should be used instead of getValue().

References _id, _trait_nb, fatal(), getTrait(), TTrait::inherit(), TTrait::mutate(), recombine(), TTrait::set_value(), and Traits.

◆ create_first_gen()

Individual * Individual::create_first_gen ( )
inline

Creates an individual's genotypes and phenotypes for first generation.

349 {
350 for(unsigned int i = 0; i < _trait_nb; i++) {
351 Traits[i]->init_sequence();
352 Traits[i]->set_value();
353 }
354 //we have to set the parents ids otherwise the first offspring generation will be made of full sibs only.
355 static unsigned long ID = std::numeric_limits< unsigned long >::max();
356 _motherID = ID--;
357 _fatherID = ID--;
358 return this;
359 }

References _fatherID, _motherID, _trait_nb, and Traits.

Referenced by LCE_Cross::create_individual_ancestors(), and Patch::setNewGeneration().

+ Here is the caller graph for this function:

◆ createTrait() [1/2]

Individual * Individual::createTrait ( IDX  i,
bool  do_inherit,
bool  do_mutate 
)
inline

Creates an individual's genotypes and phenotypes with optional recombination or mutations on one trait only.

Parameters
ithe index of the trait in the traits' table
do_inheritif true, does inheritance and recombination of the trait
do_mutateif true, performs mutation of the trait
340 {
341 if(do_inherit) inheritTrait(i, _mother, _father);
342 if(do_mutate) mutateTrait(i);
343 setTraitValue(i);
344 return this;
345 }
void inheritTrait(IDX T, Individual *mother, Individual *father)
Calls the inheritance procedure of a particular trait.
Definition: individual.h:309
void mutateTrait(IDX T)
Calls the mutation procedure of a particular trait.
Definition: individual.h:317

References _father, _mother, inheritTrait(), mutateTrait(), and setTraitValue().

◆ createTrait() [2/2]

void Individual::createTrait ( IDX  i,
Individual mother,
Individual father 
)
inline

Sets a particular trait's genotype and phenotype values from the two parents.

Includes its inheritance, mutation and value setting.

Parameters
ithe index of the trait to create in the traits table
motherthe mother
fatherthe father
326 { if(!(mother && father))
327 fatal("Individual::create::received null pointer!!!\n");
328 TTrait* T = Traits[i];
329 recombine(_id);
330 T->inherit(mother->getTrait(i),father->getTrait(i));
331 T->mutate();
332 T->set_value();
333 }

References _id, fatal(), getTrait(), TTrait::inherit(), TTrait::mutate(), recombine(), TTrait::set_value(), and Traits.

Referenced by LCE_Breed_Selection::makeOffspringWithSelection().

+ Here is the caller graph for this function:

◆ DidHaveABaby()

void Individual::DidHaveABaby ( unsigned int  category)
inline

Increments the mating and realized fecundity counters according to the pedigree class of the offspring.

Parameters
categorythe pedigree class of the offspring
226 { _matings[category]++; _realizedFecundity[category]++; }

References _matings, and _realizedFecundity.

Referenced by IndFactory::makeOffsprg(), LCE_Breed_base::makeOffspring(), and LCE_Breed_Selection::makeOffspringWithSelection().

+ Here is the caller graph for this function:

◆ getAge()

unsigned short Individual::getAge ( )
inline
123{return _age;}

References _age.

Referenced by LCE_SelectionFH::print().

+ Here is the caller graph for this function:

◆ getcurrentID()

unsigned long Individual::getcurrentID ( )
inline
132{return currentID;}

References currentID.

◆ getFather()

Individual * Individual::getFather ( )
inline

◆ getFatherID()

◆ getFecundity()

double Individual::getFecundity ( )
inline
133{return _fecundity;}

References _fecundity.

Referenced by MPStatHandler::getMeanAssignedFecundity().

+ Here is the caller graph for this function:

◆ getFecWithHomePatchMate()

double Individual::getFecWithHomePatchMate ( )
inline

Returns the proportion of succesfull local matings (i.e.

those that survived selection).

230 {
231 unsigned short mate = getLocalMatings();
232 return (mate != 0 ? (double) getLocalRealizedFecundity()/mate : 0.0);
233 }
unsigned int getLocalRealizedFecundity()
Gives the total number of surviving offspring when mating occures with mates of the same patch.
Definition: individual.h:170
unsigned short getLocalMatings()
Gives the number of times an individual mated with an individual from the same patch.
Definition: individual.h:147

References getLocalMatings(), and getLocalRealizedFecundity().

Referenced by TTDeletMutBitstrSH::getMeanFecWithPatchMate().

+ Here is the caller graph for this function:

◆ getFecWithOtherPatchMate()

double Individual::getFecWithOtherPatchMate ( )
inline

Returns the proportion of successfull remote matings.

Returns
_realizedFecundity[0]/_matings[0]
238 {
239 return (_matings[0] != 0 ? (double) _realizedFecundity[0]/_matings[0] : 0.0);
240 }

References _matings, and _realizedFecundity.

Referenced by TTDeletMutBitstrSH::getMeanFecWithPatchMate().

+ Here is the caller graph for this function:

◆ getHome()

◆ getID()

◆ getIsSelfed()

bool Individual::getIsSelfed ( )
inline
131{return (_pedigreeClass == 4);}

References _pedigreeClass.

Referenced by MPStatHandler::setKinship().

+ Here is the caller graph for this function:

◆ getLocalMatings()

unsigned short Individual::getLocalMatings ( )
inline

Gives the number of times an individual mated with an individual from the same patch.

148 {
149 return _matings[1]+_matings[2]+_matings[3]+_matings[4];
150 }

References _matings.

Referenced by getFecWithHomePatchMate(), TTDeletMutBitstrSH::getMeanFecWithPatchMate(), and getTotMatings().

+ Here is the caller graph for this function:

◆ getLocalRealizedFecundity()

unsigned int Individual::getLocalRealizedFecundity ( )
inline

Gives the total number of surviving offspring when mating occures with mates of the same patch.

References _realizedFecundity.

Referenced by getFecWithHomePatchMate(), and getTotRealizedFecundity().

+ Here is the caller graph for this function:

◆ getMatings()

unsigned short Individual::getMatings ( unsigned int  cat)
inline

Gives the number of matings that individual had with mates from a given pedigree class.

Parameters
catthe mating category (= the pedigree class of the offspring):
  • 0 = mates are from different patches
  • 1 = mates are from the same patch
  • 2 = mates are half sib
  • 3 = mates are full sib
  • 4 = selfed mating
143 {
144 return _matings[cat];
145 }

References _matings.

Referenced by TTDeletMutBitstrSH::getMeanFecWithPatchMate().

+ Here is the caller graph for this function:

◆ getMother()

Individual * Individual::getMother ( )
inline

◆ getMotherID()

◆ getPedigreeClass() [1/2]

◆ getPedigreeClass() [2/2]

unsigned int Individual::getPedigreeClass ( Individual mother,
Individual father 
)

Returns the pedigree class of two individuals.

Parameters
motherthe first individual (e.g.the mother of this individual)
fatherthe second individual (e.g. the father of this individual)
Returns
  • 0 = mother and father are from different patches
  • 1 = mother and father are from the same patch
  • 2 = mother and father are half sib
  • 3 = mother and father are full sib
  • 4 = mother and father are the same individual (selfed offspring)
233{
234 if(mother == father) return 4; //selfed
235
236 if(mother->getHome() != father->getHome()) return 0; //outbred between patch
237
238 unsigned int mm,mf,fm,ff;
239 //mother's parents:
240 mm = mother->getMotherID();
241 mf = mother->getFatherID();
242 //father's parents:
243 fm = father->getMotherID();
244 ff = father->getFatherID();
245
246 if(mm != fm && mf != ff) return 1; //outbred within patch
247
248 else if((mm == fm && mf != ff) || (mm != fm && mf == ff)) return 2; //half sibs
249
250 else return 3; //full sibs
251}
unsigned short getHome()
Definition: individual.h:128
unsigned long getMotherID()
Definition: individual.h:125
unsigned long getFatherID()
Definition: individual.h:124

References getFatherID(), getHome(), and getMotherID().

◆ getRealizedFecundity()

unsigned short Individual::getRealizedFecundity ( unsigned int  cat)
inline

Gives the number of surviving offspring for a given pedigree class of mating.

Parameters
catthe mating category:
  • 0 = mates are from different patches
  • 1 = mates are from the same patch
  • 2 = mates are half sib
  • 3 = mates are full sib
  • 4 = selfed mating
165 {
166 return _realizedFecundity[cat];
167 }

References _realizedFecundity.

◆ getSex()

◆ getTotMatings()

unsigned int Individual::getTotMatings ( )
inline

Gives the total number of matings of an individual.

153 {
154 return _matings[0] + getLocalMatings();
155 }

References _matings, and getLocalMatings().

Referenced by MPStatHandler::getMeanMatings(), and TTDeletMutBitstrSH::getPatchLoad().

+ Here is the caller graph for this function:

◆ getTotRealizedFecundity()

unsigned int Individual::getTotRealizedFecundity ( )
inline

Gives the total number of surviving offspring for all categories of mating.

References _realizedFecundity, and getLocalRealizedFecundity().

Referenced by TTDeletMutBitstrSH::getPatchLoad(), and MPStatHandler::setReproductiveStats().

+ Here is the caller graph for this function:

◆ getTrait()

TTrait * Individual::getTrait ( IDX  T)
inline

Trait accessor.

Parameters
Tthe trait's index in the traits table
Returns
the pointer to the trait
278 { if( T == -1 || !(T < (int)_trait_nb) )
279 fatal("Individual::Trying to access a trait not present in the traits table (at %i, size %i)\n",T,_trait_nb);
280 return Traits[T];
281 }

References _trait_nb, fatal(), and Traits.

Referenced by TTBDMI_SH::countAllele_diplo(), TTBDMI_SH::countAllele_haplo(), create(), createTrait(), TTDeletMutBitstrFH::FHread(), TTNeutralGenesFH::FHread(), TTQuantiFH::FHread(), TTDeletMutBitstrFH::FHwrite(), TTQFreqExtractor::FHwrite(), TTNeutralGenesSH::getDxyPerPatch(), TTQuantiSH::getSNPalleleFreqInPatch(), getTraitValue(), TTQuantiSH::getVaNoDominance(), TTQuantiSH::getVaWithDominance(), inherit(), inheritTrait(), LCE_NtrlInit::init_allele_freq(), LCE_QuantiInit::init_allele_freq(), LCE_QuantiInit::init_trait_value(), LCE_Init_BDMI::init_value(), mutateTrait(), TTQuantiFH::print(), TTNeutralGenesFH::print_PLINK_PED(), TTQuantiFH::print_PLINK_PED(), Metapop::read_trait(), TTNeutralGenesSH::setAdults_Theta(), TTNeutralGenesSH::setAlleleTables(), TTNeutralGenesSH::setCoaMatrix(), TTDeletMutBitstrSH::setDeletStats(), TTNeutralGenesSH::setHeteroTable(), TTNeutralGenesSH::setHo(), TTNeutralGenesSH::setHo2(), TTNeutralGenesSH::setSibCoa(), setTrait(), setTraitValue(), TTDeletMutBitstrSH::setViability(), store_quanti_trait_values(), Metapop::store_trait(), TTBDMI_FH::write_diplo(), TTBDMI_FH::write_haplo(), TTNeutralGenesFH::write_patch_FSTAT(), TTNeutralGenesFH::write_patch_GENEPOP(), and TTNeutralGenesFH::write_patch_TAB().

◆ getTraitNumber()

unsigned int Individual::getTraitNumber ( )
inline

Accessor to the size of the traits table.

247{ return _trait_nb;}

References _trait_nb.

Referenced by SimRunner::run(), and LCE_Breed_Selection::setNonSelectedTraitTable().

+ Here is the caller graph for this function:

◆ getTraits()

std::deque< TTrait * > & Individual::getTraits ( )
inline

Accessot to the traits table itself.

Returns
the traits table (a deque)
251{return Traits;}

References Traits.

◆ getTraitValue()

◆ inherit()

void Individual::inherit ( Individual mother,
Individual father 
)
inline

Calls the inheritance procedure of all the traits present in the individual.


Parameters
motherthe mother
fatherthe father
402 {
403 recombine(_id);
404 for(unsigned int i = 0; i < _trait_nb; i++)
405 Traits[i]->inherit(mother->getTrait(i), father->getTrait(i));
406 }

References _id, _trait_nb, getTrait(), inherit(), recombine(), and Traits.

Referenced by create(), and inherit().

+ Here is the caller graph for this function:

◆ inheritTrait()

void Individual::inheritTrait ( IDX  T,
Individual mother,
Individual father 
)
inline

Calls the inheritance procedure of a particular trait.

Parameters
Tthe trait's index in the traits table
motherthe mother
fatherthe father
310 {
311 recombine(_id);
312 getTrait(T)->inherit(mother->getTrait(T), father->getTrait(T));
313 }

References _id, getTrait(), TTrait::inherit(), and recombine().

Referenced by createTrait().

+ Here is the caller graph for this function:

◆ init()

Individual * Individual::init ( )

Inits parameters and traits.

Called by IndFactory::makeNewIndividual() to allocate the traits' sequences memory.

54{
55 _age = 0;
57 _motherID = 0;
58 _fatherID = 0;
59 _mother = NULL;
60 _father = NULL;
61 _home = 0;
62
63 memset(&_matings[0],0, 5*sizeof(unsigned short));
64 memset(&_realizedFecundity[0], 0, 5*sizeof(unsigned short));
65
66 if(_trait_nb != Traits.size()){
67 error("Individual::init: trait counter and table size differ, resetting\n");
68 _trait_nb = Traits.size();
69 }
70
71 for(unsigned int i = 0; i < _trait_nb; i++)
72 Traits[i]->init();
73
74 return this;
75}
Individual * init()
Inits parameters and traits.
Definition: individual.cc:53
int error(const char *str,...)
Definition: output.cc:77

References _age, _father, _fatherID, _home, _matings, _mother, _motherID, _pedigreeClass, _realizedFecundity, _trait_nb, error(), init(), and Traits.

Referenced by LCE_Cross::generatePedigree(), init(), and IndFactory::makeNewIndividual().

+ Here is the caller graph for this function:

◆ isFemale()

bool Individual::isFemale ( )
inline
130{return (_sex == FEM);}
@ FEM
Definition: types.h:37

References _sex, and FEM.

◆ mutate()

void Individual::mutate ( )
inline

Calls the mutation procedure of all the traits present in the individual.

410 { for(unsigned int i = 0; i < _trait_nb; i++) Traits[i]->mutate(); }

References _trait_nb, mutate(), and Traits.

Referenced by create(), and mutate().

+ Here is the caller graph for this function:

◆ mutateTrait()

void Individual::mutateTrait ( IDX  T)
inline

Calls the mutation procedure of a particular trait.

Parameters
Ttrait's index in the traits table
318 { getTrait(T)->mutate(); }

References getTrait(), and TTrait::mutate().

Referenced by createTrait().

+ Here is the caller graph for this function:

◆ operator!=()

bool Individual::operator!= ( const Individual i)
223{
224 if(!((*this) == i))
225 return true;
226 else
227 return false;
228}

◆ operator=()

Individual & Individual::operator= ( const Individual i)

Assignment, make a deep copy of the parameter values and traits.

162{
163 if(this != &i) {
164
165 if(Traits.size() != i.Traits.size())
166 fatal("Individual::operator=:not same number of traits in left and right sides of assignment\n");
167
168 if(_trait_nb != i._trait_nb) {
169 error("Individual::operator=:trait counters differ, resetting\n");
171 }
172
173 _sex = i._sex;
174 _age = i._age;
177 _mother = i._mother;
178 _father = i._father;
179 _home = i._home;
182
183 for(unsigned int j = 0; j < 5; j++) {
184 _matings[j] = i._matings[j];
186 }
187
188 for(unsigned int t = 0; t < _trait_nb; t++){
189
190 if(Traits[t]->get_type() != i.Traits[t]->get_type()) {
191
192 fatal("Individual::operator=: not same kinds of traits on left and right sides of assignment\n");
193
194 }
195
196 (*Traits[t]) = (*i.Traits[t]);
197 }
198 }
199 return *this;
200}

References _age, _father, _fatherID, _fecundity, _home, _matings, _mother, _motherID, _pedigreeClass, _realizedFecundity, _sex, _trait_nb, error(), fatal(), and Traits.

◆ operator==()

bool Individual::operator== ( const Individual i)

Only checks for traits equivalence.

205{
206 if(this != &i) {
207 if(Traits.size() != i.Traits.size()) return false;
208
209 for(unsigned int t = 0; t < Traits.size(); t++) {
210 if((*Traits[t]) != (*i.Traits[t])) {
211 return false;
212 }
213 }
214
215 //if(_sex != i._sex) return false;
216 }
217 return true;
218}

References Traits.

◆ recombine()

void Individual::recombine ( unsigned long  ID)
inline
static void recombine(unsigned long indID)
Definition: ttrait_with_map.cc:591

References TTProtoWithMap::recombine().

Referenced by create(), createTrait(), inherit(), and inheritTrait().

+ Here is the caller graph for this function:

◆ removeTrait()

void Individual::removeTrait ( IDX  T)
inline

Removes a trait from the table.

Parameters
Tthe trait's index in the traits table
297 { delete Traits[T]; Traits.erase(Traits.begin() + T); _trait_nb--;}

References _trait_nb, and Traits.

◆ reset()

void Individual::reset ( )

Resets parameters and traits values.

Does not de-allocate the traits' sequences memory (i.e. is not calling TTrait::reset() on each trait).

80{
81 _id = 0;
82 _age = 0;
83 _sex = MAL;
85 _motherID = 0;
86 _fatherID = 0;
87 _mother = NULL;
88 _father = NULL;
89 _home = 0;
90
91 memset(&_matings[0],0, 5*sizeof(unsigned short));
92 memset(&_realizedFecundity[0], 0, 5*sizeof(unsigned short));
93
94// if(_trait_nb != Traits.size()){
95// warning("Individual::reset: trait counter and table size differ, resetting\n");
96// _trait_nb = Traits.size();
97// }
98}

References _age, _father, _fatherID, _home, _id, _matings, _mother, _motherID, _pedigreeClass, _realizedFecundity, _sex, and MAL.

Referenced by IndFactory::makeNewIndividual().

+ Here is the caller graph for this function:

◆ reset_counters()

void Individual::reset_counters ( )
inline

Resets the mating and fecundity counters.

211 {
212 for(unsigned int i = 0; i < 5; i++) {
213 _matings[i] = 0; _realizedFecundity[i] = 0;
214 } }

References _matings, and _realizedFecundity.

Referenced by LCE_Breed_base::breed_cloning().

+ Here is the caller graph for this function:

◆ retrieve_data()

void Individual::retrieve_data ( BinaryStorageBuffer reader)
118{
119 reader->read(&_id, sizeof(unsigned long));
120 reader->read(&_motherID, sizeof(unsigned long));
121 reader->read(&_fatherID, sizeof(unsigned long));
122 reader->read(&_sex, sizeof(sex_t));
123 reader->read(&_home, sizeof(unsigned short));
124 reader->read(&_matings, 2*sizeof(unsigned short));
125 reader->read(&_realizedFecundity, 2*sizeof(unsigned short));
126//reader->read(&_pedigreeClass, 1);
127//reader->read(&_age, sizeof(unsigned short));
128}
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:162
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36

References _fatherID, _home, _id, _matings, _motherID, _realizedFecundity, _sex, and BinaryStorageBuffer::read().

Referenced by Metapop::retrieve_data().

+ Here is the caller graph for this function:

◆ setAge()

void Individual::setAge ( unsigned short  value)
inline
105{_age = value;}

References _age.

Referenced by LCE_Breed_base::breed_cloning(), TTDeletMutBitstrFH::FHread(), and TTQuantiFH::FHread().

+ Here is the caller graph for this function:

◆ setCurrentID()

void Individual::setCurrentID ( unsigned long  value)
inline
113{currentID = value;}

References currentID.

Referenced by IndFactory::makePrototype().

+ Here is the caller graph for this function:

◆ setFather()

void Individual::setFather ( Individual f)
inline
109{_father = f;}

References _father.

Referenced by LCE_Breed_base::breed_cloning(), LCE_Cross::create_individual_ancestors(), and IndFactory::makeNewIndividual().

+ Here is the caller graph for this function:

◆ setFatherID()

void Individual::setFatherID ( unsigned long  value)
inline

◆ setFecundity()

double Individual::setFecundity ( double  value)
inline

Sets the fecundity to the value given and returns it.

Parameters
valuethe fecundity
207{_fecundity = value; return value;}

References _fecundity.

Referenced by LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_OffSurvival(), LCE_Breed_base::NonWrightFisherPopulation(), LCE_Breed_Quanti::NonWrightFisherPopulation(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().

+ Here is the caller graph for this function:

◆ setHome()

void Individual::setHome ( unsigned short  value)
inline
111{_home = value;}

References _home.

Referenced by LCE_Breed_base::breed_cloning(), TTDeletMutBitstrFH::FHread(), and IndFactory::makeNewIndividual().

+ Here is the caller graph for this function:

◆ setID()

void Individual::setID ( unsigned long  value)
inline
104{_id = value;}

References _id.

Referenced by LCE_Cross::generatePedigree(), and IndFactory::makeNewIndividual().

+ Here is the caller graph for this function:

◆ setIsSelfed()

void Individual::setIsSelfed ( bool  s)
inline
114{_pedigreeClass = (s ? 4 : 0);}

References _pedigreeClass.

Referenced by LCE_Breed_base::breed_cloning().

+ Here is the caller graph for this function:

◆ setMother()

void Individual::setMother ( Individual m)
inline
110{_mother = m;}

References _mother.

Referenced by LCE_Breed_base::breed_cloning(), LCE_Cross::create_individual_ancestors(), and IndFactory::makeNewIndividual().

+ Here is the caller graph for this function:

◆ setMotherID()

void Individual::setMotherID ( unsigned long  value)
inline

◆ setPedigreeClass() [1/2]

void Individual::setPedigreeClass ( Individual mother,
Individual father 
)
inline
115{_pedigreeClass = getPedigreeClass(mother,father);}
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:179

References _pedigreeClass, and getPedigreeClass().

Referenced by TTDeletMutBitstrFH::FHread(), TTNeutralGenesFH::FHread(), TTQuantiFH::FHread(), and IndFactory::makeNewIndividual().

+ Here is the caller graph for this function:

◆ setPedigreeClass() [2/2]

void Individual::setPedigreeClass ( unsigned char  ped)
inline
116{_pedigreeClass = ped;}

References _pedigreeClass.

◆ setSex()

◆ setTrait()

void * Individual::setTrait ( IDX  T,
void *  value 
)
inline

Sets the phenotype/value of a trait to a particular value.

Parameters
Tthe trait's index in the traits table
valuethe value passed to the trait (using the TTrait interface)
257 { return getTrait(T)->set_trait(value); }
virtual void * set_trait(void *value)=0
Called to set the phenotypic to a particular value or to give context-dependant value(s) to the trait...

References getTrait(), and TTrait::set_trait().

Referenced by LCE_Breed_Wolbachia::inoculate_wolbachia().

+ Here is the caller graph for this function:

◆ setTraitValue() [1/2]

void Individual::setTraitValue ( )
inline

Calls the value setting procedure of all traits present in an individual.

266 { for(unsigned int i = 0; i < _trait_nb; i++) Traits[i]->set_value(); }

References _trait_nb, and Traits.

Referenced by create(), and createTrait().

+ Here is the caller graph for this function:

◆ setTraitValue() [2/2]

void Individual::setTraitValue ( IDX  T)
inline

Calls the value setting procedure of a particular trait.

Parameters
Tthe trait's index in the traits table
262 { getTrait(T)->set_value(); }

References getTrait(), and TTrait::set_value().

Referenced by LCE_QuantiModifier::setIndPhenotype(), and LCE_Breed_Quanti::setIndPhenotype().

+ Here is the caller graph for this function:

◆ show_up()

void Individual::show_up ( )

Write some info to stdout.

133{
134 message("\n Individual ID: %i\n\
135 age: %i\n\
136 sex: %i\n\
137 mother: %i\n\
138 father: %i\n\
139pedigree class: %i\n\
140 home: %i\n\
141 traits values: \n",_id,_age,_sex,_motherID,_fatherID, _pedigreeClass,_home);
142
143for(unsigned int i = 0; i < _trait_nb; i++)
144 Traits[i]->show_up();
145}
void show_up()
Write some info to stdout.
Definition: individual.cc:132
void message(const char *message,...)
Definition: output.cc:40

References _age, _fatherID, _home, _id, _motherID, _pedigreeClass, _sex, _trait_nb, message(), show_up(), and Traits.

Referenced by show_up().

+ Here is the caller graph for this function:

◆ store_data()

void Individual::store_data ( BinaryStorageBuffer saver)
103{
104 saver->store(&_id, sizeof(unsigned long));
105 saver->store(&_motherID, sizeof(unsigned long));
106 saver->store(&_fatherID, sizeof(unsigned long));
107 saver->store(&_sex, sizeof(sex_t));
108 saver->store(&_home, sizeof(unsigned short));
109 saver->store(&_matings, 2*sizeof(unsigned short));
110 saver->store(&_realizedFecundity, 2*sizeof(unsigned short));
111 //saver->store(&_pedigreeClass, 1);
112 //saver->store(&_age, sizeof(unsigned short));
113}
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16

References _fatherID, _home, _id, _matings, _motherID, _realizedFecundity, _sex, and BinaryStorageBuffer::store().

Referenced by Metapop::store_data().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _age

unsigned short Individual::_age
private

Age.

Referenced by Aging(), getAge(), init(), operator=(), reset(), setAge(), and show_up().

◆ _father

Individual * Individual::_father
private

◆ _fatherID

unsigned long Individual::_fatherID
private

◆ _fecundity

double Individual::_fecundity
private

Assigned fecundity.

Referenced by getFecundity(), operator=(), and setFecundity().

◆ _home

unsigned short Individual::_home
private

◆ _id

unsigned long Individual::_id
private

ID tag, unique for one simulation.

Referenced by create(), createTrait(), getID(), Individual(), inherit(), inheritTrait(), reset(), retrieve_data(), setID(), show_up(), and store_data().

◆ _matings

unsigned short Individual::_matings[5]
private

◆ _mother

Individual* Individual::_mother
private

Parents pointers.

Referenced by create(), createTrait(), getMother(), init(), operator=(), reset(), and setMother().

◆ _motherID

unsigned long Individual::_motherID
private

◆ _pedigreeClass

unsigned char Individual::_pedigreeClass
private

Pedigree class of the individual.

  • 0: parents are from different demes.\
  • 1: parents are from the same deme but unrelated.\
  • 2: parents are half-sib\
  • 3: parents are full-sib\
  • 4: parents are the same individual (i.e. selfing).\

Referenced by getIsSelfed(), getPedigreeClass(), init(), operator=(), reset(), setIsSelfed(), setPedigreeClass(), and show_up().

◆ _realizedFecundity

unsigned short Individual::_realizedFecundity[5]
private

◆ _sex

sex_t Individual::_sex
private

◆ _trait_nb

unsigned int Individual::_trait_nb
private

◆ currentID

unsigned long Individual::currentID = 0
static

The ID counter, reset at the beginning of each simulation.

Referenced by getcurrentID(), Individual(), IndFactory::makeNewIndividual(), and setCurrentID().

◆ Traits


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