public static ScanEventReactionCollection ScanEvents(IRawDataPlus rawFile, ScanIndex index) { if (index.AnalysisOrder == MSOrderType.Ms) { Console.WriteLine("This is not an Orbitrap file. Skipping reaction event extraction."); return(null); } else { rawFile.SelectMsData(); ScanEventReactionCollection events = new ScanEventReactionCollection(); Log.Information("Extracting scan events"); ProgressIndicator P = new ProgressIndicator(index.ScanEnumerators[MSOrderType.Any].Length, "Extracting reaction events"); P.Start(); foreach (int scan in index.ScanEnumerators[index.AnalysisOrder]) { events.Add(scan, rawFile.GetScanEventForScanNumber(scan).GetReaction(0)); P.Update(); } P.Done(); return(events); } }
public RawFileViz(string rawFile) { this.InitializeComponent(); #region initialize fields and containers nextScanButton.Text = Char.ConvertFromUtf32(0x2192); previousScanButton.Text = Char.ConvertFromUtf32(0x2190); rawFileThreadManager = RawFileReaderFactory.CreateThreadManager(rawFile); RawData = rawFileThreadManager.CreateThreadAccessor(); RawData.SelectMsData(); TotalNumScans = RawData.RunHeaderEx.SpectraCount; FirstScan = RawData.RunHeader.FirstSpectrum; LastScan = RawData.RunHeader.LastSpectrum; currentScan = FirstScan; TotalTime = RawData.RunHeader.EndTime; this.Text = "ParseDataViz - " + RawData.FileName; totalScansLabel.Text = String.Format("/ {0}", TotalNumScans); splitContainer1.SplitterDistance = this.Size.Width - 300; UpdateChromatogramData(); InitializeChromatogramPlot(); ChroMsLevelComboBox.SelectedIndex = 0; initializeMassSpecData(); initializeMassSpectrum(); scanNumber.Text = FirstScan.ToString(); y = 0; x = 1; #endregion //#region initial chromatogram this.plotViewChromatogram.Model = chromatogram; UpdateChromatogramPlot(); }
public static ScanEventReactionCollection ScanEvents(IRawDataPlus rawFile, ScanIndex index) { rawFile.SelectMsData(); ScanEventReactionCollection events = new ScanEventReactionCollection(); Log.Information("Extracting scan events"); ProgressIndicator P = new ProgressIndicator(index.ScanEnumerators[MSOrderType.Any].Length, "Extracting reaction events"); P.Start(); foreach (int scan in index.ScanEnumerators[index.AnalysisOrder]) { events.Add(scan, rawFile.GetScanEventForScanNumber(scan).GetReaction(0)); P.Update(); } P.Done(); return(events); }
static int DoStuff(ArgumentParser.LogDumpOptions opts) { List <string> files = new List <string>(); if (opts.InputFiles.Count() > 0) // did the user give us a list of files? { List <string> problems = new List <string>(); files = opts.InputFiles.ToList(); // check if the list provided contains only .raw files foreach (string file in files) { if (!file.EndsWith(".raw", StringComparison.OrdinalIgnoreCase)) { problems.Add(file); } } if (problems.Count() == 1) { Console.WriteLine("\nERROR: {0} does not appear to be a .raw file. Invoke '>RawTools --help' if you need help.", problems.ElementAt(0)); Log.Error("Invalid file provided: {0}", problems.ElementAt(0)); return(1); } if (problems.Count() > 1) { Console.WriteLine("\nERROR: The following {0} files do not appear to be .raw files. Invoke '>RawTools --help' if you need help." + "\n\n{1}", problems.Count(), String.Join("\n", problems)); Log.Error("Invalid files provided: {0}", String.Join(" ", problems)); return(1); } Log.Information("Files to be processed, provided as list: {0}", String.Join(" ", files)); } else // did the user give us a directory? { if (Directory.Exists(opts.InputDirectory)) { files = Directory.GetFiles(opts.InputDirectory, "*.*", SearchOption.TopDirectoryOnly) .Where(s => s.EndsWith(".raw", StringComparison.OrdinalIgnoreCase)).ToList(); } else { Console.WriteLine("ERROR: The provided directory does not appear to be valid."); Log.Error("Invalid directory provided: {0}", opts.InputDirectory); return(1); } Log.Information("Files to be processed, provided as directory: {0}", String.Join(" ", files)); } Console.WriteLine(); foreach (var file in files) { Console.WriteLine(Path.GetFileName(file)); Console.WriteLine("----------------------------------------"); using (IRawDataPlus rawFile = RawFileReaderFactory.ReadFile(file)) { rawFile.SelectMsData(); var numberOfLogs = rawFile.GetStatusLogEntriesCount(); var logInfo = rawFile.GetStatusLogHeaderInformation(); string logName = file + ".INST_LOG.txt"; Dictionary <int, ISingleValueStatusLog> log = new Dictionary <int, ISingleValueStatusLog>(); ProgressIndicator P = new ProgressIndicator(logInfo.Count(), "Preparing log data"); P.Start(); for (int i = 0; i < logInfo.Count(); i++) { log.Add(i, rawFile.GetStatusLogAtPosition(i)); P.Update(); } P.Done(); using (StreamWriter f = new StreamWriter(logName)) { P = new ProgressIndicator(numberOfLogs, $"Writing log"); P.Start(); f.Write("Time\t"); foreach (var x in logInfo) { f.Write(x.Label + "\t"); } f.Write("\n"); for (int i = 0; i < numberOfLogs; i++) { f.Write($"{log[0].Times[i]}\t"); for (int j = 0; j < logInfo.Length; j++) { try { f.Write("{0}\t", log[j].Values[i]); } catch (Exception) { f.Write("\t"); } } f.Write("\n"); P.Update(); } P.Done(); } } Console.WriteLine("\n"); } return(0); }
public static void WriteToDisk(WorkFlows.WorkflowParameters opts) { List <string> files = new List <string>(); Console.WriteLine(); Console.WriteLine("Writing log files"); foreach (var file in files) { Console.WriteLine(Path.GetFileName(file)); Console.WriteLine("----------------------------------------"); using (IRawDataPlus rawFile = RawFileReaderFactory.ReadFile(file)) { rawFile.SelectMsData(); var numberOfLogs = rawFile.GetStatusLogEntriesCount(); var logInfo = rawFile.GetStatusLogHeaderInformation(); string logName = file + ".INST_LOG.txt"; Dictionary <int, ISingleValueStatusLog> log = new Dictionary <int, ISingleValueStatusLog>(); ProgressIndicator P = new ProgressIndicator(logInfo.Count(), "Preparing log data"); P.Start(); for (int i = 0; i < logInfo.Count(); i++) { log.Add(i, rawFile.GetStatusLogAtPosition(i)); P.Update(); } P.Done(); using (StreamWriter f = new StreamWriter(logName)) { P = new ProgressIndicator(numberOfLogs, $"Writing log"); P.Start(); f.Write("Time\t"); foreach (var x in logInfo) { f.Write(x.Label + "\t"); } f.Write("\n"); for (int i = 0; i < numberOfLogs; i++) { f.Write($"{log[0].Times[i]}\t"); for (int j = 0; j < logInfo.Length; j++) { try { f.Write("{0}\t", log[j].Values[i]); } catch (Exception) { f.Write("\t"); } } f.Write("\n"); P.Update(); } P.Done(); } } Console.WriteLine("\n"); } }