/// <summary> /// Constructor /// </summary> /// <param name="mzXmlPath"></param> /// <param name="peptideMassCalculator"></param> private MzXmlManager(string mzXmlPath, PHRPReader.PeptideMassCalculator peptideMassCalculator) { mPeptideMassCalculator = peptideMassCalculator; try { // Note: prior to October 2017 the dataset name was determined by removing the last 4 characters from datasetName // That logic seemed flawed and has thus been removed if (mzXmlPath.EndsWith(".gz", StringComparison.OrdinalIgnoreCase)) { DatasetName = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(mzXmlPath)); } else { DatasetName = Path.GetFileNameWithoutExtension(mzXmlPath); } mzAccessor = new clsMzXMLFileAccessor(); mzAccessor.OpenFile(mzXmlPath); } catch (DirectoryNotFoundException) { throw new DirectoryNotFoundException("The specified directory for " + "the mzXml could not be found!"); } catch (FileNotFoundException) { var filename = Path.GetFileName(mzXmlPath); throw new FileNotFoundException("The specified mzXml file \"" + filename + "\" could not be found!"); } }
public override void Load(string file_name) { mstr_file_name = file_name; Close(); mobj_MzXmlFile = new clsMzXMLFileAccessor(); mobj_MzXmlFile.OpenFile(mstr_file_name); mobj_MzXmlFile.ReadAndCacheEntireFile(); }
public List<MSSpectra> GetMSMSSpectra(int group, Dictionary<int, int> excludeMap, bool loadPeaks) { var spectra = new List<MSSpectra>(); if (!m_dataFiles.ContainsKey(group)) { throw new Exception("The group-dataset ID provided was not found."); } // If we dont have a reader, then create one for this group // next time, it will be available and we won't have to waste time // opening the file. if (!m_readers.ContainsKey(group)) { var path = m_dataFiles[group]; var reader = new clsMzXMLFileAccessor(); m_readers.Add(group, reader); var opened = reader.OpenFile(path); if (!opened) { throw new IOException("Could not open the mzXML file " + path); } } var rawReader = m_readers[group]; var numberOfScans = rawReader.ScanCount; var info = new clsSpectrumInfo(); for (var i = 0; i < numberOfScans; i++) { // This scan is not to be used. var isInExcludeMap = excludeMap.ContainsKey(i); if (isInExcludeMap) continue; var header = new clsSpectrumInfo(); rawReader.GetSpectrumHeaderInfoByIndex(i, ref header); if (header.MSLevel > 1) { var spectrum = new MSSpectra(); spectrum.MsLevel = header.MSLevel; spectrum.RetentionTime = header.RetentionTimeMin; spectrum.Scan = i; spectrum.PrecursorMz = header.ParentIonMZ; spectrum.TotalIonCurrent = header.TotalIonCurrent; spectrum.CollisionType = CollisionType.Other; spectra.Add(spectrum); } } return spectra; }
private clsSpectrumInfo GetScanInfo(int scan, int groupId, out ScanSummary summary) { if (!m_dataFiles.ContainsKey(groupId)) { throw new Exception("The group-dataset ID provided was not found."); } // If we dont have a reader, then create one for this group // next time, it will be available and we won't have to waste time // opening the file. if (!m_readers.ContainsKey(groupId)) { var path = m_dataFiles[groupId]; var reader = new clsMzXMLFileAccessor(); m_readers.Add(groupId, reader); var opened = reader.OpenFile(path); if (!opened) { throw new IOException("Could not open the mzXML file " + path); } } var rawReader = m_readers[groupId]; var totalScans = rawReader.ScanCount; var info = new clsSpectrumInfo(); rawReader.GetSpectrumByScanNumber(scan, ref info); summary = new ScanSummary { Bpi = Convert.ToInt64(info.BasePeakIntensity), BpiMz = info.BasePeakMZ, MsLevel = info.MSLevel, PrecursorMz = info.ParentIonMZ, TotalIonCurrent = Convert.ToInt64(info.TotalIonCurrent) }; return info; }
/// <summary> /// Gets the total number of scans for the group id provided /// </summary> /// <param name="group"></param> /// <returns></returns> public int GetTotalScans(int group) { if (!m_dataFiles.ContainsKey(group)) { throw new Exception("The group-dataset ID provided was not found."); } // If we dont have a reader, then create one for this group // next time, it will be available and we won't have to waste time // opening the file. if (!m_readers.ContainsKey(group)) { var path = m_dataFiles[group]; var reader = new clsMzXMLFileAccessor(); m_readers.Add(group, reader); var opened = reader.OpenFile(path); if (!opened) { throw new IOException("Could not open the mzXML file " + path); } } var rawReader = m_readers[group]; return rawReader.ScanCount; }