Nemo  2.4.0b
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

typedef int Individual::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().

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

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

◆ 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 ~Individual().

◆ clone()

Individual * Individual::clone ( )

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

151 {
152  Individual* myClone = new Individual();
153 
154  for(unsigned int i = 0; i < _trait_nb; i++)
155  myClone->addTrait(Traits[i]->clone(), i);
156 
157  return myClone;
158 }
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().

◆ create() [1/3]

Individual* Individual::create ( )
inline

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

363  {
365  mutate();
366  setTraitValue();
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().

◆ 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();
376  setTraitValue();
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 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().
virtual void inherit(const TTrait *mother, const TTrait *father)=0
Inheritance procedure, creates a new trait from mother's and father's traits.

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

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

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

◆ getAge()

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

References _age.

Referenced by LCE_SelectionFH::print().

◆ getcurrentID()

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

References currentID.

◆ getFather()

◆ getFatherID()

◆ getFecundity()

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

References _fecundity.

Referenced by MPStatHandler::getMeanAssignedFecundity().

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

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

◆ getHome()

◆ getID()

◆ getIsSelfed()

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

References _pedigreeClass.

Referenced by MPStatHandler::setKinship().

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

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

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

◆ getMother()

◆ 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)
234 {
235  if(mother == father) return 4; //selfed
236 
237  if(mother->getHome() != father->getHome()) return 0; //outbred between patch
238 
239  unsigned int mm,mf,fm,ff;
240  //mother's parents:
241  mm = mother->getMotherID();
242  mf = mother->getFatherID();
243  //father's parents:
244  fm = father->getMotherID();
245  ff = father->getFatherID();
246 
247  if(mm != fm && mf != ff) return 1; //outbred within patch
248 
249  else if((mm == fm && mf != ff) || (mm != fm && mf == ff)) return 2; //half sibs
250 
251  else return 3; //full sibs
252 }
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

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

◆ 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(), TTNOhtaStats::FHwrite(), TTQFreqExtractor::FHwrite(), TTQOhtaStats::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(), TTQuantiSH::setDataTables(), TTDeletMutBitstrSH::setDeletStats(), TTNeutralGenesSH::setHeteroTable(), TTNeutralGenesSH::setHo(), TTNeutralGenesSH::setHo2(), LCE_PhenotypeExpression::setIndPhenotype(), 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 LCE_Breed_Selection::setNonSelectedTraitTable().

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

void* Individual::getTraitValue ( IDX  T)
inline

Accessor to the value (phenotype) of a particular trait.

Parameters
Tthe trait's index in the traits table
Returns
the trait's value, using the TTrait interface
272  { return getTrait(T)->getValue(); }
virtual void * getValue() const =0
Genotype to phenotype mapper.

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

Referenced by LCE_Selection_base::addPhenotypicSD(), LCE_BreedAssortativeMating::assortative_mating(), LCE_Disperse_EvolDisp::evoldisp(), LCE_Selection_base::getFitnessDirect(), LCE_Selection_base::getFitnessMultivariateGaussian(), LCE_Selection_base::getFitnessMultivariateGaussian_VE(), LCE_Selection_base::getFitnessUnivariateGaussian(), LCE_Selection_base::getFitnessUnivariateGaussian_VE(), LCE_Selection_base::getFitnessUnivariateLinear(), LCE_Selection_base::getFitnessUnivariateQuadratic(), TTDispersalSH::getMeanDispRate(), TTDispersalSH::getMeanDispRateInPatch(), TTWolbachiaSH::getMeanFemaleInfection_perPatch(), TTDispersalSH::getMeanFemDispRate(), TTDispersalSH::getMeanMalDispRate(), TTWolbachiaSH::getMeanMaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgInfection(), TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch(), TTDispersalSH::getOffsprgMeanDispRate(), LCE_Breed_Wolbachia::hasInfectedFemale(), TTQuantiFH::print_PLINK_FAM(), TTQuantiFH::print_PLINK_PED(), TTWolbachiaSH::setInfectionStats(), TTDeletMutBitstrSH::setMeanViability(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().

◆ 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(), recombine(), and Traits.

Referenced by create().

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

◆ init()

Individual * Individual::init ( )

Inits parameters and traits.

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

54 {
55  _age = 0;
56  _pedigreeClass = 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(), and Traits.

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

◆ 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, and Traits.

Referenced by create().

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

◆ operator!=()

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

◆ operator=()

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

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

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

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.

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

References Traits.

◆ recombine()

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

References TTProtoWithMap::recombine().

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

◆ 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;
84  _pedigreeClass = 0;
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().

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

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

◆ setAge()

void Individual::setAge ( unsigned short  value)
inline

◆ setCurrentID()

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

References currentID.

◆ setFather()

void Individual::setFather ( Individual f)
inline

◆ setFatherID()

void Individual::setFatherID ( unsigned long  value)
inline

◆ setFecundity()

◆ setHome()

void Individual::setHome ( unsigned short  value)
inline

◆ setID()

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

References _id.

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

◆ setIsSelfed()

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

References _pedigreeClass.

Referenced by LCE_Breed_base::breed_cloning().

◆ setMother()

void Individual::setMother ( Individual m)
inline

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

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

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

◆ 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_QuantiInit::init_allele_freq(), LCE_QuantiModifier::setIndPhenotype(), and LCE_Breed_Quanti::setIndPhenotype().

◆ 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\
139 pedigree class: %i\n\
140  home: %i\n\
141 trait in table: %i\n\
142  traits values: \n",_id,_age,_sex,_motherID,_fatherID, _pedigreeClass,_home, Traits.size());
143 
144 for(unsigned int i = 0; i < _trait_nb; i++)
145  Traits[i]->show_up();
146 }
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(), and Traits.

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

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

Locations of visitors to this page
Catalogued on GSR