Nemo  2.4.0b
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
TProtoDeletMutations_bitstring Class Reference

Prototype class of the bitstring-deleterious mutations trait class. More...

#include <ttdeletmutations_bitstring.h>

+ Inheritance diagram for TProtoDeletMutations_bitstring:
+ Collaboration diagram for TProtoDeletMutations_bitstring:

Public Member Functions

 TProtoDeletMutations_bitstring ()
 
 TProtoDeletMutations_bitstring (const TProtoDeletMutations_bitstring &T)
 
 ~TProtoDeletMutations_bitstring ()
 
Getters
int get_nb_locus ()
 
double get_mut_rate ()
 
double get_backmutation_rate ()
 
double get_strength ()
 
double get_dominance ()
 
int get_dominance_model ()
 
bool get_iscontinuous ()
 
double get_init_freq ()
 
double get_fitness_scaling_factor ()
 
float * get_s_continous ()
 
float * get_hs_continous ()
 
float ** get_effects () const
 
float get_effect (unsigned int at, unsigned int loc)
 
Setters
void set_effects ()
 
void set_effect (unsigned int at, unsigned int loc, float val)
 
double set_effects_exp ()
 
double set_effects_gamma ()
 
double set_effects_lognorm ()
 
void reset_effect_table ()
 
void write_effects_to_parameter ()
 
Parameter setters
bool setSelectionParameters ()
 
bool setEffectsFromInput ()
 
Inheritance functions
void inherit_low (sex_t SEX, bitstring *seq, bitstring **parent)
 
void inherit_free (sex_t SEX, bitstring *seq, bitstring **parent)
 
TraitPrototype implementations
virtual void init ()
 
virtual void reset ()
 
virtual TTDeletMutations_bitstringhatch ()
 
virtual TProtoDeletMutations_bitstringclone ()
 
virtual trait_t get_type () const
 
StorageComponent implementation
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
SimComponent implementation
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
- Public Member Functions inherited from TTProtoWithMap
 TTProtoWithMap ()
 
 TTProtoWithMap (const TTProtoWithMap &TP)
 
virtual ~TTProtoWithMap ()
 
void setMapIndex (unsigned int idx)
 
unsigned int getMapIndex ()
 
bool setGeneticMapParameters (string prefix)
 
void addGeneticMapParameters (string prefix)
 
bool setRecombinationMapRandom ()
 
bool setRecombinationMapNonRandom (vector< vector< double > > *lociPositions)
 
bool setRecombinationMapFixed ()
 
bool setNumLociPerChromosome (string param_name)
 
void reset_recombination_pointers ()
 
void registerGeneticMap ()
 
void unregisterFromGeneticMap ()
 
bool areGeneticMapParamSet (string prefix)
 
bool isRecombinationFree (string prefix)
 
void recordRandomMap ()
 
- Public Member Functions inherited from TraitPrototype
virtual void set_index (int idx)
 Sets the traits index. More...
 
virtual int get_index ()
 Index getter. More...
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 Sets a new ParamSet and name it. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 

Private Attributes

unsigned int _nb_locus
 
unsigned int _fitness_model
 
unsigned int _mutation_model
 
int _dominance_model
 
double _fitness_scaling_factor
 
double _init_freq
 
double _mut_rate
 
double _back_mutation_rate
 
double _strength
 
double _dominance
 
double _dist_p1
 
double _dist_p2
 
bool _continuous_effects
 
double(TTDeletMutations_bitstring::* _viability_func_ptr )(void)
 
double(TProtoDeletMutations_bitstring::* _set_effects_func )(void)
 
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr )(sex_t, bitstring *, bitstring **)
 
TTDeletMutBitstrSH_stats
 
TTDeletMutBitstrFH_writer
 
TTDeletMutBitstrFH_reader
 
float ** _effects
 

Additional Inherited Members

- Static Public Member Functions inherited from TTProtoWithMap
static void recombine (unsigned long indID)
 
- Static Public Attributes inherited from TTProtoWithMap
static GeneticMap _map
 
- Protected Attributes inherited from TTProtoWithMap
unsigned int _mapIndex
 
double _totRecombEventsMean
 
double _recombRate
 
double _mapResolution
 
unsigned int _numChromosome
 
unsigned int _numLoci
 
double * _recombRatePerChrmsm
 
unsigned int * _numLociPerChrmsm
 
unsigned int * _chrsmLength
 
unsigned int * _lociMapPositions
 
- Protected Attributes inherited from TraitPrototype
int _index
 The trait index in the Individual traits table. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Detailed Description

Prototype class of the bitstring-deleterious mutations trait class.

Constructor & Destructor Documentation

◆ TProtoDeletMutations_bitstring() [1/2]

TProtoDeletMutations_bitstring::TProtoDeletMutations_bitstring ( )
55 {
56  set_paramset("delet", false, this);
57 
58  add_parameter("delet_loci",INT,true,false,0,0);
59 
60  add_parameter("delet_mutation_rate",DBL,true,true,0,1, 0);
61  add_parameter("delet_backmutation_rate",DBL,false,true,0,1, 0);
62  add_parameter("delet_mutation_model",INT,false,true,1,2, 0);
63  add_parameter("delet_init_freq",DBL,false,true,0,1, 0);
64 
65  //genetic map parameters:
67 
68  //effects parameters
69  add_parameter("delet_effects_mean",DBL,false,false,0,1, 0);
70  add_parameter("delet_dominance_mean",DBL,false,true,0,1, 0);
71  add_parameter("delet_fitness_model",INT,false,true,1,2, 0);
72  add_parameter("delet_effects", MAT, false, false, 0, 0, 0);
73  add_parameter("delet_effects_distribution",STR,false,false,0,0, 0);
74  add_parameter("delet_effects_dist_param1",DBL,false,false,0,0, 0);
75  add_parameter("delet_effects_dist_param2",DBL,false,false,0,0, 0);
76  add_parameter("delet_fitness_scaling_factor",DBL,false,false,0,0, 0);
77  add_parameter("delet_dominance_model", INT, false, true, 1, 2, 0);
78  //for back compatibility:
79 // add_parameter("delet_sel_coef",DBL,false,true,0,1, 0);
80 // add_parameter("delet_dom_coef",DBL,false,true,0,1, 0);
81  //output parameters:
82  add_parameter("delet_save_genotype",BOOL,false,false,0,0);
83  add_parameter("delet_genot_dir",STR,false,false,0,0);
84  add_parameter("delet_genot_logtime",INT,false,false,0,0);
85 
86 }
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:86
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
TTDeletMutBitstrFH * _writer
Definition: ttdeletmutations_bitstring.h:266
unsigned int _mutation_model
Definition: ttdeletmutations_bitstring.h:250
double _strength
Definition: ttdeletmutations_bitstring.h:256
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:248
float ** _effects
Definition: ttdeletmutations_bitstring.h:268
double(TProtoDeletMutations_bitstring::* _set_effects_func)(void)
Definition: ttdeletmutations_bitstring.h:262
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:252
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:263
double _init_freq
Definition: ttdeletmutations_bitstring.h:253
double _mut_rate
Definition: ttdeletmutations_bitstring.h:254
double _dominance
Definition: ttdeletmutations_bitstring.h:257
int _dominance_model
Definition: ttdeletmutations_bitstring.h:251
double _back_mutation_rate
Definition: ttdeletmutations_bitstring.h:255
double _dist_p2
Definition: ttdeletmutations_bitstring.h:259
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:249
double _dist_p1
Definition: ttdeletmutations_bitstring.h:258
TTDeletMutBitstrFH * _reader
Definition: ttdeletmutations_bitstring.h:267
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:261
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:260
TTDeletMutBitstrSH * _stats
Definition: ttdeletmutations_bitstring.h:265
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:77
@ DBL
Definition: types.h:78
@ MAT
Definition: types.h:78
@ BOOL
Definition: types.h:78
@ STR
Definition: types.h:78
@ INT
Definition: types.h:78

References SimComponent::add_parameter(), TTProtoWithMap::addGeneticMapParameters(), BOOL, DBL, INT, MAT, SimComponent::set_paramset(), and STR.

Referenced by clone().

◆ TProtoDeletMutations_bitstring() [2/2]

TProtoDeletMutations_bitstring::TProtoDeletMutations_bitstring ( const TProtoDeletMutations_bitstring T)

◆ ~TProtoDeletMutations_bitstring()

TProtoDeletMutations_bitstring::~TProtoDeletMutations_bitstring ( )
105 {
106  if(_stats != NULL) {delete _stats; _stats = NULL;}
107  if(_reader) {delete _reader; _reader= NULL;}
108  if(_writer != NULL) {delete _writer; _writer = NULL;}
109  if(_effects != NULL) {
110  delete [] _effects[0];
111  delete [] _effects[1];
112  delete [] _effects;
113  _effects = NULL;
114  }
115 
116 }

References _effects, _reader, _stats, and _writer.

Member Function Documentation

◆ clone()

virtual TProtoDeletMutations_bitstring* TProtoDeletMutations_bitstring::clone ( )
inlinevirtual

Implements TraitPrototype.

225 {return new TProtoDeletMutations_bitstring((*this));}
TProtoDeletMutations_bitstring()
Definition: ttdeletmutations_bitstring.cc:50

References TProtoDeletMutations_bitstring().

◆ get_backmutation_rate()

double TProtoDeletMutations_bitstring::get_backmutation_rate ( )
inline

◆ get_dominance()

double TProtoDeletMutations_bitstring::get_dominance ( )
inline

◆ get_dominance_model()

int TProtoDeletMutations_bitstring::get_dominance_model ( )
inline

◆ get_effect()

float TProtoDeletMutations_bitstring::get_effect ( unsigned int  at,
unsigned int  loc 
)
inline

◆ get_effects()

float** TProtoDeletMutations_bitstring::get_effects ( ) const
inline
190 {return _effects;}

References _effects.

Referenced by resetParameterFromSource().

◆ get_fitness_scaling_factor()

◆ get_hs_continous()

float* TProtoDeletMutations_bitstring::get_hs_continous ( )
inline
189 {return _effects[0];}

References _effects.

Referenced by TTDeletMutBitstrFH::FHwrite().

◆ get_init_freq()

double TProtoDeletMutations_bitstring::get_init_freq ( )
inline
186 {return _init_freq; }

References _init_freq.

Referenced by TTDeletMutations_bitstring::init_sequence().

◆ get_iscontinuous()

bool TProtoDeletMutations_bitstring::get_iscontinuous ( )
inline

◆ get_mut_rate()

double TProtoDeletMutations_bitstring::get_mut_rate ( )
inline
180 {return _mut_rate;}

References _mut_rate.

◆ get_nb_locus()

int TProtoDeletMutations_bitstring::get_nb_locus ( )
inline

◆ get_s_continous()

float* TProtoDeletMutations_bitstring::get_s_continous ( )
inline

◆ get_strength()

◆ get_type()

virtual trait_t TProtoDeletMutations_bitstring::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

227 {return DELE;}
#define DELE
Definition: types.h:66

References DELE.

◆ hatch()

TTDeletMutations_bitstring * TProtoDeletMutations_bitstring::hatch ( )
virtual

Implements TraitPrototype.

387 {
389 
390  new_trait->set_proto(this);
391 
392  new_trait->set_nb_locus(_nb_locus);
393  new_trait->set_mut_rate(_mut_rate,_nb_locus);
394 
398 
399  return new_trait;
400 }
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:47
void set_inherit_func_ptr(void(TProtoDeletMutations_bitstring::*theFunc)(sex_t, bitstring *, bitstring **))
Definition: ttdeletmutations_bitstring.h:119
void set_mutation_func_ptr(unsigned int m_model)
Definition: ttdeletmutations_bitstring.cc:600
void set_mut_rate(double val, int nloc)
Definition: ttdeletmutations_bitstring.h:117
void set_viability_func_ptr(unsigned int f_model, bool is_cont)
Definition: ttdeletmutations_bitstring.cc:577
void set_proto(TProtoDeletMutations_bitstring *proto)
Definition: ttdeletmutations_bitstring.h:115
void set_nb_locus(int val)
Definition: ttdeletmutations_bitstring.h:116

References _continuous_effects, _fitness_model, _inherit_func_ptr, _mut_rate, _mutation_model, _nb_locus, TTDeletMutations_bitstring::set_inherit_func_ptr(), TTDeletMutations_bitstring::set_mut_rate(), TTDeletMutations_bitstring::set_mutation_func_ptr(), TTDeletMutations_bitstring::set_nb_locus(), TTDeletMutations_bitstring::set_proto(), and TTDeletMutations_bitstring::set_viability_func_ptr().

◆ inherit_free()

void TProtoDeletMutations_bitstring::inherit_free ( sex_t  SEX,
bitstring seq,
bitstring **  parent 
)
inline
405 {
406  for(unsigned int i = 0; i < _nb_locus; )
407  seq[i] = (bool)(*parent[RAND::RandBool()])[i];
408 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:162

References _nb_locus, and RAND::RandBool().

◆ inherit_low()

void TProtoDeletMutations_bitstring::inherit_low ( sex_t  SEX,
bitstring seq,
bitstring **  parent 
)
inline
413 {
414  unsigned int prevLoc = 0, cEnd = 0;
415 
416  //the table containing the loci at which x-overs happen
417  vector< pair<unsigned int, unsigned int> > recTable = _map.reduceJunctions(SEX, _mapIndex);
418 
419  //number of x-overs
420  unsigned int nbRec = recTable.size();
421 
422 #ifdef _REC_DEBUG_
423  cout << "TProtoDeletMutations_bitstring::inherit_low; nb Rec = "<<nbRec - 1<<endl;
424  cout << " --sex = "<<SEX<<"\n";
425 #endif
426 
427  unsigned int num_copied = 0;
428 
429  vector< pair<unsigned int, unsigned int> >::const_iterator xover = recTable.begin();
430 
431  while(xover != recTable.end()) {
432 
433 #ifdef _REC_DEBUG_
434  cout<< " copy seq from "<<prevLoc<<" to "<<xover->first
435  <<" ("<<(xover->first - prevLoc)<<" loc) ("
436  <<(xover->first - prevLoc)
437  <<" bits) on side "<<xover->second<<std::endl;
438 #endif
439 
440  seq->copy( *parent[ xover->second ], prevLoc, xover->first);
441 
442  prevLoc = xover->first;
443 
444  xover++;
445  }
446 
447 }
vector< pair< unsigned int, unsigned int > > reduceJunctions(sex_t SEX, unsigned int trait_idx)
Remove multiple x-over at the same locus when traits differ in number of loci.
Definition: ttrait_with_map.cc:1179
static GeneticMap _map
Definition: ttrait_with_map.h:209
unsigned int _mapIndex
Definition: ttrait_with_map.h:193
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:284

References TTProtoWithMap::_map, TTProtoWithMap::_mapIndex, bitstring::copy(), and GeneticMap::reduceJunctions().

Referenced by setParameters().

◆ init()

virtual void TProtoDeletMutations_bitstring::init ( )
inlinevirtual
219 {setParameters();};
virtual bool setParameters()
Definition: ttdeletmutations_bitstring.cc:120

References setParameters().

◆ loadFileServices()

void TProtoDeletMutations_bitstring::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

345 {
346  // --- THE READER ---
347  //always add the reader:
348  if(_reader) delete _reader;
349  _reader = new TTDeletMutBitstrFH(this);
350  //set to read mode:
352  //attach to file manager:
353  loader->attach_reader(_reader);
354 
355  //writer
356  if(get_parameter("delet_save_genotype")->isSet()) {
357 
358  if(_writer) delete _writer;
359 
360  _writer = new TTDeletMutBitstrFH(this);
361 
362  Param* param = get_parameter("delet_genot_logtime");
363 
364  if(param->isMatrix()) {
365 
366  TMatrix temp;
367  param->getMatrix(&temp);
368  _writer->set_multi(true, true, 1, &temp, get_parameter("delet_genot_dir")->getArg(), this);
369 
370  } else {
371  // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
372  _writer->set(true, true, 1, (param->isSet() ? (int)param->getValue() : 0),
373  0, get_parameter("delet_genot_dir")->getArg(),this);
374  }
375 
376  loader->attach(_writer);
377 
378  } else if(_writer != NULL) {
379  delete _writer;
380  _writer = NULL;
381  }
382 }
void set_isInputHandler(bool val)
Definition: filehandler.h:151
virtual void attach_reader(FileHandler *FH)
Attaches the FileHandler to the current list (_readers) of the FileServices.
Definition: fileservices.cc:74
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:61
This structure stores one parameter, its definition and its string argument.
Definition: param.h:54
double getValue()
Returns the argument value according to its type.
Definition: param.cc:368
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:172
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:378
bool isSet()
Definition: param.h:140
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:50
The FileHandler associated with the TTDeletMutations_bitstring trait.
Definition: ttdeletmutations_bitstring.h:343
virtual void set_multi(bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path, TP *trait_proto)
Definition: filehandler.h:244
virtual void set(bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path, TP *trait_proto)
Definition: filehandler.h:237

References _reader, _writer, FileServices::attach(), FileServices::attach_reader(), SimComponent::get_parameter(), Param::getMatrix(), Param::getValue(), Param::isMatrix(), Param::isSet(), TraitFileHandler< TP >::set(), FileHandler::set_isInputHandler(), and TraitFileHandler< TP >::set_multi().

◆ loadStatServices()

void TProtoDeletMutations_bitstring::loadStatServices ( StatServices loader)
virtual

Implements SimComponent.

334 {
335  if(_stats != NULL)
336  delete _stats;
337 
338  _stats = new TTDeletMutBitstrSH(this);
339 
340  loader->attach(_stats);
341 }// ----------------------------------------------------------------------------------------
virtual void attach(Handler *H)
attach the StatHandler to the current list (_statHandlers) of the StatServices
Definition: statservices.cc:177
The StatHandler for TTDeletMutations_bitstring.
Definition: ttdeletmutations_bitstring.h:272

References _stats, and StatServices::attach().

◆ reset()

virtual void TProtoDeletMutations_bitstring::reset ( )
inlinevirtual

Reimplemented from TTProtoWithMap.

virtual void reset()
Definition: ttrait_with_map.cc:612

References TTProtoWithMap::reset().

◆ reset_effect_table()

void TProtoDeletMutations_bitstring::reset_effect_table ( )
296 {
297  if(_effects != NULL) {
298  delete [] _effects[0];
299  delete [] _effects[1];
300  delete [] _effects;
301  }
302 
303  _effects = new float* [2];
304  _effects[0] = new float [_nb_locus];
305  _effects[1] = new float [_nb_locus];
306 
307 }

References _effects, and _nb_locus.

Referenced by resetParameterFromSource(), set_effects(), and setEffectsFromInput().

◆ resetParameterFromSource()

bool TProtoDeletMutations_bitstring::resetParameterFromSource ( std::string  param,
SimComponent cmpt 
)
virtual

Implements SimComponent.

496 {
497  TProtoDeletMutations_bitstring *srceProto = dynamic_cast< TProtoDeletMutations_bitstring* >(cmpt);
498 
499  // this works only to reset the fitness effects
500  if(param != "delet_effects") return false;
501 
502  float** efx = srceProto->get_effects();
503 
504  if(efx == NULL)
505  return error("the binary source population did not properly set the fitness effects of\
506  deleterious mutations, no effects received.\n");
507 
508  // the genetic architecture has already been checked in Metapop::loadPopFromBinarySource
509  // we can skip the check of table size
510 
511  reset_effect_table(); // deallocate and re-allocate the _effects table
512 
513  //copy effects
514  memcpy(_effects[0], efx[0], _nb_locus*sizeof(float));
515  memcpy(_effects[1], efx[1], _nb_locus*sizeof(float));
516 
517  //record effects into the parameter
519 
520  return true;
521 }
Prototype class of the bitstring-deleterious mutations trait class.
Definition: ttdeletmutations_bitstring.h:171
void reset_effect_table()
Definition: ttdeletmutations_bitstring.cc:295
void write_effects_to_parameter()
Definition: ttdeletmutations_bitstring.cc:311
float ** get_effects() const
Definition: ttdeletmutations_bitstring.h:190
int error(const char *str,...)
Definition: output.cc:77

References _effects, _nb_locus, error(), get_effects(), reset_effect_table(), and write_effects_to_parameter().

◆ retrieve_data()

bool TProtoDeletMutations_bitstring::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

466 {
467  unsigned int dummy_int;
468  reader->read(&dummy_int,sizeof(int));
469 
470  if(dummy_int != _nb_locus ){
471  warning("Deleterious mutation trait::locus number in binary source file differs from parameter value!\n\
472  >>>> adjusting locus number to match source population: %i set to %i\n", _nb_locus, dummy_int);
473  _nb_locus = dummy_int;
474  }
475 
476  char dummy_bool = 0;
477  reader->read(&dummy_bool, 1);
478 
479  if(dummy_bool != _continuous_effects) {
480  error("Deleterious mutation trait::mutation effects model in binary source file differ from parameter value!\n\
481  >>>> adjusting model to match source population: continuous = %i to continuous = %i\n",
482  _continuous_effects, (int)dummy_bool);
483  _continuous_effects = dummy_bool;
484  }
485 
486  if(_continuous_effects) {
487  reader->read(_effects[0],_nb_locus * sizeof(float));
488  reader->read(_effects[1],_nb_locus * sizeof(float));
489  }
490  return true;
491 }
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:162
void warning(const char *str,...)
Definition: output.cc:58

References _continuous_effects, _effects, _nb_locus, error(), BinaryStorageBuffer::read(), and warning().

◆ set_effect()

void TProtoDeletMutations_bitstring::set_effect ( unsigned int  at,
unsigned int  loc,
float  val 
)
inline
197 {_effects[at][loc] = val;}

References _effects.

Referenced by TTDeletMutBitstrFH::FHread(), and TTDeletMutations_bitstring::set_allele_value().

◆ set_effects()

void TProtoDeletMutations_bitstring::set_effects ( )
269 {
270  reset_effect_table (); //de-allocate, re-allocate memory
271 
272  double dom;
273  double k = -1.0*log(2*_dominance) / _strength;
274 
275  for(unsigned int i = 0; i < _nb_locus; ++i){
276 
277  do{
278  _effects[1][i] = (float)(this->*_set_effects_func)(); //homozygote effect: s
279  }while(_effects[1][i] > 1); //truncate distribution
280 
281  if(_dominance_model == 1)
282  dom = exp(-1.0*_effects[1][i]*k)/2.0; //scaling of h on s
283  else dom = _dominance;
284 
285  _effects[0][i] = (float)(dom * _effects[1][i]); //heterozygote effect: hs
286 
287  }
288 
289  // save the effects to the parameter "delet_effects" will be written to the .log file
291 }

References _dominance, _dominance_model, _effects, _nb_locus, _set_effects_func, _strength, reset_effect_table(), and write_effects_to_parameter().

Referenced by setSelectionParameters().

◆ set_effects_exp()

double TProtoDeletMutations_bitstring::set_effects_exp ( )
inline
198 {return RAND::Exponential(_strength);}
static double Exponential(double mu)
Definition: Uniform.h:447

References _strength, and RAND::Exponential().

Referenced by setSelectionParameters().

◆ set_effects_gamma()

double TProtoDeletMutations_bitstring::set_effects_gamma ( )
inline
199 {return RAND::Gamma(_dist_p1, _dist_p2);}
static double Gamma(double a, double b)
Definition: Uniform.h:385

References _dist_p1, _dist_p2, and RAND::Gamma().

Referenced by setSelectionParameters().

◆ set_effects_lognorm()

double TProtoDeletMutations_bitstring::set_effects_lognorm ( )
inline
static double LogNormal(double zeta, double sigma)
Definition: Uniform.h:357

References _dist_p1, _dist_p2, and RAND::LogNormal().

Referenced by setSelectionParameters().

◆ setEffectsFromInput()

bool TProtoDeletMutations_bitstring::setEffectsFromInput ( )
241 {
242  TMatrix tmp;
243 
244  get_parameter("delet_effects")->getMatrix(&tmp);
245 
246  if(tmp.getNbCols() != _nb_locus)
247  return error("the number of mutational effects of the deleterious trait is not equal to its number of loci, please adjust.\n");
248 
249  if(tmp.getNbRows() != 2 )
250  return error("the parameter \"delet_effects\" must have two rows, the first for\
251  the mutational effect in heterozygotes, the second for the effects in homozygotes.\n");
252 
253  _continuous_effects = true;
254 
256 
257  for(unsigned int i = 0; i < _nb_locus; ++i){
258 
259  _effects[0][i] = (float)tmp.get(0, i); //heterozygote effect: hs
260  _effects[1][i] = (float)tmp.get(1, i); //homozygote effect: s
261  }
262 
263  return true;
264 }
unsigned int getNbRows() const
Gives the number of rows.
Definition: tmatrix.h:212
unsigned int getNbCols() const
Gives the number of columns.
Definition: tmatrix.h:215
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:193

References _continuous_effects, _effects, _nb_locus, error(), TMatrix::get(), SimComponent::get_parameter(), Param::getMatrix(), TMatrix::getNbCols(), TMatrix::getNbRows(), and reset_effect_table().

Referenced by setSelectionParameters().

◆ setParameters()

bool TProtoDeletMutations_bitstring::setParameters ( )
virtual

Implements SimComponent.

121 {
122  _nb_locus = (int)get_parameter_value("delet_loci");
123  _mut_rate = get_parameter_value("delet_mutation_rate");
124 
125 
126  //we set the fitness model to 1 (multiplicative by default))
127  if(get_parameter("delet_fitness_model")->isSet())
128  _fitness_model = (int)get_parameter_value("delet_fitness_model");
129  else
130  _fitness_model = 1;
131 
132  //reverse mutation rate; we only store the ratio of back/forward mutation rate
133  if( get_parameter("delet_backmutation_rate")->isSet() ) {
134 
135  _back_mutation_rate = get_parameter_value("delet_backmutation_rate");
136 
138 
139  return error("Deleterious mutations: The backward (reverse) mutation rate is larger than\
140 the forward mutation rate!\n");
141 
142  else
143 
145 
146 
147  } else
148  _back_mutation_rate = 0; //by default we don't process backward mutations
149 
150  //mutation model
151  if( get_parameter("delet_mutation_model")->isSet() )
152  _mutation_model = (unsigned int)get_parameter_value("delet_mutation_model");
153  else
154  _mutation_model = 1;
155 
156  //initial allele frequency, applies to all loci equally
157  if( (_init_freq = get_parameter_value("delet_init_freq")) == -1.0)
158  _init_freq = 0;
159 
160  //selection parameters:
161  if(!setSelectionParameters()) return false;
162 
163 
164  if( (_fitness_scaling_factor = get_parameter_value("delet_fitness_scaling_factor")) == -1.0)
166 
167  // we do not bypass the recombination map for rec rate = 0.5, it's too slow with bitstrings
169 
171 }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
void inherit_low(sex_t SEX, bitstring *seq, bitstring **parent)
Definition: ttdeletmutations_bitstring.cc:412
bool setSelectionParameters()
Definition: ttdeletmutations_bitstring.cc:175
bool setGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:125

References _back_mutation_rate, _fitness_model, _fitness_scaling_factor, _inherit_func_ptr, _init_freq, _mut_rate, _mutation_model, _nb_locus, error(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), inherit_low(), Param::isSet(), TTProtoWithMap::setGeneticMapParameters(), and setSelectionParameters().

Referenced by init().

◆ setSelectionParameters()

bool TProtoDeletMutations_bitstring::setSelectionParameters ( )
176 {
177 
178  if(get_parameter("delet_effects")->isSet())
179  return setEffectsFromInput();
180 
181  //effects and dominance parameters:
182  _strength = get_parameter_value("delet_effects_mean");
183  _dominance = get_parameter_value("delet_dominance_mean");
184  _dist_p1 = get_parameter_value("delet_effects_dist_param1");
185  _dist_p2 = get_parameter_value("delet_effects_dist_param2");
186 
187  //for backward compatibility only, param removed
188  _dominance_model = (int)get_parameter_value("delet_dominance_model");
189 
190  if(_dominance_model == -1) _dominance_model = 1; //1 means continuous; 2 means constant
191 
192  string distro = _paramSet->getArg("delet_effects_distribution");
193 
194  _continuous_effects = true;
195 
196  if(distro.empty() || distro == "constant") {
197 
198  _continuous_effects = false;
199 
200  _set_effects_func = 0;
201 
202  } else if(distro == "exponential") {
203 
205 
206  } else if(distro == "gamma") {
207 
209  //check params:
210  if(_dist_p1 == -1) {
211  return error("missing parameter 1 (shape) of the gamma distribution for the deleterious mutation effects.");
212  }
213 
214  if(_dist_p2 == -1)
215  _dist_p2 = _strength / _dist_p1; //mean of gamma == _strength = a*b with a == shape == _dist_p1
216 
217  } else if(distro == "lognormal") {
218 
220  //check params:
221  if(_dist_p1 == -1) {
222  return error("missing parameter 1 (mu) of the log-normal distribution for the deleterious mutation effects.");
223  }
224  if(_dist_p2 == -1) {
225  return error("missing parameter 2 (sigma) of the log-normal distribution for the deleterious mutation effects.");
226  }
227 
228  } else {
229  return error("Deleterious effects distribution \"%s\" not implemented.",distro.c_str());
230  }
231 
232 
234 
235  return true;
236 }
string getArg(string name)
Accessor to the parameters argument string.
Definition: param.h:300
double set_effects_lognorm()
Definition: ttdeletmutations_bitstring.h:200
double set_effects_gamma()
Definition: ttdeletmutations_bitstring.h:199
void set_effects()
Definition: ttdeletmutations_bitstring.cc:268
double set_effects_exp()
Definition: ttdeletmutations_bitstring.h:198
bool setEffectsFromInput()
Definition: ttdeletmutations_bitstring.cc:240

References _continuous_effects, _dist_p1, _dist_p2, _dominance, _dominance_model, SimComponent::_paramSet, _set_effects_func, _strength, error(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), ParamSet::getArg(), set_effects(), set_effects_exp(), set_effects_gamma(), set_effects_lognorm(), and setEffectsFromInput().

Referenced by setParameters().

◆ store_data()

void TProtoDeletMutations_bitstring::store_data ( BinaryStorageBuffer saver)
virtual

Implements StorableComponent.

452 {
453  saver->store(&_nb_locus,sizeof(int));
454  //store all bool on 1 byte
455  char dummy = _continuous_effects;
456  saver->store(&dummy, 1);
457  if(_continuous_effects) {
458  saver->store(_effects[0],_nb_locus * sizeof(float));
459  saver->store(_effects[1],_nb_locus * sizeof(float));
460  }
461 }
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16

References _continuous_effects, _effects, _nb_locus, and BinaryStorageBuffer::store().

◆ write_effects_to_parameter()

void TProtoDeletMutations_bitstring::write_effects_to_parameter ( )
312 {
313  ostringstream r0, r1;
314 
315  for(unsigned int i = 0; i < _nb_locus -1; ++i){
316  // record the effects
317  r0<<_effects[0][i]<<",";
318  r1<<_effects[1][i]<<",";
319  }
320 
321  r0<<_effects[0][_nb_locus -1];
322  r1<<_effects[1][_nb_locus -1];
323 
324  // save the effects in a parameter; will be added to the .log simulation file
325  string arg = "{{" + r0.str() + "} {" + r1.str() + "}}";
326  get_parameter("delet_effects")->setArg(arg);
327  get_parameter("delet_effects")->setIsSet(true);
328 
329 }
void setArg(string value)
Sets the parameter's argument.
Definition: param.h:118
void setIsSet(bool value)
Sets the _isSet flag.
Definition: param.h:122

References _effects, _nb_locus, SimComponent::get_parameter(), Param::setArg(), and Param::setIsSet().

Referenced by resetParameterFromSource(), and set_effects().

Member Data Documentation

◆ _back_mutation_rate

double TProtoDeletMutations_bitstring::_back_mutation_rate
private

◆ _continuous_effects

bool TProtoDeletMutations_bitstring::_continuous_effects
private

◆ _dist_p1

double TProtoDeletMutations_bitstring::_dist_p1
private

◆ _dist_p2

double TProtoDeletMutations_bitstring::_dist_p2
private

◆ _dominance

double TProtoDeletMutations_bitstring::_dominance
private

◆ _dominance_model

int TProtoDeletMutations_bitstring::_dominance_model
private

◆ _effects

◆ _fitness_model

unsigned int TProtoDeletMutations_bitstring::_fitness_model
private

Referenced by hatch(), and setParameters().

◆ _fitness_scaling_factor

double TProtoDeletMutations_bitstring::_fitness_scaling_factor
private

◆ _inherit_func_ptr

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

Referenced by hatch(), and setParameters().

◆ _init_freq

double TProtoDeletMutations_bitstring::_init_freq
private

Referenced by get_init_freq(), and setParameters().

◆ _mut_rate

double TProtoDeletMutations_bitstring::_mut_rate
private

Referenced by get_mut_rate(), hatch(), and setParameters().

◆ _mutation_model

unsigned int TProtoDeletMutations_bitstring::_mutation_model
private

Referenced by hatch(), and setParameters().

◆ _nb_locus

◆ _reader

TTDeletMutBitstrFH* TProtoDeletMutations_bitstring::_reader
private

◆ _set_effects_func

double(TProtoDeletMutations_bitstring::* TProtoDeletMutations_bitstring::_set_effects_func) (void)
private

◆ _stats

TTDeletMutBitstrSH* TProtoDeletMutations_bitstring::_stats
private

◆ _strength

double TProtoDeletMutations_bitstring::_strength
private

◆ _viability_func_ptr

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

◆ _writer

TTDeletMutBitstrFH* TProtoDeletMutations_bitstring::_writer
private

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