public void GetMassSpectrumWithSummingTest1() { var run = new UIMFRun(FileRefs.RawDataMSFiles.UIMFStdFile3); var frame = new ScanSet(163, 162, 164); var scan = new IMSScanSet(121); var xydata = run.GetMassSpectrum(frame, scan, 0, 50000); var testMZ = 627.2655682; var maxIntensityForTestMZ = 0; for (var i = 0; i < xydata.Xvalues.Length; i++) { if (xydata.Xvalues[i] > (testMZ - 0.1) && xydata.Xvalues[i] < (testMZ + 0.1)) { if (xydata.Yvalues[i] > maxIntensityForTestMZ) { maxIntensityForTestMZ = (int)xydata.Yvalues[i]; } } } Assert.AreEqual(126568, maxIntensityForTestMZ); }
public override void InitializeRunRelatedTasks() { if (Run != null) { MSGenerator = MSGeneratorFactory.CreateMSGenerator(Run.MSFileType); int minLCScan; int maxLCScan; if (this._workflowParameters.LCScanMax == -1 || this._workflowParameters.LCScanMin == -1) { if (Run is UIMFRun) { minLCScan = ((UIMFRun)Run).MinLCScan; maxLCScan = ((UIMFRun)Run).MaxLCScan; } else { minLCScan = Run.MinLCScan; maxLCScan = Run.MaxLCScan; } } else { minLCScan = this._workflowParameters.LCScanMin; maxLCScan = this._workflowParameters.LCScanMax; } if (Run.MSFileType == DeconTools.Backend.Globals.MSFileType.PNNL_UIMF) { var uimfRun = Run as UIMFRun; uimfRun.ScanSetCollection.Create(uimfRun, minLCScan, maxLCScan, _workflowParameters.Num_LC_TimePointsSummed, 1, _workflowParameters.ProcessMSMS); bool sumAllIMSScans = (_workflowParameters.NumIMSScansSummed == -1 || _workflowParameters.NumIMSScansSummed > uimfRun.MaxLCScan); if (sumAllIMSScans) { int primaryIMSScan = Run.MinLCScan; uimfRun.IMSScanSetCollection.ScanSetList.Clear(); var imsScanset = new IMSScanSet(primaryIMSScan, uimfRun.MinIMSScan, uimfRun.MaxIMSScan); uimfRun.IMSScanSetCollection.ScanSetList.Add(imsScanset); } else { uimfRun.IMSScanSetCollection.Create(Run, uimfRun.MinIMSScan, uimfRun.MaxIMSScan, _workflowParameters.NumIMSScansSummed, 1); } } else { Run.ScanSetCollection.Create(Run, minLCScan, maxLCScan, this._workflowParameters.Num_LC_TimePointsSummed, 1, this._workflowParameters.ProcessMSMS); } } }
protected override void CreateTargetMassSpectra() { var uimfRun = (UIMFRun)Run; uimfRun.ScanSetCollection = new ScanSetCollection(); uimfRun.IMSScanSetCollection = new IMSScanSetCollection(); int numFramesSummed; if (NewDeconToolsParameters.MSGeneratorParameters.SumSpectraAcrossLC) { numFramesSummed = NewDeconToolsParameters.MSGeneratorParameters.NumLCScansToSum; } else { numFramesSummed = 1; } if (NewDeconToolsParameters.MSGeneratorParameters.UseLCScanRange) //Defines whether or not to use all LC time points, or a restricted range { uimfRun.ScanSetCollection.Create(uimfRun, NewDeconToolsParameters.MSGeneratorParameters.MinLCScan, NewDeconToolsParameters.MSGeneratorParameters.MaxLCScan, numFramesSummed, 1, NewDeconToolsParameters.ScanBasedWorkflowParameters.ProcessMS2); } else { uimfRun.ScanSetCollection.Create(uimfRun, numFramesSummed, 1); } var sumAllIMSScansInAFrame = (NewDeconToolsParameters.MSGeneratorParameters.SumAllSpectra); if (sumAllIMSScansInAFrame) { var centerScan = (uimfRun.MinIMSScan + uimfRun.MaxIMSScan + 1) / 2; uimfRun.IMSScanSetCollection.ScanSetList.Clear(); var scanset = new IMSScanSet(centerScan, uimfRun.MinIMSScan, uimfRun.MaxIMSScan); uimfRun.IMSScanSetCollection.ScanSetList.Add(scanset); } else { var sumAcrossIMSScans = NewDeconToolsParameters.MSGeneratorParameters.SumSpectraAcrossIms; int numIMSScanToSum; if (sumAcrossIMSScans) { numIMSScanToSum = NewDeconToolsParameters.MSGeneratorParameters.NumImsScansToSum; } else { numIMSScanToSum = 1; } uimfRun.IMSScanSetCollection.Create(Run, uimfRun.MinIMSScan, uimfRun.MaxIMSScan, numIMSScanToSum, 1); } }
public void InitializeRunRelatedTasks() { if (Run != null) { MSGenerator = MSGeneratorFactory.CreateMSGenerator(Run.MSFileType); int minLCScan; int maxLCScan; if (WorkflowParameters.LCScanMax == -1 || WorkflowParameters.LCScanMin == -1) { if (Run is UIMFRun thisUimfRun) { minLCScan = thisUimfRun.MinLCScan; maxLCScan = thisUimfRun.MaxLCScan; } else { minLCScan = Run.MinLCScan; maxLCScan = Run.MaxLCScan; } } else { minLCScan = WorkflowParameters.LCScanMin; maxLCScan = WorkflowParameters.LCScanMax; } if (Run.MSFileType == Globals.MSFileType.PNNL_UIMF && Run is UIMFRun uimfRun) { uimfRun.ScanSetCollection.Create(uimfRun, minLCScan, maxLCScan, WorkflowParameters.Num_LC_TimePointsSummed, 1, WorkflowParameters.ProcessMSMS); var sumAllIMSScans = WorkflowParameters.NumIMSScansSummed == -1 || WorkflowParameters.NumIMSScansSummed > uimfRun.MaxLCScan; if (sumAllIMSScans) { var primaryIMSScan = Run.MinLCScan; uimfRun.IMSScanSetCollection.ScanSetList.Clear(); var imsScanSet = new IMSScanSet(primaryIMSScan, uimfRun.MinIMSScan, uimfRun.MaxIMSScan); uimfRun.IMSScanSetCollection.ScanSetList.Add(imsScanSet); } else { uimfRun.IMSScanSetCollection.Create(Run, uimfRun.MinIMSScan, uimfRun.MaxIMSScan, WorkflowParameters.NumIMSScansSummed, 1); } } else { Run.ScanSetCollection.Create(Run, minLCScan, maxLCScan, WorkflowParameters.Num_LC_TimePointsSummed, 1, WorkflowParameters.ProcessMSMS); } } }
public ScanBasedProgressInfo(Run run, ScanSet scanSet, IMSScanSet imsScanSet = null) { CurrentRun = run; CurrentScanSet = scanSet; if (CurrentRun is UIMFRun uimfRun) { if (imsScanSet == null) { throw new NullReferenceException("ScanBasedProgressInfo error. You need to provide a valid IMSScanSet"); } uimfRun.CurrentIMSScanSet = imsScanSet; } }
public ScanBasedProgressInfo(Run currentRun, ScanSet scanSet, IMSScanSet imsScanSet = null) { this.currentRun = currentRun; this.currentScanSet = scanSet; if (currentRun is UIMFRun) { if (imsScanSet == null) { throw new NullReferenceException("ScanBasedProgressInfo error. You need to provide a valid IMSScanSet"); } ((UIMFRun)currentRun).CurrentIMSScanSet = imsScanSet; } }
protected override void IterateOverScans() { const int CONSOLE_INTERVAL_SECONDS = 15; const bool SKIP_DECONVOLUTION = false; var uimfRun = (UIMFRun)Run; var startTime = DateTime.UtcNow; var dtLastProgress = DateTime.UtcNow.Subtract(new TimeSpan(1, 0, 0)); var frameCountProcessed = 0; var maxRuntimeHours = NewDeconToolsParameters.MiscMSProcessingParameters.MaxHoursPerDataset; // uimfRun.IMSScanSetCollection.ScanSetList =uimfRun.IMSScanSetCollection.ScanSetList.Where(p => p.PrimaryScanNumber == 153).ToList(); // Iterate over unsummed data and fix saturated isotopic profiles. Unsummed will be used during a second iteration (over summed data) foreach (var lcScanSet in uimfRun.ScanSetCollection.ScanSetList) { uimfRun.ResultCollection.MSPeakResultList.Clear(); _unsummedMSFeatures.Clear(); var unsummedFrameSet = new ScanSet(lcScanSet.PrimaryScanNumber); // Get saturated MSFeatures for unsummed data uimfRun.CurrentScanSet = unsummedFrameSet; var forceProgressMessage = true; var imsScanCountProcessed = 0; var maxMinutesPerFrame = NewDeconToolsParameters.MiscMSProcessingParameters.MaxMinutesPerFrame; if (uimfRun.GetNumFrames() <= 10) { // Disable the per-frame timeout if we have 10 or fewer frames maxMinutesPerFrame = int.MaxValue; } var frameStartTime = DateTime.UtcNow; var timeoutReached = false; foreach (var scanset in uimfRun.IMSScanSetCollection.ScanSetList) { if (DateTime.UtcNow.Subtract(dtLastProgress).TotalSeconds >= CONSOLE_INTERVAL_SECONDS || forceProgressMessage) { dtLastProgress = DateTime.UtcNow; forceProgressMessage = false; Console.WriteLine("Processing frame " + lcScanSet.PrimaryScanNumber + ", scan " + scanset.PrimaryScanNumber + " (Unsummed)"); } if (DateTime.UtcNow.Subtract(frameStartTime).TotalMinutes >= maxMinutesPerFrame) { Console.WriteLine( "Aborted processing of frame {0} because {1} minutes have elapsed (processing unsummed features); IMSScanCount processed = {2}", lcScanSet.PrimaryScanNumber, (int)DateTime.UtcNow.Subtract(frameStartTime).TotalMinutes, imsScanCountProcessed); timeoutReached = true; break; } uimfRun.ResultCollection.IsosResultBin.Clear(); //clear any previous MSFeatures var unsummedIMSScanset = new IMSScanSet(scanset.PrimaryScanNumber); uimfRun.CurrentIMSScanSet = unsummedIMSScanset; _msGenerator.Execute(Run.ResultCollection); _zeroFiller.Execute(Run.ResultCollection); // For debugging.... // if (scanset.PrimaryScanNumber == 123) // { // Console.WriteLine(scanset + "\t being processed!"); // } _peakDetector.Execute(Run.ResultCollection); imsScanCountProcessed++; if (SKIP_DECONVOLUTION) { continue; } // Deconvolute Unsummed MSFeatures // This is a preliminary step for Saturation Detection //#if Disable_DeconToolsV2 // throw new NotImplementedException("Cannot use class SaturationIMSScanBasedWorkflow since support for C++ based DeconToolsV2 is disabled"); //#else _deconvolutor.Deconvolute(uimfRun.ResultCollection); //adds to IsosResultBin //#endif // Note: the deconvolutor automatically increases the MSFeatureCounter. // Here, we don't want this, since this data is used only for saturation correction, // not for generating the official MSFeatures list. So we need to // correct the MSFeatureCounter value. Run.ResultCollection.MSFeatureCounter = Run.ResultCollection.MSFeatureCounter - Run.ResultCollection.IsosResultBin.Count; _unsummedMSFeatures.AddRange(Run.ResultCollection.IsosResultBin); // Iterate over unsummed MSFeatures and check for saturation foreach (var isosResult in uimfRun.ResultCollection.IsosResultBin) { var msFeatureXYData = Run.XYData.TrimData(isosResult.IsotopicProfile.MonoPeakMZ - 10, isosResult.IsotopicProfile.MonoPeakMZ + 10); var tempMZ = isosResult.IsotopicProfile.MonoPeakMZ; var currentScan = scanset.PrimaryScanNumber; var isPossiblySaturated = isosResult.IntensityAggregate > NewDeconToolsParameters.MiscMSProcessingParameters.SaturationThreshold; // For debugging... // UIMFIsosResult tempIsosResult = (UIMFIsosResult) isosResult; // if (tempIsosResult.IMSScanSet.PrimaryScanNumber == 123) // { // Console.WriteLine(tempIsosResult + "\t being processed!"); // } if (isPossiblySaturated) { RebuildSaturatedIsotopicProfile(msFeatureXYData, isosResult, uimfRun.PeakList, out var theorIso); AdjustSaturatedIsotopicProfile(isosResult.IsotopicProfile, theorIso, AdjustMonoIsotopicMasses, true); } } } // DisplayMSFeatures(_unsummedMSFeatures); // Now sum across IMSScans, deconvolute and adjust using saturation detection forceProgressMessage = true; imsScanCountProcessed = 0; // Compute a buffer using .MaxMinutesPerFrame times 20% double maxFrameMinutesAddon = 0; var bufferMinutes = maxMinutesPerFrame * 0.2; if (bufferMinutes < 1) { bufferMinutes = 1; } if (timeoutReached || DateTime.UtcNow.Subtract(frameStartTime).TotalMinutes + bufferMinutes >= maxMinutesPerFrame) { // Maximum time per frame has been reached (or has almost been reached) // Allow the next step to run for an additional bufferMinutes maxFrameMinutesAddon = bufferMinutes; } foreach (var scanSet in uimfRun.IMSScanSetCollection.ScanSetList) { var scanset = (IMSScanSet)scanSet; if (DateTime.UtcNow.Subtract(dtLastProgress).TotalSeconds >= CONSOLE_INTERVAL_SECONDS || forceProgressMessage) { dtLastProgress = DateTime.UtcNow; forceProgressMessage = false; Console.WriteLine("Processing frame " + lcScanSet.PrimaryScanNumber + ", scan " + scanset.PrimaryScanNumber + " (Summed)"); } if (DateTime.UtcNow.Subtract(frameStartTime).TotalMinutes >= maxMinutesPerFrame + maxFrameMinutesAddon) { Console.WriteLine( "Aborted processing of frame {0} because {1} minutes have elapsed (processing summed features); IMSScanCount processed = {2}", lcScanSet.PrimaryScanNumber, (int)DateTime.UtcNow.Subtract(frameStartTime).TotalMinutes, imsScanCountProcessed); break; } uimfRun.ResultCollection.IsosResultBin.Clear(); //clear any previous MSFeatures // Get the summed isotopic profile uimfRun.CurrentScanSet = lcScanSet; uimfRun.CurrentIMSScanSet = scanset; ExecuteTask(MSGenerator); if (NewDeconToolsParameters.MiscMSProcessingParameters.UseZeroFilling) { ExecuteTask(ZeroFiller); } if (NewDeconToolsParameters.MiscMSProcessingParameters.UseSmoothing) { ExecuteTask(Smoother); } ExecuteTask(PeakDetector); imsScanCountProcessed++; if (!SKIP_DECONVOLUTION) { ExecuteTask(Deconvolutor); foreach (var isosResult in Run.ResultCollection.IsosResultBin) { var isPossiblySaturated = isosResult.IntensityAggregate > NewDeconToolsParameters.MiscMSProcessingParameters.SaturationThreshold; if (isPossiblySaturated) { var msFeatureXYData = Run.XYData.TrimData(isosResult.IsotopicProfile.MonoPeakMZ - 10, isosResult.IsotopicProfile.MonoPeakMZ + 10); RebuildSaturatedIsotopicProfile(msFeatureXYData, isosResult, Run.PeakList, out var theorIso); AdjustSaturatedIsotopicProfile(isosResult.IsotopicProfile, theorIso, AdjustMonoIsotopicMasses, false); var currentScan = scanset.PrimaryScanNumber; var currentMZ = isosResult.IsotopicProfile.MonoPeakMZ; UpdateReportedSummedPeakIntensities(isosResult, lcScanSet, scanset); } else { } if (isosResult.IsotopicProfile.IsSaturated) { GetRebuiltFitScore(isosResult); } } } // Need to remove any duplicate MSFeatures (this occurs when incorrectly deisotoped profiles are built). // Will do this by making the MSFeatureID the same. Then the Exporter will ensure that only one MSFeature per MSFeatureID // is exported. This isn't ideal. Better to remove the features but this proves to be quite hard to do without large performance hits. foreach (var isosResult in Run.ResultCollection.IsosResultBin) { double ppmToleranceForDuplicate = 20; var massTolForDuplicate = ppmToleranceForDuplicate * isosResult.IsotopicProfile.MonoIsotopicMass / 1e6; var isosResultLocal = isosResult; var duplicateIsosResults = (from n in Run.ResultCollection.IsosResultBin where Math.Abs(n.IsotopicProfile.MonoIsotopicMass - isosResultLocal.IsotopicProfile.MonoIsotopicMass) < massTolForDuplicate && n.IsotopicProfile.ChargeState == isosResultLocal.IsotopicProfile.ChargeState select n); var minMSFeatureID = int.MaxValue; foreach (var dup in duplicateIsosResults) { if (dup.MSFeatureID < minMSFeatureID) { minMSFeatureID = dup.MSFeatureID; } else { //here we have found a duplicate dup.MSFeatureID = minMSFeatureID; //because there are duplicates, we need to maintain the MSFeatureCounter so it doesn't skip values, as will //happen when there are duplicates //Run.ResultCollection.MSFeatureCounter--; } } } ExecuteTask(ResultValidator); ExecuteTask(ScanResultUpdater); if (NewDeconToolsParameters.ScanBasedWorkflowParameters.IsRefittingPerformed) { ExecuteTask(FitScoreCalculator); } // Allows derived classes to execute additional tasks ExecuteOtherTasksHook(); if (ExportData) { // The following exporting tasks should be last if (NewDeconToolsParameters.ScanBasedWorkflowParameters.ExportPeakData) { ExecuteTask(PeakToMSFeatureAssociator); ExecuteTask(PeakListExporter); } ExecuteTask(IsosResultExporter); ExecuteTask(ScanResultExporter); } ReportProgress(); } frameCountProcessed++; if (DateTime.UtcNow.Subtract(startTime).TotalHours >= maxRuntimeHours) { Console.WriteLine( "Aborted processing because {0} hours have elapsed; Frames processed = {1}", (int)DateTime.UtcNow.Subtract(startTime).TotalHours, frameCountProcessed); break; } } }
public void GetUnsummedIntensitiesAndDetectSaturation(Run run, IEnumerable <IsosResult> resultList) { Check.Require(run != null, "SaturationDetector failed. Run is null"); if (run == null) { return; } if (_msGenerator == null) { _msGenerator = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); } if (run is UIMFRun uimfRun) { if (uimfRun.CurrentScanSet == null) { throw new NullReferenceException("CurrentScanSet is null. You need to set it."); } if (uimfRun.CurrentIMSScanSet == null) { throw new NullReferenceException("CurrentIMSScanSet is null. You need to set it."); } //this creates a FrameSet containing only the primary frame. Therefore no summing will occur var lcScanSet = new ScanSet(uimfRun.CurrentScanSet.PrimaryScanNumber); //this creates a ScanSet containing only the primary scan. Therefore no summing will occur var imsScanSet = new IMSScanSet(uimfRun.CurrentIMSScanSet.PrimaryScanNumber); //get the mass spectrum +/- 5 da from the range of the isotopicProfile uimfRun.CurrentScanSet = lcScanSet; uimfRun.CurrentIMSScanSet = imsScanSet; _msGenerator.Execute(run.ResultCollection); } else { if (run.CurrentScanSet == null) { throw new NullReferenceException("CurrentScanSet is null. You need to set it."); } //this creates a ScanSet containing only the primary scan. Therefore no summing will occur var scanSet = new ScanSet(run.CurrentScanSet.PrimaryScanNumber); run.CurrentScanSet = scanSet; _msGenerator.Execute(run.ResultCollection); } foreach (var result in resultList) { var indexOfObsMostAbundant = result.IsotopicProfile.GetIndexOfMostIntensePeak(); var mzOfMostAbundant = result.IsotopicProfile.Peaklist[indexOfObsMostAbundant].XValue; var indexOfUnsummedMostAbundantMZ = run.XYData.GetClosestXVal(mzOfMostAbundant); if (indexOfUnsummedMostAbundantMZ >= 0) { result.IsotopicProfile.OriginalIntensity = run.XYData.Yvalues[indexOfUnsummedMostAbundantMZ]; result.IsotopicProfile.IsSaturated = (result.IsotopicProfile.OriginalIntensity >= SaturationThreshold); if (result.IsotopicProfile.IsSaturated) { //problem is that with these saturated profiles, they are often truncated because another //isotopic profile was falsely assigned to the back end of it. So we need to find more peaks that should //belong to the saturated profile. var theorTarget = new PeptideTarget { ChargeState = (short)result.IsotopicProfile.ChargeState, MonoIsotopicMass = result.IsotopicProfile.MonoIsotopicMass }; theorTarget.MZ = (theorTarget.MonoIsotopicMass / theorTarget.ChargeState) + Globals.PROTON_MASS; var averagineFormula = _tomIsotopicPatternGenerator.GetClosestAvnFormula(result.IsotopicProfile.MonoIsotopicMass, false); theorTarget.IsotopicProfile = _tomIsotopicPatternGenerator.GetIsotopePattern(averagineFormula, _tomIsotopicPatternGenerator.aafIsos); theorTarget.EmpiricalFormula = averagineFormula; theorTarget.CalculateMassesForIsotopicProfile(result.IsotopicProfile.ChargeState); AssignMissingPeaksToSaturatedProfile(run.PeakList, result.IsotopicProfile, theorTarget.IsotopicProfile); //goal is to find the index of the isotopic profile peaks of a peak that is not saturated var indexOfGoodUnsaturatedPeak = -1; for (var i = indexOfObsMostAbundant + 1; i < result.IsotopicProfile.Peaklist.Count; i++) { var indexUnsummedData = run.XYData.GetClosestXVal(result.IsotopicProfile.Peaklist[i].XValue); var unsummedIntensity = run.XYData.Yvalues[indexUnsummedData]; if (unsummedIntensity < _minRelIntTheorProfile * SaturationThreshold) { indexOfGoodUnsaturatedPeak = i; break; } } AdjustSaturatedIsotopicProfile(result.IsotopicProfile, theorTarget.IsotopicProfile, indexOfGoodUnsaturatedPeak); } } //double summedIntensity = 0; //foreach (MSPeak peak in result.IsotopicProfile.Peaklist) //{ // int indexOfMZ = result.Run.XYData.GetClosestXVal(peak.XValue); // if (indexOfMZ >= 0) // { // summedIntensity += result.Run.XYData.Yvalues[indexOfMZ]; // } //} //result.IsotopicProfile.OriginalTotalIsotopicAbundance = summedIntensity; } }
public void BPISaturationCorrectedTest1() { var filename = @"D:\Data\UIMF\Sarc_P13_C10_1186_23Sep11_Cheetah_11-09-06.uimf"; var run = new RunFactory().CreateRun(filename); run.ScanSetCollection = new ScanSetCollection(); //scanSetCollection.Create(run, 500, 550,1,1); var startFrame = 477; var stopFrame = 477; //startFrame = run.MinLCScan; //stopFrame = run.MaxLCScan; run.ScanSetCollection.Create(run, startFrame, stopFrame, 1, 1); ((UIMFRun)run).IMSScanSetCollection = new IMSScanSetCollection(); ((UIMFRun)run).IMSScanSetCollection.Create(run, 122, 122, 1, 1); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var peakDet = new DeconToolsPeakDetectorV2(); peakDet.PeakToBackgroundRatio = 2; peakDet.SignalToNoiseThreshold = 2; peakDet.IsDataThresholded = true; var _zeroFiller = new DeconToolsZeroFiller(); var _deconvolutor = new ThrashDeconvolutorV2(); _deconvolutor.UseAutocorrelationChargeDetermination = true; _deconvolutor.Parameters.MaxFit = 0.8; var saturationWorkflow = new SaturationIMSScanBasedWorkflow(new DeconToolsParameters(), run); var outputFile = @"C:\Users\d3x720\Documents\PNNL\My_DataAnalysis\2013\Saturation_Correction\chromOuputSatCorrected.txt"; using (var writer = new StreamWriter(outputFile)) { var uimfRun = (UIMFRun)run; var _unsummedMSFeatures = new List <IsosResult>(); foreach (var lcScanSet in run.ScanSetCollection.ScanSetList) { Console.WriteLine("Scanset= " + lcScanSet); uimfRun.ResultCollection.MSPeakResultList.Clear(); _unsummedMSFeatures.Clear(); var unsummedFrameSet = new ScanSet(lcScanSet.PrimaryScanNumber); //get saturated MSFeatures for unsummed data uimfRun.CurrentScanSet = unsummedFrameSet; var sb = new StringBuilder(); var errorInFrame = false; var numIMSScans = uimfRun.IMSScanSetCollection.ScanSetList.Count; for (var imsScanNum = 0; imsScanNum < numIMSScans; imsScanNum++) { var imsScanSet = uimfRun.IMSScanSetCollection.ScanSetList[imsScanNum]; uimfRun.ResultCollection.IsosResultBin.Clear(); //clear any previous MSFeatures var unsummedIMSScanset = new IMSScanSet(imsScanSet.PrimaryScanNumber); uimfRun.CurrentIMSScanSet = unsummedIMSScanset; try { msgen.Execute(run.ResultCollection); _zeroFiller.Execute(run.ResultCollection); peakDet.Execute(run.ResultCollection); _deconvolutor.Deconvolute(uimfRun.ResultCollection); //adds to IsosResultBin } catch (Exception ex) { errorInFrame = true; } _unsummedMSFeatures.AddRange(run.ResultCollection.IsosResultBin); var basePeakIntensity = 0; //iterate over unsummed MSFeatures and check for saturation foreach (var isosResult in uimfRun.ResultCollection.IsosResultBin) { var isPossiblySaturated = isosResult.IntensityAggregate > 1e7; if (isPossiblySaturated) { var theorIso = new IsotopicProfile(); saturationWorkflow.RebuildSaturatedIsotopicProfile(run.XYData, isosResult, uimfRun.PeakList, out theorIso); saturationWorkflow.AdjustSaturatedIsotopicProfile(isosResult.IsotopicProfile, theorIso, true, true); } TestUtilities.DisplayIsotopicProfileData(isosResult.IsotopicProfile); var height = (int)isosResult.IsotopicProfile.getMostIntensePeak().Height; if (height > basePeakIntensity) { basePeakIntensity = height; } } sb.Append(basePeakIntensity); var isNotLastIMSScan = imsScanNum != numIMSScans - 1; if (isNotLastIMSScan) { sb.Append("\t"); } } if (errorInFrame) { } else { writer.WriteLine(sb.ToString()); } } } }