Nemo  2.4.0
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 ( )
41 : _age(0), _sex(MAL),_motherID(0),_fatherID(0),_mother(NULL),_father(NULL),
43 {
44  _id = currentID++;
45  for(unsigned int i = 0; i < 5; i++) {
46  _matings[i] = 0; _realizedFecundity[i] = 0;
47  }
48 }
unsigned long _motherID
Parents ID tags.
Definition: individual.h:57
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:77
unsigned long _fatherID
Definition: individual.h:57
Individual * _mother
Parents pointers.
Definition: individual.h:59
static unsigned long currentID
The ID counter, reset at the beginning of each simulation.
Definition: individual.h:82
sex_t _sex
Sex tag.
Definition: individual.h:55
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:69
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings).
Definition: individual.h:75
unsigned short _home
Natal Patch tag.
Definition: individual.h:61
double _fecundity
Assigned fecundity.
Definition: individual.h:71
unsigned short _age
Age.
Definition: individual.h:53
unsigned short _matings[5]
Mating counter.
Definition: individual.h:73
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:51
Individual * _father
Definition: individual.h:59
@ MAL
Definition: types.h:36

References _id, _matings, _realizedFecundity, and currentID.

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~Individual()

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

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
219  { _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
288  { if((int)_trait_nb != pos)
289  fatal("Individual::adding a trait to the wrong position (at %i, size %i)!\n",pos,_trait_nb);
290  Traits.push_back(theTrait); _trait_nb++;
291  }
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:87
void fatal(const char *str,...)
Definition: output.cc:99

References _trait_nb, fatal(), and Traits.

Referenced by clone().

+ Here is the caller graph for this function:

◆ Aging()

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

References _age.

◆ clearTraits()

void Individual::clearTraits ( )
inline

Clears the traits container.

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

References _trait_nb, and Traits.

Referenced by ~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:48
Individual()
Definition: individual.cc:40
void addTrait(TTrait *theTrait, IDX pos)
Adds a trait to the table.
Definition: individual.h:287

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.

362  {
364  mutate();
365  setTraitValue();
366  return this;
367  }
void mutate()
Calls the mutation procedure of all the traits present in the individual.
Definition: individual.h:408
void inherit(Individual *mother, Individual *father)
Calls the inheritance procedure of all the traits present in the individual.
Definition: individual.h:400
void setTraitValue()
Calls the value setting procedure of all traits present in an individual.
Definition: individual.h:264

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
372  {
373  if(do_inherit) inherit(_mother, _father);
374  if(do_mutate) mutate();
375  setTraitValue();
376  return this;
377  }

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
383  {
384  if(!(mother && father))
385  fatal("Individual::create::received null parents pointer!!!\n");
386  TTrait *TT;
387  recombine(_id);
388  for(unsigned int i = 0; i < _trait_nb; i++) {
389  TT = Traits[i];
390  TT->inherit(mother->getTrait(i), father->getTrait(i));
391  TT->mutate();
392  TT->set_value();
393  }
394  return this;
395  }
void recombine(unsigned long ID)
Definition: individual.h:411
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:276
Interface for all trait types, declares all basic trait operations.
Definition: ttrait.h:45
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.

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

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
339  {
340  if(do_inherit) inheritTrait(i, _mother, _father);
341  if(do_mutate) mutateTrait(i);
342  setTraitValue(i);
343  return this;
344  }
void inheritTrait(IDX T, Individual *mother, Individual *father)
Calls the inheritance procedure of a particular trait.
Definition: individual.h:308
void mutateTrait(IDX T)
Calls the mutation procedure of a particular trait.
Definition: individual.h:316

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
325  { if(!(mother && father))
326  fatal("Individual::create::received null pointer!!!\n");
327  TTrait* T = Traits[i];
328  recombine(_id);
329  T->inherit(mother->getTrait(i),father->getTrait(i));
330  T->mutate();
331  T->set_value();
332  }

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
225  { _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
122 {return _age;}

References _age.

Referenced by LCE_SelectionFH::print(), GenotyperFH::print_genotypes(), GenotyperFH::print_snp_genotypes(), and GenotyperFH::print_snp_id().

+ Here is the caller graph for this function:

◆ getcurrentID()

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

References currentID.

◆ getFather()

◆ getFatherID()

◆ getFecundity()

double Individual::getFecundity ( )
inline
132 {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).

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

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]
237  {
238  return (_matings[0] != 0 ? (double) _realizedFecundity[0]/_matings[0] : 0.0);
239  }

References _matings, and _realizedFecundity.

Referenced by TTDeletMutBitstrSH::getMeanFecWithPatchMate().

+ Here is the caller graph for this function:

◆ getHome()

◆ getID()

◆ getIsSelfed()

bool Individual::getIsSelfed ( )
inline
130 {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.

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

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
142  {
143  return _matings[cat];
144  }

References _matings.

Referenced by TTDeletMutBitstrSH::getMeanFecWithPatchMate().

+ Here is the caller graph for this function:

◆ 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)
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:127
unsigned long getMotherID()
Definition: individual.h:124
unsigned long getFatherID()
Definition: individual.h:123

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
164  {
165  return _realizedFecundity[cat];
166  }

References _realizedFecundity.

◆ getSex()

◆ getTotMatings()

unsigned int Individual::getTotMatings ( )
inline

Gives the total number of matings of an individual.

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

References _matings, and getLocalMatings().

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

+ 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
277  { if( T == -1 || !(T < (int)_trait_nb) )
278  fatal("Individual::Trying to access a trait not present in the traits table (at %i, size %i)\n",T,_trait_nb);
279  return Traits[T];
280  }

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(), GenotyperFH::prepare_data_table(), TTQuantiFH::print(), GenotyperFH::print_genotypes(), TTNeutralGenesFH::print_PLINK_PED(), TTQuantiFH::print_PLINK_PED(), GenotyperFH::print_snp_genotypes(), GenotyperFH::print_snp_id(), Metapop::read_trait(), TTNeutralGenesSH::setAdults_Theta(), TTNeutralGenesSH::setAlleleTables(), TTNeutralGenesSH::setCoaMatrix(), TTDeletMutBitstrSH::setDeletStats(), TTNeutralGenesSH::setFstat_bitstring(), TTNeutralGenesSH::setFstatWeirCockerham_bitstring(), TTNeutralGenesSH::setHo(), TTNeutralGenesSH::setHo2(), LCE_PhenotypeExpression::setIndLiability(), LCE_PhenotypeExpression::setIndLiability_evolving(), LCE_PhenotypeExpression::setIndLiability_evolving_sigmoid(), LCE_PhenotypeExpression::setIndLiability_sigmoid(), LCE_PhenotypeExpression::setIndPhenotype(), LCE_PhenotypeExpression::setIndPhenotype_labile(), 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.

246 { return _trait_nb;}

References _trait_nb.

Referenced by 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)
250 {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
271  { 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::getFitnessMultivariateDisruptive(), LCE_Selection_base::getFitnessMultivariateGaussian(), LCE_Selection_base::getFitnessMultivariateGaussian_VE(), LCE_Selection_base::getFitnessTruncation(), LCE_Selection_base::getFitnessUnivariateDisruptive(), 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_Selection_base::setScalingFactorForLinearSelection(), 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
401  {
402  recombine(_id);
403  for(unsigned int i = 0; i < _trait_nb; i++)
404  Traits[i]->inherit(mother->getTrait(i), father->getTrait(i));
405  }

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

Referenced by create().

+ 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
309  {
310  recombine(_id);
311  getTrait(T)->inherit(mother->getTrait(T), father->getTrait(T));
312  }

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.

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

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

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

+ Here is the caller graph for this function:

◆ isFemale()

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

References _sex, and FEM.

◆ mutate()

void Individual::mutate ( )
inline

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

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

References _trait_nb, and Traits.

Referenced by create().

+ 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
317  { 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");
170  _trait_nb = i._trait_nb;
171  }
172 
173  _sex = i._sex;
174  _age = i._age;
175  _motherID = i._motherID;
176  _fatherID = i._fatherID;
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:592

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
296  { 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).

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

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.

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

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)
117 {
118  reader->read(&_id, sizeof(unsigned long));
119  reader->read(&_motherID, sizeof(unsigned long));
120  reader->read(&_fatherID, sizeof(unsigned long));
121  reader->read(&_sex, sizeof(sex_t));
122  reader->read(&_home, sizeof(unsigned short));
123  reader->read(&_matings, 2*sizeof(unsigned short));
124  reader->read(&_realizedFecundity, 2*sizeof(unsigned short));
125 //reader->read(&_pedigreeClass, 1);
126 //reader->read(&_age, sizeof(unsigned short));
127 }
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:220
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:35

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
104 {_age = value;}

References _age.

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

+ Here is the caller graph for this function:

◆ setCurrentID()

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

References currentID.

◆ setFather()

void Individual::setFather ( Individual f)
inline

◆ setFatherID()

void Individual::setFatherID ( unsigned long  value)
inline

◆ setFecundity()

double Individual::setFecundity ( double  value)
inline

◆ setHome()

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

References _home.

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

+ Here is the caller graph for this function:

◆ setID()

void Individual::setID ( unsigned long  value)
inline
103 {_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
113 {_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

◆ setMotherID()

void Individual::setMotherID ( unsigned long  value)
inline

◆ setPedigreeClass() [1/2]

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

References _pedigreeClass, and getPedigreeClass().

Referenced by IndFactory::decorateNewIndividual(), 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
115 {_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)
256  { 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.

265  { 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
261  { 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().

+ Here is the caller graph for this function:

◆ show_up()

void Individual::show_up ( )

Write some info to stdout.

132 {
133  message("\n Individual ID: %i\n\
134  age: %i\n\
135  sex: %i\n\
136  mother: %i\n\
137  father: %i\n\
138 pedigree class: %i\n\
139  home: %i\n\
140 trait in table: %i\n\
141  traits values: \n",_id,_age,_sex,_motherID,_fatherID, _pedigreeClass,_home, Traits.size());
142 
143 for(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:131
void message(const char *message,...)
Definition: output.cc:39

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

◆ store_data()

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

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

Locations of visitors to this page
Catalogued on GSR