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

Prototype class for the TTNeutralGenes trait class. More...

#include <ttneutralgenes.h>

+ Inheritance diagram for TProtoNeutralGenes:
+ Collaboration diagram for TProtoNeutralGenes:

Public Member Functions

 TProtoNeutralGenes ()
 
 TProtoNeutralGenes (const TProtoNeutralGenes &T)
 
virtual ~TProtoNeutralGenes ()
 
unsigned int get_ploidy ()
 
unsigned int get_locus_num ()
 
unsigned int get_allele_num ()
 
double get_mut_rate ()
 
unsigned int get_genome_size ()
 
unsigned int get_num_mutations ()
 
unsigned int get_init_model ()
 
TTNeutralGenesSHget_stater ()
 
void inherit_low (sex_t SEX, unsigned char *seq, const unsigned char **parent)
 
void inherit_free (sex_t SEX, unsigned char *seq, const unsigned char **parent)
 
virtual void init ()
 
virtual void reset ()
 
virtual TTNeutralGeneshatch ()
 
virtual TProtoNeutralGenesclone ()
 
virtual trait_t get_type () const
 
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
virtual void store_data (BinaryStorageBuffer *saver)
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)
 
- Public Member Functions inherited from TTProtoWithMap
 TTProtoWithMap ()
 
 TTProtoWithMap (const TTProtoWithMap &TP)
 
virtual ~TTProtoWithMap ()
 
void setMapIndex (unsigned int idx)
 
unsigned int getMapIndex ()
 
bool setGeneticMapParameters (string prefix)
 
void addGeneticMapParameters (string prefix)
 
bool setRecombinationMapRandom ()
 
bool setRecombinationMapNonRandom (vector< vector< double > > *lociPositions)
 
bool setRecombinationMapFixed ()
 
bool setNumLociPerChromosome (string param_name)
 
void reset_recombination_pointers ()
 
void registerGeneticMap ()
 
void unregisterFromGeneticMap ()
 
bool areGeneticMapParamSet (string prefix)
 
bool isRecombinationFree (string prefix)
 
void recordRandomMap ()
 
- Public Member Functions inherited from TraitPrototype
virtual void set_index (int idx)
 Sets the traits index. More...
 
virtual int get_index ()
 Index getter. More...
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 Sets a new ParamSet and name it. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 

Private Attributes

unsigned int _allele_num
 
unsigned int _locus_num
 
unsigned int _ploidy
 
double _mut_rate
 
int _mut_model
 
unsigned int _2L
 
unsigned int _init_model
 
double _recomb_rate
 
void(TTNeutralGenes::* _mutate_func_ptr )(void)
 
void(TProtoNeutralGenes::* _inherit_func_ptr )(sex_t, unsigned char *, const unsigned char **)
 
vector< TTNeutralGenesFH * > _writers
 
TTNOhtaStats_ohtaStats
 
TTNeutralGenesSH_stats
 
const trait_t _type
 

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 for the TTNeutralGenes trait class.

Constructor & Destructor Documentation

◆ TProtoNeutralGenes() [1/2]

TProtoNeutralGenes::TProtoNeutralGenes ( )
51  :_allele_num(0), _locus_num(0), _ploidy(2), _mut_rate(0),
53  _ohtaStats(0),_stats(0), _type(NTRL)
54 {
55  set_paramset("neutralgenes", false, this);
56 
57  add_parameter("ntrl_loci", INT, true, false, 0, 0);
58  add_parameter("ntrl_init_model", INT, false, true, 0, 3);
59  add_parameter("ntrl_all", INT, true, true, 2, 256);
60  add_parameter("ntrl_mutation_rate", DBL, true, true, 0, 1);
61  add_parameter("ntrl_mutation_model", INT, true, true, 0, 2);
62 
63  //genetic map parameters:
65 
66  //output
67  add_parameter("ntrl_save_genotype", STR, false, false, 0, 0);
68  add_parameter("ntrl_save_fsti", BOOL, false, false, 0, 0);
69  add_parameter("ntrl_save_freq", STR, false, false, 0, 0);
70  add_parameter("ntrl_output_dir", STR, false, false, 0, 0);
71  add_parameter("ntrl_output_logtime", INT, false, false, 0, 0);
72  add_parameter("ntrl_ohta_output", BOOL,false,false,0,0);
73  add_parameter("ntrl_ohta_logtime", INT,false,false,0,0);
74 }
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
TTNOhtaStats * _ohtaStats
Definition: ttneutralgenes.h:146
TTNeutralGenesSH * _stats
Definition: ttneutralgenes.h:147
unsigned int _allele_num
Definition: ttneutralgenes.h:134
const trait_t _type
Definition: ttneutralgenes.h:148
double _mut_rate
Definition: ttneutralgenes.h:137
unsigned int _2L
Definition: ttneutralgenes.h:139
double _recomb_rate
Definition: ttneutralgenes.h:141
unsigned int _locus_num
Definition: ttneutralgenes.h:135
void(TProtoNeutralGenes::* _inherit_func_ptr)(sex_t, unsigned char *, const unsigned char **)
Definition: ttneutralgenes.h:143
unsigned int _ploidy
Definition: ttneutralgenes.h:136
unsigned int _init_model
Definition: ttneutralgenes.h:140
int _mut_model
Definition: ttneutralgenes.h:138
void(TTNeutralGenes::* _mutate_func_ptr)(void)
Definition: ttneutralgenes.h:142
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:77
#define NTRL
Definition: types.h:70
@ DBL
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, SimComponent::set_paramset(), and STR.

Referenced by clone().

◆ TProtoNeutralGenes() [2/2]

TProtoNeutralGenes::TProtoNeutralGenes ( const TProtoNeutralGenes T)
82  _ohtaStats(0)
83 {
84  _paramSet = new ParamSet( *(T._paramSet) ) ;
85 }
Parameters container, implemented in each SimComponent.
Definition: param.h:206
ParamSet * _paramSet
The parameters container.
Definition: simcomponent.h:48

References SimComponent::_paramSet.

◆ ~TProtoNeutralGenes()

TProtoNeutralGenes::~TProtoNeutralGenes ( )
virtual
90 {
91  if(_stats != NULL) {delete _stats; _stats = NULL;}
92  for(unsigned int i = 0; i < _writers.size(); i++)
93  delete _writers[i];
94  _writers.clear();
95 
96  if(_ohtaStats) delete _ohtaStats;
97 }
vector< TTNeutralGenesFH * > _writers
Definition: ttneutralgenes.h:145

References _ohtaStats, _stats, and _writers.

Member Function Documentation

◆ clone()

virtual TProtoNeutralGenes* TProtoNeutralGenes::clone ( )
inlinevirtual

Implements TraitPrototype.

178 {return new TProtoNeutralGenes(*this);}
TProtoNeutralGenes()
Definition: ttneutralgenes.cc:51

References TProtoNeutralGenes().

◆ get_allele_num()

◆ get_genome_size()

unsigned int TProtoNeutralGenes::get_genome_size ( )
inline
162 {return _2L;}

References _2L.

◆ get_init_model()

unsigned int TProtoNeutralGenes::get_init_model ( )
inline
164 {return _init_model;}

References _init_model.

Referenced by TTNeutralGenes::init_sequence().

◆ get_locus_num()

unsigned int TProtoNeutralGenes::get_locus_num ( )
inline
159 {return _locus_num;}

References _locus_num.

Referenced by TTNeutralGenesFH::FHread(), TTNOhtaStats::FHwrite(), TTNeutralGenes::get_allele_value(), TTNeutralGenesSH::getDxyPerPatch(), TTNeutralGenes::init(), TTNeutralGenesSH::init(), TTNeutralGenes::init_sequence(), TTNeutralGenes::mutate_2all(), TTNeutralGenes::mutate_KAM(), TTNeutralGenes::mutate_SSM(), TTNeutralGenes::operator=(), TTNeutralGenes::operator==(), TTNeutralGenesFH::print_PLINK_PED(), TTNeutralGenes::retrieve_data(), TTNeutralGenes::set_sequence(), TTNeutralGenesSH::setAlleleTables(), TTNeutralGenesSH::setFreqRecorders(), TTNeutralGenesSH::setFst_li(), TTNeutralGenesSH::setFstat(), TTNeutralGenesSH::setFstat2(), TTNeutralGenesSH::setFstatWeirCockerham(), TTNeutralGenesSH::setFstatWeirCockerham_MS(), TTNeutralGenesSH::setFstMatrix(), TTNeutralGenesSH::setHeteroTable(), TTNeutralGenesSH::setHeterozygosity(), TTNeutralGenesSH::setHo(), TTNeutralGenesSH::setHo2(), TTNeutralGenesSH::setHs(), TTNeutralGenesSH::setHs2(), TTNeutralGenesSH::setHt(), TTNeutralGenesSH::setHt2(), TTNeutralGenesSH::setLociDivCounter(), TTNeutralGenesSH::setNeiGeneticDistance(), LCE_NtrlInit::setParameters(), TTNeutralGenes::show_up(), TTNeutralGenes::store_data(), TTNeutralGenesFH::write_Fst_i(), TTNeutralGenesFH::write_FSTAT(), TTNeutralGenesFH::write_GENEPOP(), TTNeutralGenesFH::write_patch_FSTAT(), TTNeutralGenesFH::write_patch_GENEPOP(), TTNeutralGenesFH::write_patch_TAB(), TTNeutralGenesFH::write_PLINK(), TTNeutralGenesFH::write_TAB(), and TTNeutralGenesFH::write_varcompWC().

◆ get_mut_rate()

double TProtoNeutralGenes::get_mut_rate ( )
inline
161 {return _mut_rate;}

References _mut_rate.

◆ get_num_mutations()

unsigned int TProtoNeutralGenes::get_num_mutations ( )
inline
163 {return RAND::Binomial( _mut_rate, _2L );}
static double Binomial(double p, unsigned int n)
Definition: Uniform.h:489

References _2L, _mut_rate, and RAND::Binomial().

Referenced by TTNeutralGenes::mutate_2all(), TTNeutralGenes::mutate_KAM(), and TTNeutralGenes::mutate_SSM().

◆ get_ploidy()

◆ get_stater()

TTNeutralGenesSH* TProtoNeutralGenes::get_stater ( )
inline
166 {return _stats;}

References _stats.

Referenced by TTNeutralGenesFH::write_Fst_i(), and TTNeutralGenesFH::write_varcompWC().

◆ get_type()

virtual trait_t TProtoNeutralGenes::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

180 {return _type;}

References _type.

Referenced by TTNeutralGenesFH::write_PLINK().

◆ hatch()

TTNeutralGenes * TProtoNeutralGenes::hatch ( )
virtual

Implements TraitPrototype.

369 {
370  TTNeutralGenes* kid = new TTNeutralGenes();
371 
372  kid->set_proto(this);
375 
376  return kid;
377 }
Microsatellites genome.
Definition: ttneutralgenes.h:56
void set_proto(TProtoNeutralGenes *proto)
Definition: ttneutralgenes.h:81
void set_mut_func_ptr(void(TTNeutralGenes::*theFunc)(void))
Definition: ttneutralgenes.h:83
void set_inherit_func_ptr(void(TProtoNeutralGenes::*theFunc)(sex_t, unsigned char *, const unsigned char **))
Definition: ttneutralgenes.h:85

References _inherit_func_ptr, _mutate_func_ptr, TTNeutralGenes::set_inherit_func_ptr(), TTNeutralGenes::set_mut_func_ptr(), and TTNeutralGenes::set_proto().

◆ inherit_free()

void TProtoNeutralGenes::inherit_free ( sex_t  SEX,
unsigned char *  seq,
const unsigned char **  parent 
)
inline
382 {
383  // cout << "TProtoNeutralGenes::inherit_free\n";
384 
385  for(unsigned int i = 0; i < _locus_num; ++i)
386  seq[i] = parent[RAND::RandBool()][i];
387 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:162

References _locus_num, and RAND::RandBool().

Referenced by setParameters().

◆ inherit_low()

void TProtoNeutralGenes::inherit_low ( sex_t  SEX,
unsigned char *  seq,
const unsigned char **  parent 
)
inline
392 {
393  unsigned int prevLoc = 0, cEnd;
394  // bool flipper;
395 
396  vector< pair<unsigned int, unsigned int> > recTable = _map.reduceJunctions(SEX, _mapIndex);
397 
398  //the table containing which homologous chromosome copy we start with, for each chromosome
399  // vector< bool > & firstRecPos = _map.getFirstRecPosition(SEX);
400 
401  //number of x-overs
402  unsigned int nbRec = recTable.size();
403 
404 #ifdef _REC_DEBUG_
405  cout << "TProtoNeutralGenes::inherit_low; nb Rec = "<<nbRec - 1<<endl;
406  cout << " --sex = "<<SEX<<"\n";
407 #endif
408 
409 
410  vector< pair<unsigned int, unsigned int> >::const_iterator xover = recTable.begin();
411 
412  while(xover != recTable.end()) {
413 
414 #ifdef _REC_DEBUG_
415  cout<< " copy seq from "<<prevLoc<<" to "<<xover->first
416  <<" ("<<(xover->first - prevLoc)<<" loc) ("
417  <<(xover->first - prevLoc)<<"B) on side "<<xover->second<<std::endl;
418 #endif
419 
420  memcpy(&seq[prevLoc], &parent[xover->second][prevLoc], (xover->first - prevLoc));
421 
422  prevLoc = xover->first;
423 
424  xover++;
425  }
426 
427 //
428 //#ifdef _REC_DEBUG_
429 // cout << "TProtoNeutralGenes::inherit_low; nb Rec = "<< nbRec-1 << endl;
430 // cout << " --sex = "<<SEX<<"\n ";
431 //#endif
432 //
433 // for(unsigned int c = 0, cStart = 0, rec = 0; c < _numChromosome; ++c) {
434 //
435 // flipper = firstRecPos[c];
436 //
437 // cEnd = cStart + _numLociPerChrmsm[c]; //last locus of focal chromosome
438 //
439 // prevLoc = cStart; //cStart = first locus of focal chromosome
440 //
441 //#ifdef _REC_DEBUG_
442 // //do recombination chromosome-wise
443 // cout<<" --chrm "<<c<<" side="<<firstRecPos[c]<<endl;
444 //#endif
445 //
446 // // check if we have to process x-over on focal chromosome
447 // for(; rec < nbRec && recTable[rec] < cEnd; ++rec) {
448 //
449 //#ifdef _REC_DEBUG_
450 // cout << " ["<<rec<<"] copy from "<<prevLoc<<" to "<<recTable[rec]
451 // << " ("<<(recTable[rec] - prevLoc)<<" loc) on side "<<flipper<<endl;
452 //#endif
453 // //skip recombination events that would lead to copying 0 byte
460 //
461 // memcpy(&seq[prevLoc], &parent[flipper][prevLoc], (recTable[rec] - prevLoc));
462 //
463 // prevLoc = recTable[rec];
464 //
465 // flipper = !flipper;
466 // }
467 //
468 //#ifdef _REC_DEBUG_
469 // cout <<" --copy end of chrmsm from "<<prevLoc<<" to "<<cEnd
470 // <<" ("<<(cEnd - prevLoc)<<" loc) on side "<<flipper<<endl;
471 //#endif
472 //
473 // //copy what's left between the last x-over point and the end of the chrmsme
474 // memcpy(&seq[prevLoc], &parent[flipper][prevLoc], (cEnd - prevLoc));
475 //
476 // cStart += _numLociPerChrmsm[c];
477 //
478 // }
479 
480 #ifdef _REC_DEBUG_
481  // cout << "parent chromosomes:\n --0:";
482  // unsigned int loc = 0;
483  // for (unsigned int c = 0; c < _numChromosome; ++c) {
484  // cout<<" ";
485  // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
486  // cout << (int)parent[0][loc++];
487  // }
488  // cout << "\n --1:";
489  // loc = 0;
490  // for (unsigned int c = 0; c < _numChromosome; ++c) {
491  // cout<<" ";
492  // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
493  // cout << (int)parent[1][loc++];
494  // }
495  //
496  // cout << "\ngamete:\n --0:";
497  // loc = 0;
498  // for (unsigned int c = 0; c < _numChromosome; ++c) {
499  // cout<<" ";
500  // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
501  // cout << (int)seq[loc++];
502  // }
503  // cout << "\n\n";
504 #endif
505 
506 }
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

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

Referenced by setParameters().

◆ init()

virtual void TProtoNeutralGenes::init ( )
inlinevirtual
172 {}

◆ loadFileServices()

void TProtoNeutralGenes::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

162 {
163  TTNeutralGenesFH* writer;
164 
165  if(_writers.size() != 0) {
166  for(unsigned int i = 0; i < _writers.size(); i++)
167  delete _writers[i];
168  _writers.clear();
169  }
170 
171  // --- THE READER ---
172  // note that this reader only reads in FSTAT format
173  //always add the reader:
174  //NOTE: the default extension is ".txt", will not accept ".dat" FSTAT files in input
175  writer = new TTNeutralGenesFH(this);
176 
177  //set to read mode:
178  writer->set_isInputHandler(true);
179 
180  //attach to file manager:
181  loader->attach_reader(writer);
182 
183  //add to list of FileHandlers, will be deleted upon destruction
184  _writers.push_back( writer );
185 
186  // Add a reader for ".dat" FSTAT files:
187  writer = new TTNeutralGenesFH(this);
188  writer->set_isInputHandler(true);
189  writer->set_extension(".dat");
190  loader->attach_reader(writer);
191 
192  _writers.push_back( writer );
193 
194  // --- WRITERS ---
195  Param* param_logtime = get_parameter("ntrl_output_logtime");
196  TMatrix logtime_matrix;
197  bool logtime_isMatrix = 0;
198 
199  if(param_logtime->isMatrix()) {
200  param_logtime->getMatrix(&logtime_matrix);
201  logtime_isMatrix = 1;
202  }
203 
204  if( get_parameter("ntrl_save_genotype")->isSet() ) {
205 
206  writer = new TTNeutralGenesFH(this);
207 
208  if(logtime_isMatrix)
209  writer->set_multi(true, true, 1, &logtime_matrix, get_parameter("ntrl_output_dir")->getArg(), this);
210 
211  else
212  writer->set(true, param_logtime->isSet(), 1, (param_logtime->isSet() ? (int)param_logtime->getValue() : 0), 0, get_parameter("ntrl_output_dir")->getArg(), this);
213  // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
214 
215  // check the output file type
216  string file_type = get_parameter("ntrl_save_genotype")->getArg();
217 
218  // lowercase the arg string:
219  std::for_each(file_type.begin(), file_type.end(), [](char& c){c = ::tolower(c);});
220 
221  if(file_type.length() == 0 || //default mode is tabular
222  file_type == "tab")
223  {
224  writer->setOutputOption("allele");
226  }
227  else if(file_type == "snp_tab")
228  {
229  writer->setOutputOption("snp");
231  }
232  else if(file_type == "fstat")
233  {
234 
236  writer->set_extension(".dat");
237 
238  }
239  else if(file_type == "genepop")
240  {
242  }
243  else if(file_type == "plink")
244  {
246  }
247 
248  else
249  fatal("parameter \"ntrl_save_genotype\" options are \"TAB\", \"SNP_TAB\", \"FSTAT\", \"GENEPOP\" or \"PLINK\".\n");
250 
251  loader->attach(writer);
252 
253  _writers.push_back( writer );
254  }
255 
256  // new writer
257  if( get_parameter("ntrl_save_fsti")->isSet() ) {
258 
259  writer = new TTNeutralGenesFH(this);
260 
261  if(logtime_isMatrix)
262  writer->set_multi(true, true, 1, &logtime_matrix, get_parameter("ntrl_output_dir")->getArg(), this);
263  // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
264  else writer->set(true, param_logtime->isSet(), 1, (param_logtime->isSet() ? (int)param_logtime->getValue() : 0), 0, get_parameter("ntrl_output_dir")->getArg(), this);
265 
267 
268  writer->set_extension(".fsti");
269 
270  loader->attach(writer);
271 
272  _writers.push_back( writer );
273  }
274 
275  // new writer
276  if( get_parameter("ntrl_save_freq")->isSet() ) {
277 
278  writer = new TTNeutralGenesFH(this);
279 
280  writer->set_extension(".freq");
281 
282  if (logtime_isMatrix)
283  writer->set_multi(true, true, 1, &logtime_matrix, get_parameter("ntrl_output_dir")->getArg(), this);
284  // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
285  else writer->set(true, param_logtime->isSet(), 1, (param_logtime->isSet() ? (int)param_logtime->getValue() : 0), 0, get_parameter("ntrl_output_dir")->getArg(), this);
286 
287  //check validity of output option:
288 
289  if(get_parameter("ntrl_save_freq")->getArg() == "allfreq") {
290 
291  warning("option \"allfreq\" to \"ntrl_save_freq\" is deprecated, using \"locus\" instead\n");
292 
293  writer->setOutputOption("locus");
294 
295  } else if(get_parameter("ntrl_save_freq")->getArg() == "vcomp") {
296 
297  warning("option \"vcomp\" to \"ntrl_save_freq\" is deprecated, using \"allele\" instead\n");
298 
299  writer->setOutputOption("allele");
300 
301  } else if( get_parameter("ntrl_save_freq")->getArg() != "1" &&
302  get_parameter("ntrl_save_freq")->getArg() != "locus" &&
303  get_parameter("ntrl_save_freq")->getArg() != "allele") {
304 
305  fatal("parameter \"ntrl_save_freq\" options are \"locus\" or \"allele\".\n");
306 
307  } else
308  writer->setOutputOption(get_parameter("ntrl_save_freq")->getArg());
309 
311 
312  loader->attach(writer);
313 
314  _writers.push_back( writer );
315  }
316 
317 
318  // Ohta's (1982) D statistics
319  if(get_parameter("ntrl_ohta_output")->isSet()) {
320 
321  // Output Ohta stats :
322  // Only if pop alive
323  // Only for diallelic mutation models
324  // Only for multi-population scenarios
325  if ((_allele_num > 2) || (SIMenv::MainSim->get_pop()->getPatchNbr() < 2)) {
326  fatal("output option \"ntrl_ohta_output\" is only valid for diallelic neutral markers and multiple patches!\n");
327  }
328 
329  if(_ohtaStats == NULL) _ohtaStats = new TTNOhtaStats(this);
330 
331  Param* param = get_parameter("ntrl_ohta_logtime");
332 
333  if(param->isMatrix()) {
334 
335  TMatrix temp;
336  param->getMatrix(&temp);
337  _ohtaStats->set_multi(true, true, 1, &temp, get_parameter("ntrl_output_dir")->getArg(), this);
338 
339  } else // rpl_per, gen_per, rpl_occ, gen_occ, rank (0), path, self-ref
340  _ohtaStats->set(true, true, 1, (param->isSet() ? (int)param->getValue() : 0),
341  0, get_parameter("ntrl_output_dir")->getArg(),this);
342 
343  loader->attach(_ohtaStats);
344  }
345  else if(_ohtaStats != NULL) {
346  delete _ohtaStats;
347  _ohtaStats = NULL;
348  }
349 
350 }
void set_extension(const char *ext)
Definition: filehandler.h:145
void set_isInputHandler(bool val)
Definition: filehandler.h:151
virtual void attach_reader(FileHandler *FH)
Attaches the FileHandler to the current list (_readers) of the FileServices.
Definition: fileservices.cc:74
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:61
This structure stores one parameter, its definition and its string argument.
Definition: param.h:54
double getValue()
Returns the argument value according to its type.
Definition: param.cc:368
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:172
string getArg()
Definition: param.h:138
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
static SimRunner * MainSim
Definition: simenv.h:42
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
TTNOhtaStats.
Definition: ttneutralgenes.h:247
A file handler to save the neutral markers genotypes in the FSTAT format (extended).
Definition: ttneutralgenes.h:208
void write_GENEPOP()
Definition: ttneutralgenes.cc:1158
void write_Fst_i()
Definition: ttneutralgenes.cc:1426
void setOutputOption(string opt)
Definition: ttneutralgenes.cc:796
void write_FSTAT()
Definition: ttneutralgenes.cc:1077
void write_TAB()
Definition: ttneutralgenes.cc:826
void write_varcompWC()
Definition: ttneutralgenes.cc:1492
void write_PLINK()
Definition: ttneutralgenes.cc:922
void set_write_fct(void(TTNeutralGenesFH::*fct_ptr)())
Definition: ttneutralgenes.h:238
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
void fatal(const char *str,...)
Definition: output.cc:96
void warning(const char *str,...)
Definition: output.cc:58

References _allele_num, _ohtaStats, _writers, FileServices::attach(), FileServices::attach_reader(), fatal(), SimComponent::get_parameter(), Param::getArg(), Param::getMatrix(), Param::getValue(), Param::isMatrix(), Param::isSet(), SIMenv::MainSim, TraitFileHandler< TP >::set(), FileHandler::set_extension(), FileHandler::set_isInputHandler(), TraitFileHandler< TP >::set_multi(), TTNeutralGenesFH::set_write_fct(), TTNeutralGenesFH::setOutputOption(), warning(), TTNeutralGenesFH::write_Fst_i(), TTNeutralGenesFH::write_FSTAT(), TTNeutralGenesFH::write_GENEPOP(), TTNeutralGenesFH::write_PLINK(), TTNeutralGenesFH::write_TAB(), and TTNeutralGenesFH::write_varcompWC().

◆ loadStatServices()

void TProtoNeutralGenes::loadStatServices ( StatServices loader)
virtual

Implements SimComponent.

355 {
356  //allocate the stat handler
357  if(_stats) delete _stats;
358 
359  // this makes sure that the trait index is reset correctly between simulations
360  _stats = new TTNeutralGenesSH(this);
361 
362  loader->attach(_stats);
363 
364 }
virtual void attach(Handler *H)
attach the StatHandler to the current list (_statHandlers) of the StatServices
Definition: statservices.cc:177
The stat handler for neutral markers.
Definition: ttneutralgenes.h:267

References _stats, and StatServices::attach().

◆ reset()

virtual void TProtoNeutralGenes::reset ( )
inlinevirtual

Reimplemented from TTProtoWithMap.

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

References TTProtoWithMap::reset().

◆ resetParameterFromSource()

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

Implements SimComponent.

522 {
523  TProtoNeutralGenes *srcProto = dynamic_cast< TProtoNeutralGenes* >(cmpt);
524 
525  if( param != "ntrl_genetic_map" ) return false;
526 
527  Param *srcMap = srcProto->get_parameter(param);
528 
529  if(!srcMap->isSet()) return error("parameter \"ntrl_genetic_map\" not set in source.\n");
530 
531 
532  //@TODO need to implement a way to update the genetic map of a trait in GeneticMap
533  return false;
534 }
Prototype class for the TTNeutralGenes trait class.
Definition: ttneutralgenes.h:131
int error(const char *str,...)
Definition: output.cc:77

References error(), SimComponent::get_parameter(), and Param::isSet().

◆ retrieve_data()

bool TProtoNeutralGenes::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

511 {
512  unsigned int dummy;
513  reader->read(&dummy, sizeof(int));
514  if(dummy != _locus_num ){
515  warning("Neutral mutation trait::locus number in binary source file differs from parameter value!\n\
516  >>>> adjusting locus number to match source population: %i set to %i\n", _locus_num, dummy);
517  _locus_num = dummy;
518  }
519  return true;
520 }
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:162

References _locus_num, BinaryStorageBuffer::read(), and warning().

◆ setParameters()

bool TProtoNeutralGenes::setParameters ( )
virtual

Implements SimComponent.

102 {
103  _locus_num = (unsigned int)get_parameter_value("ntrl_loci");
104  _allele_num = (unsigned int)get_parameter_value("ntrl_all");
105  _ploidy = 2;
106  _mut_rate = get_parameter_value("ntrl_mutation_rate");
107  _mut_model = (unsigned int)get_parameter_value("ntrl_mutation_model");
108  _2L = _ploidy * _locus_num; // genome size
109 
110  if(get_parameter("ntrl_init_model")->isSet())
111  _init_model = (unsigned short)get_parameter_value("ntrl_init_model");
112  else
113  _init_model = 1; //maximum variance
114 
115  switch(_mut_model) {
116  case 0:
117  {
119  break;
120  }
121  case 1:
122  {
124  break;
125  }
126  case 2:
127  {
129  break;
130  }
131  default:
132  {
133  error("wrong parameter value for parameter \"ntrl_mutation_model\", max is 2\n");
134  break; //should return false
135  }
136  }
137  //special case:
139 
140  // we want to bypass the genetic map if loci are not linked
141  if( TTProtoWithMap::isRecombinationFree("ntrl")) { //test all possible options to set recomb rate = 0.5
142 
144 
146 
147  } else {
148 
149  // register the locus positions on the genetic map
150  if( ! TTProtoWithMap::setGeneticMapParameters ("ntrl") ) return false;
151 
153 
154  }
155 
156  return true;
157 }
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
void inherit_low(sex_t SEX, unsigned char *seq, const unsigned char **parent)
Definition: ttneutralgenes.cc:391
void inherit_free(sex_t SEX, unsigned char *seq, const unsigned char **parent)
Definition: ttneutralgenes.cc:381
void mutate_SSM()
Definition: ttneutralgenes.cc:735
void mutate_2all()
Definition: ttneutralgenes.cc:777
void mutate_NULL()
Definition: ttneutralgenes.h:97
void mutate_KAM()
Definition: ttneutralgenes.cc:758
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

References _2L, _allele_num, _inherit_func_ptr, _init_model, _locus_num, _mut_model, _mut_rate, _mutate_func_ptr, _ploidy, TTProtoWithMap::_recombRate, error(), SimComponent::get_parameter(), SimComponent::get_parameter_value(), inherit_free(), inherit_low(), TTProtoWithMap::isRecombinationFree(), Param::isSet(), TTNeutralGenes::mutate_2all(), TTNeutralGenes::mutate_KAM(), TTNeutralGenes::mutate_NULL(), TTNeutralGenes::mutate_SSM(), and TTProtoWithMap::setGeneticMapParameters().

◆ store_data()

virtual void TProtoNeutralGenes::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

191 {saver->store(&_locus_num,sizeof(int));}
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16

References _locus_num, and BinaryStorageBuffer::store().

Member Data Documentation

◆ _2L

unsigned int TProtoNeutralGenes::_2L
private

◆ _allele_num

unsigned int TProtoNeutralGenes::_allele_num
private

◆ _inherit_func_ptr

void(TProtoNeutralGenes::* TProtoNeutralGenes::_inherit_func_ptr) (sex_t, unsigned char *, const unsigned char **)
private

Referenced by hatch(), and setParameters().

◆ _init_model

unsigned int TProtoNeutralGenes::_init_model
private

Referenced by get_init_model(), and setParameters().

◆ _locus_num

unsigned int TProtoNeutralGenes::_locus_num
private

◆ _mut_model

int TProtoNeutralGenes::_mut_model
private

Referenced by setParameters().

◆ _mut_rate

double TProtoNeutralGenes::_mut_rate
private

◆ _mutate_func_ptr

void(TTNeutralGenes::* TProtoNeutralGenes::_mutate_func_ptr) (void)
private

Referenced by hatch(), and setParameters().

◆ _ohtaStats

TTNOhtaStats* TProtoNeutralGenes::_ohtaStats
private

◆ _ploidy

unsigned int TProtoNeutralGenes::_ploidy
private

Referenced by get_ploidy(), and setParameters().

◆ _recomb_rate

double TProtoNeutralGenes::_recomb_rate
private

◆ _stats

TTNeutralGenesSH* TProtoNeutralGenes::_stats
private

◆ _type

const trait_t TProtoNeutralGenes::_type
private

Referenced by get_type().

◆ _writers

vector< TTNeutralGenesFH* > TProtoNeutralGenes::_writers
private

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

Generated for Nemo v2.4.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR