Nemo  2.4.0b
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
TTDeletMutBitstrSH Class Reference

The StatHandler for TTDeletMutations_bitstring. More...

#include <ttdeletmutations_bitstring.h>

+ Inheritance diagram for TTDeletMutBitstrSH:
+ Collaboration diagram for TTDeletMutBitstrSH:

Public Member Functions

 TTDeletMutBitstrSH (TProtoDeletMutations_bitstring *TP)
 
virtual ~TTDeletMutBitstrSH ()
 
virtual bool setStatRecorders (std::string &token)
 
void setStatsForDeletMutations (age_t AGE)
 
void setViabStats (age_t AGE)
 
void setDeletStats (age_t AGE)
 
void setLethalEquivalents (age_t AGE)
 
void setFst (age_t AGE)
 
void setAdultDeletStats ()
 
void setOffsprgDeletStats ()
 
void setViability (age_idx agex)
 
void setAdultViab ()
 
void setOffsprgViab ()
 
void setMeanViability (age_idx agex)
 
double getMeanFecWithPatchMate (bool HOME)
 
double getBtheta ()
 
double getBalpha ()
 
double getHeterosis ()
 
double getLoad ()
 
double getPatchLoad (unsigned int i)
 
double getDeletAllFreq ()
 
double getDeletAllHmz ()
 
double getDeletAllHtz ()
 
double getFixedDeletLoci ()
 
double getFixedDeletLociPerPatch ()
 
double getSegregatingDeletLoci ()
 
double getSegregatingDeletLociPerPatch ()
 
double getDeletAllPerGenome ()
 
double getHs ()
 
double getHt ()
 
double getFst ()
 
double getLethalEquivalents ()
 
double getAdultsLetheq ()
 
double getOffsprgLetheq ()
 
double getViability (unsigned int v)
 
double getMeanViability ()
 
double getMeanViability (unsigned int a)
 
double getSibProportions (unsigned int i)
 
- Public Member Functions inherited from TraitStatHandler< TProtoDeletMutations_bitstring, TTDeletMutBitstrSH >
 TraitStatHandler (TProtoDeletMutations_bitstring *trait_proto)
 
virtual ~TraitStatHandler ()
 
- Public Member Functions inherited from StatHandler< SH >
 StatHandler ()
 
virtual ~StatHandler ()
 
virtual void clear ()
 Empties the _recorders list, they are destroyed in StatHandlerBase::reset(). More...
 
virtual StatRecorder< SH > * add (std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(SH::*getStatNoArg)(void), double(SH::*getStatOneArg)(unsigned int), double(SH::*getStatTwoArg)(unsigned int, unsigned int), void(SH::*setStat)(void))
 Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list. More...
 
- Public Member Functions inherited from StatHandlerBase
 StatHandlerBase ()
 
virtual ~StatHandlerBase ()
 
virtual void reset ()
 Empties the _stats list and calls clear() (defined in the derived class). More...
 
Metapopget_pop_ptr ()
 
void set_service (StatServices *srv)
 
StatServicesget_service ()
 
unsigned int getOccurrence ()
 
unsigned int getNumOccurrences ()
 
unsigned int getCurrentOccurrence ()
 
unsigned int getNbRecorders ()
 
std::list< StatRecBase * > & getStats ()
 
virtual void add (StatRecBase *rec)
 
virtual void init ()
 
virtual void update ()
 This function is left empty as the StatServices calls StatRecorder::setVal directly. More...
 
- Public Member Functions inherited from Handler
virtual ~Handler ()
 

Private Attributes

double fecWithHomePatchMate
 
double fecWithOtherPatchMate
 
double _SibProps [5]
 
double _viability [5]
 
double _meanViab
 
double _deletHtzLoci
 
double _deletHmzLoci
 
double _fixLocPerPatch
 
double _segrLocPerPatch
 
double _Ho
 
double _Hs
 
double _Ht
 
double _Fst
 
double _Hmz
 
double _deletAllCount
 
double _freq
 
double _fixloc
 
double _segrloc
 
double _letheq
 
double * _deletFreqTable
 
bool _isContinuousEffect
 

Additional Inherited Members

- Protected Types inherited from StatHandler< SH >
typedef std::list< StatRecorder< SH > * >::iterator REC_IT
 
- Protected Attributes inherited from TraitStatHandler< TProtoDeletMutations_bitstring, TTDeletMutBitstrSH >
TProtoDeletMutations_bitstring_SHLinkedTrait
 Pointer to a TraitProtoype object. More...
 
int _SHLinkedTraitIndex
 Index of the trait in the Individual::Traits table. More...
 
- Protected Attributes inherited from StatHandler< SH >
std::list< StatRecorder< SH > * > _recorders
 The list of stat recorders. More...
 
- Protected Attributes inherited from StatHandlerBase
Metapop_pop
 Link to the current population, set through the link to the StatService. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ TTDeletMutBitstrSH()

TTDeletMutBitstrSH::TTDeletMutBitstrSH ( TProtoDeletMutations_bitstring TP)
inline
bool get_iscontinuous()
Definition: ttdeletmutations_bitstring.h:192
bool _isContinuousEffect
Definition: ttdeletmutations_bitstring.h:299
double * _deletFreqTable
Definition: ttdeletmutations_bitstring.h:297

References _isContinuousEffect, and TProtoDeletMutations_bitstring::get_iscontinuous().

◆ ~TTDeletMutBitstrSH()

virtual TTDeletMutBitstrSH::~TTDeletMutBitstrSH ( )
inlinevirtual
307 {if(_deletFreqTable != 0) delete [] _deletFreqTable;}

References _deletFreqTable.

Member Function Documentation

◆ getAdultsLetheq()

double TTDeletMutBitstrSH::getAdultsLetheq ( )
inline
342 {setDeletStats(ADULTS); return _letheq;}
double _letheq
Definition: ttdeletmutations_bitstring.h:295
void setDeletStats(age_t AGE)
Definition: stats_delet_bitstring.cc:211
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54

References _letheq, ADULTS, and setDeletStats().

◆ getBalpha()

double TTDeletMutBitstrSH::getBalpha ( )
inline
326 {return fecWithOtherPatchMate;}
double fecWithOtherPatchMate
Definition: ttdeletmutations_bitstring.h:287

References fecWithOtherPatchMate.

◆ getBtheta()

double TTDeletMutBitstrSH::getBtheta ( )
inline
325 {return fecWithHomePatchMate;}
double fecWithHomePatchMate
Definition: ttdeletmutations_bitstring.h:287

References fecWithHomePatchMate.

◆ getDeletAllFreq()

double TTDeletMutBitstrSH::getDeletAllFreq ( )
inline
330 {return _freq;}
double _freq
Definition: ttdeletmutations_bitstring.h:295

References _freq.

Referenced by setStatsForDeletMutations().

◆ getDeletAllHmz()

double TTDeletMutBitstrSH::getDeletAllHmz ( )
inline
331 {return _Hmz;}
double _Hmz
Definition: ttdeletmutations_bitstring.h:295

References _Hmz.

Referenced by setStatsForDeletMutations().

◆ getDeletAllHtz()

double TTDeletMutBitstrSH::getDeletAllHtz ( )
inline
332 {return _Ho;}
double _Ho
Definition: ttdeletmutations_bitstring.h:295

References _Ho.

Referenced by setStatsForDeletMutations().

◆ getDeletAllPerGenome()

double TTDeletMutBitstrSH::getDeletAllPerGenome ( )
inline
337 {return _deletAllCount;}
double _deletAllCount
Definition: ttdeletmutations_bitstring.h:295

References _deletAllCount.

◆ getFixedDeletLoci()

double TTDeletMutBitstrSH::getFixedDeletLoci ( )
inline
333 {return _fixloc;}
double _fixloc
Definition: ttdeletmutations_bitstring.h:295

References _fixloc.

Referenced by setStatsForDeletMutations().

◆ getFixedDeletLociPerPatch()

double TTDeletMutBitstrSH::getFixedDeletLociPerPatch ( )
inline
334 {return _fixLocPerPatch;}
double _fixLocPerPatch
Definition: ttdeletmutations_bitstring.h:294

References _fixLocPerPatch.

Referenced by setStatsForDeletMutations().

◆ getFst()

double TTDeletMutBitstrSH::getFst ( )
inline
340 {return _Fst;}
double _Fst
Definition: ttdeletmutations_bitstring.h:295

References _Fst.

Referenced by setStatsForDeletMutations().

◆ getHeterosis()

double TTDeletMutBitstrSH::getHeterosis ( )
73 {
74  double Btheta = getMeanFecWithPatchMate(true);
75  double Balpha = getMeanFecWithPatchMate(false);
76 
77  return (Balpha != 0 ? (1 - (Btheta/Balpha)): nanf("NULL"));
78 }
double getMeanFecWithPatchMate(bool HOME)
Definition: stats_delet_bitstring.cc:41

References getMeanFecWithPatchMate().

Referenced by setStatsForDeletMutations().

◆ getHs()

double TTDeletMutBitstrSH::getHs ( )
inline
338 {return _Hs;}
double _Hs
Definition: ttdeletmutations_bitstring.h:295

References _Hs.

◆ getHt()

double TTDeletMutBitstrSH::getHt ( )
inline
339 {return _Ht;}
double _Ht
Definition: ttdeletmutations_bitstring.h:295

References _Ht.

◆ getLethalEquivalents()

double TTDeletMutBitstrSH::getLethalEquivalents ( )
inline
341 {return _letheq;}

References _letheq.

Referenced by setStatsForDeletMutations().

◆ getLoad()

double TTDeletMutBitstrSH::getLoad ( )
166 {
167  unsigned int nb_patch=0;
168  double mean_load=0;
169 
170  for(unsigned int i = 0; i<_pop->getPatchNbr(); i++){
171 
172  if(_pop->getPatch(i)->size(FEM, ADLTx) != 0) {
173 
174  mean_load += getPatchLoad(i);
175 
176  nb_patch++;
177  }
178  }
179 
180  return (nb_patch != 0 ? mean_load/nb_patch : nanf("NULL"));
181 }
unsigned int getPatchNbr()
Definition: metapop.h:276
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:498
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
double getPatchLoad(unsigned int i)
Definition: stats_delet_bitstring.cc:185
@ FEM
Definition: types.h:37
@ ADLTx
Definition: types.h:42

References StatHandlerBase::_pop, ADLTx, FEM, Metapop::getPatch(), getPatchLoad(), Metapop::getPatchNbr(), and Patch::size().

Referenced by setStatsForDeletMutations().

◆ getMeanFecWithPatchMate()

double TTDeletMutBitstrSH::getMeanFecWithPatchMate ( bool  HOME)
42 {
43  double m_fec = 0;
44  unsigned int nbfem = 0;
45  Patch* patch;
46  Individual* fem;
47 
48  if(HOME) {
49  for(unsigned int i = 0, pnb = _pop->getPatchNbr(); i < pnb; ++i) {
50  patch = _pop->getPatch(i);
51  for(unsigned int j = 0, size = patch->size(FEM, ADLTx); j < size; ++j) {
52  fem = patch->get(FEM, ADLTx, j);
53  m_fec += fem->getFecWithHomePatchMate();
54  nbfem += (fem->getLocalMatings() != 0);
55  }
56  }
57  } else {
58  for(unsigned int i = 0, pnb = _pop->getPatchNbr(); i < pnb; ++i) {
59  patch = _pop->getPatch(i);
60  for(unsigned int j = 0, size = _pop->getPatch(i)->size(FEM, ADLTx); j < size; ++j) {
61  fem = patch->get(FEM, ADLTx, j);
62  m_fec += fem->getFecWithOtherPatchMate();
63  nbfem += (fem->getMatings(0) != 0);
64  }
65  }
66  }
67  return (nbfem != 0 ? (double) m_fec/nbfem : 0.0);
68 }
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:49
double getFecWithHomePatchMate()
Returns the proportion of succesfull local matings (i.e.
Definition: individual.h:229
double getFecWithOtherPatchMate()
Returns the proportion of successfull remote matings.
Definition: individual.h:237
unsigned short getMatings(unsigned int cat)
Gives the number of matings that individual had with mates from a given pedigree class.
Definition: individual.h:142
unsigned short getLocalMatings()
Gives the number of times an individual mated with an individual from the same patch.
Definition: individual.h:147
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:432
Individual * get(sex_t SEX, age_idx AGE, unsigned int at)
Returns a pointer to the individual sitting at the index passed.
Definition: metapop.h:534

References StatHandlerBase::_pop, ADLTx, FEM, Patch::get(), Individual::getFecWithHomePatchMate(), Individual::getFecWithOtherPatchMate(), Individual::getLocalMatings(), Individual::getMatings(), Metapop::getPatch(), Metapop::getPatchNbr(), and Patch::size().

Referenced by getHeterosis().

◆ getMeanViability() [1/2]

double TTDeletMutBitstrSH::getMeanViability ( )
inline
346 {return _meanViab;}
double _meanViab
Definition: ttdeletmutations_bitstring.h:289

References _meanViab.

Referenced by setStatRecorders(), and setViabStats().

◆ getMeanViability() [2/2]

double TTDeletMutBitstrSH::getMeanViability ( unsigned int  a)
inline
347 {setMeanViability(static_cast<age_idx> (a)); return _meanViab;}
void setMeanViability(age_idx agex)
Definition: stats_delet_bitstring.cc:139
age_idx
Array index of the age classes in the patch sizes and containers arrays.
Definition: types.h:41

References _meanViab, and setMeanViability().

◆ getOffsprgLetheq()

double TTDeletMutBitstrSH::getOffsprgLetheq ( )
inline
343 {setDeletStats(OFFSPRG); return _letheq;}
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

References _letheq, OFFSPRG, and setDeletStats().

◆ getPatchLoad()

double TTDeletMutBitstrSH::getPatchLoad ( unsigned int  i)
186 {
187  Individual *ind;
188  double fec, matings;
189  double rel_fec, max_fec = 0, mean_patch_fec = 0;
190 
191  for(unsigned int j = 0, size = _pop->getPatch(i)->size(FEM, ADLTx); j < size; j++) {
192  ind = _pop->getPatch(i)->get(FEM, ADLTx, j);
193  fec = (double)ind->getTotRealizedFecundity();
194  matings = (double)ind->getTotMatings();
195  rel_fec = (matings != 0 ? fec/matings : 0.0);
196  mean_patch_fec += rel_fec;
197  if(rel_fec > max_fec) max_fec = rel_fec;
198  }
199 
200  mean_patch_fec /= _pop->getPatch(i)->size(FEM, ADLTx);
201 
202  return ( max_fec != 0 ? (max_fec - mean_patch_fec)/max_fec : nanf("NULL"));
203 }
unsigned int getTotMatings()
Gives the total number of matings of an individual.
Definition: individual.h:152
unsigned int getTotRealizedFecundity()
Gives the total number of surviving offspring for all categories of mating.
Definition: individual.h:176

References StatHandlerBase::_pop, ADLTx, FEM, Patch::get(), Metapop::getPatch(), Individual::getTotMatings(), Individual::getTotRealizedFecundity(), and Patch::size().

Referenced by getLoad().

◆ getSegregatingDeletLoci()

double TTDeletMutBitstrSH::getSegregatingDeletLoci ( )
inline
335 {return _segrloc;}
double _segrloc
Definition: ttdeletmutations_bitstring.h:295

References _segrloc.

Referenced by setStatsForDeletMutations().

◆ getSegregatingDeletLociPerPatch()

double TTDeletMutBitstrSH::getSegregatingDeletLociPerPatch ( )
inline
336 {return _segrLocPerPatch;}
double _segrLocPerPatch
Definition: ttdeletmutations_bitstring.h:294

References _segrLocPerPatch.

Referenced by setStatsForDeletMutations().

◆ getSibProportions()

double TTDeletMutBitstrSH::getSibProportions ( unsigned int  i)
inline
349 {return _SibProps[i];}
double _SibProps[5]
Definition: ttdeletmutations_bitstring.h:289

References _SibProps.

Referenced by setViabStats().

◆ getViability()

double TTDeletMutBitstrSH::getViability ( unsigned int  v)
inline
345 {return _viability[v];}
double _viability[5]
Definition: ttdeletmutations_bitstring.h:289

References _viability.

Referenced by setViabStats().

◆ setAdultDeletStats()

void TTDeletMutBitstrSH::setAdultDeletStats ( )
inline

References ADULTS, and setDeletStats().

Referenced by setStatsForDeletMutations().

◆ setAdultViab()

void TTDeletMutBitstrSH::setAdultViab ( )
inline
void setViability(age_idx agex)
Definition: stats_delet_bitstring.cc:86

References ADLTx, and setViability().

Referenced by setViabStats().

◆ setDeletStats()

void TTDeletMutBitstrSH::setDeletStats ( age_t  AGE)
212 {
213  unsigned int i, j, k, nb_ind = 0, nb_patch = 0;
214  unsigned int nb_locus = _SHLinkedTrait->get_nb_locus();
215  unsigned int psize=0;
217  Patch* current_patch;
218  age_idx agex = (AGE == ADULTS ? ADLTx : OFFSx);
219 
220  _deletHtzLoci = 0;
221  _deletHmzLoci = 0;
222  _deletAllCount = 0;
223  _Hs = 0;
224  _Ht = 0;
225  _fixLocPerPatch = 0;
226  _segrLocPerPatch = 0;
227 
228  if(_deletFreqTable != NULL)
229  delete [] _deletFreqTable;
230 
231  _deletFreqTable = new double [nb_locus];
232 
233  double* patch_freqbylocus = new double[nb_locus];
234 
235  for(i = 0; i < nb_locus; ++i)
236  _deletFreqTable[i] = 0;
237 
238 
239  for(i = 0; i < _pop->getPatchNbr(); ++i) {
240 
241  current_patch = _pop->getPatch(i);
242 
243  if( (psize = current_patch->size(AGE)) == 0) continue;
244 
245  nb_patch++;
246 
247  nb_ind += psize;
248 
249  for(j = 0; j < nb_locus; ++j)
250  patch_freqbylocus[j] = 0;
251 
252  //Females
253  for(j = 0; j < current_patch->size(FEM, agex); ++j) {
254 
255  trait = static_cast< TTDeletMutations_bitstring* > ( current_patch->get( FEM, agex, j )->getTrait( _SHLinkedTraitIndex ) );
256 
258 
260 
261  //sparse iteration over set bits in both chromosomes
262  bitstring** seq = (bitstring**)trait->get_sequence();
263  for (unsigned int c = 0; c < 2; ++c) {
264  for (size_t w = 0; w < seq[c]->nb_words(); ++w) {
265  auto word = *seq[c]->getword_atIdx(w);
266  while (word) {
267  unsigned int bit = __builtin_ctzl(word);
268  patch_freqbylocus[w * BITS_PER_WORD + bit] += 1;
269  word &= word - 1;
270  }
271  }
272  }
273 
274  }//end for females
275 
276  //Males
277  for(j = 0; j < current_patch->size(MAL, agex); ++j) {
278 
279  trait = static_cast< TTDeletMutations_bitstring* > ( current_patch->get( MAL, agex, j )->getTrait( _SHLinkedTraitIndex ) );
280 
282 
284 
285  //sparse iteration over set bits in both chromosomes
286  bitstring** seq = (bitstring**)trait->get_sequence();
287  for (unsigned int c = 0; c < 2; ++c) {
288  for (size_t w = 0; w < seq[c]->nb_words(); ++w) {
289  auto word = *seq[c]->getword_atIdx(w);
290  while (word) {
291  unsigned int bit = __builtin_ctzl(word);
292  patch_freqbylocus[w * BITS_PER_WORD + bit] += 1;
293  word &= word - 1;
294  }
295  }
296  }
297 
298  }//end for males
299 
300  double dipl_size = psize*2.0;
301  for(j = 0; j < nb_locus; ++j) {
302  //aggregate for the pop freq by locus:
303  _deletFreqTable[j] += patch_freqbylocus[j];
304  //aggregate mut nbr for the population tot mut nbr:
305  _deletAllCount += patch_freqbylocus[j];
306  //get the local Patch mut freq by locus:
307  patch_freqbylocus[j] /= dipl_size;
308  //compute the expected local htz = 2pq:
309  _Hs += patch_freqbylocus[j] * (1.0 - patch_freqbylocus[j]);
310  }
311 
312  for(j = 0; j < nb_locus; ++j) {
313  //segregating and fixed loci in the Patch:
314  if(patch_freqbylocus[j] == 1.0)
315  _fixLocPerPatch++;
316  else if(patch_freqbylocus[j] != 0)
318  }
319 
320  }//end for Patch
321 
322  double dipl_size = nb_ind*2.0;
323 
324  _freq = 0;
325  _fixloc = _segrloc = 0;
326 
327  for(i = 0; i < nb_locus; ++i){
328 
329  _deletFreqTable[i] /= dipl_size;
330 
331  _Ht += _deletFreqTable[i] * (1.0 - _deletFreqTable[i]);//2pq: expected htz
332 
333  _freq += _deletFreqTable[i];
334 
335  _fixloc += (_deletFreqTable[i] == 1);
336 
337  _segrloc += (_deletFreqTable[i] < 1 && _deletFreqTable[i] != 0);
338  }
339 
340  //factorization not done in previous loops:
341  _Hs *= 2;
342  _Ht *= 2;
343 
344  _deletAllCount /= nb_ind;
345  _freq /= nb_locus;
346  _Hs /= nb_locus * nb_patch;
347  _Ht /= nb_locus;
348  _Ho = _deletHtzLoci / (nb_ind * nb_locus);
349  _Hmz = _deletHmzLoci/ (nb_ind * nb_locus);
350  _fixLocPerPatch /= nb_patch;
351  _segrLocPerPatch /= nb_patch;
352 
354 
355  setFst(AGE);
356 
357  delete [] patch_freqbylocus;
358  delete [] _deletFreqTable;
359  _deletFreqTable = 0;
360 }
#define BITS_PER_WORD
Definition: bitstring.h:41
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
int get_nb_locus()
Definition: ttdeletmutations_bitstring.h:186
double _deletHmzLoci
Definition: ttdeletmutations_bitstring.h:294
double _deletHtzLoci
Definition: ttdeletmutations_bitstring.h:294
void setFst(age_t AGE)
Definition: stats_delet_bitstring.cc:382
void setLethalEquivalents(age_t AGE)
Definition: stats_delet_bitstring.cc:364
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:47
virtual void ** get_sequence() const
Definition: ttdeletmutations_bitstring.h:149
unsigned int get_nb_htz_mutations() const
Definition: ttdeletmutations_bitstring.h:111
unsigned int get_nb_hmz_mutations() const
Definition: ttdeletmutations_bitstring.h:112
int _SHLinkedTraitIndex
Index of the trait in the Individual::Traits table.
Definition: stathandler.h:173
TProtoDeletMutations_bitstring * _SHLinkedTrait
Pointer to a TraitProtoype object.
Definition: stathandler.h:171
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:57
_ul * getword_atIdx(size_t index) const
Definition: bitstring.h:159
size_t nb_words() const
Definition: bitstring.h:164
@ MAL
Definition: types.h:37
@ OFFSx
Definition: types.h:42

References _deletAllCount, _deletFreqTable, _deletHmzLoci, _deletHtzLoci, _fixloc, _fixLocPerPatch, _freq, _Hmz, _Ho, _Hs, _Ht, StatHandlerBase::_pop, _segrloc, _segrLocPerPatch, TraitStatHandler< TProtoDeletMutations_bitstring, TTDeletMutBitstrSH >::_SHLinkedTrait, TraitStatHandler< TProtoDeletMutations_bitstring, TTDeletMutBitstrSH >::_SHLinkedTraitIndex, ADLTx, ADULTS, BITS_PER_WORD, FEM, Patch::get(), TTDeletMutations_bitstring::get_nb_hmz_mutations(), TTDeletMutations_bitstring::get_nb_htz_mutations(), TProtoDeletMutations_bitstring::get_nb_locus(), TTDeletMutations_bitstring::get_sequence(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTrait(), bitstring::getword_atIdx(), MAL, bitstring::nb_words(), OFFSx, setFst(), setLethalEquivalents(), and Patch::size().

Referenced by getAdultsLetheq(), getOffsprgLetheq(), setAdultDeletStats(), and setOffsprgDeletStats().

◆ setFst()

void TTDeletMutBitstrSH::setFst ( age_t  AGE)
383 {
384  unsigned i, nbpatch = 0;
385  double Hsnei, Htnei, harmonic = 0, size;
386  Patch* current_patch;
387 
388  for (i = 0; i < _pop->getPatchNbr(); ++i){
389 
390  current_patch = _pop->getPatch(i);
391 
392  if( (size = (double)current_patch->size(AGE)) != 0){
393  nbpatch++;
394  harmonic += 1.0/size;
395  }
396  }
397 
398  harmonic = (double)nbpatch/harmonic;
399 
400  Hsnei = harmonic/(harmonic-1.0)*(_Hs - ( _Ho/(2.0*harmonic) ) );
401  Htnei = _Ht + ( Hsnei/(harmonic*nbpatch) ) - ( _Ho/(2.0*harmonic*nbpatch) );
402 
403  _Fst = 1.0 - (Hsnei/Htnei);
404 }

References _Fst, _Ho, _Hs, _Ht, StatHandlerBase::_pop, Metapop::getPatch(), Metapop::getPatchNbr(), and Patch::size().

Referenced by setDeletStats().

◆ setLethalEquivalents()

void TTDeletMutBitstrSH::setLethalEquivalents ( age_t  AGE)
365 {
366  _letheq = 0;
367 
368  if(_deletFreqTable == 0)
369  fatal("allele frequency table not set when computing lethal equivalents\n");
370 
371  if(_isContinuousEffect) {
372  float* s = _SHLinkedTrait->get_s_continous();
373  for(int i = 0, nloc = _SHLinkedTrait->get_nb_locus(); i < nloc; i++)
374  _letheq += _deletFreqTable[i] * s[i];
375  } else
377  / _pop->size(AGE);
378 }
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:312
float * get_s_continous()
Definition: ttdeletmutations_bitstring.h:195
double get_strength()
Definition: ttdeletmutations_bitstring.h:189
void fatal(const char *str,...)
Definition: output.cc:100

References _deletFreqTable, _deletHmzLoci, _deletHtzLoci, _isContinuousEffect, _letheq, StatHandlerBase::_pop, TraitStatHandler< TProtoDeletMutations_bitstring, TTDeletMutBitstrSH >::_SHLinkedTrait, fatal(), TProtoDeletMutations_bitstring::get_nb_locus(), TProtoDeletMutations_bitstring::get_s_continous(), TProtoDeletMutations_bitstring::get_strength(), and Metapop::size().

Referenced by setDeletStats().

◆ setMeanViability()

void TTDeletMutBitstrSH::setMeanViability ( age_idx  agex)
140 {
141  unsigned int ind_cnt = 0;
142  Patch *patch;
143  _meanViab = 0;
144  for(unsigned int i = 0; i<_pop->getPatchNbr(); ++i) {
145  patch = _pop->getPatch(i);
146  for(unsigned int j = 0, size = patch->size(FEM, agex); j < size; ++j) {
147  _meanViab += *(double*)patch->get(FEM, ADLTx, j)->getTraitValue(_SHLinkedTraitIndex);
148  ind_cnt++;
149  }
150  for(unsigned int j = 0, size = patch->size(MAL, agex); j < size; ++j) {
151  _meanViab += *(double*)patch->get(MAL, ADLTx, j)->getTraitValue(_SHLinkedTraitIndex);
152  ind_cnt++;
153  }
154  }
155 
156  _meanViab = ( ind_cnt != 0 ? _meanViab/ind_cnt : nanf("NULL"));
157 }
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271

References _meanViab, StatHandlerBase::_pop, TraitStatHandler< TProtoDeletMutations_bitstring, TTDeletMutBitstrSH >::_SHLinkedTraitIndex, ADLTx, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), MAL, and Patch::size().

Referenced by getMeanViability().

◆ setOffsprgDeletStats()

void TTDeletMutBitstrSH::setOffsprgDeletStats ( )
inline

References OFFSPRG, and setDeletStats().

Referenced by setStatsForDeletMutations().

◆ setOffsprgViab()

void TTDeletMutBitstrSH::setOffsprgViab ( )
inline

References OFFSx, and setViability().

Referenced by setViabStats().

◆ setStatRecorders()

bool TTDeletMutBitstrSH::setStatRecorders ( std::string &  token)
virtual

Implements StatHandlerBase.

1034 {
1035 #ifdef _DEBUG_
1036  message("-TTDeletMutBitstrSH::setStatRecorders ");
1037 #endif
1038  if(token.compare("delet") == 0) {
1039 
1041 
1042  }else if(token.compare("adlt.delet") == 0) {
1043 
1045 
1046 
1047  }else if(token.compare("off.delet") == 0) {
1048 
1050 
1051 
1052  } else if(token.compare("viability") == 0) {
1053 
1054  setViabStats(ALL);
1055 
1056  } else if(token.compare("off.viability") == 0) {
1057 
1059 
1060  } else if(token.compare("adlt.viability") == 0) {
1061 
1063 
1064  } else if(token.compare("meanviab") == 0) {
1065 
1066  add("Offspring Viability","off.viab",OFFSPRG, static_cast<unsigned int> (OFFSx),
1068  add("Adults Viability","adlt.viab",ADULTS, static_cast<unsigned int> (ADLTx),
1070 
1071  } else
1072  return false;
1073 
1074  return true;
1075 }
virtual StatRecorder< SH > * add(std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(SH::*getStatNoArg)(void), double(SH::*getStatOneArg)(unsigned int), double(SH::*getStatTwoArg)(unsigned int, unsigned int), void(SH::*setStat)(void))
Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list.
Definition: stathandler.h:144
void setStatsForDeletMutations(age_t AGE)
Definition: ttdeletmutations_bitstring.cc:1077
double getMeanViability()
Definition: ttdeletmutations_bitstring.h:346
void setViabStats(age_t AGE)
Definition: ttdeletmutations_bitstring.cc:1125
void message(const char *message,...)
Definition: output.cc:40
#define ALL
All ages age class flag.
Definition: types.h:56

References StatHandler< SH >::add(), ADLTx, ADULTS, ALL, getMeanViability(), message(), OFFSPRG, OFFSx, setStatsForDeletMutations(), and setViabStats().

◆ setStatsForDeletMutations()

void TTDeletMutBitstrSH::setStatsForDeletMutations ( age_t  AGE)
1078 {
1079  if(AGE == ALL) {
1081  return;
1082  }
1083 
1084  string prefix = (AGE == ADULTS ? "adlt." : "off.");
1085  void (TTDeletMutBitstrSH::* setter) () = (AGE == ADULTS ?
1088 
1089  add("Frequency of deleterious alleles", prefix + "delfreq", AGE,0,0,
1091  setter);
1092 
1093  add("Homozygosity of delet. allele", prefix + "delhmz", AGE,0,0,
1095 
1096  add("Heterozygosity of delet. allele", prefix + "delhtz", AGE,0,0,
1098 
1099  add("Fixed Delet Mutations - Global", prefix + "delfix", AGE,0,0,
1101 
1102  add("Fixed Delet Mutations - Local", prefix + "delfixp", AGE,0,0,
1104 
1105  add("Segregating Delet Mutations - Global", prefix + "delsegr", AGE,0,0,
1107 
1108  add("Segregating Delet Mutations - Local", prefix + "delsegrp", AGE,0,0,
1110 
1111  add("Delet Fst", prefix + "delfst", AGE,0,0,
1113 
1114  add("Lethal Equivalents", prefix + "lethequ", AGE,0,0,
1116 
1117  add("Heterosis", "heterosis", ADULTS,0,0,
1119 
1120  add("Genetic Load", "load", ADULTS,0,0,
1122 
1123 }
The StatHandler for TTDeletMutations_bitstring.
Definition: ttdeletmutations_bitstring.h:285
double getDeletAllFreq()
Definition: ttdeletmutations_bitstring.h:330
double getDeletAllHmz()
Definition: ttdeletmutations_bitstring.h:331
double getDeletAllHtz()
Definition: ttdeletmutations_bitstring.h:332
double getFst()
Definition: ttdeletmutations_bitstring.h:340
double getLoad()
Definition: stats_delet_bitstring.cc:165
double getLethalEquivalents()
Definition: ttdeletmutations_bitstring.h:341
double getFixedDeletLociPerPatch()
Definition: ttdeletmutations_bitstring.h:334
double getFixedDeletLoci()
Definition: ttdeletmutations_bitstring.h:333
double getSegregatingDeletLociPerPatch()
Definition: ttdeletmutations_bitstring.h:336
void setOffsprgDeletStats()
Definition: ttdeletmutations_bitstring.h:317
double getHeterosis()
Definition: stats_delet_bitstring.cc:72
double getSegregatingDeletLoci()
Definition: ttdeletmutations_bitstring.h:335
void setAdultDeletStats()
Definition: ttdeletmutations_bitstring.h:316

References StatHandler< SH >::add(), ADULTS, ALL, getDeletAllFreq(), getDeletAllHmz(), getDeletAllHtz(), getFixedDeletLoci(), getFixedDeletLociPerPatch(), getFst(), getHeterosis(), getLethalEquivalents(), getLoad(), getSegregatingDeletLoci(), getSegregatingDeletLociPerPatch(), OFFSPRG, setAdultDeletStats(), and setOffsprgDeletStats().

Referenced by setStatRecorders().

◆ setViability()

void TTDeletMutBitstrSH::setViability ( age_idx  agex)
87 {
88  Individual *ind;
89  unsigned int ped_class;
90  Patch *patch;
91 
92  for(unsigned i = 0; i < 5; i++) {
93  _viability[i] = 0;
94  _SibProps[i] = 0;
95  }
96 
97  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
98 
99  patch = _pop->getPatch(i);
100 
101  for(unsigned int j = 0, size = patch->size(MAL, agex); j < size; ++j) {
102 
103  ind = patch->get(MAL, agex, j);
104 
105  ped_class = ind->getPedigreeClass();
106 
107  _viability[ped_class] += *(double*)ind->getTrait(_SHLinkedTraitIndex)->getValue();
108 
109  _SibProps[ped_class]++;
110  }
111 
112  for(unsigned int j = 0, size = patch->size(FEM, agex); j < size; ++j) {
113 
114  ind = patch->get(FEM, agex, j);
115 
116  ped_class = ind->getPedigreeClass();
117 
118  _viability[ped_class] += *(double*)ind->getTrait(_SHLinkedTraitIndex)->getValue();
119 
120  _SibProps[ped_class]++;
121  }
122 
123  }
124 
125  double tot_ind = _SibProps[0] + _SibProps[1] + _SibProps[2] + _SibProps[3] + _SibProps[4];
127  _meanViab /= tot_ind;
128 
129  for(unsigned i = 0; i < 5; i++)
130  _viability[i] = (_SibProps[i] != 0 ? _viability[i] / _SibProps[i] : nanf("NULL"));
131 
132  for(unsigned i = 0; i < 5; i++)
133  _SibProps[i] /= tot_ind;
134 
135 }
unsigned int getPedigreeClass()
Returns the pedigree class of the individual, as set during offspring creation.
Definition: individual.h:179
virtual void * getValue() const =0
Genotype to phenotype mapper.

References _meanViab, StatHandlerBase::_pop, TraitStatHandler< TProtoDeletMutations_bitstring, TTDeletMutBitstrSH >::_SHLinkedTraitIndex, _SibProps, _viability, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getPedigreeClass(), Individual::getTrait(), TTrait::getValue(), MAL, and Patch::size().

Referenced by setAdultViab(), and setOffsprgViab().

◆ setViabStats()

void TTDeletMutBitstrSH::setViabStats ( age_t  AGE)
1126 {
1127  if(AGE == ALL) {
1129  return;
1130  }
1131 
1132  string prefix = (AGE == ADULTS ? "adlt." : "off.");
1133  void (TTDeletMutBitstrSH::* setter) () = (AGE == ADULTS ?
1136 
1137  add("Average Viability", prefix + "viab", AGE, 0, 0,
1139  setter);
1140 
1141  add("Outbreds Viability", prefix + "viab.outb", AGE, 0,0,0,
1143 
1144  add("Inbreds Viability", prefix + "viab.outw", AGE, 1,0,0,
1146 
1147  add("Half Sibs Viability", prefix + "viab.hsib", AGE, 2,0,0,
1149 
1150  add("Full Sibs Viability", prefix + "viab.fsib", AGE, 3,0,0,
1152 
1153  add("Selfed Viability", prefix + "viab.self", AGE, 4,0,0,
1155 
1156  add("Outbred btw Proportion", prefix + "prop.outb", AGE, 0,0,0,
1158 
1159  add("Outbred wtn Proportion", prefix + "prop.outw", AGE, 1,0,0,
1161 
1162  add("Half Sibs Proportion", prefix + "prop.hsibs", AGE, 2,0,0,
1164 
1165  add("Full Sibs Proportion", prefix + "prop.fsibs", AGE, 3,0,0,
1167 
1168  add("Selfed Proportion", prefix + "prop.self", AGE, 4,0,0,
1170 }
void setAdultViab()
Definition: ttdeletmutations_bitstring.h:319
void setOffsprgViab()
Definition: ttdeletmutations_bitstring.h:320
double getViability(unsigned int v)
Definition: ttdeletmutations_bitstring.h:345
double getSibProportions(unsigned int i)
Definition: ttdeletmutations_bitstring.h:349

References StatHandler< SH >::add(), ADULTS, ALL, getMeanViability(), getSibProportions(), getViability(), OFFSPRG, setAdultViab(), and setOffsprgViab().

Referenced by setStatRecorders().

Member Data Documentation

◆ _deletAllCount

double TTDeletMutBitstrSH::_deletAllCount
private

◆ _deletFreqTable

double* TTDeletMutBitstrSH::_deletFreqTable
private

◆ _deletHmzLoci

double TTDeletMutBitstrSH::_deletHmzLoci
private

◆ _deletHtzLoci

double TTDeletMutBitstrSH::_deletHtzLoci
private

◆ _fixloc

double TTDeletMutBitstrSH::_fixloc
private

Referenced by getFixedDeletLoci(), and setDeletStats().

◆ _fixLocPerPatch

double TTDeletMutBitstrSH::_fixLocPerPatch
private

◆ _freq

double TTDeletMutBitstrSH::_freq
private

Referenced by getDeletAllFreq(), and setDeletStats().

◆ _Fst

double TTDeletMutBitstrSH::_Fst
private

Referenced by getFst(), and setFst().

◆ _Hmz

double TTDeletMutBitstrSH::_Hmz
private

Referenced by getDeletAllHmz(), and setDeletStats().

◆ _Ho

double TTDeletMutBitstrSH::_Ho
private

◆ _Hs

double TTDeletMutBitstrSH::_Hs
private

Referenced by getHs(), setDeletStats(), and setFst().

◆ _Ht

double TTDeletMutBitstrSH::_Ht
private

Referenced by getHt(), setDeletStats(), and setFst().

◆ _isContinuousEffect

bool TTDeletMutBitstrSH::_isContinuousEffect
private

◆ _letheq

double TTDeletMutBitstrSH::_letheq
private

◆ _meanViab

double TTDeletMutBitstrSH::_meanViab
private

◆ _segrloc

double TTDeletMutBitstrSH::_segrloc
private

◆ _segrLocPerPatch

double TTDeletMutBitstrSH::_segrLocPerPatch
private

◆ _SibProps

double TTDeletMutBitstrSH::_SibProps[5]
private

Referenced by getSibProportions(), and setViability().

◆ _viability

double TTDeletMutBitstrSH::_viability[5]
private

Referenced by getViability(), and setViability().

◆ fecWithHomePatchMate

double TTDeletMutBitstrSH::fecWithHomePatchMate
private

Referenced by getBtheta().

◆ fecWithOtherPatchMate

double TTDeletMutBitstrSH::fecWithOtherPatchMate
private

Referenced by getBalpha().


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

Generated for Nemo v2.4.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR