Nemo  2.4.0b
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
92  _phenotype(0), _type(DELE)
93  {sequence[0] = sequence[1] = NULL;}
TProtoDeletMutations_bitstring * _myProto
Definition: ttdeletmutations_bitstring.h:51
bool _is_continuous
Definition: ttdeletmutations_bitstring.h:66
unsigned int _nb_htz_mutations
Definition: ttdeletmutations_bitstring.h:71
double _phenotype
Definition: ttdeletmutations_bitstring.h:75
bitstring * _htz
Definition: ttdeletmutations_bitstring.h:74
unsigned int _nb_hmz_mutations
Definition: ttdeletmutations_bitstring.h:70
double _genomic_mut_rate
Definition: ttdeletmutations_bitstring.h:56
unsigned int _nb_mutations
Definition: ttdeletmutations_bitstring.h:69
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:55
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:58
trait_t _type
Definition: ttdeletmutations_bitstring.h:77
void(TTDeletMutations_bitstring::* _mutation_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:60
bitstring * _hmz
Definition: ttdeletmutations_bitstring.h:74
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:59
bitstring * sequence[2]
Definition: ttdeletmutations_bitstring.h:73
#define DELE
Definition: types.h:66

References sequence.

Referenced by clone().

◆ TTDeletMutations_bitstring() [2/2]

TTDeletMutations_bitstring::TTDeletMutations_bitstring ( const TTDeletMutations_bitstring T)
inline

◆ ~TTDeletMutations_bitstring()

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

References reset().

Member Function Documentation

◆ clone()

virtual TTDeletMutations_bitstring* TTDeletMutations_bitstring::clone ( )
inlinevirtual

Implements TTrait.

161 {return new TTDeletMutations_bitstring(*this);}
TTDeletMutations_bitstring()
Definition: ttdeletmutations_bitstring.h:88

References TTDeletMutations_bitstring().

◆ get_allele()

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

Implements TTrait.

681 {
682  return (*sequence[all])[loc];
683 }

References sequence.

◆ get_allele_value()

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

Implements TTrait.

668 {
669  if((*sequence[all])[loc]) {
670  if(get_hmz_atLocus(loc)) return _myProto->get_effect(1, loc);
671  else return _myProto->get_effect(0, loc);
672  } else {
673  if(get_hmz_atLocus(loc)) return 0;
674  else return _myProto->get_effect(0, loc);
675  }
676 }
float get_effect(unsigned int at, unsigned int loc)
Definition: ttdeletmutations_bitstring.h:198
bool get_hmz_atLocus(unsigned int loc) const
Definition: ttdeletmutations_bitstring.h:113

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
113 {return (*sequence[0])[loc] & (*sequence[1])[loc];}

References sequence.

Referenced by get_allele_value().

◆ get_htz_atLocus()

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

References sequence.

◆ get_nb_hmz_mutations()

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

References _nb_hmz_mutations.

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

◆ get_nb_htz_mutations()

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

References _nb_htz_mutations.

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

◆ get_nb_mut_atLocus()

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

References sequence.

◆ get_nb_mutations()

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

References _nb_mutations.

Referenced by show_up().

◆ get_sequence()

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

Implements TTrait.

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

References sequence.

Referenced by TTDeletMutBitstrSH::setDeletStats().

◆ get_type()

virtual trait_t TTDeletMutations_bitstring::get_type ( ) const
inlinevirtual

Implements TTrait.

155 {return _type;}

References _type.

◆ getValue()

virtual void* TTDeletMutations_bitstring::getValue ( ) const
inlinevirtual

Implements TTrait.

159 {return (void*)&_phenotype;}

References _phenotype.

Referenced by show_up().

◆ inherit()

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

Implements TTrait.

744 {
745  bitstring** mother_seq = (bitstring**)mother->get_sequence();
746  bitstring** father_seq = (bitstring**)father->get_sequence();
747 
748  (_myProto->* _inherit_func_ptr) (FEM, sequence[FEM], mother_seq);
749 
750  (_myProto->* _inherit_func_ptr) (MAL, sequence[MAL], father_seq);
751 }
virtual void ** get_sequence() const =0
sequence accessor.
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:57
@ FEM
Definition: types.h:37
@ MAL
Definition: types.h:37

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

◆ init()

void TTDeletMutations_bitstring::init ( )
virtual

Implements TTrait.

624 {
625  if(sequence[0] != NULL)
626  fatal("TTDeletMutations_bitstring::init::sequence[0] is not NULL !\n");
627 
628  if(sequence[1] != NULL)
629  fatal("TTDeletMutations_bitstring::init::sequence[1] is not NULL !\n");
630 
631  sequence[0] = new bitstring(_nb_locus);
632  sequence[1] = new bitstring(_nb_locus);
633 
634  _htz = new bitstring(_nb_locus);
635  _hmz = new bitstring(_nb_locus);
636 }
void fatal(const char *str,...)
Definition: output.cc:100

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

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

◆ init_sequence()

void TTDeletMutations_bitstring::init_sequence ( )
virtual

Implements TTrait.

711 {
712  if(sequence[0] == NULL) sequence[0] = new bitstring(_nb_locus);
713 
714  if(sequence[1] == NULL) sequence[1] = new bitstring(_nb_locus);
715 
716  unsigned int nb_mut, locus;
717 
718  sequence[0]->reset();
719  sequence[1]->reset();
720 
721  if(_myProto->get_init_freq() != 0) {
722 
723  nb_mut = (unsigned int)(_myProto->get_init_freq()*_nb_locus*2);
724 
725  for(unsigned int i = 0; i < nb_mut; i++) {
726 
727  do {
728  locus = RAND::Uniform( _nb_locus );
729  //check if the locus is not already homozygote:
730  } while( (*sequence[0])[ locus ] && (*sequence[1])[ locus ] );
731 
732  if((*sequence[0])[ locus ])
733  sequence[1]->set(locus);
734  else
735  sequence[0]->set(locus);
736  }
737 
738  }
739 }
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:127
double get_init_freq()
Definition: ttdeletmutations_bitstring.h:193
void set(size_t n)
Set a bit to 1.
Definition: bitstring.h:336
void reset(size_t length)
Definition: bitstring.h:140

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.

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

References _mutation_func_ptr.

◆ mutate_noredraw()

void TTDeletMutations_bitstring::mutate_noredraw ( )
785 {
786  unsigned int NbMut, mut_locus, mut_chrom;
787 
788  NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
789 
790  while(NbMut != 0) {
791 
792  mut_locus = RAND::Uniform( _nb_locus ); // choose the locus that is going to mutate
793  mut_chrom = RAND::RandBool(); // which chromosome of the two will we mutate
794 
795  // has it already mutated in the past?
796  if( (*sequence[mut_chrom])[mut_locus] ) {
797 
798  // true if there is already a mutation there because that would =1
799  // maybe backmutate (this has a reduced prob)
800  // draw a new rand num and if of some value, proceed with backmutation
801 
803  { // by default, 1% of the time do a backmutation once we get here
804 
805  //backmutate:
806  sequence[mut_chrom]->flip(mut_locus); // change to the other number at that locus (0 to 1 or vice versa)
807 
808  }
809 
810  } else {
811  // or forward mutate
812  sequence[mut_chrom]->set(mut_locus);
813  }
814 
815  NbMut--;
816  }
817 }
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:222
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:165
double get_backmutation_rate()
Definition: ttdeletmutations_bitstring.h:188
void flip(size_t n)
Flip the bit at n.
Definition: bitstring.h:347

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

◆ mutate_noredraw_noBackMutation()

void TTDeletMutations_bitstring::mutate_noredraw_noBackMutation ( )
822 {
823  unsigned int NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
824 
825  while(NbMut != 0) {
826 
828 
829  NbMut--;
830  }
831 
832 }

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

Referenced by set_mutation_func_ptr().

◆ mutate_redraw()

void TTDeletMutations_bitstring::mutate_redraw ( )
757 {
758  unsigned int NbMut, mutLocus;
759 
760  NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
761 
762  if( (int)_nb_hmz_mutations - (int)NbMut < 0 ) NbMut -= _nb_hmz_mutations;
763 
764  while(NbMut != 0) {
765 
766  do {
767  mutLocus = RAND::Uniform( _nb_locus );
768  //check if the locus is not already homozygote:
769  } while( (*sequence[0])[mutLocus] && (*sequence[1])[mutLocus] );
770 
771  if ( !( (*sequence[0])[mutLocus] || (*sequence[1])[mutLocus] ) )
772  sequence[RAND::RandBool()]->set(mutLocus);
773  else if((*sequence[0])[mutLocus])
774  sequence[1]->set(mutLocus);
775  else
776  sequence[0]->set(mutLocus);
777 
778  NbMut--;
779  }
780 }

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

◆ operator!=()

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

Implements TTrait.

572 {
573  if(!((*this) == T))
574  return true;
575  else
576  return false;
577 }

◆ operator=()

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

Implements TTrait.

534 {
535  const TTDeletMutations_bitstring& TD = dynamic_cast<const TTDeletMutations_bitstring&> (T);
536 
537  if(this != &TD) {
538 
539  _nb_locus = TD._nb_locus;
540 
541  //deallocate any previous sequence memory:
542  reset();
543 
544  //allocate sequence memory:
545  init();
546 
547  //copy sequence:
548  sequence[0]->copy(*TD.sequence[0]);
549  sequence[1]->copy(*TD.sequence[1]);
550 
551  set_value();
552  }
553  return *this;
554 }
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:47
virtual void set_value()
Definition: ttdeletmutations_bitstring.cc:836
virtual void init()
Definition: ttdeletmutations_bitstring.cc:623
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:361

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

◆ operator==()

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

Implements TTrait.

559 {
560  if( _type != T.get_type() ) return false;
561 
562  const TTDeletMutations_bitstring& TD = dynamic_cast<const TTDeletMutations_bitstring&> (T);
563  if(this != &TD) {
564  if(_nb_locus != TD._nb_locus) return false;
565  }
566  return true;
567 }
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.

641 {
642  if(sequence[0] != NULL) delete sequence[0];
643  if(sequence[1] != NULL) delete sequence[1];
644 
645  sequence[0] = NULL;
646  sequence[1] = NULL;
647 
648  if(_htz != NULL) delete _htz;
649  _htz = 0;
650 
651  if(_hmz != NULL) delete _hmz;
652  _hmz = 0;
653 }

References _hmz, _htz, and sequence.

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

◆ retrieve_data()

bool TTDeletMutations_bitstring::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

987 {
988  size_t wnb = sequence[0]->nb_words();
989  size_t bytes = wnb * sizeof(bitstring::_ul);
990  bitstring::_ul *srce = new bitstring::_ul [wnb];
991 
992  reader->read(srce, bytes);
993  sequence[0]->set_data(srce,wnb);
994 
995  reader->read(srce, bytes);
996  sequence[1]->set_data(srce,wnb);
997 
998  delete [] srce;
999 
1000  return true;
1001 }
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:162
unsigned long _ul
Definition: bitstring.h:61
void set_data(_ul *srce, size_t nbwrd)
Copy bits from an array of unsigned long words.
Definition: bitstring.h:350
size_t nb_words() const
Definition: bitstring.h:164

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.

689 {
690  assert(locus < _nb_locus && allele < 2);
691 
692  sequence[allele]->set(locus);
693 
694  _myProto->set_effect(1, locus, (float)value);
695 
696  double dom;
697 
698  if(_myProto->get_dominance_model() == 1)
699  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
700  else dom = _myProto->get_dominance();
701 
702  //heterozygote effect: hs
703  _myProto->set_effect(0, locus, (float)(dom * _myProto->get_effect(1, locus)) );
704 
705 }
double get_dominance()
Definition: ttdeletmutations_bitstring.h:190
int get_dominance_model()
Definition: ttdeletmutations_bitstring.h:191
void set_effect(unsigned int at, unsigned int loc, float val)
Definition: ttdeletmutations_bitstring.h:204
double get_strength()
Definition: ttdeletmutations_bitstring.h:189

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
874 {
875  unsigned int hmz_cnt = 0, htz_cnt = 0;
876  size_t nw = sequence[0]->nb_words();
877  for (size_t w = 0; w < nw; ++w) {
878  auto w0 = *sequence[0]->getword_atIdx(w);
879  auto w1 = *sequence[1]->getword_atIdx(w);
880  auto hmz_word = w0 & w1;
881  auto htz_word = w0 ^ w1;
882  *_hmz->getword_atIdx(w) = hmz_word;
883  *_htz->getword_atIdx(w) = htz_word;
884  hmz_cnt += __builtin_popcountl(hmz_word);
885  htz_cnt += __builtin_popcountl(htz_word);
886  }
887  _nb_hmz_mutations = hmz_cnt;
888  _nb_htz_mutations = htz_cnt;
889  _nb_mutations = 2 * hmz_cnt + htz_cnt;
890 }
_ul * getword_atIdx(size_t index) const
Definition: bitstring.h:159

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

Referenced by set_value().

◆ 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
126  {_inherit_func_ptr = theFunc;}

References _inherit_func_ptr.

Referenced by TProtoDeletMutations_bitstring::hatch().

◆ set_is_continuous()

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

References _is_continuous.

Referenced by TProtoDeletMutations_bitstring::hatch().

◆ set_mut_rate()

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

References _genomic_mut_rate.

Referenced by TProtoDeletMutations_bitstring::hatch().

◆ set_mutation_func_ptr()

void TTDeletMutations_bitstring::set_mutation_func_ptr ( unsigned int  m_model)
605 {
606  switch(m_model) {
607  case 1:
608  {
609  if(_myProto->get_backmutation_rate() != 0)
611  else
613  break;
614  }
615  case 2:
617  break;
618  }
619 }
void mutate_noredraw_noBackMutation()
Definition: ttdeletmutations_bitstring.cc:821
void mutate_redraw()
Definition: ttdeletmutations_bitstring.cc:756
void mutate_noredraw()
Definition: ttdeletmutations_bitstring.cc:784

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

Referenced by TProtoDeletMutations_bitstring::hatch().

◆ set_nb_hmz_mutations()

void TTDeletMutations_bitstring::set_nb_hmz_mutations ( )
private
866 {
867  (*_hmz) = *sequence[0] & *sequence[1];
869 }
unsigned int count()
Count number of set bits.
Definition: bitstring.h:259

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

◆ set_nb_htz_mutations()

void TTDeletMutations_bitstring::set_nb_htz_mutations ( )
private
858 {
859  (*_htz) = *sequence[0] ^ *sequence[1];
861 }

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

◆ set_nb_locus()

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

References _nb_locus.

Referenced by TProtoDeletMutations_bitstring::hatch().

◆ set_nb_mutations()

void TTDeletMutations_bitstring::set_nb_mutations ( )
private
851 {
852  _nb_mutations = sequence[0]->count() + sequence[1]->count();
853 }

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

◆ set_proto()

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

References _myProto.

Referenced by TProtoDeletMutations_bitstring::hatch().

◆ 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)
658 {
659  reset();
660  init();
661  sequence[0]->copy(*seq[0]);
662  sequence[1]->copy(*seq[1]);
663 }

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

Referenced by TTDeletMutBitstrFH::FHread().

◆ set_sequence() [2/2]

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

Implements TTrait.

154 {}

◆ set_trait()

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

Implements TTrait.

148 {return NULL;}

◆ set_value()

void TTDeletMutations_bitstring::set_value ( )
virtual

Implements TTrait.

837 {
838  if (_is_continuous) {
840  } else {
844  }
845  _phenotype = (this->*_viability_func_ptr)();
846 }
void set_counts_and_bitstrings()
Definition: ttdeletmutations_bitstring.cc:873
unsigned int count_xor(const bitstring &other) const
Fused XOR popcount: count set bits in (this XOR other).
Definition: bitstring.h:309
unsigned int count_and(const bitstring &mask) const
Masked popcount: count set bits in (this AND mask).
Definition: bitstring.h:300

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

◆ set_viability_func_ptr()

void TTDeletMutations_bitstring::set_viability_func_ptr ( unsigned int  f_model,
bool  is_cont 
)
581  {
582  switch(f_model) {
583  case 1:
584  {
585  if(is_cont)
587  else
589  break;
590  }
591  case 2:
592  {
593  if(is_cont)
595  else
597  break;
598  }
599  }
600 }
double viability_multi()
Definition: ttdeletmutations_bitstring.cc:894
double viability_epist_continuous()
Definition: ttdeletmutations_bitstring.cc:944
double viability_multi_continuous()
Definition: ttdeletmutations_bitstring.cc:912
double viability_epist()
Definition: ttdeletmutations_bitstring.cc:904

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

Referenced by TProtoDeletMutations_bitstring::hatch().

◆ show_up()

void TTDeletMutations_bitstring::show_up ( )
virtual

Implements TTrait.

1007 {
1008  set_value();
1009  std::cout<<"\n Trait type: delet"
1010  <<"\n value: "<<*(double*)getValue()
1011  <<"\nnb mutations: "<<get_nb_mutations()
1012  <<"\n nb hmz mut: "<<get_nb_hmz_mutations()
1013  <<"\n nb htz mut: "<<get_nb_htz_mutations()
1014  <<"\n sequence: "<<std::endl;
1015  cout<<"0: ";
1016  for(unsigned int i = 0; i < _nb_locus && i < 64; i++)
1017  cout<<(*sequence[0])[i];
1018  cout<<"\n1: ";
1019  for(unsigned int i = 0; i < _nb_locus && i < 64; i++)
1020  cout<<(*sequence[1])[i];
1021  cout<<endl;
1022 }
unsigned int get_nb_mutations() const
Definition: ttdeletmutations_bitstring.h:109
virtual void * getValue() const
Definition: ttdeletmutations_bitstring.h:159
unsigned int get_nb_htz_mutations() const
Definition: ttdeletmutations_bitstring.h:111
unsigned int get_nb_hmz_mutations() const
Definition: ttdeletmutations_bitstring.h:112

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.

