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

StatHandler for the DBMI trait. More...

#include <ttbdmi.h>

+ Inheritance diagram for TTBDMI_SH:
+ Collaboration diagram for TTBDMI_SH:

Public Member Functions

 TTBDMI_SH (TProtoBDMI *TP)
 
virtual ~TTBDMI_SH ()
 
virtual bool setStatRecorders (std::string &token)
 
void addStats (age_t AGE)
 
void setAdultStats ()
 
void setOffsprgStats ()
 
void setStats (age_idx agex, void(TTBDMI_SH::*cntFunc)(Patch *, sex_t, age_idx, double **, double **))
 
void countAllele_haplo (Patch *patch, sex_t SEX, age_idx AGE, double **frqTab, double **icpTab)
 
void countAllele_diplo (Patch *patch, sex_t SEX, age_idx AGE, double **frqTab, double **icpTab)
 
double getFreq ()
 
double getFreqIcmp ()
 
double getPatchFreq (unsigned int i)
 
double getPatchIcmp (unsigned int i)
 
- Public Member Functions inherited from TraitStatHandler< TProtoBDMI, TTBDMI_SH >
 TraitStatHandler (TProtoBDMI *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

double _freq
 
double _freqIcomp
 
double * _patchFreq
 
double * _patchIcmp
 

Additional Inherited Members

- Protected Types inherited from StatHandler< SH >
typedef std::list< StatRecorder< SH > * >::iterator REC_IT
 
- Protected Attributes inherited from TraitStatHandler< TProtoBDMI, TTBDMI_SH >
TProtoBDMI_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 for the DBMI trait.

Records the average allele frequencies at all loci, and the frequencies of incompatibilities (i.e. double heterozygotes).

Constructor & Destructor Documentation

◆ TTBDMI_SH()

TTBDMI_SH::TTBDMI_SH ( TProtoBDMI TP)
inline
273 _patchFreq(0), _patchIcmp(0) {}
double * _patchFreq
Definition: ttbdmi.h:269
double * _patchIcmp
Definition: ttbdmi.h:269

◆ ~TTBDMI_SH()

virtual TTBDMI_SH::~TTBDMI_SH ( )
inlinevirtual
275{if(_patchFreq)delete[]_patchFreq;if(_patchIcmp)delete[]_patchIcmp;}

References _patchFreq, and _patchIcmp.

Member Function Documentation

◆ addStats()

void TTBDMI_SH::addStats ( age_t  AGE)
708{
709 string prefix = (AGE == ADULTS ? "adlt." : "off.");
710 ostringstream name;
711 void (TTBDMI_SH::* setter) () = (AGE == ADULTS ?
714
715 add("", prefix + "dmi.freq", AGE, 0, 0, &TTBDMI_SH::getFreq, 0, 0, setter);
716 add("", prefix + "dmi.icmp", AGE, 0, 0, &TTBDMI_SH::getFreqIcmp, 0, 0, 0);
717 for (unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
718 name << prefix << "dmi.p" << i+1;
719 add("", name.str(), AGE, i, 0, 0, &TTBDMI_SH::getPatchFreq, 0, 0);
720 name.str(""); //reset the string
721 }
722 for (unsigned int i = 0; i < _pop->getPatchNbr(); ++i) {
723 name << prefix << "icmp.p" << i+1;
724 add("", name.str(), AGE, i, 0, 0, &TTBDMI_SH::getPatchIcmp, 0, 0);
725 name.str("");
726 }
727
728}
unsigned int getPatchNbr()
Definition: metapop.h:276
Metapop * _pop
Link to the current population, set through the link to the StatService.
Definition: stathandler.h:61
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
StatHandler for the DBMI trait.
Definition: ttbdmi.h:266
double getPatchIcmp(unsigned int i)
Definition: ttbdmi.h:288
void setAdultStats()
Definition: ttbdmi.cc:732
void setOffsprgStats()
Definition: ttbdmi.cc:740
double getFreqIcmp()
Definition: ttbdmi.h:286
double getFreq()
Definition: ttbdmi.h:285
double getPatchFreq(unsigned int i)
Definition: ttbdmi.h:287
#define ADULTS
Adults age class flag (breeders).
Definition: types.h:54

References StatHandlerBase::_pop, StatHandler< SH >::add(), ADULTS, getFreq(), getFreqIcmp(), getPatchFreq(), getPatchIcmp(), Metapop::getPatchNbr(), setAdultStats(), and setOffsprgStats().

Referenced by setStatRecorders().

+ Here is the caller graph for this function:

◆ countAllele_diplo()

void TTBDMI_SH::countAllele_diplo ( Patch patch,
sex_t  SEX,
age_idx  AGE,
double **  frqTab,
double **  icpTab 
)
871{
872 TT_BDMI* trait;
873 unsigned int l, a1, a2, num_pair = _SHLinkedTrait->get_nb_locus()/2;
874
875 for(unsigned int j = 0; j < patch->size(SEX, AGE); ++j) {
876
877 trait = dynamic_cast< TT_BDMI* > ( patch->get( SEX, AGE, j )->getTrait( _SHLinkedTraitIndex ) );
878
879 l = 0;
880 for(unsigned int k = 0; k < num_pair; ++k) {
881
882 a1 = trait->get_num_mut_diplo(l);
883 frqTab[patch->getID()][l++] += a1;
884
885 a2 = trait->get_num_mut_diplo(l);
886 frqTab[patch->getID()][l++] += a2;
887
888 icpTab[patch->getID()][k] += ((a1 == 1) && (a2 == 1));
889 }
890 }
891}
TTrait * getTrait(IDX T)
Trait accessor.
Definition: individual.h:277
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
unsigned int getID()
Definition: metapop.h:478
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
int get_nb_locus()
Definition: ttbdmi.h:77
Definition: ttbdmi.h:134
unsigned int get_num_mut_diplo(unsigned int loc)
Definition: ttbdmi.h:205
int _SHLinkedTraitIndex
Index of the trait in the Individual::Traits table.
Definition: stathandler.h:173
TProtoBDMI * _SHLinkedTrait
Pointer to a TraitProtoype object.
Definition: stathandler.h:171

References TraitStatHandler< TProtoBDMI, TTBDMI_SH >::_SHLinkedTrait, TraitStatHandler< TProtoBDMI, TTBDMI_SH >::_SHLinkedTraitIndex, Patch::get(), TProtoBDMI::get_nb_locus(), TT_BDMI::get_num_mut_diplo(), Patch::getID(), Individual::getTrait(), and Patch::size().

Referenced by setAdultStats(), and setOffsprgStats().

+ Here is the caller graph for this function:

◆ countAllele_haplo()

void TTBDMI_SH::countAllele_haplo ( Patch patch,
sex_t  SEX,
age_idx  AGE,
double **  frqTab,
double **  icpTab 
)
846{
847 TT_BDMI* trait;
848 unsigned int l, a1, a2, num_pair = _SHLinkedTrait->get_nb_locus()/2;
849
850 for(unsigned int j = 0; j < patch->size(SEX, AGE); ++j) {
851
852 trait = dynamic_cast< TT_BDMI* > ( patch->get( SEX, AGE, j )->getTrait( _SHLinkedTraitIndex ) );
853
854 l = 0;
855 for(unsigned int k = 0; k < num_pair; ++k) {
856
857 a1 = trait->get_num_mut_haplo(l);
858 frqTab[patch->getID()][l++] += a1;
859
860 a2 = trait->get_num_mut_haplo(l);
861 frqTab[patch->getID()][l++] += a2;
862
863 icpTab[patch->getID()][k] += a1 ^ a2;
864 }
865 }
866}
unsigned int get_num_mut_haplo(unsigned int loc)
Definition: ttbdmi.h:204

References TraitStatHandler< TProtoBDMI, TTBDMI_SH >::_SHLinkedTrait, TraitStatHandler< TProtoBDMI, TTBDMI_SH >::_SHLinkedTraitIndex, Patch::get(), TProtoBDMI::get_nb_locus(), TT_BDMI::get_num_mut_haplo(), Patch::getID(), Individual::getTrait(), and Patch::size().

Referenced by setAdultStats(), and setOffsprgStats().

+ Here is the caller graph for this function:

◆ getFreq()

double TTBDMI_SH::getFreq ( )
inline
285{return _freq;}
double _freq
Definition: ttbdmi.h:268

References _freq.

Referenced by addStats().

+ Here is the caller graph for this function:

◆ getFreqIcmp()

double TTBDMI_SH::getFreqIcmp ( )
inline
286{return _freqIcomp;}
double _freqIcomp
Definition: ttbdmi.h:268

References _freqIcomp.

Referenced by addStats().

+ Here is the caller graph for this function:

◆ getPatchFreq()

double TTBDMI_SH::getPatchFreq ( unsigned int  i)
inline
287{return _patchFreq[i];}

References _patchFreq.

Referenced by addStats().

+ Here is the caller graph for this function:

◆ getPatchIcmp()

double TTBDMI_SH::getPatchIcmp ( unsigned int  i)
inline
288{return _patchIcmp[i];}

References _patchIcmp.

Referenced by addStats().

+ Here is the caller graph for this function:

◆ setAdultStats()

void TTBDMI_SH::setAdultStats ( )
733{
736}
bool isHaploid()
Definition: ttbdmi.h:79
void countAllele_haplo(Patch *patch, sex_t SEX, age_idx AGE, double **frqTab, double **icpTab)
Definition: ttbdmi.cc:845
void setStats(age_idx agex, void(TTBDMI_SH::*cntFunc)(Patch *, sex_t, age_idx, double **, double **))
Definition: ttbdmi.cc:748
void countAllele_diplo(Patch *patch, sex_t SEX, age_idx AGE, double **frqTab, double **icpTab)
Definition: ttbdmi.cc:870
@ ADLTx
Definition: types.h:42

References TraitStatHandler< TProtoBDMI, TTBDMI_SH >::_SHLinkedTrait, ADLTx, countAllele_diplo(), countAllele_haplo(), TProtoBDMI::isHaploid(), and setStats().

Referenced by addStats().

+ Here is the caller graph for this function:

◆ setOffsprgStats()

void TTBDMI_SH::setOffsprgStats ( )

◆ setStatRecorders()

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

Implements StatHandlerBase.

682{
683#ifdef _DEBUG_
684 message("-TTBDMI_SH::setStatRecorders ");
685#endif
686 if(token == "dmi") {
687
690
691 } else if(token == "off.dmi") {
692
694
695 } else if(token == "adlt.dmi") {
696
698
699 } else
700 return false;
701
702 return true;
703}
void addStats(age_t AGE)
Definition: ttbdmi.cc:707
void message(const char *message,...)
Definition: output.cc:40
#define OFFSPRG
Offspring age class flag.
Definition: types.h:50

References addStats(), ADULTS, message(), and OFFSPRG.

◆ setStats()

void TTBDMI_SH::setStats ( age_idx  agex,
void(TTBDMI_SH::*)(Patch *, sex_t, age_idx, double **, double **)  cntFunc 
)
749{
750 unsigned int i, nb_ind = 0, nb_patch = 0;
751 unsigned int nb_locus = _SHLinkedTrait->get_nb_locus();
752 unsigned int num_pair;
753 unsigned int psize=0;
754 unsigned int npatch=_pop->getPatchNbr();
755
756 Patch* current_patch;
757
758 num_pair = nb_locus/2;
759
760 double* freqTable = new double [nb_locus];
761 double* icmpTable = new double [num_pair];
762 double** patchFreqTable = new double* [npatch];
763 double** patchIcmpTable = new double* [npatch];
764
765 for(i = 0; i < nb_locus; ++i)
766 freqTable[i] = 0;
767
768 for(i = 0; i < num_pair; ++i)
769 icmpTable[i] = 0;
770
771 //init patch tables:
772 if(_patchFreq) delete [] _patchFreq;
773 _patchFreq = new double [npatch];
774
775 if(_patchIcmp) delete [] _patchIcmp;
776 _patchIcmp = new double [npatch];
777
778 //patch loop:
779 for(i = 0; i < npatch; ++i) {
780
781 current_patch = _pop->getPatch(i);
782
783 patchFreqTable[i] = new double [nb_locus];
784 for(unsigned int j = 0; j < nb_locus; ++j) patchFreqTable[i][j] = 0;
785
786 patchIcmpTable[i] = new double [num_pair];
787 for(unsigned int j = 0; j < num_pair; ++j) patchIcmpTable[i][j] = 0;
788
789 _patchFreq[i] = 0;
790 _patchIcmp[i] = 0;
791
792 if( (psize = current_patch->size(agex)) == 0) continue;
793
794 nb_patch++;
795
796 nb_ind += psize;
797
798 (this->* cntFunc) (current_patch, FEM, agex, patchFreqTable, patchIcmpTable);
799 (this->* cntFunc) (current_patch, MAL, agex, patchFreqTable, patchIcmpTable);
800
801 //mut frequ.
802 for(unsigned int k = 0; k < nb_locus; ++k)
803 _patchFreq[i] += patchFreqTable[i][k]/psize;
804
805 if(_SHLinkedTrait->isHaploid()) _patchFreq[i] /= nb_locus;
806 else _patchFreq[i] /= 2*nb_locus;
807
808 //incompatibilities:
809 for(unsigned int k = 0; k < num_pair; ++k)
810 _patchIcmp[i] += patchIcmpTable[i][k]/psize;
811
812 _patchIcmp[i] /= num_pair;
813
814
815 }//end for Patch
816
817 //set pop means
818 //mut frequ:
819 _freq = 0;
820
821 for(i = 0; i < npatch; ++i) _freq += _patchFreq[i];
822
823 _freq /= npatch;
824
825 //Incompatibilities:
826 _freqIcomp = 0;
827
828 for(i = 0; i < npatch; ++i) _freqIcomp += _patchIcmp[i];
829
830 _freqIcomp /= npatch;
831
832
833 delete [] freqTable;
834 delete [] icmpTable;
835 for(i = 0; i < npatch; ++i) {
836 delete [] patchFreqTable[i];
837 delete [] patchIcmpTable[i];
838 }
839 delete [] patchFreqTable;
840 delete [] patchIcmpTable;
841}
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
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37

References _freq, _freqIcomp, _patchFreq, _patchIcmp, StatHandlerBase::_pop, TraitStatHandler< TProtoBDMI, TTBDMI_SH >::_SHLinkedTrait, FEM, TProtoBDMI::get_nb_locus(), Metapop::getPatch(), Metapop::getPatchNbr(), TProtoBDMI::isHaploid(), MAL, and Patch::size().

Referenced by setAdultStats(), and setOffsprgStats().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _freq

double TTBDMI_SH::_freq
private

Referenced by getFreq(), and setStats().

◆ _freqIcomp

double TTBDMI_SH::_freqIcomp
private

Referenced by getFreqIcmp(), and setStats().

◆ _patchFreq

double* TTBDMI_SH::_patchFreq
private

Referenced by getPatchFreq(), setStats(), and ~TTBDMI_SH().

◆ _patchIcmp

double * TTBDMI_SH::_patchIcmp
private

Referenced by getPatchIcmp(), setStats(), and ~TTBDMI_SH().


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