static void Main(string[] args) { if (args.Length == 0) { MainForm mf = new MainForm(); //mf.ShowDialog(); return; } FileInfo file; file = new FileInfo(args[0]); RawReaderParams readerParams = new RawReaderParams(); readerParams.LoadDefaults(); Reader reader = new Reader(readerParams); List <MSLight> allSpectra = reader.GetSpectra(file.FullName, new List <int>(), false); if (readerParams.ExtractMS1) { List <MSLight> msPrint = allSpectra.FindAll(a => a.ActivationType.Equals("")); SpectraPrinter.PrintFile(file, msPrint, ".ms1", readerParams); } if (readerParams.ExtractMS2) { List <MSLight> msPrint = allSpectra.FindAll(a => !a.ActivationType.Equals("")); SpectraPrinter.PrintFile(file, msPrint, ".ms2", readerParams); } }
private void buttonGO_Click(object sender, EventArgs e) { if (!Directory.Exists(textBoxInputDirectory.Text)) { MessageBox.Show("Please enter a valid directory"); return; } if (!checkBoxMS1.Checked && !checkBoxMS2.Checked && !checkBoxMGF.Checked) { MessageBox.Show("Please enter at least one valid output format."); return; } buttonGO.Text = "Working"; this.Update(); DirectoryInfo di = new DirectoryInfo(textBoxInputDirectory.Text); List <FileInfo> rawFiles = di.GetFiles("*.raw").ToList(); progressBar1.Value = 0; this.Update(); RawReaderParams rawReaderParams = CaptureParamsFromScreen(); double fileCounter = 0; foreach (FileInfo rawFile in rawFiles) { try { Console.WriteLine("Processing file " + rawFile.Name); Reader r = new Reader(rawReaderParams); List <MSLight> theSpectra = r.GetSpectra(rawFile.FullName, new List <int>(), false); if (theSpectra.Count == 0) { WriteMessageToLog(di, "No mass spectra found in file : " + rawFile.Name); } else { if (rawReaderParams.ExtractMS1) { List <MSLight> ms2Print = theSpectra.FindAll(a => a.ZLines.Count == 0); SpectraPrinter.PrintFile(rawFile, ms2Print, ".ms1", rawReaderParams); } //MS2 and MS3 need to be revised to work with MS3. if (rawReaderParams.ExtractMS2) { List <MSLight> ms2Print = theSpectra.FindAll(a => a.ZLines.Count > 0); SpectraPrinter.PrintFile(rawFile, ms2Print, ".ms2", rawReaderParams); } if (rawReaderParams.ExtractMS3) { List <MSLight> ms3Print = theSpectra.FindAll(a => a.ZLines.Count > 0); SpectraPrinter.PrintFile(rawFile, ms3Print, ".ms3", rawReaderParams); } if (checkBoxMGF.Checked) { List <MSLight> ms2Print = theSpectra.FindAll(a => a.ZLines.Count > 0); List <MSUltraLight> ms22 = ms2Print.Select(a => new MSUltraLight(a, -1)).ToList(); WriteAsMGF(ms22, rawFile.FullName + ".mgf"); } } fileCounter++; progressBar1.Value = (int)((fileCounter / (double)rawFiles.Count()) * 100); this.Update(); } catch (Exception e2) { Console.WriteLine("Problem on file : " + rawFile.Name + "\n" + e2.Message); WriteMessageToLog(di, "Problem on file : " + rawFile.Name + "\n" + e2.Message); } } buttonGO.Text = "GO !"; this.Update(); }