public void getVeryLowN15ProfileWithIterativeTFFTest1() { var n14n15Util = new N14N15TestingUtilities(); //get sample MS from Test Data var rf = new RunFactory(); var run = rf.CreateRun(N14N15TestingUtilities.MS_AMTTag23085904_z2_sum1_lowN15); run.XYData = N14N15TestingUtilities.GetTestSpectrum(N14N15TestingUtilities.MS_AMTTag23085904_z2_sum1_lowN15); var mt23140708 = n14n15Util.CreateMT23085904_Z2(); run.CurrentMassTag = mt23140708; run.ResultCollection.ResultType = Globals.ResultType.N14N15_TARGETED_RESULT; var theorN14FeatureGen = new TomTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005); theorN14FeatureGen.GenerateTheorFeature(mt23140708); var theorN15FeatureGen = new TomTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.N15, 0.005); theorN15FeatureGen.GenerateTheorFeature(mt23140708); var parameters = new IterativeTFFParameters(); parameters.IsotopicProfileType = Globals.IsotopicProfileType.LABELLED; parameters.ToleranceInPPM = 30; var itff = new IterativeTFF(parameters); itff.Execute(run.ResultCollection); // IsotopicProfile iso = itff.iterativelyFindMSFeature(run, mt23140708.IsotopicProfileLabelled); var result = (N14N15_TResult)run.ResultCollection.GetTargetedResult(run.CurrentMassTag); Assert.IsNotNull(result.IsotopicProfileLabeled); Assert.AreEqual(82280, (int)result.IntensityAggregate); Assert.AreEqual(3, result.IsotopicProfileLabeled.MonoIsotopicPeakIndex); TestUtilities.DisplayIsotopicProfileData(result.IsotopicProfileLabeled); }
public void smartChromPeakSelectorTest_noSumming() { var run = new RunFactory().CreateRun(xcaliburTestfile); run.Close(); run = new RunFactory().CreateRun(xcaliburTestfile); var massTagColl = new TargetCollection(); var masstagImporter = new MassTagFromTextFileImporter(massTagTestList1); massTagColl = masstagImporter.Import(); var chromAligner = new ChromAlignerUsingVIPERInfo(); chromAligner.Execute(run); var theorFeatureGen = new TomTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005); var chromPeakDet = new ChromPeakDetector(0.5, 1); var smartchromParam = new SmartChromPeakSelectorParameters(); var smartChromPeakSelector = new SmartChromPeakSelector(smartchromParam); var basicChromParam = new ChromPeakSelectorParameters(); var basicChromPeakSelector = new BasicChromPeakSelector(basicChromParam); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var iterativeTff = new IterativeTFF(new IterativeTFFParameters()); var fitscoreCalc = new IsotopicProfileFitScoreCalculator(); var testChromatogramDataFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\TargetedWorkflowStandards\massTag635428_chromatogramData.txt"; var xydata = TestUtilities.LoadXYDataFromFile(testChromatogramDataFile); Assert.IsNotNull(xydata); run.XYData = xydata; // run.XYData.Display(); run.CurrentMassTag = massTagColl.TargetList.Where(p => p.ID == 635428).First(); Console.WriteLine("------MT = " + run.CurrentMassTag.ToString()); theorFeatureGen.Execute(run.ResultCollection); chromPeakDet.Execute(run.ResultCollection); var result = run.ResultCollection.GetTargetedResult(run.CurrentMassTag); //first run the standard peak selector basicChromPeakSelector.Execute(run.ResultCollection); Assert.AreEqual(10066, (int)Math.Round(result.ChromPeakSelected.XValue)); //now run the smart chrom peak selector run.XYData = xydata; chromPeakDet.Execute(run.ResultCollection); smartChromPeakSelector.Parameters.NETTolerance = 0.025f; smartChromPeakSelector.Execute(run.ResultCollection); msgen.Execute(run.ResultCollection); iterativeTff.Execute(run.ResultCollection); TestUtilities.DisplayPeaks(run.PeakList); fitscoreCalc.Execute(run.ResultCollection); Assert.AreEqual(9579, (int)Math.Round(result.ChromPeakSelected.XValue)); //result.DisplayToConsole(); TestUtilities.DisplayIsotopicProfileData(result.Target.IsotopicProfile); }
public override void Execute(ResultCollection resultList) { Check.Require(resultList.Run.CurrentMassTag != null, this.Name + " failed. MassTag was not defined."); var currentResult = resultList.GetTargetedResult(resultList.Run.CurrentMassTag); if (msgen == null) { msgen = MSGeneratorFactory.CreateMSGenerator(resultList.Run.MSFileType); msgen.IsTICRequested = false; } var mt = resultList.Run.CurrentMassTag; float normalizedElutionTime; if (currentResult.Run.CurrentMassTag.ElutionTimeUnit == DeconTools.Backend.Globals.ElutionTimeUnit.ScanNum) { normalizedElutionTime = resultList.Run.CurrentMassTag.ScanLCTarget / (float)currentResult.Run.GetNumMSScans(); } else { normalizedElutionTime = resultList.Run.CurrentMassTag.NormalizedElutionTime; } //collect Chrom peaks that fall within the NET tolerance var peaksWithinTol = new List <ChromPeak>(); // foreach (ChromPeak peak in resultList.Run.PeakList) { if (Math.Abs(peak.NETValue - normalizedElutionTime) <= Parameters.NETTolerance) //peak.NETValue was determined by the ChromPeakDetector or a future ChromAligner Task { peaksWithinTol.Add(peak); } } var peakQualityList = new List <ChromPeakQualityData>(); //iterate over peaks within tolerance and score each peak according to MSFeature quality var tempMinScanWithinTol = (int)resultList.Run.NetAlignmentInfo.GetScanForNet(normalizedElutionTime - Parameters.NETTolerance); var tempMaxScanWithinTol = (int)resultList.Run.NetAlignmentInfo.GetScanForNet(normalizedElutionTime + Parameters.NETTolerance); var tempCenterTol = (int)resultList.Run.NetAlignmentInfo.GetScanForNet(normalizedElutionTime); IqLogger.Log.Debug("SmartPeakSelector --> NETTolerance= " + Parameters.NETTolerance + "; chromMinCenterMax= " + tempMinScanWithinTol + "\t" + tempCenterTol + "" + "\t" + tempMaxScanWithinTol); IqLogger.Log.Debug("MT= " + currentResult.Target.ID + ";z= " + currentResult.Target.ChargeState + "; mz= " + currentResult.Target.MZ.ToString("0.000") + "; ------------------------- PeaksWithinTol = " + peaksWithinTol.Count); currentResult.NumChromPeaksWithinTolerance = peaksWithinTol.Count; currentResult.NumQualityChromPeaks = -1; ChromPeak bestChromPeak; if (currentResult.NumChromPeaksWithinTolerance > _parameters.NumChromPeaksAllowed) { bestChromPeak = null; } else { foreach (var chromPeak in peaksWithinTol) { var pq = new ChromPeakQualityData(chromPeak); peakQualityList.Add(pq); var lcscanSet = ChromPeakUtilities.GetLCScanSetForChromPeak(chromPeak, resultList.Run, _parameters.NumMSSummedInSmartSelector); resultList.Run.CurrentScanSet = lcscanSet; //This resets the flags and the scores on a given result currentResult.ResetResult(); //generate a mass spectrum msgen.Execute(resultList); //find isotopic profile TargetedMSFeatureFinder.Execute(resultList); try { //get fit score fitScoreCalc.Execute(resultList); //get i_score resultValidator.Execute(resultList); } catch (Exception) { currentResult.FailedResult = true; } //collect the results together AddScoresToPeakQualityData(pq, currentResult); #if DEBUG IqLogger.Log.Debug(pq.Display() + Environment.NewLine); #endif } //run a algorithm that decides, based on fit score mostly. bestChromPeak = determineBestChromPeak(peakQualityList, currentResult); } currentResult.ChromPeakQualityList = peakQualityList; if (Parameters.SummingMode == SummingModeEnum.SUMMINGMODE_STATIC) { resultList.Run.CurrentScanSet = ChromPeakUtilities.GetLCScanSetForChromPeak(bestChromPeak, resultList.Run, Parameters.NumScansToSum); } else { resultList.Run.CurrentScanSet = ChromPeakUtilities.GetLCScanSetForChromPeakBasedOnPeakWidth(bestChromPeak, resultList.Run, Parameters.AreaOfPeakToSumInDynamicSumming, Parameters.MaxScansSummedInDynamicSumming); } UpdateResultWithChromPeakAndLCScanInfo(currentResult, bestChromPeak); }
public void smartChromPeakSelectorTest_withDynamicSumming() { var run = new RunFactory().CreateRun(xcaliburTestfile); var massTagColl = new TargetCollection(); var masstagImporter = new MassTagFromTextFileImporter(massTagTestList1); massTagColl = masstagImporter.Import(); var chromAligner = new ChromAlignerUsingVIPERInfo(); chromAligner.Execute(run); var theorFeatureGen = new TomTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005); var chromPeakDet = new ChromPeakDetector(0.5, 1); var smartchromParam = new SmartChromPeakSelectorParameters(); var smartChromPeakSelector = new SmartChromPeakSelector(smartchromParam); var basicChromPeakSelector = new BasicChromPeakSelector(new ChromPeakSelectorParameters()); var msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); var iterativeTff = new IterativeTFF(new IterativeTFFParameters()); var fitscoreCalc = new IsotopicProfileFitScoreCalculator(); var testChromatogramDataFile = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\TargetedWorkflowStandards\massTag635428_chromatogramData.txt"; var xydata = TestUtilities.LoadXYDataFromFile(testChromatogramDataFile); Assert.IsNotNull(xydata); run.XYData = new XYData(); run.XYData.Xvalues = xydata.Xvalues; run.XYData.Yvalues = xydata.Yvalues; // run.XYData.Display(); run.CurrentMassTag = massTagColl.TargetList.Where(p => p.ID == 635428).First(); Console.WriteLine("------MT = " + run.CurrentMassTag.ToString()); theorFeatureGen.Execute(run.ResultCollection); chromPeakDet.Execute(run.ResultCollection); //first run the standard peak selector basicChromPeakSelector.Execute(run.ResultCollection); var result = run.ResultCollection.GetTargetedResult(run.CurrentMassTag); Assert.AreEqual(10066, (int)Math.Round(result.ChromPeakSelected.XValue)); //now run the smart chrom peak selector run.XYData = new XYData(); run.XYData.Xvalues = xydata.Xvalues; run.XYData.Yvalues = xydata.Yvalues; chromPeakDet.Execute(run.ResultCollection); smartChromPeakSelector.Parameters.NETTolerance = 0.025f; smartChromPeakSelector.Parameters.MaxScansSummedInDynamicSumming = 51; smartChromPeakSelector.Parameters.SummingMode = SummingModeEnum.SUMMINGMODE_DYNAMIC; smartChromPeakSelector.Parameters.AreaOfPeakToSumInDynamicSumming = 1; smartChromPeakSelector.Execute(run.ResultCollection); msgen.Execute(run.ResultCollection); iterativeTff.Execute(run.ResultCollection); fitscoreCalc.Execute(run.ResultCollection); Console.WriteLine(result.ScanSet); Assert.AreEqual(14, result.ScanSet.IndexValues.Count); Assert.AreEqual(0.0104m, (decimal)Math.Round(result.Score, 4)); Assert.AreEqual("9575 {9534, 9540, 9547, 9554, 9561, 9568, 9575, 9582, 9589, 9596, 9603, 9610, 9617, 9624}", result.ScanSet.ToString()); run.XYData = new XYData(); run.XYData.Xvalues = xydata.Xvalues; run.XYData.Yvalues = xydata.Yvalues; chromPeakDet.Execute(run.ResultCollection); smartChromPeakSelector.Parameters.NETTolerance = 0.025f; smartChromPeakSelector.Parameters.MaxScansSummedInDynamicSumming = 51; smartChromPeakSelector.Parameters.SummingMode = SummingModeEnum.SUMMINGMODE_DYNAMIC; smartChromPeakSelector.Parameters.AreaOfPeakToSumInDynamicSumming = 2; smartChromPeakSelector.Execute(run.ResultCollection); msgen.Execute(run.ResultCollection); iterativeTff.Execute(run.ResultCollection); fitscoreCalc.Execute(run.ResultCollection); result.DisplayToConsole(); Assert.AreEqual(9579, (int)Math.Round(result.ChromPeakSelected.XValue)); Assert.AreEqual(0.025m, (decimal)(Math.Round(result.Score, 4))); //Console.WriteLine(result.ScanSet); Assert.AreEqual(26, result.ScanSet.IndexValues.Count); Assert.AreEqual("9575 {9493, 9500, 9506, 9513, 9520, 9527, 9534, 9540, 9547, 9554, 9561, 9568, 9575, 9582, 9589, 9596, 9603, 9610, 9617, 9624, 9631, 9638, 9645, 9652, 9658, 9665}", result.ScanSet.ToString()); }