public static ThermoStaticData LoadAllStaticData(string filePath, IFilteringParams filterParams = null) { if (!File.Exists(filePath)) { throw new FileNotFoundException(); } if (CheckForMsFileReader() == false) { throw new MzLibException("MsFileReader Not Installed"); } var ok = new ManagedThermoHelperLayer.HelperClass(); IXRawfile5 theConnection = (IXRawfile5) new MSFileReader_XRawfile(); theConnection.Open(filePath); int pbSMData = 0; theConnection.IsThereMSData(ref pbSMData); if (pbSMData == 0) { throw new MzLibException("Could not read data from file " + Path.GetFileName(filePath)); } theConnection.SetCurrentController(0, 1); var precursorInfosArray = ok.GetAllPrecursorInfos(filePath); for (int i = 0; i < precursorInfosArray.Length; i++) { if (precursorInfosArray[i].nScanNumber == 0) { precursorInfosArray[i].nScanNumber = -1; } } int pnFirstSpectrum = 0; theConnection.GetFirstSpectrumNumber(ref pnFirstSpectrum); int pnLastSpectrum = 0; theConnection.GetLastSpectrumNumber(ref pnLastSpectrum); ThermoGlobalParams p = GetAllGlobalStuff(theConnection, precursorInfosArray, filePath); MsDataScan[] scans = new MsDataScan[pnLastSpectrum - pnFirstSpectrum + 1]; for (int nScanNumber = pnFirstSpectrum; nScanNumber <= pnLastSpectrum; nScanNumber++) { scans[nScanNumber - pnFirstSpectrum] = GetMsDataOneBasedScanFromThermoFile(theConnection, nScanNumber, p, filterParams); } theConnection.Close(); string sendCheckSum; using (FileStream stream = File.OpenRead(filePath)) { using (SHA1Managed sha = new SHA1Managed()) { byte[] checksum = sha.ComputeHash(stream); sendCheckSum = BitConverter.ToString(checksum) .Replace("-", string.Empty); } } SourceFile sourceFile = new SourceFile( @"Thermo nativeID format", @"Thermo RAW format", sendCheckSum, @"SHA-1", filePath, Path.GetFileNameWithoutExtension(filePath)); return(new ThermoStaticData(scans, p, sourceFile)); }