// REAL MAGIC HERE! y- B- private void DrawData(String pepseq) { PeptideMW PMW = new PeptideMW(pepseq); float[] Bs = PMW.GetPepFragmentBValues(); float[] Ys = PMW.GetPepFragmentYValues(); bool bPhos = PMW.IsPhosphorylation(); int Count = sd.Count; int i = 0; for (i = 0; i < Count; i++) { float mz = ((SpectrumData)sd[i]).mz; float intensity = ((SpectrumData)sd[i]).intensity; /* * Pen dataPen = new Pen(Brushes.Black, 1); * Pen BLinePen = new Pen(Brushes.Blue, 2); * Pen YLinePen = new Pen(Brushes.Red, 2); * Pen ALinePen = new Pen(Brushes.Green, 2); * Pen MLinePen = new Pen(Brushes.Gray, 2); * Font Numberfont = new Font("Arial", 9, FontStyle.Regular);*/ string strAnn = GetAnnotation(sd, i, Bs, Ys, float.Parse(PrecursorMZ), int.Parse(ChargeState), bPhos); if (strAnn.StartsWith("(b")) { sd[i].setColor("#0000ff"); sd[i].setTip(labelChargeCount(stripParenth(strAnn))); //g.DrawLine(BLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); //g.DrawString(strAnn, Numberfont, Brushes.Blue, new PointF(x, y)); } else if (strAnn.StartsWith("(y")) { sd[i].setColor("#ff0000"); sd[i].setTip(labelChargeCount(stripParenth(strAnn))); //g.DrawLine(YLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); //g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y)); } else if (strAnn.StartsWith("(a")) { sd[i].setColor("#00ff00"); sd[i].setTip(labelChargeCount(stripParenth(strAnn))); //g.DrawLine(ALinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); //g.DrawString(strAnn, Numberfont, Brushes.Green, new PointF(x, y)); } else if (strAnn.StartsWith("(M")) { sd[i].setColor("#cccccc"); sd[i].setTip(labelChargeCount(stripParenth(strAnn))); //g.DrawLine(MLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); //g.DrawString(strAnn, Numberfont, Brushes.Gray, new PointF(x, y)); } else { sd[i].setColor("#000000"); //g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); } //g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y)); /* * if (intensity == MaxIntensitiy) * { * //peak value point * GraphicsPath p = new GraphicsPath(); * p.AddLine(x, (float)HEIGHT - NETAREABOTTOMMARGIN, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength); * p.AddLine(x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength, x - XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength); * p.CloseFigure(); * g.FillPath(Brushes.Red, p); * * g.DrawString(mz.ToString(), Numberfont, Brushes.Red, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN); * }*/ } }
// REAL MAGIC HERE! y- B- private void DrawData(Graphics g, float Xunit, float Yunit, int xstart) { PeptideMW PMW = new PeptideMW(PeptideSequence); float[] Bs = PMW.GetPepFragmentBValues(); float[] Ys = PMW.GetPepFragmentYValues(); bool bPhos = PMW.IsPhosphorylation(); int Count = SpectrumData.Count; int i = 0; for (i = 0; i < Count; i++) { float mz = ((MZintensitiy )SpectrumData[i]).mz; float intensity = ((MZintensitiy )SpectrumData[i]).intensity; float x = (mz - xstart) * Xunit + NETAREALEFTMARGIN; float y; if (bZoomOut) { if (intensity * 100 / MaxIntensitiy > DisplayMaxY) { y = NETAREATOPMARGIN; } else { y = HEIGHT - NETAREABOTTOMMARGIN - intensity * 100 * Yunit / MaxIntensitiy; } } else { y = HEIGHT - NETAREABOTTOMMARGIN - intensity * 100 * Yunit / MaxIntensitiy; } Pen dataPen = new Pen(Brushes.Black, 1); Pen BLinePen = new Pen(Brushes.Blue, 2); Pen YLinePen = new Pen(Brushes.Red, 2); Pen ALinePen = new Pen(Brushes.Green, 2); Pen MLinePen = new Pen(Brushes.Gray, 2); Font Numberfont = new Font("Arial", 9, FontStyle.Regular); if (y < HEIGHT - NETAREABOTTOMMARGIN - 20 && bShowLabel) { string strAnn = GetAnnotation(SpectrumData, i, Bs, Ys, PrecursorMZ, int.Parse(ChargeState), bPhos); if (strAnn.StartsWith("(b")) { g.DrawLine(BLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); g.DrawString(strAnn, Numberfont, Brushes.Blue, new PointF(x, y)); } else if (strAnn.StartsWith("(y")) { g.DrawLine(YLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y)); } else if (strAnn.StartsWith("(a")) { g.DrawLine(ALinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); g.DrawString(strAnn, Numberfont, Brushes.Green, new PointF(x, y)); } else if (strAnn.StartsWith("(M") && y < HEIGHT - NETAREABOTTOMMARGIN - 100) { g.DrawLine(MLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); g.DrawString(strAnn, Numberfont, Brushes.Gray, new PointF(x, y)); } else { g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); } //g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y)); } else { g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN); } if (intensity == MaxIntensitiy) { //peak value point GraphicsPath p = new GraphicsPath(); p.AddLine(x, (float)HEIGHT - NETAREABOTTOMMARGIN, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength); p.AddLine(x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength, x - XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength); p.CloseFigure(); g.FillPath(Brushes.Red, p); g.DrawString(mz.ToString(), Numberfont, Brushes.Red, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN); } } }