Nemo  2.4.0b
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)
 
Implementations


virtual void init ()
 
virtual TTraithatch ()
 
virtual TraitPrototypeclone ()
 
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)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
- Public Member Functions inherited from TTProtoWithMap
 TTProtoWithMap ()
 
 TTProtoWithMap (const TTProtoWithMap &TP)
 
virtual ~TTProtoWithMap ()
 
void setMapIndex (unsigned int idx)
 
unsigned int getMapIndex ()
 
bool setGeneticMapParameters (string prefix)
 
void addGeneticMapParameters (string prefix)
 
bool setRecombinationMapRandom ()
 
bool setRecombinationMapNonRandom (vector< vector< double > > *lociPositions)
 
bool setRecombinationMapFixed ()
 
bool setNumLociPerChromosome (string param_name)
 
void reset_recombination_pointers ()
 
void registerGeneticMap ()
 
void unregisterFromGeneticMap ()
 
bool areGeneticMapParamSet (string prefix)
 
bool isRecombinationFree (string prefix)
 
void recordRandomMap ()
 
virtual void reset ()
 
- 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 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 ( )
40  :
44 {
45  set_paramset("dmi", false, this);
46 
47  add_parameter("dmi_loci",INT,true,false, 0, 0);
48  add_parameter("dmi_is_haploid",BOOL,false,false, 0, 0);
49  add_parameter("dmi_mutation_rate",DBL,true,true, 0, 1, 0);
50  add_parameter("dmi_genot_table", MAT, true, 0, 0, 0);
51 
52  //genetic map parameters:
54 
55  add_parameter("dmi_save_genotype", BOOL, false, false, 0, 0, 0);
56  add_parameter("dmi_logtime", INT, false, false, 0, 0);
57  add_parameter("dmi_output_dir", STR, false, false, 0, 0);
58 
59 }
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
bool _isHaploid
Definition: ttbdmi.h:54
double * _init_freq
Definition: ttbdmi.h:60
TMatrix _genoTable
Definition: ttbdmi.h:70
double _recomb_rate
Definition: ttbdmi.h:59
double _genomic_mut_rate
Definition: ttbdmi.h:58
void(TProtoBDMI::* _gamete_recomb_func_ptr)(sex_t SEX, bitstring &seq, const bitstring *parent)
Definition: ttbdmi.h:66
TTBDMI_FH * _writer
Definition: ttbdmi.h:72
trait_t _type
Definition: ttbdmi.h:52
unsigned int _num_locus
Definition: ttbdmi.h:55
double _mut_rate
Definition: ttbdmi.h:57
double(TT_BDMI::* _viability_func_ptr)(void)
Definition: ttbdmi.h:68
unsigned int _npair
Definition: ttbdmi.h:56
bool _isInitSet
Definition: ttbdmi.h:61
void(TT_BDMI::* _mutation_func_ptr)(void)
Definition: ttbdmi.h:67
void(TT_BDMI::* _inherit_func_ptr)(const TTrait *, const TTrait *)
Definition: ttbdmi.h:65
TTBDMI_SH * _stater
Definition: ttbdmi.h:71
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:77
@ DBL
Definition: types.h:78
@ MAT
Definition: types.h:78
@ BOOL
Definition: types.h:78
@ STR
Definition: types.h:78
@ INT
Definition: types.h:78

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

Referenced by clone().

◆ TProtoBDMI() [2/2]

TProtoBDMI::TProtoBDMI ( const TProtoBDMI TP)
63  :
70 {
71  _paramSet = new ParamSet( *TP._paramSet );
72 }
Parameters container, implemented in each SimComponent.
Definition: param.h:206
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48

References SimComponent::_paramSet.

◆ ~TProtoBDMI()

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

References _init_freq, _stater, and _writer.

Member Function Documentation

◆ clone()

virtual TraitPrototype* TProtoBDMI::clone ( )
inlinevirtual

Implements TraitPrototype.

118 {return new TProtoBDMI(*this);}
TProtoBDMI()
Definition: ttbdmi.cc:40

References TProtoBDMI().

◆ gamete_recombination()

void TProtoBDMI::gamete_recombination ( sex_t  SEX,
bitstring seq,
const bitstring parent 
)
inline
282 {
283  (this->* _gamete_recomb_func_ptr)(SEX, seq, parent);
284 }

References _gamete_recomb_func_ptr.

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

◆ get_init_freq()

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

References _init_freq.

Referenced by TT_BDMI::init_sequence().

◆ get_mut_rate()

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

References _mut_rate.

◆ get_num_locus()

◆ get_type()

virtual trait_t TProtoBDMI::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

119 {return _type;}

References _type.

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

◆ getGenoFitnessDiplo() [1/2]

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

References _genoTable, and TMatrix::get().

◆ getGenoFitnessDiplo() [2/2]

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

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

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

◆ getGenoFitnessHaplo()

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

References _genoTable, and TMatrix::get().

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

◆ hatch()

TTrait * TProtoBDMI::hatch ( )
virtual

Implements TraitPrototype.

237 {
238  TT_BDMI* chick = new TT_BDMI();
239 
240  chick->set_proto (this);
241  return chick;
242 }
friend class TT_BDMI
Definition: ttbdmi.h:74
Definition: ttbdmi.h:141
void set_proto(TProtoBDMI *proto)
Definition: ttbdmi.h:168

References TT_BDMI::set_proto(), and TT_BDMI.

◆ inherit_free()

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

References _num_locus, and RAND::RandBool().

Referenced by setParameters().

◆ inherit_low()

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

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

Referenced by setParameters().

◆ init()

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

References setParameters().

◆ isHaploid()

bool TProtoBDMI::isHaploid ( )
inline

◆ isInitSet()

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

References _isInitSet.

Referenced by TT_BDMI::init_sequence().

◆ loadFileServices()

void TProtoBDMI::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

194 {
195  //writer
196  if(get_parameter("dmi_save_genotype")->isSet()) {
197 
198  if(_writer == NULL) _writer = new TTBDMI_FH(this);
199 
200  Param* param = get_parameter("dmi_logtime");
201 
202  if(param->isMatrix()) {
203 
204  TMatrix temp;
205  param->getMatrix(&temp);
206  _writer->set_multi(true, true, 1, &temp, get_parameter("dmi_output_dir")->getArg(), this);
207 
208  } else {
209  // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
210  _writer->set(true, true, 1, (param->isSet() ? (int)param->getValue() : 0),
211  0, get_parameter("dmi_output_dir")->getArg(),this);
212  }
213 
214  loader->attach(_writer);
215 
216  } else if(_writer != NULL) {
217  delete _writer;
218  _writer = NULL;
219  }
220 }
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:61
This structure stores one parameter, its definition and its string argument.
Definition: param.h:54
double getValue()
Returns the argument value according to its type.
Definition: param.cc:368
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:172
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:378
bool isSet()
Definition: param.h:140
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:50
FileHandler for the DBMI trait.
Definition: ttbdmi.h:229
virtual void set_multi(bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path, TP *trait_proto)
Definition: filehandler.h:244
virtual void set(bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path, TP *trait_proto)
Definition: filehandler.h:237

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

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

References _stater, and StatServices::attach().

◆ resetParameterFromSource()

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

Implements SimComponent.

132 {return false;}

◆ retrieve_data()

bool TProtoBDMI::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

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

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

◆ set_init_freq()

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

References _init_freq, _isInitSet, and _num_locus.

Referenced by LCE_Init_BDMI::execute().

◆ setGenoFitnessValue()

void TProtoBDMI::setGenoFitnessValue ( unsigned int  row,
unsigned int  geno,
double  value 
)
inline
106  { _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:103

References _genoTable, and TMatrix::set().

Referenced by TT_BDMI::set_allele_value().

◆ setParameters()

bool TProtoBDMI::setParameters ( )
virtual

Implements SimComponent.

87 {
88  _num_locus = (unsigned int)get_parameter_value("dmi_loci");
89 
90  if(_num_locus%2)
91  return error("dmi trait: the number of loci must be an even number; incompatible loci go by pair!\n");
92 
93  _npair = _num_locus/2;
94  _mut_rate = get_parameter_value("dmi_mutation_rate");
95 
96  if(get_parameter("dmi_is_haploid")->isSet())
97  _isHaploid = (bool)get_parameter_value("dmi_is_haploid");
98  else
99  _isHaploid = 0; //diploid by default
100 
102 
103  if(_isHaploid){
107  } else {
111  }
112 
113  //setting the incompatibility table:
114  get_parameter("dmi_genot_table")->getMatrix(&_genoTable);
115 
116  //checks on size of genoTable
117  if(_isHaploid && _genoTable.ncols() != 4)
118  return error("dmi trait: the genotype fitness table must have 4 elements per locus pair in the haploid case.");
119 
120  if(!_isHaploid) {
121  if(_genoTable.ncols() != 9 && _genoTable.ncols() != 16)
122  return error("dmi trait: the genotype fitness table must have 9 or 16 elements per locus pair in the diploid case.");
123  }
124 
125  if(_genoTable.nrows() > _npair )
126  return error("dmi trait: the number of rows of the genotype fitness table exceeds the number of locus pairs.\n");
127 
128  if(_genoTable.nrows() < _npair ) {
129  // we need to expand the table, copying the existing rows to complete the table
130  TMatrix cpymat(_genoTable);
131 
132  _genoTable.reset(_npair, cpymat.ncols());
133 
134  _genoTable.copy_recycle(cpymat);
135  }
136 
137  if(_genoTable.ncols() == 9)
138  {
139  // expand to the 16 genotype values; we copy the heterozygotes values (aABB -> AaBB, etc)
140  // the order is:
141  // 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}
142  // 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}
143 
144  // indexes of elements in the 9-table to convert a 9-table into a 16-table:
145  unsigned int index[16] = {0,1,1,2,3,4,4,5,3,4,4,5,6,7,7,8};
146 
147  //backup:
148  TMatrix oldmat(_genoTable);
149 
150  //expand the genotable to hold 16 elements per row
151  _genoTable.reset(oldmat.nrows(), 16);
152 
153  //copy values from the 9-table into the 16-table using the indexes of elements in the 9-table
154  for(unsigned int i = 0; i < oldmat.nrows(); ++i)
155  for(unsigned int j = 0; j < 16; ++j)
156  _genoTable.set(i, j, oldmat.get(i, index[j]));
157 
158  }
159 
160  _isInitSet = 0;
161 
162 #ifdef _DEBUG_
163  message("::TProtoBDMI::\nFitness table:\n");
165 #endif
166 
167  // RECOMBINATION ------------------------------------------------------------------------------------
168 
169  //bypass the genetic map for free recombination to save significant time:
170  //this is done whenever the recombination rate is set to 0.5
171 
172  if( TTProtoWithMap::isRecombinationFree("dmi")) { //test all possible options to set recomb rate = 0.5
173 
175 
177 
178  } else {
179  // loci are not independent, ie recomb rate < 0.5
180 
181  // the loci positions will be registered in the genetic map
182  if( !TTProtoWithMap::setGeneticMapParameters ("dmi") ) return false;
183 
185 
186  }
187 
188  return true;
189 }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
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:161
unsigned int ncols() const
Definition: tmatrix.h:216
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:90
unsigned int nrows() const
Definition: tmatrix.h:213
void inherit_free(sex_t SEX, bitstring &seq, const bitstring *parent)
Definition: ttbdmi.cc:288
void inherit_low(sex_t SEX, bitstring &seq, const bitstring *parent)
Definition: ttbdmi.cc:297
void showGenoTable(unsigned int nrows)
Definition: ttbdmi.cc:261
double _recombRate
Definition: ttrait_with_map.h:195
bool isRecombinationFree(string prefix)
Definition: ttrait_with_map.cc:98
bool setGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:125
void mutate_diplo()
Definition: ttbdmi.cc:580
double viability_diplo()
Definition: ttbdmi.cc:617
double viability_haplo()
Definition: ttbdmi.cc:603
void inherit_haplo(const TTrait *mother, const TTrait *father)
Definition: ttbdmi.cc:546
void mutate_haplo()
Definition: ttbdmi.cc:564
void inherit_diplo(const TTrait *mother, const TTrait *father)
Definition: ttbdmi.cc:535
int error(const char *str,...)
Definition: output.cc:77
void message(const char *message,...)
Definition: output.cc:40

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

◆ showGenoTable()

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

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

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

◆ store_data()

virtual void TProtoBDMI::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

123  {
124  saver->store(&_num_locus, sizeof(int));
125  saver->store(&_isHaploid, sizeof(bool));
126  }
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16

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

Locations of visitors to this page
Catalogued on GSR