Nemo  2.3.46
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 ()
 
int get_nb_locus ()
 
double get_mut_rate ()
 
double get_strength ()
 
double get_dominance ()
 
int get_dominance_model ()
 
bool get_iscontinuous ()
 
void set_effects ()
 
double set_effects_exp ()
 
double set_effects_gamma ()
 
double set_effects_lognorm ()
 
float * get_s_continous ()
 
float * get_hs_continous ()
 
void inherit_low (sex_t SEX, bitstring *seq, bitstring **parent)
 
void inherit_free (sex_t SEX, bitstring *seq, bitstring **parent)
 
bool setSelectionParameters ()
 
virtual void init ()
 
virtual void reset ()
 
virtual
TTDeletMutations_bitstring
hatch ()
 
virtual
TProtoDeletMutations_bitstring
clone ()
 
virtual trait_t get_type () const
 
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
- 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 ()
 
- 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...
 

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 _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::TProtoDeletMutations_bitstring ( )

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

Referenced by clone().

54 _writer(0), _reader(0), _effects(0)
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_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  add_parameter("delet_fitness_model",INT,true,true,1,2, 0);
68  add_parameter("delet_effects_distribution",STR,false,false,0,0, 0);
69  add_parameter("delet_effects_mean",DBL,true,false,0,1, 0);
70  add_parameter("delet_effects_dist_param1",DBL,false,false,0,0, 0);
71  add_parameter("delet_effects_dist_param2",DBL,false,false,0,0, 0);
72  add_parameter("delet_dominance_mean",DBL,true,true,0,1, 0);
73  add_parameter("delet_fitness_scaling_factor",DBL,false,false,0,0, 0);
74  add_parameter("delet_dominance_model", INT, false, true, 1, 2, 0);
75  //for back compatibility:
76  add_parameter("delet_sel_coef",DBL,false,true,0,1, 0);
77  add_parameter("delet_dom_coef",DBL,false,true,0,1, 0);
78  //output parameters:
79  add_parameter("delet_save_genotype",BOOL,false,false,0,0);
80  add_parameter("delet_genot_dir",STR,false,false,0,0);
81  add_parameter("delet_genot_logtime",INT,false,false,0,0);
82 
83 }
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:241
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:242
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:244
TTDeletMutBitstrFH * _reader
Definition: ttdeletmutations_bitstring.h:248
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:247
double _dominance
Definition: ttdeletmutations_bitstring.h:238
Definition: types.h:78
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:77
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:231
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:234
float ** _effects
Definition: ttdeletmutations_bitstring.h:249
unsigned int _mutation_model
Definition: ttdeletmutations_bitstring.h:232
double _init_freq
Definition: ttdeletmutations_bitstring.h:235
TTDeletMutBitstrSH * _stats
Definition: ttdeletmutations_bitstring.h:246
Definition: types.h:78
int _dominance_model
Definition: ttdeletmutations_bitstring.h:233
double _mut_rate
Definition: ttdeletmutations_bitstring.h:236
Definition: types.h:78
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:230
double _strength
Definition: ttdeletmutations_bitstring.h:237
Definition: types.h:78
TProtoDeletMutations_bitstring::TProtoDeletMutations_bitstring ( const TProtoDeletMutations_bitstring T)

References SimComponent::_paramSet.

93 {
94  _paramSet = new ParamSet( *(T._paramSet) ) ;
95 }
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:241
double(TTDeletMutations_bitstring::* _viability_func_ptr)(void)
Definition: ttdeletmutations_bitstring.h:242
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:244
TTDeletMutBitstrFH * _reader
Definition: ttdeletmutations_bitstring.h:248
TTDeletMutBitstrFH * _writer
Definition: ttdeletmutations_bitstring.h:247
double _dominance
Definition: ttdeletmutations_bitstring.h:238
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:231
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:234
float ** _effects
Definition: ttdeletmutations_bitstring.h:249
unsigned int _mutation_model
Definition: ttdeletmutations_bitstring.h:232
double _init_freq
Definition: ttdeletmutations_bitstring.h:235
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
TTDeletMutBitstrSH * _stats
Definition: ttdeletmutations_bitstring.h:246
int _dominance_model
Definition: ttdeletmutations_bitstring.h:233
double _mut_rate
Definition: ttdeletmutations_bitstring.h:236
Parameters container, implemented in each SimComponent.
Definition: param.h:203
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:230
double _strength
Definition: ttdeletmutations_bitstring.h:237
TProtoDeletMutations_bitstring::~TProtoDeletMutations_bitstring ( )

References _effects, _reader, _stats, and _writer.

100 {
101  if(_stats != NULL) {delete _stats; _stats = NULL;}
102  if(_reader) {delete _reader; _reader= NULL;}
103  if(_writer != NULL) {delete _writer; _writer = NULL;}
104  if(_effects != NULL) {
105  delete [] _effects[0];
106  delete [] _effects[1];
107  delete [] _effects;
108  _effects = NULL;
109  }
110 
111 }
TTDeletMutBitstrFH * _reader
Definition: ttdeletmutations_bitstring.h:248
TTDeletMutBitstrFH * _writer
Definition: ttdeletmutations_bitstring.h:247
float ** _effects
Definition: ttdeletmutations_bitstring.h:249
TTDeletMutBitstrSH * _stats
Definition: ttdeletmutations_bitstring.h:246

Member Function Documentation

virtual TProtoDeletMutations_bitstring* TProtoDeletMutations_bitstring::clone ( )
inlinevirtual

Implements TraitPrototype.

References TProtoDeletMutations_bitstring().

214 {return new TProtoDeletMutations_bitstring((*this));}
TProtoDeletMutations_bitstring()
Definition: ttdeletmutations_bitstring.cc:50
double TProtoDeletMutations_bitstring::get_dominance ( )
inline

References _dominance.

191 {return _dominance;}
double _dominance
Definition: ttdeletmutations_bitstring.h:238
int TProtoDeletMutations_bitstring::get_dominance_model ( )
inline

References _dominance_model.

Referenced by TTDeletMutations_bitstring::set_allele_value().

192 {return _dominance_model;}
int _dominance_model
Definition: ttdeletmutations_bitstring.h:233
float* TProtoDeletMutations_bitstring::get_hs_continous ( )
inline

Referenced by TTDeletMutBitstrFH::FHwrite().

200 {return _effects[0];}
float ** _effects
Definition: ttdeletmutations_bitstring.h:249
bool TProtoDeletMutations_bitstring::get_iscontinuous ( )
inline

References _continuous_effects.

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

193 {return _continuous_effects;}
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:241
double TProtoDeletMutations_bitstring::get_mut_rate ( )
inline

References _mut_rate.

189 {return _mut_rate;}
double _mut_rate
Definition: ttdeletmutations_bitstring.h:236
int TProtoDeletMutations_bitstring::get_nb_locus ( )
inline
float* TProtoDeletMutations_bitstring::get_s_continous ( )
inline

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

199 {return _effects[1];}
float ** _effects
Definition: ttdeletmutations_bitstring.h:249
double TProtoDeletMutations_bitstring::get_strength ( )
inline

References _strength.

Referenced by TTDeletMutBitstrSH::setLethalEquivalents().

190 {return _strength;}
double _strength
Definition: ttdeletmutations_bitstring.h:237
virtual trait_t TProtoDeletMutations_bitstring::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

References DELE.

216 {return DELE;}
#define DELE
Definition: types.h:66
TTDeletMutations_bitstring * TProtoDeletMutations_bitstring::hatch ( )
virtual

Implements TraitPrototype.

References _continuous_effects, _dominance, _fitness_model, _fitness_scaling_factor, _inherit_func_ptr, _init_freq, _mut_rate, _mutation_model, _nb_locus, _strength, TTDeletMutations_bitstring::set_continuous_effects(), TTDeletMutations_bitstring::set_dominance(), TTDeletMutations_bitstring::set_fitness_model(), TTDeletMutations_bitstring::set_fitness_scaling_factor(), TTDeletMutations_bitstring::set_inherit_func_ptr(), TTDeletMutations_bitstring::set_init_freq(), TTDeletMutations_bitstring::set_mut_rate(), TTDeletMutations_bitstring::set_mutation_func_ptr(), TTDeletMutations_bitstring::set_nb_locus(), TTDeletMutations_bitstring::set_proto(), TTDeletMutations_bitstring::set_strength(), and TTDeletMutations_bitstring::set_viability_func_ptr().

296 {
298 
299  new_trait->set_proto(this);
300  new_trait->set_nb_locus(_nb_locus);
301  new_trait->set_init_freq(_init_freq);
302  new_trait->set_fitness_model(_fitness_model);
304  new_trait->set_dominance(_dominance);
305  new_trait->set_strength(_strength);
308  new_trait->set_mut_rate(_mut_rate,_nb_locus);
311 
312  return new_trait;
313 }
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:241
void set_fitness_scaling_factor(double val)
Definition: ttdeletmutations_bitstring.h:130
void set_proto(TProtoDeletMutations_bitstring *proto)
Definition: ttdeletmutations_bitstring.h:121
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:244
double _dominance
Definition: ttdeletmutations_bitstring.h:238
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:231
void set_continuous_effects(bool val)
Definition: ttdeletmutations_bitstring.h:133
Bitstring implementation of TTDeletMutations with recombination.
Definition: ttdeletmutations_bitstring.h:47
void set_nb_locus(int val)
Definition: ttdeletmutations_bitstring.h:122
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:234
unsigned int _mutation_model
Definition: ttdeletmutations_bitstring.h:232
void set_viability_func_ptr(unsigned int f_model, bool is_cont)
Definition: ttdeletmutations_bitstring.cc:483
double _init_freq
Definition: ttdeletmutations_bitstring.h:235
void set_mutation_func_ptr(unsigned int m_model)
Definition: ttdeletmutations_bitstring.cc:506
double _mut_rate
Definition: ttdeletmutations_bitstring.h:236
void set_fitness_model(int val)
Definition: ttdeletmutations_bitstring.h:132
void set_inherit_func_ptr(void(TProtoDeletMutations_bitstring::*theFunc)(sex_t, bitstring *, bitstring **))
Definition: ttdeletmutations_bitstring.h:127
void set_mut_rate(double val, int nloc)
Definition: ttdeletmutations_bitstring.h:123
void set_strength(double val)
Definition: ttdeletmutations_bitstring.h:124
void set_dominance(double val)
Definition: ttdeletmutations_bitstring.h:125
void set_init_freq(double val)
Definition: ttdeletmutations_bitstring.h:131
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:230
double _strength
Definition: ttdeletmutations_bitstring.h:237
void TProtoDeletMutations_bitstring::inherit_free ( sex_t  SEX,
bitstring seq,
bitstring **  parent 
)
inline

References _nb_locus, and RAND::RandBool().

318 {
319  for(unsigned int i = 0; i < _nb_locus; )
320  seq[i] = (bool)(*parent[RAND::RandBool()])[i];
321 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:139
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:230
void TProtoDeletMutations_bitstring::inherit_low ( sex_t  SEX,
bitstring seq,
bitstring **  parent 
)
inline

References TTProtoWithMap::_map, TTProtoWithMap::_mapIndex, TTProtoWithMap::_numChromosome, TTProtoWithMap::_numLociPerChrmsm, bitstring::copy(), GeneticMap::getFirstRecPosition(), and GeneticMap::getRecLoci().

Referenced by setParameters().

326 {
327 
328  register unsigned int nbRec, prevLoc = 0, chrm_bloc;
329  register bool flipper;
330 
331  vector< unsigned int >& recTable = _map.getRecLoci(SEX, _mapIndex);
332  vector< bool > & firstRecPos = _map.getFirstRecPosition(SEX);
333 
334  nbRec = recTable.size();
335 
336  // cout << "\nTProtoDeletMutations_bitstring::inherit_low -- "<<nbRec<<" recombination events\n";
337 
338  for(unsigned int c = 0, stride = 0, rec = 0; c < _numChromosome; ++c) {
339 
340  flipper = firstRecPos[c];
341 
342  chrm_bloc = stride + _numLociPerChrmsm[c]; //number of loci considered so far
343 
344  prevLoc = stride; //stride is the first locus of a chromosome
345 
346  //do recombination chromosome-wise
347  for(; recTable[rec] < chrm_bloc && rec < nbRec; rec++) {
348 
349  // cout << " -- copy from "<<prevLoc<<" to "<<recTable[rec]<<" (side="<<flipper<<")"<<endl;
350 
351  seq->copy( *parent[flipper], prevLoc, recTable[rec]);
352 
353  // memcpy(&seq[prevLoc], &parent[flipper][prevLoc], (recTable[rec] - prevLoc));
354 
355  prevLoc = recTable[rec];
356 
357  flipper = !flipper;
358  }
359 
360  // cout << " -- copy from "<<prevLoc<<" to "<<chrm_bloc<<" (side="<<flipper<<")"<<endl;
361  //copy what's left between the last x-over point and the end of the chrmsme
362  seq->copy( *parent[flipper], prevLoc, chrm_bloc);
363 
364  // memcpy(&seq[prevLoc], &parent[flipper][prevLoc], (chrm_bloc - prevLoc));
365 
366  stride += _numLociPerChrmsm[c];
367 
368  }
369  // cout << "parent chromosomes:\n --0:";
370  // for(unsigned int i = 0; i < _nb_locus; ++i)
371  // cout << (*parent[0])[i];
372  // cout << "\n --1:";
373  // for(unsigned int i = 0; i < _nb_locus; ++i)
374  // cout << (*parent[1])[i];
375  // cout << "\ngamete:\n --0:";
376  // for(unsigned int i = 0; i < _nb_locus; ++i)
377  // cout << (*seq)[i];
378  // cout << "\n";
379 }
static GeneticMap _map
Definition: ttrait_with_map.h:190
vector< bool > & getFirstRecPosition(sex_t SEX)
Returns the vector of the first chromosome position for recombination, used for all traits...
Definition: ttrait_with_map.h:155
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:255
unsigned int * _numLociPerChrmsm
Definition: ttrait_with_map.h:181
unsigned int _numChromosome
Definition: ttrait_with_map.h:178
vector< unsigned int > & getRecLoci(sex_t SEX, unsigned int trait)
Returns a vector of the loci where crossing-overs take place.
Definition: ttrait_with_map.h:149
unsigned int _mapIndex
Definition: ttrait_with_map.h:174
virtual void TProtoDeletMutations_bitstring::init ( )
inlinevirtual

References setParameters().

208 {setParameters();};
virtual bool setParameters()
Definition: ttdeletmutations_bitstring.cc:115
void TProtoDeletMutations_bitstring::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

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

256 {
257  // --- THE READER ---
258  //always add the reader:
259  if(_reader) delete _reader;
260  _reader = new TTDeletMutBitstrFH(this);
261  //set to read mode:
263  //attach to file manager:
264  loader->attach_reader(_reader);
265 
266  //writer
267  if(get_parameter("delet_save_genotype")->isSet()) {
268 
269  if(_writer == NULL) _writer = new TTDeletMutBitstrFH(this);
270 
271  Param* param = get_parameter("delet_genot_logtime");
272 
273  if(param->isMatrix()) {
274 
275  TMatrix temp;
276  param->getMatrix(&temp);
277  _writer->set_multi(true, true, 1, &temp, get_parameter("delet_genot_dir")->getArg());
278 
279  } else {
280  // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
281  _writer->set(true, true, 1, (param->isSet() ? (int)param->getValue() : 0),
282  0, get_parameter("delet_genot_dir")->getArg(),this);
283  }
284 
285  loader->attach(_writer);
286 
287  } else if(_writer != NULL) {
288  delete _writer;
289  _writer = NULL;
290  }
291 }
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:57
double getValue()
Returns the argument value according to its type.
Definition: param.cc:319
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:329
TTDeletMutBitstrFH * _reader
Definition: ttdeletmutations_bitstring.h:248
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:170
TTDeletMutBitstrFH * _writer
Definition: ttdeletmutations_bitstring.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:236
virtual void attach_reader(FileHandler *FH)
Attaches the FileHandler to the current list (_readers) of the FileServices.
Definition: fileservices.cc:70
The FileHandler associated with the TTDeletMutations_bitstring trait.
Definition: ttdeletmutations_bitstring.h:324
This structure stores one parameter, its definition and its string argument.
Definition: param.h:53
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
virtual void set_multi(bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path)
Definition: filehandler.h:197
string getArg()
Definition: param.h:136
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
void set_isInputHandler(bool val)
Definition: filehandler.h:151
bool isSet()
Definition: param.h:138
void TProtoDeletMutations_bitstring::loadStatServices ( StatServices loader)
virtual

Implements SimComponent.

References _stats, and StatServices::attach().

245 {
246  if(_stats != NULL)
247  delete _stats;
248 
249  _stats = new TTDeletMutBitstrSH(this);
250 
251  loader->attach(_stats);
252 }// ----------------------------------------------------------------------------------------
TTDeletMutBitstrSH * _stats
Definition: ttdeletmutations_bitstring.h:246
The StatHandler for TTDeletMutations_bitstring.
Definition: ttdeletmutations_bitstring.h:253
virtual void attach(Handler *H)
attach the StatHandler to the current list (_statHandlers) of the StatServices
Definition: statservices.cc:177
virtual void TProtoDeletMutations_bitstring::reset ( )
inlinevirtual

Reimplemented from TTProtoWithMap.

References TTProtoWithMap::reset().

virtual void reset()
Definition: ttrait_with_map.cc:505
bool TProtoDeletMutations_bitstring::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

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

398 {
399  unsigned int dummy_int;
400  reader->read(&dummy_int,sizeof(int));
401  if(dummy_int != _nb_locus ){
402  error("TProtoDeletMutations::retrieve_data:nb locus in file differ from parameter value!\n");
403  _nb_locus = dummy_int;
404  }
405 
406  char dummy_bool = 0;
407  reader->read(&dummy_bool, 1);
408  if(dummy_bool != _continuous_effects) {
409  error("TProtoDeletMutations::retrieve_data:effects in file differ from parameter value!\n");
410  _continuous_effects = dummy_bool;
411  }
412 
413  if(_continuous_effects) {
414  reader->read(_effects[0],_nb_locus * sizeof(float));
415  reader->read(_effects[1],_nb_locus * sizeof(float));
417  }
418  return true;
419 }
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:241
int error(const char *str,...)
Definition: output.cc:73
float ** _effects
Definition: ttdeletmutations_bitstring.h:249
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:147
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:230
static void set_effects(float **fx)
Definition: ttdeletmutations_bitstring.cc:41
void TProtoDeletMutations_bitstring::set_effects ( )

References _dominance, _dominance_model, _effects, _nb_locus, _set_effects_func, _strength, and TTDeletMutations_bitstring::set_effects().

Referenced by setSelectionParameters().

212 {
213  if(_effects != NULL) {
214  delete [] _effects[0];
215  delete [] _effects[1];
216  delete [] _effects;
217  }
218 
219  _effects = new float* [2];
220  _effects[0] = new float [_nb_locus];
221  _effects[1] = new float [_nb_locus];
222 
223  double dom;
224  double k = -1.0*log(2*_dominance) / _strength;
225 
226  for(unsigned int i = 0; i < _nb_locus; ++i){
227 
228  do{
229  _effects[1][i] = (float)(this->*_set_effects_func)(); //homozygote effect: s
230  }while(_effects[1][i] > 1); //truncate distribution
231 
232  if(_dominance_model == 1)
233  dom = exp(-1.0*_effects[1][i]*k)/2.0; //scaling of h on s
234  else dom = _dominance;
235 
236  _effects[0][i] = (float)(dom * _effects[1][i]); //heterozygote effect: hs
237  }
238  //set the TTDeletMutations global var:
240 }
double(TProtoDeletMutations_bitstring::* _set_effects_func)(void)
Definition: ttdeletmutations_bitstring.h:243
double _dominance
Definition: ttdeletmutations_bitstring.h:238
float ** _effects
Definition: ttdeletmutations_bitstring.h:249
int _dominance_model
Definition: ttdeletmutations_bitstring.h:233
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:230
double _strength
Definition: ttdeletmutations_bitstring.h:237
static void set_effects(float **fx)
Definition: ttdeletmutations_bitstring.cc:41
double TProtoDeletMutations_bitstring::set_effects_exp ( )
inline

References RAND::Exponential().

Referenced by setSelectionParameters().

196 {return RAND::Exponential(_strength);}
static double Exponential(double mu)
Definition: Uniform.h:424
double _strength
Definition: ttdeletmutations_bitstring.h:237
double TProtoDeletMutations_bitstring::set_effects_gamma ( )
inline

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

Referenced by setSelectionParameters().

197 {return RAND::Gamma(_dist_p1, _dist_p2);}
double _dist_p2
Definition: ttdeletmutations_bitstring.h:240
double _dist_p1
Definition: ttdeletmutations_bitstring.h:239
static double Gamma(double a, double b)
Definition: Uniform.h:362
double TProtoDeletMutations_bitstring::set_effects_lognorm ( )
inline

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

Referenced by setSelectionParameters().

static double LogNormal(double zeta, double sigma)
Definition: Uniform.h:334
double _dist_p2
Definition: ttdeletmutations_bitstring.h:240
double _dist_p1
Definition: ttdeletmutations_bitstring.h:239
bool TProtoDeletMutations_bitstring::setParameters ( )
virtual

Implements SimComponent.

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

Referenced by init().

116 {
117  _nb_locus = (int)get_parameter_value("delet_loci");
118  _mut_rate = get_parameter_value("delet_mutation_rate");
119  _fitness_model = (int)get_parameter_value("delet_fitness_model");
120 
122 
123  //mutation model
124  if( get_parameter("delet_mutation_model")->isSet() )
125  _mutation_model = (unsigned int)get_parameter_value("delet_mutation_model");
126  else
127  _mutation_model = 1;
128 
129  if( (_init_freq = get_parameter_value("delet_init_freq")) == -1.0)
130  _init_freq = 0;
131 
132  //selection parameters:
133  if(!setSelectionParameters()) return false;
134 
136 }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
void(TProtoDeletMutations_bitstring::* _inherit_func_ptr)(sex_t, bitstring *, bitstring **)
Definition: ttdeletmutations_bitstring.h:244
void inherit_low(sex_t SEX, bitstring *seq, bitstring **parent)
Definition: ttdeletmutations_bitstring.cc:325
unsigned int _fitness_model
Definition: ttdeletmutations_bitstring.h:231
unsigned int _mutation_model
Definition: ttdeletmutations_bitstring.h:232
bool setSelectionParameters()
Definition: ttdeletmutations_bitstring.cc:140
double _init_freq
Definition: ttdeletmutations_bitstring.h:235
bool setGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:88
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
double _mut_rate
Definition: ttdeletmutations_bitstring.h:236
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:230
bool isSet()
Definition: param.h:138
bool TProtoDeletMutations_bitstring::setSelectionParameters ( )

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

Referenced by setParameters().

141 {
142  //effects and dominance parameters:
143  _strength = get_parameter_value("delet_effects_mean");
144  _dominance = get_parameter_value("delet_dominance_mean");
145  _dist_p1 = get_parameter_value("delet_effects_dist_param1");
146  _dist_p2 = get_parameter_value("delet_effects_dist_param2");
147 
148  //for backward compatibility only, param removed
149  _dominance_model = (int)get_parameter_value("delet_dominance_model");
150  if(_dominance_model == -1) _dominance_model = 1; //1 means continuous; 2 means constant
151 
152  if(get_parameter("delet_sel_coef")->isSet())
153  _strength = get_parameter_value("delet_sel_coef");
154  if(get_parameter("delet_dom_coef")->isSet())
155  _dominance = get_parameter_value("delet_dom_coef");
156 
157  string distro = _paramSet->getArg("delet_effects_distribution");
158 
159  _continuous_effects = true;
160 
161  if(distro.empty() || distro.compare("constant") == 0) {
162 
163  _continuous_effects = false;
164 
165  _set_effects_func = 0;
166 
167  } else if(distro.compare("exponential") == 0) {
168 
170 
171  } else if(distro.compare("gamma") == 0) {
172 
174  //check params:
175  if(_dist_p1 == -1) {
176  error("missing parameter 1 (shape) of the gamma distribution for the deleterious mutation effects.");
177  return false;
178  }
179 
180  if(_dist_p2 == -1)
181  _dist_p2 = _strength / _dist_p1; //mean of gamma == _strength = a*b with a == shape == _dist_p1
182 
183  } else if(distro.compare("lognormal") == 0) {
184 
186  //check params:
187  if(_dist_p1 == -1) {
188  error("missing parameter 1 (mu) of the log-normal distribution for the deleterious mutation effects.");
189  return false;
190  }
191  if(_dist_p2 == -1) {
192  error("missing parameter 2 (sigma) of the log-normal distribution for the deleterious mutation effects.");
193  return false;
194  }
195 
196  } else {
197  error("Deleterious effects distribution \"%s\" not implemented.",distro.c_str());
198  return false;
199  }
200 
201  if( (_fitness_scaling_factor = get_parameter_value("delet_fitness_scaling_factor")) == -1.0)
203 
205 
206  return true;
207 }
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:241
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
double(TProtoDeletMutations_bitstring::* _set_effects_func)(void)
Definition: ttdeletmutations_bitstring.h:243
double _dominance
Definition: ttdeletmutations_bitstring.h:238
int error(const char *str,...)
Definition: output.cc:73
double set_effects_exp()
Definition: ttdeletmutations_bitstring.h:196
double set_effects_gamma()
Definition: ttdeletmutations_bitstring.h:197
double _dist_p2
Definition: ttdeletmutations_bitstring.h:240
double _fitness_scaling_factor
Definition: ttdeletmutations_bitstring.h:234
void set_effects()
Definition: ttdeletmutations_bitstring.cc:211
double set_effects_lognorm()
Definition: ttdeletmutations_bitstring.h:198
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
double _dist_p1
Definition: ttdeletmutations_bitstring.h:239
string getArg(string name)
Accessor to the parameters argument string.
Definition: param.h:285
int _dominance_model
Definition: ttdeletmutations_bitstring.h:233
double _strength
Definition: ttdeletmutations_bitstring.h:237
bool isSet()
Definition: param.h:138
void TProtoDeletMutations_bitstring::store_data ( BinaryStorageBuffer saver)
virtual

Implements StorableComponent.

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

384 {
385  saver->store(&_nb_locus,sizeof(int));
386  //store all bool on 1 byte
387  char dummy = _continuous_effects;
388  saver->store(&dummy, 1);
389  if(_continuous_effects) {
390  saver->store(_effects[0],_nb_locus * sizeof(float));
391  saver->store(_effects[1],_nb_locus * sizeof(float));
392  }
393 }
bool _continuous_effects
Definition: ttdeletmutations_bitstring.h:241
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:130
float ** _effects
Definition: ttdeletmutations_bitstring.h:249
unsigned int _nb_locus
Definition: ttdeletmutations_bitstring.h:230

Member Data Documentation

bool TProtoDeletMutations_bitstring::_continuous_effects
private
double TProtoDeletMutations_bitstring::_dist_p1
private
double TProtoDeletMutations_bitstring::_dist_p2
private
double TProtoDeletMutations_bitstring::_dominance
private
int TProtoDeletMutations_bitstring::_dominance_model
private
float** TProtoDeletMutations_bitstring::_effects
private
unsigned int TProtoDeletMutations_bitstring::_fitness_model
private

Referenced by hatch(), and setParameters().

double TProtoDeletMutations_bitstring::_fitness_scaling_factor
private

Referenced by hatch(), and setSelectionParameters().

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

Referenced by hatch(), and setParameters().

double TProtoDeletMutations_bitstring::_init_freq
private

Referenced by hatch(), and setParameters().

double TProtoDeletMutations_bitstring::_mut_rate
private

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

unsigned int TProtoDeletMutations_bitstring::_mutation_model
private

Referenced by hatch(), and setParameters().

unsigned int TProtoDeletMutations_bitstring::_nb_locus
private
TTDeletMutBitstrFH* TProtoDeletMutations_bitstring::_reader
private
double(TProtoDeletMutations_bitstring::* TProtoDeletMutations_bitstring::_set_effects_func)(void)
private
TTDeletMutBitstrSH* TProtoDeletMutations_bitstring::_stats
private
double TProtoDeletMutations_bitstring::_strength
private
double(TTDeletMutations_bitstring::* TProtoDeletMutations_bitstring::_viability_func_ptr)(void)
private
TTDeletMutBitstrFH* TProtoDeletMutations_bitstring::_writer
private

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

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR