Nemo  2.2.0
ttwolbachia.h
Go to the documentation of this file.
00001 
00031 #ifndef TTWOLBACHIA_H
00032 #define TTWOLBACHIA_H
00033 
00034 #include "ttrait.h"
00035 #include "stathandler.h"
00036 #include "binarystoragebuffer.h"
00037 #include "Uniform.h"
00038 
00039 class TTWolbachiaSH;
00040 
00041 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
00042 
00043 //                               ****** TTWolbachia ******
00044 
00045 /*_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\*/
00050 class TTWolbachia : public TTrait
00051 {
00052 private:
00053   double _transmit_rate;  
00054   bool _is_infected;
00055   
00056 public:
00057         
00058     TTWolbachia () 
00059     : _transmit_rate(0), _is_infected(0) { }
00060   
00061   TTWolbachia (const TTWolbachia& T) 
00062     : _transmit_rate(T._transmit_rate), _is_infected(T._is_infected) { }
00063   
00064   
00065   virtual ~TTWolbachia                            () {}
00066   
00067   void set_transmit_rate              (double val) {_transmit_rate = val;}
00068   
00069   virtual void    init                            ()  {_is_infected = 0;}
00070   virtual void    init_sequence           ()  {_is_infected = 0;}
00071   virtual void    reset                           ()  {_is_infected = 0;}
00072   virtual void    inherit             (TTrait* mother, TTrait* father)
00073   {  _is_infected = *(bool*)mother->getValue();  }
00074   virtual void    mutate              ()
00075   {  _is_infected &= (RAND::Uniform() < _transmit_rate);  }  
00076   virtual void*   set_trait                       (void* value)
00077   {  _is_infected = *(bool*)value; return &_is_infected; }
00078   virtual void    set_sequence        (void** seq)  { }
00079   virtual void    set_value           ( )  { }
00080   virtual void*   getValue                        ( )  {return (void*)&_is_infected;}
00081   virtual trait_t get_type                        () const {return WOLB;}
00082   virtual void**  get_sequence        () const {return NULL;}  
00083   virtual void*   get_allele              (int loc, int all) const {return NULL;}  
00084   virtual void    show_up                         () {}
00085   virtual TTWolbachia*  clone             ()  {return new TTWolbachia(*this);}
00086   virtual TTWolbachia& operator=      (const TTrait& T);
00087   virtual bool    operator==          (const TTrait& T);
00088   virtual bool    operator!=          (const TTrait& T);
00089     
00090   virtual void    store_data      (BinaryStorageBuffer* saver)  
00091   { 
00092     unsigned char dummy = static_cast<unsigned char>(_is_infected);
00093     saver->store(&dummy, 1);
00094   }
00095   virtual bool    retrieve_data   (BinaryStorageBuffer* reader)
00096   {
00097     unsigned char dummy;
00098     reader->read(&dummy, 1);
00099     _is_infected = dummy;
00100     return true;
00101   }
00102   
00103 };
00104 
00105 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
00106 
00107 //                               ****** TProtoWolbachia ******
00108 
00109 /*_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\*/
00111 class TProtoWolbachia : public TraitPrototype {
00112 public:
00113   TProtoWolbachia();
00114   TProtoWolbachia(const TProtoWolbachia&);
00115   ~TProtoWolbachia();
00116   
00117   virtual void init(){}
00118   virtual bool setParameters()
00119   { _transmit_rate =  get_parameter_value("wolbachia_transmission_rate"); return true;}
00120   
00121   virtual TTWolbachia* hatch() 
00122   {
00123     TTWolbachia* new_trait = new TTWolbachia();
00124     new_trait->set_transmit_rate(_transmit_rate);
00125     return new_trait;
00126   }
00127   
00128   virtual TProtoWolbachia* clone() {return new TProtoWolbachia(*this);}
00129   
00130   virtual trait_t get_type ( ) const {return WOLB;}
00131   
00132   virtual void store_data (BinaryStorageBuffer* saver)     {/*we have nothing to save...*/}
00133   virtual bool retrieve_data (BinaryStorageBuffer* reader) {return true;}
00134   
00135   virtual void    loadFileServices ( FileServices* loader ) {}
00136   virtual void    loadStatServices ( StatServices* loader );
00137   
00138 private:
00139   
00140     double _transmit_rate;
00141   TTWolbachiaSH* _stats;
00142 };
00143 
00144 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/*/
00145 
00146 //                               ****** TTWolbachiaSH ******
00147 
00148 /*_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\*/
00150 class TTWolbachiaSH : public StatHandler<TTWolbachiaSH> {
00151   
00152   TProtoWolbachia* _trait;
00153   int _TTidx;
00154   double _Fmean, _Mmean, _var, _extrate;
00155 public:
00156   
00157   TTWolbachiaSH (TProtoWolbachia* TT) 
00158   : _trait(TT), _TTidx(TT->get_index()), _Fmean(0), _Mmean(0), _var(0), _extrate(0) {}
00159   
00160   virtual ~TTWolbachiaSH ( ) { }
00161   
00162   virtual bool setStatRecorders (string& token);
00163   
00164   void   setInfectionStats                      ( );
00165   double getMeanInfection                       (unsigned int sex) {return ((bool)sex ? _Fmean : _Mmean);}
00166   double getMeanOffsprgInfection                (unsigned int sex);
00167   double getMeanFemaleInfection_perPatch        (unsigned int patch);
00168   double getMeanMaleInfection_perPatch          (unsigned int patch);
00169   double getMeanOffsprgFemaleInfection_perPatch (unsigned int patch);
00170   double getMeanOffsprgMaleInfection_perPatch   (unsigned int patch);
00171   double getIcompatibleMatingFreq                               ( );
00172   double getDemicInfectionVar                   ( ) {return _var;}
00173   double getDemicExtinctionRate                 ( ) {return _extrate;}
00174 };
00175 
00176 #endif //TTWOLBACHIA_H
00177 

Generated for Nemo v2.2.0 by  doxygen 1.7.5.1 -- Nemo is hosted by  SourceForge.net Logo