Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string SamplePath = WebConfigurationManager.ConnectionStrings["SampleData"].ConnectionString;

        if (Directory.Exists(SamplePath) && ddlSamples.Items.Count == 0)
        {
            string[] Files = Directory.GetFiles(SamplePath);
            foreach (string samplefile in Files)
            {
                string FileName = samplefile.Substring(samplefile.LastIndexOf("\\") + 1);
                this.ddlSamples.Items.Add(FileName);
            }
        }
        if (!Page.IsPostBack)
        {
            ddlModules.Items.Clear();
            try
            {
                COPaWS.COPaWS     ws            = new COPaWS.COPaWS();
                NetworkCredential objCredential = new NetworkCredential(ConfigurationSettings.AppSettings["COPaWSUser"], ConfigurationSettings.AppSettings["COPaWSPassword"]);
                ws.Credentials = objCredential;
                string[] Mods = ws.GetLibraryModules();
                foreach (string mod in Mods)
                {
                    this.ddlModules.Items.Add(mod);
                }
                this.ddlModules.Text = this.ddlModules.Items[0].Text;
            }
            catch (Exception ex)
            {
                this.lbMessage.Text = "Open the COPa Web Service with error. Please contact with COPa Library!";
            }
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string queryShow = Request.QueryString["showInfo"];

        NoInfo = queryShow;

        if (NoInfo == "T")
        { // collapse
            informationShow.Text = @"<div id='helpNote' class='collapse'>";
            informationBtn.Text  = @"<button type='button' class='close button collapsed' data-toggle='collapse' data-target='#helpNote'>&times;</button>";
        }
        else
        {
            informationShow.Text = @"<div id='helpNote' class='collapse in'>";
            informationBtn.Text  = @"<button type='button' class='close button' data-toggle='collapse' data-target='#helpNote'>&times;</button>";
        }

        cbUseDefault.Attributes.Add("onclick", "return cbevent();");
        cbUseURL.Attributes.Add("onclick", "return UsingURL();");
        cbHighResolution.Attributes.Add("onclick", "return HighResolution();");
        string strMsg = Request.QueryString["MSG"];

        if (strMsg != "" && strMsg != null)
        {
            this.lbReportError.Text = "No report availabe for your query!";
        }
        //task ID was not found in the task_seq table
        if (cbUseURL.Checked)
        {
            this.InputFile1.Style.Remove("display");
            this.InputFile1.Style.Add("display", "none");
            this.URLPanel.Style.Remove("display");
            this.URLPanel.Style.Add("display", "block");
            //call url panel and disable file browse panel
        }
        if (!cbUseDefault.Checked)
        {
            this.ParameterPanel.Style.Remove("display");
            this.ParameterPanel.Style.Add("display", "block");
            //call in detailed settings panel
        }

        //btUpload.Attributes.Add("onclick", "return ShowProgress();");
        if (!Page.IsPostBack)
        {
            this.ddlModels.Items.Clear();
            COPaWS.COPaWS     ws            = new COPaWS.COPaWS();
            NetworkCredential objCredential = new NetworkCredential(ConfigurationSettings.AppSettings["COPaWSUser"], ConfigurationSettings.AppSettings["COPaWSPassword"]);
            ws.Credentials = objCredential;
            string[] Mods = ws.GetLibraryModules();
            foreach (string mod in Mods)
            {
                this.ddlModels.Items.Add(mod);
            }
            this.ddlModels.Text = this.ddlModels.Items[0].Text;
            //initializing dropdown menu
        }
    }
Exemplo n.º 3
0
    void UpdateSearchingCondition(string TaskID, float confidence, int distinctPeptides, int UniquePeptides)
    {
        string   scLocation = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + "\\searchcondition.xml";
        FileInfo fi         = new FileInfo(scLocation);

        if (fi.Exists)
        {
            SearchingParameters mySP = new SearchingParameters(scLocation);
            mySP.ConfidenceLevel = confidence;
            mySP.DistinctPeptide = distinctPeptides;
            mySP.UniquePeptide   = UniquePeptides;
            mySP.SaveSettings();
        }
        COPaWS.COPaWS copaws = new COPaWS.COPaWS();
        if (copaws.ChangeCreteria(TaskID, this.lbmzML.Text.Replace("<br/>", "\r\n")))
        {
            Response.Redirect(string.Format("Report.aspx?TaskID={0}", TaskID));
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string queryShow = Request.QueryString["showInfo"];
        NoInfo = queryShow;

        if (NoInfo == "T")
        { // collapse
            informationShow.Text = @"<div id='helpNote' class='collapse'>";
            informationBtn.Text = @"<button type='button' class='close button collapsed' data-toggle='collapse' data-target='#helpNote'>&times;</button>";
        }
        else
        {
            informationShow.Text = @"<div id='helpNote' class='collapse in'>";
            informationBtn.Text = @"<button type='button' class='close button' data-toggle='collapse' data-target='#helpNote'>&times;</button>";
        }

        cbUseDefault.Attributes.Add("onclick", "return cbevent();");
        cbUseURL.Attributes.Add("onclick", "return UsingURL();");
        cbHighResolution.Attributes.Add("onclick", "return HighResolution();");
        string strMsg = Request.QueryString["MSG"];
        if (strMsg != "" && strMsg != null)
            this.lbReportError.Text = "No report availabe for your query!";
        //task ID was not found in the task_seq table
        if (cbUseURL.Checked)
        {
            this.InputFile1.Style.Remove("display");
            this.InputFile1.Style.Add("display", "none");
            this.URLPanel.Style.Remove("display");
            this.URLPanel.Style.Add("display", "block");
            //call url panel and disable file browse panel
        }
        if (!cbUseDefault.Checked)
        {
            this.ParameterPanel.Style.Remove("display");
            this.ParameterPanel.Style.Add("display", "block");
            //call in detailed settings panel
        }

        //btUpload.Attributes.Add("onclick", "return ShowProgress();");
        if (!Page.IsPostBack)
        {

            this.ddlModels.Items.Clear();
            COPaWS.COPaWS ws = new COPaWS.COPaWS();
            NetworkCredential objCredential = new NetworkCredential(ConfigurationSettings.AppSettings["COPaWSUser"], ConfigurationSettings.AppSettings["COPaWSPassword"]);
            ws.Credentials = objCredential;
            string[] Mods = ws.GetLibraryModules();
            foreach (string mod in Mods)
            {
                this.ddlModels.Items.Add(mod);
            }
            this.ddlModels.Text = this.ddlModels.Items[0].Text;
            //initializing dropdown menu
        }
    }
Exemplo n.º 5
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!");
        }
    }
Exemplo n.º 6
0
    private void ResetReport()
    {
        //string strOldFile = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + "\\Result.txt";
        //string strBackFile = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + "\\Result.txt.back";
        //string strFreqFile = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + "\\Result.txt.Freq";
        float threshold = 0.0f;

        try
        {
            threshold = float.Parse(this.tbThreshold.Text);
            if (threshold < 0 || threshold > 100)
            {
                lbMessage.Text = "Please input a number between 1 and 100.";
                return;
            }
        }
        catch (Exception ex)
        {
            lbMessage.Text = "Please input a number.";
            return;
        }
        COPaWS.COPaWS copaws = new COPaWS.COPaWS();
        if (copaws.ChangeThreshold(TaskID, this.lbmzML.Text.Replace("<br/>", "\r\n"), threshold))
        {
            Response.Redirect(string.Format("Report.aspx?TaskID={0}", TaskID));
        }
        // string strNewFreqFile = strFreqFile + ".back";
        // FileInfo fi = new FileInfo(strFreqFile);
        // fi.CopyTo(strNewFreqFile,true );
        // StreamWriter freqsw = new StreamWriter(strFreqFile, false);
        // StreamReader freqsr = new StreamReader(strNewFreqFile);
        // string line = "";
        // float newPossiblity = 0.0f;
        // try
        // {
        //     while ((line = freqsr.ReadLine()) != null)
        //     {
        //         if (line.StartsWith("H"))
        //         {
        //             string[] tokens = line.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
        //             string miu1 = tokens[1];
        //             string sigma1 = tokens[2];
        //             string miu2 = tokens[3];
        //             string sigma2 = tokens[4];
        //             string strthreshold = threshold.ToString();
        //             string falseNumber = tokens[6];
        //             string trueNumber = tokens[7];
        //             freqsw.WriteLine(string.Format("H|{0}|{1}|{2}|{3}|{4}|{5}|{6}|", miu1, sigma1, miu2, sigma2, strthreshold, falseNumber, trueNumber));
        //             newPossiblity = getPossiblity(miu1, sigma1, miu2, sigma2, falseNumber, trueNumber, threshold);

        //         }
        //         else
        //             freqsw.WriteLine(line);
        //     }
        // }
        // catch (Exception ex)
        // {
        //     DBInterface.LogEvent(ex.ToString(),System.Diagnostics.EventLogEntryType.Error );
        // }
        // finally
        // {

        //     freqsw.Close();
        //     freqsr.Close();
        // }
        // //delte the old file
        // StreamWriter sw = new StreamWriter(strOldFile, false);
        // StreamReader sr = new StreamReader(strBackFile);
        // try
        // {
        //     while ((line = sr.ReadLine()) != null)
        //     {
        //         string[] tokens = line.Split(new string[] { "|" }, StringSplitOptions.None);
        //         if (tokens[0] == "Y")
        //         {
        //             string peptideID = tokens[2];
        //             if ((float.Parse(tokens[10])) * 100 >= threshold)
        //             {
        //                 sw.WriteLine(line);
        //             }

        //         }
        //     }
        // }
        // catch (Exception ex)
        // {
        //     DBInterface.LogEvent(ex.ToString(), System.Diagnostics.EventLogEntryType.Error);
        // }
        // finally
        // {
        //     sr.Close();
        //     sw.Close();
        // }
        //string sc = string.Format("Threshold set at {0}, peptide accuracy rate is {1}%.", threshold/100,newPossiblity );
        //int NeedDistinctPeptide = UpdateSearchConditionFile(TaskID, newPossiblity);
        //CreateReport(TaskID, this.lbmzML.Text.Replace("<br/>", "\r\n"), this.lbSearchingModule.Text, sc,NeedDistinctPeptide );
    }
Exemplo n.º 7
0
    void UpdateSearchingCondition(string TaskID, float confidence, int distinctPeptides, int UniquePeptides)
    {
        string scLocation = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + "\\searchcondition.xml";
        FileInfo fi = new FileInfo(scLocation);

        if (fi.Exists)
        {
            SearchingParameters mySP = new SearchingParameters(scLocation);
            mySP.ConfidenceLevel = confidence;
            mySP.DistinctPeptide = distinctPeptides;
            mySP.UniquePeptide = UniquePeptides;
            mySP.SaveSettings();
        }
        COPaWS.COPaWS copaws = new COPaWS.COPaWS();
        if (copaws.ChangeCreteria(TaskID, this.lbmzML.Text.Replace("<br/>", "\r\n")))
            Response.Redirect(string.Format("Report.aspx?TaskID={0}", TaskID));
    }
Exemplo n.º 8
0
    private void ResetReport()
    {
        //string strOldFile = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + "\\Result.txt";
        //string strBackFile = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + "\\Result.txt.back";
        //string strFreqFile = WebConfigurationManager.ConnectionStrings["UploadPath"].ConnectionString + TaskID + "\\Result.txt.Freq";
        float threshold = 0.0f;
        try
        {
            threshold = float.Parse(this.tbThreshold.Text);
            if (threshold < 0 || threshold > 100)
            {
                lbMessage.Text = "Please input a number between 1 and 100.";
                return;
            }
        }
        catch (Exception ex)
        {
            lbMessage.Text = "Please input a number.";
            return;
        }
        COPaWS.COPaWS copaws = new COPaWS.COPaWS();
        if (copaws.ChangeThreshold(TaskID, this.lbmzML.Text.Replace("<br/>", "\r\n"), threshold))
            Response.Redirect(string.Format("Report.aspx?TaskID={0}", TaskID));
        // string strNewFreqFile = strFreqFile + ".back";
        // FileInfo fi = new FileInfo(strFreqFile);
        // fi.CopyTo(strNewFreqFile,true );
        // StreamWriter freqsw = new StreamWriter(strFreqFile, false);
        // StreamReader freqsr = new StreamReader(strNewFreqFile);
        // string line = "";
        // float newPossiblity = 0.0f;
        // try
        // {
        //     while ((line = freqsr.ReadLine()) != null)
        //     {
        //         if (line.StartsWith("H"))
        //         {
        //             string[] tokens = line.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
        //             string miu1 = tokens[1];
        //             string sigma1 = tokens[2];
        //             string miu2 = tokens[3];
        //             string sigma2 = tokens[4];
        //             string strthreshold = threshold.ToString();
        //             string falseNumber = tokens[6];
        //             string trueNumber = tokens[7];
        //             freqsw.WriteLine(string.Format("H|{0}|{1}|{2}|{3}|{4}|{5}|{6}|", miu1, sigma1, miu2, sigma2, strthreshold, falseNumber, trueNumber));
        //             newPossiblity = getPossiblity(miu1, sigma1, miu2, sigma2, falseNumber, trueNumber, threshold);

        //         }
        //         else
        //             freqsw.WriteLine(line);
        //     }
        // }
        // catch (Exception ex)
        // {
        //     DBInterface.LogEvent(ex.ToString(),System.Diagnostics.EventLogEntryType.Error );
        // }
        // finally
        // {

        //     freqsw.Close();
        //     freqsr.Close();
        // }
        // //delte the old file
        // StreamWriter sw = new StreamWriter(strOldFile, false);
        // StreamReader sr = new StreamReader(strBackFile);
        // try
        // {
        //     while ((line = sr.ReadLine()) != null)
        //     {
        //         string[] tokens = line.Split(new string[] { "|" }, StringSplitOptions.None);
        //         if (tokens[0] == "Y")
        //         {
        //             string peptideID = tokens[2];
        //             if ((float.Parse(tokens[10])) * 100 >= threshold)
        //             {
        //                 sw.WriteLine(line);
        //             }

        //         }
        //     }
        // }
        // catch (Exception ex)
        // {
        //     DBInterface.LogEvent(ex.ToString(), System.Diagnostics.EventLogEntryType.Error);
        // }
        // finally
        // {
        //     sr.Close();
        //     sw.Close();
        // }
        //string sc = string.Format("Threshold set at {0}, peptide accuracy rate is {1}%.", threshold/100,newPossiblity );
        //int NeedDistinctPeptide = UpdateSearchConditionFile(TaskID, newPossiblity);
        //CreateReport(TaskID, this.lbmzML.Text.Replace("<br/>", "\r\n"), this.lbSearchingModule.Text, sc,NeedDistinctPeptide );
    }
Exemplo n.º 9
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!");
    }
Exemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string SamplePath = WebConfigurationManager.ConnectionStrings["SampleData"].ConnectionString;

        if (Directory.Exists(SamplePath) && ddlSamples.Items.Count ==0)
        {
            string[] Files = Directory.GetFiles(SamplePath);
            foreach (string samplefile in Files)
            {
                string FileName = samplefile.Substring(samplefile.LastIndexOf("\\")+1);
                this.ddlSamples.Items.Add(FileName);

            }
        }
        if (!Page.IsPostBack)
        {
            ddlModules.Items.Clear();
            try
            {
                COPaWS.COPaWS ws = new COPaWS.COPaWS();
                NetworkCredential objCredential = new NetworkCredential(ConfigurationSettings.AppSettings["COPaWSUser"], ConfigurationSettings.AppSettings["COPaWSPassword"]);
                ws.Credentials = objCredential;
                string[] Mods = ws.GetLibraryModules();
                foreach (string mod in Mods)
                {
                    this.ddlModules.Items.Add(mod);
                }
                this.ddlModules.Text = this.ddlModules.Items[0].Text;
            }
            catch (Exception ex)
            {
                this.lbMessage.Text = "Open the COPa Web Service with error. Please contact with COPa Library!";
            }
        }
    }