/// <summary> /// Gets the LC Scanset used in generating a mass spectrum, based on the width of the Chrom peak. /// </summary> /// <param name="chromPeak"></param> /// <param name="run"></param> /// <param name="peakWidthInSigma">number of sigma. In Gaussian peak theory, 4 sigma is often used to define /// the base of a Gaussian peak. 2.35 sigma is the peak at half height. </param> /// <param name="maxScansToSum"></param> /// <returns></returns> public ScanSet GetLCScanSetForChromPeakBasedOnPeakWidth(Peak chromPeak, Run run, double peakWidthInSigma = 2, int maxScansToSum = 100) { ScanSet scanset; if (chromPeak == null || chromPeak.XValue == 0) { return(null); //throw new NullReferenceException("Trying to use chromPeak to generate mass spectrum, but chrompeak is null"); } var bestScan = (int)chromPeak.XValue; bestScan = run.GetClosestMSScan(bestScan, DeconTools.Backend.Globals.ScanSelectionMode.CLOSEST); var sigma = chromPeak.Width / 2.35; var lowerScan = (int)Math.Round(chromPeak.XValue - (peakWidthInSigma * sigma / 2)); var closestLowerScan = run.GetClosestMSScan(lowerScan, DeconTools.Backend.Globals.ScanSelectionMode.CLOSEST); var upperScan = (int)Math.Round(chromPeak.XValue + (peakWidthInSigma * sigma / 2)); var closestUpperScan = run.GetClosestMSScan(upperScan, DeconTools.Backend.Globals.ScanSelectionMode.CLOSEST); scanset = _scansetFactory.CreateScanSet(run, bestScan, closestLowerScan, closestUpperScan); _scansetFactory.TrimScans(scanset, maxScansToSum); if (run.MSFileType == DeconTools.Backend.Globals.MSFileType.PNNL_UIMF) { // GORD: Update this when fixing CurrentFrameSet throw new NotSupportedException("UIMF worflows should use a UIMF specific peak selector."); } return(scanset); }
public void TrimScansTest1() { var startScan = 5970; var stopScan = 6035; var rf = new RunFactory(); var run = rf.CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1); var ssf = new ScanSetFactory(); var scan = ssf.CreateScanSet(run, 6005, startScan, stopScan); Assert.AreEqual("6005 {5970, 5977, 5984, 5991, 5998, 6005, 6012, 6019, 6026, 6033}", scan.ToString()); var maxScansAllowed = 7; ssf.TrimScans(scan, maxScansAllowed); Assert.AreEqual("6005 {5984, 5991, 5998, 6005, 6012, 6019}", scan.ToString()); }