/// <summary> /// Name: GetParentMZ /// Description: This function returns the ParentIon of the current experiment (determined by m_experimentCode). /// </summary> /// <returns> /// Output: This function outputs the Parent Ion in the form of a double. /// </returns> public double GetParentMZ() { clsSpectrumInfo tempInfo = new clsSpectrumInfo(); m_fileToRead.GetSpectrumByScanNumber(this.m_experimentCode, ref tempInfo); return(tempInfo.ParentIonMZ); }
// Note that Centroid is ignored by this class public override bool GetRawData(out List <double> mzs, out List <double> intensities, int scan_num, bool centroid, int num_pts) { if (scan_num > mint_num_scans) { var mesg = "File only has " + mint_num_scans + " scans. Cannot read to scan number: " + scan_num; throw new Exception(mesg); } mint_current_scan = scan_num; mobj_MzXmlFile.GetSpectrumHeaderInfoByScanNumber(scan_num, out mobj_CurrentScanData); mzs = new List <double>(); intensities = new List <double>(); var scanData = new clsSpectrumInfo(); mobj_MzXmlFile.GetSpectrumByScanNumber(scan_num, out scanData); var num_points = scanData.DataCount; if (num_pts > 0 && num_pts < num_points) { num_points = num_pts; } mzs.Capacity = num_points; intensities.Capacity = num_points; double fMass; double fInten; var max_intensity = -1 * double.MaxValue; var min_intensity = double.MaxValue; for (var i = 0; i < scanData.DataCount; i++) { fMass = scanData.MZList[i]; fInten = scanData.IntensityList[i]; if (fInten > max_intensity) { max_intensity = fInten; } if (fInten < min_intensity) //Anoop Jan 08: was > before { min_intensity = fInten; } mzs.Add(fMass); intensities.Add(fInten); } mdbl_signal_level = max_intensity - min_intensity; return(true); }
public override bool IsProfileScan(int scan_num) { var scanData = new clsSpectrumInfo(); mobj_MzXmlFile.GetSpectrumHeaderInfoByScanNumber(scan_num, out scanData); // TODO: Validate this solution //if (scanData.profileType == 'p') // return true; //else if (scanData.profileType == 'c') // return false; return(!scanData.Centroided); //default //return true; }
public override double GetScanTime(int scan_num) { if (mint_current_scan == scan_num) { return(mobj_CurrentScanData.RetentionTimeMin); } else { var scanData = new clsSpectrumInfo(); // its time to read in that scan. mint_current_scan = scan_num; mobj_MzXmlFile.GetSpectrumHeaderInfoByScanNumber(scan_num, out scanData); return(scanData.RetentionTimeMin); } }
public override int GetParentScan(int scan_num) { var scan = scan_num; var scanData = new clsSpectrumInfo(); mobj_MzXmlFile.GetSpectrumHeaderInfoByScanNumber(scan, out scanData); for (scan = scan_num - 1;; scan--) { mobj_MzXmlFile.GetSpectrumHeaderInfoByScanNumber(scan, out scanData); if (scanData.MSLevel == 1) { break; } } return(scan); }
public override void GetTicFromFile(out List <double> intensities, out List <double> scan_times, bool base_peak_tic) { intensities = new List <double>(); scan_times = new List <double>(); if (mobj_MzXmlFile == null) { return; } var nonzero_time_reported = false; for (var scan_num = 0; scan_num <= mint_num_scans; scan_num++) { // its time to read in that scan. mint_current_scan = scan_num; var scanData = new clsSpectrumInfo(); mobj_MzXmlFile.GetSpectrumHeaderInfoByScanNumber(scan_num, out scanData); scan_times.Add(scanData.RetentionTimeMin); if (scanData.RetentionTimeMin != 0.0) { nonzero_time_reported = true; } if (base_peak_tic) { intensities.Add(scanData.BasePeakIntensity); } else { intensities.Add(scanData.TotalIonCurrent); } } // for mzxml files in which no retention times were recorded. if (!nonzero_time_reported) { for (var scan_num = 0; scan_num <= mint_num_scans; scan_num++) { scan_times[scan_num] = scan_num; } } }
public override bool IsFTScan(int scan_num) { var scan = scan_num; var scanData = new clsSpectrumInfo(); mobj_MzXmlFile.GetSpectrumHeaderInfoByScanNumber(scan, out scanData); string xmlText; mobj_MzXmlFile.GetSourceXMLByScanNumber(scan_num, out xmlText); // TODO: Validate this solution if (xmlText.Contains("FTMS")) { return(true); } else if (xmlText.Contains("ITMS")) { return(false); } //default return(false); }
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> /// Reads a list of MSMS Spectra header data from the mzXML file. /// </summary> /// <param name="file">file to read.</param> /// <returns>List of MSMS spectra data</returns> public List<MSSpectra> ReadMSMSSpectra(string file) { var spectra = new List<MSSpectra>(); var reader = new clsMzXMLFileReader {SkipBinaryData = true}; var opened = reader.OpenFile(file); if (!opened) { throw new IOException("Could not open the mzXML file " + file); } var totalScans = reader.ScanCount; for (var i = 0; i < totalScans; i++) { var info = new clsSpectrumInfo(); reader.GetSpectrumByScanNumber(i, ref info); if (info.MSLevel > 1) { var spectrum = new MSSpectra { MsLevel = info.MSLevel, RetentionTime = info.RetentionTimeMin, Scan = i, PrecursorMz = info.ParentIonMZ, TotalIonCurrent = info.TotalIonCurrent, CollisionType = CollisionType.Other }; // Need to make this a standard type of collision based off of the data. spectra.Add(spectrum); } } reader.CloseFile(); return spectra; }
/// <summary> /// Name: CloseFile /// Description: This function Closes the file and sets the opened flag to false. /// </summary> public void CloseFile() { this.m_isFileOpened = false; this.m_fileToRead.CloseFile(); this.m_currentSpectrum = null; }