/// <summary> /// Set coords based on gene symbol & current target map /// </summary> /// <param name="rr"></param> void SetCoordinates(UnpivotedAssayResult rr) { UnpivotedAssayResult rr2; int tci; if (TargetMap == null || !TargetMap.Coords.ContainsKey(rr.GeneId)) { return; } //if (rr.TargetSymbol != "CHRM5") rr = rr; // debug List <TargetMapCoords> coordList = TargetMap.Coords[rr.GeneId]; for (tci = 0; tci < coordList.Count; tci++) { if (tci == 0) { rr2 = rr; } else { rr2 = rr.CloneUnpivotedAssayResult(); } TargetMapCoords tmc = coordList[tci]; rr2.TargetMapX = tmc.X; rr2.TargetMapY = -tmc.Y; // use negative value for y if (tci > 0) { BufferedRows.Add(rr2); // add to buffer } } }
/// <summary> /// Get a map by name with coordinates /// </summary> /// <param name="name"></param> /// <returns></returns> public static TargetMap GetMapWithCoords( string name) { if (TargetMapDict == null) { ReadTargetMapDict(); } string key = name.ToUpper(); if (!TargetMapDict.ContainsKey(key)) { throw new Exception("Target map doesn't exist: " + name); } TargetMap tm = TargetMapDict[key]; if (tm.Coords != null) { return(tm); // have coords? } tm.Coords = new Dictionary <int, List <TargetMapCoords> >(); StreamReader sr = new StreamReader(TargetMapDir + @"\" + tm.CoordsFile); while (true) { string rec = sr.ReadLine(); try { if (rec == null) { break; } if (rec.Trim().StartsWith(";")) { continue; } if (rec.Trim() == "") { continue; } string[] sa = rec.Split('\t'); int targetId = int.Parse(sa[0]); if (!tm.Coords.ContainsKey(targetId)) { tm.Coords[targetId] = new List <TargetMapCoords>(); } List <TargetMapCoords> tml = tm.Coords[targetId]; TargetMapCoords tmc = new TargetMapCoords(); tml.Add(tmc); tmc.TargetId = targetId; tmc.X = int.Parse(sa[1]); tmc.Y = int.Parse(sa[2]); if (sa.Length > 3 && !String.IsNullOrEmpty(sa[3])) { tmc.X2 = int.Parse(sa[3]); } if (sa.Length > 4 && !String.IsNullOrEmpty(sa[4])) { tmc.Y2 = int.Parse(sa[4]); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } } sr.Close(); return(tm); }