Nemo  2.2.0
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
Individual Class Reference

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

#include <individual.h>

+ Collaboration diagram for Individual:

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.

References _id, _matings, _realizedFecundity, and currentID.

Referenced by clone().

: _age(0), _sex(MAL),_motherID(0),_fatherID(0),_mother(NULL),_father(NULL),
_home(0),_pedigreeClass(0),_fecundity(0),_trait_nb(0)
{
  _id = currentID++;
  for(unsigned int i = 0; i < 5; i++) {
    _matings[i] = 0; _realizedFecundity[i] = 0;
  }
}
Individual::~Individual ( ) [inline]

Definition at line 87 of file individual.h.

References clearTraits().


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

Definition at line 215 of file individual.h.

References _matings.

Referenced by LCE_Breed_Selection::makeOffspringWithSelection().

  { _matings[category]++; }
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

Definition at line 284 of file individual.h.

References _trait_nb, fatal(), and Traits.

Referenced by clone().

  { if((int)_trait_nb != pos)
    fatal("Individual::adding a trait to the wrong position (at %i, size %i)!\n",pos,_trait_nb);
    Traits.push_back(theTrait); _trait_nb++;
  }
void Individual::Aging ( ) [inline]

Definition at line 102 of file individual.h.

References _age.

{_age++;}
void Individual::clearTraits ( ) [inline]

Clears the traits container.

Definition at line 296 of file individual.h.

References _trait_nb, and Traits.

Referenced by ~Individual().

  { if(_trait_nb != 0) {for(unsigned int i = 0; i < Traits.size(); ++i) delete Traits[i];
    Traits.clear(); _trait_nb = 0;}
  }
Individual * Individual::clone ( )

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

Definition at line 149 of file individual.cc.

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

Referenced by IndFactory::makeNewIndividual().

{
  Individual* myClone = new Individual();
  
  for(unsigned int i = 0; i < _trait_nb; i++)
    myClone->addTrait(Traits[i]->clone(), i);
  
  return myClone;
}
Individual* Individual::create ( ) [inline]

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

Definition at line 353 of file individual.h.

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

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

  { 
    inherit(_mother, _father);
    mutate();
    setTraitValue();
    return this;
  } 
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

Definition at line 363 of file individual.h.

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

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

Definition at line 374 of file individual.h.

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

  { if(mother == 0 || father == 0) fatal("Individual::create::received null parents pointer!!!\n");
    TTrait *TT;
    for(unsigned int i = 0; i < _trait_nb; i++) {
      TT = Traits[i];
      TT->inherit(mother->getTrait(i), father->getTrait(i));
      TT->mutate();
      TT->set_value();
    }
    return this;
  }
Individual* Individual::create_first_gen ( ) [inline]

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

Definition at line 339 of file individual.h.

References _fatherID, _motherID, _trait_nb, and Traits.

Referenced by Patch::setNewGeneration().

  {
    for(unsigned int i = 0; i < _trait_nb; i++) {
      Traits[i]->init_sequence();
      Traits[i]->set_value();
    }
    //we have to set the parents ids otherwise the first offspring generation will be made of full sibs only.
    static unsigned long ID = std::numeric_limits< unsigned long >::max();
    _motherID = ID--;
    _fatherID = ID--;
    return this;
  }  
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

Definition at line 318 of file individual.h.

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

Referenced by LCE_Breed_Selection::makeOffspringWithSelection().

  { if(mother == 0 || father == 0) fatal("Individual::create::received null pointer!!!\n");
    TTrait* T = Traits[i];
    T->inherit(mother->getTrait(i),father->getTrait(i));
    T->mutate();  
    T->set_value();
  }
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

Definition at line 330 of file individual.h.

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

  {
    if(do_inherit) inheritTrait(i, _mother, _father);
    if(do_mutate)  mutateTrait(i);
    setTraitValue(i);
    return this;
  } 
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

Definition at line 221 of file individual.h.

References _matings, and _realizedFecundity.

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

  { _matings[category]++; _realizedFecundity[category]++; }
unsigned short Individual::getAge ( ) [inline]

Definition at line 119 of file individual.h.

References _age.

{return _age;}
unsigned long Individual::getcurrentID ( ) [inline]

Definition at line 128 of file individual.h.

References currentID.

{return currentID;}
Individual* Individual::getFather ( ) [inline]

Definition at line 122 of file individual.h.

References _father.

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

{return _father;}
unsigned long Individual::getFatherID ( ) [inline]

Definition at line 120 of file individual.h.

References _fatherID.

Referenced by getPedigreeClass().

{return _fatherID;}
double Individual::getFecundity ( ) [inline]

Definition at line 129 of file individual.h.

References _fecundity.

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

References getLocalMatings(), and getLocalRealizedFecundity().

  { 
    unsigned short mate = getLocalMatings();
    return (mate != 0 ? (double) getLocalRealizedFecundity()/mate : 0.0);
  }
double Individual::getFecWithOtherPatchMate ( ) [inline]

Returns the proportion of successfull remote matings.

Returns:
_realizedFecundity[0]/_matings[0]

Definition at line 233 of file individual.h.

References _matings, and _realizedFecundity.

  {
    return (_matings[0] != 0 ? (double) _realizedFecundity[0]/_matings[0] : 0.0);
  }
unsigned short Individual::getHome ( ) [inline]

Definition at line 124 of file individual.h.

References _home.

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

{return _home;}
unsigned long Individual::getID ( ) [inline]

Definition at line 118 of file individual.h.

References _id.

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

{return _id;}
bool Individual::getIsSelfed ( ) [inline]

Definition at line 127 of file individual.h.

References _pedigreeClass.

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

References _matings.

Referenced by getFecWithHomePatchMate(), and getTotMatings().

  {
    return _matings[1]+_matings[2]+_matings[3]+_matings[4];
  }
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.

References _realizedFecundity.

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:
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

Definition at line 138 of file individual.h.

References _matings.

  {
    return _matings[cat];
  }
Individual* Individual::getMother ( ) [inline]

Definition at line 123 of file individual.h.

References _mother.

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

{return _mother;}
unsigned long Individual::getMotherID ( ) [inline]

Definition at line 121 of file individual.h.

References _motherID.

Referenced by getPedigreeClass().

{return _motherID;}
unsigned int Individual::getPedigreeClass ( ) [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)

Definition at line 220 of file individual.cc.

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

{
  if(mother == father) return 4; //selfed

  if(mother->getHome() != father->getHome()) return 0; //outbred between patch
  
  unsigned int mm,mf,fm,ff;
  //mother's parents:
  mm = mother->getMotherID();
  mf = mother->getFatherID();
  //father's parents:
  fm = father->getMotherID();
  ff = father->getFatherID();

  if(mm != fm && mf != ff) return 1; //outbred within patch
    
  else if((mm == fm && mf != ff) || (mm != fm && mf == ff)) return 2; //half sibs
    
  else return 3; //full sibs
}
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

Definition at line 160 of file individual.h.

References _realizedFecundity.

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

References _matings, and getLocalMatings().

  {
    return _matings[0] + getLocalMatings();
  }
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.

References _realizedFecundity, and getLocalRealizedFecundity().

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

Trait accessor.

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

Definition at line 273 of file individual.h.

References _trait_nb, fatal(), and Traits.

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

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

Accessor to the size of the traits table.

Definition at line 243 of file individual.h.

References _trait_nb.

Referenced by LCE_Selection_base::setParameters().

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

References Traits.

