Nemo  2.3.46
TTDeletMutations_bitstring Class Reference

Bitstring implementation of TTDeletMutations with recombination. More...

#include <ttdeletmutations_bitstring.h>

+ Inheritance diagram for TTDeletMutations_bitstring:
+ Collaboration diagram for TTDeletMutations_bitstring:

Public Member Functions

 TTDeletMutations_bitstring ()
 
 TTDeletMutations_bitstring (const TTDeletMutations_bitstring &T)
 
virtual ~TTDeletMutations_bitstring ()
 
double viability_multi ()
 
double viability_epist ()
 
double viability_multi_continuous ()
 
double viability_epist_continuous ()
 
void mutate_redraw ()
 
void mutate_noredraw ()
 
void set_sequence (bitstring **seq)
 
Getters:
unsigned int get_nb_mutations ()
 
unsigned int get_nb_mut_atLocus (unsigned int loc)
 
unsigned int get_nb_htz_mutations ()
 
unsigned int get_nb_hmz_mutations ()
 
bool get_hmz_atLocus (unsigned int loc)
 
bool get_htz_atLocus (unsigned int loc)
 
float ** get_effects () const
 
Setters:
void set_proto (TProtoDeletMutations_bitstring *proto)
 
void set_nb_locus (int val)
 
void set_mut_rate (double val, int nloc)
 
void set_strength (double val)
 
void set_dominance (double val)
 
void set_viability_func_ptr (unsigned int f_model, bool is_cont)
 
void set_inherit_func_ptr (void(TProtoDeletMutations_bitstring::*theFunc)(sex_t, bitstring *, bitstring **))
 
void set_mutation_func_ptr (unsigned int m_model)
 
void set_fitness_scaling_factor (double val)
 
void set_init_freq (double val)
 
void set_fitness_model (int val)
 
void set_continuous_effects (bool val)
 
Implementations
virtual void init ()
 
virtual void init_sequence ()
 
virtual void reset ()
 
virtual void * set_trait (void *value)
 
virtual void ** get_sequence () const
 
virtual double get_allele_value (int loc, int all)
 
virtual void set_allele_value (unsigned int locus, unsigned int allele, double value)
 
virtual void set_sequence (void **seq)
 
virtual trait_t get_type () const
 
virtual void inherit (TTrait *mother, TTrait *father)
 
virtual void mutate ()
 
virtual void set_value ()
 
virtual void * getValue () const
 
virtual void show_up ()
 
virtual
TTDeletMutations_bitstring
clone ()
 
virtual
TTDeletMutations_bitstring
operator= (const TTrait &T)
 
virtual bool operator== (const TTrait &T)
 
virtual bool operator!= (const TTrait &T)
 
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
- Public Member Functions inherited from TTrait
virtual ~TTrait ()
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 

Static Public Member Functions

static void set_effects (float **fx)
 
static void set_recomb_template (unsigned int size)
 

Private Member Functions

void set_nb_mutations ()
 
void set_nb_htz_mutations ()
 
void set_nb_hmz_mutations ()
 

Private Attributes

TProtoDeletMutations_bitstring_myProto
 
unsigned int _nb_mutations
 
unsigned int _nb_hmz_mutations
 
unsigned int _nb_htz_mutations
 
bitstringsequence [2]
 
bitstring_htz
 
bitstring_hmz
 
double _phenotype
 
trait_t _type
 
Parameters
unsigned int _nb_locus
 
unsigned int _fitness_model
 
double _fitness_scaling_factor
 
double _init_freq
 
double _mut_rate
 
double _genomic_mut_rate
 
double _strength
 
double _dominance
 
bool _continuous_effects
 
double(TTDeletMutations_bitstring::* _viability_func_ptr )(void)
 
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr )(sex_t, bitstring *, bitstring **)
 
void(TTDeletMutations_bitstring::* _mutation_func_ptr )(void)
 

Static Private Attributes

static float ** _effects = NULL
 

Detailed Description

Bitstring implementation of TTDeletMutations with recombination.

Constructor & Destructor Documentation

TTDeletMutations_bitstring::TTDeletMutations_bitstring ( )
inline

Referenced by clone().

