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

StatHandler of the Wolbachia trait. More...

#include <ttwolbachia.h>

+ Inheritance diagram for TTWolbachiaSH:
+ Collaboration diagram for TTWolbachiaSH:

Public Member Functions

 TTWolbachiaSH (TProtoWolbachia *TT)
 
virtual ~TTWolbachiaSH ()
 
virtual bool setStatRecorders (string &token)
 
void setInfectionStats ()
 
double getMeanInfection (unsigned int sex)
 
double getMeanOffsprgInfection (unsigned int sex)
 
double getMeanFemaleInfection_perPatch (unsigned int patch)
 
double getMeanMaleInfection_perPatch (unsigned int patch)
 
double getMeanOffsprgFemaleInfection_perPatch (unsigned int patch)
 
double getMeanOffsprgMaleInfection_perPatch (unsigned int patch)
 
double getIcompatibleMatingFreq ()
 
double getDemicInfectionVar ()
 
double getDemicExtinctionRate ()
 
- Public Member Functions inherited from TraitStatHandler< TProtoWolbachia, TTWolbachiaSH >
 TraitStatHandler (TProtoWolbachia *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

TProtoWolbachia_trait
 
int _TTidx
 
double _Fmean
 
double _Mmean
 
double _var
 
double _extrate
 

Additional Inherited Members

- Protected Types inherited from StatHandler< SH >
typedef std::list< StatRecorder< SH > * >::iterator REC_IT
 
- Protected Attributes inherited from TraitStatHandler< TProtoWolbachia, TTWolbachiaSH >
TProtoWolbachia_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

StatHandler of the Wolbachia trait.

Constructor & Destructor Documentation

◆ TTWolbachiaSH()

TTWolbachiaSH::TTWolbachiaSH ( TProtoWolbachia TT)
inline
179  _trait(TT), _TTidx(TT->get_index()), _Fmean(0), _Mmean(0), _var(0), _extrate(0) {}
double _Mmean
Definition: ttwolbachia.h:174
int _TTidx
Definition: ttwolbachia.h:173
double _extrate
Definition: ttwolbachia.h:174
double _Fmean
Definition: ttwolbachia.h:174
double _var
Definition: ttwolbachia.h:174
TProtoWolbachia * _trait
Definition: ttwolbachia.h:172
virtual int get_index()
Index getter.
Definition: ttrait.h:151

◆ ~TTWolbachiaSH()

virtual TTWolbachiaSH::~TTWolbachiaSH ( )
inlinevirtual
181 { }

Member Function Documentation

◆ getDemicExtinctionRate()

double TTWolbachiaSH::getDemicExtinctionRate ( )
inline
194 {return _extrate;}

References _extrate.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getDemicInfectionVar()

double TTWolbachiaSH::getDemicInfectionVar ( )
inline
193 {return _var;}

References _var.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getIcompatibleMatingFreq()

double TTWolbachiaSH::getIcompatibleMatingFreq ( )
181 {
182 // double sum = 0;
183 // Patch* crnt_patch;
184 //
185 // for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
186 // crnt_patch = _pop->getPatch(i);
187 // for(unsigned int j = 0; j < crnt_patch->size(FEM, ADLTx);++j)
188 // sum += crnt_patch->get(FEM, ADLTx, j)->getFecundity();
189 // }
190 // return (double)Patch::DeadOffsprgs/sum;
191  return nanf("NULL");
192 }

◆ getMeanFemaleInfection_perPatch()

double TTWolbachiaSH::getMeanFemaleInfection_perPatch ( unsigned int  patch)
131 {
132  double indNbr = 0, mean = 0;
133  Patch* crnt_patch = _pop->getPatch(i);
134 
135  indNbr = crnt_patch->size(FEM, ADLTx);
136  for(unsigned int j = 0; j < indNbr; ++j)
137  mean += (double)*(bool*)crnt_patch->get(FEM, ADLTx, j)->getTraitValue(_TTidx);
138 
139  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
140 }
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:270
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:256
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:431
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:497
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:533
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:60
@ FEM
Definition: types.h:36
@ ADLTx
Definition: types.h:41

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

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getMeanInfection()

double TTWolbachiaSH::getMeanInfection ( unsigned int  sex)
inline
186 {return ((bool)sex ? _Fmean : _Mmean);}

References _Fmean, and _Mmean.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getMeanMaleInfection_perPatch()

double TTWolbachiaSH::getMeanMaleInfection_perPatch ( unsigned int  patch)
143 {
144  double indNbr = 0, mean = 0;
145  Patch* crnt_patch = _pop->getPatch(i);
146 
147  indNbr = crnt_patch->size(MAL, ADLTx);
148  for(unsigned int j = 0; j < indNbr; ++j)
149  mean += (double)*(bool*)crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_TTidx);
150 
151  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
152 }
@ MAL
Definition: types.h:36

References StatHandlerBase::_pop, _TTidx, ADLTx, Patch::get(), Metapop::getPatch(), Individual::getTraitValue(), MAL, and Patch::size().

◆ getMeanOffsprgFemaleInfection_perPatch()

double TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch ( unsigned int  patch)
155 {
156  double indNbr = 0, mean = 0;
157  Patch* crnt_patch = _pop->getPatch(i);
158 
159  indNbr = crnt_patch->size(FEM, OFFSx);
160 
161  for(unsigned int j = 0; j < indNbr; ++j)
162  mean += (double)*(bool*)crnt_patch->get(FEM, OFFSx, j)->getTraitValue(_TTidx);
163 
164  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
165 }
@ OFFSx
Definition: types.h:41

References StatHandlerBase::_pop, _TTidx, FEM, Patch::get(), Metapop::getPatch(), Individual::getTraitValue(), OFFSx, and Patch::size().

◆ getMeanOffsprgInfection()

double TTWolbachiaSH::getMeanOffsprgInfection ( unsigned int  sex)
105 {
106  unsigned int i,j;
107  double indNbr = 0, mean = 0;
108  Patch* crnt_patch;
109 
110 
111  if(sex) {//females:
112  for(i = 0; i < _pop->getPatchNbr(); ++i) {
113  crnt_patch = _pop->getPatch(i);
114  for(j = 0; j < crnt_patch->size(FEM, OFFSx); ++j)
115  mean += (double)*(bool*)crnt_patch->get(FEM, OFFSx, j)->getTraitValue(_TTidx);
116  }
117  indNbr = _pop->size(FEM, OFFSPRG);
118  } else { //males
119  for(i = 0; i < _pop->getPatchNbr(); ++i) {
120  crnt_patch = _pop->getPatch(i);
121  for(j = 0; j < crnt_patch->size(MAL, OFFSx); ++j)
122  mean += (double)*(bool*)crnt_patch->get(MAL, OFFSx, j)->getTraitValue(_TTidx);
123  }
124  indNbr = _pop->size(MAL, OFFSPRG);
125  }
126 
127  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
128 }
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:311
unsigned int getPatchNbr()
Definition: metapop.h:275
#define OFFSPRG
Offspring age class flag.
Definition: types.h:49

References StatHandlerBase::_pop, _TTidx, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), MAL, OFFSPRG, OFFSx, Metapop::size(), and Patch::size().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getMeanOffsprgMaleInfection_perPatch()

double TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch ( unsigned int  patch)
168 {
169  double indNbr = 0, mean = 0;
170  Patch* crnt_patch = _pop->getPatch(i);
171 
172  indNbr = crnt_patch->size(MAL, OFFSx);
173 
174  for(unsigned int j = 0; j < indNbr; ++j)
175  mean += (double)*(bool*)crnt_patch->get(MAL, OFFSx, j)->getTraitValue(_TTidx);
176 
177  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
178 }

References StatHandlerBase::_pop, _TTidx, Patch::get(), Metapop::getPatch(), Individual::getTraitValue(), MAL, OFFSx, and Patch::size().

◆ setInfectionStats()

void TTWolbachiaSH::setInfectionStats ( )
35 {
36  double Fsize = 0, Msize = 0, val, local_inf;
37  double *all;
38  Patch* crnt_patch;
39 
40  Fsize = _pop->size(FEM, ADULTS);
41  Msize = _pop->size(MAL, ADULTS);
42 
43  if( Fsize != 0 )
44  all = new double [ _pop->getPatchNbr() ];
45  else {
46  _Fmean = nanf("NULL");
47  _Mmean = nanf("NULL");
48  _extrate = nanf("NULL");
49  _var = nanf("NULL");
50  return;
51  }
52 
53  _Fmean = _Mmean = 0;
54  _extrate = 0;
55 
56  //females:
57  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
58  crnt_patch = _pop->getPatch(i);
59  local_inf = 0;
60  all[i] = 0;
61  unsigned int fsize = crnt_patch->size(FEM, ADLTx);
62  for(unsigned int j = 0; j < fsize; ++j) {
63  val = (double)*(bool*)(crnt_patch->get(FEM, ADLTx, j)->getTraitValue(_TTidx));
64  local_inf += val;
65  }
66 
67  if(local_inf != 0) {
68  all[i] = local_inf / fsize;
69  _Fmean += all[i];
70  } else _extrate++;
71 
72  }
73 
74  _Fmean = (Fsize != 0 ? _Fmean / (_pop->getPatchNbr() - _extrate) : nanf("NULL"));
75 
77 
78  _var = 0;
79  double local_mean = 0;
80 
81  for (unsigned int i = 0; i < _pop->getPatchNbr(); i++)
82  local_mean += all[i];
83 
84  local_mean /= _pop->getPatchNbr();
85 
86  //hacked from the GSL:
87  for (unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
88  const long double delta = (all[i] - local_mean);
89  _var += (delta * delta - _var) / (i + 1);
90  }
91 
92  //males
93  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
94  crnt_patch = _pop->getPatch(i);
95  for(unsigned int j = 0, msize = crnt_patch->size(MAL, ADLTx); j < msize; ++j)
96  _Mmean += (double)*(bool*)(crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_TTidx));
97  }
98 
99  _Mmean = (Msize != 0 ? _Mmean / Msize : nanf("NULL"));
100 
101  delete [] all;
102 }
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:53

