Nemo  2.3.56
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 ()
 
TTNeutralGenesSHget_stater ()
 
void inherit_low (sex_t SEX, unsigned char *seq, unsigned char **parent)
 
void inherit_free (sex_t SEX, unsigned char *seq, 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 ()
 
virtual void reset ()
 
- Public Member Functions inherited from TraitPrototype
virtual void reset ()=0
 Called at the end of a simulation to reset the Traits' prototypes (e.g. More...
 
virtual TTraithatch ()=0
 Creates the trait of which it is the prototype, called by IndFactory::makePrototype(). More...
 
virtual TraitPrototypeclone ()=0
 Returns a copy of itself. More...
 
virtual trait_t get_type () const =0
 Type accessor. More...
 
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 void store_data (BinaryStorageBuffer *saver)=0
 Interface to store the component data (e.g. gene values) into a binary buffer. More...
 
virtual bool retrieve_data (BinaryStorageBuffer *reader)=0
 Interface to retrieve the same data from the binary buffer. More...
 
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 short _init_model
 
double _recomb_rate
 
void(TTNeutralGenes::* _mutate_func_ptr )(void)
 
void(TProtoNeutralGenes::* _inherit_func_ptr )(sex_t, unsigned char *, unsigned char **)
 
vector< TTNeutralGenesFH * > _writers
 
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_stats(0), _type(NTRL)
52{
53 set_paramset("neutralgenes", false, this);
54
55 add_parameter("ntrl_loci", INT, true, false, 0, 0);
56 add_parameter("ntrl_init_model", INT, false, true, 0, 3);
57 add_parameter("ntrl_all", INT, true, true, 2, 256);
58 add_parameter("ntrl_mutation_rate", DBL, true, true, 0, 1);
59 add_parameter("ntrl_mutation_model", INT, true, true, 0, 2);
60
61 //genetic map parameters:
63
64 //output
65 add_parameter("ntrl_save_genotype", STR, false, false, 0, 0);
66 add_parameter("ntrl_save_fsti", BOOL, false, false, 0, 0);
67 add_parameter("ntrl_save_freq", STR, false, false, 0, 0);
68 add_parameter("ntrl_output_dir", STR, false, false, 0, 0);
69 add_parameter("ntrl_output_logtime", INT, false, false, 0, 0);
70}
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
TTNeutralGenesSH * _stats
Definition: ttneutralgenes.h:178
unsigned int _allele_num
Definition: ttneutralgenes.h:167
const trait_t _type
Definition: ttneutralgenes.h:179
double _mut_rate
Definition: ttneutralgenes.h:170
unsigned short _init_model
Definition: ttneutralgenes.h:172
double _recomb_rate
Definition: ttneutralgenes.h:173
unsigned int _locus_num
Definition: ttneutralgenes.h:168
void(TProtoNeutralGenes::* _inherit_func_ptr)(sex_t, unsigned char *, unsigned char **)
Definition: ttneutralgenes.h:175
unsigned int _ploidy
Definition: ttneutralgenes.h:169
int _mut_model
Definition: ttneutralgenes.h:171
void(TTNeutralGenes::* _mutate_func_ptr)(void)
Definition: ttneutralgenes.h:174
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().

+ Here is the caller graph for this function:

◆ TProtoNeutralGenes() [2/2]

TProtoNeutralGenes::TProtoNeutralGenes ( const TProtoNeutralGenes T)
78{
79 _paramSet = new ParamSet( *(T._paramSet) ) ;
80}
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
85{
86 if(_stats != NULL) {delete _stats; _stats = NULL;}
87 for(unsigned int i = 0; i < _writers.size(); i++)
88 delete _writers[i];
89 _writers.clear();
90
91}
vector< TTNeutralGenesFH * > _writers
Definition: ttneutralgenes.h:177

References _stats, and _writers.

Member Function Documentation

◆ clone()

virtual TProtoNeutralGenes * TProtoNeutralGenes::clone ( )
inlinevirtual

Implements TraitPrototype.

205{return new TProtoNeutralGenes(*this);}
TProtoNeutralGenes()
Definition: ttneutralgenes.cc:49

References TProtoNeutralGenes().

◆ get_allele_num()

◆ get_locus_num()

◆ get_ploidy()

◆ get_stater()

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

207{return _type;}

References _type.

Referenced by TTNeutralGenesFH::write_PLINK().

+ Here is the caller graph for this function:

◆ hatch()

TTNeutralGenes * TProtoNeutralGenes::hatch ( )
virtual

Implements TraitPrototype.

329{
330 TTNeutralGenes* kid = new TTNeutralGenes();
331
332 kid->set_proto(this);
340
341 if(_recombRate == 0.5) {
342
344
345 } else {
346
348
349 }
350
352
353 return kid;
354}
void inherit_low(sex_t SEX, unsigned char *seq, unsigned char **parent)
Definition: ttneutralgenes.cc:368
void inherit_free(sex_t SEX, unsigned char *seq, unsigned char **parent)
Definition: ttneutralgenes.cc:358
Microsatellites genome.
Definition: ttneutralgenes.h:54
void set_proto(TProtoNeutralGenes *proto)
Definition: ttneutralgenes.h:95
void set_mut_model(int value)
Definition: ttneutralgenes.h:101
void set_2L(unsigned int val)
Definition: ttneutralgenes.h:99
void set_inherit_func_ptr(void(TProtoNeutralGenes::*theFunc)(sex_t, unsigned char *, unsigned char **))
Definition: ttneutralgenes.h:105
void set_allele_num(int value)
Definition: ttneutralgenes.h:97
void set_mut_func_ptr(void(TTNeutralGenes::*theFunc)(void))
Definition: ttneutralgenes.h:103
void set_init_model(unsigned short val)
Definition: ttneutralgenes.h:102
void set_mut_rate(double value)
Definition: ttneutralgenes.h:98
void set_locus_num(int value)
Definition: ttneutralgenes.h:96
double _recombRate
Definition: ttrait_with_map.h:187

References _allele_num, _inherit_func_ptr, _init_model, _locus_num, _mut_model, _mut_rate, _mutate_func_ptr, _ploidy, TTProtoWithMap::_recombRate, inherit_free(), inherit_low(), TTNeutralGenes::set_2L(), TTNeutralGenes::set_allele_num(), TTNeutralGenes::set_inherit_func_ptr(), TTNeutralGenes::set_init_model(), TTNeutralGenes::set_locus_num(), TTNeutralGenes::set_mut_func_ptr(), TTNeutralGenes::set_mut_model(), TTNeutralGenes::set_mut_rate(), and TTNeutralGenes::set_proto().

◆ inherit_free()

void TProtoNeutralGenes::inherit_free ( sex_t  SEX,
unsigned char *  seq,
unsigned char **  parent 
)
inline
359{
360 // cout << "TProtoNeutralGenes::inherit_free\n";
361
362 for(unsigned int i = 0; i < _locus_num; ++i)
363 seq[i] = parent[RAND::RandBool()][i];
364}
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:163

References _locus_num, and RAND::RandBool().

Referenced by hatch(), and setParameters().

+ Here is the caller graph for this function:

◆ inherit_low()

void TProtoNeutralGenes::inherit_low ( sex_t  SEX,
unsigned char *  seq,
unsigned char **  parent 
)
inline
369{
370 register unsigned int prevLoc = 0, chrm_bloc;
371 register bool flipper;
372
373 vector< unsigned int >& recTable = _map.getRecLoci(SEX, _mapIndex);
374 vector< bool > & firstRecPos = _map.getFirstRecPosition(SEX);
375
376 unsigned int nbRec = recTable.size();
377
378// cout << "TProtoNeutralGenes::inherit_low; sex="<<SEX<<"\n +++ nb Rec = "
379// << nbRec-1 << "\n (recLoc[0]=" << recTable[0] << ")" << endl;
380
381 // if (!nbRec) {
382 // memcpy(&seq[0], &parent[flipper][prevLoc], (recTable[rec] - prevLoc));
383 // return;
384 // }
385 for(unsigned int c = 0, stride = 0, rec = 0; c < _numChromosome; ++c) {
386
387 flipper = firstRecPos[c];
388
389 chrm_bloc = stride + _numLociPerChrmsm[c]; //number of loci considered so far
390
391 prevLoc = stride; //stride is the first locus of a chromosome
392
393 //do recombination chromosome-wise
394// cout<<" --chrm "<<c<<" side="<<firstRecPos[c]<<endl;
395
396 for(; rec < nbRec && recTable[rec] < chrm_bloc; rec++) {
397
398// cout << " --copy from "<<prevLoc<<" to "<<recTable[rec] //<<" (side="<<flipper<<")"<<endl
399// <<" ("<<(recTable[rec] - prevLoc)<<" loc) on side "<<flipper<<endl;
400
401 memcpy(&seq[prevLoc], &parent[flipper][prevLoc], (recTable[rec] - prevLoc));
402
403 prevLoc = recTable[rec];
404
405 flipper = !flipper;
406 }
407// cout <<" --copy end of chrmsm from "<<prevLoc<<" to "<<chrm_bloc
408// <<" ("<<(chrm_bloc - prevLoc)<<" loc) on side "<<flipper<<endl;
409
410 //copy what's left between the last x-over point and the end of the chrmsme
411 memcpy(&seq[prevLoc], &parent[flipper][prevLoc], (chrm_bloc - prevLoc));
412
413 stride += _numLociPerChrmsm[c];
414
415 }
416
417 // cout << "parent chromosomes:\n --0:";
418 // unsigned int loc = 0;
419 // for (unsigned int c = 0; c < _numChromosome; ++c) {
420 // cout<<" ";
421 // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
422 // cout << (int)parent[0][loc++];
423 // }
424 // cout << "\n --1:";
425 // loc = 0;
426 // for (unsigned int c = 0; c < _numChromosome; ++c) {
427 // cout<<" ";
428 // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
429 // cout << (int)parent[1][loc++];
430 // }
431 //
432 // cout << "\ngamete:\n --0:";
433 // loc = 0;
434 // for (unsigned int c = 0; c < _numChromosome; ++c) {
435 // cout<<" ";
436 // for(unsigned int i = 0; i < _numLociPerChrmsm[c] && loc < _locus_num; ++i)
437 // cout << (int)seq[loc++];
438 // }
439 // cout << "\n\n";
440
441}
vector< unsigned int > & getRecLoci(sex_t SEX, unsigned int trait)
Returns a vector of the loci where crossing-overs take place.
Definition: ttrait_with_map.h:157
vector< bool > & getFirstRecPosition(sex_t SEX)
Returns the vector of the first chromosome position for recombination, used for all traits.
Definition: ttrait_with_map.h:163
static GeneticMap _map
Definition: ttrait_with_map.h:201
unsigned int _numChromosome
Definition: ttrait_with_map.h:189
unsigned int * _numLociPerChrmsm
Definition: ttrait_with_map.h:192
unsigned int _mapIndex
Definition: ttrait_with_map.h:185

References TTProtoWithMap::_map, TTProtoWithMap::_mapIndex, TTProtoWithMap::_numChromosome, TTProtoWithMap::_numLociPerChrmsm, GeneticMap::getFirstRecPosition(), and GeneticMap::getRecLoci().

Referenced by hatch(), and setParameters().

+ Here is the caller graph for this function:

◆ init()

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

◆ loadFileServices()

void TProtoNeutralGenes::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

155{
156 TTNeutralGenesFH* writer;
157
158 if(_writers.size() != 0) {
159 for(unsigned int i = 0; i < _writers.size(); i++)
160 delete _writers[i];
161 _writers.clear();
162 }
163
164 // --- THE READER ---
165 // note that this reader only reads in FSTAT format
166 //always add the reader:
167 //NOTE: the default extension is ".txt", will not accept ".dat" FSTAT files in input
168 writer = new TTNeutralGenesFH(this);
169
170 //set to read mode:
171 writer->set_isInputHandler(true);
172
173 //attach to file manager:
174 loader->attach_reader(writer);
175
176 //add to list of FileHandlers, will be deleted upon destruction
177 _writers.push_back( writer );
178
179 // Add a reader for ".dat" FSTAT files:
180 writer = new TTNeutralGenesFH(this);
181 writer->set_isInputHandler(true);
182 writer->set_extension(".dat");
183 loader->attach_reader(writer);
184
185 _writers.push_back( writer );
186
187 // --- WRITERS ---
188 Param* param = get_parameter("ntrl_output_logtime");
189 TMatrix temp;
190 bool isMatrix = 0;
191
192 if(param->isMatrix()) {
193 param->getMatrix(&temp);
194 isMatrix = 1;
195 }
196
197 if( get_parameter("ntrl_save_genotype")->isSet() ) {
198
199 writer = new TTNeutralGenesFH(this);
200
201 if(isMatrix)
202 writer->set_multi(true, true, 1, &temp, get_parameter("ntrl_output_dir")->getArg());
203
204 else
205 writer->set(true, param->isSet(), 1, (param->isSet() ? (int)param->getValue() : 0), 0, get_parameter("ntrl_output_dir")->getArg(), this);
206 // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
207
208 if(get_parameter("ntrl_save_genotype")->getArg().length() == 0 || //default mode is tabular
209 get_parameter("ntrl_save_genotype")->getArg() == "TAB" ||
210 get_parameter("ntrl_save_genotype")->getArg() == "tab"
211 )
212 {
213 writer->setOutputOption("allele");
215
216 }
217 else if(get_parameter("ntrl_save_genotype")->getArg() == "snp_tab" ||
218 get_parameter("ntrl_save_genotype")->getArg() == "SNP_TAB")
219 {
220 writer->setOutputOption("snp");
222 }
223 else if(get_parameter("ntrl_save_genotype")->getArg() == "FSTAT" ||
224 get_parameter("ntrl_save_genotype")->getArg() == "fstat")
225 {
226
228 writer->set_extension(".dat");
229
230 }
231 else if(get_parameter("ntrl_save_genotype")->getArg() == "GENEPOP" ||
232 get_parameter("ntrl_save_genotype")->getArg() == "genepop")
233 {
234
236
237 }
238 else if(get_parameter("ntrl_save_genotype")->getArg() == "PLINK" ||
239 get_parameter("ntrl_save_genotype")->getArg() == "plink")
240 {
242 }
243 else
244 fatal("parameter \"ntrl_save_genotype\" options are \"TAB\", \"SNP_TAB\", \"FSTAT\", \"GENEPOP\" or \"PLINK\".\n");
245
246 loader->attach(writer);
247
248 _writers.push_back( writer );
249 }
250
251 // new writer
252 if( get_parameter("ntrl_save_fsti")->isSet() ) {
253
254 writer = new TTNeutralGenesFH(this);
255
256 if(isMatrix) writer->set_multi(true, true, 1, &temp, get_parameter("ntrl_output_dir")->getArg());
257 // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
258 else writer->set(true, param->isSet(), 1, (param->isSet() ? (int)param->getValue() : 0), 0, get_parameter("ntrl_output_dir")->getArg(), this);
259
261
262 writer->set_extension(".fsti");
263
264 loader->attach(writer);
265
266 _writers.push_back( writer );
267 }
268
269 // new writer
270 if( get_parameter("ntrl_save_freq")->isSet() ) {
271
272 writer = new TTNeutralGenesFH(this);
273
274 writer->set_extension(".freq");
275
276 if (isMatrix) writer->set_multi(true, true, 1, &temp, get_parameter("ntrl_output_dir")->getArg());
277 // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
278 else writer->set(true, param->isSet(), 1, (param->isSet() ? (int)param->getValue() : 0), 0, get_parameter("ntrl_output_dir")->getArg(), this);
279
280 //check validity of output option:
281
282 if(get_parameter("ntrl_save_freq")->getArg() == "allfreq") {
283
284 warning("option \"allfreq\" to \"ntrl_save_freq\" is deprecated, using \"locus\" instead\n");
285
286 writer->setOutputOption("locus");
287
288 } else if(get_parameter("ntrl_save_freq")->getArg() == "vcomp") {
289
290 warning("option \"vcomp\" to \"ntrl_save_freq\" is deprecated, using \"allele\" instead\n");
291
292 writer->setOutputOption("allele");
293
294 } else if( get_parameter("ntrl_save_freq")->getArg() != "1" &&
295 get_parameter("ntrl_save_freq")->getArg() != "locus" &&
296 get_parameter("ntrl_save_freq")->getArg() != "allele") {
297
298 fatal("parameter \"ntrl_save_freq\" options are \"locus\" or \"allele\".\n");
299
300 } else
301 writer->setOutputOption(get_parameter("ntrl_save_freq")->getArg());
302
304
305 loader->attach(writer);
306
307 _writers.push_back( writer );
308 }
309
310}
void set_extension(const char *ext)
Definition: filehandler.h:145
virtual void set_multi(bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path)
Definition: filehandler.h:197
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:73
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:60
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:347
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:172
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:357
bool isSet()
Definition: param.h:140
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
A file handler to save the neutral markers genotypes in the FSTAT format (extended).
Definition: ttneutralgenes.h:235
void write_GENEPOP()
Definition: ttneutralgenes.cc:1113
void write_Fst_i()
Definition: ttneutralgenes.cc:1343
void setOutputOption(string opt)
Definition: ttneutralgenes.cc:703
void write_FSTAT()
Definition: ttneutralgenes.cc:1032
void write_TAB()
Definition: ttneutralgenes.cc:733
void write_varcompWC()
Definition: ttneutralgenes.cc:1409
void write_PLINK()
Definition: ttneutralgenes.cc:828
void set_write_fct(void(TTNeutralGenesFH::*fct_ptr)())
Definition: ttneutralgenes.h:266
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:236
void fatal(const char *str,...)
Definition: output.cc:96
void warning(const char *str,...)
Definition: output.cc:58

References _writers, FileServices::attach(), FileServices::attach_reader(), fatal(), SimComponent::get_parameter(), Param::getMatrix(), Param::getValue(), Param::isMatrix(), Param::isSet(), TraitFileHandler< TP >::set(), FileHandler::set_extension(), FileHandler::set_isInputHandler(), FileHandler::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.

315{
316 //allocate the stat handler
317 if(_stats) delete _stats;
318
319 // this makes sure that the trait index is reset correctly between simulations
320 _stats = new TTNeutralGenesSH(this);
321
322 loader->attach(_stats);
323
324}
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:277

References _stats, and StatServices::attach().

◆ reset()

virtual void TProtoNeutralGenes::reset ( )
inlinevirtual

Reimplemented from TTProtoWithMap.

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

References TTProtoWithMap::reset().

◆ resetParameterFromSource()

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

Implements SimComponent.

457{
458 TProtoNeutralGenes *srcProto = dynamic_cast< TProtoNeutralGenes* >(cmpt);
459
460 if( param != "ntrl_genetic_map" ) return false;
461
462 Param *srcMap = srcProto->get_parameter(param);
463
464 if(!srcMap->isSet()) return error("parameter \"ntrl_genetic_map\" not set in source.\n");
465
466
467 //@TODO need to implement a way to update the genetic map of a trait in GeneticMap
468 return false;
469}
Prototype class for the TTNeutralGenes trait class.
Definition: ttneutralgenes.h:164
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.

446{
447 unsigned int dummy;
448 reader->read(&dummy, sizeof(int));
449 if(dummy != _locus_num ){
450 warning("Neutral mutation trait::locus number in binary source file differs from parameter value!\n\
451 >>>> adjusting locus number to match source population: %i set to %i\n", _locus_num, dummy);
452 _locus_num = dummy;
453 }
454 return true;
455}
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.

96{
97 _locus_num = (unsigned int)get_parameter_value("ntrl_loci");
98 _allele_num = (unsigned int)get_parameter_value("ntrl_all");
99 _ploidy = 2;
100 _mut_rate = get_parameter_value("ntrl_mutation_rate");
101 _mut_model = (unsigned int)get_parameter_value("ntrl_mutation_model");
102
103 if(get_parameter("ntrl_init_model")->isSet())
104 _init_model = (unsigned short)get_parameter_value("ntrl_init_model");
105 else
106 _init_model = 1; //maximum variance
107
108 switch(_mut_model) {
109 case 0:
110 {
112 break;
113 }
114 case 1:
115 {
117 break;
118 }
119 case 2:
120 {
122 break;
123 }
124 default:
125 {
126 error("wrong parameter value for parameter \"ntrl_mutation_model\", max is 2\n");
127 break; //should return false
128 }
129 }
130 //special case:
132
133 // we want to bypass the genetic map if loci are not linked
134 if( TTProtoWithMap::isRecombinationFree("ntrl")) { //test all possible options to set recomb rate = 0.5
135
137
139
140 } else {
141
142 // register the locus positions on the genetic map
143 if( ! TTProtoWithMap::setGeneticMapParameters ("ntrl") ) return false;
144
146
147 }
148
149 return true;
150}
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
void mutate_SSM()
Definition: ttneutralgenes.cc:642
void mutate_2all()
Definition: ttneutralgenes.cc:684
void mutate_NULL()
Definition: ttneutralgenes.h:117
void mutate_KAM()
Definition: ttneutralgenes.cc:665
bool isRecombinationFree(string prefix)
Definition: ttrait_with_map.cc:98
bool setGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:125

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

218{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

◆ _allele_num

unsigned int TProtoNeutralGenes::_allele_num
private

◆ _inherit_func_ptr

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

Referenced by hatch(), and setParameters().

◆ _init_model

unsigned short TProtoNeutralGenes::_init_model
private

Referenced by hatch(), and setParameters().

◆ _locus_num

unsigned int TProtoNeutralGenes::_locus_num
private

◆ _mut_model

int TProtoNeutralGenes::_mut_model
private

Referenced by hatch(), and setParameters().

◆ _mut_rate

double TProtoNeutralGenes::_mut_rate
private

Referenced by hatch(), and setParameters().

◆ _mutate_func_ptr

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

Referenced by hatch(), and setParameters().

◆ _ploidy

unsigned int TProtoNeutralGenes::_ploidy
private

Referenced by get_ploidy(), hatch(), 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.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR