Nemo  2.4.2
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)
 
TraitPrototype implementations
virtual void init ()
 
virtual void reset ()
 
virtual TTNeutralGeneshatch ()
 
virtual TProtoNeutralGenesclone ()
 
virtual trait_t get_type () const
 
virtual int get_phenotype_dimension ()
 
virtual int get_allele_number ()
 
virtual int get_locus_number ()
 Returns the number of locus. More...
 
SimComponent implementation
virtual bool setParameters ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
StorableComponent implementation
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 ()
 
double getRecombRate () const
 
bool setGeneticMapParameters (string prefix, unsigned int numLoci=0)
 
void addGeneticMapParameters (string prefix)
 
bool setRecombinationMapRandom ()
 
bool setRecombinationMapNonRandom (vector< vector< double > > &lociPositions)
 
bool setRecombinationMapFixed ()
 
bool setNumLociPerChromosome (string param_name)
 
void reset_recombination_pointers ()
 
void registerGeneticMap ()
 
void unregisterFromGeneticMap ()
 
bool areGeneticMapParamSet (string prefix)
 
bool isRecombinationFree (string prefix)
 
void recordRandomMap ()
 
virtual bool is_mappable ()
 Checks if the trait is mappable, i.e., if the loci can be placed on a genetic map. More...
 
virtual bool is_mapped ()
 Checks if the trait's loci are placed on a genetic map. More...
 
virtual vector< unsigned int > get_locus_map_positions ()
 Returns the map positions of the loci in vector. More...
 
- Public Member Functions inherited from TraitPrototype
virtual void set_index (int idx)
 Sets the traits index. More...
 
virtual int get_index ()
 Index getter. More...
 
- Public Member Functions inherited from StorableComponent
virtual ~StorableComponent ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 Sets a new ParamSet and name it. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 

Private Attributes

unsigned int _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_byte::* _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 GeneticMapgetGeneticMapRef ()
 
static void recombine (unsigned long indID)
 
- Static Public Attributes inherited from TTProtoWithMap
static GeneticMap _map
 
- Protected Attributes inherited from TTProtoWithMap
unsigned int _mapIndex
 
double _totRecombEventsMean
 
double _recombRate
 
double _mapResolution
 
unsigned int _numChromosome
 
unsigned int _numLoci
 
double * _recombRatePerChrmsm
 
unsigned int * _numLociPerChrmsm
 
unsigned int * _chrsmLength
 
unsigned int * _lociMapPositions
 
- Protected Attributes inherited from TraitPrototype
int _index
 The trait index in the Individual traits table. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Detailed Description

Prototype class for the TTNeutralGenes trait class.

Constructor & Destructor Documentation

◆ TProtoNeutralGenes() [1/2]

TProtoNeutralGenes::TProtoNeutralGenes ( )
50  :_allele_num(0), _locus_num(0), _ploidy(2), _mut_rate(0),
52  _ohtaStats(0),_stats(0), _type(NTRL)
53 {
54  set_paramset("neutralgenes", false, this);
55 
56  add_parameter("ntrl_loci", INT, true, false, 0, 0);
57  add_parameter("ntrl_init_model", INT, false, true, 0, 2);
58  add_parameter("ntrl_all", INT, true, true, 2, 256);
59  add_parameter("ntrl_mutation_rate", DBL, true, true, 0, 1);
60  add_parameter("ntrl_mutation_model", INT, true, true, 0, 2);
61 
62  //genetic map parameters:
64 
65  //output
66  add_parameter("ntrl_save_genotype", STR, false, false, 0, 0);
67  add_parameter("ntrl_save_fsti", BOOL, false, false, 0, 0);
68  add_parameter("ntrl_save_freq", STR, false, false, 0, 0);
69  add_parameter("ntrl_output_dir", STR, false, false, 0, 0);
70  add_parameter("ntrl_output_logtime", INT, false, false, 0, 0);
71  add_parameter("ntrl_ohta_output", BOOL,false,false,0,0);
72  add_parameter("ntrl_ohta_logtime", INT,false,false,0,0);
73 }
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
TTNOhtaStats * _ohtaStats
Definition: ttneutralgenes.h:185
TTNeutralGenesSH * _stats
Definition: ttneutralgenes.h:186
unsigned int _allele_num
Definition: ttneutralgenes.h:173
const trait_t _type
Definition: ttneutralgenes.h:187
double _mut_rate
Definition: ttneutralgenes.h:176
unsigned int _2L
Definition: ttneutralgenes.h:178
double _recomb_rate
Definition: ttneutralgenes.h:180
unsigned int _locus_num
Definition: ttneutralgenes.h:174
void(TProtoNeutralGenes::* _inherit_func_ptr)(sex_t, unsigned char *, const unsigned char **)
Definition: ttneutralgenes.h:182
unsigned int _ploidy
Definition: ttneutralgenes.h:175
unsigned int _init_model
Definition: ttneutralgenes.h:179
int _mut_model
Definition: ttneutralgenes.h:177
void(TTNeutralGenes_byte::* _mutate_func_ptr)(void)
Definition: ttneutralgenes.h:181
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:76
#define NTRL
Definition: types.h:68
@ DBL
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, SimComponent::set_paramset(), and STR.

