示例#1
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            ArrayList fileList = new ArrayList();
            fileList = GetFileList(tvSelDirs, tbSrcDir.Text.Replace("\\", "/"));
            if (fileList.Count == 0)
            {
                MessageBox.Show("please select input files");
                return;
            }
            List<string> allowedFormat = new List<string>(new string[] { "mzXML", "mzxml", "mzML", "mzml", "mgf", "MGF", "MS2", "ms2" });

            // run directag, allow write high quality spectra by directag, allow add identification label and write unidentified spectra
            if (cbAssessement.Checked)  
            {
                # region  Error checking
                if (tbSrcDir.Text.Equals(string.Empty))
                {
                    MessageBox.Show("Error: Please select input file directory!");
                    return;
                }
                if (tbOutputDir.Text.Equals(string.Empty) || !Directory.Exists(tbOutputDir.Text))
                {
                    MessageBox.Show("Error: Please select correct output directory!");
                    return;
                }
                //List<string> allowedFormat = new List<string>(new string[] { "mzXML", "mzxml", "mzML", "mzml", "mgf", "MGF", "MS2", "ms2" });
                if (cbRemoval.Checked)
                {                    
                    if (!allowedFormat.Exists(element => element.Equals(cmbOutputFileFormat.Text)))
                    {
                        MessageBox.Show("Please select proper output format");
                        return;
                    }
                    if (Convert.ToInt32(tbRemovalCutoff.Text) <= 0 || Convert.ToInt32(tbRemovalCutoff.Text) > 100)
                    {
                        MessageBox.Show("Please specify proper cutoff between 0 and 100!");
                        return;
                    }
                    if (tbOutFileNameSuffixForRemoval.Text.Equals(string.Empty))
                    {
                        MessageBox.Show("Please specify output file suffix!");
                        return;
                    }
                }
                if (cbRecovery.Checked)
                {
                    if (tbPepXMLDir.Text.Equals(string.Empty))
                    {
                        MessageBox.Show("Error: Please specify pepXML file directory!");
                        return;
                    }
                    if (tbDBFile.Text.Equals(string.Empty))
                    {
                        MessageBox.Show("Error: Please specify database file!");
                        return;
                    }
                    if (tbMaxFDR.Text.Equals(string.Empty))
                    {
                        MessageBox.Show("Error: Please specify FDR!");
                        return;
                    }
                    double fdr = Convert.ToDouble(tbMaxFDR.Text);
                    if (fdr <= 0 || fdr >= 100)
                    {
                        MessageBox.Show("Please input proper FDR between 0 and 100");
                        return;
                    }
                    if (cmbScoreInfo.Text.Equals(string.Empty))
                    {
                        MessageBox.Show("Error: Please specify database search score weights!");
                        return;
                    }
                    if (tbOutFileNameSuffixForRecovery.Text.Equals(string.Empty))
                    {
                        MessageBox.Show("Error: Please specify output file suffix!");
                        return;
                    }
                    if (cbWriteOutUnidentifiedSpectra.Checked)
                    {
                        if (Convert.ToInt32(tbRecoveryCutoff.Text) <= 0 || Convert.ToInt32(tbRecoveryCutoff.Text) > 100)
                        {
                            MessageBox.Show("Please specify proper recovery cutoff between 0 and 100!");
                            return;
                        }                        
                        if (!allowedFormat.Exists(element => element.Equals(cmbRecoveryOutFormat.Text)))
                        {
                            MessageBox.Show("Please select proper output format");
                            return;
                        }
                    }
                }

                # endregion

                RunDirecTagAction directagAction = new RunDirecTagAction();
                directagAction.InFileList = fileList;
                directagAction.OutMetricsSuffix = tbOutputMetricsSuffix.Text;
                directagAction.OutputDir = tbOutputDir.Text;
                if (cbRemoval.Checked)
                {
                    directagAction.OutputFilenameSuffixForRemoval = tbOutFileNameSuffixForRemoval.Text;
                    directagAction.OutputFormat = cmbOutputFileFormat.Text;
                }
                if (cbRecovery.Checked)
                {
                    directagAction.AddLabel = true;
                    //directagAction.IdpickerCfg = idpickerCfg;
                    directagAction.IdpickerCfg = getIdpickerCfg();
                    directagAction.OutputFilenameSuffixForRecovery = tbOutFileNameSuffixForRecovery.Text;
                    if (cbWriteOutUnidentifiedSpectra.Checked)
                    {
                        directagAction.WriteOutUnidentifedSpectra = true;
                        directagAction.RecoveryCutoff = Convert.ToSingle(tbRecoveryCutoff.Text) / 100.0f;
                        directagAction.RecoveryOutFormat = cmbRecoveryOutFormat.Text;
                    }
                }

                if ( cbAdjustScoreByGroup.Checked)
                {
                    directagAction.AdjustScanRankerScoreByGroup = true;
                }

                string outputDir = tbOutputDir.Text;
                Directory.SetCurrentDirectory(outputDir);

                if (Workspace.statusForm == null || Workspace.statusForm.IsDisposed)
                {
                    Workspace.statusForm = new TextBoxForm(this);
                    Workspace.statusForm.Show();
                    Application.DoEvents();
                }

                // run directag 
                bgDirectagRun.WorkerSupportsCancellation = true;
                bgDirectagRun.RunWorkerCompleted += bgDirectagRun_RunWorkerCompleted;
                DirecTagInfo directagInfo = new DirecTagInfo();
                bulidAndWriteDirectagInfo(directagInfo);
                //Thread t = new Thread(delegate() { directagAction.RunDirectag(); });
                //t.Start();
                //t.Join();
                //bgDirectagRun.ProgressChanged += bgDirectagRun_ProgressChanged;
                bgDirectagRun.RunWorkerAsync(directagAction);

            }
