Nemo  2.4.2
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
TProtoBDMI Class Reference

#include <ttbdmi.h>

+ Inheritance diagram for TProtoBDMI:
+ Collaboration diagram for TProtoBDMI:

Public Member Functions

 TProtoBDMI ()
 
 TProtoBDMI (const TProtoBDMI &TP)
 
virtual ~TProtoBDMI ()
 
int get_num_locus ()
 
double get_mut_rate ()
 
bool isHaploid ()
 
void set_init_freq (double *val, unsigned int size)
 
double get_init_freq (unsigned int i)
 
bool isInitSet ()
 
double getGenoFitnessHaplo (unsigned int row, unsigned int pos)
 
double getGenoFitnessDiplo (unsigned int row, unsigned int posA, unsigned int posB)
 
double getGenoFitnessDiplo (unsigned int row, unsigned int pos)
 
void setGenoFitnessValue (unsigned int row, unsigned int geno, double value)
 
void showGenoTable (unsigned int nrows)
 
void gamete_recombination (sex_t SEX, bitstring &seq, const bitstring *parent)
 
void inherit_free (sex_t SEX, bitstring &seq, const bitstring *parent)
 
void inherit_low (sex_t SEX, bitstring &seq, const bitstring *parent)
 
TraitPrototype Implementation


virtual void init ()
 
virtual TTraithatch ()
 
virtual TraitPrototypeclone ()
 
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 void reset ()
 
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

trait_t _type
 
bool _isHaploid
 
unsigned int _num_locus
 
unsigned int _npair
 
double _mut_rate
 
double _genomic_mut_rate
 
double _recomb_rate
 
double * _init_freq
 
bool _isInitSet
 
void(TT_BDMI::* _inherit_func_ptr )(const TTrait *, const TTrait *)
 
void(TProtoBDMI::* _gamete_recomb_func_ptr )(sex_t SEX, bitstring &seq, const bitstring *parent)
 
void(TT_BDMI::* _mutation_func_ptr )(void)
 
double(TT_BDMI::* _viability_func_ptr )(void)
 
TMatrix _genoTable
 
TTBDMI_SH_stater
 
TTBDMI_FH_writer
 

Static Private Attributes

static unsigned int _diploGenotTableCoding3x3 [3][3] = {{0,1,2},{3,4,5},{6,7,8}}
 
static unsigned int _diploGenotTableCoding4x4 [4][4] = {{0,1,2,3},{4,5,6,7},{8,9,10,11},{12,13,14,15}}
 

Friends

class TT_BDMI
 

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

Constructor & Destructor Documentation

◆ TProtoBDMI() [1/2]

TProtoBDMI::TProtoBDMI ( )
39  :
43 {
44  set_paramset("dmi", false, this);
45 
46  add_parameter("dmi_loci",INT,true,false, 0, 0);
47  add_parameter("dmi_is_haploid",BOOL,false,false, 0, 0);
48  add_parameter("dmi_mutation_rate",DBL,true,true, 0, 1, 0);
49  add_parameter("dmi_genot_table", MAT, true, 0, 0, 0);
50 
51  //genetic map parameters:
53 
54  add_parameter("dmi_save_genotype", BOOL, false, false, 0, 0, 0);
55  add_parameter("dmi_logtime", INT, false, false, 0, 0);
56  add_parameter("dmi_output_dir", STR, false, false, 0, 0);
57 
58 }
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:84
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:110
bool _isHaploid
Definition: ttbdmi.h:52
double * _init_freq
Definition: ttbdmi.h:58
TMatrix _genoTable
Definition: ttbdmi.h:68
double _recomb_rate
Definition: ttbdmi.h:57
double _genomic_mut_rate
Definition: ttbdmi.h:56
void(TProtoBDMI::* _gamete_recomb_func_ptr)(sex_t SEX, bitstring &seq, const bitstring *parent)
Definition: ttbdmi.h:64
TTBDMI_FH * _writer
Definition: ttbdmi.h:70
trait_t _type
Definition: ttbdmi.h:50
unsigned int _num_locus
Definition: ttbdmi.h:53
double _mut_rate
Definition: ttbdmi.h:55
double(TT_BDMI::* _viability_func_ptr)(void)
Definition: ttbdmi.h:66
unsigned int _npair
Definition: ttbdmi.h:54
bool _isInitSet
Definition: ttbdmi.h:59
void(TT_BDMI::* _mutation_func_ptr)(void)
Definition: ttbdmi.h:65
void(TT_BDMI::* _inherit_func_ptr)(const TTrait *, const TTrait *)
Definition: ttbdmi.h:63
TTBDMI_SH * _stater
Definition: ttbdmi.h:69
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:76
@ DBL
Definition: types.h:76
@ MAT
Definition: types.h:76
@ BOOL
Definition: types.h:76
@ STR
Definition: types.h:76
@ INT
Definition: types.h:76

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:

◆ TProtoBDMI() [2/2]

TProtoBDMI::TProtoBDMI ( const TProtoBDMI TP)
62  :
69 {
70  _paramSet = new ParamSet( *TP._paramSet );
71 }
Parameters container, implemented in each SimComponent.
Definition: param.h:214
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:46

References SimComponent::_paramSet.

◆ ~TProtoBDMI()

TProtoBDMI::~TProtoBDMI ( )
virtual
76 {
77  if(_stater) delete _stater;
78  if(_writer) delete _writer;
79  if(_init_freq) delete [] _init_freq;
80 }

References _init_freq, _stater, and _writer.

Member Function Documentation

◆ clone()

virtual TraitPrototype* TProtoBDMI::clone ( )
inlinevirtual

Implements TraitPrototype.

116 {return new TProtoBDMI(*this);}
TProtoBDMI()
Definition: ttbdmi.cc:39

References TProtoBDMI().

◆ gamete_recombination()

void TProtoBDMI::gamete_recombination ( sex_t  SEX,
bitstring seq,
const bitstring parent 
)
inline
285 {
286  (this->* _gamete_recomb_func_ptr)(SEX, seq, parent);
287 }

References _gamete_recomb_func_ptr.

Referenced by TT_BDMI::inherit_diplo(), and TT_BDMI::inherit_haplo().

+ Here is the caller graph for this function:

◆ get_allele_number()

virtual int TProtoBDMI::get_allele_number ( )
inlinevirtual

Returns the number of allele per locus.

Implements TraitPrototype.

121 {return 2;}

◆ get_init_freq()

double TProtoBDMI::get_init_freq ( unsigned int  i)
inline
84 {return _init_freq[i];}

References _init_freq.

Referenced by TT_BDMI::init_sequence().

+ Here is the caller graph for this function:

◆ get_locus_number()

virtual int TProtoBDMI::get_locus_number ( )
inlinevirtual

Returns the number of locus.

Implements TraitPrototype.

123 {return _num_locus;}

References _num_locus.

◆ get_mut_rate()

double TProtoBDMI::get_mut_rate ( )
inline
81 {return _mut_rate;}

References _mut_rate.

◆ get_num_locus()

int TProtoBDMI::get_num_locus ( )
inline

◆ get_phenotype_dimension()

virtual int TProtoBDMI::get_phenotype_dimension ( )
inlinevirtual

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

Implements TraitPrototype.

119 {return 1;}

◆ get_type()

virtual trait_t TProtoBDMI::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

117 {return _type;}

References _type.

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

+ Here is the caller graph for this function:

◆ getGenoFitnessDiplo() [1/2]

double TProtoBDMI::getGenoFitnessDiplo ( unsigned int  row,
unsigned int  pos 
)
inline
98  {
99  assert(pos < 16);
100  return _genoTable.get(row, pos);
101  }
double get(unsigned int i, unsigned int j) const
Accessor to element at row i and column j.
Definition: tmatrix.h:191

References _genoTable, and TMatrix::get().

◆ getGenoFitnessDiplo() [2/2]

double TProtoBDMI::getGenoFitnessDiplo ( unsigned int  row,
unsigned int  posA,
unsigned int  posB 
)
inline
93  {
94  return _genoTable.get(row, _diploGenotTableCoding4x4[posA][posB] );
95  }
static unsigned int _diploGenotTableCoding4x4[4][4]
Definition: ttbdmi.h:61

References _diploGenotTableCoding4x4, _genoTable, and TMatrix::get().

Referenced by TT_BDMI::get_allele_value(), and TT_BDMI::viability_diplo().

+ Here is the caller graph for this function:

◆ getGenoFitnessHaplo()

double TProtoBDMI::getGenoFitnessHaplo ( unsigned int  row,
unsigned int  pos 
)
inline
87  {
88  assert(pos < 4);
89  return _genoTable.get(row, pos);
90  }

References _genoTable, and TMatrix::get().

Referenced by TT_BDMI::get_allele_value(), and TT_BDMI::viability_haplo().

+ Here is the caller graph for this function:

◆ hatch()

TTrait * TProtoBDMI::hatch ( )
virtual

Implements TraitPrototype.

240 {
241  TT_BDMI* chick = new TT_BDMI();
242 
243  chick->set_proto (this);
244  return chick;
245 }
friend class TT_BDMI
Definition: ttbdmi.h:72
Definition: ttbdmi.h:148
void set_proto(TProtoBDMI *proto)
Definition: ttbdmi.h:175

References TT_BDMI::set_proto(), and TT_BDMI.

◆ inherit_free()

void TProtoBDMI::inherit_free ( sex_t  SEX,
bitstring seq,
const bitstring parent 
)
inline
292 {
293  for(unsigned int i = 0; i < _num_locus; ++i) {
294  seq[i] = parent[RAND::RandBool()][i];
295  }
296 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:170

References _num_locus, and RAND::RandBool().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ inherit_low()

void TProtoBDMI::inherit_low ( sex_t  SEX,
bitstring seq,
const bitstring parent 
)
inline
301 {
302 
303  unsigned int prevLoc = 0;
304 
305 
306  //the table containing the loci at which x-overs happen; < position, side >
307  vector< pair<unsigned int, unsigned int> > recTable = _map.reduceJunctions(SEX, _mapIndex);
308 
309 
310 #ifdef _REC_DEBUG_
311  //number of x-overs
312  unsigned int nbRec = recTable.size();
313  cout << "TProtoBDMI::inherit_low; nb Rec = "<<nbRec - 1<<endl;
314  cout << " --sex = "<<SEX<<"\n";
315 #endif
316 
317  // unsigned int num_copied = 0;
318 
319  vector< pair<unsigned int, unsigned int> >::const_iterator xover = recTable.begin();
320 
321  while(xover != recTable.end()) {
322 
323 #ifdef _REC_DEBUG_
324  cout<< " copy seq from "<<prevLoc<<" to "<<xover->first
325  <<" ("<<(xover->first - prevLoc)<<" loc) ("
326  <<(xover->first - prevLoc)
327  <<" bits) on side "<<xover->second<<std::endl;
328 #endif
329 
330  seq.copy( parent[xover->second], prevLoc, xover->first);
331 
332  prevLoc = xover->first;
333 
334  xover++;
335  }
336 
337 
338 // bool flipper;
339 //
340 // vector< unsigned int >& recTable = _map.getRecLoci(SEX, _mapIndex);
341 // vector< bool > & firstRecPos = _map.getFirstRecPosition(SEX);
342 //
343 // nbRec = recTable.size();
344 //
345 // for(unsigned int c = 0, stride = 0, rec = 0; c < _numChromosome; ++c) {
346 //
347 // flipper = firstRecPos[c];
348 //
349 // chrm_bloc = stride + _numLociPerChrmsm[c]; //number of loci considered so far
350 //
351 // prevLoc = stride; //stride is the first locus of a chromosome
352 //
353 // //do recombination chromosome-wise
354 // for(; recTable[rec] < chrm_bloc && rec < nbRec; rec++) {
355 //
356 // seq->copy( *parent[flipper], prevLoc, recTable[rec]);
357 //
358 // prevLoc = recTable[rec];
359 //
360 // flipper = !flipper;
361 // }
362 //
363 // //copy what's left between the last x-over point and the end of the chrmsme
364 // seq->copy( *parent[flipper], prevLoc, chrm_bloc);
365 //
366 // stride += _numLociPerChrmsm[c];
367 //
368 // }
369 
370 }
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:1312
static GeneticMap _map
Definition: ttrait_with_map.h:227
unsigned int _mapIndex
Definition: ttrait_with_map.h:211
void copy(const bitstring &b)
Unchecked copy, assumes we have sames sizes.
Definition: bitstring.h:357

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

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ init()

virtual void TProtoBDMI::init ( )
inlinevirtual
114 {setParameters();}
virtual bool setParameters()
Definition: ttbdmi.cc:85

References setParameters().

◆ isHaploid()

bool TProtoBDMI::isHaploid ( )
inline
82 {return _isHaploid;}

References _isHaploid.

Referenced by TTBDMI_FH::FHwrite(), TTBDMI_SH::setAdultStats(), TTBDMI_SH::setOffsprgStats(), and TTBDMI_SH::setStats().

+ Here is the caller graph for this function:

◆ isInitSet()

bool TProtoBDMI::isInitSet ( )
inline
85 {return _isInitSet;}

References _isInitSet.

Referenced by TT_BDMI::init_sequence().

+ Here is the caller graph for this function:

◆ loadFileServices()

void TProtoBDMI::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

193 {
194  //writer
195  if(get_parameter("dmi_save_genotype")->isSet()) {
196 
197  if(_writer == NULL) _writer = new TTBDMI_FH(this);
198 
199  Param* param = get_parameter("dmi_logtime");
200 
201  if(!param->isSet() )
202  fatal("dmi trait::parameter \"dmi_logtime\" is required to set the periodicity of the output file\n");
203 
204  if(param->isMatrix()) {
205 
206  TMatrix temp;
207 
208  param->getMatrix(&temp);
209 
210  _writer->set_multi(true, true, 1, &temp, get_parameter("dmi_output_dir")->getArg(), this);
211 
212  } else {
213  // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
214  _writer->set(true, true, 1, (int)param->getValue(), 0, get_parameter("dmi_output_dir")->getArg(),this);
215  }
216 
217  loader->attach(_writer);
218 
219  } else if(_writer != NULL) {
220  delete _writer;
221  _writer = NULL;
222  }
223 }
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:59
This structure stores one parameter, its definition and its string argument.
Definition: param.h:52
double getValue()
Returns the argument value according to its type.
Definition: param.cc:386
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:180
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:396
bool isSet()
Definition: param.h:146
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:137
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:48
FileHandler for the DBMI trait.
Definition: ttbdmi.h:237
virtual void set_multi(bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path, TP *trait_proto)
Definition: filehandler.h:246
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:239
void fatal(const char *str,...)
Definition: output.cc:98

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

◆ loadStatServices()

void TProtoBDMI::loadStatServices ( StatServices loader)
virtual

Implements SimComponent.

228 {
229  if(_stater != NULL)
230  delete _stater;
231 
232  _stater = new TTBDMI_SH(this);
233 
234  loader->attach(_stater);
235 }
virtual void attach(Handler *H)
attach the StatHandler to the current list (_statHandlers) of the StatServices
Definition: statservices.cc:175
StatHandler for the DBMI trait.
Definition: ttbdmi.h:260

References _stater, and StatServices::attach().

◆ resetParameterFromSource()

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

Implements SimComponent.

139 {return false;}

◆ retrieve_data()

bool TProtoBDMI::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

373 {
374  int dummy_int;
375  bool dummy_bool;
376 
377  reader->read(&dummy_int, sizeof(int));
378 
379  if(dummy_int != _num_locus) {
380  warning("DMI mutation trait::locus number in binary source file differs from parameter value!\n\
381  >>>> adjusting locus number to match source population: %i set to %i\n", _num_locus, dummy_int);
382  _num_locus = dummy_int;
383  }
384  reader->read(&_isHaploid, sizeof(bool));
385 
386  if(dummy_bool != _isHaploid){
387  warning("DMI mutation trait::haploidy in binary source file differs from parameter value!\n\
388  >>>> adjusting haploidy to match source population: %i set to %i\n", _isHaploid, dummy_bool);
389  _isHaploid = dummy_bool;
390  }
391 
392  return true;
393 }
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:219
void warning(const char *str,...)
Definition: output.cc:56

References _isHaploid, _num_locus, BinaryStorageBuffer::read(), and warning().

◆ set_init_freq()

void TProtoBDMI::set_init_freq ( double *  val,
unsigned int  size 
)
250 {
251  assert(size == _num_locus);
252 
253  if(_init_freq) delete [] _init_freq;
254 
255  _init_freq = new double [size];
256 
257  memcpy(_init_freq, val, size*sizeof(double));
258 
259  _isInitSet = true;
260 }

References _init_freq, _isInitSet, and _num_locus.

Referenced by LCE_Init_BDMI::execute().

+ Here is the caller graph for this function:

◆ setGenoFitnessValue()

void TProtoBDMI::setGenoFitnessValue ( unsigned int  row,
unsigned int  geno,
double  value 
)
inline
104  { _genoTable.set(row, geno, value); }
void set(unsigned int i, unsigned int j, double val)
Sets element at row i and column j to value val.
Definition: tmatrix.h:101

References _genoTable, and TMatrix::set().

Referenced by TT_BDMI::set_allele_value().

+ Here is the caller graph for this function:

◆ setParameters()

bool TProtoBDMI::setParameters ( )
virtual

Implements SimComponent.

86 {
87  _num_locus = (unsigned int)get_parameter_value("dmi_loci");
88 
89  if(_num_locus%2)
90  return error("dmi trait: the number of loci must be an even number; incompatible loci go by pair!\n");
91 
92  _npair = _num_locus/2;
93  _mut_rate = get_parameter_value("dmi_mutation_rate");
94 
95  if(get_parameter("dmi_is_haploid")->isSet())
96  _isHaploid = (bool)get_parameter_value("dmi_is_haploid");
97  else
98  _isHaploid = 0; //diploid by default
99 
101 
102  if(_isHaploid){
106  } else {
110  }
111 
112  //setting the incompatibility table:
113  get_parameter("dmi_genot_table")->getMatrix(&_genoTable);
114 
115  //checks on size of genoTable
116  if(_isHaploid && _genoTable.ncols() != 4)
117  return error("dmi trait: the genotype fitness table must have 4 elements per locus pair in the haploid case.");
118 
119  if(!_isHaploid) {
120  if(_genoTable.ncols() != 9 && _genoTable.ncols() != 16)
121  return error("dmi trait: the genotype fitness table must have 9 or 16 elements per locus pair in the diploid case.");
122  }
123 
124  if(_genoTable.nrows() > _npair )
125  return error("dmi trait: the number of rows of the genotype fitness table exceeds the number of locus pairs.\n");
126 
127  if(_genoTable.nrows() < _npair ) {
128  // we need to expand the table, copying the existing rows to complete the table
129  TMatrix cpymat(_genoTable);
130 
131  _genoTable.reset(_npair, cpymat.ncols());
132 
133  _genoTable.copy_recycle(cpymat);
134  }
135 
136  if(_genoTable.ncols() == 9)
137  {
138  // expand to the 16 genotype values; we copy the heterozygotes values (aABB -> AaBB, etc)
139  // the order is:
140  // 9 elements: {0=AABB, 1=AABb/AAbB, 2=AAbb}, {3=AaBB/aABB, 4=AaBb/aABb/AabB/aAbB, 5=Aabb/aAbb}, {6=aaBB, 7=aaBb/aabB, 8=aabb}
141  // 16 elements:{0=AABB, 1=AABb, 2=AAbB, 3=AAbb},{4=AaBB, 5=AaBb, 6=AabB, 7=Aabb},{8=aABB, 9=aABb, 10=aAbB, 11=aAbb},{12=aaBB, 13=aaBb, 14=aabB, 15=aabb}
142 
143  // indexes of elements in the 9-table to convert a 9-table into a 16-table:
144  unsigned int index[16] = {0,1,1,2,3,4,4,5,3,4,4,5,6,7,7,8};
145 
146  //backup:
147  TMatrix oldmat(_genoTable);
148 
149  //expand the genotable to hold 16 elements per row
150  _genoTable.reset(oldmat.nrows(), 16);
151 
152  //copy values from the 9-table into the 16-table using the indexes of elements in the 9-table
153  for(unsigned int i = 0; i < oldmat.nrows(); ++i)
154  for(unsigned int j = 0; j < 16; ++j)
155  _genoTable.set(i, j, oldmat.get(i, index[j]));
156 
157  }
158 
159  _isInitSet = 0;
160 
161 #ifdef _DEBUG_
162  message("::TProtoBDMI::\nFitness table:\n");
164 #endif
165 
166  // RECOMBINATION ------------------------------------------------------------------------------------
167 
168  //bypass the genetic map for free recombination to save significant time:
169  //this is done whenever the recombination rate is set to 0.5
170 
171  if( TTProtoWithMap::isRecombinationFree("dmi")) { //test all possible options to set recomb rate = 0.5
172 
174 
176 
177  } else {
178  // loci are not independent, ie recomb rate < 0.5
179 
180  // the loci positions will be registered in the genetic map
181  if( !TTProtoWithMap::setGeneticMapParameters ("dmi") ) return false;
182 
184 
185  }
186 
187  return true;
188 }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:141
void reset(unsigned int rows, unsigned int cols)
Re-allocate the existing matrix with assigned rows and cols dimensions and all elements to 0.
Definition: tmatrix.h:159
unsigned int ncols() const
Definition: tmatrix.h:214
void copy_recycle(const TMatrix &mat)
Copy elements of 'mat', recycling elements of 'mat' if its size is smaller than current matrix.
Definition: tmatrix.h:88
unsigned int nrows() const
Definition: tmatrix.h:211
void inherit_free(sex_t SEX, bitstring &seq, const bitstring *parent)
Definition: ttbdmi.cc:291
void inherit_low(sex_t SEX, bitstring &seq, const bitstring *parent)
Definition: ttbdmi.cc:300
void showGenoTable(unsigned int nrows)
Definition: ttbdmi.cc:264
double _recombRate
Definition: ttrait_with_map.h:213
bool setGeneticMapParameters(string prefix, unsigned int numLoci=0)
Definition: ttrait_with_map.cc:124
bool isRecombinationFree(string prefix)
Definition: ttrait_with_map.cc:97
void mutate_diplo()
Definition: ttbdmi.cc:591
double viability_diplo()
Definition: ttbdmi.cc:628
double viability_haplo()
Definition: ttbdmi.cc:614
void inherit_haplo(const TTrait *mother, const TTrait *father)
Definition: ttbdmi.cc:557
void mutate_haplo()
Definition: ttbdmi.cc:575
void inherit_diplo(const TTrait *mother, const TTrait *father)
Definition: ttbdmi.cc:546
int error(const char *str,...)
Definition: output.cc:77
void message(const char *message,...)
Definition: output.cc:38

References _gamete_recomb_func_ptr, _genomic_mut_rate, _genoTable, _inherit_func_ptr, _isHaploid, _isInitSet, _mut_rate, _mutation_func_ptr, _npair, _num_locus, TTProtoWithMap::_recombRate, _viability_func_ptr, TMatrix::copy_recycle(), error(), TMatrix::get(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), Param::getMatrix(), TT_BDMI::inherit_diplo(), inherit_free(), TT_BDMI::inherit_haplo(), inherit_low(), TTProtoWithMap::isRecombinationFree(), message(), TT_BDMI::mutate_diplo(), TT_BDMI::mutate_haplo(), TMatrix::ncols(), TMatrix::nrows(), TMatrix::reset(), TMatrix::set(), TTProtoWithMap::setGeneticMapParameters(), showGenoTable(), TT_BDMI::viability_diplo(), and TT_BDMI::viability_haplo().

Referenced by init().

+ Here is the caller graph for this function:

◆ showGenoTable()

void TProtoBDMI::showGenoTable ( unsigned int  nrows)
265 {
266  unsigned int len = (_isHaploid ? 4 : 16);
267 
268  if(_isHaploid)
269  cout << "AB\taB\tAb\tab\n";
270  else
271  cout << "AABB\tAaBB\taaBB\t AABb\tAaBb\taaBb\t AAbb\tAabb\taabb\n";
272 
273  for (unsigned int i = 0; i < nrows; ++i) {
274  cout << i+1 << ": ";
275  for (unsigned int j = 0; j < len ; ++j) {
276  cout << _genoTable.get(i, j) << "\t";
277  }
278  cout << endl;
279  }
280 }

References _genoTable, _isHaploid, and TMatrix::get().

Referenced by setParameters(), and TT_BDMI::show_up().

+ Here is the caller graph for this function:

◆ store_data()

virtual void TProtoBDMI::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

128  {
129  saver->store(&_num_locus, sizeof(int));
130  saver->store(&_isHaploid, sizeof(bool));
131  }
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:36

References _isHaploid, _num_locus, and BinaryStorageBuffer::store().

Friends And Related Function Documentation

◆ TT_BDMI

friend class TT_BDMI
friend

Referenced by hatch().

Member Data Documentation

◆ _diploGenotTableCoding3x3

unsigned int TProtoBDMI::_diploGenotTableCoding3x3 = {{0,1,2},{3,4,5},{6,7,8}}
staticprivate

◆ _diploGenotTableCoding4x4

unsigned int TProtoBDMI::_diploGenotTableCoding4x4 = {{0,1,2,3},{4,5,6,7},{8,9,10,11},{12,13,14,15}}
staticprivate

Referenced by getGenoFitnessDiplo().

◆ _gamete_recomb_func_ptr

void(TProtoBDMI::* TProtoBDMI::_gamete_recomb_func_ptr) (sex_t SEX, bitstring &seq, const bitstring *parent)
private

◆ _genomic_mut_rate

double TProtoBDMI::_genomic_mut_rate
private

◆ _genoTable

◆ _inherit_func_ptr

void(TT_BDMI::* TProtoBDMI::_inherit_func_ptr) (const TTrait *, const TTrait *)
private

Referenced by TT_BDMI::inherit(), and setParameters().

◆ _init_freq

double* TProtoBDMI::_init_freq
private

◆ _isHaploid

◆ _isInitSet

bool TProtoBDMI::_isInitSet
private

◆ _mut_rate

double TProtoBDMI::_mut_rate
private

Referenced by get_mut_rate(), and setParameters().

◆ _mutation_func_ptr

void(TT_BDMI::* TProtoBDMI::_mutation_func_ptr) (void)
private

Referenced by TT_BDMI::mutate(), and setParameters().

◆ _npair

unsigned int TProtoBDMI::_npair
private

◆ _num_locus

◆ _recomb_rate

double TProtoBDMI::_recomb_rate
private

◆ _stater

TTBDMI_SH* TProtoBDMI::_stater
private

Referenced by loadStatServices(), and ~TProtoBDMI().

◆ _type

trait_t TProtoBDMI::_type
private

Referenced by get_type().

◆ _viability_func_ptr

double(TT_BDMI::* TProtoBDMI::_viability_func_ptr) (void)
private

◆ _writer

TTBDMI_FH* TProtoBDMI::_writer
private

Referenced by loadFileServices(), and ~TProtoBDMI().


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

Generated for Nemo v2.4.2 by  doxygen 1.9.1

Catalogued on GSR