Nemo  2.3.46
ttrait_with_map.h
Go to the documentation of this file.
1 
30 #ifndef TTRAIT_WITH_MAP_H
31 #define TTRAIT_WITH_MAP_H
32 
33 #include <string>
34 #include <vector>
35 #include <map>
36 #include <utility>
37 #include "ttrait.h"
38 
39 
40 // ------------------------------------------------------------------------------
44 // ------------------------------------------------------------------------------
45 
46 class GeneticMap {
47 
48 private:
49 
50  unsigned long _currentIndividual;
51 
53  map< trait_t, unsigned int > _traits;
54 
56  unsigned int _nTrait;
57 
61  vector< unsigned int* > _lociLookupTable; //this is the actual map, for each trait
63  vector< unsigned int > _numChrsmPerTrait;
65  vector< unsigned int > _numLociPerTrait;
67  vector< unsigned int* > _numLociPerChrsmPerTrait;
69  vector< unsigned int* > _locPositionsPerTrait;
70 
74  vector< vector < unsigned int > > _recPositions[2];
75 
78  vector< bool > _chrsmFirstRecombPosition[2];
79 
80  unsigned int _numChromosome;
81  unsigned int *_perChrsmLength; //array length is _numChromosome
82  unsigned int *_chrsmFirstLocusPosition; //array length is _numChromosome
83  unsigned int _totalLength;
84  unsigned int _totalNumLoci;
85  double _resolution;
87 
88 
89 public:
90 
91  GeneticMap() :_currentIndividual(0), _nTrait(0),
92  _numChromosome(0), _perChrsmLength(0),
93  _chrsmFirstLocusPosition(0), _totalLength(0), _totalNumLoci(0), _resolution(1),
94  _totRecombEventsMean(0) {}
95 
97 
98  double getResolution ( ) {return _resolution;}
99 
100  double setResolution (double val)
101  {
102  _resolution = (val < _resolution ? val : _resolution);
103  return _resolution;
104  }
105 
106  void rescaleMap (double val);
107  void reset_tables ();
108  void clear ();
109 
115  void setLookupTable (unsigned int idx);
116 
124  void recombine (sex_t SEX);
125 
133  bool registerIndForRecombine (unsigned long ID)
134  {
135  if (ID == _currentIndividual) return false;
136  else _currentIndividual = ID;
137  return true;
138  }
139 
141  unsigned int addTrait (trait_t trait, unsigned int nChrm, unsigned int nLoc, unsigned int* nLocChrm,
142  double resolution, unsigned int* locPositions);
143 
144  void unregisterTrait (trait_t trait);
145 
146 // void unregisterTrait_at (unsigned int traitIdx);
147 
149  vector< unsigned int>& getRecLoci (sex_t SEX, unsigned int trait)
150  {
151  return _recPositions[SEX][trait];
152  }
153 
155  vector< bool >& getFirstRecPosition (sex_t SEX)
156  { return _chrsmFirstRecombPosition[SEX]; }
157 };
158 
159 
160 // ------------------------------------------------------------------------------
164 // ------------------------------------------------------------------------------
166 
167  string _paramPrefix;
168 
170 
171 protected:
172 
173  //recombination:
174  unsigned int _mapIndex;
176  double _recombRate;
178  unsigned int _numChromosome;
179  unsigned int _numLoci;
181  unsigned int *_numLociPerChrmsm;
182  unsigned int *_chrsmLength;
183  unsigned int *_lociMapPositions;
184 
185  friend class TTraitWithMap;
186 
187 public:
188 
189 
190  static GeneticMap _map;
191 
192 
193  TTProtoWithMap():_mapIndex(0), _isRegistered(0),_totRecombEventsMean(0),
194  _recombRate(0), _mapResolution(1), _numChromosome(0), _numLoci(0),
195  _recombRatePerChrmsm(0), _numLociPerChrmsm(0), _chrsmLength(0),
196  _lociMapPositions(0)
197  {}
198 
199  TTProtoWithMap(const TTProtoWithMap& TP);
200 
201  virtual ~TTProtoWithMap();
202 
203  void setMapIndex (unsigned int idx) {_mapIndex = idx;}
204 
205  unsigned int getMapIndex () {return _mapIndex;}
206 
207  bool setGeneticMapParameters (string prefix);
208 
209  void addGeneticMapParameters (string prefix);
210 
212 
213  bool setRecombinationMapNonRandom (vector< vector<double> >* lociPositions);
214 
215  bool setRecombinationMapFixed ();
216 
217  bool setNumLociPerChromosome (string param_name);
218 
220 
221  void registerGeneticMap ();
222 
223  static void recombine (unsigned long indID);
224 
225  virtual void reset ();
226 
227 };
228 
229 
230 // ------------------------------------------------------------------------------
234 // ------------------------------------------------------------------------------
235 class TTraitWithMap : public TTrait {
236 
237 protected:
238 
240 
241 public:
242 
243  TTraitWithMap():_myProto(0) {}
244 
245  virtual ~TTraitWithMap() {}
246 
247 };
248 
249 #endif
unsigned int addTrait(trait_t trait, unsigned int nChrm, unsigned int nLoc, unsigned int *nLocChrm, double resolution, unsigned int *locPositions)
Returns the table index for the registered trait.
Definition: ttrait_with_map.cc:547
double * _recombRatePerChrmsm
Definition: ttrait_with_map.h:180
GeneticMap.
Definition: ttrait_with_map.h:46
GeneticMap()
Definition: ttrait_with_map.h:91
void setLookupTable(unsigned int idx)
Bbuilds the lookup table for each trait.
Definition: ttrait_with_map.cc:769
vector< unsigned int > _numChrsmPerTrait
Vector of number of chromosomes for each trait.
Definition: ttrait_with_map.h:63
std::string trait_t
Trait types.
Definition: types.h:63
unsigned int _nTrait
Number of traits registered in the map.
Definition: ttrait_with_map.h:56
double setResolution(double val)
Definition: ttrait_with_map.h:100
void registerGeneticMap()
Definition: ttrait_with_map.cc:476
double _resolution
Definition: ttrait_with_map.h:85
map< trait_t, unsigned int > _traits
Table mapping trait type to its position index in the following tables.
Definition: ttrait_with_map.h:53
bool setRecombinationMapNonRandom(vector< vector< double > > *lociPositions)
Definition: ttrait_with_map.cc:311
string _paramPrefix
Definition: ttrait_with_map.h:167
unsigned int _totalNumLoci
Definition: ttrait_with_map.h:84
double _totRecombEventsMean
Definition: ttrait_with_map.h:175
unsigned int * _lociMapPositions
Definition: ttrait_with_map.h:183
double _recombRate
Definition: ttrait_with_map.h:176
TTProtoWithMap.
Definition: ttrait_with_map.h:165
~GeneticMap()
Definition: ttrait_with_map.h:96
static GeneticMap _map
Definition: ttrait_with_map.h:190
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:155
unsigned int * _chrsmLength
Definition: ttrait_with_map.h:182
double _totRecombEventsMean
Definition: ttrait_with_map.h:86
unsigned int getMapIndex()
Definition: ttrait_with_map.h:205
void reset_recombination_pointers()
Definition: ttrait_with_map.cc:495
vector< bool > _chrsmFirstRecombPosition[2]
Two vectors holding the starting copy of each chromosome to use when creating the two gametes that ar...
Definition: ttrait_with_map.h:78
unsigned int _totalLength
Definition: ttrait_with_map.h:83
vector< unsigned int * > _locPositionsPerTrait
Vector containing the table of map position for the loci of each trait.
Definition: ttrait_with_map.h:69
Interface for all trait types, declares all basic trait operations.
Definition: ttrait.h:46
vector< vector< unsigned int > > _recPositions[2]
Vector of tables containing, for each trait, the locus number at which x-overs happen.
Definition: ttrait_with_map.h:74
virtual void reset()
Definition: ttrait_with_map.cc:505
unsigned int _numLoci
Definition: ttrait_with_map.h:179
void addGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:77
void rescaleMap(double val)
Definition: ttrait_with_map.cc:740
void setMapIndex(unsigned int idx)
Definition: ttrait_with_map.h:203
unsigned int _numChromosome
Definition: ttrait_with_map.h:80
TTProtoWithMap * _myProto
Definition: ttrait_with_map.h:239
unsigned int * _numLociPerChrmsm
Definition: ttrait_with_map.h:181
static void recombine(unsigned long indID)
Definition: ttrait_with_map.cc:485
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
bool setRecombinationMapFixed()
Definition: ttrait_with_map.cc:335
bool registerIndForRecombine(unsigned long ID)
Called by TTProtoWithMap::recombine with individual ID passed down from Individual::recombine.
Definition: ttrait_with_map.h:133
TTraitWithMap.
Definition: ttrait_with_map.h:235
bool setNumLociPerChromosome(string param_name)
Definition: ttrait_with_map.cc:253
unsigned int * _chrsmFirstLocusPosition
Definition: ttrait_with_map.h:82
vector< unsigned int > _numLociPerTrait
Vector of number of loci for each trait.
Definition: ttrait_with_map.h:65
unsigned int _numChromosome
Definition: ttrait_with_map.h:178
bool _isRegistered
Definition: ttrait_with_map.h:169
TTrait setter.
Definition: ttrait.h:125
unsigned long _currentIndividual
Definition: ttrait_with_map.h:50
bool setGeneticMapParameters(string prefix)
Definition: ttrait_with_map.cc:88
double getResolution()
Definition: ttrait_with_map.h:98
virtual ~TTraitWithMap()
Definition: ttrait_with_map.h:245
void reset_tables()
Definition: ttrait_with_map.cc:972
unsigned int * _perChrsmLength
Definition: ttrait_with_map.h:81
void clear()
Definition: ttrait_with_map.cc:538
vector< unsigned int * > _numLociPerChrsmPerTrait
Vector containing a table of number of loci per chromosome for each trait.
Definition: ttrait_with_map.h:67
vector< unsigned int * > _lociLookupTable
A list of tables that map the map position (cM) to a locus, for each trait.
Definition: ttrait_with_map.h:61
void recombine(sex_t SEX)
Called by TTProtoWithMap::recombine twice to create the two gametes necessary for the creation of a n...
Definition: ttrait_with_map.cc:879
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:149
TTraitWithMap()
Definition: ttrait_with_map.h:243
unsigned int _mapIndex
Definition: ttrait_with_map.h:174
virtual ~TTProtoWithMap()
Definition: ttrait_with_map.cc:70
double _mapResolution
Definition: ttrait_with_map.h:177
bool setRecombinationMapRandom()
Definition: ttrait_with_map.cc:381
void unregisterTrait(trait_t trait)
Definition: ttrait_with_map.cc:517
TTProtoWithMap()
Definition: ttrait_with_map.h:193

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR