/// <summary> /// Draws the graph to the form /// </summary> /// <param name="o"></param> /// <param name="e"></param> public void PaintGraph(object o, PaintEventArgs e) { Graphics g = e.Graphics; // Create a new graph with topLeft at (40,40) and size 600x400 myPane = new ZedGraph.GraphPane(new Rectangle(this.Location.X, this.Location.Y + 210, 450, 325), "Allele Frequency\n", "Generations", "Frequency of A"); myPane.XAxis.Max = 100; //this.generation.Value; myPane.XAxis.Min = 0; myPane.YAxis.Max = 1; myPane.YAxis.Min = 0; ZedGraph.LineItem myCurve = myPane.AddCurve("1", list1, Color.Red, ZedGraph.SymbolType.None); ZedGraph.LineItem myCurve2 = myPane.AddCurve("2", list2, Color.Blue, ZedGraph.SymbolType.None); ZedGraph.LineItem myCurve3 = myPane.AddCurve("3", list3, Color.LimeGreen, ZedGraph.SymbolType.None); ZedGraph.LineItem myCurve4 = myPane.AddCurve("4", list4, Color.Black, ZedGraph.SymbolType.None); myPane.AxisChange(this.CreateGraphics()); myPane.Draw(e.Graphics); }
void updateGraph(Item useritem) { var sitems = mvv.Glassmodels.Where(o => o.Name.ToLower().StartsWith(useritem.Name.ToLower())); sitems.ForEach(o => { o.MBE = (useritem.Ottv - o.Ottv) / useritem.Ottv; }); mvv.ImgSource = null; var ch = new ZedGraph.GraphPane(); // zedGraphControl1.GraphPane; ch.Title.Text = $"OTTV Analysis"; ch.XAxis.Title.Text = "Glass Types Proposal"; ch.YAxis.Title.Text = "MBE impact"; ch.Y2Axis.IsVisible = false; ch.X2Axis.IsVisible = false; ch.XAxis.Scale.MinAuto = false; ch.XAxis.Scale.Max = sitems.Count() + 1; ch.XAxis.Scale.MajorStepAuto = false; ch.XAxis.Scale.MajorStep = 1; ch.XAxis.Scale.Min = 0; ch.XAxis.Scale.MinorStepAuto = false; ch.XAxis.Scale.MinorStep = 0.1; ch.XAxis.MinorTic.Size = 0; ch.XAxis.MajorTic.Size = 0; ch.YAxis.Scale.Format = "00.00"; ch.YAxis.MinorTic.Size = 0; ch.YAxis.MajorGrid.Color = System.Drawing.Color.DimGray; ch.YAxis.MajorGrid.PenWidth = 1; ch.YAxis.MajorGrid.DashOn = 6; ch.YAxis.MajorGrid.IsVisible = true; var bar = ch.AddCurve("MBE Value", null, sitems.Select(o => o.MBE).Cast <double>().ToArray(), System.Drawing.Color.DarkBlue); //bar.c.Fill.Type = ZedGraph.FillType.Solid; bar.Line.Width = 5f; bar.Line.IsSmooth = false; ch.XAxis.Scale.TextLabels = sitems.Select(o => o.Name).ToArray(); ch.XAxis.Type = ZedGraph.AxisType.Text; ch.XAxis.Scale.FontSpec.Angle = 90; ch.AxisChange(); mvv.ImgSource = Utility.IO.ImageIO.ConvertFromImage(ch.GetImage((int)Width, (int)Height, 150, true)); }
private void zedGraphControl1_ZoomEvent(ZedGraph.ZedGraphControl sender, ZedGraph.ZoomState oldState, ZedGraph.ZoomState newState) { ZedGraph.GraphPane pane = zedGraphControl1.GraphPane; int bins = (int)pane.CalcChartRect(zedGraphControl1.CreateGraphics()).Width; foreach (ZedGraph.CurveItem curve in pane.CurveList) { (curve.Points as SeemsPointList).SetScale(bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max); } pane.AxisChange(); SetDataLabelsVisible(true); Refresh(); }
private void BuildSubPerVerGraph() { ZedGraph.ZedGraphControl zg1 = new ZedGraph.ZedGraphControl(); zg1.Dock = DockStyle.Fill; zg1.IsEnableZoom = false; zg1.IsShowPointValues = false; ZedGraph.GraphPane pane = zg1.GraphPane; pane.Fill = new ZedGraph.Fill(Color.Azure, Color.FromArgb(230, 220, 250), 90); pane.Chart.Fill = new ZedGraph.Fill(Color.FromArgb(225, 220, 245), Color.LightCyan, -90); pane.Title.Text = "Submission per Verdict"; pane.Title.FontSpec.Size = 18; pane.Title.FontSpec.FontColor = Color.Maroon; pane.Title.FontSpec.Family = "Segoe UI Semibold"; pane.Title.FontSpec.IsBold = false; pane.Legend.IsVisible = false; double[] yval = new double[] { _acCount, _waCount, _tleCount, _reCount, _peCount, _ceCount, _oleCount, _subeCount, _mleCount }; string[] labels = new string[] { "AC", "WA", "TLE", "RE", "PE", "CE", "OLE", "SUBE", "MLE" }; for (int i = 0; i < yval.Length; ++i) { labels[i] += string.Format("\n({0})", yval[i].ToString()); } pane.XAxis.Title.Text = "Verdicts"; pane.XAxis.Title.FontSpec.Family = "Courier New"; pane.XAxis.Title.FontSpec.FontColor = Color.Maroon; pane.XAxis.Title.FontSpec.IsBold = false; pane.XAxis.Scale.TextLabels = labels; pane.XAxis.Type = ZedGraph.AxisType.Text; pane.YAxis.Title.Text = "Submissions"; pane.YAxis.Title.FontSpec.Family = "Courier New"; pane.YAxis.Title.FontSpec.FontColor = Color.Navy; pane.YAxis.Title.FontSpec.IsBold = false; // Generate a bar chart ZedGraph.BarItem bar = pane.AddBar("Verdicts", null, yval, Color.DarkTurquoise); bar.Label.IsVisible = true; pane.AxisChange(); this.subPerVerTab.Controls.Clear(); this.subPerVerTab.Controls.Add(zg1); }
private void SaveFromConsoleApplication() { // simulate plotting from a console application var pane = new ZedGraph.GraphPane(); var curve1 = pane.AddCurve( label: "demo", x: new double[] { 1, 2, 3, 4, 5 }, y: new double[] { 1, 4, 9, 16, 25 }, color: Color.Blue); curve1.Line.IsAntiAlias = true; pane.AxisChange(); Bitmap bmp = pane.GetImage(400, 300, dpi: 100, isAntiAlias: true); bmp.Save("zedgraph-console-quickstart.png", ImageFormat.Png); }
private void BuildSubPerLangGraph() { ZedGraph.ZedGraphControl zg1 = new ZedGraph.ZedGraphControl(); zg1.Dock = DockStyle.Fill; zg1.IsEnableZoom = false; zg1.IsShowPointValues = false; ZedGraph.GraphPane pane = zg1.GraphPane; pane.Fill = new ZedGraph.Fill(Color.Azure, Color.FromArgb(245, 220, 250), 90); pane.Chart.Fill = new ZedGraph.Fill(Color.Snow, Color.FromArgb(225, 240, 250), -90); pane.Title.Text = "Submission per Language"; pane.Title.FontSpec.Size = 18; pane.Title.FontSpec.FontColor = Color.Navy; pane.Title.FontSpec.Family = "Segoe UI Semibold"; pane.Title.FontSpec.IsBold = false; pane.Legend.FontSpec.Size = 12; pane.Legend.IsShowLegendSymbols = true; pane.Legend.Position = ZedGraph.LegendPos.TopCenter; double[] value = { _subInCPP, _subInJava, _subInAnsiC, _subInCPP11, _subInPascal }; string[] label = { "C++", "Java", "ANSI C", "C++11", "Pascal" }; Color[] color1 = { Color.Lime, Color.Blue, Color.Red, Color.Green, Color.Yellow }; Color[] color2 = { Color.DarkOrange, Color.DarkBlue, Color.DarkRed, Color.DarkGreen, Color.YellowGreen }; for (int i = 0; i < value.Length; ++i) { ZedGraph.PieItem pie = pane.AddPieSlice(value[i], color2[i], color1[i], 0, 0.04, label[i]); pie.LabelType = ZedGraph.PieLabelType.Name_Value; pie.LabelDetail.FontSpec.Border.IsVisible = false; pie.LabelDetail.FontSpec.Family = "Segoe UI Semibold"; pie.LabelDetail.FontSpec.Size = 12; pie.LabelDetail.FontSpec.IsAntiAlias = false; pie.IsSelectable = true; } pane.AxisChange(); this.subPerLanTab.Controls.Clear(); this.subPerLanTab.Controls.Add(zg1); }
private void BuildSubPerDateGraph() { ZedGraph.ZedGraphControl zg1 = new ZedGraph.ZedGraphControl(); zg1.Dock = DockStyle.Fill; zg1.IsShowPointValues = true; ZedGraph.GraphPane pane = zg1.GraphPane; pane.Fill = new ZedGraph.Fill(Color.MintCream, Color.FromArgb(245, 250, 210), -90); pane.Chart.Fill = new ZedGraph.Fill(Color.Snow, Color.FromArgb(245, 250, 230), 90); pane.Title.Text = "Submission and Accepted over Time"; pane.Title.FontSpec.Size = 18; pane.Title.FontSpec.FontColor = Color.Navy; pane.Title.FontSpec.Family = "Segoe UI Semibold"; pane.Title.FontSpec.IsBold = false; pane.Legend.FontSpec.Size = 12; pane.Legend.Position = ZedGraph.LegendPos.TopCenter; pane.XAxis.Title.Text = "Date-Time"; pane.XAxis.Title.FontSpec.Family = "Courier New"; pane.XAxis.Title.FontSpec.FontColor = Color.Maroon; pane.XAxis.Title.FontSpec.IsBold = false; pane.XAxis.Type = ZedGraph.AxisType.Date; pane.YAxis.Title.Text = "Submissions"; pane.YAxis.Title.FontSpec.Family = "Courier New"; pane.YAxis.Title.FontSpec.FontColor = Color.Navy; pane.YAxis.Title.FontSpec.IsBold = false; // Generate a red curve var a = pane.AddCurve("Submissions / Time", _subOverTime, Color.DarkGoldenrod, ZedGraph.SymbolType.VDash); var b = pane.AddCurve("Accepted / Time", _acOverTime, Color.Navy, ZedGraph.SymbolType.VDash); a.Symbol.Size = 2; b.Symbol.Size = 2; pane.AxisChange(); this.subPerDateTab.Controls.Clear(); this.subPerDateTab.Controls.Add(zg1); }
private void BuildRankCloud() { ZedGraph.ZedGraphControl zg1 = new ZedGraph.ZedGraphControl(); zg1.Dock = DockStyle.Fill; zg1.IsShowPointValues = true; ZedGraph.GraphPane pane = zg1.GraphPane; pane.Fill = new ZedGraph.Fill(Color.Azure, Color.FromArgb(230, 220, 250), 90); pane.Chart.Fill = new ZedGraph.Fill(Color.FromArgb(225, 220, 245), Color.LightCyan, -90); pane.Title.Text = "Rank Cloud"; pane.Title.FontSpec.Size = 18; pane.Title.FontSpec.FontColor = Color.Maroon; pane.Title.FontSpec.Family = "Segoe UI Semibold"; pane.Title.FontSpec.IsBold = false; pane.Legend.IsVisible = false; pane.XAxis.Title.Text = "Ranks"; pane.XAxis.Title.FontSpec.Family = "Courier New"; pane.XAxis.Title.FontSpec.FontColor = Color.Maroon; pane.XAxis.Title.FontSpec.IsBold = false; pane.YAxis.Title.Text = "Problems"; pane.YAxis.Title.FontSpec.Family = "Courier New"; pane.YAxis.Title.FontSpec.FontColor = Color.Navy; pane.YAxis.Title.FontSpec.IsBold = false; pane.YAxis.Type = ZedGraph.AxisType.Linear; ZedGraph.LineItem curve = pane.AddCurve("Ranks", _RankCount, Color.Black, ZedGraph.SymbolType.Circle); curve.Symbol.Fill = new ZedGraph.Fill(Color.LightCyan, Color.DarkTurquoise); curve.Symbol.Border.IsVisible = true; curve.Symbol.Size = 5; curve.Line.IsVisible = false; pane.AxisChange(); this.rankCloudTab.Controls.Clear(); this.rankCloudTab.Controls.Add(zg1); }
private void showData(int dataIndex, bool isOverlay) { SeemsScan scan = dataSource.CurrentScanHeaders[dataIndex]; ZedGraph.GraphPane pane = zedGraphControl1.GraphPane; if (isOverlay && pane.CurveList.Count > overlayColors.Length) { MessageBox.Show("SeeMS only supports up to " + overlayColors.Length + " simultaneous overlays.", "Too many overlays", MessageBoxButtons.OK, MessageBoxIcon.Stop); } // set form title if (!isOverlay) { Text = String.Format("{0} - {1}", System.IO.Path.GetFileName(dataSource.CurrentFilepath), scan.Id); } else { Text += "," + scan.Id; } if (!isOverlay) { pane.CurveList.Clear(); } if (shownScan != null && scan.IsMassSpectrum != shownScan.IsMassSpectrum) { zedGraphControl1.RestoreScale(pane); zedGraphControl1.ZoomOutAll(pane); } bool isScaleAuto = !pane.IsZoomed; //pane.GraphObjList.Clear(); SeemsPointList pointList = scan.PointList; if (pointList.FullCount == 0) { // the header does not have the data points, assume it is a mass spectrum pane.YAxis.Title.Text = "Intensity"; pane.XAxis.Title.Text = "m/z"; bool doCentroid = SeemsMdiParent.CentroidMenuItem.Enabled && SeemsMdiParent.CentroidMenuItem.Checked; dataSource.InstrumentInterface.setCentroiding(doCentroid, doCentroid, SeemsMdiParent.UseVendorCentroidMenuItem.Checked); SeemsScan scanWithData = new SeemsScan(dataSource.InstrumentInterface.getScan(scan.Scan.ScanNumber)); pointList = scanWithData.PointList; int bins = (int)pane.CalcChartRect(zedGraphControl1.CreateGraphics()).Width; if (isScaleAuto) { pointList.SetScale(bins, pointList[0].X, pointList[pointList.Count - 1].X); } else { pointList.SetScale(bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max); } if (doCentroid || scanWithData.Scan.IsCentroided) { ZedGraph.StickItem stick = pane.AddStick(scan.Id, pointList, Color.Gray); stick.Symbol.IsVisible = false; stick.Line.Width = 1; } else { pane.AddCurve(scan.Id, pointList, Color.Gray, ZedGraph.SymbolType.None); } } else { // the header has the data points, assume it is a chromatogram int bins = (int)pane.CalcChartRect(zedGraphControl1.CreateGraphics()).Width; if (isScaleAuto) { pointList.SetScale(bins, pointList[0].X, pointList[pointList.Count - 1].X); } else { pointList.SetScale(bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max); } pane.YAxis.Title.Text = "Total Intensity"; pane.XAxis.Title.Text = "Retention Time (in seconds)"; pane.AddCurve(scan.Id, pointList, Color.Gray, ZedGraph.SymbolType.None); } pane.AxisChange(); if (isOverlay) { pane.Legend.IsVisible = true; pane.Legend.Position = ZedGraph.LegendPos.TopCenter; for (int i = 0; i < pane.CurveList.Count; ++i) { pane.CurveList[i].Color = overlayColors[i]; } } else { pane.Legend.IsVisible = false; } SetDataLabelsVisible(true); shownScan = scan; zedGraphControl1.Refresh(); //zedGraphControl1.Focus(); }
public static Image GetAnnotatedImage(string argPeptide, MSScan argScan, List<MSPoint> argPeaks, GlycanStructure argStructure) { float MaxX = argStructure.Root.FetchAllGlycanNode().OrderByDescending(o => o.IDMass).ToList()[0].IDMass; if (MaxX + 100 > 2000.0) { MaxX = 2000.0f; } else { MaxX = MaxX + 100; } ZedGraph.GraphPane Pane = new ZedGraph.GraphPane(new RectangleF(0.0f, 0.0f, 2000.0f, 1500.0f), argScan.ScanNo.ToString(), "Mass", "Intensity"); //ZedGraph.MasterPane Pane = new ZedGraph.MasterPane(argTitle,new RectangleF(0.0f, 0.0f, 2400.0f, 1800.0f) ); Pane.XAxis.MajorTic.IsInside = false; Pane.XAxis.MinorTic.IsInside = false; Pane.Legend.IsVisible = false; ZedGraph.PointPairList Peaks = new ZedGraph.PointPairList(); double MaxIntensity = 0.0; ///////////////// //Peaks //////////////// foreach (MSPoint p in argPeaks) { if (p.Intensity > MaxIntensity && p.Mass<=MaxX) { MaxIntensity = p.Intensity; } } foreach (MSPoint p in argPeaks) { if (p.Mass <= MaxX) { Peaks.Add(p.Mass, (p.Intensity/MaxIntensity)*100.0); } } Pane.AddStick("Peaks", Peaks, Color.Red); ////////////////// //Y1 text object ////////////////// /* ZedGraph.TextObj txtY1 = new ZedGraph.TextObj("Y1", argStructure.Y1.MZ, 102); txtY1.FontSpec.Size = txtY1.FontSpe.cSize*0.5f; txtY1.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Insert(0, txtY1);*/ ///////////////// //Structure //////////////// GlycansDrawer GS; double previousBoundary = 0; foreach (GlycanTreeNode t in argStructure.Root.FetchAllGlycanNode().OrderBy(o => o.IDMass).ToList()) { GS = new GlycansDrawer(t.IUPACFromRoot, false); double glycopeptideMZ = t.IDMass; //double glycopeptideMZ =argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHexNac * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHex*GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.Hex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfDeHex * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.DeHex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuAc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuGc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuGc, FGS.Charge); Image imgStructure = GlycanImage.RotateImage(GS.GetImage(), 270); ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 131); double PositionX = glycopeptideMZ; if (previousBoundary >= PositionX) { PositionX = previousBoundary + 20; } if (imgStructure.Width > txtGlycanMz.Location.Width) { previousBoundary = imgStructure.Width + PositionX; } else { previousBoundary = (float)txtGlycanMz.Location.Width + PositionX; } ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width + 20, imgStructure.Height); glycan.IsScaled = false; glycan.Location.AlignV = ZedGraph.AlignV.Bottom; txtGlycanMz.Location.X = glycan.Location.X + (float)glycan.Image.Width / 2 - (float)txtGlycanMz.Location.Width / 2; txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.3f; txtGlycanMz.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMz); Pane.GraphObjList.Add(glycan); double interval = 100000; int idx = 0; for (int i = 0; i < Peaks.Count; i++) { if (Math.Abs(Peaks[i].X - glycopeptideMZ) < interval) { interval = Math.Abs((float)Peaks[i].X - glycopeptideMZ); idx = i; } } string mzLabelwPPM = Peaks[idx].X.ToString("0.000");// + "\n(" + Math.Abs(glycopeptideMZ - (float)Peaks[idx].X).ToString("0") + "da)"; ZedGraph.TextObj PeakLabel = new ZedGraph.TextObj(mzLabelwPPM, Peaks[idx].X, Peaks[idx].Y + 3.0); PeakLabel.FontSpec.Size = PeakLabel.FontSpec.Size * 0.3f; PeakLabel.FontSpec.Border.IsVisible = false; PeakLabel.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(PeakLabel); } Pane.AxisChange(); Pane.YAxis.Scale.Max = 145; Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100); Pane.XAxis.Scale.Max = Peaks[Peaks.Count - 1].X + 100; //////////// //Glycan Structure //////////// GS = new GlycansDrawer(argStructure.IUPACString, false); Image imgStruc = RotateImage( GS.GetImage() ,180); ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, Pane.XAxis.Scale.Min + 20, 140, imgStruc.Width + 20, imgStruc.Height); fullStructure.IsScaled = false; Pane.GraphObjList.Add(fullStructure); /////////////// //Glycan M/Z ////////////// double glycopeptidemz = GlycanMass.GetGlycanMasswithCharge(argStructure.Root.GlycanType,argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge); ZedGraph.TextObj txtGlycanMZ = new ZedGraph.TextObj("\n Precursor:" + argScan.ParentMZ.ToString("0.000")+"(" +argScan.ParentCharge.ToString()+")"+ "\nPeptide Sequence:" + argPeptide , Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2, 140); txtGlycanMZ.FontSpec.Size = txtGlycanMZ.FontSpec.Size * 0.3f; txtGlycanMZ.FontSpec.Border.IsVisible = false; txtGlycanMZ.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMZ); Image tmp = (Image)Pane.GetImage(); return tmp; }
public static Image GetAnnotatedImage(string argPeptide, MSScan argScan, List <MSPoint> argPeaks, GlycanStructure argStructure) { float MaxX = argStructure.Root.FetchAllGlycanNode().OrderByDescending(o => o.IDMass).ToList()[0].IDMass; if (MaxX + 100 > 2000.0) { MaxX = 2000.0f; } else { MaxX = MaxX + 100; } ZedGraph.GraphPane Pane = new ZedGraph.GraphPane(new RectangleF(0.0f, 0.0f, 2000.0f, 1500.0f), argScan.ScanNo.ToString(), "Mass", "Intensity"); //ZedGraph.MasterPane Pane = new ZedGraph.MasterPane(argTitle,new RectangleF(0.0f, 0.0f, 2400.0f, 1800.0f) ); Pane.XAxis.MajorTic.IsInside = false; Pane.XAxis.MinorTic.IsInside = false; Pane.Legend.IsVisible = false; ZedGraph.PointPairList Peaks = new ZedGraph.PointPairList(); double MaxIntensity = 0.0; ///////////////// //Peaks //////////////// foreach (MSPoint p in argPeaks) { if (p.Intensity > MaxIntensity && p.Mass <= MaxX) { MaxIntensity = p.Intensity; } } foreach (MSPoint p in argPeaks) { if (p.Mass <= MaxX) { Peaks.Add(p.Mass, (p.Intensity / MaxIntensity) * 100.0); } } Pane.AddStick("Peaks", Peaks, Color.Red); ////////////////// //Y1 text object ////////////////// /* ZedGraph.TextObj txtY1 = new ZedGraph.TextObj("Y1", argStructure.Y1.MZ, 102); * txtY1.FontSpec.Size = txtY1.FontSpe.cSize*0.5f; * txtY1.FontSpec.Border.IsVisible = false; * Pane.GraphObjList.Insert(0, txtY1);*/ ///////////////// //Structure //////////////// GlycansDrawer GS; double previousBoundary = 0; foreach (GlycanTreeNode t in argStructure.Root.FetchAllGlycanNode().OrderBy(o => o.IDMass).ToList()) { GS = new GlycansDrawer(t.IUPACFromRoot, false); double glycopeptideMZ = t.IDMass; //double glycopeptideMZ =argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHexNac * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHex*GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.Hex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfDeHex * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.DeHex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuAc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuGc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuGc, FGS.Charge); Image imgStructure = GlycanImage.RotateImage(GS.GetImage(), 270); ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 131); double PositionX = glycopeptideMZ; if (previousBoundary >= PositionX) { PositionX = previousBoundary + 20; } if (imgStructure.Width > txtGlycanMz.Location.Width) { previousBoundary = imgStructure.Width + PositionX; } else { previousBoundary = (float)txtGlycanMz.Location.Width + PositionX; } ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width + 20, imgStructure.Height); glycan.IsScaled = false; glycan.Location.AlignV = ZedGraph.AlignV.Bottom; txtGlycanMz.Location.X = glycan.Location.X + (float)glycan.Image.Width / 2 - (float)txtGlycanMz.Location.Width / 2; txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.3f; txtGlycanMz.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMz); Pane.GraphObjList.Add(glycan); double interval = 100000; int idx = 0; for (int i = 0; i < Peaks.Count; i++) { if (Math.Abs(Peaks[i].X - glycopeptideMZ) < interval) { interval = Math.Abs((float)Peaks[i].X - glycopeptideMZ); idx = i; } } string mzLabelwPPM = Peaks[idx].X.ToString("0.000");// + "\n(" + Math.Abs(glycopeptideMZ - (float)Peaks[idx].X).ToString("0") + "da)"; ZedGraph.TextObj PeakLabel = new ZedGraph.TextObj(mzLabelwPPM, Peaks[idx].X, Peaks[idx].Y + 3.0); PeakLabel.FontSpec.Size = PeakLabel.FontSpec.Size * 0.3f; PeakLabel.FontSpec.Border.IsVisible = false; PeakLabel.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(PeakLabel); } Pane.AxisChange(); Pane.YAxis.Scale.Max = 145; Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100); Pane.XAxis.Scale.Max = Peaks[Peaks.Count - 1].X + 100; //////////// //Glycan Structure //////////// GS = new GlycansDrawer(argStructure.IUPACString, false); Image imgStruc = RotateImage(GS.GetImage(), 180); ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, Pane.XAxis.Scale.Min + 20, 140, imgStruc.Width + 20, imgStruc.Height); fullStructure.IsScaled = false; Pane.GraphObjList.Add(fullStructure); /////////////// //Glycan M/Z ////////////// double glycopeptidemz = GlycanMass.GetGlycanMasswithCharge(argStructure.Root.GlycanType, argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge); ZedGraph.TextObj txtGlycanMZ = new ZedGraph.TextObj("\n Precursor:" + argScan.ParentMZ.ToString("0.000") + "(" + argScan.ParentCharge.ToString() + ")" + "\nPeptide Sequence:" + argPeptide , Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2, 140); txtGlycanMZ.FontSpec.Size = txtGlycanMZ.FontSpec.Size * 0.3f; txtGlycanMZ.FontSpec.Border.IsVisible = false; txtGlycanMZ.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMZ); Image tmp = (Image)Pane.GetImage(); return(tmp); }
public void DrawsequencingGraph(GlycanStructure argStructure) { zedSequence.GraphPane.GraphObjList.Clear(); zedSequence.GraphPane.Legend.IsVisible = false; List <String> tmp = argStructure.Root.GetSequencingMapList(); if (tmp.Count == 0) { return; } float Xmin = Convert.ToSingle(tmp[0].Split('-')[0]); float Xmax = Convert.ToSingle(tmp[tmp.Count - 1].Split('-')[2]); if (Xmax == 0.0f) { Xmax = scan.MSPeaks[scan.MSPeaks.Count - 1].MonoMass; } double YMax = 0.0; ZedGraph.PointPairList pplPeak = new ZedGraph.PointPairList(); for (int i = 0; i < GS.FilteredPeaks.Count; i++) { if (GS.FilteredPeaks[i].Mass >= Xmin + 10.0f && GS.FilteredPeaks[i].Mass <= Xmax + 10.0f) { if (GS.FilteredPeaks[i].Intensity > YMax) { YMax = GS.FilteredPeaks[i].Intensity; } } } for (int i = 0; i < GS.FilteredPeaks.Count; i++) { if (GS.FilteredPeaks[i].Mass >= Xmin + 10.0f && GS.FilteredPeaks[i].Mass <= Xmax + 10.0f) { pplPeak.Add(GS.FilteredPeaks[i].Mass, GS.FilteredPeaks[i].Intensity / YMax * 100.0f); } } ZedGraph.GraphPane Pane = zedSequence.GraphPane; Pane.XAxis.MajorTic.IsInside = false; Pane.XAxis.MinorTic.IsInside = false; Pane.CurveList.Clear(); Pane.AddStick("Peaks", pplPeak, Color.Red); //Pane.XAxis.Scale.Min = Xmin - 10; //Pane.XAxis.Scale.Max = Xmax + 10; Pane.Title.Text = "No. " + txtScanNo.Text + "; Y1 m/z:" + argStructure.Y1.Mass.ToString("0.000");//+ " Structure:" + Convert.ToString(dgView.Rows[e.RowIndex].Cells[0].Value); Pane.AxisChange(); double YLevel = YMax; double outX, outY, outY2, diff; Pane.ReverseTransform(new Point(100, 100), out outX, out outY); Pane.ReverseTransform(new Point(100, 110), out outX, out outY2); diff = outY - outY2; GlycanTreeNode GT = argStructure.Root;//GS.GlycanTrees[e.RowIndex]; //Peak Interval //List<string> SeqList = new List<string>(); //for (int i = 0; i < GT.GetSequencingMapList().Count; i++) //{ // //Split the string // string[] strArray = GT.GetSequencingMapList()[i].Split('-'); // ZedGraph.TextObj TxtObg = new ZedGraph.TextObj(); // TxtObg.Text = strArray[1]; // double Start = Convert.ToDouble(strArray[0]); // double End = Convert.ToDouble(strArray[2]); // System.Drawing.Drawing2D.DashStyle LineStyle = DashStyle.Solid; // if (Start == 0) // { // if (strArray[1] == "HexNAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // TxtObg.Text = TxtObg.Text + "?"; // LineStyle = DashStyle.Dash; // } // else // { // if (strArray[1] == "HexNAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // } // if (End == 0) // { // if (strArray[1] == "HexNAc") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // TxtObg.Text = TxtObg.Text + "?"; // LineStyle = DashStyle.Dash; // } // //Determine the Y level // int Ylevel = 0; // if (SeqList.Count == 0) // { // SeqList.Add(Start.ToString() + "," + End.ToString() + ",0"); // } // else // { // for (int j = i - 1; j >= 0; j--) // { // double PreStart = Convert.ToDouble(SeqList[j].Split(',')[0]); // double PreEnd = Convert.ToDouble(SeqList[j].Split(',')[1]); // int Prelevel = Convert.ToInt32(SeqList[j].Split(',')[2]); // if ((PreStart <= Start && Start <= PreEnd)) // { // if (Math.Abs(PreEnd - Start) <= 10.0) // { // Ylevel = Prelevel; // break; // } // else // { // Ylevel = Prelevel + 1; // break; // } // } // } // SeqList.Add(Start.ToString() + "," + End.ToString() + "," + Ylevel.ToString()); // } // TxtObg.FontSpec.Size = TxtObg.FontSpec.Size * 0.8f; // YLevel = YMax + diff * Ylevel; // ZedGraph.LineObj Lne = new ZedGraph.LineObj(Start, YLevel + diff, Start, YLevel - diff); //Left V Line // Pane.GraphObjList.Add(Lne); // Lne = new ZedGraph.LineObj(End, YLevel + diff, End, YLevel - diff); //Right V Line // Pane.GraphObjList.Add(Lne); // Lne = new ZedGraph.LineObj(Start, YLevel, End, YLevel); //Add Line // Lne.Line.Style = LineStyle; // Pane.GraphObjList.Add(Lne); // //ZedGraph.ArrowObj arr= new ZedGraph.ArrowObj(Start, YLevel, End, YLevel); // //arr.IsArrowHead = true; // //arr.Line.Style = LineStyle; // //Pane.GraphObjList.Add(arr); // TxtObg.Location = new ZedGraph.Location(((Start + End) / 2), (double)YLevel, ZedGraph.CoordType.AxisXYScale); // TxtObg.FontSpec.Border.IsVisible = false; // TxtObg.Location.AlignH = ZedGraph.AlignH.Center; // TxtObg.Location.AlignV = ZedGraph.AlignV.Center; // Pane.GraphObjList.Insert(0, TxtObg); //} /////Annotation GlycansDrawer GDraw; double previousX2 = 0; List <GlycanTreeNode> Fragements = argStructure.Root.FetchAllGlycanNode(); Fragements.Sort(delegate(GlycanTreeNode T1, GlycanTreeNode T2) { return(Comparer <float> .Default.Compare(T1.IDMass, T2.IDMass)); }); foreach (GlycanTreeNode FGS in Fragements) { string Exp = argStructure.GetIUPACfromParentToNodeID(FGS.NodeID); //Queue<string> tmpQue = new Queue<string>(); //for (int i = 0; i < Exp.Length; i++) //{ // int NodeID = 0; // if (Exp[i].StartsWith("(") || Exp[i].StartsWith(")")) // { // NodeID = Convert.ToInt32(Exp[i].Split(',')[0].Substring(1)); // } // else // { // NodeID = Convert.ToInt32(Exp[i].Split(',')[0]); // } // if (NodeID > FGS.NodeID) // { // if (Exp[i].StartsWith("(") || Exp[i].StartsWith(")")) // { // tmpQue.Enqueue(Exp[i].Substring(0, 1)); // // } // } // else // { // tmpQue.Enqueue(Exp[i]); // } //} //string IUPAC = ""; //do //{ // string tmp =tmpQue.Dequeue(); // if(tmp == "(" && tmpQue.Peek() == ")" ) // { // } //}while(tmpQue.Count!=0) string tmpIUPAC = argStructure.GetSequqncedIUPACwNodeID(FGS.NodeID); GDraw = new GlycansDrawer(tmpIUPAC); float glycopeptideMZ = FGS.IDMass; if (double.IsNaN(glycopeptideMZ)) { continue; } Image imgStructure = RotateImage(GDraw.GetImage(), 270); double PositionX = glycopeptideMZ; if (previousX2 >= PositionX) { PositionX = previousX2 + 20; } ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width * 0.3f, imgStructure.Height * 0.3f); glycan.IsScaled = true; glycan.Location.AlignV = ZedGraph.AlignV.Bottom; Pane.GraphObjList.Add(glycan); ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 140); txtGlycanMz.Location.X = Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X1 + (Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2 - Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X1) / 2; txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.5f; txtGlycanMz.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMz); if (Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2 > Pane.GraphObjList[Pane.GraphObjList.Count - 2].Location.X2) { previousX2 = Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2; } else { previousX2 = Pane.GraphObjList[Pane.GraphObjList.Count - 2].Location.X2; } } Pane.AxisChange(); Pane.YAxis.Scale.Max = 145; Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100); Pane.XAxis.Scale.Max = pplPeak[pplPeak.Count - 1].X + 100; //////////// //Glycan Structure on the Right Top Header //////////// GDraw = new GlycansDrawer(argStructure.IUPACString, false); Image imgStruc = GDraw.GetImage(); ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, 0.01f, 0.01f, imgStruc.Width, imgStruc.Height); fullStructure.IsScaled = false; Pane.GraphObjList.Add(fullStructure); Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.CoordinateFrame = ZedGraph.CoordType.PaneFraction; zedSequence.AxisChange(); zedSequence.Refresh(); }