Referenced by clone().

+ Here is the caller graph for this function:

◆ TProtoNeutralGenes() [2/2]

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

References SimComponent::_paramSet.

◆ ~TProtoNeutralGenes()

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

References _ohtaStats, _stats, and _writers.

Member Function Documentation

◆ clone()

virtual TProtoNeutralGenes* TProtoNeutralGenes::clone ( )
inlinevirtual

Implements TraitPrototype.

218 {return new TProtoNeutralGenes(*this);}
TProtoNeutralGenes()
Definition: ttneutralgenes.cc:50

References TProtoNeutralGenes().

◆ get_allele_num()

◆ get_allele_number()

virtual int TProtoNeutralGenes::get_allele_number ( )
inlinevirtual

Implements TraitPrototype.

224 {return _allele_num;}

References _allele_num.

◆ get_genome_size()

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

References _2L.

◆ get_init_model()

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

References _init_model.

Referenced by TTNeutralGenes_byte::init_sequence().

+ Here is the caller graph for this function:

◆ get_locus_num()

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

References _locus_num.

Referenced by TTNeutralGenesFH::FHread(), TTNOhtaStats::FHwrite(), TTNeutralGenes_byte::get_allele(), TTNeutralGenes_byte::get_allele_value(), TTNeutralGenesSH::getDxyPerPatch(), TTNeutralGenes_byte::init(), TTNeutralGenesSH::init(), TTNeutralGenes_byte::init_sequence(), TTNeutralGenes_byte::mutate_2all(), TTNeutralGenes_byte::mutate_KAM(), TTNeutralGenes_byte::mutate_SSM(), TTNeutralGenes_byte::operator=(), TTNeutralGenes::operator==(), TTNeutralGenesFH::print_PLINK_PED(), TTNeutralGenes_byte::retrieve_data(), TTNeutralGenes_byte::set_sequence(), TTNeutralGenesSH::setAlleleTables(), TTNeutralGenesSH::setFreqRecorders(), TTNeutralGenesSH::setFst_li(), TTNeutralGenesSH::setFstat(), TTNeutralGenesSH::setFstat_bitstring(), TTNeutralGenesSH::setFstatWeirCockerham(), TTNeutralGenesSH::setFstatWeirCockerham_bitstring(), 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_byte::show_up(), TTNeutralGenes_byte::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_locus_number()

virtual int TProtoNeutralGenes::get_locus_number ( )
inlinevirtual

Returns the number of locus.

Implements TraitPrototype.

226 {return _locus_num;}

References _locus_num.

◆ get_mut_rate()

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

References _mut_rate.

◆ get_num_mutations()

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

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

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

+ Here is the caller graph for this function:

◆ get_phenotype_dimension()

virtual int TProtoNeutralGenes::get_phenotype_dimension ( )
inlinevirtual

Implements TraitPrototype.

222 {return 0;}

◆ get_ploidy()

◆ get_stater()

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

References _stats.

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

+ Here is the caller graph for this function:

◆ get_type()

virtual trait_t TProtoNeutralGenes::get_type ( ) const
inlinevirtual

Implements TraitPrototype.

220 {return _type;}

References _type.

Referenced by TTNeutralGenesFH::write_PLINK().

+ Here is the caller graph for this function:

◆ hatch()

TTNeutralGenes * TProtoNeutralGenes::hatch ( )
virtual

Implements TraitPrototype.

376 {
377  TTNeutralGenes* kid;
378 
379  if (_allele_num == 2) {
380  kid = new TTNeutralGenes_bitstring();
381  } else {
385  kid = bkid;
386  }
387 
388  kid->set_proto(this);
389 
390  return kid;
391 }
TTNeutralGenes_bitstring : diallelic neutral loci encoded as bitstrings.
Definition: ttneutralgenes_bitstring.h:38
Byte-encoded neutral gene trait (unsigned char per allele).
Definition: ttneutralgenes.h:109
void set_inherit_func_ptr(void(TProtoNeutralGenes::*theFunc)(sex_t, unsigned char *, const unsigned char **))
Definition: ttneutralgenes.h:131
void set_mut_func_ptr(void(TTNeutralGenes_byte::*theFunc)(void))
Definition: ttneutralgenes.h:129
Abstract base class for neutral gene traits.
Definition: ttneutralgenes.h:55
void set_proto(TProtoNeutralGenes *proto)
Definition: ttneutralgenes.h:72

References _allele_num, _inherit_func_ptr, _mutate_func_ptr, TTNeutralGenes_byte::set_inherit_func_ptr(), TTNeutralGenes_byte::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
396 {
397  for(unsigned int i = 0; i < _locus_num; ++i)
398  seq[i] = parent[RAND::RandBool()][i];
399 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:170

References _locus_num, and RAND::RandBool().

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ inherit_low()

void TProtoNeutralGenes::inherit_low ( sex_t  SEX,
unsigned char *  seq,
const unsigned char **  parent 
)
inline
404 {
405  unsigned int prevLoc = 0, cEnd;
406 
407  vector< pair<unsigned int, unsigned int> > recTable = _map.reduceJunctions(SEX, _mapIndex);
408 
409  //number of x-overs
410  unsigned int nbRec = recTable.size();
411 
412 #ifdef _REC_DEBUG_
413  cout << "TProtoNeutralGenes::inherit_low; nb Rec = "<<nbRec - 1<<endl;
414  cout << " --sex = "<<SEX<<"\n";
415 #endif
416 
417 
418  vector< pair<unsigned int, unsigned int> >::const_iterator xover = recTable.begin();
419 
420  while(xover != recTable.end()) {
421 
422 #ifdef _REC_DEBUG_
423  cout<< " copy seq from "<<prevLoc<<" to "<<xover->first
424  <<" ("<<(xover->first - prevLoc)<<" loc) ("
425  <<(xover->first - prevLoc)<<"B) on side "<<xover->second<<std::endl;
426 #endif
427 
428  memcpy(&seq[prevLoc], &parent[xover->second][prevLoc], (xover->first - prevLoc));
429 
430  prevLoc = xover->first;
431 
432  xover++;
433  }
434 
435 #ifdef _REC_DEBUG_
436  // cout << "parent chromosomes:\n --0:";
437  // unsigned int loc = 0;
438  // for (unsigned int c = 0; c < _numChromosome; ++c) {
439  // cout<<" ";
440  // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
441  // cout << (int)parent[0][loc++];
442  // }
443  // cout << "\n --1:";
444  // loc = 0;
445  // for (unsigned int c = 0; c < _numChromosome; ++c) {
446  // cout<<" ";
447  // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
448  // cout << (int)parent[1][loc++];
449  // }
450  //
451  // cout << "\ngamete:\n --0:";
452  // loc = 0;
453  // for (unsigned int c = 0; c < _numChromosome; ++c) {
454  // cout<<" ";
455  // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
456  // cout << (int)seq[loc++];
457  // }
458  // cout << "\n\n";
459 #endif
460 
461 }
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

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

Referenced by setParameters().

+ Here is the caller graph for this function:

◆ init()

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

◆ loadFileServices()

void TProtoNeutralGenes::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

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

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.

362 {
363  //allocate the stat handler
364  if(_stats) delete _stats;
365 
366  // this makes sure that the trait index is reset correctly between simulations
367  _stats = new TTNeutralGenesSH(this);
368 
369  loader->attach(_stats);
370 
371 }
virtual void attach(Handler *H)
attach the StatHandler to the current list (_statHandlers) of the StatServices
Definition: statservices.cc:175
The stat handler for neutral markers.
Definition: ttneutralgenes.h:319

References _stats, and StatServices::attach().

◆ reset()

virtual void TProtoNeutralGenes::reset ( )
inlinevirtual

Reimplemented from TTProtoWithMap.

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

References TTProtoWithMap::reset().

◆ resetParameterFromSource()

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

Implements SimComponent.

477 {
478  TProtoNeutralGenes *srcProto = dynamic_cast< TProtoNeutralGenes* >(cmpt);
479 
480  if( param != "ntrl_genetic_map" ) return false;
481 
482  Param *srcMap = srcProto->get_parameter(param);
483 
484  if(!srcMap->isSet()) return error("parameter \"ntrl_genetic_map\" not set in source.\n");
485 
486 
487  //@TODO need to implement a way to update the genetic map of a trait in GeneticMap
488  return false;
489 }
Prototype class for the TTNeutralGenes trait class.
Definition: ttneutralgenes.h:170
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.

466 {
467  unsigned int dummy;
468  reader->read(&dummy, sizeof(int));
469  if(dummy != _locus_num ){
470  warning("Neutral mutation trait::locus number in binary source file differs from parameter value!\n\
471  >>>> adjusting locus number to match source population: %i set to %i\n", _locus_num, dummy);
472  _locus_num = dummy;
473  }
474  return true;
475 }
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:219

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

◆ setParameters()

bool TProtoNeutralGenes::setParameters ( )
virtual

Implements SimComponent.

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

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_byte::mutate_2all(), TTNeutralGenes_byte::mutate_KAM(), TTNeutralGenes_byte::mutate_NULL(), TTNeutralGenes_byte::mutate_SSM(), and TTProtoWithMap::setGeneticMapParameters().

◆ store_data()

virtual void TProtoNeutralGenes::store_data ( BinaryStorageBuffer saver)
inlinevirtual

Implements StorableComponent.

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

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_byte::* 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.2 by  doxygen 1.9.1

Catalogued on GSR