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)
 
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 ( )
52  :_allele_num(0), _locus_num(0), _ploidy(2), _mut_rate(0),
54  _ohtaStats(0),_stats(0), _type(NTRL)
55 {
56  set_paramset("neutralgenes", false, this);
57 
58  add_parameter("ntrl_loci", INT, true, false, 0, 0);
59  add_parameter("ntrl_init_model", INT, false, true, 0, 1);
60  add_parameter("ntrl_all", INT, true, true, 2, 256);
61  add_parameter("ntrl_mutation_rate", DBL, true, true, 0, 1);
62  add_parameter("ntrl_mutation_model", INT, true, true, 0, 2);
63 
64  //genetic map parameters:
66 
67  //output
68  add_parameter("ntrl_save_genotype", STR, false, false, 0, 0);
69  add_parameter("ntrl_save_fsti", BOOL, false, false, 0, 0);
70  add_parameter("ntrl_save_freq", STR, false, false, 0, 0);
71  add_parameter("ntrl_output_dir", STR, false, false, 0, 0);
72  add_parameter("ntrl_output_logtime", INT, false, false, 0, 0);
73  add_parameter("ntrl_ohta_output", BOOL,false,false,0,0);
74  add_parameter("ntrl_ohta_logtime", INT,false,false,0,0);
75 }
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:187
TTNeutralGenesSH * _stats
Definition: ttneutralgenes.h:188
unsigned int _allele_num
Definition: ttneutralgenes.h:175
const trait_t _type
Definition: ttneutralgenes.h:189
double _mut_rate
Definition: ttneutralgenes.h:178
unsigned int _2L
Definition: ttneutralgenes.h:180
double _recomb_rate
Definition: ttneutralgenes.h:182
unsigned int _locus_num
Definition: ttneutralgenes.h:176
void(TProtoNeutralGenes::* _inherit_func_ptr)(sex_t, unsigned char *, const unsigned char **)
Definition: ttneutralgenes.h:184
unsigned int _ploidy
Definition: ttneutralgenes.h:177
unsigned int _init_model
Definition: ttneutralgenes.h:181
int _mut_model
Definition: ttneutralgenes.h:179
void(TTNeutralGenes_byte::* _mutate_func_ptr)(void)
Definition: ttneutralgenes.h:183
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:78
#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)
83  _ohtaStats(0)
84 {
85  _paramSet = new ParamSet( *(T._paramSet) ) ;
86 }
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
91 {
92  if(_stats != NULL) {delete _stats; _stats = NULL;}
93  for(unsigned int i = 0; i < _writers.size(); i++)
94  delete _writers[i];
95  _writers.clear();
96 
97  if(_ohtaStats) delete _ohtaStats;
98 }
vector< TTNeutralGenesFH * > _writers
Definition: ttneutralgenes.h:186

References _ohtaStats, _stats, and _writers.

Member Function Documentation

◆ clone()

virtual TProtoNeutralGenes* TProtoNeutralGenes::clone ( )
inlinevirtual

Implements TraitPrototype.

220 {return new TProtoNeutralGenes(*this);}
TProtoNeutralGenes()
Definition: ttneutralgenes.cc:52

References TProtoNeutralGenes().

◆ get_allele_num()

◆ get_allele_number()

virtual int TProtoNeutralGenes::get_allele_number ( )
inlinevirtual

Implements TraitPrototype.

226 {return _allele_num;}

References _allele_num.

◆ get_genome_size()

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

References _2L.

◆ get_init_model()

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

References _init_model.

Referenced by TTNeutralGenes_byte::init_sequence().

◆ get_locus_num()

unsigned int TProtoNeutralGenes::get_locus_num ( )
inline
200 {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::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_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.

228 {return _locus_num;}

References _locus_num.

◆ get_mut_rate()

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

References _mut_rate.

◆ get_num_mutations()

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

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

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

◆ get_phenotype_dimension()

virtual int TProtoNeutralGenes::get_phenotype_dimension ( )
inlinevirtual

Implements TraitPrototype.

224 {return 0;}

◆ get_ploidy()

◆ get_stater()

TTNeutralGenesSH* TProtoNeutralGenes::get_stater ( )
inline
207 {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.

222 {return _type;}

References _type.

Referenced by TTNeutralGenesFH::write_PLINK().

◆ hatch()

TTNeutralGenes * TProtoNeutralGenes::hatch ( )
virtual

Implements TraitPrototype.

378 {
379  TTNeutralGenes* kid;
380 
381  if (_allele_num == 2) {
382  kid = new TTNeutralGenes_bitstring();
383  } else {
387  kid = bkid;
388  }
389 
390  kid->set_proto(this);
391 
392  return kid;
393 }
TTNeutralGenes_bitstring : diallelic neutral loci encoded as bitstrings.
Definition: ttneutralgenes_bitstring.h:40
Byte-encoded neutral gene trait (unsigned char per allele).
Definition: ttneutralgenes.h:111
void set_inherit_func_ptr(void(TProtoNeutralGenes::*theFunc)(sex_t, unsigned char *, const unsigned char **))
Definition: ttneutralgenes.h:133
void set_mut_func_ptr(void(TTNeutralGenes_byte::*theFunc)(void))
Definition: ttneutralgenes.h:131
Abstract base class for neutral gene traits.
Definition: ttneutralgenes.h:57
void set_proto(TProtoNeutralGenes *proto)
Definition: ttneutralgenes.h:74

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
398 {
399  // cout << "TProtoNeutralGenes::inherit_free\n";
400 
401  for(unsigned int i = 0; i < _locus_num; ++i)
402  seq[i] = parent[RAND::RandBool()][i];
403 }
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:165

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

◆ loadFileServices()

void TProtoNeutralGenes::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

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

364 {
365  //allocate the stat handler
366  if(_stats) delete _stats;
367 
368  // this makes sure that the trait index is reset correctly between simulations
369  _stats = new TTNeutralGenesSH(this);
370 
371  loader->attach(_stats);
372 
373 }
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:321

References _stats, and StatServices::attach().

◆ reset()

virtual void TProtoNeutralGenes::reset ( )
inlinevirtual

Reimplemented from TTProtoWithMap.

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

References TTProtoWithMap::reset().

◆ resetParameterFromSource()

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

Implements SimComponent.

481 {
482  TProtoNeutralGenes *srcProto = dynamic_cast< TProtoNeutralGenes* >(cmpt);
483 
484  if( param != "ntrl_genetic_map" ) return false;
485 
486  Param *srcMap = srcProto->get_parameter(param);
487 
488  if(!srcMap->isSet()) return error("parameter \"ntrl_genetic_map\" not set in source.\n");
489 
490 
491  //@TODO need to implement a way to update the genetic map of a trait in GeneticMap
492  return false;
493 }
Prototype class for the TTNeutralGenes trait class.
Definition: ttneutralgenes.h:172
int error(const char *str,...)
Definition: output.cc:79

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

◆ retrieve_data()

bool TProtoNeutralGenes::retrieve_data ( BinaryStorageBuffer reader)
virtual

Implements StorableComponent.

470 {
471  unsigned int dummy;
472  reader->read(&dummy, sizeof(int));
473  if(dummy != _locus_num ){
474  warning("Neutral mutation trait::locus number in binary source file differs from parameter value!\n\
475  >>>> adjusting locus number to match source population: %i set to %i\n", _locus_num, dummy);
476  _locus_num = dummy;
477  }
478  return true;
479 }
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.

103 {
104  _locus_num = (unsigned int)get_parameter_value("ntrl_loci");
105  _allele_num = (unsigned int)get_parameter_value("ntrl_all");
106  _ploidy = 2;
107  _mut_rate = get_parameter_value("ntrl_mutation_rate");
108  _mut_model = (unsigned int)get_parameter_value("ntrl_mutation_model");
109  _2L = _ploidy * _locus_num; // genome size
110 
111  if(get_parameter("ntrl_init_model")->isSet())
112  _init_model = (unsigned short)get_parameter_value("ntrl_init_model");
113  else
114  _init_model = 1; //maximum variance
115 
116  switch(_mut_model) {
117  case 0:
118  {
120  break;
121  }
122  case 1:
123  {
125  break;
126  }
127  case 2:
128  {
130  break;
131  }
132  default:
133  {
134  error("wrong parameter value for parameter \"ntrl_mutation_model\", max is 2\n");
135  break; //should return false
136  }
137  }
138  //special case:
140 
141  // we want to bypass the genetic map if loci are not linked
142  if( TTProtoWithMap::isRecombinationFree("ntrl")) { //test all possible options to set recomb rate = 0.5
143 
145 
147 
148  } else {
149 
150  // register the locus positions on the genetic map
151  if( ! TTProtoWithMap::setGeneticMapParameters ("ntrl") ) return false;
152 
154 
155  }
156 
157  return true;
158 }
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:407
void inherit_free(sex_t SEX, unsigned char *seq, const unsigned char **parent)
Definition: ttneutralgenes.cc:397
void mutate_KAM()
Definition: ttneutralgenes.cc:724
void mutate_SSM()
Definition: ttneutralgenes.cc:701
void mutate_2all()
Definition: ttneutralgenes.cc:743
void mutate_NULL()
Definition: ttneutralgenes.h:143
double _recombRate
Definition: ttrait_with_map.h:195
bool setGeneticMapParameters(string prefix, unsigned int numLoci=0)
Definition: ttrait_with_map.cc:126
bool isRecombinationFree(string prefix)
Definition: ttrait_with_map.cc:99

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.

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

Locations of visitors to this page
Catalogued on GSR