Nemo  2.3.46
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

Constructor & Destructor Documentation

Individual::Individual ( )

References _id, _matings, _realizedFecundity, and currentID.

Referenced by clone().

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 short _home
Natal Patch tag.
Definition: individual.h:62
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
unsigned short _age
Age.
Definition: individual.h:54
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
Individual * _father
Definition: individual.h:60
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
double _fecundity
Assigned fecundity.
Definition: individual.h:72
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
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
Definition: types.h:37
Individual * _mother
Parents pointers.
Definition: individual.h:60
unsigned long _fatherID
Definition: individual.h:58
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:70
Individual::~Individual ( )
inline

References clearTraits().

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

Member Function Documentation

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

Referenced by LCE_Breed_Selection::makeOffspringWithSelection().

220  { _matings[category]++; }
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
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

References fatal().

Referenced by clone().

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  }
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
void fatal(const char *str,...)
Definition: output.cc:90
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
void Individual::Aging ( )
inline
106 {_age++;}
unsigned short _age
Age.
Definition: individual.h:54
void Individual::clearTraits ( )
inline

Clears the traits container.

Referenced by ~Individual().

301  { if(_trait_nb != 0) {for(unsigned int i = 0; i < Traits.size(); ++i) delete Traits[i];
302  Traits.clear(); _trait_nb = 0;}
303  }
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
Individual * Individual::clone ( )

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

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

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

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 }
Individual()
Definition: individual.cc:41
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
void addTrait(TTrait *theTrait, IDX pos)
Adds a trait to the table.
Definition: individual.h:288
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
Individual* Individual::create ( )
inline

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

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

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

363  {
365  mutate();
366  setTraitValue();
367  return this;
368  }
Individual * _father
Definition: individual.h:60
Individual * _mother
Parents pointers.
Definition: individual.h:60
void setTraitValue()
Calls the value setting procedure of all traits present in an individual.
Definition: individual.h:265
void inherit(Individual *mother, Individual *father)
Calls the inheritance procedure of all the traits present in the individual.
Definition: individual.h:401
void mutate()
Calls the mutation procedure of all the traits present in the individual.
Definition: individual.h:409
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

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

373  {
374  if(do_inherit) inherit(_mother, _father);
375  if(do_mutate) mutate();
376  setTraitValue();
377  return this;
378  }
Individual * _father
Definition: individual.h:60
Individual * _mother
Parents pointers.
Definition: individual.h:60
void setTraitValue()
Calls the value setting procedure of all traits present in an individual.
Definition: individual.h:265
void inherit(Individual *mother, Individual *father)
Calls the inheritance procedure of all the traits present in the individual.
Definition: individual.h:401
void mutate()
Calls the mutation procedure of all the traits present in the individual.
Definition: individual.h:409
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

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

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  }
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.
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
Interface for all trait types, declares all basic trait operations.
Definition: ttrait.h:46
void fatal(const char *str,...)
Definition: output.cc:90
void recombine(unsigned long ID)
Definition: individual.h:412
virtual void set_value()=0
Tells the trait to set its phenotype from genotype, should be used instead of getValue().
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
Individual* Individual::create_first_gen ( )
inline

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

References _trait_nb.

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

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  }
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
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
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

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

Referenced by LCE_Breed_Selection::makeOffspringWithSelection().

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  }
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.
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
Interface for all trait types, declares all basic trait operations.
Definition: ttrait.h:46
void fatal(const char *str,...)
Definition: output.cc:90
void recombine(unsigned long ID)
Definition: individual.h:412
virtual void set_value()=0
Tells the trait to set its phenotype from genotype, should be used instead of getValue().
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
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

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

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
Individual * _father
Definition: individual.h:60
Individual * _mother
Parents pointers.
Definition: individual.h:60
void setTraitValue()
Calls the value setting procedure of all traits present in an individual.
Definition: individual.h:265
void mutateTrait(IDX T)
Calls the mutation procedure of a particular trait.
Definition: individual.h:317
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

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

226  { _matings[category]++; _realizedFecundity[category]++; }
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
unsigned short Individual::getAge ( )
inline

References _age.

Referenced by LCE_SelectionFH::print().

123 {return _age;}
unsigned short _age
Age.
Definition: individual.h:54
unsigned long Individual::getcurrentID ( )
inline

References currentID.

132 {return currentID;}
static unsigned long currentID
The ID counter, reset at the beginning of each simulation.
Definition: individual.h:83
Individual* Individual::getFather ( )
inline
double Individual::getFecundity ( )
inline

References _fecundity.

Referenced by MPStatHandler::getMeanAssignedFecundity().

133 {return _fecundity;}
double _fecundity
Assigned fecundity.
Definition: individual.h:72
double Individual::getFecWithHomePatchMate ( )
inline

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

those that survived selection).

References getLocalMatings(), and getLocalRealizedFecundity().

Referenced by TTDeletMutBitstrSH::getMeanFecWithPatchMate().

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

Returns the proportion of successfull remote matings.

Returns
_realizedFecundity[0]/_matings[0]

Referenced by TTDeletMutBitstrSH::getMeanFecWithPatchMate().

238  {
239  return (_matings[0] != 0 ? (double) _realizedFecundity[0]/_matings[0] : 0.0);
240  }
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
unsigned long Individual::getID ( )
inline
bool Individual::getIsSelfed ( )
inline

Referenced by MPStatHandler::setKinship().

131 {return (_pedigreeClass == 4);}
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:70
unsigned short Individual::getLocalMatings ( )
inline

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

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

148  {
149  return _matings[1]+_matings[2]+_matings[3]+_matings[4];
150  }
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
unsigned int Individual::getLocalRealizedFecundity ( )
inline

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

Referenced by getFecWithHomePatchMate(), and getTotRealizedFecundity().

171  {
173  }
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
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

Referenced by TTDeletMutBitstrSH::getMeanFecWithPatchMate().

143  {
144  return _matings[cat];
145  }
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
Individual* Individual::getMother ( )
inline
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)

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

221 {
222  if(mother == father) return 4; //selfed
223 
224  if(mother->getHome() != father->getHome()) return 0; //outbred between patch
225 
226  unsigned int mm,mf,fm,ff;
227  //mother's parents:
228  mm = mother->getMotherID();
229  mf = mother->getFatherID();
230  //father's parents:
231  fm = father->getMotherID();
232  ff = father->getFatherID();
233 
234  if(mm != fm && mf != ff) return 1; //outbred within patch
235 
236  else if((mm == fm && mf != ff) || (mm != fm && mf == ff)) return 2; //half sibs
237 
238  else return 3; //full sibs
239 }
unsigned long getMotherID()
Definition: individual.h:125
unsigned long getFatherID()
Definition: individual.h:124
unsigned short getHome()
Definition: individual.h:128
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  }
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
unsigned int Individual::getTotMatings ( )
inline

Gives the total number of matings of an individual.

References getLocalMatings().

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

153  {
154  return _matings[0] + getLocalMatings();
155  }
unsigned short getLocalMatings()
Gives the number of times an individual mated with an individual from the same patch.
Definition: individual.h:147
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
unsigned int Individual::getTotRealizedFecundity ( )
inline

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

References getLocalRealizedFecundity().

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

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 _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
TTrait* Individual::getTrait ( IDX  T)
inline

Trait accessor.

Parameters
Tthe trait's index in the traits table
Returns
the pointer to the trait

References fatal().

Referenced by TTBDMI_SH::countAllele_diplo(), TTBDMI_SH::countAllele_haplo(), create(), createTrait(), TTNeutralGenesFH::FHread(), TTDeletMutBitstrFH::FHread(), TTDeletMutBitstrFH::FHwrite(), TTQFreqExtractor::FHwrite(), TTNeutralGenesSH::getDxyPerPatch(), getTraitValue(), inherit(), inheritTrait(), LCE_QuantiInit::init_allele_freq(), LCE_NtrlInit::init_allele_freq(), LCE_QuantiInit::init_trait_value(), LCE_Init_BDMI::init_value(), mutateTrait(), TTQuantiFH::print(), 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(), TTBDMI_FH::write_diplo(), TTNeutralGenesFH::write_FSTAT(), TTNeutralGenesFH::write_GENEPOP(), TTBDMI_FH::write_haplo(), and TTNeutralGenesFH::write_TAB().

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  }
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
void fatal(const char *str,...)
Definition: output.cc:90
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
unsigned int Individual::getTraitNumber ( )
inline

Accessor to the size of the traits table.

References _trait_nb.

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

247 { return _trait_nb;}
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
std::deque<TTrait *>& Individual::getTraits ( )
inline

Accessot to the traits table itself.

Returns
the traits table (a deque)

References Traits.

251 {return Traits;}
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
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

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

Referenced by create().

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  }
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
void recombine(unsigned long ID)
Definition: individual.h:412
void inherit(Individual *mother, Individual *father)
Calls the inheritance procedure of all the traits present in the individual.
Definition: individual.h:401
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
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

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

Referenced by createTrait().

310  {
311  recombine(_id);
312  getTrait(T)->inherit(mother->getTrait(T), father->getTrait(T));
313  }
virtual void inherit(TTrait *mother, TTrait *father)=0
Inheritance procedure, creates a new trait from mother's and father's traits.
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
void recombine(unsigned long ID)
Definition: individual.h:412
Individual * Individual::init ( )

Inits parameters and traits.

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

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

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

54 {
55  _age = 0;
56  _pedigreeClass = 0;
57  _motherID = 0;
58  _fatherID = 0;
59  _mother = NULL;
60  _father = NULL;
61  _home = 0;
62  for(unsigned int i = 0; i < 5; i++) {
63  _matings[i] = 0; _realizedFecundity[i] = 0;
64  }
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 }
unsigned short _home
Natal Patch tag.
Definition: individual.h:62
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
unsigned short _age
Age.
Definition: individual.h:54
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
Individual * _father
Definition: individual.h:60
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
int error(const char *str,...)
Definition: output.cc:73
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
Individual * _mother
Parents pointers.
Definition: individual.h:60
unsigned long _fatherID
Definition: individual.h:58
Individual * init()
Inits parameters and traits.
Definition: individual.cc:53
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:70
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
bool Individual::isFemale ( )
inline

References FEM.

130 {return (_sex == FEM);}
sex_t _sex
Sex tag.
Definition: individual.h:56
Definition: types.h:37
void Individual::mutate ( )
inline

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

References _trait_nb.

Referenced by create().

410  { for(unsigned int i = 0; i < _trait_nb; i++) Traits[i]->mutate(); }
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
void mutate()
Calls the mutation procedure of all the traits present in the individual.
Definition: individual.h:409
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
void Individual::mutateTrait ( IDX  T)
inline

Calls the mutation procedure of a particular trait.

Parameters
Ttrait's index in the traits table

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

Referenced by createTrait().

318  { getTrait(T)->mutate(); }
virtual void mutate()=0
Mutation procedure, perform mutations on the genes sequence.
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
bool Individual::operator!= ( const Individual i)
211 {
212  if(!((*this) == i))
213  return true;
214  else
215  return false;
216 }
Individual & Individual::operator= ( const Individual i)

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

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

162 {
163  if(this != &i) {
164 
165  if(Traits.size() != i.Traits.size()) fatal("Individual::operator=:not same number of traits in left and right sides of assignment\n");
166  if(_trait_nb != i._trait_nb) {
167  error("Individual::operator=:trait counters differ, restting\n");
168  _trait_nb = i._trait_nb;
169  }
170  _sex = i._sex;
171  _age = i._age;
172  _motherID = i._motherID;
173  _fatherID = i._fatherID;
174  _mother = i._mother;
175  _father = i._father;
176  _home = i._home;
179  for(unsigned int j = 0; j < 5; j++) {
180  _matings[j] = i._matings[j];
182  }
183 
184  for(unsigned int t = 0; t < _trait_nb; t++){
185  if(Traits[t]->get_type().compare(i.Traits[t]->get_type()) != 0)
186  fatal("Individual::operator=: not same kinds of traits on left and right sides of assignment\n");
187  (*Traits[t]) = (*i.Traits[t]);
188  }
189  }
190  return *this;
191 }
unsigned short _home
Natal Patch tag.
Definition: individual.h:62
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
unsigned short _age
Age.
Definition: individual.h:54
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
void fatal(const char *str,...)
Definition: output.cc:90
Individual * _father
Definition: individual.h:60
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
int error(const char *str,...)
Definition: output.cc:73
double _fecundity
Assigned fecundity.
Definition: individual.h:72
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
sex_t _sex
Sex tag.
Definition: individual.h:56
Individual * _mother
Parents pointers.
Definition: individual.h:60
unsigned long _fatherID
Definition: individual.h:58
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:70
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
bool Individual::operator== ( const Individual i)

Only checks for traits equivalence.

References Traits.

196 {
197  if(this != &i) {
198  if(Traits.size() != i.Traits.size()) return false;
199 
200  for(unsigned int t = 0; t < Traits.size(); t++)
201  if((*Traits[t]) != (*i.Traits[t])) return false;
202 
203  //if(_sex != i._sex) return false;
204  }
205  return true;
206 }
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
void Individual::recombine ( unsigned long  ID)
inline

References TTProtoWithMap::recombine().

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

static void recombine(unsigned long indID)
Definition: ttrait_with_map.cc:485
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--;}
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
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).

References _age, _father, _fatherID, _home, _id, _matings, _mother, _motherID, _pedigreeClass, _realizedFecundity, _sex, _trait_nb, MAL, Traits, and warning().

Referenced by IndFactory::makeNewIndividual().

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  for(unsigned int i = 0; i < 5; i++) {
91  _matings[i] = 0; _realizedFecundity[i] = 0;
92  }
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 }
unsigned short _home
Natal Patch tag.
Definition: individual.h:62
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
unsigned short _age
Age.
Definition: individual.h:54
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
Individual * _father
Definition: individual.h:60
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
void warning(const char *str,...)
Definition: output.cc:56
sex_t _sex
Sex tag.
Definition: individual.h:56
Definition: types.h:37
Individual * _mother
Parents pointers.
Definition: individual.h:60
unsigned long _fatherID
Definition: individual.h:58
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:70
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
void Individual::reset_counters ( )
inline

Resets the mating and fecundity counters.

Referenced by LCE_Breed_base::breed_cloning().

211  {
212  for(unsigned int i = 0; i < 5; i++) {
213  _matings[i] = 0; _realizedFecundity[i] = 0;
214  } }
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
void Individual::retrieve_data ( BinaryStorageBuffer reader)

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

Referenced by Metapop::retrieve_data().

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 }
unsigned short _home
Natal Patch tag.
Definition: individual.h:62
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
sex_t _sex
Sex tag.
Definition: individual.h:56
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:147
unsigned long _fatherID
Definition: individual.h:58
void Individual::setAge ( unsigned short  value)
inline

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

105 {_age = value;}
unsigned short _age
Age.
Definition: individual.h:54
void Individual::setCurrentID ( unsigned long  value)
inline
113 {currentID = value;}
static unsigned long currentID
The ID counter, reset at the beginning of each simulation.
Definition: individual.h:83
void Individual::setFather ( Individual f)
inline

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

109 {_father = f;}
Individual * _father
Definition: individual.h:60
void Individual::setFatherID ( unsigned long  value)
inline
double Individual::setFecundity ( double  value)
inline

Sets the fecundity to the value given and returns it.

Parameters
valuethe fecundity

Referenced by LCE_Breed_Selection::do_breed_selection_FecFitness(), LCE_Breed_Selection::do_breed_selection_OffSurvival(), LCE_Breed::execute(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().

207 {_fecundity = value; return value;}
double _fecundity
Assigned fecundity.
Definition: individual.h:72
void Individual::setHome ( unsigned short  value)
inline

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

111 {_home = value;}
unsigned short _home
Natal Patch tag.
Definition: individual.h:62
void Individual::setID ( unsigned long  value)
inline

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

104 {_id = value;}
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
void Individual::setIsSelfed ( bool  s)
inline

Referenced by LCE_Breed_base::breed_cloning().

114 {_pedigreeClass = (s ? 4 : 0);}
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:70
void Individual::setMother ( Individual m)
inline

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

110 {_mother = m;}
Individual * _mother
Parents pointers.
Definition: individual.h:60
void Individual::setMotherID ( unsigned long  value)
inline

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

108 {_motherID = value;}
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
void Individual::setPedigreeClass ( Individual mother,
Individual father 
)
inline

References getPedigreeClass().

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

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

Referenced by IndFactory::makeNewIndividual().

112 {_sex = sex;}
sex_t _sex
Sex tag.
Definition: individual.h:56
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)

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

Referenced by LCE_Breed_Wolbachia::inoculate_wolbachia().

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...
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
void Individual::setTraitValue ( IDX  T)
inline

Calls the value setting procedure of a particular trait.

Parameters
Tthe trait's index in the traits table

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

262  { getTrait(T)->set_value(); }
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
virtual void set_value()=0
Tells the trait to set its phenotype from genotype, should be used instead of getValue().
void Individual::setTraitValue ( )
inline

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

References _trait_nb.

Referenced by create(), and createTrait().

266  { for(unsigned int i = 0; i < _trait_nb; i++) Traits[i]->set_value(); }
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
void Individual::show_up ( )

Write some info to stdout.

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

Referenced by TTDeletMutBitstrFH::FHread().

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  traits values: \n",_id,_age,_sex,_motherID,_fatherID, _pedigreeClass,_home);
142 
143 for(unsigned int i = 0; i < _trait_nb; i++)
144  Traits[i]->show_up();
145 }
void message(const char *message,...)
Definition: output.cc:40
unsigned short _home
Natal Patch tag.
Definition: individual.h:62
void show_up()
Write some info to stdout.
Definition: individual.cc:132
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
unsigned short _age
Age.
Definition: individual.h:54
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
unsigned int _trait_nb
Number of traits in the table.
Definition: individual.h:78
sex_t _sex
Sex tag.
Definition: individual.h:56
unsigned long _fatherID
Definition: individual.h:58
unsigned char _pedigreeClass
Pedigree class of the individual.
Definition: individual.h:70
std::deque< TTrait * > Traits
The traits table.
Definition: individual.h:88
void Individual::store_data ( BinaryStorageBuffer saver)

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

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 }
unsigned short _home
Natal Patch tag.
Definition: individual.h:62
unsigned long _motherID
Parents ID tags.
Definition: individual.h:58
unsigned long _id
ID tag, unique for one simulation.
Definition: individual.h:52
unsigned short _matings[5]
Mating counter.
Definition: individual.h:74
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:130
unsigned short _realizedFecundity[5]
Number of surviving offspring from the different mating categories (see matings). ...
Definition: individual.h:76
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
sex_t _sex
Sex tag.
Definition: individual.h:56
unsigned long _fatherID
Definition: individual.h:58

Member Data Documentation

unsigned short Individual::_age
private

Age.

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

Individual * Individual::_father
private

Referenced by getFather(), init(), operator=(), and reset().

unsigned long Individual::_fatherID
private
double Individual::_fecundity
private

Assigned fecundity.

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

unsigned short Individual::_home
private
unsigned long Individual::_id
private

ID tag, unique for one simulation.

Referenced by getID(), Individual(), reset(), retrieve_data(), show_up(), and store_data().

unsigned short Individual::_matings[5]
private

Mating counter.

The relationship

Referenced by Individual(), init(), operator=(), reset(), retrieve_data(), and store_data().

Individual* Individual::_mother
private

Parents pointers.

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

unsigned long Individual::_motherID
private

Parents ID tags.

Referenced by getMotherID(), init(), operator=(), reset(), retrieve_data(), show_up(), and store_data().

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 getPedigreeClass(), init(), operator=(), reset(), and show_up().

unsigned short Individual::_realizedFecundity[5]
private

Number of surviving offspring from the different mating categories (see matings).

Referenced by Individual(), init(), operator=(), reset(), retrieve_data(), and store_data().

sex_t Individual::_sex
private
unsigned int Individual::_trait_nb
private
unsigned long Individual::currentID = 0
static

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

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

std::deque<TTrait*> Individual::Traits

The traits table.

Referenced by clone(), getTraits(), init(), operator=(), operator==(), reset(), and show_up().


The documentation for this class was generated from the following files:

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR