public void DefineChromosomePositions(double dBetweenMarkers = 0.5, long numberOfLocii = 11) { List <int> numberOfLoci = null; //go over all chromosome and define the position according to each marker dBetweenMarkers=0.5 . ex: 0 , 0.5, 1.5 ... //each chromosome begin at 0 cm the position of loci if (OrganismType.Random == this.type) { numberOfLoci = new List <int>(); foreach (Dictionary <int, string> dic in rawGeneticData) { numberOfLoci.Add(Convert.ToInt32(dic[2])); } } int idLocus = 0; for (int iChr = 0; iChr < nChr; iChr++) { if (OrganismType.Random == this.type) { numberOfLocii = numberOfLoci[iChr]; } double posPrev = -0.5; for (int jOnChr = 0; jOnChr < numberOfLocii; jOnChr++) { if (posPrev < go.Chromosome[iChr].LenGenetcM) { Position pos = new Position(); pos.Chromosome = go.Chromosome[iChr]; pos.PositionChrGenetic = posPrev; pos.PositionChrGenetic += dBetweenMarkers; posPrev = pos.PositionChrGenetic; Locus locus = new Locus(jOnChr, pos); idLocus++; locus.Id = idLocus; go.Chromosome[iChr].Locus.Add(locus); } } } }
/// <summary> /// Create the genetic organism object via teh input data /// </summary> /// <param name="data"></param> private void buildGenomeOrganizm(List <Dictionary <int, string> > data) { var db = DatabaseProvider.GetDatabase(); db.GenomeOrganization = new GenomeOrganization(); db.GenomeOrganization.Chromosome = new List <Chromosome>(); int markerId = 0; var chrDic = new Dictionary <int, List <Locus> >(); foreach (Dictionary <int, string> row in data) { //get the chr number string chrNum = row[1].Substring(2); int chrNumber = Convert.ToInt32(chrNum); //get the position of the marker double genPosition = Convert.ToDouble(row[2]); //set the position Position p = new Position(); p.PositionChrGenetic = genPosition; if (chrDic.ContainsKey(chrNumber)) { //This is case we have the chromosome List <Locus> markerList; chrDic.TryGetValue(chrNumber, out markerList); //same chromosome - as the first one from the list p.Chromosome = markerList[0].Position.Chromosome; Locus l = new Locus(markerId, p); l.FullName = row[0]; markerList.Add(l); markerId++; //add to the current chr } else { List <Locus> markerList = new List <Locus>(); chrDic.Add(chrNumber, markerList); p.Chromosome = new Chromosome(); p.Chromosome.Name = chrNumber.ToString(); Locus l = new Locus(markerId, p); l.FullName = row[0]; markerList.Add(l); //add new chromosome markerId++; } } foreach (KeyValuePair <int, List <Locus> > entry in chrDic) { Chromosome ch = new Chromosome(); ch.Id = entry.Key; ch.Locus = entry.Value; var maxChrLen = ch.Locus.Max(x => x.Position.PositionChrGenetic); ch.LenGenetcM = maxChrLen; db.GenomeOrganization.addChr(ch); } }
/// <summary> /// This is method defines the location of the loci on the chromosome /// </summary> /// <param name="dBetweenMarkers_set"></param> /// <param name="nMarkersGrouped"></param> /// <param name="dMarkersGrouped"></param> /// <param name="indexAnimal"></param> public void DefineChromosomePositions(double dBetweenMarkers_set, long nMarkersGrouped, double dMarkersGrouped, int indexAnimal) { int index = 1; double coorPrev = 0.0, d, coorStartOnCurrentChr = 0.0, dBetweenMarkers = 2.0; long j, nMarkersMax, nOnChr = 11; if (dBetweenMarkers_set > 0) { //distance between markers dBetweenMarkers = dBetweenMarkers_set; } if (index == 0) { //amount of markers nMarkersMax = nChr * nOnChr; } else { //amount of markers nMarkersMax = nChr * (int)(500 / dBetweenMarkers); } for (int i = 0; i < nChr; i++) { if (index == 0) { d = go.Chromosome[i].LenGenetcM / (nOnChr - 1); } else { d = dBetweenMarkers; nOnChr = (int)(go.Chromosome[i].LenGenetcM / d) + 1; } //Line 195 is this correct if (go.Chromosome[i].Id > 1) { coorPrev = coorPrev + 1000 - d; } else { coorPrev = -d; } for (j = 0; j < nOnChr; j++) { Locus loci = new Locus(); //default location loci.Position.Chromosome = go.Chromosome[i]; loci.Position.PositionChrGenetic = coorPrev + d; if (j > 1 && j <= dMarkersGrouped) { loci.Position.PositionChrGenetic = coorPrev + dMarkersGrouped; } if (j == 1) { coorStartOnCurrentChr = loci.Position.PositionChrGenetic; } if (j == nOnChr) { loci.Position.PositionChrGenetic = coorStartOnCurrentChr + go.Chromosome[i].LenGenetcM; } //Line 215 not clear // go.Chromosome[i]loci.Position.PositionChrGenetic - coorStartOnCurrentChr; loci.Name = "loc_" + j; loci.Id = i; coorPrev = loci.Position.PositionChrGenetic; go.Chromosome[i].Locus.Add(loci); } } }