References _extrate, _Fmean, _Mmean, StatHandlerBase::_pop, _TTidx, _var, ADLTx, ADULTS, FEM, Patch::get(), Metapop::getPatch(), Metapop::getPatchNbr(), Individual::getTraitValue(), MAL, Metapop::size(), and Patch::size().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ setStatRecorders()

bool TTWolbachiaSH::setStatRecorders ( string &  token)
virtual

Implements StatHandlerBase.

114 {
115 // cout << "TTWolbachiaSH::setStatRecorders("<<token<<")\n";
116 
117  if(token == "wolbachia") {
118 
119  add("Wolbachia female infection (offsprng)","off.fwoinf",OFFSPRG,1,0,0,&TTWolbachiaSH::getMeanOffsprgInfection,0,0);
120  add("Wolbachia male infection (offsprng)","off.mwoinf",OFFSPRG,0,0,0,&TTWolbachiaSH::getMeanOffsprgInfection,0,0);
121  // add("Wolbachia incompatible mating freq ","off.incmating",OFFSPRG,0,&TTWolbachiaSH::getIcompatibleMatingFreq,0,0,0);
122  add("Wolbachia female infection (adults) ","adlt.fwoinf",ADULTS,1,0,0,&TTWolbachiaSH::getMeanInfection,0,&TTWolbachiaSH::setInfectionStats);
123  add("Wolbachia male infection (adults) ","adlt.mwoinf",ADULTS,0,0,0,&TTWolbachiaSH::getMeanInfection,0,0);
124  add("Wolbachia demic infection variance ","wolb.infvar",ADULTS,0,0,&TTWolbachiaSH::getDemicInfectionVar,0,0,0);
125  add("Wolbachia demic extinction rate ","wolb.extrate",ADULTS,0,0,&TTWolbachiaSH::getDemicExtinctionRate,0,0,0);
126 
127  } else if(token == "wolbachia_perpatch") {
128 
129  ostringstream name, sub_name;
130 
131  // for(unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
132  // _name<<"Wolbachia fem infctn: patch "<<i+1;
133  // sub_name<<"off.p"<<i+1<<"fwoinf";
134  // add(_name.str(),sub_name.str(),OFFSPRG,i,0,0,&TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch,0);
135  // _name.str("");
136  // _name<<"Wolbachia mal infctn: patch "<<i+1;
137  // sub_name.str("");
138  // sub_name<<"off.p"<<i+1<<"mwoinf";
139  // add(_name.str(),sub_name.str(),OFFSPRG,i,0,0,&TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch,0);
140  // sub_name.str("");
141  // _name.str("");
142  // }
143 
144  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
145  name<<"Patch "<<i+1;
146  sub_name<<"adlt.p"<<i+1<<"fwoinf";
147  add(name.str(),sub_name.str(),ADULTS,i,0,0,&TTWolbachiaSH::getMeanFemaleInfection_perPatch,0,0);
148  // sub_name.str("");
149  // sub_name<<"adlt.p"<<i+1<<"mwoinf";
150  // add(_name.str(),sub_name.str(),ADULTS,i,0,0,&TTWolbachiaSH::getMeanMaleInfection_perPatch,0);
151  sub_name.str("");
152  name.str("");
153  }
154 
155  }else
156  return false;
157 
158  return true;
159 }
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:143
double getDemicExtinctionRate()
Definition: ttwolbachia.h:194
double getDemicInfectionVar()
Definition: ttwolbachia.h:193
double getMeanInfection(unsigned int sex)
Definition: ttwolbachia.h:186
double getMeanFemaleInfection_perPatch(unsigned int patch)
Definition: stats_wolbachia.cc:130
double getMeanOffsprgInfection(unsigned int sex)
Definition: stats_wolbachia.cc:104
void setInfectionStats()
Definition: stats_wolbachia.cc:34

References StatHandlerBase::_pop, StatHandler< SH >::add(), ADULTS, getDemicExtinctionRate(), getDemicInfectionVar(), getMeanFemaleInfection_perPatch(), getMeanInfection(), getMeanOffsprgInfection(), Metapop::getPatchNbr(), OFFSPRG, and setInfectionStats().

Member Data Documentation

◆ _extrate

double TTWolbachiaSH::_extrate
private

◆ _Fmean

double TTWolbachiaSH::_Fmean
private

◆ _Mmean

double TTWolbachiaSH::_Mmean
private

◆ _trait

TProtoWolbachia* TTWolbachiaSH::_trait
private

◆ _TTidx

◆ _var

double TTWolbachiaSH::_var
private

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

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

Locations of visitors to this page
Catalogued on GSR