Nemo  2.4.0
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
 
virtual int get_phenotype_dimension ()
 Returns the dimension of the phenotype of the trait (size of the array accessed with TTrait::getValue() More...
 
virtual int get_allele_number ()
 Returns the number of allele per locus. More...
 
virtual int get_locus_number ()
 Returns the number of locus. More...
 
StorableComponent 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 ()
 
double getRecombRate () const
 
bool setGeneticMapParameters (string prefix, unsigned int numLoci=0)
 
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 ()
 
virtual bool is_mappable ()
 Checks if the trait is mappable, i.e., if the loci can be placed on a genetic map. More...
 
virtual bool is_mapped ()
 Checks if the trait's loci are placed on a genetic map. More...
 
virtual vector< unsigned int > get_locus_map_positions ()
 Returns the map positions of the loci in vector. More...
 
- 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 GeneticMapgetGeneticMapRef ()
 
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 ( )
54 {
55  set_paramset("delet", false, this);
56 
57  add_parameter("delet_loci",INT,true,false,0,0);
58 
59  add_parameter("delet_mutation_rate",DBL,true,true,0,1, 0);
60  add_parameter("delet_backmutation_rate",DBL,false,true,0,1, 0);
61  add_parameter("delet_mutation_model",INT,false,true,1,2, 0);
62  add_parameter("delet_init_freq",DBL,false,true,0,1, 0);
63 
64  //genetic map parameters:
66 
67  //effects parameters
68  add_parameter("delet_effects_mean",DBL,false,false,0,1, 0);
69  add_parameter("delet_dominance_mean",DBL,false,true,0,1, 0);
70  add_parameter("delet_fitness_model",INT,false,true,1,2, 0);
71  add_parameter("delet_effects", MAT, false, false, 0, 0, 0);
72  add_parameter("delet_effects_distribution",STR,false,false,0,0, 0);
73  add_parameter("delet_effects_dist_param1",DBL,false,false,0,0, 0);
74  add_parameter("delet_effects_dist_param2",DBL,false,false,0,0, 0);
75  add_parameter("delet_fitness_scaling_factor",DBL,false,false,0,0, 0);
76  add_parameter("delet_dominance_model", INT, false, true, 1, 2, 0);
77  //for back compatibility:
78 // add_parameter("delet_sel_coef",DBL,false,true,0,1, 0);
79 // add_parameter("delet_dom_coef",DBL,false,true,0,1, 0);
80  //output parameters:
81  add_parameter("delet_save_genotype",BOOL,false,false,0,0);
82  add_parameter("delet_genot_dir",STR,false,false,0,0);
83  add_parameter("delet_genot_logtime",INT,false,false,0,0);
84 
85 }
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:85
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:111
TTDeletMutBitstrFH * _writer
Definition: ttdeletmutations_bitstring.h:278
unsigned int _mutation_model
Definition: ttdeletmutations_bitstring.h:262
double _strength
Definition: ttdeletmutations_bitstring.h:268
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:260
float ** _effects
Definition: ttdeletmutations_bitstring.h:280
double(TProtoDeletMutations_bitstring::* _set_effects_func)(void)
Definition: ttdeletmutations_bitstring.h:274
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:264
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:275
double _init_freq
Definition: ttdeletmutations_bitstring.h:265
double _mut_rate
Definition: ttdeletmutations_bitstring.h:266
double _dominance
Definition: ttdeletmutations_bitstring.h:269
int _dominance_model
Definition: ttdeletmutations_bitstring.h:263
double _back_mutation_rate
Definition: ttdeletmutations_bitstring.h:267
double _dist_p2
Definition: ttdeletmutations_bitstring.h:271
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:261
double _dist_p1
Definition: ttdeletmutations_bitstring.h:270
TTDeletMutBitstrFH * _reader
Definition: ttdeletmutations_bitstring.h:279
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:273
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:272
TTDeletMutBitstrSH * _stats
Definition: ttdeletmutations_bitstring.h:277
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:77
@ DBL
Definition: types.h:77
@ MAT
Definition: types.h:77
@ BOOL
Definition: types.h:77
@ STR
Definition: types.h:77
@ INT
Definition: types.h:77

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

Referenced by clone().

+ Here is the caller graph for this function:

◆ TProtoDeletMutations_bitstring() [2/2]

TProtoDeletMutations_bitstring::TProtoDeletMutations_bitstring ( const TProtoDeletMutations_bitstring T)

◆ ~TProtoDeletMutations_bitstring()

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

References _effects, _reader, _stats, and _writer.

Member Function Documentation

◆ clone()

virtual TProtoDeletMutations_bitstring* TProtoDeletMutations_bitstring::clone ( )
inlinevirtual

Implements TraitPrototype.

231 {return new TProtoDeletMutations_bitstring((*this));}
TProtoDeletMutations_bitstring()
Definition: ttdeletmutations_bitstring.cc:49

References TProtoDeletMutations_bitstring().

◆ get_allele_number()

virtual int TProtoDeletMutations_bitstring::get_allele_number ( )
inlinevirtual

Returns the number of allele per locus.

Implements TraitPrototype.

237 {return 2;}

◆ get_backmutation_rate()

double TProtoDeletMutations_bitstring::get_backmutation_rate ( )
inline
187 {return _back_mutation_rate;}

References _back_mutation_rate.

Referenced by TTDeletMutations_bitstring::mutate_noredraw(), and TTDeletMutations_bitstring::set_mutation_func_ptr().

+ Here is the caller graph for this function:

◆ get_dominance()

double TProtoDeletMutations_bitstring::get_dominance ( )
inline

◆ get_dominance_model()

int TProtoDeletMutations_bitstring::get_dominance_model ( )
inline
190 {return _dominance_model;}

References _dominance_model.

Referenced by TTDeletMutations_bitstring::set_allele_value().

+ Here is the caller graph for this function:

◆ get_effect()

float TProtoDeletMutations_bitstring::get_effect ( unsigned int  at,
unsigned int  loc 
)
inline
197 {return _effects[at][loc];}

References _effects.

Referenced by TTDeletMutations_bitstring::get_allele_value(), and TTDeletMutations_bitstring::set_allele_value().

+ Here is the caller graph for this function:

◆ get_effects()

float** TProtoDeletMutations_bitstring::get_effects ( ) const
inline

◆ get_fitness_scaling_factor()

double TProtoDeletMutations_bitstring::get_fitness_scaling_factor ( )
inline

◆ get_hs_continous()

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

References _effects.

Referenced by TTDeletMutBitstrFH::FHwrite().

+ Here is the caller graph for this function:

◆ get_init_freq()

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

References _init_freq.

Referenced by TTDeletMutations_bitstring::init_sequence().

+ Here is the caller graph for this function:

◆ get_iscontinuous()

bool TProtoDeletMutations_bitstring::get_iscontinuous ( )
inline
191 {return _continuous_effects;}

References _continuous_effects.

Referenced by TTDeletMutBitstrFH::FHwrite(), and TTDeletMutBitstrSH::TTDeletMutBitstrSH().

+ Here is the caller graph for this function:

◆ get_locus_number()

virtual int TProtoDeletMutations_bitstring::get_locus_number ( )
inlinevirtual

Returns the number of locus.

Implements TraitPrototype.

239 {return _nb_locus;}

References _nb_locus.

◆ get_mut_rate()

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

References _mut_rate.

◆ get_nb_locus()

int TProtoDeletMutations_bitstring::get_nb_locus ( )
inline

◆ get_phenotype_dimension()

virtual int TProtoDeletMutations_bitstring::get_phenotype_dimension ( )
inlinevirtual

Returns the dimension of the phenotype of the trait (size of the array accessed with TTrait::getValue()

Implements TraitPrototype.

235 {return 1;}

◆ get_s_continous()

float* TProtoDeletMutations_bitstring::get_s_continous ( )
inline
194 {return _effects[1];}

References _effects.

Referenced by TTDeletMutBitstrFH::FHwrite(), and TTDeletMutBitstrSH::setLethalEquivalents().

+ Here is the caller graph for this function:

◆ get_strength()

double TProtoDeletMutations_bitstring::get_strength ( )
inline

◆ get_type()

virtual trait_t TProtoDeletMutations_bitstring::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

233 {return DELE;}
#define DELE
Definition: types.h:65

References DELE.

◆ hatch()

TTDeletMutations_bitstring * TProtoDeletMutations_bitstring::hatch ( )
virtual

Implements TraitPrototype.

389 {
391 
392  new_trait->set_proto(this);
393 
394  new_trait->set_nb_locus(_nb_locus);
395  new_trait->set_mut_rate(_mut_rate,_nb_locus);
396 
401 
402  return new_trait;
403 }
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:46
void set_inherit_func_ptr(void(TProtoDeletMutations_bitstring::*theFunc)(sex_t, bitstring *, bitstring **))
Definition: ttdeletmutations_bitstring.h:124
void set_mutation_func_ptr(unsigned int m_model)
Definition: ttdeletmutations_bitstring.cc:618
void set_mut_rate(double val, int nloc)
Definition: ttdeletmutations_bitstring.h:121
void set_viability_func_ptr(unsigned int f_model, bool is_cont)
Definition: ttdeletmutations_bitstring.cc:595
void set_proto(TProtoDeletMutations_bitstring *proto)
Definition: ttdeletmutations_bitstring.h:119
void set_is_continuous(bool val)
Definition: ttdeletmutations_bitstring.h:122
void set_nb_locus(int val)
Definition: ttdeletmutations_bitstring.h:120

References _continuous_effects, _fitness_model, _inherit_func_ptr, _mut_rate, _mutation_model, _nb_locus, TTDeletMutations_bitstring::set_inherit_func_ptr(), TTDeletMutations_bitstring::set_is_continuous(), 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
408 {
409 // for(unsigned int i = 0; i < _nb_locus; )
410 // seq[i] = (bool)(*parent[RAND::RandBool()])[i];
411 
412  // Word-level random recombination: for each 64-bit word, generate a random mask
413  // offspring = (parent_chrom_a & mask) | (parent_chrom_b & ~mask)
414  size_t nwords = parent[0]->nb_words();
415 
416  unsigned int first = RAND::RandBool();
417  const bitstring& seq0 = *parent[first];
418  const bitstring& seq1 = *parent[!first];
419 
420  for (size_t w = 0; w < nwords; w++) {
422  bitstring::_ul result = (*seq0.getword_atIdx(w) & mask) |
423  (*seq1.getword_atIdx(w) & ~mask);
424  *(seq->getword_atIdx(w)) = result;
425  }
426 }
static unsigned long RandULong()
Return a random unsigned long, from uniform distribution.
Definition: Uniform.h:191
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:164
Non-template and faster implementation of std::bitset.
Definition: bitstring.h:56
unsigned long _ul
Definition: bitstring.h:60
_ul * getword_atIdx(size_t index) const
Definition: bitstring.h:158
size_t nb_words() const
Definition: bitstring.h:163

References bitstring::getword_atIdx(), bitstring::nb_words(), RAND::RandBool(), and RAND::RandULong().

◆ inherit_low()

void TProtoDeletMutations_bitstring::inherit_low ( sex_t  SEX,
bitstring seq,
bitstring **  parent 
)
inline
431 {
432  unsigned int prevLoc = 0, cEnd = 0;
433 
434  //the table containing the loci at which x-overs happen
435  vector< pair<unsigned int, unsigned int> > recTable = _map.reduceJunctions(SEX, _mapIndex);
436 
437  //number of x-overs
438  unsigned int nbRec = recTable.size();
439 
440 #ifdef _REC_DEBUG_
441  cout << "TProtoDeletMutations_bitstring::inherit_low; nb Rec = "<<nbRec - 1<<endl;
442  cout << " --sex = "<<SEX<<"\n";
443 #endif
444 
445  unsigned int num_copied = 0;
446 
447  vector< pair<unsigned int, unsigned int> >::const_iterator xover = recTable.begin();
448 
449  while(xover != recTable.end()) {
450 
451 #ifdef _REC_DEBUG_
452  cout<< " copy seq from "<<prevLoc<<" to "<<xover->first
453  <<" ("<<(xover->first - prevLoc)<<" loc) ("
454  <<(xover->first - prevLoc)
455  <<" bits) on side "<<xover->second<<std::endl;
456 #endif
457 
458  seq->copy( *parent[ xover->second ], prevLoc, xover->first);
459 
460  prevLoc = xover->first;
461 
462  xover++;
463  }
464 
465 }
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:1209
static GeneticMap _map
Definition: ttrait_with_map.h:208
unsigned int _mapIndex
Definition: ttrait_with_map.h:192
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:360

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

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ init()

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

References setParameters().

◆ loadFileServices()

void TProtoDeletMutations_bitstring::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

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

References _reader, _writer, FileServices::attach(), FileServices::attach_reader(), fatal(), 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.

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

References _stats, and StatServices::attach().

◆ reset()

virtual void TProtoDeletMutations_bitstring::reset ( )
inlinevirtual

Reimplemented from TTProtoWithMap.

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

References TTProtoWithMap::reset().

◆ reset_effect_table()

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

References _effects, and _nb_locus.

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

+ Here is the caller graph for this function:

◆ resetParameterFromSource()

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

Implements SimComponent.

514 {
515  TProtoDeletMutations_bitstring *srceProto = dynamic_cast< TProtoDeletMutations_bitstring* >(cmpt);
516 
517  // this works only to reset the fitness effects
518  if(param != "delet_effects") return false;
519 
520  float** efx = srceProto->get_effects();
521 
522  if(efx == NULL)
523  return error("the binary source population did not properly set the fitness effects of\
524  deleterious mutations, no effects received.\n");
525 
526  // the genetic architecture has already been checked in Metapop::loadPopFromBinarySource
527  // we can skip the check of table size
528 
529  reset_effect_table(); // deallocate and re-allocate the _effects table
530 
531  //copy effects
532  memcpy(_effects[0], efx[0], _nb_locus*sizeof(float));
533  memcpy(_effects[1], efx[1], _nb_locus*sizeof(float));
534 
535  //record effects into the parameter
537 
538  return true;
539 }
Prototype class of the bitstring-deleterious mutations trait class.
Definition: ttdeletmutations_bitstring.h:177
void reset_effect_table()
Definition: ttdeletmutations_bitstring.cc:294
void write_effects_to_parameter()
Definition: ttdeletmutations_bitstring.cc:310
float ** get_effects() const
Definition: ttdeletmutations_bitstring.h:196
int error(const char *str,...)
Definition: output.cc:78

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.

484 {
485  unsigned int dummy_int;
486  reader->read(&dummy_int,sizeof(int));
487 
488  if(dummy_int != _nb_locus ){
489  warning("Deleterious mutation trait::locus number in binary source file differs from parameter value!\n\
490  >>>> adjusting locus number to match source population: %i set to %i\n", _nb_locus, dummy_int);
491  _nb_locus = dummy_int;
492  }
493 
494  char dummy_bool = 0;
495  reader->read(&dummy_bool, 1);
496 
497  if(dummy_bool != _continuous_effects) {
498  error("Deleterious mutation trait::mutation effects model in binary source file differ from parameter value!\n\
499  >>>> adjusting model to match source population: continuous = %i to continuous = %i\n",
500  _continuous_effects, (int)dummy_bool);
501  _continuous_effects = dummy_bool;
502  }
503 
504  if(_continuous_effects) {
505  reader->read(_effects[0],_nb_locus * sizeof(float));
506  reader->read(_effects[1],_nb_locus * sizeof(float));
507  }
508  return true;
509 }
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:220
void warning(const char *str,...)
Definition: output.cc:57

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
203 {_effects[at][loc] = val;}

References _effects.

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

+ Here is the caller graph for this function:

◆ set_effects()

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

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

Referenced by setSelectionParameters().

+ Here is the caller graph for this function:

◆ set_effects_exp()

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

References _strength, and RAND::Exponential().

Referenced by setSelectionParameters().

+ Here is the caller graph for this function:

◆ set_effects_gamma()

double TProtoDeletMutations_bitstring::set_effects_gamma ( )
inline
205 {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().

+ Here is the caller graph for this function:

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

+ Here is the caller graph for this function:

◆ setEffectsFromInput()

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

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

+ Here is the caller graph for this function:

◆ setParameters()

bool TProtoDeletMutations_bitstring::setParameters ( )
virtual

Implements SimComponent.

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

+ Here is the caller graph for this function:

◆ setSelectionParameters()

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

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

+ Here is the caller graph for this function:

◆ store_data()

void TProtoDeletMutations_bitstring::store_data ( BinaryStorageBuffer saver)
virtual

Implements StorableComponent.

470 {
471  saver->store(&_nb_locus,sizeof(int));
472  //store all bool on 1 byte
473  char dummy = _continuous_effects;
474  saver->store(&dummy, 1);
475  if(_continuous_effects) {
476  saver->store(_effects[0],_nb_locus * sizeof(float));
477  saver->store(_effects[1],_nb_locus * sizeof(float));
478  }
479 }
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:37

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

◆ write_effects_to_parameter()

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

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

Referenced by resetParameterFromSource(), and set_effects().

+ Here is the caller graph for this function:

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

Locations of visitors to this page
Catalogued on GSR