Nemo  2.3.46
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< TTWolbachiaSH >
 StatHandler ()
 
virtual ~StatHandler ()
 
virtual void clear ()
 Empties the _recorders list, they are destroyed in StatHandlerBase::reset(). More...
 
virtual StatRecorder
< TTWolbachiaSH > * 
add (std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(TTWolbachiaSH::*getStatNoArg)(void), double(TTWolbachiaSH::*getStatOneArg)(unsigned int), double(TTWolbachiaSH::*getStatTwoArg)(unsigned int, unsigned int), void(TTWolbachiaSH::*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...
 
virtual bool setStatRecorders (std::string &token)=0
 
- 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< TTWolbachiaSH >
typedef std::list
< StatRecorder< TTWolbachiaSH >
* >::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< TTWolbachiaSH >
std::list< StatRecorder
< TTWolbachiaSH > * > 
_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 ( TProtoWolbachia TT)
inline
164  _trait(TT), _TTidx(TT->get_index()), _Fmean(0), _Mmean(0), _var(0), _extrate(0) {}
double _Mmean
Definition: ttwolbachia.h:159
virtual int get_index()
Index getter.
Definition: ttrait.h:146
double _extrate
Definition: ttwolbachia.h:159
TProtoWolbachia * _trait
Definition: ttwolbachia.h:157
int _TTidx
Definition: ttwolbachia.h:158
double _var
Definition: ttwolbachia.h:159
double _Fmean
Definition: ttwolbachia.h:159
virtual TTWolbachiaSH::~TTWolbachiaSH ( )
inlinevirtual
166 { }

Member Function Documentation

double TTWolbachiaSH::getDemicExtinctionRate ( )
inline

References _extrate.

Referenced by setStatRecorders().

179 {return _extrate;}
double _extrate
Definition: ttwolbachia.h:159
double TTWolbachiaSH::getDemicInfectionVar ( )
inline

References _var.

Referenced by setStatRecorders().

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

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

Referenced by setStatRecorders().

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

Referenced by setStatRecorders().

171 {return ((bool)sex ? _Fmean : _Mmean);}
double _Mmean
Definition: ttwolbachia.h:159
double _Fmean
Definition: ttwolbachia.h:159
double TTWolbachiaSH::getMeanMaleInfection_perPatch ( unsigned int  patch)

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

144 {
145  double indNbr = 0, mean = 0;
146  Patch* crnt_patch = _pop->getPatch(i);
147 
148  indNbr = crnt_patch->size(MAL, ADLTx);
149  for(unsigned int j = 0; j < indNbr; ++j)
150  mean += (double)*(bool*)crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_TTidx);
151 
152  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
153 }
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
Definition: types.h:42
int _TTidx
Definition: ttwolbachia.h:158
Definition: types.h:37
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
double TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch ( unsigned int  patch)

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

156 {
157  double indNbr = 0, mean = 0;
158  Patch* crnt_patch = _pop->getPatch(i);
159 
160  indNbr = crnt_patch->size(FEM, OFFSx);
161 
162  for(unsigned int j = 0; j < indNbr; ++j)
163  mean += (double)*(bool*)crnt_patch->get(FEM, OFFSx, j)->getTraitValue(_TTidx);
164 
165  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
166 }
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
int _TTidx
Definition: ttwolbachia.h:158
Definition: types.h:42
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
Definition: types.h:37
double TTWolbachiaSH::getMeanOffsprgInfection ( unsigned int  sex)

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

Referenced by setStatRecorders().

106 {
107  unsigned int i,j;
108  double indNbr = 0, mean = 0;
109  Patch* crnt_patch;
110 
111 
112  if(sex) {//females:
113  for(i = 0; i < _pop->getPatchNbr(); ++i) {
114  crnt_patch = _pop->getPatch(i);
115  for(j = 0; j < crnt_patch->size(FEM, OFFSx); ++j)
116  mean += (double)*(bool*)crnt_patch->get(FEM, OFFSx, j)->getTraitValue(_TTidx);
117  }
118  indNbr = _pop->size(FEM, OFFSPRG);
119  } else { //males
120  for(i = 0; i < _pop->getPatchNbr(); ++i) {
121  crnt_patch = _pop->getPatch(i);
122  for(j = 0; j < crnt_patch->size(MAL, OFFSx); ++j)
123  mean += (double)*(bool*)crnt_patch->get(MAL, OFFSx, j)->getTraitValue(_TTidx);
124  }
125  indNbr = _pop->size(MAL, OFFSPRG);
126  }
127 
128  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
129 }
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
int _TTidx
Definition: ttwolbachia.h:158
Definition: types.h:37
Definition: types.h:42
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together...
Definition: metapop.h:302
Definition: types.h:37
double TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch ( unsigned int  patch)

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

169 {
170  double indNbr = 0, mean = 0;
171  Patch* crnt_patch = _pop->getPatch(i);
172 
173  indNbr = crnt_patch->size(MAL, OFFSx);
174 
175  for(unsigned int j = 0; j < indNbr; ++j)
176  mean += (double)*(bool*)crnt_patch->get(MAL, OFFSx, j)->getTraitValue(_TTidx);
177 
178  return (indNbr != 0 ? mean/indNbr : nanf("NULL"));
179 }
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
int _TTidx
Definition: ttwolbachia.h:158
Definition: types.h:37
Definition: types.h:42
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
void TTWolbachiaSH::setInfectionStats ( )

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

36 {
37  double Fsize = 0, Msize = 0, val, local_inf;
38  double *all;
39  Patch* crnt_patch;
40 
41  Fsize = _pop->size(FEM, ADULTS);
42  Msize = _pop->size(MAL, ADULTS);
43 
44  if( Fsize != 0 )
45  all = new double [ _pop->getPatchNbr() ];
46  else {
47  _Fmean = nanf("NULL");
48  _Mmean = nanf("NULL");
49  _extrate = nanf("NULL");
50  _var = nanf("NULL");
51  return;
52  }
53 
54  _Fmean = _Mmean = 0;
55  _extrate = 0;
56 
57  //females:
58  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
59  crnt_patch = _pop->getPatch(i);
60  local_inf = 0;
61  all[i] = 0;
62  unsigned int fsize = crnt_patch->size(FEM, ADLTx);
63  for(unsigned int j = 0; j < fsize; ++j) {
64  val = (double)*(bool*)(crnt_patch->get(FEM, ADLTx, j)->getTraitValue(_TTidx));
65  local_inf += val;
66  }
67 
68  if(local_inf != 0) {
69  all[i] = local_inf / fsize;
70  _Fmean += all[i];
71  } else _extrate++;
72 
73  }
74 
75  _Fmean = (Fsize != 0 ? _Fmean / (_pop->getPatchNbr() - _extrate) : nanf("NULL"));
76 
78 
79  _var = 0;
80  double local_mean = 0;
81 
82  for (unsigned int i = 0; i < _pop->getPatchNbr(); i++)
83  local_mean += all[i];
84 
85  local_mean /= _pop->getPatchNbr();
86 
87  //hacked from the GSL:
88  for (unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
89  const long double delta = (all[i] - local_mean);
90  _var += (delta * delta - _var) / (i + 1);
91  }
92 
93  //males
94  for(unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
95  crnt_patch = _pop->getPatch(i);
96  for(unsigned int j = 0, msize = crnt_patch->size(MAL, ADLTx); j < msize; ++j)
97  _Mmean += (double)*(bool*)(crnt_patch->get(MAL, ADLTx, j)->getTraitValue(_TTidx));
98  }
99 
100  _Mmean = (Msize != 0 ? _Mmean / Msize : nanf("NULL"));
101 
102  delete [] all;
103 }
double _Mmean
Definition: ttwolbachia.h:159
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
void * getTraitValue(IDX T)
Accessor to the value (phenotype) of a particular trait.
Definition: individual.h:271
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:487
Second class in the metapopulation design structure, between the Metapop and Individual classes...
Definition: metapop.h:421
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:251
unsigned int getPatchNbr()
Definition: metapop.h:270
double _extrate
Definition: ttwolbachia.h:159
Definition: types.h:42
int _TTidx
Definition: ttwolbachia.h:158
Definition: types.h:37
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:523
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
double _var
Definition: ttwolbachia.h:159
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together...
Definition: metapop.h:302
double _Fmean
Definition: ttwolbachia.h:159
Definition: types.h:37
bool TTWolbachiaSH::setStatRecorders ( string &  token)
virtual

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

115 {
116 // cout << "TTWolbachiaSH::setStatRecorders("<<token<<")\n";
117 
118  if(token == "wolbachia") {
119 
120  add("Wolbachia female infection (offsprng)","off.fwoinf",OFFSPRG,1,0,0,&TTWolbachiaSH::getMeanOffsprgInfection,0,0);
121  add("Wolbachia male infection (offsprng)","off.mwoinf",OFFSPRG,0,0,0,&TTWolbachiaSH::getMeanOffsprgInfection,0,0);
122  // add("Wolbachia incompatible mating freq ","off.incmating",OFFSPRG,0,&TTWolbachiaSH::getIcompatibleMatingFreq,0,0,0);
123  add("Wolbachia female infection (adults) ","adlt.fwoinf",ADULTS,1,0,0,&TTWolbachiaSH::getMeanInfection,0,&TTWolbachiaSH::setInfectionStats);
124  add("Wolbachia male infection (adults) ","adlt.mwoinf",ADULTS,0,0,0,&TTWolbachiaSH::getMeanInfection,0,0);
125  add("Wolbachia demic infection variance ","wolb.infvar",ADULTS,0,0,&TTWolbachiaSH::getDemicInfectionVar,0,0,0);
126  add("Wolbachia demic extinction rate ","wolb.extrate",ADULTS,0,0,&TTWolbachiaSH::getDemicExtinctionRate,0,0,0);
127 
128  } else if(token == "wolbachia_perpatch") {
129 
130  ostringstream name, sub_name;
131 
132  // for(unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
133  // _name<<"Wolbachia fem infctn: patch "<<i+1;
134  // sub_name<<"off.p"<<i+1<<"fwoinf";
135  // add(_name.str(),sub_name.str(),OFFSPRG,i,0,0,&TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch,0);
136  // _name.str("");
137  // _name<<"Wolbachia mal infctn: patch "<<i+1;
138  // sub_name.str("");
139  // sub_name<<"off.p"<<i+1<<"mwoinf";
140  // add(_name.str(),sub_name.str(),OFFSPRG,i,0,0,&TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch,0);
141  // sub_name.str("");
142  // _name.str("");
143  // }
144 
145  for(unsigned int i = 0; i < _pop->getPatchNbr(); i++) {
146  name<<"Patch "<<i+1;
147  sub_name<<"adlt.p"<<i+1<<"fwoinf";
148  add(name.str(),sub_name.str(),ADULTS,i,0,0,&TTWolbachiaSH::getMeanFemaleInfection_perPatch,0,0);
149  // sub_name.str("");
150  // sub_name<<"adlt.p"<<i+1<<"mwoinf";
151  // add(_name.str(),sub_name.str(),ADULTS,i,0,0,&TTWolbachiaSH::getMeanMaleInfection_perPatch,0);
152  sub_name.str("");
153  name.str("");
154  }
155 
156  }else
157  return false;
158 
159  return true;
160 }
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54
void setInfectionStats()
Definition: stats_wolbachia.cc:35
double getMeanOffsprgInfection(unsigned int sex)
Definition: stats_wolbachia.cc:105
double getDemicExtinctionRate()
Definition: ttwolbachia.h:179
double getMeanFemaleInfection_perPatch(unsigned int patch)
Definition: stats_wolbachia.cc:131
unsigned int getPatchNbr()
Definition: metapop.h:270
double getMeanInfection(unsigned int sex)
Definition: ttwolbachia.h:171
virtual StatRecorder< TTWolbachiaSH > * add(std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(TTWolbachiaSH::*getStatNoArg)(void), double(TTWolbachiaSH::*getStatOneArg)(unsigned int), double(TTWolbachiaSH::*getStatTwoArg)(unsigned int, unsigned int), void(TTWolbachiaSH::*setStat)(void))
Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list.
Definition: stathandler.h:144
double getDemicInfectionVar()
Definition: ttwolbachia.h:178
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

Member Data Documentation

double TTWolbachiaSH::_extrate
private
double TTWolbachiaSH::_Fmean
private

Referenced by setInfectionStats().

double TTWolbachiaSH::_Mmean
private

Referenced by setInfectionStats().

TProtoWolbachia* TTWolbachiaSH::_trait
private
double TTWolbachiaSH::_var
private

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

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