Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SpectrumData = new ArrayList();
        GuestSpectrumData = new ArrayList();
        SessionID = Request.QueryString["SessionID"];
        TaskID = Request.QueryString["TaskID"];
        if (Request.QueryString["file"] != null)
        {
            string file_path = Request.QueryString["file"];

            if (Request.QueryString["mode"] != null)
            {
                if (Request.QueryString["mode"] == "ZoomOut")
                {
                    //get the param how to show the spectrum
                    string displayMin = Request.QueryString["xmin"];
                    string displayMax = Request.QueryString["xmax"];
                    string displayYMax = Request.QueryString["ymax"];
                    try
                    {
                        if (displayMin == null)
                            DisplayMinX = -1;
                        else
                        {
                            DisplayMinX = int.Parse(displayMin);
                            if (DisplayMinX < 0)
                                DisplayMinX = -1;

                        }

                        if (displayMax == null)
                            DisplayMaxX = -1;
                        else
                        {
                            DisplayMaxX = int.Parse(displayMax);
                            if (DisplayMaxX < 0 || DisplayMaxX <= DisplayMinX)
                                DisplayMaxX = -1;
                        }
                    }
                    catch
                    {
                        DisplayMaxX = -1;
                        DisplayMinX = -1;
                    }
                    //use the params to decide the seg distance will show on the axial
                    if (DisplayMaxX != -1 && DisplayMinX != -1)
                    {
                        int Length = DisplayMaxX - DisplayMinX;

                        if (Length > 1000)
                            XBIGSEG = 100;
                        else if (Length > 500)
                            XBIGSEG = 50;
                        else if (Length > 200)
                            XBIGSEG = 25;
                        else if (Length > 100)
                            XBIGSEG = 15;
                        else if (Length > 50)
                            XBIGSEG = 10;
                        else if (Length > 20)
                            XBIGSEG = 5;
                        else if (Length > 10)
                            XBIGSEG = 2;
                        else
                            XBIGSEG = 1;
                    }
                    try
                    {
                        if (displayYMax == null)
                            DisplayMaxY = 100;
                        else
                        {
                            DisplayMaxY = int.Parse(displayYMax);
                            if (DisplayMaxY < 75 && DisplayMaxY > 30)
                            {
                                YBIGSEG = 10;
                            }
                            else if (DisplayMaxY <= 30 && DisplayMaxY > 20)
                            {
                                YBIGSEG = 5;
                            }
                            else if (DisplayMaxY >= 0 && DisplayMaxY <= 20)
                            {
                                YBIGSEG = 2;
                            }
                            else if (DisplayMaxY <= 100 && DisplayMaxY >= 75)
                            {
                                YBIGSEG = 25;
                            }
                            else
                            {
                                DisplayMaxY = 100;
                                YBIGSEG = 25;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DisplayMaxY = 100; ;
                    }
                    bZoomOut = true;
                }
                else
                {
                    bZoomOut = false;
                }
            }
            if (Request.QueryString["Printable"] != null)
            {
                if (Request.QueryString["Printable"] == "True")
                    WIDTH = 580;
                else
                    WIDTH = 800;
            }

            if (Request.QueryString["ShowTheory"] != null)
            {
                if (Request.QueryString["ShowTheory"] == "True")
                {
                    bShowTheory = true;

                }
                else
                    bShowTheory = false;

            }

            if (Request.QueryString["Noise"] != null)
            {
                if (Request.QueryString["Noise"] == "True")
                    bShowNoise = true;
                else
                    bShowNoise = false;
            }

            if (Request.QueryString["Label"] != null)
            {
                if (Request.QueryString["Label"] == "True")
                    bShowLabel = true;
                else
                    bShowLabel = false;
            }
            AdditionalSequence = Request.QueryString["SEQ"];
            ChargeState = Request.QueryString["CS"];
            SearchType = Request.QueryString["ST"];
            PrecursorMZ = float.Parse(Request.QueryString["pmz"]);
            mzTolerance = float.Parse(WebConfigurationManager.ConnectionStrings["mzTolerance"].ConnectionString);
            // get the library spectrum data
            if (true)//File.Exists(file_path))
            {
                //multiuser-fridendly streamreader
                //FileInfo fiLibSpectra = new FileInfo(file_path);
                //if (!fiLibSpectra.Exists)
                //    return;

                //FileStream fs = File.Open(file_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                //StreamReader sr = new StreamReader(fs);

                string lines = "";
                String strSQL = string.Format("select spectrum,ptm_sequence from spectrum_tbl where spectrum_seq={0}", file_path);
                DataSet result = DBInterface.QuerySQL2(strSQL);
                if (result != null)
                {

                    if (result.Tables[0].Rows.Count > 0)
                    {
                        lines = result.Tables[0].Rows[0].ItemArray[0].ToString();
                        PeptideSequence = result.Tables[0].Rows[0].ItemArray[1].ToString();
                    }
                }

                String[] dtaLines = lines.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                {
                    MinX = DisplayMinX;
                    MaxX = DisplayMaxX;
                }
                foreach (String line in dtaLines)
                {
                    if (char.IsDigit(line, 0))
                    {
                        string[] tokens = line.Split (new string[]{" ","\t"},StringSplitOptions.RemoveEmptyEntries );
                        string mz = tokens[0];
                        string intensity = tokens [1];
                        MZintensitiy mzi = new MZintensitiy();
                        try
                        {
                            mzi.mz = float.Parse(mz);
                            if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                            {
                                if (mzi.mz < DisplayMaxX && mzi.mz > DisplayMinX)
                                {
                                    //if (mzi.mz < MinX)
                                    //    MinX = mzi.mz;
                                    //if (mzi.mz > MaxX)
                                    //    MaxX = mzi.mz;
                                    mzi.intensity = float.Parse(intensity);
                                    if (mzi.intensity > MaxIntensitiy)
                                        MaxIntensitiy = mzi.intensity;
                                    SpectrumData.Add(mzi);
                                }
                            }
                            else
                            {
                                if (mzi.mz < MinX)
                                    MinX = mzi.mz;
                                if (mzi.mz > MaxX)
                                    MaxX = mzi.mz;
                                mzi.intensity = float.Parse(intensity);
                                if (mzi.intensity > MaxIntensitiy)
                                    MaxIntensitiy = mzi.intensity;
                                SpectrumData.Add(mzi);
                            }
                        }
                        catch
                        { }
                    }
                }
                //sr.Close();

                if (SearchType == "DTA")
                {
                    ////get the guest spectrum data
                    //if (GuestSpectrums == "")
                    //    GuestSpectrums = (string)(Session[SessionID]);

                    //string[] lines = GuestSpectrums.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                    //foreach (string pair in lines)
                    //{
                    //    if (char.IsDigit(pair, 0))
                    //    {
                    //        int sperator = pair.IndexOf(" ");
                    //        string mz = pair.Substring(0, sperator);
                    //        string intensity = pair.Substring(sperator);
                    //        MZintensitiy mzi = new MZintensitiy();
                    //        try
                    //        {
                    //            mzi.mz = float.Parse(mz);
                    //            if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                    //            {
                    //                // if mz in the zoom view
                    //                if (mzi.mz < DisplayMaxX && mzi.mz > DisplayMinX)
                    //                {
                    //                    if (mzi.mz < GuestMinX)
                    //                        GuestMinX = mzi.mz;
                    //                    if (mzi.mz > GuestMaxX)
                    //                        GuestMaxX = mzi.mz;
                    //                    mzi.intensity = float.Parse(intensity);
                    //                    if (mzi.intensity > GuestMaxIntensitiy)
                    //                        GuestMaxIntensitiy = mzi.intensity;
                    //                    GuestSpectrumData.Add(mzi);
                    //                }
                    //            }
                    //            else
                    //            {
                    //                if (mzi.mz < GuestMinX)
                    //                    GuestMinX = mzi.mz;
                    //                if (mzi.mz > GuestMaxX)
                    //                    GuestMaxX = mzi.mz;
                    //                mzi.intensity = float.Parse(intensity);
                    //                if (mzi.intensity > GuestMaxIntensitiy)
                    //                    GuestMaxIntensitiy = mzi.intensity;
                    //                GuestSpectrumData.Add(mzi);
                    //            }
                    //        }
                    //        catch (Exception ex)
                    //        { }
                    //    }
                    //}
                }
                else
                {
                    string msFile = Request.QueryString["MSFile"];
                    string dtaFilePath = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + string.Format ("\\{0}_dta\\",msFile ) + SessionID + ".dta";

                    FileInfo fiDta = new FileInfo(dtaFilePath);
                    if (!fiDta.Exists)
                        return;

                    // get from the generated dta file
                    FileStream gfs = File.Open(dtaFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
                    StreamReader gsr = new StreamReader(gfs);
                    if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                    {
                        GuestMinX = DisplayMinX;
                        GuestMaxX = DisplayMaxX;
                    }
                    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);
                            MZintensitiy mzi = new MZintensitiy();
                            try
                            {
                                mzi.mz = float.Parse(mz);
                                if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                                {
                                    if (mzi.mz < DisplayMaxX && mzi.mz > DisplayMinX)
                                    {
                                        //if (mzi.mz < GuestMinX)
                                        //    GuestMinX = mzi.mz;
                                        //if (mzi.mz > GuestMaxX)
                                        //    GuestMaxX = mzi.mz;
                                        mzi.intensity = float.Parse(intensity);
                                        if (mzi.intensity > GuestMaxIntensitiy)
                                            GuestMaxIntensitiy = mzi.intensity;
                                        GuestSpectrumData.Add(mzi);
                                    }
                                }
                                else
                                {
                                    if (mzi.mz < GuestMinX)
                                        GuestMinX = mzi.mz;
                                    if (mzi.mz > GuestMaxX)
                                        GuestMaxX = mzi.mz;
                                    mzi.intensity = float.Parse(intensity);
                                    if (mzi.intensity > GuestMaxIntensitiy)
                                        GuestMaxIntensitiy = mzi.intensity;
                                    GuestSpectrumData.Add(mzi);
                                }
                            }
                            catch
                            { }
                        }
                    }
                    gsr.Close();
                }
                DrawSpectrum();

            }
        }
    }
Esempio n. 2
0
    //string PeptideSequence = "";
    //string ChargeState = "";

    //float mzTolerance = 1F;
    //float PrecursorMZ = 0.0F;

    protected void Page_Load(object sender, EventArgs e)
    {
        SpectrumData = new ArrayList();
        if (Request.QueryString["file"] != null)
        {
            string file_path = Request.QueryString["file"];


            //PeptideSequence = Request.QueryString["SEQ"];
            //ChargeState = Request.QueryString["CS"];
            //PrecursorMZ = float.Parse(Request.QueryString["pmz"]);

            //mzTolerance = float.Parse(WebConfigurationManager.ConnectionStrings["mzTolerance"].ConnectionString);
            if (true)//File.Exists(file_path))
            {
                //multiuser-fridendly streamreader
                //FileStream fs = File.Open(file_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
                //StreamReader sr = new StreamReader(fs);
                string lines = "";
                string strSQL;
                if (file_path.Length < 10)
                {
                    strSQL = string.Format("select spectrum from spectrum_tbl where spectrum_seq={0}", file_path);
                }
                else
                {
                    strSQL = string.Format("select spectrum from spectrum_tbl where spectrum_seq={0}", "159268");
                }
                DataSet result = DBInterface.QuerySQL2(strSQL);
                if (result != null)
                {
                    if (result.Tables[0].Rows.Count > 0)
                    {
                        lines = result.Tables[0].Rows[0].ItemArray[0].ToString();
                    }
                }

                String[] dtaLines = lines.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (String line in dtaLines)
                {
                    if (char.IsDigit(line, 0))
                    {
                        int          sperator  = line.IndexOf(" ");
                        string       mz        = line.Substring(0, sperator);
                        string       intensity = line.Substring(sperator);
                        MZintensitiy mzi       = new MZintensitiy();
                        try
                        {
                            mzi.mz = float.Parse(mz);
                            if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                            {
                                if (mzi.mz < DisplayMaxX && mzi.mz > DisplayMinX)
                                {
                                    if (mzi.mz < MinX)
                                    {
                                        MinX = mzi.mz;
                                    }
                                    if (mzi.mz > MaxX)
                                    {
                                        MaxX = mzi.mz;
                                    }
                                    mzi.intensity = float.Parse(intensity);
                                    if (mzi.intensity > MaxIntensitiy)
                                    {
                                        MaxIntensitiy = mzi.intensity;
                                    }
                                    SpectrumData.Add(mzi);
                                }
                            }
                            else
                            {
                                if (mzi.mz < MinX)
                                {
                                    MinX = mzi.mz;
                                }
                                if (mzi.mz > MaxX)
                                {
                                    MaxX = mzi.mz;
                                }
                                mzi.intensity = float.Parse(intensity);
                                if (mzi.intensity > MaxIntensitiy)
                                {
                                    MaxIntensitiy = mzi.intensity;
                                }
                                SpectrumData.Add(mzi);
                            }
                        }
                        catch
                        { }
                    }
                }

                DrawSpectrum();
            }
        }
    }
Esempio n. 3
0
    private void DoSearchInWS()
    {
        double[] NormalizedSpectrum = new double[4096];
        string[] lines = this.tbDTA.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
        if (lines.Length == 0)
        {
            lbMessage.Text = "Please input spectrum data.";
            return;
        }
        SessionID = DateTime.Now.ToString("yyyy_MM_dd");
        IndexID   = DateTime.Now.ToString("fffffff");


        //  string UploadPath = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + string.Format ("WebDta\\{0}\\",SessionID );
        //  DirectoryInfo newpath = new DirectoryInfo(UploadPath);
        //  if (!newpath.Exists)
        //  {
        //      newpath.Create();
        //  }


        //string dtaFilename = UploadPath   + IndexID + ".dta";
        //try
        //{
        //    using (StreamWriter sw = new StreamWriter(dtaFilename, true))
        //    {
        foreach (string line in lines)
        {
            //sw.WriteLine(line);
            if (char.IsDigit(line, 0))
            {
                String []    sperator  = line.Split(new string [] { " ", "\t" }, StringSplitOptions.RemoveEmptyEntries);
                string       mz        = sperator[0];
                string       intensity = sperator[1];
                MZintensitiy mzi       = new MZintensitiy();
                try
                {
                    mzi.mz        = float.Parse(mz);
                    mzi.intensity = float.Parse(intensity);

                    if (mzi.mz > NoiseCutoff)
                    {
                        double dintensity = (double)mzi.intensity;
                        NormalizedSpectrum[(int)mzi.mz] += dintensity;
                    }
                    //SpectrumData.Add(mzi);
                }
                catch (Exception ex)
                { }
            }
        }
        //      sw.Close();
        //    }
        //}
        //  catch (Exception ex)
        //{
        //      this.lbMessage.Text = string.Format ("Write dta file to server with error:{0} ",ex.ToString ());
        //  }


        //double TotalNormal = 0;
        //foreach (double mz in NormalizedSpectrum)
        //{
        //    TotalNormal += mz * mz;
        //}
        //TotalNormal = Math.Sqrt(TotalNormal);

        //for (int i = 0; i < 4096; i++)
        //{
        //    NormalizedSpectrum[i] = NormalizedSpectrum[i] / TotalNormal;
        //}

        int   slideSize   = int.Parse(this.ddlChargeState.Text);
        float PrecursorMZ = float.Parse(this.tbPrecursorMZ.Text);
        float mzTolerance = float.Parse(this.tbTolerance.Text);

        COPaWS.COPaWS     webserv       = new COPaWS.COPaWS();
        NetworkCredential objCredential = new NetworkCredential(ConfigurationSettings.AppSettings["COPaWSUser"], ConfigurationSettings.AppSettings["COPaWSPassword"]);

        webserv.Credentials = objCredential;
        COPaWS.SearchingCondition sc = new COPaWS.SearchingCondition();
        sc.bUseNoiseLibrary    = true;
        sc.bStatisticSearching = false;
        sc.bHighResolution     = false;
        sc.fPrecursorWindow    = mzTolerance;
        sc.iSlideSize          = slideSize;
        COPaWS.SearchingThreadPair tp = new COPaWS.SearchingThreadPair();
        tp.DetaDecoyScore        = float.Parse(this.tbCutoff.Text);
        tp.MatchScore            = 0.0F;
        sc.NormalSearchCondition = new COPaWS.SearchingThreadPair[] { tp };
        COPaWS.Module lib_mod = COPaWS.Module.human_heart_mitochondria;
        if (this.ddlModules.Text != null)
        {
            try
            {
                lib_mod = (COPaWS.Module)(int.Parse(this.ddlModules.Text.Substring(0, this.ddlModules.Text.IndexOf("."))) - 1);
            }
            catch (Exception ex)
            {
                lbMessage.Text = "Could not recognize the library module!";
                return;
            }
        }
        COPaWS.Module[]         Modules = new COPaWS.Module[] { lib_mod };
        COPaWS.MSPepetideInfo[] results = webserv.SearchDTA2("WebDta", SessionID, IndexID, NormalizedSpectrum, PrecursorMZ, Modules, sc, 2);
        if (results != null)
        {
            string PepIDURL    = "<a href='PeptideInfo.aspx?QType=Peptide+ID&QValue={0}' Target='_blank'>{1}</a>";
            string SpectrumURL = "<a href='MatchSpectrum.aspx?QValue={0}&SessionID={1}&ST=RUN&TaskID={2}&File={3}' Target='_blank'><img src='_image/mirror_spectrum.gif' /></a>";
            foreach (COPaWS.MSPepetideInfo mspep in results)
            {
                TableRow trResult = new TableRow();

                TableCell tcPepID  = new TableCell();
                string    strPepID = mspep.COPaPeptideID;
                tcPepID.Text            = string.Format(PepIDURL, strPepID, strPepID);
                tcPepID.HorizontalAlign = HorizontalAlign.Left;
                trResult.Cells.Add(tcPepID);

                TableCell tcPepSeq   = new TableCell();
                string    PeptideSeq = mspep.PeptideSequence;
                //string ModifiedType = mspep.ModifiedType;
                tcPepSeq.Text            = PeptideSeq;
                tcPepSeq.HorizontalAlign = HorizontalAlign.Left;
                trResult.Cells.Add(tcPepSeq);

                TableCell tcModifiedType = new TableCell();

                tcModifiedType.Text            = "";// ModifiedType;
                tcModifiedType.HorizontalAlign = HorizontalAlign.Left;
                trResult.Cells.Add(tcModifiedType);

                //TableCell tcDotProduct = new TableCell();
                //double dp = double.Parse(foundRows[i].ItemArray[1].ToString());
                //tcDotProduct.Text = string.Format("{0:F3}", dp);
                //tcDotProduct.HorizontalAlign = HorizontalAlign.Right;
                //trResult.Cells.Add(tcDotProduct);

                //TableCell tcDotBias = new TableCell();
                //double db = double.Parse(foundRows[i].ItemArray[2].ToString());
                //tcDotBias.Text = string.Format("{0:F3}", db);
                //tcDotBias.HorizontalAlign = HorizontalAlign.Right;
                //trResult.Cells.Add(tcDotBias);

                TableCell tcFscore   = new TableCell();
                double    finalScore = double.Parse(mspep.DecoyScore);// double.Parse(foundRows[i].ItemArray[3].ToString());
                tcFscore.Text            = string.Format("{0:F3}", finalScore);
                tcFscore.HorizontalAlign = HorizontalAlign.Right;
                trResult.Cells.Add(tcFscore);

                TableCell tcSpectrum = new TableCell();
                tcSpectrum.Text            = string.Format(SpectrumURL, mspep.LibSpectraSeq, IndexID, "WebDta", SessionID);
                tcSpectrum.HorizontalAlign = HorizontalAlign.Center;
                trResult.Cells.Add(tcSpectrum);

                tbPeptides.Rows.Add(trResult);
            }
            if (results.Length > 0)
            {
                lbMessage.Text = string.Format(" {0} spectra matched!", results.Length);
            }
            else
            {
                lbMessage.Text = string.Format("no spectrum was matched under your criteria, you could adjust the cutoff and try again!");
            }
        }
        else
        {
            lbMessage.Text = string.Format("no spectrum was matched under your criteria, you could adjust the cutoff and try again!");
        }
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SpectrumData = new ArrayList() ;
        if (Request.QueryString["file"] != null)
        {
            string file_path = Request.QueryString["file"];

            if (Request.QueryString["mode"] != null)
            {
                if (Request.QueryString["mode"] == "ZoomOut")
                {
                    string displayMin = Request.QueryString["xmin"];
                    string displayMax = Request.QueryString["xmax"];
                    string displayYMax = Request.QueryString["ymax"];
                    try
                    {
                        if (displayMin == null)
                            DisplayMinX = -1;
                        else
                        {
                            DisplayMinX = int.Parse(displayMin);
                            if (DisplayMinX < 0)
                                DisplayMinX = -1;

                        }

                        if (displayMax == null)
                            DisplayMaxX = -1;
                        else
                        {
                            DisplayMaxX = int.Parse(displayMax);
                            if (DisplayMaxX < 0 || DisplayMaxX <= DisplayMinX)
                                DisplayMaxX = -1;
                        }
                    }
                    catch
                    {
                        DisplayMaxX = -1;
                        DisplayMinX = -1;
                    }
                    if (DisplayMaxX != -1 && DisplayMinX != -1)
                    {
                        int Length = DisplayMaxX - DisplayMinX;

                        if (Length > 1000)
                            XBIGSEG = 250;
                        else if (Length > 500)
                            XBIGSEG = 100;
                        else if (Length > 200)
                            XBIGSEG = 50;
                        else if (Length > 100)
                            XBIGSEG = 25;
                        else if (Length > 50)
                            XBIGSEG = 10;
                        else if (Length > 20)
                            XBIGSEG = 5;
                        else
                            XBIGSEG = 2;
                    }
                    try
                    {
                        if (displayYMax == null)
                            DisplayMaxY = 100;
                        else
                        {
                            DisplayMaxY = int.Parse(displayYMax);
                            if (DisplayMaxY < 75 && DisplayMaxY > 30)
                            {
                                YBIGSEG = 10;
                            }
                            else if (DisplayMaxY <= 30 && DisplayMaxY > 20)
                            {
                                YBIGSEG = 5;
                            }
                            else if (DisplayMaxY >= 0 && DisplayMaxY <= 20)
                            {
                                YBIGSEG = 2;
                            }
                            else if (DisplayMaxY <= 100 && DisplayMaxY >= 75)
                            {
                                YBIGSEG = 25;
                            }
                            else
                            {
                                DisplayMaxY = 100;
                                YBIGSEG = 25;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DisplayMaxY = 100; ;
                    }
                    bZoomOut = true;
                }
                else
                {
                    bZoomOut = false;
                }
            }
            if (Request.QueryString["Printable"] != null)
            {
                if (Request.QueryString["Printable"] == "True")
                {
                    bShowLabel = true;
                    //HEIGHT = 250;
                }
                else
                    bShowLabel = false;
            }

            if (Request.QueryString["ShowTheory"] != null)
            {
                if (Request.QueryString["ShowTheory"] == "True")
                {
                    bShowTheory = true;

                }
                else
                    bShowTheory = false;

            }

            PeptideSequence = Request.QueryString["SEQ"];
            ChargeState = Request.QueryString["CS"];
            PrecursorMZ = float.Parse (Request.QueryString["pmz"]);

            mzTolerance = float.Parse(WebConfigurationManager.ConnectionStrings["mzTolerance"].ConnectionString);
            if (true)//File.Exists(file_path))
            {
                //multiuser-fridendly streamreader
                //FileStream fs = File.Open(file_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
                //StreamReader sr = new StreamReader(fs);
                string lines="";
                string strSQL;
                if (file_path.Length < 10)
                {
                    strSQL = string.Format("select spectrum from spectrum_tbl where spectrum_seq={0}", file_path);
                }
                else
                {
                    strSQL = string.Format("select spectrum from spectrum_tbl where spectrum_seq={0}", "159268");
                }
                 DataSet result = DBInterface.QuerySQL2(strSQL);
                 if (result != null)
                 {

                     if (result.Tables[0].Rows.Count > 0)
                     {
                         lines = result.Tables[0].Rows[0].ItemArray[0].ToString();
                     }
                 }

                 String[] dtaLines = lines.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (String line in dtaLines )
                {
                    if (char.IsDigit(line, 0))
                    {
                        string[] tokens = line.Split(new string[]{" ","\t"},StringSplitOptions.RemoveEmptyEntries );
                        string mz = tokens[0];
                        string intensity = tokens[1];
                        MZintensitiy mzi = new MZintensitiy();
                        try
                        {
                            mzi.mz = float.Parse(mz);
                            if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                            {
                                if (mzi.mz < DisplayMaxX && mzi.mz > DisplayMinX)
                                {
                                    if (mzi.mz < MinX)
                                        MinX = mzi.mz;
                                    if (mzi.mz > MaxX)
                                        MaxX = mzi.mz;
                                    mzi.intensity = float.Parse(intensity);
                                    if (mzi.intensity > MaxIntensitiy)
                                        MaxIntensitiy = mzi.intensity;
                                    SpectrumData.Add(mzi);
                                }
                            }
                            else
                            {
                                if (mzi.mz < MinX)
                                    MinX = mzi.mz;
                                if (mzi.mz > MaxX)
                                    MaxX = mzi.mz;
                                mzi.intensity = float.Parse(intensity);
                                if (mzi.intensity > MaxIntensitiy)
                                    MaxIntensitiy = mzi.intensity;
                                SpectrumData.Add(mzi);
                            }
                        }
                        catch
                        { }
                    }
                }

                DrawSpectrum();

            }
        }
    }
Esempio n. 5
0
    //string PeptideSequence = "";
    //string ChargeState = "";
    //float mzTolerance = 1F;
    //float PrecursorMZ = 0.0F;
    protected void Page_Load(object sender, EventArgs e)
    {
        SpectrumData = new ArrayList();
        if (Request.QueryString["file"] != null)
        {
            string file_path = Request.QueryString["file"];

            //PeptideSequence = Request.QueryString["SEQ"];
            //ChargeState = Request.QueryString["CS"];
            //PrecursorMZ = float.Parse(Request.QueryString["pmz"]);

            //mzTolerance = float.Parse(WebConfigurationManager.ConnectionStrings["mzTolerance"].ConnectionString);
            if (true)//File.Exists(file_path))
            {
                //multiuser-fridendly streamreader
                //FileStream fs = File.Open(file_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
                //StreamReader sr = new StreamReader(fs);
                string lines = "";
                string strSQL;
                if (file_path.Length < 10)
                {
                    strSQL = string.Format("select spectrum from spectrum_tbl where spectrum_seq={0}", file_path);
                }
                else
                {
                    strSQL = string.Format("select spectrum from spectrum_tbl where spectrum_seq={0}", "159268");
                }
                DataSet result = DBInterface.QuerySQL2(strSQL);
                if (result != null)
                {

                    if (result.Tables[0].Rows.Count > 0)
                    {
                        lines = result.Tables[0].Rows[0].ItemArray[0].ToString();
                    }
                }

                String[] dtaLines = lines.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (String line in dtaLines)
                {
                    if (char.IsDigit(line, 0))
                    {
                        int sperator = line.IndexOf(" ");
                        string mz = line.Substring(0, sperator);
                        string intensity = line.Substring(sperator);
                        MZintensitiy mzi = new MZintensitiy();
                        try
                        {
                            mzi.mz = float.Parse(mz);
                            if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                            {
                                if (mzi.mz < DisplayMaxX && mzi.mz > DisplayMinX)
                                {
                                    if (mzi.mz < MinX)
                                        MinX = mzi.mz;
                                    if (mzi.mz > MaxX)
                                        MaxX = mzi.mz;
                                    mzi.intensity = float.Parse(intensity);
                                    if (mzi.intensity > MaxIntensitiy)
                                        MaxIntensitiy = mzi.intensity;
                                    SpectrumData.Add(mzi);
                                }
                            }
                            else
                            {
                                if (mzi.mz < MinX)
                                    MinX = mzi.mz;
                                if (mzi.mz > MaxX)
                                    MaxX = mzi.mz;
                                mzi.intensity = float.Parse(intensity);
                                if (mzi.intensity > MaxIntensitiy)
                                    MaxIntensitiy = mzi.intensity;
                                SpectrumData.Add(mzi);
                            }
                        }
                        catch
                        { }
                    }
                }

                DrawSpectrum();

            }
        }
    }
Esempio n. 6
0
    private void DoSearchInWS()
    {
        double[] NormalizedSpectrum = new double[4096];
        string[] lines = this.tbDTA.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
        if (lines.Length == 0)
        {
            lbMessage.Text = "Please input spectrum data.";
            return;
        }
        SessionID = DateTime.Now.ToString("yyyy_MM_dd") ;
        IndexID = DateTime.Now.ToString("fffffff");

          //  string UploadPath = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + string.Format ("WebDta\\{0}\\",SessionID );
          //  DirectoryInfo newpath = new DirectoryInfo(UploadPath);
          //  if (!newpath.Exists)
          //  {
          //      newpath.Create();
          //  }

          //string dtaFilename = UploadPath   + IndexID + ".dta";
          //try
          //{
          //    using (StreamWriter sw = new StreamWriter(dtaFilename, true))
          //    {
            foreach (string line in lines)
            {
                //sw.WriteLine(line);
                if (char.IsDigit(line, 0))
                {
                    String [] sperator = line.Split (new string []{" ","\t"},StringSplitOptions.RemoveEmptyEntries );
                    string mz = sperator[0];
                    string intensity = sperator[1];
                    MZintensitiy mzi = new MZintensitiy();
                    try
                    {
                        mzi.mz = float.Parse(mz);
                        mzi.intensity = float.Parse(intensity);

                        if (mzi.mz > NoiseCutoff)
                        {
                            double dintensity = (double)mzi.intensity;
                            NormalizedSpectrum[(int)mzi.mz] += dintensity;
                        }
                        //SpectrumData.Add(mzi);
                    }
                    catch (Exception ex)
                    { }
                }

            }
          //      sw.Close();
          //    }
          //}
          //  catch (Exception ex)
          //{
          //      this.lbMessage.Text = string.Format ("Write dta file to server with error:{0} ",ex.ToString ());
          //  }

        //double TotalNormal = 0;
        //foreach (double mz in NormalizedSpectrum)
        //{
        //    TotalNormal += mz * mz;
        //}
        //TotalNormal = Math.Sqrt(TotalNormal);

        //for (int i = 0; i < 4096; i++)
        //{
        //    NormalizedSpectrum[i] = NormalizedSpectrum[i] / TotalNormal;
        //}

        int slideSize = int.Parse(this.ddlChargeState.Text);
        float PrecursorMZ = float.Parse(this.tbPrecursorMZ.Text);
        float mzTolerance = float.Parse(this.tbTolerance.Text);

        COPaWS.COPaWS webserv = new COPaWS.COPaWS();
        NetworkCredential objCredential = new NetworkCredential(ConfigurationSettings.AppSettings["COPaWSUser"], ConfigurationSettings.AppSettings["COPaWSPassword"]);
        webserv.Credentials = objCredential;
        COPaWS.SearchingCondition sc = new COPaWS.SearchingCondition ();
        sc.bUseNoiseLibrary = true ;
        sc.bStatisticSearching = false ;
        sc.bHighResolution = false;
        sc.fPrecursorWindow = mzTolerance ;
        sc.iSlideSize = slideSize  ;
        COPaWS.SearchingThreadPair tp = new COPaWS.SearchingThreadPair() ;
        tp.DetaDecoyScore = float.Parse (this.tbCutoff.Text );
        tp.MatchScore = 0.0F;
        sc.NormalSearchCondition = new COPaWS.SearchingThreadPair[] {tp} ;
        COPaWS.Module lib_mod = COPaWS.Module.human_heart_mitochondria ;
        if (this.ddlModules.Text != null)
        {
            try
            {
                lib_mod = (COPaWS.Module)(int.Parse(this.ddlModules.Text.Substring(0, this.ddlModules.Text.IndexOf("."))) - 1);
            }
            catch (Exception ex)
            {
                lbMessage.Text = "Could not recognize the library module!";
                return;
            }
        }
        COPaWS.Module[] Modules = new COPaWS.Module[] { lib_mod };
        COPaWS.MSPepetideInfo[] results = webserv.SearchDTA2("WebDta", SessionID, IndexID, NormalizedSpectrum, PrecursorMZ, Modules, sc, 2);
        if (results != null)
        {
            string PepIDURL = "<a href='PeptideInfo.aspx?QType=Peptide+ID&QValue={0}' Target='_blank'>{1}</a>";
            string SpectrumURL = "<a href='MatchSpectrum.aspx?QValue={0}&SessionID={1}&ST=RUN&TaskID={2}&File={3}' Target='_blank'><img src='_image/mirror_spectrum.gif' /></a>";
            foreach (COPaWS.MSPepetideInfo mspep in results)
            {
                TableRow trResult = new TableRow();

                TableCell tcPepID = new TableCell();
                string strPepID = mspep.COPaPeptideID;
                tcPepID.Text = string.Format(PepIDURL, strPepID, strPepID);
                tcPepID.HorizontalAlign = HorizontalAlign.Left;
                trResult.Cells.Add(tcPepID);

                TableCell tcPepSeq = new TableCell();
                string PeptideSeq = mspep.PeptideSequence;
                //string ModifiedType = mspep.ModifiedType;
                tcPepSeq.Text = PeptideSeq;
                tcPepSeq.HorizontalAlign = HorizontalAlign.Left;
                trResult.Cells.Add(tcPepSeq);

                TableCell tcModifiedType = new TableCell();

                tcModifiedType.Text = "";// ModifiedType;
                tcModifiedType.HorizontalAlign = HorizontalAlign.Left;
                trResult.Cells.Add(tcModifiedType);

                //TableCell tcDotProduct = new TableCell();
                //double dp = double.Parse(foundRows[i].ItemArray[1].ToString());
                //tcDotProduct.Text = string.Format("{0:F3}", dp);
                //tcDotProduct.HorizontalAlign = HorizontalAlign.Right;
                //trResult.Cells.Add(tcDotProduct);

                //TableCell tcDotBias = new TableCell();
                //double db = double.Parse(foundRows[i].ItemArray[2].ToString());
                //tcDotBias.Text = string.Format("{0:F3}", db);
                //tcDotBias.HorizontalAlign = HorizontalAlign.Right;
                //trResult.Cells.Add(tcDotBias);

                TableCell tcFscore = new TableCell();
                double finalScore = double.Parse(mspep.DecoyScore);// double.Parse(foundRows[i].ItemArray[3].ToString());
                tcFscore.Text = string.Format("{0:F3}", finalScore);
                tcFscore.HorizontalAlign = HorizontalAlign.Right;
                trResult.Cells.Add(tcFscore);

                TableCell tcSpectrum = new TableCell();
                tcSpectrum.Text = string.Format(SpectrumURL, mspep.LibSpectraSeq, IndexID, "WebDta", SessionID);
                tcSpectrum.HorizontalAlign = HorizontalAlign.Center;
                trResult.Cells.Add(tcSpectrum);

                tbPeptides.Rows.Add(trResult);
            }
            if (results.Length > 0)
                lbMessage.Text = string.Format(" {0} spectra matched!", results.Length);
            else
                lbMessage.Text = string.Format("no spectrum was matched under your criteria, you could adjust the cutoff and try again!");
        }
        else
            lbMessage.Text = string.Format("no spectrum was matched under your criteria, you could adjust the cutoff and try again!");
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SpectrumData = new ArrayList();
        if (Request.QueryString["file"] != null)
        {
            string file_path = Request.QueryString["file"];

            if (Request.QueryString["mode"] != null)
            {
                if (Request.QueryString["mode"] == "ZoomOut")
                {
                    string displayMin  = Request.QueryString["xmin"];
                    string displayMax  = Request.QueryString["xmax"];
                    string displayYMax = Request.QueryString["ymax"];
                    try
                    {
                        if (displayMin == null)
                        {
                            DisplayMinX = -1;
                        }
                        else
                        {
                            DisplayMinX = int.Parse(displayMin);
                            if (DisplayMinX < 0)
                            {
                                DisplayMinX = -1;
                            }
                        }

                        if (displayMax == null)
                        {
                            DisplayMaxX = -1;
                        }
                        else
                        {
                            DisplayMaxX = int.Parse(displayMax);
                            if (DisplayMaxX < 0 || DisplayMaxX <= DisplayMinX)
                            {
                                DisplayMaxX = -1;
                            }
                        }
                    }
                    catch
                    {
                        DisplayMaxX = -1;
                        DisplayMinX = -1;
                    }
                    if (DisplayMaxX != -1 && DisplayMinX != -1)
                    {
                        int Length = DisplayMaxX - DisplayMinX;

                        if (Length > 1000)
                        {
                            XBIGSEG = 250;
                        }
                        else if (Length > 500)
                        {
                            XBIGSEG = 100;
                        }
                        else if (Length > 200)
                        {
                            XBIGSEG = 50;
                        }
                        else if (Length > 100)
                        {
                            XBIGSEG = 25;
                        }
                        else if (Length > 50)
                        {
                            XBIGSEG = 10;
                        }
                        else if (Length > 20)
                        {
                            XBIGSEG = 5;
                        }
                        else
                        {
                            XBIGSEG = 2;
                        }
                    }
                    try
                    {
                        if (displayYMax == null)
                        {
                            DisplayMaxY = 100;
                        }
                        else
                        {
                            DisplayMaxY = int.Parse(displayYMax);
                            if (DisplayMaxY < 75 && DisplayMaxY > 30)
                            {
                                YBIGSEG = 10;
                            }
                            else if (DisplayMaxY <= 30 && DisplayMaxY > 20)
                            {
                                YBIGSEG = 5;
                            }
                            else if (DisplayMaxY >= 0 && DisplayMaxY <= 20)
                            {
                                YBIGSEG = 2;
                            }
                            else if (DisplayMaxY <= 100 && DisplayMaxY >= 75)
                            {
                                YBIGSEG = 25;
                            }
                            else
                            {
                                DisplayMaxY = 100;
                                YBIGSEG     = 25;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DisplayMaxY = 100;;
                    }
                    bZoomOut = true;
                }
                else
                {
                    bZoomOut = false;
                }
            }
            if (Request.QueryString["Printable"] != null)
            {
                if (Request.QueryString["Printable"] == "True")
                {
                    bShowLabel = true;
                    //HEIGHT = 250;
                }
                else
                {
                    bShowLabel = false;
                }
            }

            if (Request.QueryString["ShowTheory"] != null)
            {
                if (Request.QueryString["ShowTheory"] == "True")
                {
                    bShowTheory = true;
                }
                else
                {
                    bShowTheory = false;
                }
            }

            PeptideSequence = Request.QueryString["SEQ"];
            ChargeState     = Request.QueryString["CS"];
            PrecursorMZ     = float.Parse(Request.QueryString["pmz"]);

            mzTolerance = float.Parse(WebConfigurationManager.ConnectionStrings["mzTolerance"].ConnectionString);
            if (true)//File.Exists(file_path))
            {
                //multiuser-fridendly streamreader
                //FileStream fs = File.Open(file_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite );
                //StreamReader sr = new StreamReader(fs);
                string lines = "";
                string strSQL;
                if (file_path.Length < 10)
                {
                    strSQL = string.Format("select spectrum from spectrum_tbl where spectrum_seq={0}", file_path);
                }
                else
                {
                    strSQL = string.Format("select spectrum from spectrum_tbl where spectrum_seq={0}", "159268");
                }
                DataSet result = DBInterface.QuerySQL2(strSQL);
                if (result != null)
                {
                    if (result.Tables[0].Rows.Count > 0)
                    {
                        lines = result.Tables[0].Rows[0].ItemArray[0].ToString();
                    }
                }

                String[] dtaLines = lines.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (String line in dtaLines)
                {
                    if (char.IsDigit(line, 0))
                    {
                        string[]     tokens    = line.Split(new string[] { " ", "\t" }, StringSplitOptions.RemoveEmptyEntries);
                        string       mz        = tokens[0];
                        string       intensity = tokens[1];
                        MZintensitiy mzi       = new MZintensitiy();
                        try
                        {
                            mzi.mz = float.Parse(mz);
                            if (bZoomOut && DisplayMaxX != -1 && DisplayMinX != -1)
                            {
                                if (mzi.mz < DisplayMaxX && mzi.mz > DisplayMinX)
                                {
                                    if (mzi.mz < MinX)
                                    {
                                        MinX = mzi.mz;
                                    }
                                    if (mzi.mz > MaxX)
                                    {
                                        MaxX = mzi.mz;
                                    }
                                    mzi.intensity = float.Parse(intensity);
                                    if (mzi.intensity > MaxIntensitiy)
                                    {
                                        MaxIntensitiy = mzi.intensity;
                                    }
                                    SpectrumData.Add(mzi);
                                }
                            }
                            else
                            {
                                if (mzi.mz < MinX)
                                {
                                    MinX = mzi.mz;
                                }
                                if (mzi.mz > MaxX)
                                {
                                    MaxX = mzi.mz;
                                }
                                mzi.intensity = float.Parse(intensity);
                                if (mzi.intensity > MaxIntensitiy)
                                {
                                    MaxIntensitiy = mzi.intensity;
                                }
                                SpectrumData.Add(mzi);
                            }
                        }
                        catch
                        { }
                    }
                }

                DrawSpectrum();
            }
        }
    }