Nemo  2.4.2
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
GeneticMap Class Reference

GeneticMap. More...

#include <ttrait_with_map.h>

+ Collaboration diagram for GeneticMap:

Public Member Functions

 GeneticMap ()
 
 ~GeneticMap ()
 
bool getGeneticMap (trait_t trait, double **table, unsigned int table_length)
 
double getResolution ()
 
double setResolution (double val)
 
void rescaleMap (double val)
 
void reset_tables ()
 
void clear ()
 
void setLookupTable (unsigned int idx)
 Bbuilds the lookup table for each trait. More...
 
void recombine (sex_t SEX)
 Called by TTProtoWithMap::recombine twice to create the two gametes necessary for the creation of a new individual. More...
 
void placeRecombinationEvents (sex_t SEX, vector< unsigned int > junctions, const vector< bool > &firstRecPos)
 Deterministic counterpart of recombine(sex_t): instead of drawing the x-over map positions and per-chromosome start sides at random, they are supplied by the caller. More...
 
void placeRecombinationEvents (sex_t SEX)
 Shared no-allocation core of recombine()/placeRecombinationEvents(): maps the x-over positions already stored in the member _junctions to per-trait locus indices (dedup + lookup-table mapping + trailing-gap/boundary skip + sentinel), filling _recPositions[SEX]. More...
 
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. More...
 
bool registerIndForRecombine (unsigned long ID)
 Called by TTProtoWithMap::recombine with individual ID passed down from Individual::recombine. More...
 
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. More...
 
void unregisterTrait (trait_t trait)
 
bool checkRegisteredTrait (trait_t trait)
 Returns true if trait 'trait' has registered a genetic map, false otherwise. More...
 
vector< unsigned int > & getRecLoci (sex_t SEX, unsigned int trait)
 Returns a vector of the loci where crossing-overs take place. More...
 
vector< bool > & getFirstRecPosition (sex_t SEX)
 Returns the vector of the first chromosome position for recombination, used for all traits. More...
 
unsigned int * getLocusPositionTable (const trait_t trait)
 

Private Attributes

unsigned long _currentIndividual
 
map< trait_t, unsigned int > _traits
 Table mapping trait type to its position index in the following tables. More...
 
unsigned int _nTrait
 Number of traits registered in the map. More...
 
vector< unsigned int * > _lociLookupTable
 A list of tables that map the map position (cM) to a locus, for each trait. More...
 
vector< unsigned int > _numChrsmPerTrait
 Vector of number of chromosomes for each trait. More...
 
vector< unsigned int > _numLociPerTrait
 Vector of number of loci for each trait. More...
 
vector< unsigned int * > _numLociPerChrsmPerTrait
 Vector containing a table of number of loci per chromosome for each trait. More...
 
vector< unsigned int * > _locPositionsPerTrait
 Vector containing the table of map position for the loci of each trait. More...
 
vector< vector< unsigned int > > _recPositions [2]
 Vector of tables containing, for each trait, the locus number at which x-overs happen. More...
 
vector< bool > _chrsmFirstRecombPosition [2]
 Two vectors holding the starting copy of each chromosome to use when creating the two gametes that are used to create a new individual. More...
 
vector< unsigned int > _junctions
 A vector to store the position of the recombination events. More...
 
unsigned int _numChromosome
 
unsigned int * _perChrsmLength
 
unsigned int * _chrsmFirstLocusPosition
 
unsigned int _totalLength
 
unsigned int _recombLength
 
unsigned int _totalNumLoci
 
double _resolution
 
double _totRecombEventsMean
 
double _recombinationRate
 

Detailed Description

Constructor & Destructor Documentation

◆ GeneticMap()

GeneticMap::GeneticMap ( )
inline
unsigned int _nTrait
Number of traits registered in the map.
Definition: ttrait_with_map.h:54
unsigned int _recombLength
Definition: ttrait_with_map.h:86
double _recombinationRate
Definition: ttrait_with_map.h:90
double _totRecombEventsMean
Definition: ttrait_with_map.h:89
unsigned int * _chrsmFirstLocusPosition
Definition: ttrait_with_map.h:84
unsigned int _totalLength
Definition: ttrait_with_map.h:85
unsigned int * _perChrsmLength
Definition: ttrait_with_map.h:83
unsigned int _numChromosome
Definition: ttrait_with_map.h:82
unsigned int _totalNumLoci
Definition: ttrait_with_map.h:87
double _resolution
Definition: ttrait_with_map.h:88
unsigned long _currentIndividual
Definition: ttrait_with_map.h:48

◆ ~GeneticMap()

GeneticMap::~GeneticMap ( )
inline
100 {reset_tables();}
void reset_tables()
Definition: ttrait_with_map.cc:1403

References reset_tables().

Member Function Documentation

◆ addTrait()

unsigned int GeneticMap::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.

695 {
696  map<trait_t, unsigned int>::iterator tIter;
697 
698  unsigned int traitIdx = 0;
699 
700  bool do_add = true;
701 
702  tIter = _traits.find(trait);
703 
704  if ( tIter != _traits.end() ) {
705  //this shouldn't happen... unless we are loading a pop from source!!
706 
707  traitIdx = tIter->second;
708 
709  if(_numChrsmPerTrait[traitIdx] != nChrm)
710  fatal("mismatch while loading source population and resetting genetic map for trait \"%s\" \n\
711 >>>>> number of chromosomes differ (%i != %i)\n\
712 >>>>> please check match between init file and source population\n",trait.c_str(),_numChrsmPerTrait[traitIdx],nChrm);
713 
714  if(_numLociPerTrait[traitIdx] != nLoc)
715  fatal("mismatch while loading source population and resetting genetic map for trait \"%s\"\n\
716 >>>>> number of loci differ (%i != %i)\n\
717 >>>>> please check match between init file and source population\n",trait.c_str(),_numLociPerTrait[traitIdx], nLoc);
718 
719  unsigned int *locTable = _numLociPerChrsmPerTrait[traitIdx];
720 
721  for (unsigned int i=0; i<nChrm; i++)
722  if(locTable[i] != nLocChrm[i])
723  fatal("mismatch while loading source population and resetting genetic map for trait \"%s\"\n\
724 >>>>> number of loci differ (%i != %i) on chromosome %i\n\
725 >>>>> please check match between init file and source population\n",trait.c_str(),locTable[i], nLocChrm[i], i+1);
726 
727  do_add = false;
728 
729  }
730 
731 #if defined(_DEBUG_)
732  cout << "GeneticMap::addTrait: \n";
733  cout << " _numChromosome = "<<nChrm<<endl;
734  cout << " _totalNumLoci = "<<_totalNumLoci<<endl;
735  cout << " _resolution = "<<_resolution<<endl;
736  cout << " _totalLength = "<<_totalLength<<endl;
737  cout << ":::"<<trait<<"::: params:\n";
738  cout << " num chromosome = "<<nChrm<<endl;
739  cout << " num loci = "<<nLoc<<endl;
740  cout << " map resolution = "<<resolution<<endl;
741 #endif
742 
743  if (_nTrait == 0) { //this is the first trait to register its map
744 
745  _numChromosome = nChrm;
746  _totalNumLoci = nLoc;
747  _resolution = resolution;
748  _totalLength = locPositions[nLoc-1];
749 
750  //destroy all previously allocated tables
751  reset_tables();
752 
753  _perChrsmLength = new unsigned int[_numChromosome];
754  _chrsmFirstLocusPosition = new unsigned int[_numChromosome];
755 
756  } else {
757  //we have already registered some trait's genetic map, we append this trait's info and update the map
758 
759  if (nChrm != _numChromosome) //check chromosome numbers
760  fatal("Traits in init file don't have same number of chromosomes, cannot set the genetic map!\n");
761 
762  //number of loci
763  _totalNumLoci = max(_totalNumLoci, nLoc);
764 
765  //setting the resolution:
766  if (resolution < _resolution) {
767 
768 // cout << "GeneticMap::addTrait: rescaling map resolution (old "<< _resolution << "; new "<< resolution<< ")\n";
769 
770  rescaleMap(resolution);
771 
772  } else if (resolution > _resolution) {
773 
774 // cout << "GeneticMap::addTrait: rescaling locus position (old "<< _resolution << "; new "<< resolution<< "; ratio "<< resolution/_resolution <<")\n";
775 
776  double ratio = resolution/_resolution;
777 
778  for(unsigned int i = 0; i < nLoc; ++i)
779  locPositions[i] = (unsigned int)((double)locPositions[i]*ratio);
780  }
781 
782  }
783 
784  if(do_add) { //only at the start of a simulation, not when loading pop from binary source
785 
786  traitIdx = _nTrait;
787 
788  _traits[trait] = _nTrait++;
789 
790 
791  //---- record num chrmsm
792  if ( _numChrsmPerTrait.size() != _nTrait -1 ) {
793  fatal("Genetic map::wrong size of table of num chrms per trait (%i != %i)",
794  _numChrsmPerTrait.size(), _nTrait -1);
795  } else
796  _numChrsmPerTrait.push_back(nChrm);
797 
798  //---- record num loci
799  if ( _numLociPerTrait.size() != _nTrait -1 ) {
800  fatal("Genetic map::wrong size of table of num loci per trait (%i != %i)",
801  _numLociPerTrait.size(), _nTrait -1);
802  } else
803  _numLociPerTrait.push_back(nLoc);
804 
805  //---- record table of num loci per chrmsm
806  if ( _numLociPerChrsmPerTrait.size() != _nTrait -1 )
807  fatal("Genetic map::wrong size of table of num loci per chrms per trait (%i != %i)",
809 
810  unsigned int* locTable = new unsigned int[nChrm];
811 
812  for (unsigned int i = 0; i < nChrm; i++) locTable[i] = nLocChrm[i];
813 
814  _numLociPerChrsmPerTrait.push_back(locTable);
815 
816  //---- record the locus positions
817  if ( _locPositionsPerTrait.size() != _nTrait -1 ) {
818  fatal("Genetic map::wrong size of table of loc position per trait (%i != %i)",
819  _locPositionsPerTrait.size(), _nTrait-1);
820  }
821 
822  //copy the locus positions, they are at the correct resolution already
823  unsigned int* posTable = new unsigned int[nLoc];
824 
825  for (unsigned int i = 0; i < nLoc; ++i) {
826  posTable[i] = locPositions[i];
827  }
828 
829  _locPositionsPerTrait.push_back(posTable);
830 
831 
832  //---- create tables to record positions of x-over, for each gamete (male and female)
833 
834  for(unsigned int s = 0; s < 2; ++s){
835  if ( _recPositions[s].size() != _nTrait -1 )
836  fatal("Genetic map::wrong size of rec positions table (%i != %i)",
837  _recPositions[s].size(), _nTrait-1);
838 
839  _recPositions[s].push_back(vector<unsigned int>()); //add an empty array for each trait
840  }
841 
842 
843  //---- set the map positions according to other trait's
844  //---- need to correctly set starting position and length of each chromosome
845 
846  if (_nTrait == 1) { //first trait to register
847 
848  for (unsigned int c = 0, stride = 0; c < _numChromosome; ++c) {
849  _chrsmFirstLocusPosition[c] = locPositions[stride];
850  _perChrsmLength[c] = locPositions[stride + nLocChrm[c] - 1] - locPositions[stride]; //position of last locus - position of first locus on that chromosome.
851  stride += nLocChrm[c];
852  }
853 
854  } else {
855 
856  for (unsigned int c = 0, lastPos, stride = 0; c < _numChromosome; ++c) {
857 
858  lastPos = max(locPositions[stride + nLocChrm[c] - 1],
860 
861  _chrsmFirstLocusPosition[c] = min(_chrsmFirstLocusPosition[c], locPositions[stride]);
862 
863  _perChrsmLength[c] = lastPos - _chrsmFirstLocusPosition[c];
864 
865  stride += nLocChrm[c];
866  }
867  }
868 
869  //---- compute total chromosome length
870  _totalLength = 0;
871  for (unsigned int c = 0; c < _numChromosome; ++c) _totalLength += _perChrsmLength[c];
872 
873  //---- mean num recombination events, map length of 1M = 1 x-over on average
874  _totRecombEventsMean = (double)_totalLength * 0.01 * _resolution;
875 
876  //---- set the map size used to draw recombination spots; one less operation in recombine()...
878 
879  //---- set the recombination rate between adjacent positions on the map;
881 
882 
883 #if defined(_DEBUG_) or defined(_REC_DEBUG_)
884  cout << "GeneticMap::addTrait: "<<endl;
885  cout << " map stats for trait \""<<trait<<"\" at "<<traitIdx<<"\n";
886  cout << " _totalLength = "<<_totalLength<<endl;
887  cout << " _totRecombEventsMean = "<<_totRecombEventsMean<<endl;
888 #endif
889 
890  if(_totalLength > 9e+8)
891  warning("Your genetic map is larger than %.2fcM with %i elements, you may experience memory allocation problems\
892  as well as problems at runtime.\n",
894 
895  //---- create new slot for the lookup table of that trait
896  // will be allocated and filled in setLookupTable
897  if ( _lociLookupTable.size() != _nTrait -1 )
898  fatal("Genetic map::wrong size of loci lookup tables (%i != %i)",
899  _lociLookupTable.size(), _nTrait-1);
900 
901  _lociLookupTable.push_back(NULL);
902 
903  //---- set all lookup tables (all genetic maps):
904  // we reset all tables each time a trait is added because _totalLength changes
905  for (unsigned int t = 0; t < _nTrait; ++t) setLookupTable(t);
906  }
907 
908 #if defined(_DEBUG_) or defined(_REC_DEBUG_)
909  cout << "GeneticMap::addTrait: "<<endl;
910  cout << " traits in table:\n";
911  map<trait_t, unsigned int>::const_iterator tt_it = _traits.begin();
912  while(tt_it != _traits.end()) {
913  cout << " ["<<tt_it->second<<"] "<<tt_it->first<<endl;
914  tt_it++;
915  }
916 #endif
917 
918  return traitIdx;
919 }
void setLookupTable(unsigned int idx)
Bbuilds the lookup table for each trait.
Definition: ttrait_with_map.cc:982
vector< unsigned int > _numLociPerTrait
Vector of number of loci for each trait.
Definition: ttrait_with_map.h:63
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:59
vector< unsigned int > _numChrsmPerTrait
Vector of number of chromosomes for each trait.
Definition: ttrait_with_map.h:61
vector< unsigned int * > _locPositionsPerTrait
Vector containing the table of map position for the loci of each trait.
Definition: ttrait_with_map.h:68
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:73
vector< unsigned int * > _numLociPerChrsmPerTrait
Vector containing a table of number of loci per chromosome for each trait.
Definition: ttrait_with_map.h:65
map< trait_t, unsigned int > _traits
Table mapping trait type to its position index in the following tables.
Definition: ttrait_with_map.h:51
void rescaleMap(double val)
Definition: ttrait_with_map.cc:953
void fatal(const char *str,...)
Definition: output.cc:98
void warning(const char *str,...)
Definition: output.cc:56

References _chrsmFirstLocusPosition, _lociLookupTable, _locPositionsPerTrait, _nTrait, _numChromosome, _numChrsmPerTrait, _numLociPerChrsmPerTrait, _numLociPerTrait, _perChrsmLength, _recombinationRate, _recombLength, _recPositions, _resolution, _totalLength, _totalNumLoci, _totRecombEventsMean, _traits, fatal(), rescaleMap(), reset_tables(), setLookupTable(), and warning().

Referenced by TTProtoWithMap::registerGeneticMap().

+ Here is the caller graph for this function:

◆ checkRegisteredTrait()

bool GeneticMap::checkRegisteredTrait ( trait_t  trait)

Returns true if trait 'trait' has registered a genetic map, false otherwise.

Parameters
traitThe trait name to check for in the trait table.
673 {
674  map<trait_t, unsigned int>::iterator tIter = _traits.find(trait);
675 
676  return ( tIter != _traits.end() );
677 }

References _traits.

Referenced by TTProtoWithMap::is_mapped(), and TTQuantiFH::setOutputOption().

+ Here is the caller graph for this function:

◆ clear()

void GeneticMap::clear ( )
682 {
683  reset_tables();
684  _traits.clear();
685  _nTrait = 0;
686 }

References _nTrait, _traits, and reset_tables().

Referenced by IndFactory::clearPrototype().

+ Here is the caller graph for this function:

◆ getFirstRecPosition()

vector< bool >& GeneticMap::getFirstRecPosition ( sex_t  SEX)
inline

Returns the vector of the first chromosome position for recombination, used for all traits.

190  { return _chrsmFirstRecombPosition[SEX]; }
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:77

References _chrsmFirstRecombPosition.

◆ getGeneticMap()

bool GeneticMap::getGeneticMap ( trait_t  trait,
double **  table,
unsigned int  table_length 
)
924 {
925  map< trait_t, unsigned int>::const_iterator ITER = _traits.find(trait);
926 
927  if(ITER == _traits.end())
928  return(error("GeneticMap::getGeneticMap::failed to find trait \"%s\" in genetic map\n", trait.c_str()));
929 
930  unsigned int idx = ITER->second;
931 
932  assert(table_length == _numLociPerTrait[idx]);
933 
934  unsigned int chr = 0, loc_cnt = _numLociPerChrsmPerTrait[idx][0];
935 
936  for(unsigned int i = 0; i < table_length; ++i) {
937 
938  if(i >= loc_cnt) {
939  chr++;
940  loc_cnt += _numLociPerChrsmPerTrait[idx][chr];
941  }
942 
943  table[0][i] = chr;
944  table[1][i] = _locPositionsPerTrait[idx][i];
945 
946  }
947 
948  return true;
949 }
int error(const char *str,...)
Definition: output.cc:77

References _locPositionsPerTrait, _numLociPerChrsmPerTrait, _numLociPerTrait, _traits, and error().

Referenced by GenotyperFH::FHwrite(), GenotyperFH::print_PLINK(), TTNeutralGenesFH::write_PLINK(), and TTQuantiFH::write_PLINK().

+ Here is the caller graph for this function:

◆ getLocusPositionTable()

unsigned int* GeneticMap::getLocusPositionTable ( const trait_t  trait)
inline
193  {return _locPositionsPerTrait[ _traits[ trait ] ];}

References _locPositionsPerTrait, and _traits.

Referenced by TTProtoWithMap::get_locus_map_positions().

+ Here is the caller graph for this function:

◆ getRecLoci()

vector< unsigned int>& GeneticMap::getRecLoci ( sex_t  SEX,
unsigned int  trait 
)
inline

Returns a vector of the loci where crossing-overs take place.

184  {
185  return _recPositions[SEX][trait];
186  }

References _recPositions.

◆ getResolution()

double GeneticMap::getResolution ( )
inline
104 {return _resolution;}

References _resolution.

Referenced by TTProtoWithMap::recordRandomMap().

+ Here is the caller graph for this function:

◆ placeRecombinationEvents() [1/2]

void GeneticMap::placeRecombinationEvents ( sex_t  SEX)

Shared no-allocation core of recombine()/placeRecombinationEvents(): maps the x-over positions already stored in the member _junctions to per-trait locus indices (dedup + lookup-table mapping + trailing-gap/boundary skip + sentinel), filling _recPositions[SEX].

It does NOT set _chrsmFirstRecombPosition: each caller sets the per-chromosome start copies itself (recombine() draws them, the deterministic overload copies them from firstRecPos).

1195 {
1196  //empty the array of x-over positions
1197  for (unsigned int t = 0; t < _nTrait; t++) {
1198  _recPositions[SEX][t].clear();
1199  }
1200 
1201  //_junctions are assumed in range [0,_totalLength]: the random path (recombine) draws them
1202  //that way by construction and only calls this when nbRec>0; the deterministic entry point
1203  //clamps untrusted input before calling. So no per-gamete bounds scan happens here.
1204 
1205  unsigned int nbRec = _junctions.size();
1206 
1207  //now determine where the x-over will take place
1208  if(nbRec > 0) {
1209 
1210  //sort the positions
1211  sort(_junctions.begin(), _junctions.end());
1212 
1213 #ifdef _REC_DEBUG_
1214  cout<< " --- sorted junctions ("<< _junctions.size()<<"): ";
1215  auto print = [](unsigned int& n){cout<<" "<<n;};
1216  for_each(_junctions.begin(), _junctions.end(), print);
1217  cout<<endl;
1218 #endif
1219 
1220  //remove the duplicates, we keep only one when that happens (in principle very rarely):
1221  auto last = unique(_junctions.begin(), _junctions.end());
1222 
1223 
1224  // UPDATE NUMBER OF RECOMBINATION EVENTS
1225 
1226  nbRec = last - _junctions.begin(); // these are the unique x-over map positions
1227 
1228 #ifdef _REC_DEBUG_
1229  cout<<" --- after removing duplicates ("<< last - _junctions.begin()<<"): ";
1230  for_each(_junctions.begin(), last, print);
1231  cout<<endl;
1232 
1233  cout<<" --- computing rec map position: \n";
1234 #endif
1235 
1236  size_t pos;
1237 
1238  // chromosome of a contiguous map position. A boundary coordinate B_c is shared by
1239  // chromosome c-1's max-position locus and chromosome c's min-position locus;
1240  // setLookupTable fills B_c during chromosome c-1's loop (its bound is inclusive:
1241  // pos <= _perChrsmLength[c-1]), so B_c belongs to the LOWER chromosome. We must use
1242  // the SAME convention here ("<=", not "<"): otherwise a crossover landing exactly on
1243  // B_c is classified as chromosome c here but mapped to chromosome c-1's last locus by
1244  // the lookup, and traits disagree on which chromosome it belongs to -> desync at the
1245  // sparse trait's first locus of the next chromosome.
1246  auto chromOfPos = [this](size_t p) -> unsigned int {
1247  unsigned int end = 0;
1248  for (unsigned int c = 0; c < _numChromosome; ++c) {
1249  end += _perChrsmLength[c];
1250  if (p <= end) return c;
1251  }
1252  return (_numChromosome ? _numChromosome - 1 : 0);
1253  };
1254 
1255  for (unsigned int t = 0; t < _nTrait; t++) {
1256 
1257  // chromosome of a locus index for trait t; the sentinel region (loc past the
1258  // last locus of the last chromosome) returns _numChromosome.
1259  auto chromOfLocus = [this, t](unsigned int loc) -> unsigned int {
1260  unsigned int end = 0;
1261  for (unsigned int c = 0; c < _numChromosome; ++c) {
1262  end += _numLociPerChrsmPerTrait[t][c];
1263  if (loc < end) return c;
1264  }
1265  return _numChromosome;
1266  };
1267 
1268 #ifdef _REC_DEBUG_
1269  cout<<" trait "<< t << endl;
1270 #endif
1271 
1272  for(unsigned int i = 0, hit; i < nbRec; ++i) {
1273 
1274  pos = _junctions[i];
1275 
1276  hit = _lociLookupTable[t][pos];
1277 
1278  // A crossover that falls on chromosome c but past this trait's LAST locus on c
1279  // (its "trailing gap") maps to cStart(c+1), i.e. a locus on a LATER chromosome
1280  // than the crossover itself. Such a crossover is a no-op for this trait and must
1281  // NOT be recorded: otherwise reduceJunctions' zip-forward would mis-account it as
1282  // a flip of chromosome c+1 and decouple this trait from the others across that
1283  // whole chromosome. (Mirror of the leading-gap case handled in reduceJunctions.)
1284  if ( chromOfLocus(hit) > chromOfPos(pos) ) {
1285 #ifdef _REC_DEBUG_
1286  cout<< " ["<<i<<"] @"<<pos<<" -> loc "<< hit <<" SKIPPED (trailing gap on chrm "
1287  << chromOfPos(pos) <<")\n";
1288 #endif
1289  continue;
1290  }
1291  _recPositions[SEX][t].push_back( hit );
1292 
1293 
1294 #ifdef _REC_DEBUG_
1295  cout<< " ["<<i<<"] @"<<pos<<" -> loc "<< hit <<"\n";
1296 #endif
1297 
1298  }// end_for_bRec
1299  }// end_for_traits
1300  } // end_if_nbRec
1301 
1302  // we always add the last position possible, to avoid returning an empty vector
1303  for (unsigned int t = 0; t < _nTrait; t++) {
1304  _recPositions[SEX][t].push_back(_numLociPerTrait[t]);
1305  }
1306 
1307 
1308 }
vector< unsigned int > _junctions
A vector to store the position of the recombination events.
Definition: ttrait_with_map.h:80

References _junctions, _lociLookupTable, _nTrait, _numChromosome, _numLociPerChrsmPerTrait, _numLociPerTrait, _perChrsmLength, and _recPositions.

◆ placeRecombinationEvents() [2/2]

void GeneticMap::placeRecombinationEvents ( sex_t  SEX,
vector< unsigned int >  junctions,
const vector< bool > &  firstRecPos 
)

Deterministic counterpart of recombine(sex_t): instead of drawing the x-over map positions and per-chromosome start sides at random, they are supplied by the caller.

The SAME dedup + per-trait lookup-table mapping + sentinel logic is then applied, so the resulting GeneticMap::_recPositions are identical to what recombine() would have produced for those same draws. Used by tests/tools to reproduce an exact gamete.

Parameters
SEXthe origin of the gamete
junctionscrossover positions in contiguous map coordinates, in 0,_totalLength
firstRecPoswhich parental chromosome copy each chromosome starts with (size must be _numChromosome)
1167 {
1168  //adopt the caller-supplied positions into the reusable member.
1169  _junctions.swap(junctions);
1170 
1171  //sanitise untrusted input: clamp out-of-range positions (the lookup table has
1172  //_totalLength+1 elements, so the largest valid index is _totalLength). The random
1173  //hot path skips this because its draws are in range by construction.
1174  for (unsigned int& n : _junctions) {
1175  if (n > _totalLength) {
1176  warning("GeneticMap::placeRecombinationEvents: junction position %i out of range "
1177  "(map length %i), clamping.\n", n, _totalLength);
1178  n = _totalLength;
1179  }
1180  }
1181 
1182  //run the shared core (same dedup + lookup + sentinel mapping as the random hot path).
1184 
1185  //set the starting copy for each chromosome from the supplied values
1186  _chrsmFirstRecombPosition[SEX].assign(_numChromosome, 0); //re-initialise the array
1187  for(unsigned int c = 0; c < _numChromosome && c < firstRecPos.size(); ++c) {
1188  _chrsmFirstRecombPosition[SEX][c] = firstRecPos[c];
1189  }
1190 }
void placeRecombinationEvents(sex_t SEX, vector< unsigned int > junctions, const vector< bool > &firstRecPos)
Deterministic counterpart of recombine(sex_t): instead of drawing the x-over map positions and per-ch...
Definition: ttrait_with_map.cc:1165

References _chrsmFirstRecombPosition, _junctions, _numChromosome, _totalLength, and warning().

Referenced by recombine().

+ Here is the caller graph for this function:

◆ recombine()

void GeneticMap::recombine ( sex_t  SEX)

Called by TTProtoWithMap::recombine twice to create the two gametes necessary for the creation of a new individual.

This function sets the location of the x-over on the chromosome map and records the loci positions at which x-over happen for each trait separately. The positions are stored in GeneticMap::_recPositions, which are then passed to the trait-specific inheritance functions when setting up the genetics of the traits in new individuals.

Parameters
SEXthe origin of the gamete, whether from the father or the mother
1115 {
1116  unsigned int nbRec = 0;
1117 
1118 
1119 
1120  //create a gamete:
1121 
1122  //draw the number of x-over depending on the total map size
1123  nbRec = (unsigned int)RAND::Poisson( _totRecombEventsMean );
1124 
1125 
1126 #ifdef _REC_DEBUG_
1127  cout << "\n@@@ GeneticMap::recombine( SEX = "<<SEX<<" nbRec = "<<nbRec<<")"<<endl;
1128 #endif
1129 
1130  //adjust
1131  if(nbRec > _totalNumLoci - 1) nbRec = _totalNumLoci - 1;
1132 
1133  if(nbRec > 0) {
1134 
1135  //draw where the x-over will take place (contiguous map positions) into the reusable
1136  //_junctions buffer; resize() keeps the previously allocated capacity, so no per-gamete
1137  //heap allocation happens after warm-up. The draw is in range [0,_totalLength] by
1138  //construction (Uniform() < 1, _recombLength == _totalLength + 1), so no clamp is needed.
1139  _junctions.resize(nbRec);
1140  for (unsigned int& n : _junctions)
1141  n = (unsigned int)(RAND::Uniform() * _recombLength);
1142 
1143  //map the drawn positions to per-trait loci (clears _recPositions, dedup + lookup, sentinel)
1145 
1146  } else {
1147 
1148  //common case (no crossover, the majority of gametes on a short map): just clear and
1149  //append the end sentinel for each trait, skipping the buffer/dedup/lookup machinery and
1150  //the extra function call entirely.
1151  for (unsigned int t = 0; t < _nTrait; t++) {
1152  _recPositions[SEX][t].clear();
1153  _recPositions[SEX][t].push_back(_numLociPerTrait[t]);
1154  }
1155  }
1156 
1157  //draw the starting copy for each chromosome straight into the destination (no temp vector)
1158  _chrsmFirstRecombPosition[SEX].assign(_numChromosome, 0);
1159  for(unsigned int c = 0; c < _numChromosome; ++c)
1161 }
static double Poisson(double mean)
From the Numerical Recieps.
Definition: Uniform.h:229
static double Uniform()
Generates a random number from [0.0, 1.0[ uniformly distributed.
Definition: Uniform.h:125
static bool RandBool()
Returns a random boolean.
Definition: Uniform.h:170

References _chrsmFirstRecombPosition, _junctions, _nTrait, _numChromosome, _numLociPerTrait, _recombLength, _recPositions, _totalNumLoci, _totRecombEventsMean, placeRecombinationEvents(), RAND::Poisson(), RAND::RandBool(), and RAND::Uniform().

Referenced by TTProtoWithMap::recombine().

+ Here is the caller graph for this function:

◆ reduceJunctions()

vector< pair< unsigned int, unsigned int > > GeneticMap::reduceJunctions ( sex_t  SEX,
unsigned int  trait_idx 
)

Remove multiple x-over at the same locus when traits differ in number of loci.

1314 {
1315  unsigned int prevLoc = 0, cEnd = 0;
1316  bool flipper;
1317  //number of x-overs
1318  vector< unsigned int >& recTable = _recPositions[SEX][trait_idx];
1319  unsigned int nbRec = recTable.size();
1320 
1321  vector< pair<unsigned int, unsigned int> > junctions;
1322 
1323  unsigned int num_copied = 0;
1324 
1325 #ifdef _REC_DEBUG_
1326  cout << "GeneticMap::reduceJunctions; trait "<<trait_idx<< "; nb Rec = "<<nbRec - 1<<endl;
1327  cout << " --sex = "<<SEX<<"\n";
1328 #endif
1329 
1330  // c is the chromosome number
1331  // stride is the number of loci considered so-far, sum of chromosome loci
1332  // rec is the number of x-over done so-far
1333  for(unsigned int c = 0, cStart = 0, rec = 0; c < _numChromosome; ++c) {
1334 
1335  //the copy of the chromosome with which with start
1336  flipper = _chrsmFirstRecombPosition[SEX][c];
1337 
1338  //number of loci to consider, including previous chromosomes
1339  cEnd = cStart + _numLociPerChrsmPerTrait[trait_idx][c] ;
1340 
1341  //last locus at which a x-over happened, will be first position on current chromosome
1342  prevLoc = cStart;
1343 
1344  num_copied = 0;
1345 
1346 #ifdef _REC_DEBUG_
1347  cout<<" --chrm "<<c<<", start="<<cStart<<", end="<<cEnd<<" (rec="<<rec<<"; rec pos = "
1348  <<recTable[rec]<<")"<<", side="<<flipper<<endl;
1349 #endif
1350 
1351  // zip forward if x-over on previous chrm were past the last locus on previous chrm
1352  // we need to catch up with position in the current chrm without changing the flipper
1353  while(recTable[rec] == cStart) {rec++; flipper = !flipper;}
1354 
1355  // copy blocs of loci between x-over points on current chromosome
1356  // skip x-over if locus is not on this chromosome but a latter one (junction pos > cEnd)
1357  for(; recTable[rec] < cEnd && rec < nbRec; rec++) {
1358 
1359  //skip recombination events that would lead to copying 0 byte because even num x-over at same locus
1360  if(recTable[rec] == prevLoc){
1361  //but switch side for next bloc to copy on this chromosome
1362  //absolutely necessary to be in sync with other traits on the map
1363  flipper = !flipper;
1364  continue;
1365  }
1366 
1367 
1368 #ifdef _REC_DEBUG_
1369  cout<< " ["<<rec<<"] junction "<<recTable[rec]<< " on side "<<flipper<<std::endl;
1370 #endif
1371 
1372  junctions.push_back(pair<unsigned int, unsigned int>(recTable[rec], flipper));
1373 
1374  num_copied += recTable[rec] - prevLoc;
1375 
1376  //update the starting locus to the next recombination point
1377  prevLoc = recTable[rec];
1378 
1379  //switch side for next bloc to copy on this chromosome
1380  flipper = !flipper;
1381  }
1382 
1383 #ifdef _REC_DEBUG_
1384  cout << " --copy til end of chrmsm from "<<prevLoc<<" to "<<cEnd<<" on side "<<flipper<<endl;
1385 #endif
1386 
1387  num_copied += cEnd - prevLoc;
1388 
1389  junctions.push_back(pair<unsigned int, unsigned int>(cEnd, flipper));
1390 
1391  if(num_copied != _numLociPerChrsmPerTrait[trait_idx][c])
1392  error("number of loci copied on chromosome %i is %i != %i\n", c, num_copied, _numLociPerChrsmPerTrait[trait_idx][c]);
1393 
1394  cStart += _numLociPerChrsmPerTrait[trait_idx][c];
1395  }
1396 
1397  return junctions;
1398 }

References _chrsmFirstRecombPosition, _numChromosome, _numLociPerChrsmPerTrait, _recPositions, and error().

Referenced by TProtoBDMI::inherit_low(), TProtoDeletMutations_bitstring::inherit_low(), TTNeutralGenes_bitstring::inherit_low(), TProtoQuanti::inherit_low(), and TProtoNeutralGenes::inherit_low().

+ Here is the caller graph for this function:

◆ registerIndForRecombine()

bool GeneticMap::registerIndForRecombine ( unsigned long  ID)
inline

Called by TTProtoWithMap::recombine with individual ID passed down from Individual::recombine.

Returns false when already called by the same individual. The function is called for each trait separately but recombination must be computed once per individual only. It is so because some functions create new individual's trait separately, for instance in breed_selection when traits under viability selection are created before neutral traits.

Parameters
IDthe ID number of the individual calling the recombination function
163  {
164  if (ID == _currentIndividual) return false;
165  else _currentIndividual = ID;
166  return true;
167  }

References _currentIndividual.

Referenced by TTProtoWithMap::recombine().

+ Here is the caller graph for this function:

◆ rescaleMap()

void GeneticMap::rescaleMap ( double  val)
954 {
955  assert(val < _resolution);
956 
957  double ratio = _resolution/val; //it is assumed that val < _resolution
958 
959  _resolution = val;
960 
961  //we have to update all positions
962  for (unsigned int i = 0; i < _nTrait; ++i) {
963  for (unsigned int j = 0; j < _numLociPerTrait[i]; ++j) {
964  _locPositionsPerTrait[i][j] *= ratio;
965  }
966  }
967 
968  for (unsigned int i = 0; i < _numChromosome; ++i) {
969  _perChrsmLength[i] *= ratio;
970  _chrsmFirstLocusPosition[i] *= ratio;
971  }
972 
973  _totalLength *= ratio;
974  _totRecombEventsMean = (double)_totalLength * 0.01 * _resolution;
975 
976  //reset all lookup tables, the total length has changed!
977  for (unsigned int i = 0; i < _nTrait; ++i) setLookupTable(i);
978 }

References _chrsmFirstLocusPosition, _locPositionsPerTrait, _nTrait, _numChromosome, _numLociPerTrait, _perChrsmLength, _resolution, _totalLength, _totRecombEventsMean, and setLookupTable().

Referenced by addTrait().

+ Here is the caller graph for this function:

◆ reset_tables()

void GeneticMap::reset_tables ( )
1404 {
1405  if(_perChrsmLength != NULL) delete [] _perChrsmLength;
1406  _perChrsmLength = NULL;
1407 
1408  if(_chrsmFirstLocusPosition != NULL) delete [] _chrsmFirstLocusPosition;
1409  _chrsmFirstLocusPosition = NULL;
1410 
1411  _numChrsmPerTrait.clear();
1412  _numLociPerTrait.clear();
1413 
1414  for (unsigned int i = 0; i < _lociLookupTable.size(); ++i) {
1415  if(_lociLookupTable[i] != NULL) delete [] _lociLookupTable[i];
1416  else error("GeneticMap::reset_tables::found null pointer in _lociLookupTable\n");
1417  }
1418  _lociLookupTable.clear();
1419 
1420  for (unsigned int i = 0; i < _numLociPerChrsmPerTrait.size(); ++i) {
1421  if(_numLociPerChrsmPerTrait[i] != NULL) delete [] _numLociPerChrsmPerTrait[i];
1422  else error("GeneticMap::reset_tables::found null pointer in _numLociPerChrsmPerTrait\n");
1423  }
1424  _numLociPerChrsmPerTrait.clear();
1425 
1426  for (unsigned int i = 0; i < _locPositionsPerTrait.size(); ++i) {
1427  if(_locPositionsPerTrait[i] != NULL) delete [] _locPositionsPerTrait[i];
1428  else error("GeneticMap::reset_tables::found null pointer in _locPositionsPerTrait\n");
1429  }
1430  _locPositionsPerTrait.clear();
1431 
1432  _recPositions[0].clear();
1433  _recPositions[1].clear();
1434 
1435  _chrsmFirstRecombPosition[0].clear();
1436  _chrsmFirstRecombPosition[1].clear();
1437 
1438 }

References _chrsmFirstLocusPosition, _chrsmFirstRecombPosition, _lociLookupTable, _locPositionsPerTrait, _numChrsmPerTrait, _numLociPerChrsmPerTrait, _numLociPerTrait, _perChrsmLength, _recPositions, and error().

Referenced by addTrait(), clear(), and ~GeneticMap().

+ Here is the caller graph for this function:

◆ setLookupTable()

void GeneticMap::setLookupTable ( unsigned int  idx)

Bbuilds the lookup table for each trait.

A lookup table maps a chromosomal position to a locus so that when a x-over is placed at a given map position, the corresponding locus can be directly found. The size of the lookup table depends on the _totalLength and _resolution of the map. The lookup table for a 1M map at the 0.01 cM scale will have 10,000 elements.

Parameters
idxthe index of the trait in the table (stored in the trait prototype)

!!! +1 needed here because map must start with 0 !!!!

983 {
984  if(_lociLookupTable[idx] != NULL) delete [] _lociLookupTable[idx];
985 
986  _lociLookupTable[idx] = new unsigned int [_totalLength +1];
988 
989  if(_lociLookupTable[idx] == NULL)
990  fatal("GeneticMap::set lookup table: memory exhausted?\n");
991 
992  //------------------------------------------------------------------------
993  int pre_offset = 0, post_offset = 0, offset;
994 
995 // cout<<"\n-- Genetic map #"<<idx<<":"<<endl;
996 
997  for (unsigned int loc = 0, pos = 0, stride = 0,
998  c = 0; c < _numChromosome; ++c) {
999 
1000 // cout<<"Chrm "<<c+1<<" ("<<_perChrsmLength[c]<<" ["<<_resolution<<"cM]):\n"<<"{ ";
1001 
1002  loc = stride;
1003 
1004  stride += _numLociPerChrsmPerTrait[idx][c];
1005 
1006  //the map must start with position zero for the first locus with lowest position
1007  pre_offset = -_chrsmFirstLocusPosition[c];
1008 
1009  //chromosomes are contiguous
1010  offset = pre_offset + post_offset;
1011 
1012  for(; loc < stride && loc < _numLociPerTrait[idx]; ++loc)
1013  {
1014 
1015  while (pos <= ( _locPositionsPerTrait[idx][loc] + offset) &&
1016  ((int)pos - post_offset) <= (int)_perChrsmLength[c])
1017  //table has 1 more elmnt, hence "<="
1018 
1019  _lociLookupTable[idx][pos++] = loc;
1020 
1021 // cout << loc<<":"<<pos-1<<"("<<(int)pos - post_offset<<"; tab["<<pos-1<<"]="<<_lociLookupTable[idx][pos-1]<<") ";
1022 
1023  }
1024 
1025  post_offset += _perChrsmLength[c];
1026 
1027  // need to pad to the right when we reached last locus on a chromosome but not at the last map position of that chrm
1028  // this must apply only to all chrm but the last, hence loc < max num loci
1029  while( pos < post_offset && loc == stride && loc < _numLociPerTrait[idx])
1030  {
1031  _lociLookupTable[idx][pos++] = loc;
1032 // cout << loc<<":"<<pos-1<<"(tab["<<pos-1<<"]="<<_lociLookupTable[idx][pos-1]<<") ";
1033 
1034  }
1035 
1036  // we need to pad to the right when position of last locus is within last chromosome (chrom length set by other traits too)
1037  // pad with last locus number+1 (tot num loci) on that chromosome
1038  while (pos < _totalLength+1 && loc >= _numLociPerTrait[idx])
1039  {
1040 
1041  _lociLookupTable[idx][pos++] = _numLociPerTrait[idx];
1042 
1043 // cout << loc<<":"<<pos-1<<"(tab["<<pos-1<<"]="<<_lociLookupTable[idx][pos-1]<<") ";
1044 
1045  }
1046 // cout << "}\n";
1047  }
1048 
1049 
1050 #ifdef _DEBUG_
1051 // map< trait_t, unsigned int>::iterator ITER = _traits.begin() + idx;
1052 
1053  cout << "\nGeneticMap::setLookupTable ("<<idx<<")\n";
1054 
1055  cout << "lookup table: [";
1056  for(unsigned int i = 0; i < _totalLength+1 && i < 101; ++i) {
1057  cout << _lociLookupTable[idx][i] << " ";
1058  if( i == 100) cout << "|>100) ";
1059  }
1060  if(_totalLength >= 100) cout << "... last pos ("<<_totalLength<<") "<<_lociLookupTable[idx][_totalLength];
1061  cout << "] (truncated if > 100 positions)\n";
1062 
1063  pre_offset = 0; post_offset = 0;
1064  for(unsigned int c = 0, stride = 0; c < _numChromosome; c++) {
1065 
1066  cout <<"+++Chrm "<<c+1<<" num loci: "<<_numLociPerChrsmPerTrait[idx][c]
1067  <<" ("<<_perChrsmLength[c]<<" ["<<_resolution<<"*cM]):\n";
1068  cout << "Loc positions: [ ";
1069 
1070  for(unsigned int i = 0; i < _numLociPerChrsmPerTrait[idx][c] && i < 101; ++i){
1071  if( i < 100 || !(i % 100) )
1072  cout << _locPositionsPerTrait[idx][i+stride] << " " ;
1073  if( i == 100) cout << "|>100) ";
1074  }
1075  cout << "]\n";
1076 
1077  pre_offset = -_chrsmFirstLocusPosition[c];
1078  offset = pre_offset + post_offset;
1079 
1080  cout << "lookup table: (from first pos:"<<_chrsmFirstLocusPosition[c]+offset<<") [ ";
1081 
1082  for(unsigned int cnt=0, i = _chrsmFirstLocusPosition[c]+offset;
1083  i < _chrsmFirstLocusPosition[c]+_perChrsmLength[c]+offset && cnt < 100;
1084  ++i, ++cnt){
1085  cout << _lociLookupTable[idx][i] << " " ;
1086  }
1087  cout << "] (first 100 positions only)\nlookup table: {position:locus} (first 100 + 100th) (offset = "<<offset<<", stride = "<<stride<<")\n {";
1088 
1089  for(unsigned int i = 0; i < _numLociPerChrsmPerTrait[idx][c]; ++i) {
1090  if( i < 100 || !(i % 100) )
1091  cout<<_locPositionsPerTrait[idx][i+stride]+offset<<":"<<_lociLookupTable[idx][_locPositionsPerTrait[idx][i+stride]+offset]<<", ";
1092  if( i == 100) cout << "|>100) ";
1093  }
1094  // last locus
1095  cout<<_locPositionsPerTrait[idx][stride + _numLociPerChrsmPerTrait[idx][c]-1]+offset
1096  <<":"<<_lociLookupTable[idx][_locPositionsPerTrait[idx][stride + _numLociPerChrsmPerTrait[idx][c]-1]+offset]<<"}\n";
1097 
1098  post_offset += _perChrsmLength[c];
1099  stride += _numLociPerChrsmPerTrait[idx][c];
1100  }
1101  cout<<endl;
1102 // cout<<"Loc pos lookup table:"<<endl<<"{";
1103 // for(unsigned int i = 0; i < _superChrsmLength; ++i)
1104 // cout<<_recLociPositionTable[i]<<", ";
1105 // cout<<"}"<<endl;
1106 
1107  cout<<" Tot map length: "<<_totalLength<<endl;
1108  cout<<" Mean num recombination events: "<<_totRecombEventsMean<<endl;
1109 #endif
1110 }

References _chrsmFirstLocusPosition, _lociLookupTable, _locPositionsPerTrait, _numChromosome, _numLociPerChrsmPerTrait, _numLociPerTrait, _perChrsmLength, _resolution, _totalLength, _totRecombEventsMean, and fatal().

Referenced by addTrait(), and rescaleMap().

+ Here is the caller graph for this function:

◆ setResolution()

double GeneticMap::setResolution ( double  val)
inline
107  {
108  _resolution = (val < _resolution ? val : _resolution);
109  return _resolution;
110  }

References _resolution.

◆ unregisterTrait()

void GeneticMap::unregisterTrait ( trait_t  trait)
649 {
650  map<trait_t, unsigned int>::iterator tIter;
651 
652  tIter = _traits.find(trait);
653 
654  if ( tIter != _traits.end() ) {
655 
656 // cout<<"GeneticMap::unregisterTrait::"<<tIter->first<<" (idx: "<<tIter->second<<")"<<endl;
657 
658  _traits.erase(tIter);
659 
660  //@TODO trait lookup tables must be erased as well
661 
662 // cout<<"GeneticMap::unregisterTrait::done\n";
663  }
664  else fatal("Genetic map::unregisterTrait: trait \"%s\" is not registered\n", trait.c_str());
665 
666  _nTrait--;
667 }

References _nTrait, _traits, and fatal().

Referenced by TTProtoWithMap::reset(), and TTProtoWithMap::unregisterFromGeneticMap().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _chrsmFirstLocusPosition

unsigned int* GeneticMap::_chrsmFirstLocusPosition
private

◆ _chrsmFirstRecombPosition

vector< bool > GeneticMap::_chrsmFirstRecombPosition[2]
private

Two vectors holding the starting copy of each chromosome to use when creating the two gametes that are used to create a new individual.

Referenced by getFirstRecPosition(), placeRecombinationEvents(), recombine(), reduceJunctions(), and reset_tables().

◆ _currentIndividual

unsigned long GeneticMap::_currentIndividual
private

Referenced by registerIndForRecombine().

◆ _junctions

vector< unsigned int > GeneticMap::_junctions
private

A vector to store the position of the recombination events.

Referenced by placeRecombinationEvents(), and recombine().

◆ _lociLookupTable

vector< unsigned int* > GeneticMap::_lociLookupTable
private

A list of tables that map the map position (cM) to a locus, for each trait.

The length of the table is the length of the genetic map, which depends on the map resolution (cM by default).

Referenced by addTrait(), placeRecombinationEvents(), reset_tables(), and setLookupTable().

◆ _locPositionsPerTrait

vector< unsigned int* > GeneticMap::_locPositionsPerTrait
private

Vector containing the table of map position for the loci of each trait.

Positions are recorded according to the minimum map resolution as used in the lookup table.

Referenced by addTrait(), getGeneticMap(), getLocusPositionTable(), rescaleMap(), reset_tables(), and setLookupTable().

◆ _nTrait

unsigned int GeneticMap::_nTrait
private

Number of traits registered in the map.

Length of following arrays.

Referenced by addTrait(), clear(), placeRecombinationEvents(), recombine(), rescaleMap(), and unregisterTrait().

◆ _numChromosome

unsigned int GeneticMap::_numChromosome
private

◆ _numChrsmPerTrait

vector< unsigned int > GeneticMap::_numChrsmPerTrait
private

Vector of number of chromosomes for each trait.

Referenced by addTrait(), and reset_tables().

◆ _numLociPerChrsmPerTrait

vector< unsigned int* > GeneticMap::_numLociPerChrsmPerTrait
private

Vector containing a table of number of loci per chromosome for each trait.

Referenced by addTrait(), getGeneticMap(), placeRecombinationEvents(), reduceJunctions(), reset_tables(), and setLookupTable().

◆ _numLociPerTrait

vector< unsigned int > GeneticMap::_numLociPerTrait
private

Vector of number of loci for each trait.

Referenced by addTrait(), getGeneticMap(), placeRecombinationEvents(), recombine(), rescaleMap(), reset_tables(), and setLookupTable().

◆ _perChrsmLength

unsigned int* GeneticMap::_perChrsmLength
private

◆ _recombinationRate

double GeneticMap::_recombinationRate
private

Referenced by addTrait().

◆ _recombLength

unsigned int GeneticMap::_recombLength
private

Referenced by addTrait(), and recombine().

◆ _recPositions

vector< vector < unsigned int > > GeneticMap::_recPositions[2]
private

Vector of tables containing, for each trait, the locus number at which x-overs happen.

Updated at each generation. There is matrix per sex/gamete with one trait per row and a variable number of elements in each row.

Referenced by addTrait(), getRecLoci(), placeRecombinationEvents(), recombine(), reduceJunctions(), and reset_tables().

◆ _resolution

double GeneticMap::_resolution
private

◆ _totalLength

unsigned int GeneticMap::_totalLength
private

◆ _totalNumLoci

unsigned int GeneticMap::_totalNumLoci
private

Referenced by addTrait(), and recombine().

◆ _totRecombEventsMean

double GeneticMap::_totRecombEventsMean
private

◆ _traits

map< trait_t, unsigned int > GeneticMap::_traits
private

Table mapping trait type to its position index in the following tables.

Referenced by addTrait(), checkRegisteredTrait(), clear(), getGeneticMap(), getLocusPositionTable(), and unregisterTrait().


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