{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:
motherthe mother
fatherthe father

Definition at line 389 of file individual.h.

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

Referenced by create(), and inherit().

  { 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:
Tthe trait's index in the traits table
motherthe mother
fatherthe father

Definition at line 305 of file individual.h.

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

Referenced by createTrait().

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

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

Referenced by IndFactory::makeNewIndividual().

{
  _age = 0;
  _pedigreeClass = 0;
  _motherID = 0;
  _fatherID = 0;
  _mother = NULL;
  _father = NULL;
  _home = 0;
  for(unsigned int i = 0; i < 5; i++) {
    _matings[i] = 0; _realizedFecundity[i] = 0;
  }
  
  if(_trait_nb != Traits.size()){
    error("Individual::init: trait counter and table size differ, resetting\n");
    _trait_nb = Traits.size();
  }
  
  for(unsigned int i = 0; i < _trait_nb; i++)
    Traits[i]->init();

  return this;
}
bool Individual::isFemale ( ) [inline]

Definition at line 126 of file individual.h.

References _sex, and FEM.

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

References _trait_nb, mutate(), and Traits.

Referenced by create(), and mutate().

  { 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:
Ttrait's index in the traits table

Definition at line 310 of file individual.h.

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

Referenced by createTrait().

  {  getTrait(T)->mutate(); }
bool Individual::operator!= ( const Individual i)

Definition at line 210 of file individual.cc.

{
  if(!((*this) == i))
    return true;
  else
    return false;
}
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.

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

{
  if(this != &i) {  
    
    if(Traits.size() != i.Traits.size()) fatal("Individual::operator=:not same number of traits in left and right sides of assignment\n");
    if(_trait_nb != i._trait_nb) {
      error("Individual::operator=:trait counters differ, restting\n");
      _trait_nb = i._trait_nb;
    }
    _sex = i._sex;
    _age = i._age;
    _motherID = i._motherID;
    _fatherID = i._fatherID;
    _mother = i._mother;
    _father = i._father;
    _home = i._home;
    _pedigreeClass = i._pedigreeClass;
    _fecundity = i._fecundity;
    for(unsigned int j = 0; j < 5; j++) {
      _matings[j] = i._matings[j];
      _realizedFecundity[j] = i._realizedFecundity[j];
    }

    for(unsigned int t = 0; t < _trait_nb; t++){ 
      if(Traits[t]->get_type().compare(i.Traits[t]->get_type()) != 0) 
        fatal("Individual::operator=: not same kinds of traits on left and right sides of assignment\n");
      (*Traits[t]) = (*i.Traits[t]);
    }
  }
  return *this;
}
bool Individual::operator== ( const Individual i)

Only checks for traits equivalence.

Definition at line 195 of file individual.cc.

References Traits.

{
  if(this != &i) {
    if(Traits.size() != i.Traits.size()) return false;

    for(unsigned int t = 0; t < Traits.size(); t++)
      if((*Traits[t]) != (*i.Traits[t])) return false;

  //if(_sex != i._sex) return false;
  }
  return true;
}
void Individual::removeTrait ( IDX  T) [inline]

Removes a trait from the table.

Parameters:
Tthe trait's index in the traits table

Definition at line 292 of file individual.h.

References _trait_nb, and Traits.

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

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

Referenced by IndFactory::makeNewIndividual().

{
  _id = 0;
  _age = 0;
  _sex = MAL;
  _pedigreeClass = 0;
  _motherID = 0;
  _fatherID = 0;
  _mother = NULL;
  _father = NULL;
  _home = 0;
  for(unsigned int i = 0; i < 5; i++) {
    _matings[i] = 0; _realizedFecundity[i] = 0;
  }
   
  if(_trait_nb != Traits.size()){
    warning("Individual::reset: trait counter and table size differ, resetting\n");
    _trait_nb = Traits.size();
  }
}
void Individual::reset_counters ( ) [inline]

Resets the mating and fecundity counters.

Definition at line 206 of file individual.h.

References _matings, and _realizedFecundity.

Referenced by LCE_Breed_base::breed_cloning().

  { 
    for(unsigned int i = 0; i < 5; i++) {
      _matings[i] = 0; _realizedFecundity[i] = 0;
    } }
void Individual::retrieve_data ( BinaryStorageBuffer reader)

Definition at line 117 of file individual.cc.

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

Referenced by Metapop::retrieve_data().

{
  reader->read(&_id, sizeof(unsigned long));
  reader->read(&_motherID, sizeof(unsigned long));
  reader->read(&_fatherID, sizeof(unsigned long));
  reader->read(&_sex, sizeof(sex_t));
  reader->read(&_home, sizeof(unsigned short));
  reader->read(&_matings, 2*sizeof(unsigned short));
  reader->read(&_realizedFecundity, 2*sizeof(unsigned short));
//reader->read(&_pedigreeClass, 1);
//reader->read(&_age, sizeof(unsigned short));
}
void Individual::setAge ( unsigned short  value) [inline]

Definition at line 101 of file individual.h.

References _age.

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

{_age = value;}
void Individual::setCurrentID ( unsigned long  value) [inline]

Definition at line 109 of file individual.h.

References currentID.

{currentID = value;}
void Individual::setFather ( Individual f) [inline]

Definition at line 105 of file individual.h.

References _father.

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

{_father = f;}
void Individual::setFatherID ( unsigned long  value) [inline]

Definition at line 103 of file individual.h.

References _fatherID.

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

{_fatherID = value;}
double Individual::setFecundity ( double  value) [inline]

Sets the fecundity to the value given and returns it.

Parameters:
valuethe fecundity

Definition at line 203 of file individual.h.

References _fecundity.

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

{_fecundity = value; return value;}
void Individual::setHome ( unsigned short  value) [inline]

Definition at line 107 of file individual.h.

References _home.

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

{_home = value;}
void Individual::setID ( unsigned long  value) [inline]

Definition at line 100 of file individual.h.

References _id.

Referenced by IndFactory::makeNewIndividual().

{_id = value;}
void Individual::setIsSelfed ( bool  s) [inline]

Definition at line 110 of file individual.h.

References _pedigreeClass.

Referenced by LCE_Breed_base::breed_cloning().

{_pedigreeClass = (s ? 4 : 0);}
void Individual::setMother ( Individual m) [inline]

Definition at line 106 of file individual.h.

References _mother.

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

{_mother = m;}
void Individual::setMotherID ( unsigned long  value) [inline]

Definition at line 104 of file individual.h.

References _motherID.

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

{_motherID = value;}
void Individual::setPedigreeClass ( Individual mother,
Individual father 
) [inline]
void Individual::setPedigreeClass ( unsigned char  ped) [inline]

Definition at line 112 of file individual.h.

References _pedigreeClass.

{_pedigreeClass = ped;}
void Individual::setSex ( sex_t  sex) [inline]

Definition at line 108 of file individual.h.

References _sex.

Referenced by IndFactory::makeNewIndividual().

{_sex = sex;}
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)

Definition at line 252 of file individual.h.

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

Referenced by LCE_Breed_Wolbachia::inoculate_wolbachia().

  { return getTrait(T)->set_trait(value); }
void Individual::setTraitValue ( IDX  T) [inline]

Calls the value setting procedure of a particular trait.

Parameters:
Tthe trait's index in the traits table

Definition at line 257 of file individual.h.

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

  {  getTrait(T)->set_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.

References _trait_nb, and Traits.

Referenced by create(), and createTrait().

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

Write some info to stdout.

Definition at line 132 of file individual.cc.

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

Referenced by TTDeletMutBitstrFH::FHread().

{
  message("\n Individual ID: %i\n\
           age: %i\n\
           sex: %i\n\
        mother: %i\n\
        father: %i\n\
pedigree class: %i\n\
          home: %i\n\
 traits values: \n",_id,_age,_sex,_motherID,_fatherID, _pedigreeClass,_home);

for(unsigned int i = 0; i < _trait_nb; i++)
  Traits[i]->show_up();
}
void Individual::store_data ( BinaryStorageBuffer saver)

Definition at line 102 of file individual.cc.

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

{
  saver->store(&_id, sizeof(unsigned long));
  saver->store(&_motherID, sizeof(unsigned long));
  saver->store(&_fatherID, sizeof(unsigned long));
  saver->store(&_sex, sizeof(sex_t));
  saver->store(&_home, sizeof(unsigned short));
  saver->store(&_matings, 2*sizeof(unsigned short));
  saver->store(&_realizedFecundity, 2*sizeof(unsigned short));
  //saver->store(&_pedigreeClass, 1);
  //saver->store(&_age, sizeof(unsigned short));
}

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.2.0 by  doxygen 1.7.5.1 -- Nemo is hosted by  SourceForge.net Logo