Individual Class Reference

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

#include <individual.h>

Collaboration diagram for Individual:

Collaboration graph
[legend]

List of all members.

Public Types

typedef int IDX

Public Member Functions

 Individual ()
 ~Individual ()
Individualinit ()
 Inits parameters and traits.
void reset ()
 Resets parameters and traits values.
void show_up ()
 Write some info to stdout.
Individualclone ()
 Cloning procedure, clones all the traits present in the individual.
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.
unsigned short getLocalMatings ()
 Gives the number of times an individual mated with an individual from the same patch.
unsigned int getTotMatings ()
 Gives the total number of matings of an individual.
unsigned short getRealizedFecundity (unsigned int cat)
 Gives the number of surviving offspring for a given pedigree class of mating.
unsigned int getLocalRealizedFecundity ()
 Gives the total number of surviving offspring when mating occures with mates of the same patch.
unsigned int getTotRealizedFecundity ()
 Gives the total number of surviving offspring for all categories of mating.
unsigned int getPedigreeClass ()
 Returns the pedigree class of the individual, as set during offspring creation.
unsigned int getPedigreeClass (Individual *mother, Individual *father)
 Returns the pedigree class of two individuals.
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.
void reset_counters ()
 Resets the mating and fecundity counters.
void addMating (unsigned int category)
 Increments the mating counter according to the pedigree class of the offspring.
void DidHaveABaby (unsigned int category)
 Increments the mating and realized fecundity counters according to the pedigree class of the offspring.
double getFecWithHomePatchMate ()
 Returns the proportion of succesfull local matings (i.e.
double getFecWithOtherPatchMate ()
 Returns the proportion of successfull remote matings.
Trait interface
unsigned int getTraitNumber ()
 Accessor to the size of the traits table.
std::deque< TTrait * > & getTraits ()
 Accessot to the traits table itself.
void * setTrait (IDX T, void *value)
 Sets the phenotype/value of a trait to a particular value.
void setTraitValue (IDX T)
 Calls the value setting procedure of a particular trait.
void setTraitValue ()
 Calls the value setting procedure of all traits present in an individual.
void * getTraitValue (IDX T)
 Accessor to the value (phenotype) of a particular trait.
TTraitgetTrait (IDX T)
 Trait accessor.
void addTrait (TTrait *theTrait, IDX pos)
 Adds a trait to the table.
void removeTrait (IDX T)
 Removes a trait from the table.
void clearTraits ()
 Clears the traits container.
void inheritTrait (IDX T, Individual *mother, Individual *father)
 Calls the inheritance procedure of a particular trait.
void mutateTrait (IDX T)
 Calls the mutation procedure of a particular trait.
void createTrait (IDX i, Individual *mother, Individual *father)
 Sets a particular trait's genotype and phenotype values from the two parents.
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.
Individualcreate_first_gen ()
 Creates an individual's genotypes and phenotypes for first generation.
Individualcreate ()
 Creates an individual's genotypes and phenotypes with recombination and mutations.
Individualcreate (bool do_inherit, bool do_mutate)
 Creates an individual's genotypes and phenotypes with optional recombination or mutations.
Individualcreate (Individual *mother, Individual *father)
 Creates an individual, inherit, mutate and set all its trait's values.
void inherit (Individual *mother, Individual *father)
 Calls the inheritance procedure of all the traits present in the individual.
void mutate ()
 Calls the mutation procedure of all the traits present in the individual.
Operators
Individualoperator= (const Individual &i)
 Assignment, make a deep copy of the parameter values and traits.
bool operator== (const Individual &i)
 Only checks for traits equivalence.
bool operator!= (const Individual &i)

Public Attributes

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

Static Public Attributes

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

Private Attributes

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


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.

Definition at line 48 of file individual.h.


Member Typedef Documentation

typedef int Individual::IDX

Definition at line 82 of file individual.h.


Constructor & Destructor Documentation

Individual::Individual (  ) 

Definition at line 41 of file individual.cc.

Referenced by clone().

00042 : _age(0), _sex(MAL),_motherID(0),_fatherID(0),_mother(NULL),_father(NULL),
00043 _home(0),_pedigreeClass(0),_fecundity(0),_trait_nb(0)
00044 {
00045   _id = currentID++;
00046   for(unsigned int i = 0; i < 5; i++) {
00047     _matings[i] = 0; _realizedFecundity[i] = 0;
00048   }
00049 }

Individual::~Individual (  )  [inline]

Definition at line 87 of file individual.h.

00087 {clearTraits();}


Member Function Documentation

void Individual::addMating ( unsigned int  category  )  [inline]

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

Parameters:
category the pedigree class of the offspring

Definition at line 215 of file individual.h.

Referenced by LCE_Breed_Selection::makeOffspringWithSelection().

00216   { _matings[category]++; }

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

Adds a trait to the table.

Parameters:
theTrait pointer to the trait to add
pos the 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

Definition at line 284 of file individual.h.

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

00285   { if((int)_trait_nb != pos)
00286     fatal("Individual::adding a trait to the wrong position (at %i, size %i)!\n",pos,_trait_nb);
00287     Traits.push_back(theTrait); _trait_nb++;
00288   }

void Individual::Aging (  )  [inline]

Definition at line 102 of file individual.h.

00102 {_age++;}

void Individual::clearTraits (  )  [inline]

Clears the traits container.

Definition at line 296 of file individual.h.

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

00297   { if(_trait_nb != 0) {for(unsigned int i = 0; i < Traits.size(); ++i) delete Traits[i];
00298     Traits.clear(); _trait_nb = 0;}
00299   }

Individual * Individual::clone (  ) 

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

Definition at line 149 of file individual.cc.

Referenced by IndFactory::makeNewIndividual().

00150 {
00151   Individual* myClone = new Individual();
00152   
00153   for(unsigned int i = 0; i < _trait_nb; i++)
00154     myClone->addTrait(Traits[i]->clone(), i);
00155   
00156   return myClone;
00157 }

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

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

Parameters:
mother the mother
father the father

Definition at line 374 of file individual.h.

00375   { if(mother == 0 || father == 0) fatal("Individual::create::received null parents pointer!!!\n");
00376     TTrait *TT;
00377     for(unsigned int i = 0; i < _trait_nb; i++) {
00378       TT = Traits[i];
00379       TT->inherit(mother->getTrait(i), father->getTrait(i));
00380       TT->mutate();
00381       TT->set_value();
00382     }
00383     return this;
00384   }

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

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

Parameters:
do_inherit if true, do traits inheritance and recombination
do_mutate if true, performs mutation of the traits

Definition at line 363 of file individual.h.

00364   { 
00365     if(do_inherit) inherit(_mother, _father);
00366     if(do_mutate)  mutate();
00367     setTraitValue();
00368     return this;
00369   } 

Individual* Individual::create (  )  [inline]

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

Definition at line 353 of file individual.h.

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

00354   { 
00355     inherit(_mother, _father);
00356     mutate();
00357     setTraitValue();
00358     return this;
00359   } 

Individual* Individual::create_first_gen (  )  [inline]

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

Definition at line 339 of file individual.h.

Referenced by Patch::setNewGeneration().

00340   {
00341     for(unsigned int i = 0; i < _trait_nb; i++) {
00342       Traits[i]->init_sequence();
00343       Traits[i]->set_value();
00344     }
00345     //we have to set the parents ids otherwise the first offspring generation will made of full sibs only.
00346     static unsigned long ID = std::numeric_limits< unsigned long >::max();
00347     _motherID = ID--;
00348     _fatherID = ID--;
00349     return this;
00350   }  

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:
i the index of the trait in the traits' table
do_inherit if true, does inheritance and recombination of the trait
do_mutate if true, performs mutation of the trait

Definition at line 330 of file individual.h.

00331   {
00332     if(do_inherit) inheritTrait(i, _mother, _father);
00333     if(do_mutate)  mutateTrait(i);
00334     setTraitValue(i);
00335     return this;
00336   } 

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:
i the index of the trait to create in the traits table
mother the mother
father the father

Definition at line 318 of file individual.h.

Referenced by LCE_Breed_Selection::makeOffspringWithSelection().

00319   { if(mother == 0 || father == 0) fatal("Individual::create::received null pointer!!!\n");
00320     TTrait* T = Traits[i];
00321     T->inherit(mother->getTrait(i),father->getTrait(i));
00322     T->mutate();  
00323     T->set_value();
00324   }

void Individual::DidHaveABaby ( unsigned int  category  )  [inline]

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

Parameters:
category the pedigree class of the offspring

Definition at line 221 of file individual.h.

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

00222   { _matings[category]++; _realizedFecundity[category]++; }

unsigned short Individual::getAge (  )  [inline]

Definition at line 119 of file individual.h.

00119 {return _age;}

unsigned long Individual::getcurrentID (  )  [inline]

Definition at line 128 of file individual.h.

00128 {return currentID;}

Individual* Individual::getFather (  )  [inline]

Definition at line 122 of file individual.h.

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

00122 {return _father;}

unsigned long Individual::getFatherID (  )  [inline]

Definition at line 120 of file individual.h.

Referenced by getPedigreeClass().

00120 {return _fatherID;}

double Individual::getFecundity (  )  [inline]

Definition at line 129 of file individual.h.

00129 {return _fecundity;}

double Individual::getFecWithHomePatchMate (  )  [inline]

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

those that survived selection).

Definition at line 225 of file individual.h.

00226   { 
00227     unsigned short mate = getLocalMatings();
00228     return (mate != 0 ? (double) getLocalRealizedFecundity()/mate : 0.0);
00229   }

double Individual::getFecWithOtherPatchMate (  )  [inline]

Returns the proportion of successfull remote matings.

Returns:
_realizedFecundity[0]/_matings[0]

Definition at line 233 of file individual.h.

00234   {
00235     return (_matings[0] != 0 ? (double) _realizedFecundity[0]/_matings[0] : 0.0);
00236   }

unsigned short Individual::getHome (  )  [inline]

Definition at line 124 of file individual.h.

Referenced by TTDeletMutBitstrFH::FHwrite(), getPedigreeClass(), and TTNeutralGenesFH::write_FSTAT().

00124 {return _home;}

unsigned long Individual::getID (  )  [inline]

Definition at line 118 of file individual.h.

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

00118 {return _id;}

bool Individual::getIsSelfed (  )  [inline]

Definition at line 127 of file individual.h.

00127 {return (_pedigreeClass == 4);}

unsigned short Individual::getLocalMatings (  )  [inline]

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

Definition at line 143 of file individual.h.

Referenced by getFecWithHomePatchMate(), and getTotMatings().

00144   {
00145     return _matings[1]+_matings[2]+_matings[3]+_matings[4];
00146   }

unsigned int Individual::getLocalRealizedFecundity (  )  [inline]

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

Definition at line 166 of file individual.h.

Referenced by getFecWithHomePatchMate(), and getTotRealizedFecundity().

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

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

Parameters:
cat the 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

Definition at line 138 of file individual.h.

00139   {
00140     return _matings[cat];
00141   }

Individual* Individual::getMother (  )  [inline]

Definition at line 123 of file individual.h.

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

00123 {return _mother;}

unsigned long Individual::getMotherID (  )  [inline]

Definition at line 121 of file individual.h.

Referenced by getPedigreeClass().

00121 {return _motherID;}

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

Returns the pedigree class of two individuals.

Parameters:
mother the first individual (e.g.the mother of this individual)
father the 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)

Definition at line 220 of file individual.cc.

00221 {
00222   if(mother == father) return 4; //selfed
00223 
00224   if(mother->getHome() != father->getHome()) return 0; //outbred between patch
00225   
00226   unsigned int mm,mf,fm,ff;
00227   //mother's parents:
00228   mm = mother->getMotherID();
00229   mf = mother->getFatherID();
00230   //father's parents:
00231   fm = father->getMotherID();
00232   ff = father->getFatherID();
00233 
00234   if(mm != fm && mf != ff) return 1; //outbred within patch
00235     
00236   else if((mm == fm && mf != ff) || (mm != fm && mf == ff)) return 2; //half sibs
00237     
00238   else return 3; //full sibs
00239 }

unsigned int Individual::getPedigreeClass (  )  [inline]

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

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

Parameters:
cat the 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

Definition at line 160 of file individual.h.

00161   {
00162     return _realizedFecundity[cat];
00163   }

sex_t Individual::getSex (  )  [inline]

unsigned int Individual::getTotMatings (  )  [inline]

Gives the total number of matings of an individual.

Definition at line 148 of file individual.h.

00149   {
00150     return _matings[0] + getLocalMatings();
00151   }

unsigned int Individual::getTotRealizedFecundity (  )  [inline]

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

Definition at line 172 of file individual.h.

TTrait* Individual::getTrait ( IDX  T  )  [inline]

Trait accessor.

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

Definition at line 273 of file individual.h.

Referenced by create(), createTrait(), TTNeutralGenesFH::FHread(), TTDeletMutBitstrFH::FHread(), TTDeletMutBitstrFH::FHwrite(), getTraitValue(), inherit(), inheritTrait(), mutateTrait(), setTrait(), setTraitValue(), TTNeutralGenesFH::write_FSTAT(), and TTNeutralGenesFH::write_varcompWC().

00274   { if( T == -1 || !(T < (int)_trait_nb) )
00275     fatal("Individual::Trying to access a trait not present in the traits table (at %i, size %i)\n",T,_trait_nb);
00276     return Traits[T]; 
00277   }

unsigned int Individual::getTraitNumber (  )  [inline]

Accessor to the size of the traits table.

Definition at line 243 of file individual.h.

Referenced by LCE_Selection_base::setParameters().

00243 { return _trait_nb;}

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

Accessot to the traits table itself.

Returns:
the traits table (a deque)

Definition at line 247 of file individual.h.

00247 {return Traits;}

void* Individual::getTraitValue ( IDX  T  )  [inline]

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

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

Parameters:
mother the mother
father the father

Definition at line 389 of file individual.h.

Referenced by create(), and inherit().

00390   { for(unsigned int i = 0; i < _trait_nb; i++) Traits[i]->inherit(mother->getTrait(i), father->getTrait(i)); }

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

Calls the inheritance procedure of a particular trait.

Parameters:
T the trait's index in the traits table
mother the mother
father the father

Definition at line 305 of file individual.h.

Referenced by createTrait().

00306   {  getTrait(T)->inherit(mother->getTrait(T), father->getTrait(T)); }

Individual * Individual::init (  ) 

Inits parameters and traits.

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

Definition at line 53 of file individual.cc.

Referenced by IndFactory::makeNewIndividual().

00054 {
00055   _age = 0;
00056   _pedigreeClass = 0;
00057   _motherID = 0;
00058   _fatherID = 0;
00059   _mother = NULL;
00060   _father = NULL;
00061   _home = 0;
00062   for(unsigned int i = 0; i < 5; i++) {
00063     _matings[i] = 0; _realizedFecundity[i] = 0;
00064   }
00065   
00066   if(_trait_nb != Traits.size()){
00067     error("Individual::init: trait counter and table size differ, resetting\n");
00068     _trait_nb = Traits.size();
00069   }
00070   
00071   for(unsigned int i = 0; i < _trait_nb; i++)
00072     Traits[i]->init();
00073 
00074   return this;
00075 }

bool Individual::isFemale (  )  [inline]

Definition at line 126 of file individual.h.

00126 {return (_sex == FEM);}

void Individual::mutate (  )  [inline]

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

Definition at line 393 of file individual.h.

Referenced by create(), and mutate().

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

void Individual::mutateTrait ( IDX  T  )  [inline]

Calls the mutation procedure of a particular trait.

Parameters:
T trait's index in the traits table

Definition at line 310 of file individual.h.

Referenced by createTrait().

00311   {  getTrait(T)->mutate(); }

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

Definition at line 210 of file individual.cc.

00211 {
00212   if(!((*this) == i))
00213     return true;
00214   else
00215     return false;
00216 }

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

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

Definition at line 161 of file individual.cc.

00162 {
00163   if(this != &i) {  
00164     
00165     if(Traits.size() != i.Traits.size()) fatal("Individual::operator=:not same number of traits in left and right sides of assignment\n");
00166     if(_trait_nb != i._trait_nb) {
00167       error("Individual::operator=:trait counters differ, restting\n");
00168       _trait_nb = i._trait_nb;
00169     }
00170     _sex = i._sex;
00171     _age = i._age;
00172     _motherID = i._motherID;
00173     _fatherID = i._fatherID;
00174     _mother = i._mother;
00175     _father = i._father;
00176     _home = i._home;
00177     _pedigreeClass = i._pedigreeClass;
00178     _fecundity = i._fecundity;
00179     for(unsigned int j = 0; j < 5; j++) {
00180       _matings[j] = i._matings[j];
00181       _realizedFecundity[j] = i._realizedFecundity[j];
00182     }
00183 
00184     for(unsigned int t = 0; t < _trait_nb; t++){ 
00185       if(Traits[t]->get_type().compare(i.Traits[t]->get_type()) != 0) 
00186         fatal("Individual::operator=: not same kinds of traits on left and right sides of assignment\n");
00187       (*Traits[t]) = (*i.Traits[t]);
00188     }
00189   }
00190   return *this;
00191 }

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

Only checks for traits equivalence.

Definition at line 195 of file individual.cc.

00196 {
00197   if(this != &i) {
00198     if(Traits.size() != i.Traits.size()) return false;
00199 
00200     for(unsigned int t = 0; t < Traits.size(); t++)
00201       if((*Traits[t]) != (*i.Traits[t])) return false;
00202 
00203   //if(_sex != i._sex) return false;
00204   }
00205   return true;
00206 }

void Individual::removeTrait ( IDX  T  )  [inline]

Removes a trait from the table.

Parameters:
T the trait's index in the traits table

Definition at line 292 of file individual.h.

00293   { delete Traits[T]; Traits.erase(Traits.begin() + T); _trait_nb--;}

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

Definition at line 79 of file individual.cc.

Referenced by IndFactory::makeNewIndividual().

00080 {
00081   _id = 0;
00082   _age = 0;
00083   _sex = MAL;
00084   _pedigreeClass = 0;
00085   _motherID = 0;
00086   _fatherID = 0;
00087   _mother = NULL;
00088   _father = NULL;
00089   _home = 0;
00090   for(unsigned int i = 0; i < 5; i++) {
00091     _matings[i] = 0; _realizedFecundity[i] = 0;
00092   }
00093    
00094   if(_trait_nb != Traits.size()){
00095     warning("Individual::reset: trait counter and table size differ, resetting\n");
00096     _trait_nb = Traits.size();
00097   }
00098 }

void Individual::reset_counters (  )  [inline]

Resets the mating and fecundity counters.

Definition at line 206 of file individual.h.

Referenced by LCE_Breed_base::breed_cloning().

00207   { 
00208     for(unsigned int i = 0; i < 5; i++) {
00209       _matings[i] = 0; _realizedFecundity[i] = 0;
00210     } }

void Individual::retrieve_data ( BinaryStorageBuffer reader  ) 

Definition at line 117 of file individual.cc.

Referenced by Metapop::retrieve_data().

00118 {
00119   reader->read(&_id, sizeof(unsigned long));
00120   reader->read(&_motherID, sizeof(unsigned long));
00121   reader->read(&_fatherID, sizeof(unsigned long));
00122   reader->read(&_sex, sizeof(sex_t));
00123   reader->read(&_home, sizeof(unsigned short));
00124   reader->read(&_matings, 2*sizeof(unsigned short));
00125   reader->read(&_realizedFecundity, 2*sizeof(unsigned short));
00126 //reader->read(&_pedigreeClass, 1);
00127 //reader->read(&_age, sizeof(unsigned short));
00128 }

void Individual::setAge ( unsigned short  value  )  [inline]

Definition at line 101 of file individual.h.

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

00101 {_age = value;}

void Individual::setCurrentID ( unsigned long  value  )  [inline]

Definition at line 109 of file individual.h.

Referenced by IndFactory::makePrototype().

00109 {currentID = value;}

void Individual::setFather ( Individual f  )  [inline]

Definition at line 105 of file individual.h.

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

00105 {_father = f;}

void Individual::setFatherID ( unsigned long  value  )  [inline]

Definition at line 103 of file individual.h.

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

00103 {_fatherID = value;}

double Individual::setFecundity ( double  value  )  [inline]

Sets the fecundity to the value given and returns it.

Parameters:
value the fecundity

Definition at line 203 of file individual.h.

Referenced by LCE_Breed_Selection::execute(), LCE_Breed_Wolbachia::execute(), and LCE_Breed::execute().

00203 {_fecundity = value; return value;}

void Individual::setHome ( unsigned short  value  )  [inline]

Definition at line 107 of file individual.h.

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

00107 {_home = value;}

void Individual::setID ( unsigned long  value  )  [inline]

Definition at line 100 of file individual.h.

Referenced by IndFactory::makeNewIndividual().

00100 {_id = value;}

void Individual::setIsSelfed ( bool  s  )  [inline]

Definition at line 110 of file individual.h.

Referenced by LCE_Breed_base::breed_cloning().

00110 {_pedigreeClass = (s ? 4 : 0);}

void Individual::setMother ( Individual m  )  [inline]

Definition at line 106 of file individual.h.

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

00106 {_mother = m;}

void Individual::setMotherID ( unsigned long  value  )  [inline]

Definition at line 104 of file individual.h.

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

00104 {_motherID = value;}

void Individual::setPedigreeClass ( unsigned char  ped  )  [inline]

Definition at line 112 of file individual.h.

00112 {_pedigreeClass = ped;}

void Individual::setPedigreeClass ( Individual mother,
Individual father 
) [inline]

void Individual::setSex ( sex_t  sex  )  [inline]

Definition at line 108 of file individual.h.

Referenced by IndFactory::makeNewIndividual().

00108 {_sex = sex;}

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

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

Parameters:
T the trait's index in the traits table
value the value passed to the trait (using the TTrait interface)

Definition at line 252 of file individual.h.

Referenced by LCE_Breed_Wolbachia::inoculate_wolbachia().

00253   { return getTrait(T)->set_trait(value); }

void Individual::setTraitValue (  )  [inline]

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

Definition at line 261 of file individual.h.

Referenced by create(), and createTrait().

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

void Individual::setTraitValue ( IDX  T  )  [inline]

Calls the value setting procedure of a particular trait.

Parameters:
T the trait's index in the traits table

Definition at line 257 of file individual.h.

00258   {  getTrait(T)->set_value(); }

void Individual::show_up (  ) 

Write some info to stdout.

Definition at line 132 of file individual.cc.

Referenced by TTDeletMutBitstrFH::FHread().

00133 {
00134   message("\n Individual ID: %i\n\
00135            age: %i\n\
00136            sex: %i\n\
00137         mother: %i\n\
00138         father: %i\n\
00139 pedigree class: %i\n\
00140           home: %i\n\
00141  traits values: \n",_id,_age,_sex,_motherID,_fatherID, _pedigreeClass,_home);
00142 
00143 for(unsigned int i = 0; i < _trait_nb; i++)
00144   Traits[i]->show_up();
00145 }

void Individual::store_data ( BinaryStorageBuffer saver  ) 

Definition at line 102 of file individual.cc.

00103 {
00104   saver->store(&_id, sizeof(unsigned long));
00105   saver->store(&_motherID, sizeof(unsigned long));
00106   saver->store(&_fatherID, sizeof(unsigned long));
00107   saver->store(&_sex, sizeof(sex_t));
00108   saver->store(&_home, sizeof(unsigned short));
00109   saver->store(&_matings, 2*sizeof(unsigned short));
00110   saver->store(&_realizedFecundity, 2*sizeof(unsigned short));
00111   //saver->store(&_pedigreeClass, 1);
00112   //saver->store(&_age, sizeof(unsigned short));
00113 }


Member Data Documentation

unsigned short Individual::_age [private]

Age.

Definition at line 53 of file individual.h.

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

Definition at line 59 of file individual.h.

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

unsigned long Individual::_fatherID [private]

double Individual::_fecundity [private]

Assigned fecundity.

Definition at line 71 of file individual.h.

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

unsigned short Individual::_home [private]

Natal Patch tag.

Definition at line 61 of file individual.h.

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

unsigned long Individual::_id [private]

ID tag, unique for one simulation.

Definition at line 51 of file individual.h.

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

unsigned short Individual::_matings[5] [private]

Parents pointers.

Definition at line 59 of file individual.h.

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

unsigned long Individual::_motherID [private]

Parents ID tags.

Definition at line 57 of file individual.h.

Referenced by create_first_gen(), getMotherID(), init(), operator=(), reset(), retrieve_data(), setMotherID(), 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).\

Definition at line 69 of file individual.h.

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

unsigned short Individual::_realizedFecundity[5] [private]

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

Definition at line 75 of file individual.h.

Referenced by DidHaveABaby(), getFecWithOtherPatchMate(), getLocalRealizedFecundity(), getRealizedFecundity(), getTotRealizedFecundity(), Individual(), init(), operator=(), reset(), reset_counters(), retrieve_data(), and store_data().

Sex tag.

Definition at line 55 of file individual.h.

Referenced by getSex(), isFemale(), operator=(), reset(), retrieve_data(), setSex(), show_up(), and store_data().

unsigned int Individual::_trait_nb [private]

unsigned long Individual::currentID = 0 [static]

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

Definition at line 80 of file individual.h.

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

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


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

Generated for Nemo v2.1.2 by  doxygen 1.5.8 -- Nemo is hosted by  SourceForge.net Logo