975 {
976  size_t wnb = sequence[0]->nb_words();
977  size_t bytes = sizeof(bitstring::_ul);
978 
979  for(size_t i = 0; i < wnb; i++)
980  saver->store(sequence[0]->getword_atIdx(i), bytes);
981 
982  for(size_t i = 0; i < wnb; i++)
983  saver->store(sequence[1]->getword_atIdx(i), bytes);
984 }
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16

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

◆ viability_epist()

double TTDeletMutations_bitstring::viability_epist ( )

◆ viability_epist_continuous()

double TTDeletMutations_bitstring::viability_epist_continuous ( )
945 {
946  //w = 1 - sum_i(s_i*hmz_i + hs_i*htz_i)
947  //sparse iteration: only visit set bits (mutated loci) using ctz
948  double fitness = 1.0;
949  float** effects = _myProto->get_effects();
950 
951  for (size_t w = 0; w < _hmz->nb_words(); ++w) {
952  auto word = *_hmz->getword_atIdx(w);
953  while (word) {
954  unsigned int bit = __builtin_ctzl(word);
955  unsigned int locus = w * BITS_PER_WORD + bit;
956  fitness -= effects[1][locus];
957  word &= word - 1;
958  }
959  }
960 
961  for (size_t w = 0; w < _htz->nb_words(); ++w) {
962  auto word = *_htz->getword_atIdx(w);
963  while (word) {
964  unsigned int bit = __builtin_ctzl(word);
965  unsigned int locus = w * BITS_PER_WORD + bit;
966  fitness -= effects[0][locus];
967  word &= word - 1;
968  }
969  }
970 
971  return fitness * _myProto->get_fitness_scaling_factor();
972 }
#define BITS_PER_WORD
Definition: bitstring.h:41
float ** get_effects() const
Definition: ttdeletmutations_bitstring.h:197

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

◆ viability_multi()

double TTDeletMutations_bitstring::viability_multi ( )

◆ viability_multi_continuous()

double TTDeletMutations_bitstring::viability_multi_continuous ( )
913 {
914  //w = prod_i (1-s_i)^hmz_i * (1-hs_i)^htz_i
915  //sparse iteration: only visit set bits (mutated loci) using ctz
916  double fitness = 1.0;
917  float** effects = _myProto->get_effects();
918 
919  for (size_t w = 0; w < _hmz->nb_words(); ++w) {
920  auto word = *_hmz->getword_atIdx(w);
921  while (word) {
922  unsigned int bit = __builtin_ctzl(word);
923  unsigned int locus = w * BITS_PER_WORD + bit;
924  fitness *= (1.0f - effects[1][locus]);
925  word &= word - 1;
926  }
927  }
928 
929  for (size_t w = 0; w < _htz->nb_words(); ++w) {
930  auto word = *_htz->getword_atIdx(w);
931  while (word) {
932  unsigned int bit = __builtin_ctzl(word);
933  unsigned int locus = w * BITS_PER_WORD + bit;
934  fitness *= (1.0f - effects[0][locus]);
935  word &= word - 1;
936  }
937  }
938 
939  return fitness * _myProto->get_fitness_scaling_factor();
940 }

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

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.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR