Nemo  2.4.0
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
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 mutate_noredraw_noBackMutation ()
 
void set_sequence (bitstring **seq)
 
Getters:
unsigned int get_nb_mutations () const
 
unsigned int get_nb_mut_atLocus (unsigned int loc) const
 
unsigned int get_nb_htz_mutations () const
 
unsigned int get_nb_hmz_mutations () const
 
bool get_hmz_atLocus (unsigned int loc) const
 
bool get_htz_atLocus (unsigned int loc) const
 
Setters:
void set_proto (TProtoDeletMutations_bitstring *proto)
 
void set_nb_locus (int val)
 
void set_mut_rate (double val, int nloc)
 
void set_is_continuous (bool 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)
 
Implementations
virtual void init ()
 
virtual void init_sequence ()
 
virtual void reset ()
 
virtual void * set_trait (void *value)
 
virtual void ** get_sequence () const
 
virtual unsigned int get_allele (int loc, int all) const
 
virtual double get_allele_value (int loc, int all) const
 
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 (const TTrait *mother, const TTrait *father)
 
virtual void mutate ()
 
virtual void set_value ()
 
virtual void * getValue () const
 
virtual void show_up ()
 
virtual TTDeletMutations_bitstringclone ()
 
virtual TTDeletMutations_bitstringoperator= (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 ()
 
void set_counts_and_bitstrings ()
 

Private Attributes

TProtoDeletMutations_bitstring_myProto
 
bool _is_continuous
 
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
 
double _genomic_mut_rate
 
double(TTDeletMutations_bitstring::* _viability_func_ptr )(void)
 
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr )(sex_t, bitstring *, bitstring **)
 
void(TTDeletMutations_bitstring::* _mutation_func_ptr )(void)
 

Detailed Description

Bitstring implementation of TTDeletMutations with recombination.

Constructor & Destructor Documentation

◆ TTDeletMutations_bitstring() [1/2]

