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 }
public void find_targetMassTag_131959Test1() { var run = new RunFactory().CreateRun(xcaliburTestfile); var masstagImporter = new MassTagFromTextFileImporter(massTagTestList1); var massTagColl = masstagImporter.Import(); Assert.AreEqual(2719, massTagColl.TargetList.Count); var chromAligner = new ChromAlignerUsingVIPERInfo(); chromAligner.Execute(run); var peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(xcaliburAllPeaksFile); peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList); //int mtID = 635428; var mtID = 131959; Task peakChromGen = new PeakChromatogramGenerator(20); Task smoother = new DeconTools.Backend.ProcessingTasks.Smoothers.SavitzkyGolaySmoother(23, 2); Task zeroFill = new DeconTools.Backend.ProcessingTasks.ZeroFillers.DeconToolsZeroFiller(3); Task peakDet = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector(0.5, 1); Task msPeakDet = new DeconToolsPeakDetectorV2(1.3, 2, Globals.PeakFitType.QUADRATIC, true); var basicChromPeakSelParam = new ChromPeakSelectorParameters(); basicChromPeakSelParam.NETTolerance = 0.1f; basicChromPeakSelParam.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget; Task chromPeakSel = new BasicChromPeakSelector(basicChromPeakSelParam); Task msgen = MSGeneratorFactory.CreateMSGenerator(run.MSFileType); run.CurrentMassTag = massTagColl.TargetList.Find(p => p.ID == mtID); var mt = run.CurrentMassTag; mt.MZ = mt.MonoIsotopicMass / mt.ChargeState + Globals.PROTON_MASS; Task theorFeatureGen = new TomTheorFeatureGenerator(DeconTools.Backend.Globals.LabellingType.NONE, 0.005); Task targetedFeatureFinder = new BasicTFF(); Task fitScoreCalc = new IsotopicProfileFitScoreCalculator(); theorFeatureGen.Execute(run.ResultCollection); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("------------------- MassTag = " + mt.ID + "---------------------------"); Console.WriteLine("monoMass = " + mt.MonoIsotopicMass.ToString("0.0000") + "; monoMZ = " + mt.MZ.ToString("0.0000") + "; ChargeState = " + mt.ChargeState + "; NET = " + mt.NormalizedElutionTime.ToString("0.000") + "; Sequence = " + mt.Code + "; EmpiricalFormula= " + mt.EmpiricalFormula + "\n"); peakChromGen.Execute(run.ResultCollection); smoother.Execute(run.ResultCollection); //TestUtilities.DisplayXYValues(run.ResultCollection); peakDet.Execute(run.ResultCollection); TestUtilities.DisplayPeaks(run.PeakList); chromPeakSel.Execute(run.ResultCollection); msgen.Execute(run.ResultCollection); //TestUtilities.DisplayXYValues(run.ResultCollection); msPeakDet.Execute(run.ResultCollection); targetedFeatureFinder.Execute(run.ResultCollection); fitScoreCalc.Execute(run.ResultCollection); var massTagResult = run.ResultCollection.MassTagResultList[mt]; massTagResult.DisplayToConsole(); //Console.WriteLine("------------------------------ end --------------------------"); }
public void ChromAnalysisForAllSelectedPrecursors() { var isDataSmoothed = true; var numPointsInSmoothing = 9; var smoother = new DeconTools.Backend.ProcessingTasks.Smoothers.SavitzkyGolaySmoother(numPointsInSmoothing, 2); var graphGenerator = new BasicGraphControl(); var thermoFile1 = @"\\protoapps\UserData\Slysz\DeconTools_TestFiles\Orbitrap\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW"; var run = new RunFactory().CreateRun(thermoFile1); var outputFolderForChromGraphs = @"\\protoapps\DataPkgs\Public\2012\684_DeconMSn_research1\ChromatogramImages"; if (!Directory.Exists(outputFolderForChromGraphs)) { Directory.CreateDirectory(outputFolderForChromGraphs); } var scanSetCollection = new ScanSetCollection(); var scanStart = run.MinLCScan; var scanStop = run.MaxLCScan; scanSetCollection.Create(run, scanStart, scanStop, 1, 1, true); var sb = new StringBuilder(); var expectedPeaksFile = Path.Combine(run.DataSetPath, run.DatasetName + "_peaks.txt"); if (!File.Exists(expectedPeaksFile)) { var peakCreatorParams = new PeakDetectAndExportWorkflowParameters(); peakCreatorParams.PeakBR = 1.75; var peakCreator = new PeakDetectAndExportWorkflow(run, peakCreatorParams); peakCreator.Execute(); } var peakImporter = new PeakImporterFromText(expectedPeaksFile); peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList); double ppmTol = 50; var peakChromatogramGenerator = new PeakChromatogramGenerator(ppmTol, Globals.ChromatogramGeneratorMode.MZ_BASED); var scansetList = scanSetCollection.ScanSetList; var scanCounter = 0; var currentBin = 0; foreach (var scanSet in scansetList) { run.CurrentScanSet = scanSet; var currentScanLevel = run.GetMSLevel(scanSet.PrimaryScanNumber); if (currentScanLevel > 1) { scanCounter++; var precursorInfo = run.GetPrecursorInfo(scanSet.PrimaryScanNumber); var scanInfo = run.GetScanInfo(scanSet.PrimaryScanNumber); var scanWindowSize = 400; var startScan = scanSet.PrimaryScanNumber - scanWindowSize / 2; var stopScan = scanSet.PrimaryScanNumber + scanWindowSize / 2; run.XYData = peakChromatogramGenerator.GenerateChromatogram(run, startScan, stopScan, precursorInfo.PrecursorMZ, ppmTol); if (run.XYData == null) { run.XYData = new XYData(); run.XYData.Xvalues = new double[] { 0, 1, 2 }; run.XYData.Yvalues = new double[] { 0, 1, 2 }; Console.WriteLine(scanSet.PrimaryScanNumber + "\t" + precursorInfo.MSLevel + "\t" + precursorInfo.PrecursorMZ + "\t" + precursorInfo.PrecursorScan + "--------- NO XYData!!! -------------"); } else { if (isDataSmoothed) { run.XYData = smoother.Smooth(run.XYData); } } Console.WriteLine(scanSet.PrimaryScanNumber + "\t" + precursorInfo.MSLevel + "\t" + precursorInfo.PrecursorMZ + "\t" + precursorInfo.PrecursorScan); graphGenerator.GenerateGraph(run.XYData.Xvalues, run.XYData.Yvalues); var line = graphGenerator.GraphPane.CurveList[0] as LineItem; line.Line.IsVisible = true; line.Symbol.Size = 2; line.Symbol.Type = SymbolType.Circle; graphGenerator.GraphPane.XAxis.Title.Text = "scan"; graphGenerator.GraphPane.YAxis.Title.Text = "intensity"; graphGenerator.GraphPane.XAxis.Scale.MinAuto = true; graphGenerator.GraphPane.YAxis.Scale.MinAuto = false; graphGenerator.GraphPane.YAxis.Scale.Min = 0; graphGenerator.GraphPane.XAxis.Scale.FontSpec.Size = 12; graphGenerator.AddVerticalLineToGraph(scanSet.PrimaryScanNumber, 3); graphGenerator.AddAnnotationRelativeAxis(scanInfo, 0.3, 0.1); if (scanCounter > 500) { currentBin++; scanCounter = 0; } var currentOutputFolder = Path.Combine(outputFolderForChromGraphs, "bin" + currentBin); if (!Directory.Exists(currentOutputFolder)) { Directory.CreateDirectory(currentOutputFolder); } var baseFilename = Path.Combine(currentOutputFolder, scanSet.PrimaryScanNumber.ToString().PadLeft(5, '0') + "_mz" + precursorInfo.PrecursorMZ); string outputGraphFilename; string outputXYData; if (isDataSmoothed) { outputGraphFilename = baseFilename + "_smoothed_chrom.png"; outputXYData = baseFilename + "_smoothed_xydata.txt"; } else { outputXYData = baseFilename + "_xydata.txt"; outputGraphFilename = baseFilename + "_chrom.png"; } graphGenerator.SaveGraph(outputGraphFilename); TestUtilities.WriteToFile(run.XYData, outputXYData); } } Console.WriteLine(sb.ToString()); }