public override void Execute(ResultCollection resultList) { var mt = resultList.Run.CurrentMassTag; Check.Require(mt != null, "Current mass tag is not defined."); var currentResult = resultList.CurrentTargetedResult; Check.Require(currentResult != null, "Quantifier failed. Result doesn't exist for current mass tag."); Check.Require(currentResult is N14N15_TResult, "Quantifier failed. Result is not of the N14N15 type."); var n14n15Result = ((N14N15_TResult)currentResult); var quant = new BasicN14N15Quantifier(this.MSToleranceInPPM, this.RatioType); var iso1 = ((N14N15_TResult)currentResult).IsotopicProfile; var iso2 = ((N14N15_TResult)currentResult).IsotopicProfileLabeled; if (iso1 == null || iso2 == null) { n14n15Result.RatioN14N15 = -1; } else { quant.GetRatioBasedOnTopPeaks(iso1, iso2, mt.IsotopicProfile, _N15IsotopicProfileGenerator.GetN15IsotopicProfile(mt, 0.005), currentResult.ScanSet.BackgroundIntensity, NumPeaksUsedInRatioCalc, out var ratio, out var ratioContribIso1, out var ratioContribIso2); n14n15Result.RatioN14N15 = ratio; n14n15Result.RatioContributionN14 = ratioContribIso1; n14n15Result.RatioContributionN15 = ratioContribIso2; } //((N14N15_TResult)currentResult).RatioN14N15 = quant.GetRatioBasedOnAreaUnderPeaks(resultColl.Run.XYData.Xvalues, resultColl.Run.XYData.Yvalues, iso1, iso2, currentResult.ScanSet.BackgroundIntensity); }
public void test01_mt230140708_z3() { double featureFinderTol = 15; var featureFinderRequiresMonoPeak = false; var numPeaksUsedInQuant = 3; var n14n15Util = new N14N15TestingUtilities(); //get MS var massSpectrum = n14n15Util.GetSpectrumAMTTag23140708_Z3_Sum3(); //this is the diff b/w previous test and this one var smoother = new DeconTools.Backend.ProcessingTasks.Smoothers.SavitzkyGolaySmoother(3, 2); massSpectrum = smoother.Smooth(massSpectrum); //get target MT var mt23140708 = n14n15Util.CreateMT23140708_Z3(); //get ms peaks var peakDet = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, false); var msPeakList = peakDet.FindPeaks(massSpectrum, 0, 0); //TestUtilities.DisplayPeaks(msPeakList); var featureGen = new TomTheorFeatureGenerator(); featureGen.GenerateTheorFeature(mt23140708); TestUtilities.DisplayIsotopicProfileData(mt23140708.IsotopicProfile); var featureGen2 = new JoshTheorFeatureGenerator(); featureGen2.GenerateTheorFeature(mt23140708); Console.WriteLine(); TestUtilities.DisplayIsotopicProfileData(mt23140708.IsotopicProfile); var gen = new N15IsotopeProfileGenerator(); var theorN15Profile = gen.GetN15IsotopicProfile(mt23140708, 0.005); var bff = new BasicTFF(featureFinderTol, featureFinderRequiresMonoPeak); var n14Profile = bff.FindMSFeature(msPeakList, mt23140708.IsotopicProfile); var n15Profile = bff.FindMSFeature(msPeakList, theorN15Profile); Console.WriteLine(mt23140708.GetEmpiricalFormulaFromTargetCode()); TestUtilities.DisplayIsotopicProfileData(mt23140708.IsotopicProfile); Console.WriteLine(); TestUtilities.DisplayIsotopicProfileData(theorN15Profile); Console.WriteLine(); TestUtilities.DisplayIsotopicProfileData(n14Profile); Console.WriteLine(); TestUtilities.DisplayIsotopicProfileData(n15Profile); var quant = new BasicN14N15Quantifier(featureFinderTol); double ratioContribIso1; double ratioContribIso2; double ratio; quant.GetRatioBasedOnTopPeaks(n14Profile, n15Profile, mt23140708.IsotopicProfile, theorN15Profile, peakDet.BackgroundIntensity, numPeaksUsedInQuant, out ratio, out ratioContribIso1, out ratioContribIso2); Console.WriteLine("--------------------------------"); Console.WriteLine("Background intensity = " + peakDet.BackgroundIntensity); Console.WriteLine("--------------------------------"); Console.WriteLine("Ratio = " + ratio); Console.WriteLine("Ratio contrib Iso1 = " + ratioContribIso1); Console.WriteLine("Ratio contrib Iso2 = " + ratioContribIso2); Console.WriteLine("--------------------------------"); Assert.AreEqual(1.458267m, (decimal)Math.Round(ratio, 6)); //see 'N14N15Quantification_manualValidation_of_algorithm.xls' for manual validation }