TTDeletMutations_bitstring::TTDeletMutations_bitstring ( )
inline
91  _phenotype(0), _type(DELE)
92  {sequence[0] = sequence[1] = NULL;}
TProtoDeletMutations_bitstring * _myProto
Definition: ttdeletmutations_bitstring.h:50
bool _is_continuous
Definition: ttdeletmutations_bitstring.h:65
unsigned int _nb_htz_mutations
Definition: ttdeletmutations_bitstring.h:70
double _phenotype
Definition: ttdeletmutations_bitstring.h:74
bitstring * _htz
Definition: ttdeletmutations_bitstring.h:73
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:69
double _genomic_mut_rate
Definition: ttdeletmutations_bitstring.h:55
unsigned int _nb_mutations
Definition: ttdeletmutations_bitstring.h:68
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:54
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:57
trait_t _type
Definition: ttdeletmutations_bitstring.h:76
void(TTDeletMutations_bitstring::* _mutation_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:59
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:73
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:58
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:72
#define DELE
Definition: types.h:65

References sequence.

Referenced by clone().

+ Here is the caller graph for this function:

◆ TTDeletMutations_bitstring() [2/2]

TTDeletMutations_bitstring::TTDeletMutations_bitstring ( const TTDeletMutations_bitstring T)
inline

◆ ~TTDeletMutations_bitstring()

virtual TTDeletMutations_bitstring::~TTDeletMutations_bitstring ( )
inlinevirtual
103 {reset();}
virtual void reset()
Definition: ttdeletmutations_bitstring.cc:654

References reset().

Member Function Documentation

◆ clone()

virtual TTDeletMutations_bitstring* TTDeletMutations_bitstring::clone ( )
inlinevirtual

Implements TTrait.

160 {return new TTDeletMutations_bitstring(*this);}
TTDeletMutations_bitstring()
Definition: ttdeletmutations_bitstring.h:87

References TTDeletMutations_bitstring().

◆ get_allele()

unsigned int TTDeletMutations_bitstring::get_allele ( int  loc,
int  all 
) const
virtual

Implements TTrait.

695 {
696  return (*sequence[all])[loc];
697 }

References sequence.

◆ get_allele_value()

double TTDeletMutations_bitstring::get_allele_value ( int  loc,
int  all 
) const
virtual

Implements TTrait.

682 {
683  if((*sequence[all])[loc]) {
684  if(get_hmz_atLocus(loc)) return _myProto->get_effect(1, loc);
685  else return _myProto->get_effect(0, loc);
686  } else {
687  if(get_hmz_atLocus(loc)) return 0;
688  else return _myProto->get_effect(0, loc);
689  }
690 }
float get_effect(unsigned int at, unsigned int loc)
Definition: ttdeletmutations_bitstring.h:197
bool get_hmz_atLocus(unsigned int loc) const
Definition: ttdeletmutations_bitstring.h:112

References _myProto, TProtoDeletMutations_bitstring::get_effect(), get_hmz_atLocus(), and sequence.

◆ get_hmz_atLocus()

bool TTDeletMutations_bitstring::get_hmz_atLocus ( unsigned int  loc) const
inline
112 {return (*sequence[0])[loc] & (*sequence[1])[loc];}

References sequence.

Referenced by get_allele_value().

+ Here is the caller graph for this function:

◆ get_htz_atLocus()

bool TTDeletMutations_bitstring::get_htz_atLocus ( unsigned int  loc) const
inline
113 {return (*sequence[0])[loc] ^ (*sequence[1])[loc];}

References sequence.

◆ get_nb_hmz_mutations()

unsigned int TTDeletMutations_bitstring::get_nb_hmz_mutations ( ) const
inline
111 {return _nb_hmz_mutations;}

References _nb_hmz_mutations.

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

+ Here is the caller graph for this function:

◆ get_nb_htz_mutations()

unsigned int TTDeletMutations_bitstring::get_nb_htz_mutations ( ) const
inline
110 {return _nb_htz_mutations;}

References _nb_htz_mutations.

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

+ Here is the caller graph for this function:

◆ get_nb_mut_atLocus()

unsigned int TTDeletMutations_bitstring::get_nb_mut_atLocus ( unsigned int  loc) const
inline
109 {return (*sequence[0])[loc] + (*sequence[1])[loc];}

References sequence.

◆ get_nb_mutations()

unsigned int TTDeletMutations_bitstring::get_nb_mutations ( ) const
inline
108 {return _nb_mutations;}

References _nb_mutations.

Referenced by show_up().

+ Here is the caller graph for this function:

◆ get_sequence()

virtual void** TTDeletMutations_bitstring::get_sequence ( ) const
inlinevirtual

Implements TTrait.

148 {return (void**)&sequence[0];}

References sequence.

Referenced by TTDeletMutBitstrSH::setDeletStats().

+ Here is the caller graph for this function:

◆ get_type()

virtual trait_t TTDeletMutations_bitstring::get_type ( ) const
inlinevirtual

Implements TTrait.

154 {return _type;}

References _type.

◆ getValue()

virtual void* TTDeletMutations_bitstring::getValue ( ) const
inlinevirtual

Implements TTrait.

158 {return (void*)&_phenotype;}

References _phenotype.

Referenced by show_up().

+ Here is the caller graph for this function:

◆ inherit()

void TTDeletMutations_bitstring::inherit ( const TTrait mother,
const TTrait father 
)
virtual

Implements TTrait.

758 {
759  bitstring** mother_seq = (bitstring**)mother->get_sequence();
760  bitstring** father_seq = (bitstring**)father->get_sequence();
761 
762  (_myProto->* _inherit_func_ptr) (FEM, sequence[FEM], mother_seq);
763 
764  (_myProto->* _inherit_func_ptr) (MAL, sequence[MAL], father_seq);
765 }
virtual void ** get_sequence() const =0
sequence accessor.
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
@ FEM
Definition: types.h:36
@ MAL
Definition: types.h:36

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

◆ init()

void TTDeletMutations_bitstring::init ( )
virtual

Implements TTrait.

638 {
639  if(sequence[0] != NULL)
640  fatal("TTDeletMutations_bitstring::init::sequence[0] is not NULL !\n");
641 
642  if(sequence[1] != NULL)
643  fatal("TTDeletMutations_bitstring::init::sequence[1] is not NULL !\n");
644 
645  sequence[0] = new bitstring(_nb_locus);
646  sequence[1] = new bitstring(_nb_locus);
647 
648  _htz = new bitstring(_nb_locus);
649  _hmz = new bitstring(_nb_locus);
650 }
void fatal(const char *str,...)
Definition: output.cc:99

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

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

+ Here is the caller graph for this function:

◆ init_sequence()

void TTDeletMutations_bitstring::init_sequence ( )
virtual

Implements TTrait.

725 {
726  if(sequence[0] == NULL) sequence[0] = new bitstring(_nb_locus);
727 
728  if(sequence[1] == NULL) sequence[1] = new bitstring(_nb_locus);
729 
730  unsigned int nb_mut, locus;
731 
732  sequence[0]->reset();
733  sequence[1]->reset();
734 
735  if(_myProto->get_init_freq() != 0) {
736 
737  nb_mut = (unsigned int)(_myProto->get_init_freq()*_nb_locus*2);
738 
739  for(unsigned int i = 0; i < nb_mut; i++) {
740 
741  do {
742  locus = RAND::Uniform( _nb_locus );
743  //check if the locus is not already homozygote:
744  } while( (*sequence[0])[ locus ] && (*sequence[1])[ locus ] );
745 
746  if((*sequence[0])[ locus ])
747  sequence[1]->set(locus);
748  else
749  sequence[0]->set(locus);
750  }
751 
752  }
753 }
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:126
double get_init_freq()
Definition: ttdeletmutations_bitstring.h:192
void set(size_t n)
Set a bit to 1.
Definition: bitstring.h:335
void reset(size_t length)
Definition: bitstring.h:139

References _myProto, _nb_locus, TProtoDeletMutations_bitstring::get_init_freq(), bitstring::reset(), sequence, bitstring::set(), and RAND::Uniform().

◆ mutate()

virtual void TTDeletMutations_bitstring::mutate ( )
inlinevirtual

Implements TTrait.

156 {(this->*_mutation_func_ptr)();}

References _mutation_func_ptr.

◆ mutate_noredraw()

void TTDeletMutations_bitstring::mutate_noredraw ( )
799 {
800  unsigned int NbMut, mut_locus, mut_chrom;
801 
802  NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
803 
804  while(NbMut != 0) {
805 
806  mut_locus = RAND::Uniform( _nb_locus ); // choose the locus that is going to mutate
807  mut_chrom = RAND::RandBool(); // which chromosome of the two will we mutate
808 
809  // has it already mutated in the past?
810  if( (*sequence[mut_chrom])[mut_locus] ) {
811 
812  // true if there is already a mutation there because that would =1
813  // maybe backmutate (this has a reduced prob)
814  // draw a new rand num and if of some value, proceed with backmutation
815 
817  { // by default, 1% of the time do a backmutation once we get here
818 
819  //backmutate:
820  sequence[mut_chrom]->flip(mut_locus); // change to the other number at that locus (0 to 1 or vice versa)
821 
822  }
823 
824  } else {
825  // or forward mutate
826  sequence[mut_chrom]->set(mut_locus);
827  }
828 
829  NbMut--;
830  }
831 }
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:219
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:164
double get_backmutation_rate()
Definition: ttdeletmutations_bitstring.h:187
void flip(size_t n)
Flip the bit at n.
Definition: bitstring.h:346

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

Referenced by set_mutation_func_ptr().

+ Here is the caller graph for this function:

◆ mutate_noredraw_noBackMutation()

void TTDeletMutations_bitstring::mutate_noredraw_noBackMutation ( )
836 {
837  unsigned int NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
838 
839  while(NbMut != 0) {
840 
842 
843  NbMut--;
844  }
845 
846 }

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

Referenced by set_mutation_func_ptr().

+ Here is the caller graph for this function:

◆ mutate_redraw()

void TTDeletMutations_bitstring::mutate_redraw ( )
771 {
772  unsigned int NbMut, mutLocus;
773 
774  NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
775 
776  if( (int)_nb_hmz_mutations - (int)NbMut < 0 ) NbMut -= _nb_hmz_mutations;
777 
778  while(NbMut != 0) {
779 
780  do {
781  mutLocus = RAND::Uniform( _nb_locus );
782  //check if the locus is not already homozygote:
783  } while( (*sequence[0])[mutLocus] && (*sequence[1])[mutLocus] );
784 
785  if ( !( (*sequence[0])[mutLocus] || (*sequence[1])[mutLocus] ) )
786  sequence[RAND::RandBool()]->set(mutLocus);
787  else if((*sequence[0])[mutLocus])
788  sequence[1]->set(mutLocus);
789  else
790  sequence[0]->set(mutLocus);
791 
792  NbMut--;
793  }
794 }

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

+ Here is the caller graph for this function:

◆ operator!=()

bool TTDeletMutations_bitstring::operator!= ( const TTrait T)
virtual

Implements TTrait.

586 {
587  if(!((*this) == T))
588  return true;
589  else
590  return false;
591 }

◆ operator=()

TTDeletMutations_bitstring & TTDeletMutations_bitstring::operator= ( const TTrait T)
virtual

Implements TTrait.

548 {
549  const TTDeletMutations_bitstring& TD = dynamic_cast<const TTDeletMutations_bitstring&> (T);
550 
551  if(this != &TD) {
552 
553  _nb_locus = TD._nb_locus;
554 
555  //deallocate any previous sequence memory:
556  reset();
557 
558  //allocate sequence memory:
559  init();
560 
561  //copy sequence:
562  sequence[0]->copy(*TD.sequence[0]);
563  sequence[1]->copy(*TD.sequence[1]);
564 
565  set_value();
566  }
567  return *this;
568 }
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:46
virtual void set_value()
Definition: ttdeletmutations_bitstring.cc:850
virtual void init()
Definition: ttdeletmutations_bitstring.cc:637
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:360

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

◆ operator==()

bool TTDeletMutations_bitstring::operator== ( const TTrait T)
virtual

Implements TTrait.

573 {
574  if( _type != T.get_type() ) return false;
575 
576  const TTDeletMutations_bitstring& TD = dynamic_cast<const TTDeletMutations_bitstring&> (T);
577  if(this != &TD) {
578  if(_nb_locus != TD._nb_locus) return false;
579  }
580  return true;
581 }
virtual trait_t get_type() const =0
type accessor.

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

◆ reset()

void TTDeletMutations_bitstring::reset ( )
virtual

Implements TTrait.

655 {
656  if(sequence[0] != NULL) delete sequence[0];
657  if(sequence[1] != NULL) delete sequence[1];
658 
659  sequence[0] = NULL;
660  sequence[1] = NULL;
661 
662  if(_htz != NULL) delete _htz;
663  _htz = 0;
664 
665  if(_hmz != NULL) delete _hmz;
666  _hmz = 0;
667 }

References _hmz, _htz, and sequence.

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

+ Here is the caller graph for this function:

◆ retrieve_data()

bool TTDeletMutations_bitstring::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

1001 {
1002  size_t wnb = sequence[0]->nb_words();
1003  size_t bytes = wnb * sizeof(bitstring::_ul);
1004  bitstring::_ul *srce = new bitstring::_ul [wnb];
1005 
1006  reader->read(srce, bytes);
1007  sequence[0]->set_data(srce,wnb);
1008 
1009  reader->read(srce, bytes);
1010  sequence[1]->set_data(srce,wnb);
1011 
1012  delete [] srce;
1013 
1014  return true;
1015 }
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:220
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:349
size_t nb_words() const
Definition: bitstring.h:163

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

◆ set_allele_value()

void TTDeletMutations_bitstring::set_allele_value ( unsigned int  locus,
unsigned int  allele,
double  value 
)
virtual

Implements TTrait.

703 {
704  assert(locus < _nb_locus && allele < 2);
705 
706  sequence[allele]->set(locus);
707 
708  _myProto->set_effect(1, locus, (float)value);
709 
710  double dom;
711 
712  if(_myProto->get_dominance_model() == 1)
713  dom = exp(-1.0*_myProto->get_effect(1, locus)*(-1.0*log(2*_myProto->get_dominance()) / _myProto->get_strength()))/2.0; //scaling of h on s
714  else dom = _myProto->get_dominance();
715 
716  //heterozygote effect: hs
717  _myProto->set_effect(0, locus, (float)(dom * _myProto->get_effect(1, locus)) );
718 
719 }
double get_dominance()
Definition: ttdeletmutations_bitstring.h:189
int get_dominance_model()
Definition: ttdeletmutations_bitstring.h:190
void set_effect(unsigned int at, unsigned int loc, float val)
Definition: ttdeletmutations_bitstring.h:203
double get_strength()
Definition: ttdeletmutations_bitstring.h:188

References _myProto, _nb_locus, TProtoDeletMutations_bitstring::get_dominance(), TProtoDeletMutations_bitstring::get_dominance_model(), TProtoDeletMutations_bitstring::get_effect(), TProtoDeletMutations_bitstring::get_strength(), sequence, bitstring::set(), and TProtoDeletMutations_bitstring::set_effect().

◆ set_counts_and_bitstrings()

void TTDeletMutations_bitstring::set_counts_and_bitstrings ( )
private
888 {
889  unsigned int hmz_cnt = 0, htz_cnt = 0;
890  size_t nw = sequence[0]->nb_words();
891  for (size_t w = 0; w < nw; ++w) {
892  auto w0 = *sequence[0]->getword_atIdx(w);
893  auto w1 = *sequence[1]->getword_atIdx(w);
894  auto hmz_word = w0 & w1;
895  auto htz_word = w0 ^ w1;
896  *_hmz->getword_atIdx(w) = hmz_word;
897  *_htz->getword_atIdx(w) = htz_word;
898  hmz_cnt += __builtin_popcountl(hmz_word);
899  htz_cnt += __builtin_popcountl(htz_word);
900  }
901  _nb_hmz_mutations = hmz_cnt;
902  _nb_htz_mutations = htz_cnt;
903  _nb_mutations = 2 * hmz_cnt + htz_cnt;
904 }
_ul * getword_atIdx(size_t index) const
Definition: bitstring.h:158

References _hmz, _htz, _nb_hmz_mutations, _nb_htz_mutations, _nb_mutations, bitstring::getword_atIdx(), bitstring::nb_words(), and sequence.

Referenced by set_value().

+ Here is the caller graph for this function:

◆ set_effects()

static void TTDeletMutations_bitstring::set_effects ( float **  fx)
static

◆ set_inherit_func_ptr()

void TTDeletMutations_bitstring::set_inherit_func_ptr ( void(TProtoDeletMutations_bitstring::*)(sex_t, bitstring *, bitstring **)  theFunc)
inline
125  {_inherit_func_ptr = theFunc;}

References _inherit_func_ptr.

Referenced by TProtoDeletMutations_bitstring::hatch().

+ Here is the caller graph for this function:

◆ set_is_continuous()

void TTDeletMutations_bitstring::set_is_continuous ( bool  val)
inline
122 {_is_continuous = val;}

References _is_continuous.

Referenced by TProtoDeletMutations_bitstring::hatch().

+ Here is the caller graph for this function:

◆ set_mut_rate()

void TTDeletMutations_bitstring::set_mut_rate ( double  val,
int  nloc 
)
inline
121 {_genomic_mut_rate = 2*nloc*val;}

References _genomic_mut_rate.

Referenced by TProtoDeletMutations_bitstring::hatch().

+ Here is the caller graph for this function:

◆ set_mutation_func_ptr()

void TTDeletMutations_bitstring::set_mutation_func_ptr ( unsigned int  m_model)
619 {
620  switch(m_model) {
621  case 1:
622  {
623  if(_myProto->get_backmutation_rate() != 0)
625  else
627  break;
628  }
629  case 2:
631  break;
632  }
633 }
void mutate_noredraw_noBackMutation()
Definition: ttdeletmutations_bitstring.cc:835
void mutate_redraw()
Definition: ttdeletmutations_bitstring.cc:770
void mutate_noredraw()
Definition: ttdeletmutations_bitstring.cc:798

References _mutation_func_ptr, _myProto, TProtoDeletMutations_bitstring::get_backmutation_rate(), mutate_noredraw(), mutate_noredraw_noBackMutation(), and mutate_redraw().

Referenced by TProtoDeletMutations_bitstring::hatch().

+ Here is the caller graph for this function:

◆ set_nb_hmz_mutations()

void TTDeletMutations_bitstring::set_nb_hmz_mutations ( )
private
880 {
881  (*_hmz) = *sequence[0] & *sequence[1];
883 }
unsigned int count()
Count number of set bits.
Definition: bitstring.h:258

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

◆ set_nb_htz_mutations()

void TTDeletMutations_bitstring::set_nb_htz_mutations ( )
private
872 {
873  (*_htz) = *sequence[0] ^ *sequence[1];
875 }

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

◆ set_nb_locus()

void TTDeletMutations_bitstring::set_nb_locus ( int  val)
inline
120 {_nb_locus = val;}

References _nb_locus.

Referenced by TProtoDeletMutations_bitstring::hatch().

+ Here is the caller graph for this function:

◆ set_nb_mutations()

void TTDeletMutations_bitstring::set_nb_mutations ( )
private
865 {
866  _nb_mutations = sequence[0]->count() + sequence[1]->count();
867 }

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

◆ set_proto()

void TTDeletMutations_bitstring::set_proto ( TProtoDeletMutations_bitstring proto)
inline
119 {_myProto = proto;}

References _myProto.

Referenced by TProtoDeletMutations_bitstring::hatch().

+ Here is the caller graph for this function:

◆ set_recomb_template()

static void TTDeletMutations_bitstring::set_recomb_template ( unsigned int  size)
static

◆ set_sequence() [1/2]

void TTDeletMutations_bitstring::set_sequence ( bitstring **  seq)
672 {
673  reset();
674  init();
675  sequence[0]->copy(*seq[0]);
676  sequence[1]->copy(*seq[1]);
677 }

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

Referenced by TTDeletMutBitstrFH::FHread().

+ Here is the caller graph for this function:

◆ set_sequence() [2/2]

virtual void TTDeletMutations_bitstring::set_sequence ( void **  seq)
inlinevirtual

Implements TTrait.

153 {}

◆ set_trait()

virtual void* TTDeletMutations_bitstring::set_trait ( void *  value)
inlinevirtual

Implements TTrait.

147 {return NULL;}

◆ set_value()

void TTDeletMutations_bitstring::set_value ( )
virtual

Implements TTrait.

851 {
852  if (_is_continuous) {
854  } else {
858  }
859  _phenotype = (this->*_viability_func_ptr)();
860 }
void set_counts_and_bitstrings()
Definition: ttdeletmutations_bitstring.cc:887
unsigned int count_xor(const bitstring &other) const
Fused XOR popcount: count set bits in (this XOR other).
Definition: bitstring.h:308
unsigned int count_and(const bitstring &mask) const
Masked popcount: count set bits in (this AND mask).
Definition: bitstring.h:299

References _is_continuous, _nb_hmz_mutations, _nb_htz_mutations, _nb_mutations, _phenotype, _viability_func_ptr, bitstring::count_and(), bitstring::count_xor(), sequence, and set_counts_and_bitstrings().

Referenced by TTDeletMutBitstrFH::FHread(), operator=(), and show_up().

+ Here is the caller graph for this function:

◆ set_viability_func_ptr()

void TTDeletMutations_bitstring::set_viability_func_ptr ( unsigned int  f_model,
bool  is_cont 
)
595  {
596  switch(f_model) {
597  case 1:
598  {
599  if(is_cont)
601  else
603  break;
604  }
605  case 2:
606  {
607  if(is_cont)
609  else
611  break;
612  }
613  }
614 }
double viability_multi()
Definition: ttdeletmutations_bitstring.cc:908
double viability_epist_continuous()
Definition: ttdeletmutations_bitstring.cc:958
double viability_multi_continuous()
Definition: ttdeletmutations_bitstring.cc:926
double viability_epist()
Definition: ttdeletmutations_bitstring.cc:918

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

Referenced by TProtoDeletMutations_bitstring::hatch().

+ Here is the caller graph for this function:

◆ show_up()

void TTDeletMutations_bitstring::show_up ( )
virtual

Implements TTrait.

1021 {
1022  set_value();
1023  std::cout<<"\n Trait type: delet"
1024  <<"\n value: "<<*(double*)getValue()
1025  <<"\nnb mutations: "<<get_nb_mutations()
1026  <<"\n nb hmz mut: "<<get_nb_hmz_mutations()
1027  <<"\n nb htz mut: "<<get_nb_htz_mutations()
1028  <<"\n sequence: "<<std::endl;
1029  cout<<"0: ";
1030  for(unsigned int i = 0; i < _nb_locus && i < 64; i++)
1031  cout<<(*sequence[0])[i];
1032  cout<<"\n1: ";
1033  for(unsigned int i = 0; i < _nb_locus && i < 64; i++)
1034  cout<<(*sequence[1])[i];
1035  cout<<endl;
1036 }
unsigned int get_nb_mutations() const
Definition: ttdeletmutations_bitstring.h:108
virtual void * getValue() const
Definition: ttdeletmutations_bitstring.h:158
unsigned int get_nb_htz_mutations() const
Definition: ttdeletmutations_bitstring.h:110
unsigned int get_nb_hmz_mutations() const
Definition: ttdeletmutations_bitstring.h:111

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

◆ store_data()

void TTDeletMutations_bitstring::store_data ( BinaryStorageBuffer saver)
virtual

Implements StorableComponent.

989 {
990  size_t wnb = sequence[0]->nb_words();
991  size_t bytes = sizeof(bitstring::_ul);
992 
993  for(size_t i = 0; i < wnb; i++)
994  saver->store(sequence[0]->getword_atIdx(i), bytes);
995 
996  for(size_t i = 0; i < wnb; i++)
997  saver->store(sequence[1]->getword_atIdx(i), bytes);
998 }
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:37

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

◆ viability_epist()

double TTDeletMutations_bitstring::viability_epist ( )
919 {
920  //w = 1 - s(hmz + h*htz)
922 }
double get_fitness_scaling_factor()
Definition: ttdeletmutations_bitstring.h:193

References _myProto, _nb_hmz_mutations, _nb_htz_mutations, TProtoDeletMutations_bitstring::get_dominance(), TProtoDeletMutations_bitstring::get_fitness_scaling_factor(), and TProtoDeletMutations_bitstring::get_strength().

Referenced by set_viability_func_ptr().

+ Here is the caller graph for this function:

◆ viability_epist_continuous()

double TTDeletMutations_bitstring::viability_epist_continuous ( )
959 {
960  //w = 1 - sum_i(s_i*hmz_i + hs_i*htz_i)
961  //sparse iteration: only visit set bits (mutated loci) using ctz
962  double fitness = 1.0;
963  float** effects = _myProto->get_effects();
964 
965  for (size_t w = 0; w < _hmz->nb_words(); ++w) {
966  auto word = *_hmz->getword_atIdx(w);
967  while (word) {
968  unsigned int bit = __builtin_ctzl(word);
969  unsigned int locus = w * BITS_PER_WORD + bit;
970  fitness -= effects[1][locus];
971  word &= word - 1;
972  }
973  }
974 
975  for (size_t w = 0; w < _htz->nb_words(); ++w) {
976  auto word = *_htz->getword_atIdx(w);
977  while (word) {
978  unsigned int bit = __builtin_ctzl(word);
979  unsigned int locus = w * BITS_PER_WORD + bit;
980  fitness -= effects[0][locus];
981  word &= word - 1;
982  }
983  }
984 
985  return fitness * _myProto->get_fitness_scaling_factor();
986 }
#define BITS_PER_WORD
Definition: bitstring.h:40
float ** get_effects() const
Definition: ttdeletmutations_bitstring.h:196

References _hmz, _htz, _myProto, BITS_PER_WORD, TProtoDeletMutations_bitstring::get_effects(), TProtoDeletMutations_bitstring::get_fitness_scaling_factor(), bitstring::getword_atIdx(), and bitstring::nb_words().

Referenced by set_viability_func_ptr().

+ Here is the caller graph for this function:

◆ viability_multi()

double TTDeletMutations_bitstring::viability_multi ( )
909 {
910  //w = (1-s)^hmz * (1-hs)^htz
911  return ( pow( 1.0 - _myProto->get_strength(), (double)_nb_hmz_mutations ) *
912  pow( 1.0 - (_myProto->get_dominance() * _myProto->get_strength()), (double)_nb_htz_mutations) *
914 }

References _myProto, _nb_hmz_mutations, _nb_htz_mutations, TProtoDeletMutations_bitstring::get_dominance(), TProtoDeletMutations_bitstring::get_fitness_scaling_factor(), and TProtoDeletMutations_bitstring::get_strength().

Referenced by set_viability_func_ptr().

+ Here is the caller graph for this function:

◆ viability_multi_continuous()

double TTDeletMutations_bitstring::viability_multi_continuous ( )
927 {
928  //w = prod_i (1-s_i)^hmz_i * (1-hs_i)^htz_i
929  //sparse iteration: only visit set bits (mutated loci) using ctz
930  double fitness = 1.0;
931  float** effects = _myProto->get_effects();
932 
933  for (size_t w = 0; w < _hmz->nb_words(); ++w) {
934  auto word = *_hmz->getword_atIdx(w);
935  while (word) {
936  unsigned int bit = __builtin_ctzl(word);
937  unsigned int locus = w * BITS_PER_WORD + bit;
938  fitness *= (1.0f - effects[1][locus]);
939  word &= word - 1;
940  }
941  }
942 
943  for (size_t w = 0; w < _htz->nb_words(); ++w) {
944  auto word = *_htz->getword_atIdx(w);
945  while (word) {
946  unsigned int bit = __builtin_ctzl(word);
947  unsigned int locus = w * BITS_PER_WORD + bit;
948  fitness *= (1.0f - effects[0][locus]);
949  word &= word - 1;
950  }
951  }
952 
953  return fitness * _myProto->get_fitness_scaling_factor();
954 }

References _hmz, _htz, _myProto, BITS_PER_WORD, TProtoDeletMutations_bitstring::get_effects(), TProtoDeletMutations_bitstring::get_fitness_scaling_factor(), bitstring::getword_atIdx(), and bitstring::nb_words().

Referenced by set_viability_func_ptr().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _genomic_mut_rate

double TTDeletMutations_bitstring::_genomic_mut_rate
private

◆ _hmz

◆ _htz

◆ _inherit_func_ptr

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

Referenced by inherit(), and set_inherit_func_ptr().

◆ _is_continuous

bool TTDeletMutations_bitstring::_is_continuous
private

Referenced by set_is_continuous(), and set_value().

◆ _mutation_func_ptr

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

Referenced by mutate(), and set_mutation_func_ptr().

◆ _myProto

◆ _nb_hmz_mutations

unsigned int TTDeletMutations_bitstring::_nb_hmz_mutations
private

◆ _nb_htz_mutations

unsigned int TTDeletMutations_bitstring::_nb_htz_mutations
private

◆ _nb_locus

◆ _nb_mutations

unsigned int TTDeletMutations_bitstring::_nb_mutations
private

◆ _phenotype

double TTDeletMutations_bitstring::_phenotype
private

Referenced by getValue(), and set_value().

◆ _type

trait_t TTDeletMutations_bitstring::_type
private

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

◆ _viability_func_ptr

double(TTDeletMutations_bitstring::* TTDeletMutations_bitstring::_viability_func_ptr) (void)
private

◆ sequence


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

Generated for Nemo v2.4.0 by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR