// 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); } } }
private void DrawData(Graphics g, float Xunit, float Yunit, int xstart) { PeptideMW PMW = new PeptideMW(PeptideSequence); float[] Bs = PMW.GetPepFragmentBValues(); float[] Ys = PMW.GetPepFragmentYValues(); int charge1 = int.Parse (ChargeState);//(int) (PMW.GetMW2() / PrecursorMZ) +1; bool bPhos1 = PMW.IsPhosphorylation(); PeptideMW PMW2 = new PeptideMW(AdditionalSequence); float[] Bs2 = PMW2.GetPepFragmentBValues(); float[] Ys2 = PMW2.GetPepFragmentYValues(); float Precursor2 = PMW2.getPrecurMz2(charge1); bool bPhos2 = PMW2.IsPhosphorylation(); Pen dataPen = new Pen(Brushes.Black, 1); Pen BLinePen = new Pen(Brushes.Blue, 1); Pen YLinePen = new Pen(Brushes.Red, 1); Pen ALinePen = new Pen(Brushes.Green, 1); Pen MLinePen = new Pen(Brushes.Gray , 1); int LabelTolerance = 20; if (bShowNoise) { BLinePen = new Pen(NoiseModeColor , 1); YLinePen = new Pen(NoiseModeColor, 1); ALinePen = new Pen(NoiseModeColor , 1); MLinePen = new Pen(NoiseModeColor , 1); LabelTolerance = 1; } //draw the library spectrum int Count = SpectrumData.Count; for (int 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 = XLinePos - intensity * 100 * Yunit / MaxIntensitiy; } } else y = XLinePos - intensity * 100 * Yunit / MaxIntensitiy; Font Numberfont = new Font("Arial", 9, FontStyle.Regular); if (y < XLinePos - LabelTolerance ) { string strAnn = GetAnnotation(SpectrumData,i, Bs, Ys,bShowNoise,PrecursorMZ,charge1,bPhos1 ); if (strAnn.StartsWith("(b")) { if (bShowLabel) { g.DrawLine(BLinePen, x, y, x, (float)XLinePos); g.DrawString(strAnn, Numberfont, Brushes.Blue, new PointF(x, y)); } else { if (bShowNoise ) g.DrawLine(BLinePen, x, y, x, (float)XLinePos); else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } } else if (strAnn.StartsWith("(y")) { if (bShowLabel) { g.DrawLine(YLinePen, x, y, x, (float)XLinePos); g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y)); } else { if (bShowNoise ) g.DrawLine(YLinePen, x, y, x, (float)XLinePos); else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } } else if (strAnn.StartsWith("(a")) { if (bShowLabel) { g.DrawLine(ALinePen, x, y, x, (float)XLinePos); g.DrawString(strAnn, Numberfont, Brushes.Green, new PointF(x, y)); } else { if (bShowNoise ) g.DrawLine(ALinePen, x, y, x, (float)XLinePos); else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } } else if (strAnn.StartsWith("(M") && y < XLinePos - 100) { if (bShowLabel) { g.DrawLine(MLinePen, x, y, x, (float)XLinePos); g.DrawString(strAnn, Numberfont, Brushes.Gray, new PointF(x, y)); } else { if (bShowNoise ) g.DrawLine(MLinePen, x, y, x, (float)XLinePos); else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } } else { g.DrawLine(dataPen, x, y, x, (float)XLinePos ); } //g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y)); } else g.DrawLine(dataPen, x, y, x, (float)XLinePos ); } //draw the guest spectrum Count = GuestSpectrumData.Count; for (int i = 0; i < Count; i++) { float mz = ((MZintensitiy)GuestSpectrumData[i]).mz; float intensity = ((MZintensitiy)GuestSpectrumData[i]).intensity; float x = (mz - xstart) * Xunit + NETAREALEFTMARGIN; float y; if (bZoomOut) { if (intensity * 100 / GuestMaxIntensitiy > DisplayMaxY) { y = HEIGHT - NETAREABOTTOMMARGIN ; } else { y = XLinePos + intensity * 100 * Yunit / GuestMaxIntensitiy; } } else y = XLinePos + intensity * 100 * Yunit / GuestMaxIntensitiy; Font Numberfont = new Font("Arial", 9, FontStyle.Regular); if (y > XLinePos + LabelTolerance) { string strAnn = GetAnnotation(GuestSpectrumData,i, Bs2, Ys2,bShowNoise,Precursor2,charge1 ,bPhos2); if (strAnn.StartsWith("(b")) { if (bShowLabel) { g.DrawLine(BLinePen, x, y, x, (float)XLinePos); g.DrawString(strAnn, Numberfont, Brushes.Blue, new PointF(x, y - 10)); } else { if (bShowNoise ) g.DrawLine(BLinePen, x, y, x, (float)XLinePos); else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } } else if (strAnn.StartsWith("(y")) { if (bShowLabel) { g.DrawLine(YLinePen, x, y, x, (float)XLinePos); g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y - 10)); } else { if (bShowNoise ) g.DrawLine(YLinePen, x, y, x, (float)XLinePos); else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } } else if (strAnn.StartsWith("(a")) { if (bShowLabel) { g.DrawLine(ALinePen, x, y, x, (float)XLinePos); g.DrawString(strAnn, Numberfont, Brushes.Green, new PointF(x, y - 10)); } else { if (bShowNoise ) g.DrawLine(ALinePen, x, y, x, (float)XLinePos); else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } } else if (strAnn.StartsWith("(M") && y > XLinePos + 100) { if (bShowLabel) { g.DrawLine(MLinePen, x, y, x, (float)XLinePos); g.DrawString(strAnn, Numberfont, Brushes.Gray, new PointF(x, y - 10)); } else { if (bShowNoise ) g.DrawLine(MLinePen, x, y, x, (float)XLinePos); else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } } else { g.DrawLine(dataPen, x, y, x, (float)XLinePos); } //g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y)); } else g.DrawLine(dataPen, x, y, x, (float)XLinePos); } }
// 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); }*/ } }