public override MsDataScan GetOneBasedScan(int oneBasedScanNumber) { if (Scans[oneBasedScanNumber - 1] == null) { var representativeScanNumber = oneBasedScanNumber + (numScansToAverage - 1) / 2; var representative = raw.GetOneBasedScan(representativeScanNumber); if (representative.MsnOrder != 1) { throw new MzLibException("Scan " + representativeScanNumber + " is not MS1 scan"); } int msnOrder = 1; Polarity polarity = representative.Polarity; if (!representative.IsCentroid) { throw new MzLibException("Scan " + representativeScanNumber + " is not centroid scan"); } bool isCentroid = true; double retentionTime = representative.RetentionTime; MZAnalyzerType mzAnalyzer = representative.MzAnalyzer; MzSpectrum peaks = CombinePeaks(raw.GetAllScansList().Where(b => b.OneBasedScanNumber >= oneBasedScanNumber && b.OneBasedScanNumber <= oneBasedScanNumber + numScansToAverage - 1).Select(b => b.MassSpectrum).ToList(), ppmToleranceForPeakCombination); MzRange scanWindowRange = representative.ScanWindowRange; double totalIonCurrent = peaks.SumOfAllY; double injectionTime = double.NaN; double[,] noiseData = null; Scans[oneBasedScanNumber - 1] = new MsDataScan(peaks, oneBasedScanNumber, msnOrder, isCentroid, polarity, retentionTime, scanWindowRange, null, mzAnalyzer, totalIonCurrent, injectionTime, noiseData, "scan=" + oneBasedScanNumber); } return(Scans[oneBasedScanNumber - 1]); }
public IEnumerable <MsDataScan> GetMsScansInTimeRange(double firstRT, double lastRT) { int oneBasedSpectrumNumber = GetClosestOneBasedSpectrumNumber(firstRT); while (oneBasedSpectrumNumber <= NumSpectra) { MsDataScan scan = GetOneBasedScan(oneBasedSpectrumNumber); double rt = scan.RetentionTime; if (rt < firstRT) { oneBasedSpectrumNumber++; continue; } if (rt > lastRT) { yield break; } yield return(scan); oneBasedSpectrumNumber++; } }