94  {sequence[0] = sequence[1] = NULL;}
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:64
unsigned int _nb_htz_mutations
Definition: ttdeletmutations_bitstring.h:73
double _genomic_mut_rate
Definition: ttdeletmutations_bitstring.h:59
void(TTDeletMutations_bitstring::* _mutation_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:65
double _strength
Definition: ttdeletmutations_bitstring.h:60
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
double _init_freq
Definition: ttdeletmutations_bitstring.h:57
trait_t _type
Definition: ttdeletmutations_bitstring.h:79
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:62
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:55
TProtoDeletMutations_bitstring * _myProto
Definition: ttdeletmutations_bitstring.h:50
bitstring * _htz
Definition: ttdeletmutations_bitstring.h:76
unsigned int _nb_mutations
Definition: ttdeletmutations_bitstring.h:71
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:76
double _dominance
Definition: ttdeletmutations_bitstring.h:61
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:56
#define DELE
Definition: types.h:66
double _phenotype
Definition: ttdeletmutations_bitstring.h:77
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:63
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:72
double _mut_rate
Definition: ttdeletmutations_bitstring.h:58
TTDeletMutations_bitstring::TTDeletMutations_bitstring ( const TTDeletMutations_bitstring T)
inline
104  {sequence[0] = sequence[1] = NULL;}
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:64
unsigned int _nb_htz_mutations
Definition: ttdeletmutations_bitstring.h:73
double _genomic_mut_rate
Definition: ttdeletmutations_bitstring.h:59
void(TTDeletMutations_bitstring::* _mutation_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:65
double _strength
Definition: ttdeletmutations_bitstring.h:60
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
double _init_freq
Definition: ttdeletmutations_bitstring.h:57
trait_t _type
Definition: ttdeletmutations_bitstring.h:79
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:62
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:55
TProtoDeletMutations_bitstring * _myProto
Definition: ttdeletmutations_bitstring.h:50
bitstring * _htz
Definition: ttdeletmutations_bitstring.h:76
unsigned int _nb_mutations
Definition: ttdeletmutations_bitstring.h:71
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:76
double _dominance
Definition: ttdeletmutations_bitstring.h:61
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:56
#define DELE
Definition: types.h:66
double _phenotype
Definition: ttdeletmutations_bitstring.h:77
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:63
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:72
double _mut_rate
Definition: ttdeletmutations_bitstring.h:58
virtual TTDeletMutations_bitstring::~TTDeletMutations_bitstring ( )
inlinevirtual

References reset().

106 {reset();}
virtual void reset()
Definition: ttdeletmutations_bitstring.cc:534

Member Function Documentation

virtual TTDeletMutations_bitstring* TTDeletMutations_bitstring::clone ( )
inlinevirtual

Implements TTrait.

References TTDeletMutations_bitstring().

165 {return new TTDeletMutations_bitstring(*this);}
TTDeletMutations_bitstring()
Definition: ttdeletmutations_bitstring.h:89
double TTDeletMutations_bitstring::get_allele_value ( int  loc,
int  all 
)
virtual

Implements TTrait.

References _effects, get_hmz_atLocus(), and sequence.

561 {
562  if((*sequence[all])[loc]) {
563  if(get_hmz_atLocus(loc)) return _effects[1][loc];
564  else return _effects[0][loc];
565  } else {
566  if(get_hmz_atLocus(loc)) return 0;
567  else return _effects[0][loc];
568  }
569 }
bool get_hmz_atLocus(unsigned int loc)
Definition: ttdeletmutations_bitstring.h:115
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
static float ** _effects
Definition: ttdeletmutations_bitstring.h:68
float** TTDeletMutations_bitstring::get_effects ( ) const
inline

References _effects.

117 {return _effects;}
static float ** _effects
Definition: ttdeletmutations_bitstring.h:68
bool TTDeletMutations_bitstring::get_hmz_atLocus ( unsigned int  loc)
inline

Referenced by get_allele_value().

115 {return (*sequence[0])[loc] & (*sequence[1])[loc];}
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
bool TTDeletMutations_bitstring::get_htz_atLocus ( unsigned int  loc)
inline
116 {return (*sequence[0])[loc] ^ (*sequence[1])[loc];}
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
unsigned int TTDeletMutations_bitstring::get_nb_hmz_mutations ( )
inline

References _nb_hmz_mutations.

Referenced by TTDeletMutBitstrSH::setDeletStats(), and show_up().

114 {return _nb_hmz_mutations;}
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:72
unsigned int TTDeletMutations_bitstring::get_nb_htz_mutations ( )
inline

References _nb_htz_mutations.

Referenced by TTDeletMutBitstrSH::setDeletStats(), and show_up().

113 {return _nb_htz_mutations;}
unsigned int _nb_htz_mutations
Definition: ttdeletmutations_bitstring.h:73
unsigned int TTDeletMutations_bitstring::get_nb_mut_atLocus ( unsigned int  loc)
inline

Referenced by TTDeletMutBitstrSH::setDeletStats().

112 {return (*sequence[0])[loc] + (*sequence[1])[loc];}
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
unsigned int TTDeletMutations_bitstring::get_nb_mutations ( )
inline

References _nb_mutations.

Referenced by show_up().

111 {return _nb_mutations;}
unsigned int _nb_mutations
Definition: ttdeletmutations_bitstring.h:71
virtual void** TTDeletMutations_bitstring::get_sequence ( ) const
inlinevirtual

Implements TTrait.

154 {return (void**)&sequence[0];}
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
virtual trait_t TTDeletMutations_bitstring::get_type ( ) const
inlinevirtual

Implements TTrait.

References _type.

159 {return _type;}
trait_t _type
Definition: ttdeletmutations_bitstring.h:79
virtual void* TTDeletMutations_bitstring::getValue ( ) const
inlinevirtual

Implements TTrait.

References _phenotype.

Referenced by show_up().

163 {return (void*)&_phenotype;}
double _phenotype
Definition: ttdeletmutations_bitstring.h:77
void TTDeletMutations_bitstring::inherit ( TTrait mother,
TTrait father 
)
virtual

Implements TTrait.

References _inherit_func_ptr, _myProto, FEM, TTrait::get_sequence(), MAL, and sequence.

628 {
629  bitstring** mother_seq = (bitstring**)mother->get_sequence();
630  bitstring** father_seq = (bitstring**)father->get_sequence();
631 
632  (_myProto->* _inherit_func_ptr) (FEM, sequence[FEM], mother_seq);
633 
634  (_myProto->* _inherit_func_ptr) (MAL, sequence[MAL], father_seq);
635 }
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:64
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
TProtoDeletMutations_bitstring * _myProto
Definition: ttdeletmutations_bitstring.h:50
virtual void ** get_sequence() const =0
sequence accessor.
Definition: types.h:37
Definition: types.h:37
void TTDeletMutations_bitstring::init ( )
virtual

Implements TTrait.

References _hmz, _htz, _nb_locus, fatal(), and sequence.

Referenced by operator=(), and set_sequence().

521 {
522  if(sequence[0] != NULL) fatal("TTDeletMutations_bitstring::init::sequence[0] is not NULL !\n");
523  if(sequence[1] != NULL) fatal("TTDeletMutations_bitstring::init::sequence[1] is not NULL !\n");
524 
525  sequence[0] = new bitstring(_nb_locus);
526  sequence[1] = new bitstring(_nb_locus);
527 
528  _htz = new bitstring(_nb_locus);
529  _hmz = new bitstring(_nb_locus);
530 }
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
void fatal(const char *str,...)
Definition: output.cc:90
bitstring * _htz
Definition: ttdeletmutations_bitstring.h:76
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:76
void TTDeletMutations_bitstring::init_sequence ( )
virtual

Implements TTrait.

References _init_freq, _nb_locus, bitstring::reset(), sequence, bitstring::set(), and RAND::Uniform().

595 {
596  if(sequence[0] == NULL) sequence[0] = new bitstring(_nb_locus);
597 
598  if(sequence[1] == NULL) sequence[1] = new bitstring(_nb_locus);
599 
600  unsigned int nb_mut, locus;
601 
602  sequence[0]->reset();
603  sequence[1]->reset();
604 
605  if(_init_freq != 0) {
606 
607  nb_mut = (unsigned int)(_init_freq*_nb_locus*2);
608 
609  for(unsigned int i = 0; i < nb_mut; i++) {
610 
611  do {
612  locus = RAND::Uniform( _nb_locus );
613  //check if the locus is not already homozygote:
614  } while( (*sequence[0])[ locus ] && (*sequence[1])[ locus ] );
615 
616  if((*sequence[0])[ locus ])
617  sequence[1]->set(locus);
618  else
619  sequence[0]->set(locus);
620  }
621 
622  }
623 }
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
double _init_freq
Definition: ttdeletmutations_bitstring.h:57
void set(size_t n)
Set a bit to 1.
Definition: bitstring.h:235
void reset()
Set all bits to 0.
Definition: bitstring.h:251
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:101
virtual void TTDeletMutations_bitstring::mutate ( )
inlinevirtual

Implements TTrait.

References _mutation_func_ptr.

161 {(this->*_mutation_func_ptr)();}
void(TTDeletMutations_bitstring::* _mutation_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:65
void TTDeletMutations_bitstring::mutate_noredraw ( )

References _genomic_mut_rate, _nb_locus, RAND::Poisson(), RAND::RandBool(), sequence, bitstring::set(), and RAND::Uniform().

Referenced by set_mutation_func_ptr().

669 {
670  unsigned int NbMut;
671 
672  NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
673 
674  while(NbMut != 0) {
675 
677 
678  NbMut--;
679  }
680 }
double _genomic_mut_rate
Definition: ttdeletmutations_bitstring.h:59
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:196
void set(size_t n)
Set a bit to 1.
Definition: bitstring.h:235
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:101
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:139
void TTDeletMutations_bitstring::mutate_redraw ( )

References _genomic_mut_rate, _nb_hmz_mutations, _nb_locus, RAND::Poisson(), RAND::RandBool(), sequence, bitstring::set(), and RAND::Uniform().

Referenced by set_mutation_func_ptr().

641 {
642  unsigned int NbMut, mutLocus;
643 
644  NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
645 
646  if( (int)_nb_hmz_mutations - (int)NbMut < 0 ) NbMut -= _nb_hmz_mutations;
647 
648  while(NbMut != 0) {
649 
650  do {
651  mutLocus = RAND::Uniform( _nb_locus );
652  //check if the locus is not already homozygote:
653  } while( (*sequence[0])[mutLocus] && (*sequence[1])[mutLocus] );
654 
655  if ( !( (*sequence[0])[mutLocus] || (*sequence[1])[mutLocus] ) )
656  sequence[RAND::RandBool()]->set(mutLocus);
657  else if((*sequence[0])[mutLocus])
658  sequence[1]->set(mutLocus);
659  else
660  sequence[0]->set(mutLocus);
661 
662  NbMut--;
663  }
664 }
double _genomic_mut_rate
Definition: ttdeletmutations_bitstring.h:59
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:196
void set(size_t n)
Set a bit to 1.
Definition: bitstring.h:235
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:101
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:139
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:72
bool TTDeletMutations_bitstring::operator!= ( const TTrait T)
virtual

Implements TTrait.

474 {
475  if(!((*this) == T))
476  return true;
477  else
478  return false;
479 }
TTDeletMutations_bitstring & TTDeletMutations_bitstring::operator= ( const TTrait T)
virtual

Implements TTrait.

References _nb_locus, bitstring::copy(), init(), reset(), sequence, and set_value().

429 {
430  const TTDeletMutations_bitstring& TD = dynamic_cast<const TTDeletMutations_bitstring&> (T);
431  if(this != &TD) {
432 
433 // _myProto = TD._myProto;
434  _nb_locus = TD._nb_locus;
435 // _fitness_model = TD._fitness_model;
436 // _fitness_scaling_factor = TD._fitness_scaling_factor;
437 // _init_freq = TD._init_freq;
438 // _mut_rate = TD._mut_rate;
439  // _recomb_rate = TD._recomb_rate;
440 // _strength = TD._strength;
441 // _dominance = TD._dominance;
442 // _continuous_effects = TD._continuous_effects;
443 // _viability_func_ptr = TD._viability_func_ptr;
444 // _inherit_func_ptr = TD._inherit_func_ptr;
445  //deallocate any previous sequence memory:
446  reset();
447  //allocate sequence memory:
448  init();
449  //copy sequence:
450  sequence[0]->copy(*TD.sequence[0]);
451  sequence[1]->copy(*TD.sequence[1]);
452 
453  set_value();
454  }
455  return *this;
456 }
virtual void reset()
Definition: ttdeletmutations_bitstring.cc:534
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
virtual void init()
Definition: ttdeletmutations_bitstring.cc:520
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:255
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:47
virtual void set_value()
Definition: ttdeletmutations_bitstring.cc:684
bool TTDeletMutations_bitstring::operator== ( const TTrait T)
virtual

Implements TTrait.

References _nb_locus, _type, and TTrait::get_type().

461 {
462  if(_type.compare(T.get_type()) != 0) return false;
463 
464  const TTDeletMutations_bitstring& TD = dynamic_cast<const TTDeletMutations_bitstring&> (T);
465  if(this != &TD) {
466  if(_nb_locus != TD._nb_locus) return false;
467  }
468  return true;
469 }
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
trait_t _type
Definition: ttdeletmutations_bitstring.h:79
virtual trait_t get_type() const =0
type accessor.
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:47
void TTDeletMutations_bitstring::reset ( )
virtual

Implements TTrait.

References _hmz, _htz, and sequence.

Referenced by operator=(), set_sequence(), and ~TTDeletMutations_bitstring().

535 {
536  if(sequence[0] != NULL) delete sequence[0];
537  if(sequence[1] != NULL) delete sequence[1];
538 
539  sequence[0] = NULL;
540  sequence[1] = NULL;
541 
542  if(_htz != NULL) delete _htz;
543  _htz = 0;
544 
545  if(_hmz != NULL) delete _hmz;
546  _hmz = 0;
547 }
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
bitstring * _htz
Definition: ttdeletmutations_bitstring.h:76
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:76
bool TTDeletMutations_bitstring::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

References bitstring::nb_words(), BinaryStorageBuffer::read(), sequence, and bitstring::set_data().

773 {
774  size_t wnb = sequence[0]->nb_words();
775  size_t bytes = wnb * sizeof(bitstring::_ul);
776  bitstring::_ul *srce = new bitstring::_ul [wnb];
777 
778  reader->read(srce, bytes);
779  sequence[0]->set_data(srce,wnb);
780 
781  reader->read(srce, bytes);
782  sequence[1]->set_data(srce,wnb);
783 
784  return true;
785 }
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
size_t nb_words()
Definition: bitstring.h:144
unsigned long _ul
Definition: bitstring.h:60
void set_data(_ul *srce, size_t nbwrd)
Copy bits from an array of unsigned long words.
Definition: bitstring.h:241
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:147
void TTDeletMutations_bitstring::set_allele_value ( unsigned int  locus,
unsigned int  allele,
double  value 
)
virtual

Implements TTrait.

References _dominance, _effects, _myProto, _nb_locus, _strength, TProtoDeletMutations_bitstring::get_dominance_model(), sequence, and bitstring::set().

575 {
576  assert(locus < _nb_locus && allele < 2);
577 
578  sequence[allele]->set(locus);
579 
580  _effects[1][locus] = (float)value;
581 
582  double dom;
583  if(_myProto->get_dominance_model() == 1)
584  dom = exp(-1.0*_effects[1][locus]*(-1.0*log(2*_dominance) / _strength))/2.0; //scaling of h on s
585  else dom = _dominance;
586 
587  _effects[0][locus] = (float)(dom * _effects[1][locus]); //heterozygote effect: hs
588 
589 }
int get_dominance_model()
Definition: ttdeletmutations_bitstring.h:192
double _strength
Definition: ttdeletmutations_bitstring.h:60
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
TProtoDeletMutations_bitstring * _myProto
Definition: ttdeletmutations_bitstring.h:50
void set(size_t n)
Set a bit to 1.
Definition: bitstring.h:235
double _dominance
Definition: ttdeletmutations_bitstring.h:61
static float ** _effects
Definition: ttdeletmutations_bitstring.h:68
void TTDeletMutations_bitstring::set_continuous_effects ( bool  val)
inline

Referenced by TProtoDeletMutations_bitstring::hatch().

133 {_continuous_effects = val;}
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:62
void TTDeletMutations_bitstring::set_dominance ( double  val)
inline

Referenced by TProtoDeletMutations_bitstring::hatch().

125 {_dominance = val;}
double _dominance
Definition: ttdeletmutations_bitstring.h:61
void TTDeletMutations_bitstring::set_effects ( float **  fx)
static

References _effects.

Referenced by TProtoDeletMutations_bitstring::retrieve_data(), and TProtoDeletMutations_bitstring::set_effects().

41 {_effects = fx;}
static float ** _effects
Definition: ttdeletmutations_bitstring.h:68
void TTDeletMutations_bitstring::set_fitness_model ( int  val)
inline

Referenced by TProtoDeletMutations_bitstring::hatch().

132 {_fitness_model = val;}
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:55
void TTDeletMutations_bitstring::set_fitness_scaling_factor ( double  val)
inline

Referenced by TProtoDeletMutations_bitstring::hatch().

double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:56
void TTDeletMutations_bitstring::set_inherit_func_ptr ( void(TProtoDeletMutations_bitstring::*)(sex_t, bitstring *, bitstring **)  theFunc)
inline

References _inherit_func_ptr.

Referenced by TProtoDeletMutations_bitstring::hatch().

128  {_inherit_func_ptr = theFunc;}
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:64
void TTDeletMutations_bitstring::set_init_freq ( double  val)
inline

Referenced by TProtoDeletMutations_bitstring::hatch().

131 {_init_freq = val;}
double _init_freq
Definition: ttdeletmutations_bitstring.h:57
void TTDeletMutations_bitstring::set_mut_rate ( double  val,
int  nloc 
)
inline

References _mut_rate.

Referenced by TProtoDeletMutations_bitstring::hatch().

123 {_mut_rate = val; _genomic_mut_rate = 2*nloc*_mut_rate;}
double _genomic_mut_rate
Definition: ttdeletmutations_bitstring.h:59
double _mut_rate
Definition: ttdeletmutations_bitstring.h:58
void TTDeletMutations_bitstring::set_mutation_func_ptr ( unsigned int  m_model)

References _mutation_func_ptr, mutate_noredraw(), and mutate_redraw().

Referenced by TProtoDeletMutations_bitstring::hatch().

507 {
508  switch(m_model) {
509  case 1:
511  break;
512  case 2:
514  break;
515  }
516 }
void(TTDeletMutations_bitstring::* _mutation_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:65
void mutate_redraw()
Definition: ttdeletmutations_bitstring.cc:640
void mutate_noredraw()
Definition: ttdeletmutations_bitstring.cc:668
void TTDeletMutations_bitstring::set_nb_hmz_mutations ( )
private

References _hmz, _nb_hmz_mutations, bitstring::count(), and sequence.

Referenced by set_value(), and show_up().

710 {
711  (*_hmz) = *sequence[0] & *sequence[1];
713 }
unsigned int count()
Count number of set bits.
Definition: bitstring.h:224
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:76
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:72
void TTDeletMutations_bitstring::set_nb_htz_mutations ( )
private

References _htz, _nb_htz_mutations, bitstring::count(), and sequence.

Referenced by set_value(), and show_up().

702 {
703  (*_htz) = *sequence[0] ^ *sequence[1];
705 }
unsigned int _nb_htz_mutations
Definition: ttdeletmutations_bitstring.h:73
unsigned int count()
Count number of set bits.
Definition: bitstring.h:224
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
bitstring * _htz
Definition: ttdeletmutations_bitstring.h:76
void TTDeletMutations_bitstring::set_nb_locus ( int  val)
inline

Referenced by TProtoDeletMutations_bitstring::hatch().

122 {_nb_locus = val;}
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
void TTDeletMutations_bitstring::set_nb_mutations ( )
private

References _nb_mutations, bitstring::count(), and sequence.

Referenced by set_value(), and show_up().

695 {
696  _nb_mutations = sequence[0]->count() + sequence[1]->count();
697 }
unsigned int count()
Count number of set bits.
Definition: bitstring.h:224
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
unsigned int _nb_mutations
Definition: ttdeletmutations_bitstring.h:71
void TTDeletMutations_bitstring::set_proto ( TProtoDeletMutations_bitstring proto)
inline

Referenced by TProtoDeletMutations_bitstring::hatch().

121 {_myProto = proto;}
TProtoDeletMutations_bitstring * _myProto
Definition: ttdeletmutations_bitstring.h:50
static void TTDeletMutations_bitstring::set_recomb_template ( unsigned int  size)
static
void TTDeletMutations_bitstring::set_sequence ( bitstring **  seq)

References bitstring::copy(), init(), reset(), and sequence.

Referenced by TTDeletMutBitstrFH::FHread().

552 {
553  reset(); init();
554  sequence[0]->copy(*seq[0]);
555  sequence[1]->copy(*seq[1]);
556 }
virtual void reset()
Definition: ttdeletmutations_bitstring.cc:534
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
virtual void init()
Definition: ttdeletmutations_bitstring.cc:520
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:255
virtual void TTDeletMutations_bitstring::set_sequence ( void **  seq)
inlinevirtual

Implements TTrait.

158 {}
void TTDeletMutations_bitstring::set_strength ( double  val)
inline

Referenced by TProtoDeletMutations_bitstring::hatch().

124 {_strength = val;}
double _strength
Definition: ttdeletmutations_bitstring.h:60
virtual void* TTDeletMutations_bitstring::set_trait ( void *  value)
inlinevirtual

Implements TTrait.

153 {return NULL;}
void TTDeletMutations_bitstring::set_value ( )
virtual

Implements TTrait.

References _phenotype, _viability_func_ptr, set_nb_hmz_mutations(), set_nb_htz_mutations(), and set_nb_mutations().

Referenced by operator=(), and show_up().

685 {
689  _phenotype = (this->*_viability_func_ptr)();
690 }
void set_nb_htz_mutations()
Definition: ttdeletmutations_bitstring.cc:701
void set_nb_mutations()
Definition: ttdeletmutations_bitstring.cc:694
void set_nb_hmz_mutations()
Definition: ttdeletmutations_bitstring.cc:709
double _phenotype
Definition: ttdeletmutations_bitstring.h:77
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:63
void TTDeletMutations_bitstring::set_viability_func_ptr ( unsigned int  f_model,
bool  is_cont 
)

References _viability_func_ptr, viability_epist(), viability_epist_continuous(), viability_multi(), and viability_multi_continuous().

Referenced by TProtoDeletMutations_bitstring::hatch().

483  {
484  switch(f_model) {
485  case 1:
486  {
487  if(is_cont)
489  else
491  break;
492  }
493  case 2:
494  {
495  if(is_cont)
497  else
499  break;
500  }
501  }
502 }
double viability_multi_continuous()
Definition: ttdeletmutations_bitstring.cc:735
double viability_epist_continuous()
Definition: ttdeletmutations_bitstring.cc:749
double viability_multi()
Definition: ttdeletmutations_bitstring.cc:717
double viability_epist()
Definition: ttdeletmutations_bitstring.cc:727
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:63
void TTDeletMutations_bitstring::show_up ( )
virtual

Implements TTrait.

References _nb_locus, get_nb_hmz_mutations(), get_nb_htz_mutations(), get_nb_mutations(), getValue(), sequence, set_nb_hmz_mutations(), set_nb_htz_mutations(), set_nb_mutations(), and set_value().

791 {
795  set_value();
796  std::cout<<"\n Trait type: delet"
797  <<"\n value: "<<*(double*)getValue()
798  <<"\nnb mutations: "<<get_nb_mutations()
799  <<"\n nb hmz mut: "<<get_nb_hmz_mutations()
800  <<"\n nb htz mut: "<<get_nb_htz_mutations()
801  <<"\n sequence: "<<std::endl;
802  cout<<"0: ";
803  for(unsigned int i = 0; i < _nb_locus && i < 64; i++)
804  cout<<(*sequence[0])[i];
805  cout<<"\n1: ";
806  for(unsigned int i = 0; i < _nb_locus && i < 64; i++)
807  cout<<(*sequence[1])[i];
808  cout<<endl;
809 }
unsigned int get_nb_hmz_mutations()
Definition: ttdeletmutations_bitstring.h:114
void set_nb_htz_mutations()
Definition: ttdeletmutations_bitstring.cc:701
void set_nb_mutations()
Definition: ttdeletmutations_bitstring.cc:694
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
virtual void * getValue() const
Definition: ttdeletmutations_bitstring.h:163
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
void set_nb_hmz_mutations()
Definition: ttdeletmutations_bitstring.cc:709
virtual void set_value()
Definition: ttdeletmutations_bitstring.cc:684
unsigned int get_nb_htz_mutations()
Definition: ttdeletmutations_bitstring.h:113
unsigned int get_nb_mutations()
Definition: ttdeletmutations_bitstring.h:111
void TTDeletMutations_bitstring::store_data ( BinaryStorageBuffer saver)
virtual

Implements StorableComponent.

References bitstring::getword_atIdx(), bitstring::nb_words(), sequence, and BinaryStorageBuffer::store().

761 {
762  size_t wnb = sequence[0]->nb_words();
763  size_t bytes = sizeof(bitstring::_ul);
764 
765  for(size_t i = 0; i < wnb; i++)
766  saver->store(sequence[0]->getword_atIdx(i), bytes);
767 
768  for(size_t i = 0; i < wnb; i++)
769  saver->store(sequence[1]->getword_atIdx(i), bytes);
770 }
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:75
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:130
size_t nb_words()
Definition: bitstring.h:144
unsigned long _ul
Definition: bitstring.h:60
_ul * getword_atIdx(size_t index)
Definition: bitstring.h:139
double TTDeletMutations_bitstring::viability_epist ( )

References _dominance, _fitness_scaling_factor, _nb_hmz_mutations, _nb_htz_mutations, and _strength.

Referenced by set_viability_func_ptr().

728 {
729  //w = 1 - s(hmz + h*htz)
731 }
unsigned int _nb_htz_mutations
Definition: ttdeletmutations_bitstring.h:73
double _strength
Definition: ttdeletmutations_bitstring.h:60
double _dominance
Definition: ttdeletmutations_bitstring.h:61
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:56
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:72
double TTDeletMutations_bitstring::viability_epist_continuous ( )

References _effects, _fitness_scaling_factor, _hmz, and _nb_locus.

Referenced by set_viability_func_ptr().

750 {
751  //w = 1 - s(hmz + h*htz)
752  double fitness = 1.0;
753 
754  for(unsigned int i = 0; i < _nb_locus; ++i)
755  fitness -= (*_hmz)[i]*_effects[1][i] + (*_htz)[i]*_effects[0][i];
756 
757  return fitness * _fitness_scaling_factor;
758 }
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:76
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:56
static float ** _effects
Definition: ttdeletmutations_bitstring.h:68
double TTDeletMutations_bitstring::viability_multi ( )

References _dominance, _fitness_scaling_factor, _nb_hmz_mutations, _nb_htz_mutations, and _strength.

Referenced by set_viability_func_ptr().

718 {
719  //w = (1-s)^hmz * (1-hs)^htz
720  return ( pow( 1.0 - _strength, (double)_nb_hmz_mutations ) *
721  pow( 1.0 - (_dominance * _strength), (double)_nb_htz_mutations) *
723 }
unsigned int _nb_htz_mutations
Definition: ttdeletmutations_bitstring.h:73
double _strength
Definition: ttdeletmutations_bitstring.h:60
double _dominance
Definition: ttdeletmutations_bitstring.h:61
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:56
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:72
double TTDeletMutations_bitstring::viability_multi_continuous ( )

References _effects, _fitness_scaling_factor, _hmz, and _nb_locus.

Referenced by set_viability_func_ptr().

736 {
737  //w = (1-s)^hmz * (1-hs)^htz
738  double fitness = 1.0;
739 
740  for(unsigned int i = 0; i < _nb_locus; ++i)
741  //_effects[0] stores hs, _effects[1] stores s
742  fitness *= (1.0f - (*_hmz)[i]*_effects[1][i]) * (1.0f - (*_htz)[i]*_effects[0][i]);
743 
744  return fitness * _fitness_scaling_factor;
745 }
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:76
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:56
static float ** _effects
Definition: ttdeletmutations_bitstring.h:68

Member Data Documentation

bool TTDeletMutations_bitstring::_continuous_effects
private
double TTDeletMutations_bitstring::_dominance
private
float ** TTDeletMutations_bitstring::_effects = NULL
staticprivate
unsigned int TTDeletMutations_bitstring::_fitness_model
private
double TTDeletMutations_bitstring::_fitness_scaling_factor
private
double TTDeletMutations_bitstring::_genomic_mut_rate
private

Referenced by mutate_noredraw(), and mutate_redraw().

bitstring * TTDeletMutations_bitstring::_hmz
private
bitstring* TTDeletMutations_bitstring::_htz
private

Referenced by init(), reset(), and set_nb_htz_mutations().

void(TProtoDeletMutations_bitstring::* TTDeletMutations_bitstring::_inherit_func_ptr)(sex_t, bitstring *, bitstring **)
private

Referenced by inherit(), and set_inherit_func_ptr().

double TTDeletMutations_bitstring::_init_freq
private

Referenced by init_sequence().

double TTDeletMutations_bitstring::_mut_rate
private

Referenced by set_mut_rate().

void(TTDeletMutations_bitstring::* TTDeletMutations_bitstring::_mutation_func_ptr)(void)
private

Referenced by mutate(), and set_mutation_func_ptr().

TProtoDeletMutations_bitstring* TTDeletMutations_bitstring::_myProto
private

Referenced by inherit(), and set_allele_value().

unsigned int TTDeletMutations_bitstring::_nb_hmz_mutations
private
unsigned int TTDeletMutations_bitstring::_nb_htz_mutations
private
unsigned int TTDeletMutations_bitstring::_nb_mutations
private
double TTDeletMutations_bitstring::_phenotype
private

Referenced by getValue(), and set_value().

double TTDeletMutations_bitstring::_strength
private
trait_t TTDeletMutations_bitstring::_type
private

Referenced by get_type(), and operator==().

double(TTDeletMutations_bitstring::* TTDeletMutations_bitstring::_viability_func_ptr)(void)
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