Nemo  2.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
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:

List of all members.

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 inherit_0 (TTrait *mother, TTrait *father)
void inherit_low (TTrait *mother, TTrait *father)
void inherit_free (TTrait *mother, TTrait *father)
void recombine (unsigned int strand, bitstring **parent_seq)
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_nb_locus (int val)
void set_mut_rate (double val, int nloc)
void set_recomb_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 (double r_rate)
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 ()
 Called to allocate the trait's genotypic sequences.
virtual void init_sequence ()
 Called at the start of each replicate, sets the initial genotypes.
virtual void reset ()
 Called at the end of each simulation/replicate, deallocates sequence memory.
virtual void * set_trait (void *value)
 Called to set the phenotypic to a particular value or to give context-dependant value(s) to the trait.
virtual void ** get_sequence () const
 sequence accessor.
virtual void * get_allele (int loc, int all) const
 Called to read one allele value at a particular locus.
virtual void set_sequence (void **seq)
 Called to set the sequence pointer to an existing trait.
virtual trait_t get_type () const
 type accessor.
virtual void inherit (TTrait *mother, TTrait *father)
 Inheritance procedure, creates a new trait from mother's and father's traits.
virtual void mutate ()
 Mutation procedure, perform mutations on the genes sequence.
virtual void set_value ()
 Tells the trait to set its phenotype from genotype, should be used instead of getValue().
virtual void * getValue ()
 Genotype to phenotype mapper.
virtual void show_up ()
 Writes some info to stdout.
virtual
TTDeletMutations_bitstring
clone ()
 Returns a copy of itself.
virtual
TTDeletMutations_bitstring
operator= (const TTrait &T)
 Copies the complete state of the trait from right to left side of the operator, sequence data included.
virtual bool operator== (const TTrait &T)
 Checks for parameters equivalence, not genetic equivalence.
virtual bool operator!= (const TTrait &T)
virtual void store_data (BinaryStorageBuffer *saver)
 Interface to store the component data (e.g. gene values) into a binary buffer.
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 Interface to retrieve the same data from the binary buffer.

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

static unsigned int * _rSites = 0
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 _recomb_rate
double _recomb_mean
double _strength
double _dominance
bool _continuous_effects
double(TTDeletMutations_bitstring::* _viability_func_ptr )(void)
void(TTDeletMutations_bitstring::* _inherit_func_ptr )(TTrait *, TTrait *)
void(TTDeletMutations_bitstring::* _mutation_func_ptr )(void)

Static Private Attributes

static float ** _effects = NULL
static unsigned int * _recomb_template = 0
static unsigned char * _sites = 0

Detailed Description

Bitstring implementation of TTDeletMutations with recombination.

Definition at line 46 of file ttdeletmutations_bitstring.h.


Constructor & Destructor Documentation

TTDeletMutations_bitstring::TTDeletMutations_bitstring ( ) [inline]
TTDeletMutations_bitstring::TTDeletMutations_bitstring ( const TTDeletMutations_bitstring T) [inline]
virtual TTDeletMutations_bitstring::~TTDeletMutations_bitstring ( ) [inline, virtual]

Definition at line 103 of file ttdeletmutations_bitstring.h.

References reset().

{reset();}

Member Function Documentation

virtual TTDeletMutations_bitstring* TTDeletMutations_bitstring::clone ( ) [inline, virtual]

Returns a copy of itself.

Note: call the copy constructor of the trait which should only copy the parameters values not the complete state of the trait (i.e. shallow copy). The copy of the sequence data is made through the assignement operator!

Implements TTrait.

Definition at line 163 of file ttdeletmutations_bitstring.h.

References TTDeletMutations_bitstring().

{return new TTDeletMutations_bitstring(*this);}
virtual void* TTDeletMutations_bitstring::get_allele ( int  loc,
int  all 
) const [inline, virtual]

Called to read one allele value at a particular locus.

Returns:
the allelic value at position 'all' at locus 'loc'
Parameters:
loclocus position in the sequence
allwhich allele we want to read the value from

Implements TTrait.

Definition at line 155 of file ttdeletmutations_bitstring.h.

{return NULL;}
float** TTDeletMutations_bitstring::get_effects ( ) const [inline]

Definition at line 114 of file ttdeletmutations_bitstring.h.

References _effects.

{return _effects;}
bool TTDeletMutations_bitstring::get_hmz_atLocus ( unsigned int  loc) [inline]

Definition at line 112 of file ttdeletmutations_bitstring.h.

References sequence.

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

Definition at line 113 of file ttdeletmutations_bitstring.h.

References sequence.

{return (*sequence[0])[loc] ^ (*sequence[1])[loc];}
unsigned int TTDeletMutations_bitstring::get_nb_hmz_mutations ( ) [inline]

Definition at line 111 of file ttdeletmutations_bitstring.h.

References _nb_hmz_mutations.

Referenced by show_up().

unsigned int TTDeletMutations_bitstring::get_nb_htz_mutations ( ) [inline]

Definition at line 110 of file ttdeletmutations_bitstring.h.

References _nb_htz_mutations.

Referenced by show_up().

unsigned int TTDeletMutations_bitstring::get_nb_mut_atLocus ( unsigned int  loc) [inline]

Definition at line 109 of file ttdeletmutations_bitstring.h.

References sequence.

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

Definition at line 108 of file ttdeletmutations_bitstring.h.

References _nb_mutations.

Referenced by show_up().

{return _nb_mutations;}
virtual void** TTDeletMutations_bitstring::get_sequence ( ) const [inline, virtual]

sequence accessor.

Returns:
the sequence pointer

Implements TTrait.

Definition at line 154 of file ttdeletmutations_bitstring.h.

References sequence.

{return (void**)&sequence[0];}
virtual trait_t TTDeletMutations_bitstring::get_type ( ) const [inline, virtual]

type accessor.

Returns:
the trait's type

Implements TTrait.

Definition at line 157 of file ttdeletmutations_bitstring.h.

References _type.

{return _type;}
virtual void* TTDeletMutations_bitstring::getValue ( ) [inline, virtual]

Genotype to phenotype mapper.

Returns:
the phenotype computed from the genotype

Implements TTrait.

Definition at line 161 of file ttdeletmutations_bitstring.h.

References _phenotype.

Referenced by show_up().

{return &_phenotype;}
virtual void TTDeletMutations_bitstring::inherit ( TTrait mother,
TTrait father 
) [inline, virtual]

Inheritance procedure, creates a new trait from mother's and father's traits.

Parameters:
motherthe mother's trait
fatherthe father's trait

Implements TTrait.

Definition at line 158 of file ttdeletmutations_bitstring.h.

References _inherit_func_ptr.

{ (this->*_inherit_func_ptr) ( mother, father );}
void TTDeletMutations_bitstring::inherit_0 ( TTrait mother,
TTrait father 
)

Definition at line 546 of file ttdeletmutations_bitstring.cc.

References bitstring::copy(), TTrait::get_sequence(), RAND::RandBool(), and sequence.

Referenced by set_inherit_func_ptr().

{   
  bitstring** mother_seq = (bitstring**)mother->get_sequence();
  bitstring** father_seq = (bitstring**)father->get_sequence();
  sequence[0]->copy( *mother_seq[RAND::RandBool()] );
  sequence[1]->copy( *father_seq[RAND::RandBool()] );
}
void TTDeletMutations_bitstring::inherit_free ( TTrait mother,
TTrait father 
)

Definition at line 556 of file ttdeletmutations_bitstring.cc.

References _nb_locus, TTrait::get_sequence(), RAND::RandBool(), and sequence.

Referenced by set_inherit_func_ptr().

{   
  bitstring** mother_seq = (bitstring**)mother->get_sequence();
  bitstring** father_seq = (bitstring**)father->get_sequence();
  
  bitstring htz(_nb_locus);

  htz = *mother_seq[0] ^ *mother_seq[1]; //set bits to true at deleterious heterozygote loci
  
  bool flipper = RAND::RandBool();
  unsigned int prev = 0;
  //mother's gamete:
  for(unsigned int i = 0; i < _nb_locus; ) {

//    if(htz[i]) flipper = flipper ^ RAND::RandBool();
//    (*sequence[0])[i] = (*mother_seq[ flipper ])[i];
    
    prev = i;
    //we skip homozygous loci
    while(!htz[i++] && i < _nb_locus);
    
    (*sequence[0]).copy(*mother_seq[ flipper ], prev, i);
    
    flipper = flipper ^ RAND::RandBool(); 
    
  }
  
  htz = *father_seq[0] ^ *father_seq[1];
  
  flipper = RAND::RandBool();
  //father's gamete:
  for(unsigned int i = 0; i < _nb_locus; ) {
    
//    if(htz[i]) flipper = flipper ^ RAND::RandBool();
//    (*sequence[1])[i] = (*father_seq[ flipper ])[i];

    prev = i;
    
    while(!htz[i++] && i < _nb_locus);
    
    (*sequence[1]).copy(*father_seq[ flipper ], prev, i);
    
    flipper = flipper ^ RAND::RandBool(); 

  }
  
}
void TTDeletMutations_bitstring::inherit_low ( TTrait mother,
TTrait father 
)

Definition at line 606 of file ttdeletmutations_bitstring.cc.

References TTrait::get_sequence(), and recombine().

Referenced by set_inherit_func_ptr().

{
  recombine(0, (bitstring**)mother->get_sequence());
  recombine(1, (bitstring**)father->get_sequence());
}
void TTDeletMutations_bitstring::init ( ) [virtual]

Called to allocate the trait's genotypic sequences.

Called each time a new Individual is created (Individual::init())

Implements TTrait.

Definition at line 473 of file ttdeletmutations_bitstring.cc.

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

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

{  
  if(sequence[0] != NULL) fatal("TTDeletMutations_bitstring::init::sequence[0] is not NULL !\n"); 
  if(sequence[1] != NULL) fatal("TTDeletMutations_bitstring::init::sequence[1] is not NULL !\n");
  
  sequence[0] = new bitstring(_nb_locus);
  sequence[1] = new bitstring(_nb_locus);

  _htz = new bitstring(_nb_locus);
  _hmz = new bitstring(_nb_locus);
}
void TTDeletMutations_bitstring::init_sequence ( ) [virtual]

Called at the start of each replicate, sets the initial genotypes.

Called by Individual::create().

Implements TTrait.

Definition at line 513 of file ttdeletmutations_bitstring.cc.

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

{
  if(sequence[0] == NULL) sequence[0] = new bitstring(_nb_locus);
  
  if(sequence[1] == NULL) sequence[1] = new bitstring(_nb_locus);
  
  unsigned int nb_mut, locus;
  
  sequence[0]->reset();
  sequence[1]->reset();
    
  if(_init_freq != 0) {
    
        nb_mut = (unsigned int)(_init_freq*_nb_locus*2);
    
    for(unsigned int i = 0; i < nb_mut; i++) {
      
      do {
      locus = RAND::Uniform( _nb_locus );
      //check if the locus is not already homozygote:
      } while( (*sequence[0])[ locus ] && (*sequence[1])[ locus ] );
      
      if((*sequence[0])[ locus ])
        sequence[1]->set(locus);
      else
        sequence[0]->set(locus);
    }
    
  }
}
virtual void TTDeletMutations_bitstring::mutate ( ) [inline, virtual]

Mutation procedure, perform mutations on the genes sequence.

Implements TTrait.

Definition at line 159 of file ttdeletmutations_bitstring.h.

References _mutation_func_ptr.

{(this->*_mutation_func_ptr)();}
void TTDeletMutations_bitstring::mutate_noredraw ( )

Definition at line 690 of file ttdeletmutations_bitstring.cc.

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

Referenced by set_mutation_func_ptr().

{
  unsigned int NbMut;
  
  NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
  
  while(NbMut != 0) {  
    
    sequence[RAND::RandBool()]->set(  RAND::Uniform( _nb_locus ) );
    
        NbMut--;
  }
}
void TTDeletMutations_bitstring::mutate_redraw ( )

Definition at line 664 of file ttdeletmutations_bitstring.cc.

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

Referenced by set_mutation_func_ptr().

{
  unsigned int NbMut, mutLocus;
  
  NbMut = (unsigned int)RAND::Poisson(_genomic_mut_rate);
  
  if( (int)_nb_hmz_mutations - (int)NbMut < 0 ) NbMut -= _nb_hmz_mutations;
  
  while(NbMut != 0) {  
        
        do { 
      mutLocus = RAND::Uniform( _nb_locus );
      //check if the locus is not already homozygote:
    } while( (*sequence[0])[mutLocus] && (*sequence[1])[mutLocus] );
    
    if((*sequence[0])[mutLocus])
      sequence[1]->set(mutLocus);
    else
      sequence[0]->set(mutLocus);
    
        NbMut--;
  }
}
bool TTDeletMutations_bitstring::operator!= ( const TTrait T) [virtual]

Implements TTrait.

Definition at line 416 of file ttdeletmutations_bitstring.cc.

{
  if(!((*this) == T))
    return true;
  else
    return false;
}
TTDeletMutations_bitstring & TTDeletMutations_bitstring::operator= ( const TTrait ) [virtual]

Copies the complete state of the trait from right to left side of the operator, sequence data included.

Implements TTrait.

Definition at line 371 of file ttdeletmutations_bitstring.cc.

References _continuous_effects, _dominance, _fitness_model, _fitness_scaling_factor, _inherit_func_ptr, _init_freq, _mut_rate, _nb_locus, _recomb_mean, _recomb_rate, _strength, _viability_func_ptr, bitstring::copy(), init(), reset(), sequence, and set_value().

{
  const TTDeletMutations_bitstring& TD = dynamic_cast<const TTDeletMutations_bitstring&> (T);
  if(this != &TD) {
    
    _nb_locus = TD._nb_locus;
    _fitness_model = TD._fitness_model;
    _fitness_scaling_factor = TD._fitness_scaling_factor;
    _init_freq = TD._init_freq;
    _mut_rate = TD._mut_rate;
    _recomb_rate = TD._recomb_rate;
    _recomb_mean = TD._recomb_mean;
    _strength = TD._strength;
    _dominance = TD._dominance;
    _continuous_effects = TD._continuous_effects;
    _viability_func_ptr = TD._viability_func_ptr;
    _inherit_func_ptr = TD._inherit_func_ptr;
    //deallocate any previous sequence memory:
    reset();
    //allocate sequence memory:
    init();
    //copy sequence:
    sequence[0]->copy(*TD.sequence[0]);
    sequence[1]->copy(*TD.sequence[1]);
    
    set_value();
  }
  return *this;
}
bool TTDeletMutations_bitstring::operator== ( const TTrait ) [virtual]

Checks for parameters equivalence, not genetic equivalence.

Implements TTrait.

Definition at line 403 of file ttdeletmutations_bitstring.cc.

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

{
  if(_type.compare(T.get_type()) != 0) return false;
  
  const TTDeletMutations_bitstring& TD = dynamic_cast<const TTDeletMutations_bitstring&> (T);
  if(this != &TD) {
    if(_nb_locus != TD._nb_locus) return false;
  }
  return true;
}
void TTDeletMutations_bitstring::recombine ( unsigned int  strand,
bitstring **  parent_seq 
) [inline]

Definition at line 614 of file ttdeletmutations_bitstring.cc.

References _nb_locus, _recomb_mean, _recomb_template, _rSites, _sites, bitstring::copy(), RAND::Poisson(), RAND::RandBool(), sequence, and RAND::Uniform().

Referenced by inherit_low().

{
  
  register unsigned int rs, rSize, tmp;
  register unsigned int nbRec, prev;
  static size_t _mem_size = _nb_locus*sizeof(unsigned int);

  memcpy(_rSites, _recomb_template, _mem_size);
  memset(_sites, 0, _nb_locus);
  
  rSize = _nb_locus - 1;
  
  //create partental gamete:
  do {
    nbRec = (unsigned int)RAND::Poisson( _recomb_mean );
  } while ( nbRec > rSize);
  
  
  for(unsigned int i = 0; i < nbRec; i++) {
    rs = RAND::Uniform(rSize);
    rSize--;
    tmp = _rSites[rs];
    _rSites[rs] = _rSites[rSize];
    _sites[tmp] = 1;
  }
  
  bool flipper = RAND::RandBool();
  
  if(nbRec == 0) {
    
    sequence[strand]->copy(*parent_seq[flipper]);
  
  } else {
    
    for(unsigned int i = 0; i < _nb_locus;) {
      
      prev = i;
      
      while(!_sites[i++] && i < _nb_locus);
      
      sequence[strand]->copy( *parent_seq[flipper], prev, i);
      
      flipper = !flipper;
      
    }
  }
}
void TTDeletMutations_bitstring::reset ( ) [virtual]

Called at the end of each simulation/replicate, deallocates sequence memory.

Implements TTrait.

Definition at line 487 of file ttdeletmutations_bitstring.cc.

References _hmz, _htz, and sequence.

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

{
  if(sequence[0] != NULL) delete sequence[0];
  if(sequence[1] != NULL) delete sequence[1];

  sequence[0] = NULL;
  sequence[1] = NULL; 
  
  if(_htz != NULL) delete _htz;
  _htz = 0;
  
  if(_hmz != NULL) delete _hmz;
  _hmz = 0;
}
bool TTDeletMutations_bitstring::retrieve_data ( BinaryStorageBuffer reader) [virtual]

Interface to retrieve the same data from the binary buffer.

Implements StorableComponent.

Definition at line 794 of file ttdeletmutations_bitstring.cc.

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

{
  size_t wnb = sequence[0]->nb_words();
  size_t bytes = wnb * sizeof(bitstring::_ul);
  bitstring::_ul *srce = new bitstring::_ul [wnb];
  
  reader->read(srce, bytes); 
  sequence[0]->set_data(srce,wnb);
  
  reader->read(srce, bytes);
  sequence[1]->set_data(srce,wnb);
  
  return true;
}
void TTDeletMutations_bitstring::set_continuous_effects ( bool  val) [inline]
void TTDeletMutations_bitstring::set_dominance ( double  val) [inline]

Definition at line 122 of file ttdeletmutations_bitstring.h.

References _dominance.

Referenced by TProtoDeletMutations_bitstring::hatch().

{_dominance = val;}
void TTDeletMutations_bitstring::set_effects ( float **  fx) [static]

Definition at line 42 of file ttdeletmutations_bitstring.cc.

References _effects.

{_effects = fx;}
void TTDeletMutations_bitstring::set_fitness_model ( int  val) [inline]

Definition at line 128 of file ttdeletmutations_bitstring.h.

References _fitness_model.

Referenced by TProtoDeletMutations_bitstring::hatch().

{_fitness_model = val;}
void TTDeletMutations_bitstring::set_fitness_scaling_factor ( double  val) [inline]
void TTDeletMutations_bitstring::set_inherit_func_ptr ( double  r_rate)
void TTDeletMutations_bitstring::set_init_freq ( double  val) [inline]

Definition at line 127 of file ttdeletmutations_bitstring.h.

References _init_freq.

Referenced by TProtoDeletMutations_bitstring::hatch().

{_init_freq = val;}
void TTDeletMutations_bitstring::set_mut_rate ( double  val,
int  nloc 
) [inline]

Definition at line 119 of file ttdeletmutations_bitstring.h.

References _genomic_mut_rate, and _mut_rate.

Referenced by TProtoDeletMutations_bitstring::hatch().

void TTDeletMutations_bitstring::set_mutation_func_ptr ( unsigned int  m_model)
void TTDeletMutations_bitstring::set_nb_hmz_mutations ( ) [private]

Definition at line 731 of file ttdeletmutations_bitstring.cc.

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

Referenced by set_value(), and show_up().

{
  (*_hmz) = *sequence[0] & *sequence[1];
  _nb_hmz_mutations = _hmz->count();
}
void TTDeletMutations_bitstring::set_nb_htz_mutations ( ) [private]

Definition at line 723 of file ttdeletmutations_bitstring.cc.

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

Referenced by set_value(), and show_up().

{
  (*_htz) = *sequence[0] ^ *sequence[1];
  _nb_htz_mutations = _htz->count();
}
void TTDeletMutations_bitstring::set_nb_locus ( int  val) [inline]

Definition at line 118 of file ttdeletmutations_bitstring.h.

References _nb_locus.

Referenced by TProtoDeletMutations_bitstring::hatch().

{_nb_locus = val;}
void TTDeletMutations_bitstring::set_nb_mutations ( ) [private]

Definition at line 716 of file ttdeletmutations_bitstring.cc.

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

Referenced by set_value(), and show_up().

{
  _nb_mutations = sequence[0]->count() + sequence[1]->count();
}
void TTDeletMutations_bitstring::set_recomb_rate ( double  val,
int  nloc 
) [inline]
void TTDeletMutations_bitstring::set_recomb_template ( unsigned int  size) [static]

Definition at line 46 of file ttdeletmutations_bitstring.cc.

References _recomb_template, _rSites, and _sites.

Referenced by TProtoDeletMutations_bitstring::setParameters().

{
  if(_recomb_template != NULL) delete [] _recomb_template;
  _recomb_template = new unsigned int [size];
  if(_rSites != NULL) delete [] _rSites;
  _rSites = new unsigned int [size];
  if(_sites != NULL) delete [] _sites;
  _sites = new unsigned char [size];
  for(unsigned int i = 0; i < size; ++i) _recomb_template[i] = i;
}
void TTDeletMutations_bitstring::set_sequence ( bitstring **  seq)

Definition at line 504 of file ttdeletmutations_bitstring.cc.

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

Referenced by TTDeletMutBitstrFH::FHread().

{
  reset(); init();
  sequence[0]->copy(*seq[0]);
  sequence[1]->copy(*seq[1]);
}
virtual void TTDeletMutations_bitstring::set_sequence ( void **  seq) [inline, virtual]

Called to set the sequence pointer to an existing trait.

Parameters:
seqthe existing sequence pointer

Implements TTrait.

Definition at line 156 of file ttdeletmutations_bitstring.h.

{}
void TTDeletMutations_bitstring::set_strength ( double  val) [inline]

Definition at line 121 of file ttdeletmutations_bitstring.h.

References _strength.

Referenced by TProtoDeletMutations_bitstring::hatch().

{_strength = val;}
virtual void* TTDeletMutations_bitstring::set_trait ( void *  value) [inline, virtual]

Called to set the phenotypic to a particular value or to give context-dependant value(s) to the trait.

Parameters:
valuethe value passed to the trait
Returns:
the argument passed

Implements TTrait.

Definition at line 153 of file ttdeletmutations_bitstring.h.

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

Tells the trait to set its phenotype from genotype, should be used instead of getValue().

Implements TTrait.

Definition at line 706 of file ttdeletmutations_bitstring.cc.

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

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

void TTDeletMutations_bitstring::set_viability_func_ptr ( unsigned int  f_model,
bool  is_cont 
)
void TTDeletMutations_bitstring::show_up ( ) [virtual]

Writes some info to stdout.

Implements TTrait.

Definition at line 812 of file ttdeletmutations_bitstring.cc.

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

{
  set_nb_mutations();
  set_nb_hmz_mutations();
  set_nb_htz_mutations();
  set_value();
  std::cout<<"\n  Trait type: delet"
  <<"\n       value: "<<*(double*)getValue()
  <<"\nnb mutations: "<<get_nb_mutations()
  <<"\n  nb hmz mut: "<<get_nb_hmz_mutations()
  <<"\n  nb htz mut: "<<get_nb_htz_mutations()
  <<"\n    sequence: "<<std::endl;
  cout<<"0: ";
 for(unsigned int i = 0; i < _nb_locus && i < 64; i++)
   cout<<(*sequence[0])[i];
 cout<<"\n1: ";
 for(unsigned int i = 0; i < _nb_locus && i < 64; i++)
   cout<<(*sequence[1])[i];
 cout<<endl;
}
void TTDeletMutations_bitstring::store_data ( BinaryStorageBuffer saver) [virtual]

Interface to store the component data (e.g. gene values) into a binary buffer.

Implements StorableComponent.

Definition at line 782 of file ttdeletmutations_bitstring.cc.

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

{
  size_t wnb = sequence[0]->nb_words();
  size_t bytes = sizeof(bitstring::_ul);
  
  for(size_t i = 0; i < wnb; i++) 
    saver->store(sequence[0]->getword_atIdx(i), bytes);

  for(size_t i = 0; i < wnb; i++) 
    saver->store(sequence[1]->getword_atIdx(i), bytes);
}
double TTDeletMutations_bitstring::viability_epist ( )
double TTDeletMutations_bitstring::viability_epist_continuous ( )

Definition at line 771 of file ttdeletmutations_bitstring.cc.

References _effects, _fitness_scaling_factor, _hmz, and _nb_locus.

Referenced by set_viability_func_ptr().

{
  //w = 1 - s(hmz + h*htz)
  double fitness = 1.0;
  
  for(unsigned int i = 0; i < _nb_locus; ++i)
      fitness -= (*_hmz)[i]*_effects[1][i] + (*_htz)[i]*_effects[0][i];
  
  return fitness * _fitness_scaling_factor;
}
double TTDeletMutations_bitstring::viability_multi ( )

Definition at line 739 of file ttdeletmutations_bitstring.cc.

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

Referenced by set_viability_func_ptr().

{
  //w = (1-s)^hmz * (1-hs)^htz
  return ( pow( 1.0 - _strength, (double)_nb_hmz_mutations ) *
                   pow( 1.0 - (_dominance * _strength), (double)_nb_htz_mutations) *
                   _fitness_scaling_factor );
}
double TTDeletMutations_bitstring::viability_multi_continuous ( )

Definition at line 757 of file ttdeletmutations_bitstring.cc.

References _effects, _fitness_scaling_factor, _hmz, and _nb_locus.

Referenced by set_viability_func_ptr().

{
  //w = (1-s)^hmz * (1-hs)^htz
  double fitness = 1.0;
  
  for(unsigned int i = 0; i < _nb_locus; ++i)
    //_effects[0] stores hs, _effects[1] stores s
    fitness *= (1.0f - (*_hmz)[i]*_effects[1][i]) * (1.0f - (*_htz)[i]*_effects[0][i]);
  
  return fitness * _fitness_scaling_factor;
}

Member Data Documentation

Definition at line 59 of file ttdeletmutations_bitstring.h.

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

float ** TTDeletMutations_bitstring::_effects = NULL [static, private]

Definition at line 51 of file ttdeletmutations_bitstring.h.

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

Definition at line 55 of file ttdeletmutations_bitstring.h.

Referenced by mutate_noredraw(), mutate_redraw(), and set_mut_rate().

Definition at line 75 of file ttdeletmutations_bitstring.h.

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

void(TTDeletMutations_bitstring::* TTDeletMutations_bitstring::_inherit_func_ptr)(TTrait *, TTrait *) [private]

Definition at line 61 of file ttdeletmutations_bitstring.h.

Referenced by inherit(), operator=(), and set_inherit_func_ptr().

Definition at line 53 of file ttdeletmutations_bitstring.h.

Referenced by init_sequence(), operator=(), and set_init_freq().

Definition at line 54 of file ttdeletmutations_bitstring.h.

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

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

Definition at line 62 of file ttdeletmutations_bitstring.h.

Referenced by mutate(), and set_mutation_func_ptr().

unsigned int TTDeletMutations_bitstring::_nb_locus [private]

Definition at line 70 of file ttdeletmutations_bitstring.h.

Referenced by get_nb_mutations(), and set_nb_mutations().

Definition at line 76 of file ttdeletmutations_bitstring.h.

Referenced by getValue(), and set_value().

Definition at line 56 of file ttdeletmutations_bitstring.h.

Referenced by operator=(), recombine(), and set_recomb_rate().

Definition at line 56 of file ttdeletmutations_bitstring.h.

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

unsigned int * TTDeletMutations_bitstring::_recomb_template = 0 [static, private]

Definition at line 66 of file ttdeletmutations_bitstring.h.

Referenced by recombine(), and set_recomb_template().

unsigned int * TTDeletMutations_bitstring::_rSites = 0 [private]

Definition at line 66 of file ttdeletmutations_bitstring.h.

Referenced by recombine(), and set_recomb_template().

unsigned char * TTDeletMutations_bitstring::_sites = 0 [static, private]

Definition at line 67 of file ttdeletmutations_bitstring.h.

Referenced by recombine(), and set_recomb_template().

Definition at line 78 of file ttdeletmutations_bitstring.h.

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

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

Definition at line 60 of file ttdeletmutations_bitstring.h.

Referenced by operator=(), set_value(), and set_viability_func_ptr().


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

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