Exemplo n.º 1
0
    private void DrawUserTheoryData(Graphics g, float XUnit, int xstart)
    {
        PeptideMW PMW = new PeptideMW(this.AdditionalSequence);
        float[] Bs = PMW.GetPepFragmentBValues();
        float[] Ys = PMW.GetPepFragmentYValues();
        Pen dataPen = new Pen(Brushes.Blue, 1);
        dataPen.DashStyle = DashStyle.Dash;
        Pen dataPen2 = new Pen(Brushes.Red, 1);
        dataPen2.DashStyle = DashStyle.Dash;

        Font Numberfont = new Font("Times New Roman", 10, FontStyle.Regular);
        //int charge = int.Parse(ChargeState);
        StringFormat sf = new StringFormat();
        sf.Alignment = StringAlignment.Center;
        sf.LineAlignment = StringAlignment.Center;
        int axisline = HEIGHT - NETAREABOTTOMMARGIN - (HEIGHT - NETAREABOTTOMMARGIN - NETAREATOPMARGIN) / 2;
        for (int i = 0; i < Bs.Length; i++)
        {
            if (Bs[i] > xstart)
            {
                float x = (Bs[i] - xstart) * XUnit + NETAREALEFTMARGIN;
                float previousAA = 0.0F;
                if (i == 0)
                    previousAA = NETAREALEFTMARGIN;
                else
                {
                    if (Bs[i - 1] > xstart)
                        previousAA = (Bs[i - 1] - xstart) * XUnit + NETAREALEFTMARGIN;
                    else
                        previousAA = NETAREALEFTMARGIN;
                }

                g.DrawLine(dataPen, x, (float)axisline, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
                string neatSequence = ValidePepSeq(this.AdditionalSequence);
                float modified = 0.0F;
                string AA = "";
                if (HadModifed(i+1, AdditionalSequence, ref modified))
                    AA = string.Format("{0}+{1:F2}", neatSequence.Substring(i, 1), modified);
                else
                    AA = neatSequence.Substring(i, 1);

                g.DrawString(AA, Numberfont, Brushes.Blue, new RectangleF(previousAA, HEIGHT - NETAREABOTTOMMARGIN - 25, x - previousAA, 25), sf);
            }

        }

        for (int i = 0; i < Ys.Length; i++)
        {
            if (Ys[i] > xstart)
            {
                float x = (Ys[i] - xstart) * XUnit + NETAREALEFTMARGIN;
                float previousAA = 0.0F;
                if (i == 0)
                    previousAA = NETAREALEFTMARGIN;
                else
                {
                    if (Ys[i - 1] > xstart)
                        previousAA = (Ys[i - 1] - xstart) * XUnit + NETAREALEFTMARGIN;
                    else
                        previousAA = NETAREALEFTMARGIN;
                }
                g.DrawLine(dataPen2, x, (float)axisline , x, (float)HEIGHT-NETAREABOTTOMMARGIN -25);
                string neatSequence = ValidePepSeq(AdditionalSequence);
                int iSite = neatSequence.Length -1- i;
                float modified = 0.0F;
                string AA = "";
                if (HadModifed(iSite+1, AdditionalSequence, ref modified))
                    AA = string.Format("{0}+{1:F2}", neatSequence.Substring(iSite, 1), modified);
                else
                    AA = neatSequence.Substring(iSite, 1);

                g.DrawString(AA, Numberfont, Brushes.Red, new RectangleF(previousAA, HEIGHT - NETAREABOTTOMMARGIN - 50, x - previousAA, 25), sf);
            }

            //if (Ys[i] / 2 > xstart)
            //{
            //    float x = (Ys[i] / 2 - xstart) * XUnit + NETAREALEFTMARGIN;

            //    g.DrawLine(dataPen, x, (float)NETAREATOPMARGIN, x, (float)HEIGHT - NETAREABOTTOMMARGIN);

            //    g.DrawString(string.Format("Y{0:D}:2+", i + 1), Numberfont, Brushes.Red, new PointF(x, NETAREATOPMARGIN + 12));
            //}
        }
    }
Exemplo n.º 2
0
    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);

        }
    }
Exemplo n.º 3
0
    // 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);
            }

        }
    }
Exemplo n.º 4
0
    private void ShowTheoryValues(string PepSeq)
    {
        //PepSeq = ValidePepSeq(PepSeq);
        if (dtaSpectra != "")
        {
            string[] lines = dtaSpectra.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string line in lines)
            {
                if (char.IsDigit(line, 0))
                {
                    string[] tokens = line.Split(new string[] { " ", "\t" }, StringSplitOptions.RemoveEmptyEntries);
                    string mz = tokens[0];
                    string intensity = tokens[1];// line.Substring(sperator);
                    SpectrumData s = new SpectrumData(float.Parse(tokens[0]), float.Parse(tokens[1]));
                    sd.Add(s);
                    mzint mzi = new mzint();
                    mzi.mz = float.Parse(mz);
                    mzi.intensity = float.Parse(intensity);
                    mzi.bMatched = false;
                    MZS.Add(mzi);
                }
            }
            bFileReaded = true;
        }

        string modifiedSeq = PepSeq;
        PeptideMW PMW = new PeptideMW(PepSeq);
        float[] Bs = PMW.GetPepFragmentBValues();
        float[] Ys = PMW.GetPepFragmentYValues();

        PepSeq = ValidePepSeq(PepSeq);
        int Length = PepSeq.Length;
        for (int i = 0; i <= Length - 1; i++)
        {
            TableRow trValues = new TableRow();
            TableCell tcAA = new TableCell();
            TableCell tcYA = new TableCell();

            float ModifiedWeight = 0.0F;

            if (HadModifed(i + 1, modifiedSeq, ref ModifiedWeight))
                tcAA.Text = string.Format("{0}<sub>{1}</sub>+{2:F2}", PepSeq.Substring(i, 1), i + 1, ModifiedWeight);
            else
                tcAA.Text = string.Format("{0}<sub>{1}</sub>", PepSeq.Substring(i, 1), i + 1);

            tcAA.HorizontalAlign = HorizontalAlign.Left;
            trValues.Cells.Add(tcAA);

            /* B format */
            float B1;
            if (i > (Length - 2))
                B1 = Bs[0];
            else
                B1 = Bs[i];
            if (i < Length - 1)
            {
                TableCell tcB1 = new TableCell();
                tcB1.Text = string.Format("{0:F2}", B1);
                if (IsMatch(B1, MZS))
                    tcB1.ForeColor = B1Color;
                console.Text += "";
                tcB1.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcB1);
                TableCell tcB2 = new TableCell();
                tcB2.Text = string.Format("{0:F2}", (B1 - OH));
                if (IsMatch(B1 - OH, MZS))
                    tcB2.ForeColor = B2Color;
                tcB2.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcB2);
                TableCell tcB3 = new TableCell();
                tcB3.Text = string.Format("{0:F2}", (B1 - H2O));
                if (IsMatch(B1 - H2O, MZS))
                    tcB3.ForeColor = B3Color;
                tcB3.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcB3);

                float B2 = (B1 + 1) / 2;
                TableCell tc2B = new TableCell();
                tc2B.Text = string.Format("{0:F2}", B2);
                if (IsMatch(B2, MZS))
                    tc2B.ForeColor = B1Color;
                tc2B.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tc2B);
                trValues.Height = new Unit("20px");
            }
            else
            {
                TableCell tcB1 = new TableCell();
                tcB1.Text = "";
                trValues.Cells.Add(tcB1);
                TableCell tcB2 = new TableCell();
                tcB2.Text = "";
                trValues.Cells.Add(tcB2);
                TableCell tcB3 = new TableCell();
                tcB3.Text = "";
                trValues.Cells.Add(tcB3);

                TableCell tc2B = new TableCell();
                tc2B.Text = "";
                trValues.Cells.Add(tc2B);
                trValues.Height = new Unit("20px");
            }

            /* Y format */

            float Y1;
            if (i > (Length - 2) || i == 0)
                Y1 = Ys[0];
            else
                Y1 = Ys[Length - 1 - i];
            if (i != 0)
            {
                float Y2 = (Y1 + 1) / 2;
                TableCell tc2Y = new TableCell();
                tc2Y.Text = string.Format("{0:F2}", Y2);
                if (IsMatch(Y2, MZS))
                    tc2Y.ForeColor = Y1Color;
                tc2Y.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tc2Y);

                TableCell tcY3 = new TableCell();
                tcY3.Text = string.Format("{0:F2}", (Y1 - H2O));
                if (IsMatch(Y1 - H2O, MZS))
                    tcY3.ForeColor = Y3Color;
                tcY3.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcY3);

                TableCell tcY2 = new TableCell();
                tcY2.Text = string.Format("{0:F2}", (Y1 - OH));
                if (IsMatch(Y1 - OH, MZS))
                    tcY2.ForeColor = Y2Color;
                tcY2.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcY2);

                TableCell tcY1 = new TableCell();
                tcY1.Text = string.Format("{0:F2}", Y1);
                if (IsMatch(Y1, MZS))
                    tcY1.ForeColor = Y1Color;
                tcY1.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcY1);
            }
            else
            {
                TableCell tcY1 = new TableCell();
                tcY1.Text = "";
                trValues.Cells.Add(tcY1);
                TableCell tcY2 = new TableCell();
                tcY2.Text = "";
                trValues.Cells.Add(tcY2);
                TableCell tcY3 = new TableCell();
                tcY3.Text = "";
                trValues.Cells.Add(tcY3);
                TableCell tc2Y = new TableCell();
                tc2Y.Text = "";
                trValues.Cells.Add(tc2Y);
            }
            if (HadModifed(i + 1, modifiedSeq, ref ModifiedWeight))
                tcYA.Text = string.Format("<div class=\"offset9 span3\"><span class=\"pull-left\">{0}<sub>{1}</sub>+{2:F2}</span></div>", PepSeq.Substring(i, 1), Length - i, ModifiedWeight);
            else
                tcYA.Text = string.Format("<div class=\"offset9 span3\"><span class=\"pull-left\">{0}<sub>{1}</sub></span></div>", PepSeq.Substring(i, 1), Length - i);

            tcYA.HorizontalAlign = HorizontalAlign.Right;
            trValues.Cells.Add(tcYA);

            tbTheoryValues.Rows.Add(trValues);
        }
    }
Exemplo n.º 5
0
    // 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);
            }*/

        }
    }
Exemplo n.º 6
0
    private void ShowTheoryValues(string PepSeq)
    {
        //PepSeq = ValidePepSeq(PepSeq);

        if (!bFileReaded)
        {
            if (SearchType == "DTA")
            {
                if (GuestSpectrums == "")
                    GuestSpectrums = (string)(Session[SessionID]);
                dtaconent = GuestSpectrums;
                string[] lines = GuestSpectrums.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string line in lines)
                {
                    if (char.IsDigit(line, 0))
                    {
                        int sperator = line.IndexOf(" ");
                        string mz = line.Substring(0, sperator);
                        string intensity = line.Substring(sperator);
                        mzint mzi = new mzint();
                        mzi.mz = float.Parse(mz);
                        mzi.intensity = float.Parse(intensity);
                        mzi.bMatched = false;
                        MZS.Add(mzi);
                    }
                }
            }
            else
            {
                string TaskID = Request.QueryString["TaskID"];

                string dtaFilePath = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + string.Format ("\\{0}_dta\\",MSFile ) + SessionID + ".dta";
                FileInfo fiDta = new FileInfo(dtaFilePath);
                if (!fiDta.Exists)
                {
                    Response.Redirect("ErrorPage.aspx?Err=1");
                    return;
                }
                dtaconent = "";
                // get from the generated dta file
                FileStream gfs = File.Open(dtaFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
                StreamReader gsr = new StreamReader(gfs);

                string line;
                while ((line = gsr.ReadLine()) != null)
                {
                    if (char.IsDigit(line, 0))
                    {
                        int sperator = line.IndexOf(" ");
                        string mz = line.Substring(0, sperator);
                        string intensity = line.Substring(sperator);
                        mzint mzi = new mzint();
                        mzi.mz = float.Parse(mz);
                        mzi.intensity = float.Parse(intensity);
                        mzi.bMatched = false;
                        MZS.Add(mzi);
                    }
                    dtaconent += line +"\r\n";
                }
                gsr.Close();
            }
            bFileReaded = true;
        }
        string modifiedSeq = PepSeq;
        PeptideMW PMW = new PeptideMW(PepSeq);
        float[] Bs = PMW.GetPepFragmentBValues();
        float[] Ys = PMW.GetPepFragmentYValues();

        PepSeq = ValidePepSeq(PepSeq);
        int Length = PepSeq.Length;
        // started here! 123,456,,789
        for (int i = 0; i <= Length - 1; i++)
        {
            TableRow trValues = new TableRow();
            TableCell tcAA = new TableCell();
            TableCell tcYA = new TableCell();

            float ModifiedWeight = 0.0F;

            if (HadModifed(i + 1, modifiedSeq, ref ModifiedWeight))
                tcAA.Text = string.Format("{0}<sub>{1}</sub>+{2:F2}", PepSeq.Substring(i, 1), i + 1, ModifiedWeight);
            else
                tcAA.Text = string.Format("{0}<sub>{1}</sub>", PepSeq.Substring(i, 1), i + 1);

            tcAA.HorizontalAlign = HorizontalAlign.Left;
            trValues.Cells.Add(tcAA);

            /* B format */
            float B1;
            if (i > (Length - 2))
                B1 = Bs[0];
            else
                B1 = Bs[i];
            if (i < Length - 1)
            {
                TableCell tcB1 = new TableCell();
                tcB1.Text = string.Format("{0:F2}", B1);
                if (IsMatch(B1, MZS))
                    tcB1.ForeColor = B1Color;
                tcB1.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcB1);
                TableCell tcB2 = new TableCell();
                tcB2.Text = string.Format("{0:F2}", (B1 - OH));
                if (IsMatch(B1 - OH, MZS))
                    tcB2.ForeColor = B2Color;
                tcB2.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcB2);
                TableCell tcB3 = new TableCell();
                tcB3.Text = string.Format("{0:F2}", (B1 - H2O));
                if (IsMatch(B1 - H2O, MZS))
                    tcB3.ForeColor = B3Color;
                tcB3.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcB3);

                float B2 = (B1 + 1) / 2;
                TableCell tc2B = new TableCell();
                tc2B.Text = string.Format("{0:F2}", B2);
                if (IsMatch(B2, MZS))
                    tc2B.ForeColor = B1Color;
                tc2B.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tc2B);
                trValues.Height = new Unit("20px");
            }
            else
            {
                TableCell tcB1 = new TableCell();
                tcB1.Text = "";
                trValues.Cells.Add(tcB1);
                TableCell tcB2 = new TableCell();
                tcB2.Text = "";
                trValues.Cells.Add(tcB2);
                TableCell tcB3 = new TableCell();
                tcB3.Text = "";
                trValues.Cells.Add(tcB3);

                TableCell tc2B = new TableCell();
                tc2B.Text = "";
                trValues.Cells.Add(tc2B);
                trValues.Height = new Unit("20px");
            }

            /* Y format */

            float Y1;
            if (i > (Length - 2) || i == 0)
                Y1 = Ys[0];
            else
                Y1 = Ys[Length - 1 - i];
            if (i != 0)
            {
                float Y2 = (Y1 + 1) / 2;
                TableCell tc2Y = new TableCell();
                tc2Y.Text = string.Format("{0:F2}", Y2);
                if (IsMatch(Y2, MZS))
                    tc2Y.ForeColor = Y1Color;
                tc2Y.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tc2Y);

                TableCell tcY3 = new TableCell();
                tcY3.Text = string.Format("{0:F2}", (Y1 - H2O));
                if (IsMatch(Y1 - H2O, MZS))
                    tcY3.ForeColor = Y3Color;
                tcY3.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcY3);

                TableCell tcY2 = new TableCell();
                tcY2.Text = string.Format("{0:F2}", (Y1 - OH));
                if (IsMatch(Y1 - OH, MZS))
                    tcY2.ForeColor = Y2Color;
                tcY2.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcY2);

                TableCell tcY1 = new TableCell();
                tcY1.Text = string.Format("{0:F2}", Y1);
                if (IsMatch(Y1, MZS))
                    tcY1.ForeColor = Y1Color;
                tcY1.HorizontalAlign = HorizontalAlign.Right;
                trValues.Cells.Add(tcY1);
            }
            else
            {
                TableCell tcY1 = new TableCell();
                tcY1.Text = "";
                trValues.Cells.Add(tcY1);
                TableCell tcY2 = new TableCell();
                tcY2.Text = "";
                trValues.Cells.Add(tcY2);
                TableCell tcY3 = new TableCell();
                tcY3.Text = "";
                trValues.Cells.Add(tcY3);
                TableCell tc2Y = new TableCell();
                tc2Y.Text = "";
                trValues.Cells.Add(tc2Y);
            }
            if (HadModifed(i + 1, modifiedSeq, ref ModifiedWeight))
                tcYA.Text = string.Format("<div class=\"offset9 span3\"><span class=\"pull-left\">{0}<sub>{1}</sub>+{2:F2}</span></div>", PepSeq.Substring(i, 1), Length - i, ModifiedWeight);
            else
                tcYA.Text = string.Format("<div class=\"offset9 span3\"><span class=\"pull-left\">{0}<sub>{1}</sub></span></div>", PepSeq.Substring(i, 1), Length - i);

            tcYA.HorizontalAlign = HorizontalAlign.Right;
            trValues.Cells.Add(tcYA);

            tbTheoryValues.Rows.Add(trValues);
        }
    }