示例#2
0
 /// <summary>
 ///  write cfg file for DirecTag
 /// </summary>
 private void bulidAndWriteDirectagInfo(DirecTagInfo directagInfo)
 {
     directagInfo.NumChargeStates = Convert.ToInt32(tbNumChargeStates.Text);
     directagInfo.FragmentMzTolerance = Convert.ToSingle(tbFragmentTolerance.Text);
     directagInfo.IsotopeMzTolerance = Convert.ToSingle(tbFragmentTolerance.Text) / 2;
     directagInfo.TagLength = Convert.ToInt32(tbTagLength.Text);
     directagInfo.PrecursorMzTolerance = Convert.ToSingle(tbPrecursorTolerance.Text);
     directagInfo.UseAvgMassOfSequences = (rbAverage.Checked) ? 1 : 0;
     directagInfo.UseChargeStateFromMS = (cbUseChargeStateFromMS.Checked) ? 1 : 0;
     directagInfo.UseMultipleProcessors = (cbUseMultipleProcessors.Checked) ? 1 : 0;
     directagInfo.StaticMods = tbStaticMods.Text;
      
     directagInfo.WriteOutTags = (cbWriteOutTags.Checked) ? 1 : 0;
     directagInfo.WriteScanRankerMetrics = (cbAssessement.Checked) ? 1 : 0;
     //directagInfo.ScanRankerMetricsFileName; // given in cmd line
     directagInfo.WriteHighQualSpectra = (cbRemoval.Checked) ? 1 : 0;
     //directagInfo.HighQualSpecFileName = fileBaseName + tbOutFileNameSuffixForRemoval.Text + ".txt"; //given in cmd line
     directagInfo.OutputFormat = cmbOutputFileFormat.Text;
     directagInfo.HighQualSpecCutoff = Convert.ToSingle(tbRemovalCutoff.Text) / 100.0f;
     
     directagInfo.WriteDirectagCfg();
 }