public static void TestReadRaw() { try { var dataFilePath = @"..\..\Data\Angiotensin_AllScans.raw"; var reader = new pwiz.ProteowizardWrapper.MSDataFileReader(dataFilePath); var isABSciexFile = reader.IsABFile; var isThermoFile = reader.IsThermoFile; Console.WriteLine(); Console.WriteLine(System.IO.Path.GetFileName(dataFilePath) + " IsABSciexFile: " + isABSciexFile); Console.WriteLine(System.IO.Path.GetFileName(dataFilePath) + " IsThermoFile: " + isThermoFile); for (var targetIndex = 1; targetIndex < reader.SpectrumCount; targetIndex *= 2) { var spectrum = reader.GetSpectrum(targetIndex); Console.WriteLine("Spectrum at index {0,-4} is scan {1,-45} with {2,4} points", targetIndex, spectrum.NativeId, spectrum.Mzs.Length); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
public MzRun(string datasetFilePath) : this() { var fileInfo = new FileInfo(datasetFilePath); if (!fileInfo.Exists) { throw new FileNotFoundException("Cannot initialize Run. File not found: " + datasetFilePath); } var fileExtension = Path.GetExtension(datasetFilePath).ToLower(); switch (fileExtension) { case ".mzxml": MSFileType = Globals.MSFileType.MZXML_Rawdata; break; case ".mzml": MSFileType = Globals.MSFileType.MZML; break; case ".mz5": MSFileType = Globals.MSFileType.MZ5; break; default: throw new IOException("Cannot initialize Run. File extension " + fileExtension + " isn't supported. The following file extensions are supported: mzXML, mzML, and mz5"); } DatasetFileOrDirectoryPath = datasetFilePath; var baseFilename = Path.GetFileName(DatasetFileOrDirectoryPath); DatasetName = baseFilename.Substring(0, baseFilename.LastIndexOf('.')); DatasetDirectoryPath = Path.GetDirectoryName(DatasetFileOrDirectoryPath); _reader = new pwiz.ProteowizardWrapper.MSDataFileReader(datasetFilePath); MinLCScan = GetMinPossibleLCScanNum(); MaxLCScan = GetMaxPossibleLCScanNum(); }
public static void TestReadBruker() { try { var dataFilePath = @"\\proto-6\12T_FTICR_B\2014_4\2014_09_30_Stegen_ALK-3_ACN_Core05-org-1_000001\2014_09_30_Stegen_ALK-3_ACN_Core05-org-1_000001.d"; var reader = new pwiz.ProteowizardWrapper.MSDataFileReader(dataFilePath); var isABSciexFile = reader.IsABFile; var isThermoFile = reader.IsThermoFile; Console.WriteLine(); Console.WriteLine(System.IO.Path.GetFileName(dataFilePath) + " IsABSciexFile: " + isABSciexFile); Console.WriteLine(System.IO.Path.GetFileName(dataFilePath) + " IsThermoFile: " + isThermoFile); const int targetIndex = 0; var spectrum = reader.GetSpectrum(targetIndex); Console.WriteLine("Spectrum at index {0} is scan {1} with {2} points", targetIndex, spectrum.NativeId, spectrum.Mzs.Length); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
private void ProcessWiffFile(FileSystemInfo fiDatasetFile, clsDatasetFileInfo datasetFileInfo) { try { // Open the .Wiff file using the ProteoWizardWrapper var objPWiz = new pwiz.ProteowizardWrapper.MSDataFileReader(fiDatasetFile.FullName); try { var dtRunStartTime = Convert.ToDateTime(objPWiz.RunStartTime); // Update AcqTimeEnd if possible // Found out by trial and error that we need to use .ToUniversalTime() to adjust the time reported by ProteoWizard dtRunStartTime = dtRunStartTime.ToUniversalTime(); if (dtRunStartTime < datasetFileInfo.AcqTimeEnd) { if (datasetFileInfo.AcqTimeEnd.Subtract(dtRunStartTime).TotalDays < 1) { datasetFileInfo.AcqTimeStart = dtRunStartTime; } } } catch (Exception) { datasetFileInfo.AcqTimeStart = datasetFileInfo.AcqTimeEnd; } // Instantiate the Proteowizard Data Parser class var pWizParser = new clsProteowizardDataParser(objPWiz, mDatasetStatsSummarizer, mTICandBPIPlot, mLCMS2DPlot, mSaveLCMS2DPlots, mSaveTICAndBPI, mCheckCentroidingStatus) { HighResMS1 = true, HighResMS2 = true }; RegisterEvents(pWizParser); var blnTICStored = false; var blnSRMDataCached = false; double dblRuntimeMinutes = 0; // Note that SRM .Wiff files will only have chromatograms, and no spectra if (objPWiz.ChromatogramCount > 0) { // Process the chromatograms pWizParser.StoreChromatogramInfo(datasetFileInfo, out blnTICStored, out blnSRMDataCached, out dblRuntimeMinutes); pWizParser.PossiblyUpdateAcqTimeStart(datasetFileInfo, dblRuntimeMinutes); } if (objPWiz.SpectrumCount > 0 & !blnSRMDataCached) { // Process the spectral data (though only if we did not process SRM data) pWizParser.StoreMSSpectraInfo(datasetFileInfo, blnTICStored, ref dblRuntimeMinutes); pWizParser.PossiblyUpdateAcqTimeStart(datasetFileInfo, dblRuntimeMinutes); } objPWiz.Dispose(); clsProgRunner.GarbageCollectNow(); } catch (Exception ex) { OnErrorEvent("Error using ProteoWizard reader: " + ex.Message, ex); } }
private void ReadBinaryData(string dataDirectoryPath, DatasetFileInfo datasetFileInfo, double acquisitionLengthMinutes) { try { // Open the data directory using the ProteoWizardWrapper var pWiz = new pwiz.ProteowizardWrapper.MSDataFileReader(dataDirectoryPath); try { var runStartTime = Convert.ToDateTime(pWiz.RunStartTime); // Update AcqTimeEnd if possible if (runStartTime < datasetFileInfo.AcqTimeEnd) { if (datasetFileInfo.AcqTimeEnd.Subtract(runStartTime).TotalDays < 1) { datasetFileInfo.AcqTimeStart = runStartTime; if (acquisitionLengthMinutes > 0) { datasetFileInfo.AcqTimeEnd = datasetFileInfo.AcqTimeStart.AddMinutes(acquisitionLengthMinutes); } } } } catch (Exception) { // Leave the times unchanged } // Instantiate the ProteoWizard Data Parser class var pWizParser = new clsProteoWizardDataParser(pWiz, mDatasetStatsSummarizer, mTICAndBPIPlot, mLCMS2DPlot, mSaveLCMS2DPlots, mSaveTICAndBPI, mCheckCentroidingStatus) { HighResMS1 = true, HighResMS2 = true }; RegisterEvents(pWizParser); var ticStored = false; double runtimeMinutes = 0; if (pWiz.ChromatogramCount > 0) { // Process the chromatograms pWizParser.StoreChromatogramInfo(datasetFileInfo, out ticStored, out _, out runtimeMinutes); pWizParser.PossiblyUpdateAcqTimeStart(datasetFileInfo, runtimeMinutes); } if (pWiz.SpectrumCount > 0) { // Process the spectral data var skipExistingScans = (pWiz.ChromatogramCount > 0); pWizParser.StoreMSSpectraInfo(ticStored, ref runtimeMinutes, skipExistingScans, skipScansWithNoIons: true, maxScansToTrackInDetail: MAX_SCANS_TO_TRACK_IN_DETAIL, maxScansForTicAndBpi: MAX_SCANS_FOR_TIC_AND_BPI); pWizParser.PossiblyUpdateAcqTimeStart(datasetFileInfo, runtimeMinutes); } pWiz.Dispose(); ProgRunner.GarbageCollectNow(); } catch (Exception ex) { OnErrorEvent("Exception reading the Binary Data in the Agilent TOF .D directory using ProteoWizard: " + ex.Message, ex); } }
private void ReadBinaryData(string strDataFolderPath, clsDatasetFileInfo datasetFileInfo) { try { // Open the data folder using the ProteoWizardWrapper var objPWiz = new pwiz.ProteowizardWrapper.MSDataFileReader(strDataFolderPath); try { var dtRunStartTime = Convert.ToDateTime(objPWiz.RunStartTime); // Update AcqTimeEnd if possible if (dtRunStartTime < datasetFileInfo.AcqTimeEnd) { if (datasetFileInfo.AcqTimeEnd.Subtract(dtRunStartTime).TotalDays < 1) { datasetFileInfo.AcqTimeStart = dtRunStartTime; } } } catch (Exception) { // Leave the times unchanged } // Instantiate the Proteowizard Data Parser class var pWizParser = new clsProteowizardDataParser(objPWiz, mDatasetStatsSummarizer, mTICandBPIPlot, mLCMS2DPlot, mSaveLCMS2DPlots, mSaveTICAndBPI, mCheckCentroidingStatus) { HighResMS1 = true, HighResMS2 = true }; RegisterEvents(pWizParser); var blnTICStored = false; double dblRuntimeMinutes = 0; if (objPWiz.ChromatogramCount > 0) { // Process the chromatograms pWizParser.StoreChromatogramInfo(datasetFileInfo, out blnTICStored, out _, out dblRuntimeMinutes); pWizParser.PossiblyUpdateAcqTimeStart(datasetFileInfo, dblRuntimeMinutes); } if (objPWiz.SpectrumCount > 0) { // Process the spectral data pWizParser.StoreMSSpectraInfo(datasetFileInfo, blnTICStored, ref dblRuntimeMinutes); pWizParser.PossiblyUpdateAcqTimeStart(datasetFileInfo, dblRuntimeMinutes); } objPWiz.Dispose(); clsProgRunner.GarbageCollectNow(); } catch (Exception ex) { OnErrorEvent("Exception reading the Binary Data in the Agilent TOF .D folder using Proteowizard: " + ex.Message, ex); } }