public void OldDeconvolutorTest_temp1() { Run run = new XCaliburRun2(FileRefs.RawDataMSFiles.OrbitrapStdFile1); #if !Disable_DeconToolsV2 var parameters = new DeconEngineClasses.OldDecon2LSParameters(); var paramFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\ParameterFiles\LTQ_Orb_SN2_PeakBR1pt3_PeptideBR1_Thrash_MaxFit1.xml"; parameters.Load(paramFile); var scanSet = new ScanSetFactory().CreateScanSet(run, 6005, 1); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true); var deconvolutor = new HornDeconvolutor(parameters.GetDeconToolsParameters()); run.CurrentScanSet = scanSet; msgen.Execute(run.ResultCollection); peakDetector.Execute(run.ResultCollection); deconvolutor.Execute(run.ResultCollection); run.ResultCollection.ResultList = run.ResultCollection.ResultList.OrderByDescending(p => p.IntensityAggregate).ToList(); TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList); //IsosResult testIso = run.ResultCollection.ResultList[0]; //TestUtilities.DisplayIsotopicProfileData(testIso.IsotopicProfile); //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList); //TestUtilities.DisplayPeaks(run.PeakList); #endif }
private ScanSet CreateScanSet(int scanNum) { ScanSetFactory ssf = new ScanSetFactory(); int closestScanNum = Run.GetClosestMSScan(scanNum, DeconTools.Backend.Globals.ScanSelectionMode.CLOSEST); return(ssf.CreateScanSet(this.Run, closestScanNum, this.NumScansSummed)); }
public void MSGeneratorOnUIMFTest1() { var uimfFile = FileRefs.RawDataMSFiles.UIMFStdFile3; var run = new RunFactory().CreateRun(uimfFile); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true); var zeroFiller = new DeconTools.Backend.ProcessingTasks.ZeroFillers.DeconToolsZeroFiller(3); var thrashParameters = new ThrashParameters(); thrashParameters.MinMSFeatureToBackgroundRatio = 1; thrashParameters.MaxFit = 0.4; var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters); var testLCScan = 500; var testIMSScan = 120; var numIMSScanSummed = 7; var lowerIMSScan = testIMSScan - (numIMSScanSummed - 1) / 2; var upperIMSScan = testIMSScan + (numIMSScanSummed - 1) / 2; var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1); run.CurrentScanSet = scanSet; ((UIMFRun)run).CurrentIMSScanSet = new IMSScanSet(testIMSScan, lowerIMSScan, upperIMSScan); msgen.Execute(run.ResultCollection); Assert.IsTrue(run.XYData.Xvalues.Length > 100); }
public void Test1() { var rf = new RunFactory(); var run = rf.CreateRun(FileRefs.RawDataMSFiles.OrbitrapStdFile1); var ssf = new ScanSetFactory(); var scan = ssf.CreateScanSet(run, 6005, 11); Console.WriteLine(scan); }
public void CreateScanSetBasedOnRangeOfScansTest1() { 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()); }
public void MSGeneratorOnOrbiTest1() { var testfile = FileRefs.RawDataMSFiles.OrbitrapStdFile1; var run = new RunFactory().CreateRun(testfile); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var testLCScan = 6005; var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1); var xydata = msgen.GenerateMS(run, scanSet); Assert.IsNotNull(xydata); Assert.IsTrue(xydata.Xvalues.Length > 1000); }
public void ThrashV2OnIMSDataTest1() { var uimfFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\UIMF\Sarc_MS2_90_6Apr11_Cheetah_11-02-19.uimf"; var run = new RunFactory().CreateRun(uimfFile); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true); var zeroFiller = new DeconTools.Backend.ProcessingTasks.ZeroFillers.DeconToolsZeroFiller(3); var thrashParameters = new ThrashParameters(); thrashParameters.MinMSFeatureToBackgroundRatio = 1; thrashParameters.MaxFit = 0.4; var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters); var testLCScan = 500; var testIMSScan = 120; var numIMSScanSummed = 7; var lowerIMSScan = testIMSScan - (numIMSScanSummed - 1) / 2; var upperIMSScan = testIMSScan + (numIMSScanSummed - 1) / 2; var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1); run.CurrentScanSet = scanSet; ((UIMFRun)run).CurrentIMSScanSet = new IMSScanSet(testIMSScan, lowerIMSScan, upperIMSScan); msgen.Execute(run.ResultCollection); zeroFiller.Execute(run.ResultCollection); peakDetector.Execute(run.ResultCollection); newDeconvolutor.Execute(run.ResultCollection); TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList); Assert.IsTrue(run.ResultCollection.ResultList.Count > 0); Assert.AreEqual(33, run.ResultCollection.ResultList.Count); var result1 = run.ResultCollection.ResultList[0]; Assert.AreEqual(13084442, (decimal)Math.Round(result1.IntensityAggregate)); Assert.AreEqual(960.53365m, (decimal)Math.Round(result1.IsotopicProfile.MonoIsotopicMass, 5)); Assert.AreEqual(2, result1.IsotopicProfile.ChargeState); }
public void UIMFTesting1() { var uimfFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\UIMF\Sarc_MS2_90_6Apr11_Cheetah_11-02-19.uimf"; var run = new RunFactory().CreateRun(uimfFile); var testLCScan = 500; var testIMSScan = 120; var numIMSScanSummed = 7; var lowerIMSScan = testIMSScan - (numIMSScanSummed - 1) / 2; var upperIMSScan = testIMSScan + (numIMSScanSummed - 1) / 2; var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var peakDetector = new DeconToolsPeakDetectorV2(2, 2, DeconTools.Backend.Globals.PeakFitType.QUADRATIC, true); var thrashParameters = new ThrashParameters(); thrashParameters.MinMSFeatureToBackgroundRatio = 2; thrashParameters.MaxFit = 0.4; var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters); run.CurrentScanSet = scanSet; ((UIMFRun)run).CurrentIMSScanSet = new IMSScanSet(testIMSScan, lowerIMSScan, upperIMSScan); msgen.Execute(run.ResultCollection); peakDetector.Execute(run.ResultCollection); //6 500 728.6907 729.69800 1 34678 0.252 0.000 run.PeakList = (from n in run.PeakList where n.XValue > 729 && n.XValue < 731 select n).ToList(); newDeconvolutor.Execute(run.ResultCollection); TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList); }
protected override void IterateOverScans() { DeconMSnResults.Clear(); _scanCounter = 0; var resultCounter = 0; foreach (var scanSet in Run.ScanSetCollection.ScanSetList) { _scanCounter++; if (BackgroundWorker != null) { if (BackgroundWorker.CancellationPending) { return; } } //check ms level var currentMSLevel = Run.GetMSLevel(scanSet.PrimaryScanNumber); if (currentMSLevel == 1) { Run.ResultCollection.IsosResultBin.Clear(); Run.CurrentScanSet = scanSet; MSGenerator.Execute(Run.ResultCollection); _currentMS1XYValues = new XYData { Xvalues = Run.XYData.Xvalues, Yvalues = Run.XYData.Yvalues }; _currentMS1TICIntensity = Run.GetTICFromInstrumentInfo(scanSet.PrimaryScanNumber); PeakDetector.Execute(Run.ResultCollection); _currentMS1Peaks = new List <Peak>(Run.PeakList); } else if (currentMSLevel == 2) { if (_currentMS1Peaks == null || _currentMS1Peaks.Count == 0) { continue; } var precursorInfo = Run.GetPrecursorInfo(scanSet.PrimaryScanNumber); Run.CurrentScanSet = scanSet; var inaccurateParentMZ = precursorInfo.PrecursorMZ; resultCounter++; var deconMSnResult = new DeconMSnResult { ParentScan = Run.GetParentScan(scanSet.PrimaryScanNumber) }; deconMSnResult.IonInjectionTime = Run.GetIonInjectionTimeInMilliseconds(deconMSnResult.ParentScan); deconMSnResult.ScanNum = scanSet.PrimaryScanNumber; deconMSnResult.OriginalMZTarget = inaccurateParentMZ; deconMSnResult.ParentScanTICIntensity = _currentMS1TICIntensity; MSGenerator.Execute(Run.ResultCollection); var lowerMZ = inaccurateParentMZ - 1.1; var upperMZ = inaccurateParentMZ + 1.1; var dataIsCentroided = Run.IsDataCentroided(scanSet.PrimaryScanNumber); if (dataIsCentroided) { _ms2PeakDetectorForCentroidData.Execute(Run.ResultCollection); } else { _ms2PeakDetectorForProfileData.Execute(Run.ResultCollection); } var ms2Peaks = new List <Peak>(Run.PeakList); var filteredMS1Peaks = _currentMS1Peaks.Where(p => p.XValue > lowerMZ && p.XValue < upperMZ).ToList(); IsotopicProfile selectedMS1Feature = null; for (var attemptNum = 0; attemptNum < NumMaxAttemptsAtLowIntensitySpecies; attemptNum++) { var candidateMS1Features = GetCandidateMS1Features(inaccurateParentMZ, filteredMS1Peaks); //if none were found, will regenerate MS1 spectrum and find peaks again if (candidateMS1Features.Count == 0) { var numSummed = attemptNum * 2 + 3; var ms1Scan = precursorInfo.PrecursorScan; var ms1ScanSet = new ScanSetFactory().CreateScanSet(Run, ms1Scan, numSummed); //get MS1 mass spectrum again. This time sum spectra Run.CurrentScanSet = ms1ScanSet; MSGenerator.Execute(Run.ResultCollection); //run MS1 peak detector, with greater sensitivity var isLastAttempt = attemptNum >= NumMaxAttemptsAtLowIntensitySpecies - 2; //need to do -2 because of the way the loop advances the counter. if (isLastAttempt) { _superSensitiveMS1PeakDetector.MinX = lowerMZ; _superSensitiveMS1PeakDetector.MaxX = upperMZ; _superSensitiveMS1PeakDetector.Execute(Run.ResultCollection); filteredMS1Peaks = new List <Peak>(Run.PeakList); } else { _moreSensitiveMS1PeakDetector.Execute(Run.ResultCollection); var moreSensitiveMS1Peaks = new List <Peak>(Run.PeakList); filteredMS1Peaks = moreSensitiveMS1Peaks.Where(p => p.XValue > lowerMZ && p.XValue < upperMZ).ToList(); } } else if (candidateMS1Features.Count == 1) { selectedMS1Feature = candidateMS1Features.First(); break; //we found something, so no need for any further attempts } else { var highQualityCandidates = candidateMS1Features.Where(p => p.Score < 0.15).ToList(); if (highQualityCandidates.Count == 0) { selectedMS1Feature = candidateMS1Features.OrderByDescending(p => p.IntensityMostAbundantTheor).First(); } else if (highQualityCandidates.Count == 1) { selectedMS1Feature = highQualityCandidates.First(); } else { selectedMS1Feature = highQualityCandidates.OrderByDescending(p => p.IntensityMostAbundantTheor).First(); } deconMSnResult.ExtraInfo = "Warning - multiple MSFeatures found for target parent MZ"; break; //we found something, so no need for any further attempts } } if (selectedMS1Feature != null) { deconMSnResult.ParentMZ = selectedMS1Feature.MonoPeakMZ; deconMSnResult.ParentChargeState = selectedMS1Feature.ChargeState; deconMSnResult.ParentIntensity = selectedMS1Feature.IntensityMostAbundantTheor; deconMSnResult.IntensityAggregate = selectedMS1Feature.IntensityMostAbundantTheor; deconMSnResult.IsotopicProfile = selectedMS1Feature; } else { var candidatePeaks = new List <Peak>(); foreach (var peak in filteredMS1Peaks) { var currentDiff = Math.Abs(peak.XValue - inaccurateParentMZ); var toleranceInMZ = ToleranceInPPM * peak.XValue / 1e6; if (currentDiff < toleranceInMZ) { candidatePeaks.Add(peak); } } Peak selectedPeak = null; if (candidatePeaks.Count == 0) { //cannot even find a suitable MS1 peak. So can't do anything } else if (candidatePeaks.Count == 1) { selectedPeak = candidatePeaks.First(); } else { selectedPeak = candidatePeaks.OrderByDescending(p => p.Height).First(); } if (selectedPeak != null) { deconMSnResult.ParentMZ = selectedPeak.XValue; deconMSnResult.ParentChargeState = 1; //not sure what charge I should assign... Ask SangTae deconMSnResult.ParentIntensity = selectedPeak.Height; deconMSnResult.IsotopicProfile = null; deconMSnResult.ExtraInfo = "Failure code 1: No MSFeature, but peak found"; } else { deconMSnResult.ParentMZ = precursorInfo.PrecursorMZ; //could not find the accurate parentMZ, so just report what the instrument found. deconMSnResult.ParentChargeState = 1; //not sure what charge I should assign... Ask SangTae deconMSnResult.ParentIntensity = 0; deconMSnResult.IsotopicProfile = null; deconMSnResult.ExtraInfo = "Failure code 2: No MSFeature or peak found"; } } //Build export data. var outputString = GetMGFOutputString(Run, scanSet.PrimaryScanNumber, deconMSnResult, ms2Peaks); var includeHeader = resultCounter == 1; var summaryString = GetSummaryString(deconMSnResult, includeHeader); var parentProfileString = GetParentProfileString(deconMSnResult, includeHeader); if (ExportData) { WriteOutMainData(outputString); WriteOutDeconMSnSummary(summaryString); if (IsParentProfileDataExported) { WriteOutParentProfileInfoString(parentProfileString); } } if (deconMSnResult.ParentIntensity > 0) { DeconMSnResults.Add(deconMSnResult); } } else { throw new ApplicationException( "DeconMSn only works on MS1 and MS2 data; You are attempting MS3"); } ReportProgress(); } }
protected override void ExecuteWorkflow(IqResult result) { var children = result.Target.ChildTargets().ToList(); foreach (var child in children) { child.DoWorkflow(); var childResult = child.GetResult(); var chromPeakLevelResults = childResult.ChildResults(); var filteredChromPeakResults = chromPeakLevelResults.Where(r => r.IsotopicProfileFound).ToList(); childResult.FavoriteChild = SelectBestChromPeakIqResult(childResult, filteredChromPeakResults); GetDataFromFavoriteChild(childResult); } result.FavoriteChild = SelectBestChargeStateChildResult(result); GetDataFromFavoriteChild(result); var favResult = result.FavoriteChild; double?rsquaredVal, slope; getRsquaredVal(result, out rsquaredVal, out slope); var favChargeState = result.FavoriteChild == null ? 0 : result.FavoriteChild.Target.ChargeState; var favMz = result.FavoriteChild == null ? 0 : result.FavoriteChild.Target.MZTheor; if (!_headerLogged) { _headerLogged = true; IqLogger.Log.Info("\t" + "TargetID" + "\t\t\t" + "M/Z" + "\t" + "Charge" + "\t" + "LCScan" + "\t" + "RSquared" + "\t" + "Slope"); } IqLogger.Log.Info("\t" + result.Target.ID + "\t\t\t" + favMz.ToString("0.000") + "\t" + favChargeState + "\t" + result.LcScanObs + "\t" + rsquaredVal + "\t" + slope); //now get the mass spectrum given the info from the favorite child charge state result if (favResult != null) { var scanset = new ScanSetFactory().CreateScanSet(Run, favResult.LCScanSetSelected.PrimaryScanNumber, WorkflowParameters.NumMSScansToSum); var selectedChromPeak = favResult.ChromPeakSelected; var sigma = selectedChromPeak.Width / 2.35; var chromScanWindowWidth = 4 * sigma; //Determines where to start and stop chromatogram correlation var startScan = scanset.PrimaryScanNumber - (int)Math.Round(chromScanWindowWidth / 2, 0); var stopScan = scanset.PrimaryScanNumber + (int)Math.Round(chromScanWindowWidth / 2, 0); var massSpectrum = MSGenerator.GenerateMS(Run, scanset); foreach (var iqTarget in children) { var childStateIqResult = (O16O18IqResult)iqTarget.GetResult(); childStateIqResult.IqResultDetail.MassSpectrum = massSpectrum.TrimData(iqTarget.MZTheor - 3, iqTarget.MZTheor + 8); var mspeakList = _mspeakDetector.FindPeaks(childStateIqResult.IqResultDetail.MassSpectrum.Xvalues, childStateIqResult.IqResultDetail.MassSpectrum.Yvalues); childStateIqResult.CorrelationData = ChromatogramCorrelator.CorrelateData(Run, childStateIqResult, startScan, stopScan); childStateIqResult.CorrelationO16O18SingleLabel = childStateIqResult.GetCorrelationO16O18SingleLabel(); childStateIqResult.CorrelationO16O18DoubleLabel = childStateIqResult.GetCorrelationO16O18DoubleLabel(); childStateIqResult.CorrelationBetweenSingleAndDoubleLabel = childStateIqResult.GetCorrelationBetweenSingleAndDoubleLabel(); childStateIqResult.RatioO16O18DoubleLabel = childStateIqResult.GetRatioO16O18DoubleLabel(); childStateIqResult.RatioO16O18SingleLabel = childStateIqResult.GetRatioO16O18SingleLabel(); childStateIqResult.RatioSingleToDoubleLabel = childStateIqResult.GetRatioSingleToDoubleLabel(); childStateIqResult.ObservedIsotopicProfile = MsfeatureFinder.IterativelyFindMSFeature(childStateIqResult.IqResultDetail.MassSpectrum, iqTarget.TheorIsotopicProfile); if (childStateIqResult.ObservedIsotopicProfile != null) { var observedIsoList = childStateIqResult.ObservedIsotopicProfile.Peaklist.Cast <Peak>().Take(4).ToList(); //first 4 peaks excludes the O18 double label peak (fifth peak) var theorPeakList = iqTarget.TheorIsotopicProfile.Peaklist.Select(p => (Peak)p).Take(4).ToList(); childStateIqResult.FitScore = PeakFitter.GetFit(theorPeakList, observedIsoList, 0.05, WorkflowParameters.MSToleranceInPPM); var o18Iso = childStateIqResult.ConvertO16ProfileToO18(iqTarget.TheorIsotopicProfile, 4); theorPeakList = o18Iso.Peaklist.Select(p => (Peak)p).ToList(); observedIsoList = childStateIqResult.ObservedIsotopicProfile.Peaklist.Cast <Peak>().Skip(4).ToList(); //skips the first 4 peaks and thus includes the O18 double label isotopic profile childStateIqResult.FitScoreO18Profile = PeakFitter.GetFit(theorPeakList, observedIsoList, 0.05, WorkflowParameters.MSToleranceInPPM); childStateIqResult.InterferenceScore = InterferenceScorer.GetInterferenceScore(childStateIqResult.ObservedIsotopicProfile, mspeakList); childStateIqResult.MZObs = childStateIqResult.ObservedIsotopicProfile.MonoPeakMZ; childStateIqResult.MonoMassObs = childStateIqResult.ObservedIsotopicProfile.MonoIsotopicMass; childStateIqResult.MZObsCalibrated = Run.GetAlignedMZ(childStateIqResult.MZObs); childStateIqResult.MonoMassObsCalibrated = (childStateIqResult.MZObsCalibrated - DeconTools.Backend.Globals.PROTON_MASS) * childStateIqResult.Target.ChargeState; childStateIqResult.ElutionTimeObs = ((ChromPeak)favResult.ChromPeakSelected).NETValue; } else { childStateIqResult.FitScore = -1; childStateIqResult.InterferenceScore = -1; } getRsquaredVal(childStateIqResult, out rsquaredVal, out slope); IqLogger.Log.Info("\t\t\t" + childStateIqResult.Target.ID + "\t" + childStateIqResult.Target.MZTheor.ToString("0.000") + "\t" + childStateIqResult.Target.ChargeState + "\t" + childStateIqResult.LcScanObs + "\t" + childStateIqResult.FitScore.ToString("0.000") + "\t" + rsquaredVal + "\t" + slope); childStateIqResult.LCScanSetSelected = favResult.LCScanSetSelected; childStateIqResult.LcScanObs = favResult.LcScanObs; if (GraphsAreOutputted) { if (_graphGenerator == null) { _graphGenerator = new BasicGraphControl(); } ExportGraphs(childStateIqResult); } } } }
public void CompareOldAndNewDeconvolutorsUIMF() { var uimfFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\UIMF\Sarc_MS2_90_6Apr11_Cheetah_11-02-19.uimf"; var run = new RunFactory().CreateRun(uimfFile); var testLCScan = 500; var testIMSScan = 120; var numIMSScanSummed = 7; var lowerIMSScan = testIMSScan - (numIMSScanSummed - 1) / 2; var upperIMSScan = testIMSScan + (numIMSScanSummed - 1) / 2; var scanSet = new ScanSetFactory().CreateScanSet(run, testLCScan, 1); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var peakDetector = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true); var zeroFiller = new DeconTools.Backend.ProcessingTasks.ZeroFillers.DeconToolsZeroFiller(3); var thrashParameters = new ThrashParameters(); thrashParameters.MinMSFeatureToBackgroundRatio = 1; thrashParameters.MaxFit = 0.4; var newDeconvolutor = new ThrashDeconvolutorV2(thrashParameters); var oldDeconvolutor = new HornDeconvolutor(); oldDeconvolutor.MinPeptideBackgroundRatio = 1; oldDeconvolutor.MaxFitAllowed = 0.4; run.CurrentScanSet = scanSet; ((UIMFRun)run).CurrentIMSScanSet = new IMSScanSet(testIMSScan, lowerIMSScan, upperIMSScan); msgen.Execute(run.ResultCollection); zeroFiller.Execute(run.ResultCollection); //smoother.Execute(run.ResultCollection); peakDetector.Execute(run.ResultCollection); newDeconvolutor.Execute(run.ResultCollection); //Console.WriteLine("\n--------------New decon ------------------"); //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList); var newResults = new List <IsosResult>(run.ResultCollection.ResultList); // TestUtilities.DisplayMSFeatures(newResults); //DisplayPPMErrorsForeachPeakOfMSFeature(newResults); //return; run.ResultCollection.ResultList.Clear(); run.ResultCollection.IsosResultBin.Clear(); oldDeconvolutor.Execute(run.ResultCollection); var oldResults = new List <IsosResult>(run.ResultCollection.ResultList); //Console.WriteLine("\n--------------Old decon ------------------"); //TestUtilities.DisplayMSFeatures(run.ResultCollection.ResultList); var sharedIsos = new List <IsosResult>(); var uniqueToNew = new List <IsosResult>(); var uniqueToOld = new List <IsosResult>(); var toleranceForComparison = 0.05; foreach (var newresult in newResults) { var foundMatch = false; for (var i = 0; i < oldResults.Count; i++) { var oldResult = oldResults[i]; if (Math.Abs(newresult.IsotopicProfile.MonoIsotopicMass - oldResult.IsotopicProfile.MonoIsotopicMass) < toleranceForComparison && newresult.IsotopicProfile.ChargeState == oldResult.IsotopicProfile.ChargeState) { foundMatch = true; } } if (foundMatch) { sharedIsos.Add(newresult); } else { uniqueToNew.Add(newresult); } } foreach (var oldResult in oldResults) { var foundMatch = false; for (var i = 0; i < newResults.Count; i++) { var newresult = newResults[i]; if (Math.Abs(newresult.IsotopicProfile.MonoIsotopicMass - oldResult.IsotopicProfile.MonoIsotopicMass) < toleranceForComparison && newresult.IsotopicProfile.ChargeState == oldResult.IsotopicProfile.ChargeState) { foundMatch = true; } } if (!foundMatch) { uniqueToOld.Add(oldResult); } } Console.WriteLine("\n--------------Common to new and Old ------------------"); TestUtilities.DisplayMSFeatures(sharedIsos); Console.WriteLine("\n--------------Unique to new ------------------"); TestUtilities.DisplayMSFeatures(uniqueToNew); Console.WriteLine("\n--------------Unique to old ------------------"); TestUtilities.DisplayMSFeatures(uniqueToOld); }