private static void writeStandardInfoToResult(TargetedResult tr, MassTagResultBase result) { if (result.MassTag == null) { throw new ArgumentNullException("Cannot create result object. MassTag is null."); } if (result.Run == null) { throw new ArgumentNullException("Cannot create result object. Run is null."); } tr.DatasetName = result.Run.DatasetName; tr.MassTagID = result.MassTag.ID; tr.ChargeState = result.MassTag.ChargeState; tr.IndexOfMostAbundantPeak = result.IsotopicProfile == null ? (short)0 : (short)result.IsotopicProfile.getIndexOfMostIntensePeak(); tr.Intensity = result.IsotopicProfile == null ? 0f : (float)result.IsotopicProfile.IntensityAggregate; tr.IntensityI0 = result.IsotopicProfile == null ? 0f : (float)result.IsotopicProfile.GetMonoAbundance(); tr.IntensityMostAbundantPeak = result.IsotopicProfile == null ? 0f : (float)result.IsotopicProfile.getMostIntensePeak().Height; tr.IScore = (float)result.InterferenceScore; tr.MonoMass = result.IsotopicProfile == null ? 0f: result.IsotopicProfile.MonoIsotopicMass; tr.MonoMZ = result.IsotopicProfile == null ? 0f : result.IsotopicProfile.MonoPeakMZ; tr.NET = (float)result.GetNET(); tr.NumChromPeaksWithinTol = result.NumChromPeaksWithinTolerance; tr.FitScore = (float)result.Score; tr.ScanLC = result.GetScanNum(); if (result.ChromPeakSelected != null) { double sigma = result.ChromPeakSelected.Width / 2.35; tr.ScanLCStart = (int)Math.Round(result.ChromPeakSelected.XValue - sigma); tr.ScanLCEnd = (int)Math.Round(result.ChromPeakSelected.XValue + sigma); } }
public static TargetedResult CreateTargetedResult(MassTagResultBase result) { TargetedResult tr; if (result is MassTagResult) { tr = new UnlabelledTargetedResult(); writeStandardInfoToResult(tr, result); addAdditionalInfo(tr, result as MassTagResult); } else if (result is O16O18_TResult) { tr = new O16O18TargetedResult(); writeStandardInfoToResult(tr, result); addAdditionalInfo(tr, result as O16O18_TResult); } else if (result is N14N15_TResult) { tr = new N14N15TargetedResult(); writeStandardInfoToResult(tr, result); addAdditionalInfo(tr, result as N14N15_TResult); } else { throw new NotImplementedException(); } return(tr); }
public void analyzeMassTags(Run run, List <long> massTagIDList, List <Task> taskList) { MassTagCollection massTagColl = new MassTagCollection(); run.ResultCollection.MassTagResultType = DeconTools.Backend.Globals.MassTagResultType.N14N15_MASSTAG_RESULT; massTagColl.MassTagIDList = massTagIDList; MassTagFromSqlDBImporter importer = new MassTagFromSqlDBImporter("MT_R_sphaeroides241_P513", "Albert"); importer.chargeStateFilterThreshold = 0.05; importer.Import(massTagColl); List <long> timingResults = new List <long>(); foreach (MassTag mt in massTagColl.MassTagList) { run.CurrentMassTag = mt; mt.MZ = mt.MonoIsotopicMass / mt.ChargeState + Globals.PROTON_MASS; 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.NETVal.ToString("0.000") + "; Sequence = " + mt.PeptideSequence + "\n"); Stopwatch sw = new Stopwatch(); sw.Start(); try { foreach (var task in taskList) { task.Execute(run.ResultCollection); } MassTagResultBase massTagResult = run.ResultCollection.MassTagResultList[mt]; massTagResult.DisplayToConsole(); Console.WriteLine("------------------------------ end --------------------------"); } catch (Exception ex) { Console.WriteLine("Task failed. Message: " + ex.Message + ex.StackTrace); } sw.Stop(); timingResults.Add(sw.ElapsedMilliseconds); } foreach (long tr in timingResults) { Console.WriteLine(tr); } Console.WriteLine("-------- Analysis time for all MTs = " + timingResults.Sum()); Console.WriteLine("-------- Average time for each MT = " + timingResults.Average()); Console.WriteLine(); }
public void test1() { Run run = new XCaliburRun(xcaliburTestfile); List <MassTag> mass_tagList = TestUtilities.CreateTestMassTagList(); MassTag mt = mass_tagList[0]; run.CurrentScanSet = new ScanSet(9017, new int[] { 9010, 9017, 9024 }); run.CurrentMassTag = mt; MSGeneratorFactory msgenFactory = new MSGeneratorFactory(); Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType); DeconToolsV2.Peaks.clsPeakProcessorParameters peakParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(2, 1.3, true, DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC); Task mspeakDet = new DeconToolsPeakDetector(peakParams); Task theorFeatureGen = new TomTheorFeatureGenerator(); Task targetedFeatureFinder = new BasicTFF(0.01); IsotopicProfileFitScoreCalculator fitScoreCalc = new IsotopicProfileFitScoreCalculator(); msgen.Execute(run.ResultCollection); //run.XYData.Display(); mspeakDet.Execute(run.ResultCollection); theorFeatureGen.Execute(run.ResultCollection); targetedFeatureFinder.Execute(run.ResultCollection); fitScoreCalc.Execute(run.ResultCollection); MassTagResultBase result = run.ResultCollection.GetMassTagResult(mt); TestUtilities.DisplayIsotopicProfileData(result.IsotopicProfile); Console.WriteLine("Fit val = " + result.IsotopicProfile.Score); /* * * * ------------------- MassTag = 24769--------------------------- * monoMass = 2086.0595; monoMZ = 1044.0370; ChargeState = 2; NET = 0.452; Sequence = DFNEALVHQVVVAYAANAR * ****** Match ****** ******NET = 0.452 ******ChromPeak ScanNum = 9016.48992535631 ******ChromPeak NETVal = 0.453 ******ScanSet = { 9010, 9017, 9024, } ******Observed MZ and intensity = 1044.03290771556 1.269842E+07 ******------------------------------ end -------------------------- * * * * * */ }
public void test3() { MassTag massTag = new MassTag(); massTag.ID = 56488; massTag.MonoIsotopicMass = 2275.1694779; massTag.ChargeState = 3; massTag.MZ = massTag.MonoIsotopicMass / massTag.ChargeState + 1.00727649; massTag.NETVal = 0.3520239f; Run run = new XCaliburRun(xcaliburTestfile); ChromAlignerUsingVIPERInfo chromAligner = new ChromAlignerUsingVIPERInfo(); chromAligner.Execute(run); PeakImporterFromText peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(xcaliburPeakDataFile); peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList); run.CurrentMassTag = massTag; Task peakChromGen = new PeakChromatogramGenerator(20); Task smoother = new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(2, 2, 2); Task peakDet = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector(); Task chromPeakSel = new DeconTools.Backend.ProcessingTasks.ChromPeakSelector(1, 0.1); MSGeneratorFactory msgenFactory = new MSGeneratorFactory(); Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType); peakChromGen.Execute(run.ResultCollection); smoother.Execute(run.ResultCollection); peakDet.Execute(run.ResultCollection); chromPeakSel.Execute(run.ResultCollection); Console.WriteLine("Now generating MS...."); msgen.Execute(run.ResultCollection); Console.WriteLine("----------- RESULTS ----------------------\n"); TestUtilities.DisplayPeaks(run.PeakList); MassTagResultBase massTagResult = run.ResultCollection.MassTagResultList[massTag]; massTagResult.DisplayToConsole(); Assert.AreEqual(5512, massTagResult.ScanSet.PrimaryScanNumber); }
private bool resultPassesCriteria(MassTagResultBase result) { bool passesCriteria = true; if (result.ChromPeakSelected == null) { return(false); } if (result.IsotopicProfile == null) { return(false); } if (result.NumChromPeaksWithinTolerance > NumberOfChromPeaksWithinToleranceAllowed) { return(false); } if (result.ChromPeakSelected.Height < MinimumChromPeakIntensityCriteria) { return(false); } if (result.Score > UpperFitScoreAllowedCriteria) { return(false); } if (result.InterferenceScore > IScoreAllowedCriteria) { return(false); } if (result.Flags.Count > 0) { return(false); } return(passesCriteria); }
public void test1() { Run run = new XCaliburRun(xcaliburTestfile); List <MassTag> mass_tagList = TestUtilities.CreateTestMassTagList(); MassTag mt = mass_tagList[0]; run.CurrentScanSet = new ScanSet(9017, new int[] { 9010, 9017, 9024 }); run.CurrentMassTag = mt; MSGeneratorFactory msgenFactory = new MSGeneratorFactory(); Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType); DeconToolsV2.Peaks.clsPeakProcessorParameters peakParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(2, 1.3, true, DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC); Task mspeakDet = new DeconToolsPeakDetector(peakParams); Task theorFeatureGen = new TomTheorFeatureGenerator(); Task targetedFeatureFinder = new BasicTFF(0.01); IsotopicProfileFitScoreCalculator fitScoreCalc = new IsotopicProfileFitScoreCalculator(); Task exporter = new BasicMTResultSQLiteExporter(exporterOutputFile1); msgen.Execute(run.ResultCollection); //run.XYData.Display(); mspeakDet.Execute(run.ResultCollection); theorFeatureGen.Execute(run.ResultCollection); targetedFeatureFinder.Execute(run.ResultCollection); fitScoreCalc.Execute(run.ResultCollection); exporter.Execute(run.ResultCollection); exporter.Cleanup(); MassTagResultBase result = run.ResultCollection.GetMassTagResult(mt); TestUtilities.DisplayIsotopicProfileData(result.IsotopicProfile); }
public void test1() { Run run = new XCaliburRun(xcaliburTestfile); MassTagCollection massTagColl = new MassTagCollection(); MassTagIDGenericImporter mtidImporter = new MassTagIDGenericImporter(cysteineMassTagSourceFile1, '\t'); mtidImporter.Import(massTagColl); MassTagFromSqlDBImporter importer = new MassTagFromSqlDBImporter("MT_Shewanella_ProdTest_P352", "porky"); importer.Import(massTagColl); Assert.AreEqual(737, massTagColl.MassTagIDList.Count); Assert.AreEqual(826, massTagColl.MassTagList.Count); ChromAlignerUsingVIPERInfo chromAligner = new ChromAlignerUsingVIPERInfo(); chromAligner.Execute(run); PeakImporterFromText peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(xcaliburAllPeaksFile); peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList); Task peakChromGen = new PeakChromatogramGenerator(20); Task smoother = new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(11, 11, 2); Task peakDet = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector(0.5, 0.5); Task chromPeakSel = new DeconTools.Backend.ProcessingTasks.ChromPeakSelector(1, 0.01, Globals.PeakSelectorMode.CLOSEST_TO_TARGET); MSGeneratorFactory msgenFactory = new MSGeneratorFactory(); Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType); DeconToolsV2.Peaks.clsPeakProcessorParameters peakParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(2, 0.75, true, DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC); Task mspeakDet = new DeconToolsPeakDetector(peakParams); Task theorFeatureGen = new TomTheorFeatureGenerator(); Task targetedFeatureFinder = new BasicTFF(6); Task exporter = new BasicMTResultSQLiteExporter(cysteineAnalysisOutput1); IsotopicProfileFitScoreCalculator fitScoreCalc = new IsotopicProfileFitScoreCalculator(); int successCounter = 0; List <long> timingResults = new List <long>(); foreach (MassTag mt in massTagColl.MassTagList) { run.CurrentMassTag = mt; mt.MZ = mt.MonoIsotopicMass / mt.ChargeState + Globals.PROTON_MASS; 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.NETVal.ToString("0.000") + "; Sequence = " + mt.PeptideSequence + "\n"); Stopwatch sw = new Stopwatch(); sw.Start(); try { peakChromGen.Execute(run.ResultCollection); smoother.Execute(run.ResultCollection); peakDet.Execute(run.ResultCollection); chromPeakSel.Execute(run.ResultCollection); msgen.Execute(run.ResultCollection); mspeakDet.Execute(run.ResultCollection); theorFeatureGen.Execute(run.ResultCollection); targetedFeatureFinder.Execute(run.ResultCollection); fitScoreCalc.Execute(run.ResultCollection); MassTagResultBase massTagResult = run.ResultCollection.MassTagResultList[mt]; massTagResult.DisplayToConsole(); Console.WriteLine("------------------------------ end --------------------------"); } catch (Exception ex) { Console.WriteLine("Task failed. Message: " + ex.Message + ex.StackTrace); } sw.Stop(); timingResults.Add(sw.ElapsedMilliseconds); if (mt == massTagColl.MassTagList.Last()) { exporter.Execute(run.ResultCollection); } } exporter.Cleanup(); //List<IMassTagResult> successfulResults = run.ResultCollection.GetSuccessfulMassTagResults(); foreach (long tr in timingResults) { Console.WriteLine(tr); } Console.WriteLine("-------- Analysis time for all MTs = " + timingResults.Sum()); Console.WriteLine("-------- Average time for each MT = " + timingResults.Average()); Console.WriteLine(); }
public void AddResult(MassTagResultBase resultToConvert) { TargetedResult result = ResultFactory.CreateTargetedResult(resultToConvert); this.Results.Add(result); }
public void run_fullAnalysisTest1() { Run run = new BrukerRun(rsph_AOnly_28_run1File); MassTagCollection massTagColl = new MassTagCollection(); run.ResultCollection.MassTagResultType = DeconTools.Backend.Globals.MassTagResultType.N14N15_MASSTAG_RESULT; massTagColl.MassTagIDList = fourTestMTs; MassTagFromSqlDBImporter importer = new MassTagFromSqlDBImporter("MT_R_sphaeroides241_P513", "Albert"); importer.chargeStateFilterThreshold = 0.05; importer.Import(massTagColl); Assert.AreEqual(7, massTagColl.MassTagList.Count); ChromAlignerUsingVIPERInfo chromAligner = new ChromAlignerUsingVIPERInfo(); chromAligner.Execute(run); PeakImporterFromText peakImporter = new DeconTools.Backend.Data.PeakImporterFromText(rsph_Aonly_28_run1_scans500_1000_peaks); peakImporter.ImportPeaks(run.ResultCollection.MSPeakResultList); Task peakChromGen = new PeakChromatogramGenerator(20); Task smoother = new DeconTools.Backend.ProcessingTasks.Smoothers.DeconToolsSavitzkyGolaySmoother(11, 11, 2); Task peakDet = new DeconTools.Backend.ProcessingTasks.PeakDetectors.ChromPeakDetector(0.5, 0.5); Task chromPeakSel = new DeconTools.Backend.ProcessingTasks.ChromPeakSelector(1, 0.01, Globals.PeakSelectorMode.CLOSEST_TO_TARGET); MSGeneratorFactory msgenFactory = new MSGeneratorFactory(); Task msgen = msgenFactory.CreateMSGenerator(run.MSFileType); DeconToolsV2.Peaks.clsPeakProcessorParameters peakParams = new DeconToolsV2.Peaks.clsPeakProcessorParameters(2, 3, false, DeconToolsV2.Peaks.PEAK_FIT_TYPE.QUADRATIC); Task mspeakDet = new DeconToolsPeakDetector(peakParams); Task theorFeatureGen = new TomTheorFeatureGenerator(); N14N15TFFTask finder = new N14N15TFFTask(0.01); N14N15QuantifierTask quant = new N14N15QuantifierTask(1); IsotopicProfileFitScoreCalculator fitScoreCalc = new IsotopicProfileFitScoreCalculator(); List <long> timingResults = new List <long>(); foreach (MassTag mt in massTagColl.MassTagList) { run.CurrentMassTag = mt; mt.MZ = mt.MonoIsotopicMass / mt.ChargeState + Globals.PROTON_MASS; 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.NETVal.ToString("0.000") + "; Sequence = " + mt.PeptideSequence + "\n"); Stopwatch sw = new Stopwatch(); sw.Start(); try { peakChromGen.Execute(run.ResultCollection); smoother.Execute(run.ResultCollection); peakDet.Execute(run.ResultCollection); chromPeakSel.Execute(run.ResultCollection); msgen.Execute(run.ResultCollection); mspeakDet.Execute(run.ResultCollection); theorFeatureGen.Execute(run.ResultCollection); finder.Execute(run.ResultCollection); quant.Execute(run.ResultCollection); fitScoreCalc.Execute(run.ResultCollection); MassTagResultBase massTagResult = run.ResultCollection.MassTagResultList[mt]; massTagResult.DisplayToConsole(); Console.WriteLine("------------------------------ end --------------------------"); } catch (Exception ex) { Console.WriteLine("Task failed. Message: " + ex.Message + ex.StackTrace); } sw.Stop(); timingResults.Add(sw.ElapsedMilliseconds); } foreach (long tr in timingResults) { Console.WriteLine(tr); } Console.WriteLine("-------- Analysis time for all MTs = " + timingResults.Sum()); Console.WriteLine("-------- Average time for each MT = " + timingResults.Average()); Console.WriteLine(); }