Nemo  2.3.56
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 void init ()=0
 Inits state. More...
 
virtual void update ()=0
 Updates the handler state. More...
 
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
166 _trait(TT), _TTidx(TT->get_index()), _Fmean(0), _Mmean(0), _var(0), _extrate(0) {}
double _Mmean
Definition: ttwolbachia.h:161
int _TTidx
Definition: ttwolbachia.h:160
double _extrate
Definition: ttwolbachia.h:161
double _Fmean
Definition: ttwolbachia.h:161
double _var
Definition: ttwolbachia.h:161
TProtoWolbachia * _trait
Definition: ttwolbachia.h:159
virtual int get_index()
Index getter.
Definition: ttrait.h:146
Template class for the trait's StatHandler.
Definition: stathandler.h:168

◆ ~TTWolbachiaSH()

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

Member Function Documentation

◆ getDemicExtinctionRate()

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

References _extrate.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getDemicInfectionVar()

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

References _var.

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ getIcompatibleMatingFreq()

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}

◆ getMeanFemaleInfection_perPatch()

double TTWolbachiaSH::getMeanFemaleInfection_perPatch ( unsigned int  patch)
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
Patch * getPatch(unsigned int i)
Patch accessor, return the ith+1 patch in the metapop.
Definition: metapop.h:257
Second class in the metapopulation design structure, between the Metapop and Individual classes.
Definition: metapop.h:430
unsigned int size(age_t AGE)
Returns the size of the container of the appropriate age class(es) for both sexes.
Definition: metapop.h:496
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:532
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
@ FEM
Definition: types.h:37
@ ADLTx
Definition: types.h:42

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
173{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)
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}
@ MAL
Definition: types.h:37

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

◆ getMeanOffsprgFemaleInfection_perPatch()

double TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch ( unsigned int  patch)
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}
@ OFFSx
Definition: types.h:42

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

◆ getMeanOffsprgInfection()

double TTWolbachiaSH::getMeanOffsprgInfection ( unsigned int  sex)
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}
unsigned int size()
Get the total number of individuals present in the population, all sex and age classes together.
Definition: metapop.h:310
unsigned int getPatchNbr()
Definition: metapop.h:276
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

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

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

◆ setInfectionStats()

void TTWolbachiaSH::setInfectionStats ( )
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}
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54

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.

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}
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
double getDemicExtinctionRate()
Definition: ttwolbachia.h:181
double getDemicInfectionVar()
Definition: ttwolbachia.h:180
double getMeanInfection(unsigned int sex)
Definition: ttwolbachia.h:173
double getMeanFemaleInfection_perPatch(unsigned int patch)
Definition: stats_wolbachia.cc:131
double getMeanOffsprgInfection(unsigned int sex)
Definition: stats_wolbachia.cc:105
void setInfectionStats()
Definition: stats_wolbachia.cc:35

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.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR