/// <summary> /// Return the number of unique isolation windows in the dataset /// </summary> /// <returns></returns> public int GetNumUniqueIsoWindows() { var isoWindowSet = new HashSet <IsolationWindow>(); foreach (var scanNum in ScanNumToMsLevel.Where(x => x.Value > 1).Select(x => x.Key)) { if (!(GetSpectrum(scanNum) is ProductSpectrum productSpec)) { continue; } isoWindowSet.Add(productSpec.IsolationWindow); } return(isoWindowSet.Count); }
/// <summary> /// Get the narrowest isolation window width /// </summary> /// <returns></returns> public double GetMinIsolationWindowWidth() { var minWidth = Double.MaxValue; foreach (var scanNum in ScanNumToMsLevel.Where(x => x.Value > 1).Select(x => x.Key)) { var productSpec = GetSpectrum(scanNum) as ProductSpectrum; if (productSpec == null) { continue; } if (productSpec.IsolationWindow.Width < minWidth) { minWidth = productSpec.IsolationWindow.Width; } } return(minWidth); }
/* * public ProductSpectrum GetSummedMs2Spectrum(double monoIsotopicMass, Ms1Feature range, * ActivationMethod activationMethod = ActivationMethod.Unknown) * { * return GetSummedMs2Spectrum(monoIsotopicMass, range.MinScanNum, range.MaxScanNum, range.MinCharge, * range.MaxCharge, activationMethod); * }*/ #endregion #region Detail data by scan number /// <summary> /// Gets the MS level of the specified scan /// </summary> /// <param name="scanNum">scan number</param> /// <returns>MS level</returns> public int GetMsLevel(int scanNum) { int msLevel; return(ScanNumToMsLevel.TryGetValue(scanNum, out msLevel) ? msLevel : 0); }
/// <summary> /// Gets the scan numbers of the specified msLevel /// </summary> /// <param name="msLevel">MS level</param> /// <returns>scan numbers of the specified msLevel</returns> public IList <int> GetScanNumbers(int msLevel) { return(ScanNumToMsLevel.Where(x => x.Value == msLevel).Select(x => x.Key).ToList()); }
/// <summary> /// Gets the smallest scan number larger than ms2ScanNum /// </summary> /// <param name="scanNum">scan number</param> /// <param name="msLevel">MS level</param> /// <returns>next scan number at the specified level</returns> public int GetNextScanNum(int scanNum, int msLevel) { return(ScanNumToMsLevel.Where(x => x.Value == msLevel && x.Key > scanNum).DefaultIfEmpty(new KeyValuePair <int, int>(MaxLcScan + 1, 0)).Min(x => x.Key)); }
/// <summary> /// Gets the greatest scan number smaller than ms2ScanNum /// </summary> /// <param name="scanNum">scan number</param> /// <param name="msLevel">MS level</param> /// <returns>previous scan number at the specified level</returns> public int GetPrevScanNum(int scanNum, int msLevel) { return(ScanNumToMsLevel.Where(x => x.Value == msLevel && x.Key < scanNum).DefaultIfEmpty(new KeyValuePair <int, int>(MinLcScan - 1, 0)).Max(x => x.Key)); }