示例#1
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!");
        }
    }
示例#2
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!");
    }