From 831a3942d00172ddca7b180d3d82ad7e0f4ce05e Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 8 Jan 2024 15:38:57 -0600 Subject: [PATCH 01/39] Updated Mzlib and made it so there are no errors on build --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/CMD/Program.cs | 1 + .../ClassicSearch/ClassicSearchEngine.cs | 3 ++- .../ClassicSearch/MiniClassicSearchEngine.cs | 2 +- MetaMorpheus/EngineLayer/CommonParameters.cs | 3 ++- .../CrosslinkSearch/CrosslinkSearchEngine.cs | 4 +++- .../CrosslinkSearch/CrosslinkSpectralMatch.cs | 2 +- .../CrosslinkSearch/CrosslinkedPeptides.cs | 3 ++- .../CrosslinkSearch/Crosslinker.cs | 1 + MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- .../FdrAnalysis/PEPValueAnalysisGeneric.cs | 3 ++- MetaMorpheus/EngineLayer/GlobalVariables.cs | 1 + .../EngineLayer/GlycoSearch/Glycan.cs | 1 + .../EngineLayer/GlycoSearch/GlycanBox.cs | 1 + .../EngineLayer/GlycoSearch/GlycoPeptides.cs | 3 ++- .../GlycoSearch/GlycoSearchEngine.cs | 2 +- .../GlycoSearch/GlycoSpectralMatch.cs | 3 ++- .../GlycoSearch/LocalizationGraph.cs | 2 +- MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs | 1 + .../EngineLayer/Gptmd/GptmdResults.cs | 1 + .../EngineLayer/HistogramAnalysis/Bin.cs | 1 + .../HistogramAnalysis/BinTreeStructure.cs | 2 +- .../EngineLayer/Indexing/IndexingEngine.cs | 4 +++- .../EngineLayer/Indexing/IndexingResults.cs | 2 +- .../Localization/LocalizationEngine.cs | 2 +- .../EngineLayer/MetaMorpheusEngine.cs | 11 +++++---- .../ModernSearch/ModernSearchEngine.cs | 2 +- .../NonSpecificEnzymeSearchEngine.cs | 5 +++- .../EngineLayer/PeptideSpectralMatch.cs | 4 +++- .../ProteinParsimony/ParsimonySequence.cs | 2 +- .../ProteinParsimony/ProteinGroup.cs | 1 + .../ProteinParsimonyEngine.cs | 9 +++---- .../ProteinScoringAndFdr/FdrClassifier.cs | 1 + .../ProteinScoringAndFdrEngine.cs | 4 ++-- MetaMorpheus/EngineLayer/PsmTsv/PsmFromTsv.cs | 9 +++---- .../EngineLayer/PsmTsv/PsmTsvWriter.cs | 4 +++- .../EngineLayer/Silac/SilacConversions.cs | 1 + .../CrosslinkLibrarySpectrum.cs | 2 +- .../SpectralLibrarySearch/LibrarySpectrum.cs | 2 +- .../SpectralLibrarySearch/SpectralLibrary.cs | 9 +++---- .../SpectralLibrarySearchFunction.cs | 4 ++-- .../SilacInfoForDataGrid.cs | 1 + MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GUI/MainWindow.xaml.cs | 1 + .../MetaDraw/MetaDrawSettingsWindow.xaml.cs | 2 +- .../GUI/TaskWindows/SearchTaskWindow.xaml.cs | 20 +++++++++------- .../Views/CustomFragmentationWindow.xaml.cs | 3 ++- .../GUI/Views/CustomModWindow.xaml.cs | 1 + .../GUI/Views/SilacModificationWindow.xaml.cs | 1 + MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- .../GuiFunctions/MetaDraw/DrawnSequence.cs | 2 +- .../GuiFunctions/MetaDraw/MetaDrawLogic.cs | 2 +- .../GuiFunctions/MetaDraw/MetaDrawSettings.cs | 2 +- .../MetaDraw/MetaDrawSettingsSnapshot.cs | 2 +- .../GuiFunctions/MetaDraw/PlotModelStat.cs | 2 +- .../SpectrumMatch/ChimeraSpectrumMatchPlot.cs | 2 +- .../SpectrumMatch/PeptideSpectrumMatchPlot.cs | 2 +- .../SpectrumMatch/SpectrumMatchPlot.cs | 4 ++-- .../ViewModels/IonForTreeViewModel.cs | 2 +- .../ViewModels/IonTypeForTreeViewModel.cs | 2 +- .../ViewModels/Legends/PtmLegendViewModel.cs | 1 + .../ViewModels/MetaDrawSettingsViewModel.cs | 2 +- .../CalibrationTask/CalibrationTask.cs | 3 ++- .../TaskLayer/FileSpecificParameters.cs | 2 +- MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs | 1 + .../PostGlycoSearchAnalysisParameters.cs | 1 + .../PostGlycoSearchAnalysisTask.cs | 1 + MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 4 +++- MetaMorpheus/TaskLayer/PepXMLWriter.cs | 4 +++- .../TaskLayer/SearchTask/MzIdentMLWriter.cs | 2 ++ .../PostSearchAnalysisParameters.cs | 1 + .../SearchTask/PostSearchAnalysisTask.cs | 1 + .../TaskLayer/SearchTask/SearchParameters.cs | 1 + .../TaskLayer/SearchTask/SearchTask.cs | 4 +++- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- .../XLSearchTask/PostXLSearchAnalysisTask.cs | 1 + .../TaskLayer/XLSearchTask/WriteFile.cs | 4 +++- MetaMorpheus/Test/AddCompIonsTest.cs | 4 +++- MetaMorpheus/Test/AmbiguityTest.cs | 4 +++- MetaMorpheus/Test/AnalysisEngineTest.cs | 4 +++- MetaMorpheus/Test/BinGenerationTest.cs | 1 + MetaMorpheus/Test/CoIsolationTests.cs | 4 +++- MetaMorpheus/Test/CustomFragmentationTest.cs | 3 ++- .../Test/DigestionModificationTests.cs | 1 + MetaMorpheus/Test/EventArgsTest.cs | 3 ++- MetaMorpheus/Test/FdrTest.cs | 6 +++-- MetaMorpheus/Test/GPTMDengineTest.cs | 3 ++- MetaMorpheus/Test/IndexEngineTest.cs | 4 +++- MetaMorpheus/Test/LocalizationTest.cs | 3 ++- MetaMorpheus/Test/MatchIonsOfAllCharges.cs | 12 ++++++---- .../MetaDraw/MetaDrawSettingsAndViewsTest.cs | 4 +++- MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs | 2 +- .../Test/MetaDraw/SpectrumMatchPlotTests.cs | 2 +- MetaMorpheus/Test/ModificationAnalysisTest.cs | 4 +++- .../Test/MultiProteaseParsimonyTest.cs | 22 +++++++++-------- .../Test/Multiplex_Labeling_TMT_iTRAQ.cs | 3 ++- MetaMorpheus/Test/MyPeptideTest.cs | 5 ++-- MetaMorpheus/Test/MyTaskTest.cs | 1 + MetaMorpheus/Test/ParameterTest.cs | 4 +++- MetaMorpheus/Test/ProteinGroupTest.cs | 2 ++ MetaMorpheus/Test/PsmTsvWriterTests.cs | 6 +++-- MetaMorpheus/Test/PsvTsvTest.cs | 4 ++-- MetaMorpheus/Test/QuantificationTest.cs | 5 ++-- MetaMorpheus/Test/RetentionTimeTest.cs | 1 + MetaMorpheus/Test/RobTest.cs | 4 +++- MetaMorpheus/Test/SearchEngineTests.cs | 4 +++- MetaMorpheus/Test/SearchTaskTest.cs | 4 +++- .../SearchWithPeptidesAddedInParsimony.cs | 1 + MetaMorpheus/Test/SeqCoverageTest.cs | 12 ++++++---- MetaMorpheus/Test/SilacTest.cs | 1 + .../Test/SpectralLibraryReaderTest.cs | 3 ++- MetaMorpheus/Test/SpectralRecoveryTest.cs | 1 + MetaMorpheus/Test/StefanParsimonyTest.cs | 7 +++--- MetaMorpheus/Test/Test.csproj | 2 +- MetaMorpheus/Test/TestDataFile.cs | 2 +- MetaMorpheus/Test/TestPsm.cs | 24 ++++++++++--------- MetaMorpheus/Test/TestTopDown.cs | 1 + MetaMorpheus/Test/VariantSearchTests.cs | 1 + MetaMorpheus/Test/XLSearchOutputTest.cs | 6 ++--- MetaMorpheus/Test/XLTest.cs | 4 +++- MetaMorpheus/Test/XLTestNGlyco.cs | 3 ++- MetaMorpheus/Test/XLTestOGlyco.cs | 3 ++- MetaMorpheus/Test/gptmdPrunedBdTests.cs | 5 ++-- 123 files changed, 267 insertions(+), 150 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index 14333873c..b275d6b86 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/CMD/Program.cs b/MetaMorpheus/CMD/Program.cs index 50e90956a..85fa86b12 100644 --- a/MetaMorpheus/CMD/Program.cs +++ b/MetaMorpheus/CMD/Program.cs @@ -9,6 +9,7 @@ using System.IO; using System.Linq; using System.Text.RegularExpressions; +using Omics.Modifications; using TaskLayer; namespace MetaMorpheusCommandLine diff --git a/MetaMorpheus/EngineLayer/ClassicSearch/ClassicSearchEngine.cs b/MetaMorpheus/EngineLayer/ClassicSearch/ClassicSearchEngine.cs index 3a3eb2a68..cf6a78717 100644 --- a/MetaMorpheus/EngineLayer/ClassicSearch/ClassicSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/ClassicSearch/ClassicSearchEngine.cs @@ -1,12 +1,13 @@ using MassSpectrometry; using MzLibUtil; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Omics.Modifications; namespace EngineLayer.ClassicSearch { diff --git a/MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs b/MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs index 12f43ca29..6a3faca2d 100644 --- a/MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs @@ -1,7 +1,7 @@ using MassSpectrometry; using MassSpectrometry.MzSpectra; using MzLibUtil; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; diff --git a/MetaMorpheus/EngineLayer/CommonParameters.cs b/MetaMorpheus/EngineLayer/CommonParameters.cs index 3cc49cb50..f39ff3394 100644 --- a/MetaMorpheus/EngineLayer/CommonParameters.cs +++ b/MetaMorpheus/EngineLayer/CommonParameters.cs @@ -1,10 +1,11 @@ using MassSpectrometry; using MzLibUtil; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Reflection; +using Omics.Fragmentation.Peptide; namespace EngineLayer { diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs index 51b0cb0f1..48ea48c44 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs @@ -2,13 +2,15 @@ using MassSpectrometry; using MzLibUtil; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Omics.Fragmentation; +using Omics.Modifications; namespace EngineLayer.CrosslinkSearch { diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSpectralMatch.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSpectralMatch.cs index 88cbc93b3..2a65083f2 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSpectralMatch.cs @@ -1,5 +1,5 @@ using Easy.Common.Extensions; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkedPeptides.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkedPeptides.cs index 1d36753a2..ef293057e 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkedPeptides.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkedPeptides.cs @@ -1,10 +1,11 @@ using MassSpectrometry; using Proteomics; -using Proteomics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; +using Omics.Fragmentation; +using Omics.Modifications; namespace EngineLayer.CrosslinkSearch { diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/Crosslinker.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/Crosslinker.cs index 9a9bad96f..ad59d2e17 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/Crosslinker.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/Crosslinker.cs @@ -2,6 +2,7 @@ using System.IO; using MassSpectrometry; using System.Globalization; +using Omics.Modifications; using Proteomics; namespace EngineLayer diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index a0f70909e..c072889ac 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs index 7b795feac..1a1ccc6af 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs @@ -5,7 +5,7 @@ using Microsoft.ML; using Microsoft.ML.Data; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using Proteomics.RetentionTimePrediction; using System; @@ -15,6 +15,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Omics.Modifications; namespace EngineLayer { diff --git a/MetaMorpheus/EngineLayer/GlobalVariables.cs b/MetaMorpheus/EngineLayer/GlobalVariables.cs index 5d27c34f1..96efe5960 100644 --- a/MetaMorpheus/EngineLayer/GlobalVariables.cs +++ b/MetaMorpheus/EngineLayer/GlobalVariables.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; +using Omics.Modifications; using TopDownProteomics; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/Glycan.cs b/MetaMorpheus/EngineLayer/GlycoSearch/Glycan.cs index f7a7c21a4..0ce4f1361 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/Glycan.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/Glycan.cs @@ -5,6 +5,7 @@ using System; using Proteomics; using MassSpectrometry; +using Omics.Modifications; namespace EngineLayer { diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/GlycanBox.cs b/MetaMorpheus/EngineLayer/GlycoSearch/GlycanBox.cs index e7d5200cf..9a1d0f5d2 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/GlycanBox.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/GlycanBox.cs @@ -5,6 +5,7 @@ using System; using Proteomics; using MassSpectrometry; +using Omics.Modifications; namespace EngineLayer { diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoPeptides.cs b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoPeptides.cs index 9a63b3d5f..9a90f79ce 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoPeptides.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoPeptides.cs @@ -1,11 +1,12 @@ using MassSpectrometry; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; using Chemistry; +using Omics.Modifications; namespace EngineLayer.GlycoSearch { diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSearchEngine.cs b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSearchEngine.cs index c6f30f69b..3a859f859 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSearchEngine.cs @@ -1,7 +1,7 @@ using EngineLayer.ModernSearch; using MzLibUtil; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs index 0b32f1001..b4e4bbdf3 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs @@ -1,9 +1,10 @@ -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using Omics.Modifications; using Proteomics; namespace EngineLayer.GlycoSearch diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/LocalizationGraph.cs b/MetaMorpheus/EngineLayer/GlycoSearch/LocalizationGraph.cs index 44a470fcf..3d56c5cd0 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/LocalizationGraph.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/LocalizationGraph.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using Proteomics; using MzLibUtil; diff --git a/MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs b/MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs index 71b103a29..a4dcfff62 100644 --- a/MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs +++ b/MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Omics.Modifications; namespace EngineLayer.Gptmd { diff --git a/MetaMorpheus/EngineLayer/Gptmd/GptmdResults.cs b/MetaMorpheus/EngineLayer/Gptmd/GptmdResults.cs index 797c4249e..1f457d4e5 100644 --- a/MetaMorpheus/EngineLayer/Gptmd/GptmdResults.cs +++ b/MetaMorpheus/EngineLayer/Gptmd/GptmdResults.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Omics.Modifications; namespace EngineLayer.Gptmd { diff --git a/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs b/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs index 88abe91e8..c1c81590b 100644 --- a/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs +++ b/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using Omics.Modifications; namespace EngineLayer.HistogramAnalysis { diff --git a/MetaMorpheus/EngineLayer/HistogramAnalysis/BinTreeStructure.cs b/MetaMorpheus/EngineLayer/HistogramAnalysis/BinTreeStructure.cs index f74e35e7c..8da75929d 100644 --- a/MetaMorpheus/EngineLayer/HistogramAnalysis/BinTreeStructure.cs +++ b/MetaMorpheus/EngineLayer/HistogramAnalysis/BinTreeStructure.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Proteomics.Fragmentation; +using Omics.Fragmentation; namespace EngineLayer.HistogramAnalysis { diff --git a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs index 9a580f38e..3b2817b71 100644 --- a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs +++ b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs @@ -1,7 +1,7 @@ using Chemistry; using EngineLayer.NonSpecificEnzymeSearch; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -9,6 +9,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Omics.Fragmentation.Peptide; +using Omics.Modifications; using UsefulProteomicsDatabases; namespace EngineLayer.Indexing diff --git a/MetaMorpheus/EngineLayer/Indexing/IndexingResults.cs b/MetaMorpheus/EngineLayer/Indexing/IndexingResults.cs index 35c87d958..5f926c3a8 100644 --- a/MetaMorpheus/EngineLayer/Indexing/IndexingResults.cs +++ b/MetaMorpheus/EngineLayer/Indexing/IndexingResults.cs @@ -1,4 +1,4 @@ -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; using System.Text; diff --git a/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs b/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs index d336c3a13..ed0662d46 100644 --- a/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs +++ b/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs @@ -1,5 +1,5 @@ using MassSpectrometry; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Concurrent; using System.Collections.Generic; diff --git a/MetaMorpheus/EngineLayer/MetaMorpheusEngine.cs b/MetaMorpheus/EngineLayer/MetaMorpheusEngine.cs index 8afbc1647..4569b5367 100644 --- a/MetaMorpheus/EngineLayer/MetaMorpheusEngine.cs +++ b/MetaMorpheus/EngineLayer/MetaMorpheusEngine.cs @@ -2,7 +2,7 @@ using MassSpectrometry; using Microsoft.ML.Trainers.FastTree; using MzLibUtil; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Concurrent; @@ -10,6 +10,7 @@ using System.Diagnostics; using System.Linq; using System.Threading.Tasks; +using Omics.Fragmentation; namespace EngineLayer { @@ -162,7 +163,7 @@ public static List MatchFragmentIons(Ms2ScanWithSpecificMass if (commonParameters.ProductMassTolerance.Within(scan.TheScan.MassSpectrum.XArray[closestMzIndex], theoreticalFragmentMz)) { - matchedFragmentIons.Add(new MatchedFragmentIon(ref product, theoreticalFragmentMz, scan.TheScan.MassSpectrum.YArray[closestMzIndex], 1)); + matchedFragmentIons.Add(new MatchedFragmentIon(product, theoreticalFragmentMz, scan.TheScan.MassSpectrum.YArray[closestMzIndex], 1)); } } @@ -192,7 +193,7 @@ public static List MatchFragmentIons(Ms2ScanWithSpecificMass // is the mass error acceptable? if (closestExperimentalMass != null && commonParameters.ProductMassTolerance.Within(closestExperimentalMass.MonoisotopicMass, product.NeutralMass) && closestExperimentalMass.Charge <= scan.PrecursorCharge)//TODO apply this filter before picking the envelope { - matchedFragmentIons.Add(new MatchedFragmentIon(ref product, closestExperimentalMass.MonoisotopicMass.ToMz(closestExperimentalMass.Charge), + matchedFragmentIons.Add(new MatchedFragmentIon(product, closestExperimentalMass.MonoisotopicMass.ToMz(closestExperimentalMass.Charge), closestExperimentalMass.Peaks.First().intensity, closestExperimentalMass.Charge)); } } @@ -222,7 +223,7 @@ public static List MatchFragmentIons(Ms2ScanWithSpecificMass //found the peak, but we don't want to save that m/z because it's the complementary of the observed ion that we "added". Need to create a fake ion instead. double mz = (scan.PrecursorMass + protonMassShift - closestExperimentalMass.MonoisotopicMass).ToMz(closestExperimentalMass.Charge); - matchedFragmentIons.Add(new MatchedFragmentIon(ref product, mz, closestExperimentalMass.TotalIntensity, closestExperimentalMass.Charge)); + matchedFragmentIons.Add(new MatchedFragmentIon(product, mz, closestExperimentalMass.TotalIntensity, closestExperimentalMass.Charge)); } } } @@ -266,7 +267,7 @@ private static List MatchFragmentIonsOfAllCharges(Ms2ScanWit if (x != null && !ions.Contains(ion) && commonParameters.ProductMassTolerance.Within(x.MonoisotopicMass, product.NeutralMass) && x.Charge <= scan.PrecursorCharge)//TODO apply this filter before picking the envelope { Product temProduct = product; - matchedFragmentIons.Add(new MatchedFragmentIon(ref temProduct, x.MonoisotopicMass.ToMz(x.Charge), + matchedFragmentIons.Add(new MatchedFragmentIon(temProduct, x.MonoisotopicMass.ToMz(x.Charge), x.Peaks.First().intensity, x.Charge)); ions.Add(ion); diff --git a/MetaMorpheus/EngineLayer/ModernSearch/ModernSearchEngine.cs b/MetaMorpheus/EngineLayer/ModernSearch/ModernSearchEngine.cs index 0275879c9..8bf1666cf 100644 --- a/MetaMorpheus/EngineLayer/ModernSearch/ModernSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/ModernSearch/ModernSearchEngine.cs @@ -1,6 +1,6 @@ using Chemistry; using MassSpectrometry; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; diff --git a/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs b/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs index 1b211f51b..b35eb8f15 100644 --- a/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs @@ -2,7 +2,7 @@ using EngineLayer.FdrAnalysis; using EngineLayer.ModernSearch; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using MassSpectrometry; @@ -10,6 +10,9 @@ using System.Linq; using System.Threading.Tasks; using MzLibUtil; +using Omics.Digestion; +using Omics.Fragmentation.Peptide; +using Omics.Modifications; namespace EngineLayer.NonSpecificEnzymeSearch { diff --git a/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs b/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs index abe52ebf1..ba65d0c1a 100644 --- a/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs @@ -3,13 +3,15 @@ using EngineLayer.FdrAnalysis; using MassSpectrometry; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Runtime.CompilerServices; using Easy.Common.Extensions; +using Omics; +using Omics.Modifications; using Proteomics.AminoAcidPolymer; using ThermoFisher.CommonCore.Data; diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs index 053b8436d..64d4f7b5f 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs @@ -7,7 +7,7 @@ internal class ParsimonySequence public ParsimonySequence(PeptideWithSetModifications pwsm, bool TreatModPeptidesAsDifferentPeptides) { Sequence = TreatModPeptidesAsDifferentPeptides ? pwsm.FullSequence : pwsm.BaseSequence; - Protease = pwsm.DigestionParams.Protease; + Protease = pwsm.DigestionParams.DigestionAgent as Protease ?? throw new MetaMorpheusException("Digestion agent is not of type protease"); } public string Sequence { get; } diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs index 48173d5db..b8252a28c 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Text; +using Omics.Modifications; using ThermoFisher.CommonCore.Data; namespace EngineLayer diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs index d94696eef..6139fcd7c 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs @@ -1,11 +1,12 @@ using EngineLayer.ProteinParsimony; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using IDigestionParams = Omics.Digestion.IDigestionParams; namespace EngineLayer { @@ -156,8 +157,8 @@ private List RunProteinParsimonyEngine() // this gets the digestion info for all of the peptide-protein associations that should exist var proteinToPeptideInfo = new Dictionary(); + (IDigestionParams DigestParams, int OneBasedStart, int OneBasedEnd, int MissedCleavages, int Notch, + Omics.Digestion.CleavageSpecificity CleavageSpecificity)>(); foreach (PeptideSpectralMatch psm in baseSequence.Value) { @@ -218,7 +219,7 @@ private List RunProteinParsimonyEngine() } // Parsimony stage 1: add proteins with unique peptides (for each protease) - var peptidesGroupedByProtease = _fdrFilteredPeptides.GroupBy(p => p.DigestionParams.Protease); + var peptidesGroupedByProtease = _fdrFilteredPeptides.GroupBy(p => p.DigestionParams.DigestionAgent); foreach (var peptidesForThisProtease in peptidesGroupedByProtease) { Dictionary> peptideSequenceToProteinsForThisProtease = new Dictionary>(); diff --git a/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/FdrClassifier.cs b/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/FdrClassifier.cs index 115853f19..dce5762a2 100644 --- a/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/FdrClassifier.cs +++ b/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/FdrClassifier.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Text; +using Omics.Digestion; namespace EngineLayer { diff --git a/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs b/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs index 52c507589..28924565d 100644 --- a/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs +++ b/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs @@ -91,8 +91,8 @@ private void ScoreProteinGroups(List proteinGroups, IEnumerable(p.AllPeptides.Select(x => x.FullSequence + x.DigestionParams.Protease)); - var seqs2 = new HashSet(pg[i].AllPeptides.Select(x => x.FullSequence + x.DigestionParams.Protease)); + var seqs1 = new HashSet(p.AllPeptides.Select(x => x.FullSequence + x.DigestionParams.DigestionAgent)); + var seqs2 = new HashSet(pg[i].AllPeptides.Select(x => x.FullSequence + x.DigestionParams.DigestionAgent)); if (p != pg[i] && seqs1.SetEquals(seqs2)) { diff --git a/MetaMorpheus/EngineLayer/PsmTsv/PsmFromTsv.cs b/MetaMorpheus/EngineLayer/PsmTsv/PsmFromTsv.cs index 383d98fe8..92ca7a74b 100644 --- a/MetaMorpheus/EngineLayer/PsmTsv/PsmFromTsv.cs +++ b/MetaMorpheus/EngineLayer/PsmTsv/PsmFromTsv.cs @@ -1,5 +1,4 @@ using Chemistry; -using Proteomics.Fragmentation; using System; using System.Collections.Generic; using System.Globalization; @@ -10,6 +9,8 @@ using Easy.Common.Extensions; using System.Text; using MathNet.Numerics; +using Omics.Fragmentation; +using Omics.Fragmentation.Peptide; namespace EngineLayer { @@ -511,7 +512,7 @@ private static List ReadFragmentIonsFromString(string matche secondaryProductType, secondaryFragmentNumber); - matchedIons.Add(new MatchedFragmentIon(ref theoreticalProduct, mz, intensity, z)); + matchedIons.Add(new MatchedFragmentIon(theoreticalProduct, mz, intensity, z)); } } return matchedIons; @@ -629,7 +630,7 @@ public LibrarySpectrum ToLibrarySpectrum() foreach (MatchedFragmentIon ion in this.MatchedIons) { Product product = new Product(ion.NeutralTheoreticalProduct.ProductType, ion.NeutralTheoreticalProduct.Terminus, ion.NeutralTheoreticalProduct.NeutralMass, ion.NeutralTheoreticalProduct.FragmentNumber, ion.NeutralTheoreticalProduct.AminoAcidPosition, ion.NeutralTheoreticalProduct.NeutralLoss); - fragments.Add(new MatchedFragmentIon(ref product, ion.Mz, ion.Intensity / matchedIonIntensitySum, ion.Charge)); + fragments.Add(new MatchedFragmentIon(product, ion.Mz, ion.Intensity / matchedIonIntensitySum, ion.Charge)); } double retentionTime = RetentionTime ?? -1; @@ -639,7 +640,7 @@ public LibrarySpectrum ToLibrarySpectrum() foreach(var ion in BetaPeptideMatchedIons) { Product product = new Product(ion.NeutralTheoreticalProduct.ProductType, ion.NeutralTheoreticalProduct.Terminus, ion.NeutralTheoreticalProduct.NeutralMass, ion.NeutralTheoreticalProduct.FragmentNumber, ion.NeutralTheoreticalProduct.AminoAcidPosition, ion.NeutralTheoreticalProduct.NeutralLoss); - betaFragments.Add(new MatchedFragmentIon(ref product, ion.Mz, ion.Intensity / matchedIonIntensitySum, ion.Charge)); + betaFragments.Add(new MatchedFragmentIon(product, ion.Mz, ion.Intensity / matchedIonIntensitySum, ion.Charge)); } string uniqueSequence = UniqueSequence ?? FullSequence + BetaPeptideFullSequence; return new CrosslinkLibrarySpectrum(uniqueSequence, PrecursorMz, PrecursorCharge, fragments, retentionTime, betaFragments); diff --git a/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs b/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs index 509af5e42..fa2dfbb54 100644 --- a/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs +++ b/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs @@ -1,6 +1,6 @@ using Chemistry; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -8,6 +8,8 @@ using System.IO; using System.Linq; using System.Text; +using Omics; +using Omics.Modifications; namespace EngineLayer { diff --git a/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs b/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs index 872386832..5b7a90dbe 100644 --- a/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs +++ b/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Omics.Modifications; namespace EngineLayer { diff --git a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/CrosslinkLibrarySpectrum.cs b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/CrosslinkLibrarySpectrum.cs index 2c84683ab..b2985e658 100644 --- a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/CrosslinkLibrarySpectrum.cs +++ b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/CrosslinkLibrarySpectrum.cs @@ -1,4 +1,4 @@ -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Linq; diff --git a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/LibrarySpectrum.cs b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/LibrarySpectrum.cs index 63d857054..4311a71de 100644 --- a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/LibrarySpectrum.cs +++ b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/LibrarySpectrum.cs @@ -1,4 +1,4 @@ -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs index de68ddefa..477f9c092 100644 --- a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs +++ b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs @@ -1,6 +1,6 @@ using Chemistry; using MzLibUtil; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Globalization; @@ -10,6 +10,7 @@ using System.Text; using System.Text.RegularExpressions; using Easy.Common.Extensions; +using Omics.Fragmentation.Peptide; using ThermoFisher.CommonCore.Data.Business; namespace EngineLayer @@ -442,7 +443,7 @@ private LibrarySpectrum ReadLibrarySpectrum_pDeep(StreamReader reader, bool only //TODO: figure out amino acid position var product = new Product(peakProductType, terminus, experMz, fragmentNumber, 0, 0); - matchedFragmentIons.Add(new MatchedFragmentIon(ref product, experMz, experIntensity, fragmentCharge)); + matchedFragmentIons.Add(new MatchedFragmentIon(product, experMz, experIntensity, fragmentCharge)); } } @@ -590,11 +591,11 @@ public static MatchedFragmentIon ReadFragmentIon(string fragmentIonLine, char[] { int peptideLength = peptideSequence.IsNotNullOrEmptyOrWhiteSpace() ? peptideSequence.Length : 25; // Arbitrary default peptide length product = new Product(peakProductType, terminus, experMz.ToMass(fragmentCharge), fragmentNumber, - aminoAcidPosition: terminus == FragmentationTerminus.N ? fragmentNumber : peptideLength - fragmentNumber, + residuePosition: terminus == FragmentationTerminus.N ? fragmentNumber : peptideLength - fragmentNumber, neutralLoss); } - return new MatchedFragmentIon(ref product, experMz, experIntensity, fragmentCharge); + return new MatchedFragmentIon(product, experMz, experIntensity, fragmentCharge); } private void IndexSpectralLibrary(string path) diff --git a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrarySearchFunction.cs b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrarySearchFunction.cs index 579853e05..3120e9441 100644 --- a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrarySearchFunction.cs +++ b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrarySearchFunction.cs @@ -1,6 +1,6 @@ using Chemistry; using MassSpectrometry; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Linq; @@ -95,7 +95,7 @@ public static List GetDecoyLibrarySpectrumFromTargetByRevers { double decoyFragmentMz = decoyPeptideTheorIon.NeutralMass.ToMz(targetIon.Charge); Product temProduct = decoyPeptideTheorIon; - decoyFragmentIons.Add(new MatchedFragmentIon(ref temProduct, decoyFragmentMz, targetIon.Intensity, targetIon.Charge)); + decoyFragmentIons.Add(new MatchedFragmentIon(temProduct, decoyFragmentMz, targetIon.Intensity, targetIon.Charge)); } } } diff --git a/MetaMorpheus/GUI/ForDisplayingInDataGrids/SilacInfoForDataGrid.cs b/MetaMorpheus/GUI/ForDisplayingInDataGrids/SilacInfoForDataGrid.cs index 057bdf1fc..fbacda228 100644 --- a/MetaMorpheus/GUI/ForDisplayingInDataGrids/SilacInfoForDataGrid.cs +++ b/MetaMorpheus/GUI/ForDisplayingInDataGrids/SilacInfoForDataGrid.cs @@ -1,6 +1,7 @@ using Chemistry; using Proteomics; using System.Collections.Generic; +using Omics.Modifications; namespace MetaMorpheusGUI { diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 64b1a617c..d4de3f8c0 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GUI/MainWindow.xaml.cs b/MetaMorpheus/GUI/MainWindow.xaml.cs index df152a3c3..db8f7bd28 100644 --- a/MetaMorpheus/GUI/MainWindow.xaml.cs +++ b/MetaMorpheus/GUI/MainWindow.xaml.cs @@ -17,6 +17,7 @@ using System.Windows.Documents; using System.Windows.Input; using System.Windows.Navigation; +using Omics.Modifications; using TaskLayer; namespace MetaMorpheusGUI diff --git a/MetaMorpheus/GUI/MetaDraw/MetaDrawSettingsWindow.xaml.cs b/MetaMorpheus/GUI/MetaDraw/MetaDrawSettingsWindow.xaml.cs index 192e11ba7..fda4dbd2a 100644 --- a/MetaMorpheus/GUI/MetaDraw/MetaDrawSettingsWindow.xaml.cs +++ b/MetaMorpheus/GUI/MetaDraw/MetaDrawSettingsWindow.xaml.cs @@ -3,7 +3,7 @@ using GuiFunctions; using Nett; using OxyPlot; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs index c51c58b8b..73567143f 100644 --- a/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs @@ -2,7 +2,7 @@ using MassSpectrometry; using MzLibUtil; using Nett; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -19,6 +19,8 @@ using GuiFunctions; using Proteomics; using System.Threading.Tasks; +using Omics.Digestion; +using Omics.Modifications; namespace MetaMorpheusGUI { @@ -205,7 +207,7 @@ private void UpdateFieldsFromTask(SearchTask task) SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(startLabel, SilacModificationWindow.ExperimentType.Start); if (startLabel.AdditionalLabels != null) { - foreach (Proteomics.SilacLabel additionalLabel in startLabel.AdditionalLabels) + foreach (SilacLabel additionalLabel in startLabel.AdditionalLabels) { infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.Start)); } @@ -222,7 +224,7 @@ private void UpdateFieldsFromTask(SearchTask task) SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(endLabel, SilacModificationWindow.ExperimentType.End); if (endLabel.AdditionalLabels != null) { - foreach (Proteomics.SilacLabel additionalLabel in endLabel.AdditionalLabels) + foreach (SilacLabel additionalLabel in endLabel.AdditionalLabels) { infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.End)); } @@ -238,13 +240,13 @@ private void UpdateFieldsFromTask(SearchTask task) else if (task.SearchParameters.SilacLabels != null && task.SearchParameters.SilacLabels.Count != 0) { CheckBoxSILAC.IsChecked = true; - List labels = task.SearchParameters.SilacLabels; - foreach (Proteomics.SilacLabel label in labels) + List labels = task.SearchParameters.SilacLabels; + foreach (SilacLabel label in labels) { SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(label, SilacModificationWindow.ExperimentType.Multiplex); if (label.AdditionalLabels != null) { - foreach (Proteomics.SilacLabel additionalLabel in label.AdditionalLabels) + foreach (SilacLabel additionalLabel in label.AdditionalLabels) { infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.Multiplex)); } @@ -1093,7 +1095,7 @@ private void OnClosing(object sender, CancelEventArgs e) CustomFragmentationWindow.Close(); } - private static Proteomics.SilacLabel ConvertSilacDataGridInfoToSilacLabel(SilacInfoForDataGrid info) + private static SilacLabel ConvertSilacDataGridInfoToSilacLabel(SilacInfoForDataGrid info) { if (info == null) { @@ -1101,7 +1103,7 @@ private static Proteomics.SilacLabel ConvertSilacDataGridInfoToSilacLabel(SilacI } else { - Proteomics.SilacLabel label = info.SilacLabel[0]; + SilacLabel label = info.SilacLabel[0]; //This is needed to prevent double adding of additional labels. //A quick test is to create a silac condition with two labels, save, reopen the task, save, and reopen again. //Without this line, the second label will be doubled. Example: (K+8)&(R+10)&(R+10) @@ -1210,7 +1212,7 @@ private void SilacUpdates(out string error) //if they're all multiplex if (StaticSilacLabelsObservableCollection.All(x => x.LabelType == SilacModificationWindow.ExperimentType.Multiplex)) { - List labelsToSave = new List(); + List labelsToSave = new List(); foreach (SilacInfoForDataGrid info in StaticSilacLabelsObservableCollection) { labelsToSave.Add(ConvertSilacDataGridInfoToSilacLabel(info)); diff --git a/MetaMorpheus/GUI/Views/CustomFragmentationWindow.xaml.cs b/MetaMorpheus/GUI/Views/CustomFragmentationWindow.xaml.cs index 8a616e1fe..23de0c9fb 100644 --- a/MetaMorpheus/GUI/Views/CustomFragmentationWindow.xaml.cs +++ b/MetaMorpheus/GUI/Views/CustomFragmentationWindow.xaml.cs @@ -1,4 +1,4 @@ -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System.Collections.Generic; using System.Windows; using System.ComponentModel; @@ -6,6 +6,7 @@ using System.Linq; using System.Collections.ObjectModel; using System; +using Omics.Fragmentation.Peptide; namespace MetaMorpheusGUI { diff --git a/MetaMorpheus/GUI/Views/CustomModWindow.xaml.cs b/MetaMorpheus/GUI/Views/CustomModWindow.xaml.cs index acb425902..74bf9875a 100644 --- a/MetaMorpheus/GUI/Views/CustomModWindow.xaml.cs +++ b/MetaMorpheus/GUI/Views/CustomModWindow.xaml.cs @@ -8,6 +8,7 @@ using MassSpectrometry; using Proteomics; using System.Globalization; +using Omics.Modifications; namespace MetaMorpheusGUI { diff --git a/MetaMorpheus/GUI/Views/SilacModificationWindow.xaml.cs b/MetaMorpheus/GUI/Views/SilacModificationWindow.xaml.cs index 6e33fe7b5..ef266dc7f 100644 --- a/MetaMorpheus/GUI/Views/SilacModificationWindow.xaml.cs +++ b/MetaMorpheus/GUI/Views/SilacModificationWindow.xaml.cs @@ -7,6 +7,7 @@ using Chemistry; using System.Text.RegularExpressions; using System.Globalization; +using Omics.Modifications; namespace MetaMorpheusGUI { diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index f1b519d45..e8f232287 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/MetaDraw/DrawnSequence.cs b/MetaMorpheus/GuiFunctions/MetaDraw/DrawnSequence.cs index 7b43733cd..d2a2dbd02 100644 --- a/MetaMorpheus/GuiFunctions/MetaDraw/DrawnSequence.cs +++ b/MetaMorpheus/GuiFunctions/MetaDraw/DrawnSequence.cs @@ -1,6 +1,6 @@ using EngineLayer; using OxyPlot; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; diff --git a/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawLogic.cs b/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawLogic.cs index faacb3780..8f520ca84 100644 --- a/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawLogic.cs +++ b/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawLogic.cs @@ -6,7 +6,6 @@ using iText.Kernel.Pdf; using MassSpectrometry; using OxyPlot.Wpf; -using Proteomics.Fragmentation; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -25,6 +24,7 @@ using Org.BouncyCastle.Asn1.X509.Qualified; using Readers; using System.Threading; +using Omics.Fragmentation; namespace GuiFunctions { diff --git a/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs b/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs index 57b6c7d64..f9ad1812c 100644 --- a/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs +++ b/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettings.cs @@ -2,7 +2,7 @@ using EngineLayer.GlycoSearch; using OxyPlot; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.IO; diff --git a/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettingsSnapshot.cs b/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettingsSnapshot.cs index 04ccfdf5e..d38e7b52b 100644 --- a/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettingsSnapshot.cs +++ b/MetaMorpheus/GuiFunctions/MetaDraw/MetaDrawSettingsSnapshot.cs @@ -1,6 +1,6 @@ using EngineLayer.GlycoSearch; using OxyPlot; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Linq; diff --git a/MetaMorpheus/GuiFunctions/MetaDraw/PlotModelStat.cs b/MetaMorpheus/GuiFunctions/MetaDraw/PlotModelStat.cs index d042c106c..63266f050 100644 --- a/MetaMorpheus/GuiFunctions/MetaDraw/PlotModelStat.cs +++ b/MetaMorpheus/GuiFunctions/MetaDraw/PlotModelStat.cs @@ -2,7 +2,7 @@ using OxyPlot; using OxyPlot.Axes; using OxyPlot.Series; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using Proteomics.RetentionTimePrediction; using System; diff --git a/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/ChimeraSpectrumMatchPlot.cs b/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/ChimeraSpectrumMatchPlot.cs index e5c9fc8cf..1c6cfb310 100644 --- a/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/ChimeraSpectrumMatchPlot.cs +++ b/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/ChimeraSpectrumMatchPlot.cs @@ -2,7 +2,7 @@ using EngineLayer; using MassSpectrometry; using OxyPlot; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System.Collections.Generic; using System.IO; using System.Linq; diff --git a/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/PeptideSpectrumMatchPlot.cs b/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/PeptideSpectrumMatchPlot.cs index 608fa2cd7..c48f61a45 100644 --- a/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/PeptideSpectrumMatchPlot.cs +++ b/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/PeptideSpectrumMatchPlot.cs @@ -1,6 +1,5 @@ using EngineLayer; using MassSpectrometry; -using Proteomics.Fragmentation; using System.Collections.Generic; using System.IO; using System.Reflection; @@ -8,6 +7,7 @@ using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; +using Omics.Fragmentation; namespace GuiFunctions { diff --git a/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/SpectrumMatchPlot.cs b/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/SpectrumMatchPlot.cs index 0da8192c7..97026c930 100644 --- a/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/SpectrumMatchPlot.cs +++ b/MetaMorpheus/GuiFunctions/MetaDraw/SpectrumMatch/SpectrumMatchPlot.cs @@ -18,11 +18,11 @@ using MassSpectrometry; using MassSpectrometry.MzSpectra; using mzPlot; +using Omics.Fragmentation; using OxyPlot; using OxyPlot.Annotations; using OxyPlot.Axes; using OxyPlot.Series; -using Proteomics.Fragmentation; using Canvas = System.Windows.Controls.Canvas; using FontWeights = OxyPlot.FontWeights; using HorizontalAlignment = OxyPlot.HorizontalAlignment; @@ -447,7 +447,7 @@ protected void AnnotateLibraryIons(bool isBetaPeptide, List libraryIon.NeutralTheoreticalProduct.AminoAcidPosition, libraryIon.NeutralTheoreticalProduct.NeutralLoss); - mirroredLibraryIons.Add(new MatchedFragmentIon(ref neutralProduct, libraryIon.Mz, + mirroredLibraryIons.Add(new MatchedFragmentIon(neutralProduct, libraryIon.Mz, multiplier * libraryIon.Intensity, libraryIon.Charge)); } diff --git a/MetaMorpheus/GuiFunctions/ViewModels/IonForTreeViewModel.cs b/MetaMorpheus/GuiFunctions/ViewModels/IonForTreeViewModel.cs index 3ef477a5d..cdc3cf98d 100644 --- a/MetaMorpheus/GuiFunctions/ViewModels/IonForTreeViewModel.cs +++ b/MetaMorpheus/GuiFunctions/ViewModels/IonForTreeViewModel.cs @@ -1,6 +1,6 @@ using GuiFunctions; using OxyPlot; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/MetaMorpheus/GuiFunctions/ViewModels/IonTypeForTreeViewModel.cs b/MetaMorpheus/GuiFunctions/ViewModels/IonTypeForTreeViewModel.cs index a3f0cdea5..d25b16543 100644 --- a/MetaMorpheus/GuiFunctions/ViewModels/IonTypeForTreeViewModel.cs +++ b/MetaMorpheus/GuiFunctions/ViewModels/IonTypeForTreeViewModel.cs @@ -1,5 +1,5 @@ using GuiFunctions; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/MetaMorpheus/GuiFunctions/ViewModels/Legends/PtmLegendViewModel.cs b/MetaMorpheus/GuiFunctions/ViewModels/Legends/PtmLegendViewModel.cs index 72ee42ca0..cae4b5d44 100644 --- a/MetaMorpheus/GuiFunctions/ViewModels/Legends/PtmLegendViewModel.cs +++ b/MetaMorpheus/GuiFunctions/ViewModels/Legends/PtmLegendViewModel.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Windows; using EngineLayer; +using Omics.Modifications; using Proteomics.ProteolyticDigestion; namespace GuiFunctions diff --git a/MetaMorpheus/GuiFunctions/ViewModels/MetaDrawSettingsViewModel.cs b/MetaMorpheus/GuiFunctions/ViewModels/MetaDrawSettingsViewModel.cs index d6a06fa30..8ffe71a02 100644 --- a/MetaMorpheus/GuiFunctions/ViewModels/MetaDrawSettingsViewModel.cs +++ b/MetaMorpheus/GuiFunctions/ViewModels/MetaDrawSettingsViewModel.cs @@ -1,6 +1,6 @@ using EngineLayer; using GuiFunctions; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs b/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs index 9c20fbf2c..669a09399 100644 --- a/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs +++ b/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs @@ -7,11 +7,12 @@ using MzLibUtil; using Nett; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Modifications; using Readers; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/TaskLayer/FileSpecificParameters.cs b/MetaMorpheus/TaskLayer/FileSpecificParameters.cs index b6d5aa5f4..8366d96c9 100644 --- a/MetaMorpheus/TaskLayer/FileSpecificParameters.cs +++ b/MetaMorpheus/TaskLayer/FileSpecificParameters.cs @@ -5,7 +5,7 @@ using Nett; using Proteomics.ProteolyticDigestion; using MassSpectrometry; -using Proteomics.Fragmentation; +using Omics.Fragmentation; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs index ecd4f1b82..cde4fad40 100644 --- a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs +++ b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs @@ -12,6 +12,7 @@ using UsefulProteomicsDatabases; using Proteomics.ProteolyticDigestion; using System.Globalization; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisParameters.cs b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisParameters.cs index cd18d148b..a1fd56251 100644 --- a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisParameters.cs +++ b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisParameters.cs @@ -4,6 +4,7 @@ using Proteomics; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs index 077716c00..4b205c6c1 100644 --- a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using FlashLFQ; +using Omics.Modifications; using pepXML.Generated; using Proteomics.ProteolyticDigestion; using TaskLayer.MbrAnalysis; diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index 07a30e767..31f6b2189 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -17,7 +17,9 @@ using System.Reflection.Metadata.Ecma335; using System.Text; using System.Threading.Tasks; -using Proteomics.Fragmentation; +using Omics.Fragmentation; +using Omics.Fragmentation.Peptide; +using Omics.Modifications; using SpectralAveraging; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/TaskLayer/PepXMLWriter.cs b/MetaMorpheus/TaskLayer/PepXMLWriter.cs index 466879498..e4e2b3c68 100644 --- a/MetaMorpheus/TaskLayer/PepXMLWriter.cs +++ b/MetaMorpheus/TaskLayer/PepXMLWriter.cs @@ -1,12 +1,14 @@ using EngineLayer; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml.Serialization; +using Omics.Fragmentation.Peptide; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/SearchTask/MzIdentMLWriter.cs b/MetaMorpheus/TaskLayer/SearchTask/MzIdentMLWriter.cs index 750896b20..05ecd5a7c 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/MzIdentMLWriter.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/MzIdentMLWriter.cs @@ -10,6 +10,8 @@ using System.Text; using System.Xml; using System.Xml.Serialization; +using Omics.Digestion; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs index 2dc83fcb4..1251e6dd0 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs @@ -3,6 +3,7 @@ using Proteomics; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs index 74e20bcac..f131b32ab 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs @@ -22,6 +22,7 @@ using MzLibUtil; using Proteomics.AminoAcidPolymer; using System.Text.Json.Serialization; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/SearchTask/SearchParameters.cs b/MetaMorpheus/TaskLayer/SearchTask/SearchParameters.cs index 3068e8f00..c11c69212 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/SearchParameters.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/SearchParameters.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using UsefulProteomicsDatabases; using EngineLayer; +using Omics.Modifications; using Proteomics; namespace TaskLayer diff --git a/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs b/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs index e808c7732..2565349e6 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs @@ -7,13 +7,15 @@ using MassSpectrometry; using MzLibUtil; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 3976e9cd1..8b1cbcfc6 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs index d2acd5168..37057a572 100644 --- a/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs b/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs index 95ad8e996..750199ce5 100644 --- a/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs +++ b/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs @@ -2,7 +2,7 @@ using EngineLayer.CrosslinkSearch; using EngineLayer.GlycoSearch; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System; using System.Collections.Generic; using System.Globalization; @@ -10,6 +10,8 @@ using System.Linq; using System.Xml.Serialization; using Easy.Common.Extensions; +using Omics.Fragmentation.Peptide; +using Omics.Modifications; namespace TaskLayer { diff --git a/MetaMorpheus/Test/AddCompIonsTest.cs b/MetaMorpheus/Test/AddCompIonsTest.cs index ee5e8b178..c3a59ed5a 100644 --- a/MetaMorpheus/Test/AddCompIonsTest.cs +++ b/MetaMorpheus/Test/AddCompIonsTest.cs @@ -7,13 +7,15 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using Proteomics.RetentionTimePrediction; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/AmbiguityTest.cs b/MetaMorpheus/Test/AmbiguityTest.cs index 87e03ebb8..96dbc0e13 100644 --- a/MetaMorpheus/Test/AmbiguityTest.cs +++ b/MetaMorpheus/Test/AmbiguityTest.cs @@ -4,12 +4,14 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/AnalysisEngineTest.cs b/MetaMorpheus/Test/AnalysisEngineTest.cs index 9f07fb7f6..a4cd54884 100644 --- a/MetaMorpheus/Test/AnalysisEngineTest.cs +++ b/MetaMorpheus/Test/AnalysisEngineTest.cs @@ -5,11 +5,13 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; namespace Test diff --git a/MetaMorpheus/Test/BinGenerationTest.cs b/MetaMorpheus/Test/BinGenerationTest.cs index e513c7527..47cde2c42 100644 --- a/MetaMorpheus/Test/BinGenerationTest.cs +++ b/MetaMorpheus/Test/BinGenerationTest.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/CoIsolationTests.cs b/MetaMorpheus/Test/CoIsolationTests.cs index dee54bda7..5f932119f 100644 --- a/MetaMorpheus/Test/CoIsolationTests.cs +++ b/MetaMorpheus/Test/CoIsolationTests.cs @@ -5,11 +5,13 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using Readers; using TaskLayer; diff --git a/MetaMorpheus/Test/CustomFragmentationTest.cs b/MetaMorpheus/Test/CustomFragmentationTest.cs index 96fd8c5ac..3f0d6bac1 100644 --- a/MetaMorpheus/Test/CustomFragmentationTest.cs +++ b/MetaMorpheus/Test/CustomFragmentationTest.cs @@ -2,12 +2,13 @@ using MzLibUtil; using Nett; using NUnit.Framework; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using MassSpectrometry; +using Omics.Fragmentation.Peptide; using TaskLayer; namespace Test diff --git a/MetaMorpheus/Test/DigestionModificationTests.cs b/MetaMorpheus/Test/DigestionModificationTests.cs index 269251541..a3884b357 100644 --- a/MetaMorpheus/Test/DigestionModificationTests.cs +++ b/MetaMorpheus/Test/DigestionModificationTests.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using System.Text; +using Omics.Modifications; using UsefulProteomicsDatabases; namespace Test diff --git a/MetaMorpheus/Test/EventArgsTest.cs b/MetaMorpheus/Test/EventArgsTest.cs index 9b4c28c92..986630c16 100644 --- a/MetaMorpheus/Test/EventArgsTest.cs +++ b/MetaMorpheus/Test/EventArgsTest.cs @@ -5,12 +5,13 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/FdrTest.cs b/MetaMorpheus/Test/FdrTest.cs index 657585b62..80de8d810 100644 --- a/MetaMorpheus/Test/FdrTest.cs +++ b/MetaMorpheus/Test/FdrTest.cs @@ -8,12 +8,14 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; @@ -378,7 +380,7 @@ public static void TestComputePEPValue() PeptideWithSetModifications varPep = variantProtein.GetVariantProteins().SelectMany(p => p.Digest(CommonParameters.DigestionParams, null, null)).FirstOrDefault(); Product prod = new Product(ProductType.b, FragmentationTerminus.N, 1, 1, 1, 0); - List mfi = new List { new MatchedFragmentIon(ref prod, 1, 1.0, 1) }; + List mfi = new List { new MatchedFragmentIon(prod, 1, 1.0, 1) }; PeptideSpectralMatch variantPSM = new PeptideSpectralMatch(varPep, 0, maxScorePsm.Score, maxScorePsm.ScanIndex, scan, new CommonParameters(), mfi); diff --git a/MetaMorpheus/Test/GPTMDengineTest.cs b/MetaMorpheus/Test/GPTMDengineTest.cs index b89790e8e..dfc0fcef3 100644 --- a/MetaMorpheus/Test/GPTMDengineTest.cs +++ b/MetaMorpheus/Test/GPTMDengineTest.cs @@ -5,11 +5,12 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/IndexEngineTest.cs b/MetaMorpheus/Test/IndexEngineTest.cs index 3e2fa5e80..1cdf6e962 100644 --- a/MetaMorpheus/Test/IndexEngineTest.cs +++ b/MetaMorpheus/Test/IndexEngineTest.cs @@ -3,12 +3,14 @@ using MassSpectrometry; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using UsefulProteomicsDatabases; namespace Test diff --git a/MetaMorpheus/Test/LocalizationTest.cs b/MetaMorpheus/Test/LocalizationTest.cs index a7ee32e96..cc553ff84 100644 --- a/MetaMorpheus/Test/LocalizationTest.cs +++ b/MetaMorpheus/Test/LocalizationTest.cs @@ -5,10 +5,11 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; using System.Linq; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/MatchIonsOfAllCharges.cs b/MetaMorpheus/Test/MatchIonsOfAllCharges.cs index 3ec0ec8de..86e36d45d 100644 --- a/MetaMorpheus/Test/MatchIonsOfAllCharges.cs +++ b/MetaMorpheus/Test/MatchIonsOfAllCharges.cs @@ -7,7 +7,7 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using TaskLayer; using Chemistry; @@ -15,6 +15,8 @@ using MassSpectrometry; using Nett; using EngineLayer.Gptmd; +using Omics.Digestion; +using Omics.Modifications; using static System.Net.WebRequestMethods; namespace Test @@ -458,10 +460,10 @@ public static void TestDecoyLibrarySpectraGenerationFunction() Product c = new Product(ProductType.b, FragmentationTerminus.N, 3, 3, 1, 0); Product d = new Product(ProductType.b, FragmentationTerminus.N, 4, 4, 1, 0); var decoyPeptideTheorProducts = new List { a, b, c, d }; - MatchedFragmentIon aa = new MatchedFragmentIon(ref a, 1, 1, 1); - MatchedFragmentIon bb = new MatchedFragmentIon(ref b, 2, 2, 1); - MatchedFragmentIon cc = new MatchedFragmentIon(ref c, 3, 3, 1); - MatchedFragmentIon dd = new MatchedFragmentIon(ref d, 4, 4, 1); + MatchedFragmentIon aa = new MatchedFragmentIon(a, 1, 1, 1); + MatchedFragmentIon bb = new MatchedFragmentIon(b, 2, 2, 1); + MatchedFragmentIon cc = new MatchedFragmentIon(c, 3, 3, 1); + MatchedFragmentIon dd = new MatchedFragmentIon(d, 4, 4, 1); var peaks = new List { aa, bb, cc, dd }; var librarySpectrum = new LibrarySpectrum("library", 0, 0, peaks, 0); var decoySpectum = SpectralLibrarySearchFunction.GetDecoyLibrarySpectrumFromTargetByReverse(librarySpectrum, decoyPeptideTheorProducts); diff --git a/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs b/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs index 525507e90..5661074e2 100644 --- a/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs +++ b/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs @@ -8,7 +8,7 @@ using GuiFunctions.ViewModels.Legends; using NUnit.Framework; using OxyPlot; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; namespace Test.MetaDraw @@ -94,6 +94,8 @@ public static void TestSaveAndLoadDefaultSettings() string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestMetaDrawWithSpectraLibrary"); + if (Directory.Exists(outputFolder)) + Directory.Delete(outputFolder, true); Assert.That(!Directory.Exists(outputFolder)); MetaDrawSettingsViewModel.SettingsPath = Path.Combine(outputFolder, @"MetaDrawSettingsDefault.xml"); diff --git a/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs b/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs index 147b3c9fa..73b23a243 100644 --- a/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs +++ b/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs @@ -16,7 +16,7 @@ using MassSpectrometry; using NUnit.Framework; using OxyPlot.Series; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using Readers; using TaskLayer; diff --git a/MetaMorpheus/Test/MetaDraw/SpectrumMatchPlotTests.cs b/MetaMorpheus/Test/MetaDraw/SpectrumMatchPlotTests.cs index c5dd8d865..fd77aaae3 100644 --- a/MetaMorpheus/Test/MetaDraw/SpectrumMatchPlotTests.cs +++ b/MetaMorpheus/Test/MetaDraw/SpectrumMatchPlotTests.cs @@ -11,7 +11,7 @@ using NUnit.Framework; using OxyPlot; using OxyPlot.Annotations; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using TaskLayer; namespace Test.MetaDraw diff --git a/MetaMorpheus/Test/ModificationAnalysisTest.cs b/MetaMorpheus/Test/ModificationAnalysisTest.cs index 5cc07a04c..ae6275616 100644 --- a/MetaMorpheus/Test/ModificationAnalysisTest.cs +++ b/MetaMorpheus/Test/ModificationAnalysisTest.cs @@ -4,10 +4,12 @@ using MassSpectrometry; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs index e1b4c513c..2fdd76fc4 100644 --- a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs +++ b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs @@ -3,12 +3,14 @@ using MassSpectrometry; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; namespace Test @@ -252,20 +254,20 @@ public static void MultiProteaseParsimony_SharedSequenceCanBeUniquePeptide() Assert.AreEqual(2, proteinGroup1.AllPeptides.Count); Assert.AreEqual(1, proteinGroup1.UniquePeptides.Count); var pg1pep1 = proteinGroup1.AllPeptides.Where(p => p.BaseSequence == "XYZ").First(); - Assert.That(pg1pep1.DigestionParams.Protease.Name == "proteaseA"); + Assert.That(pg1pep1.DigestionParams.DigestionAgent.Name == "proteaseA"); var pg1pep2 = proteinGroup1.AllPeptides.Where(p => p.BaseSequence == "ABC").First(); - Assert.That(pg1pep2.DigestionParams.Protease.Name == "proteaseA"); + Assert.That(pg1pep2.DigestionParams.DigestionAgent.Name == "proteaseA"); Assert.That(proteinGroup1.UniquePeptides.First().BaseSequence.Equals("ABC")); var proteinGroup2 = proteinGroups.Where(p => p.ProteinGroupName == "2").First(); Assert.AreEqual(3, proteinGroup2.AllPeptides.Count); Assert.AreEqual(2, proteinGroup2.UniquePeptides.Count); var pg2pep1 = proteinGroup2.AllPeptides.Where(p => p.BaseSequence == "XYZ").First(); - Assert.That(pg2pep1.DigestionParams.Protease.Name == "proteaseA"); + Assert.That(pg2pep1.DigestionParams.DigestionAgent.Name == "proteaseA"); var pg2pep2 = proteinGroup2.AllPeptides.Where(p => p.BaseSequence == "ABC").First(); - Assert.That(pg2pep2.DigestionParams.Protease.Name == "proteaseB"); + Assert.That(pg2pep2.DigestionParams.DigestionAgent.Name == "proteaseB"); var pg2pep3 = proteinGroup2.AllPeptides.Where(p => p.BaseSequence == "EFGABC").First(); - Assert.That(pg2pep3.DigestionParams.Protease.Name == "proteaseA"); + Assert.That(pg2pep3.DigestionParams.DigestionAgent.Name == "proteaseA"); var uniquePeptideSequences = proteinGroup2.UniquePeptides.Select(p => p.BaseSequence).ToList(); Assert.That(uniquePeptideSequences.Contains("ABC")); Assert.That(uniquePeptideSequences.Contains("EFGABC")); @@ -345,9 +347,9 @@ public static void MultiProteaseParsimony_IndistringuishableProteinsNowDistingui PeptideWithSetModifications pg1pep1 = pg1.AllPeptides.Where(v => v.BaseSequence == "ABC").First(); PeptideWithSetModifications pg1pep2 = pg1.AllPeptides.Where(v => v.BaseSequence == "EFG").First(); Assert.That(pg1.UniquePeptides.Contains(pg1pep1)); - Assert.That(pg1pep1.DigestionParams.Protease.Name == "testA"); + Assert.That(pg1pep1.DigestionParams.DigestionAgent.Name == "testA"); Assert.That(pg1.UniquePeptides.Contains(pg1pep2)); - Assert.That(pg1pep2.DigestionParams.Protease.Name == "testA"); + Assert.That(pg1pep2.DigestionParams.DigestionAgent.Name == "testA"); Assert.That(pg1.AllPeptides.Count == 2); Assert.That(pg1.UniquePeptides.Count == 2); @@ -356,9 +358,9 @@ public static void MultiProteaseParsimony_IndistringuishableProteinsNowDistingui PeptideWithSetModifications pg2pep1 = pg2.AllPeptides.Where(v => v.BaseSequence == "ABC").First(); PeptideWithSetModifications pg2pep2 = pg2.AllPeptides.Where(v => v.BaseSequence == "EFG").First(); Assert.That(pg2.UniquePeptides.Contains(pg2pep1)); - Assert.That(pg2pep1.DigestionParams.Protease.Name == "testB"); + Assert.That(pg2pep1.DigestionParams.DigestionAgent.Name == "testB"); Assert.That(pg2.UniquePeptides.Contains(pg2pep2)); - Assert.That(pg2pep2.DigestionParams.Protease.Name == "testB"); + Assert.That(pg2pep2.DigestionParams.DigestionAgent.Name == "testB"); Assert.That(pg2.AllPeptides.Count == 2); Assert.That(pg2.UniquePeptides.Count == 2); } diff --git a/MetaMorpheus/Test/Multiplex_Labeling_TMT_iTRAQ.cs b/MetaMorpheus/Test/Multiplex_Labeling_TMT_iTRAQ.cs index 2b0887175..20682d7b3 100644 --- a/MetaMorpheus/Test/Multiplex_Labeling_TMT_iTRAQ.cs +++ b/MetaMorpheus/Test/Multiplex_Labeling_TMT_iTRAQ.cs @@ -4,7 +4,7 @@ using MassSpectrometry; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -17,6 +17,7 @@ using TaskLayer; using UsefulProteomicsDatabases; using System.Threading.Tasks; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/MyPeptideTest.cs b/MetaMorpheus/Test/MyPeptideTest.cs index 0f71ea28a..04af2371e 100644 --- a/MetaMorpheus/Test/MyPeptideTest.cs +++ b/MetaMorpheus/Test/MyPeptideTest.cs @@ -7,13 +7,14 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using UsefulProteomicsDatabases; + using Omics.Modifications; + using UsefulProteomicsDatabases; namespace Test { diff --git a/MetaMorpheus/Test/MyTaskTest.cs b/MetaMorpheus/Test/MyTaskTest.cs index ee4ebd4ff..be7cf4f8d 100644 --- a/MetaMorpheus/Test/MyTaskTest.cs +++ b/MetaMorpheus/Test/MyTaskTest.cs @@ -11,6 +11,7 @@ using System.IO; using System.Linq; using System.Reflection; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/ParameterTest.cs b/MetaMorpheus/Test/ParameterTest.cs index d5647df4a..539551cb2 100644 --- a/MetaMorpheus/Test/ParameterTest.cs +++ b/MetaMorpheus/Test/ParameterTest.cs @@ -3,11 +3,13 @@ using MzLibUtil; using Nett; using NUnit.Framework; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; +using Omics.Digestion; +using Omics.Fragmentation.Peptide; using TaskLayer; namespace Test diff --git a/MetaMorpheus/Test/ProteinGroupTest.cs b/MetaMorpheus/Test/ProteinGroupTest.cs index bb4c15d8e..8d92eb2b8 100644 --- a/MetaMorpheus/Test/ProteinGroupTest.cs +++ b/MetaMorpheus/Test/ProteinGroupTest.cs @@ -11,6 +11,8 @@ using TaskLayer; using ProteinGroup = EngineLayer.ProteinGroup; using System.IO; +using Omics.Digestion; +using Omics.Modifications; using UsefulProteomicsDatabases; namespace Test diff --git a/MetaMorpheus/Test/PsmTsvWriterTests.cs b/MetaMorpheus/Test/PsmTsvWriterTests.cs index 0c5b364c0..db9b9f74f 100644 --- a/MetaMorpheus/Test/PsmTsvWriterTests.cs +++ b/MetaMorpheus/Test/PsmTsvWriterTests.cs @@ -3,9 +3,11 @@ using MassSpectrometry; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; +using Omics.Digestion; +using Omics.Modifications; namespace Test { @@ -54,7 +56,7 @@ public static void ResolveModificationsTest() //we're adding a neutral loss of 5 to the product to make sure we hit the right spot in the unit test to add that loss to the product ion string Product p = new Product(ProductType.b, FragmentationTerminus.N, 1, 1, 1, 5); - mfi.Add(new MatchedFragmentIon(ref p, 1, 1, 1)); + mfi.Add(new MatchedFragmentIon(p, 1, 1, 1)); PeptideSpectralMatch myPsm = new PeptideSpectralMatch(pwsm1, 0, 10, 0, scan, new CommonParameters(), mfi); myPsm.AddOrReplace(pwsm2, 10, 0, true, mfi, 10); diff --git a/MetaMorpheus/Test/PsvTsvTest.cs b/MetaMorpheus/Test/PsvTsvTest.cs index dd3ed1000..55fd5c5f0 100644 --- a/MetaMorpheus/Test/PsvTsvTest.cs +++ b/MetaMorpheus/Test/PsvTsvTest.cs @@ -1,7 +1,7 @@ using EngineLayer; using GuiFunctions; using NUnit.Framework; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System.Collections.Generic; using System.IO; using System.Linq; @@ -239,7 +239,7 @@ public static void TestSimpleToLibrarySpectrum() //the code below tests the addition and correct output for neutral loss fragments Product p = new Product(ProductType.bWaterLoss, FragmentationTerminus.N, 1, 1, 1, 18); - MatchedFragmentIon matchedIon = new(ref p, 1, 1, 1); + MatchedFragmentIon matchedIon = new(p, 1, 1, 1); psms[0].MatchedIons.Add(matchedIon); string librarySpectrumWithNeutralLoss = psms[0].ToLibrarySpectrum().ToString(); diff --git a/MetaMorpheus/Test/QuantificationTest.cs b/MetaMorpheus/Test/QuantificationTest.cs index d61748b82..4df793fd9 100644 --- a/MetaMorpheus/Test/QuantificationTest.cs +++ b/MetaMorpheus/Test/QuantificationTest.cs @@ -5,7 +5,7 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using Readers; using System; @@ -13,6 +13,7 @@ using System.IO; using System.Linq; using System.Text; +using Omics.Modifications; using TaskLayer; namespace Test @@ -192,7 +193,7 @@ public static void TestProteinQuantFileHeaders(bool hasDefinedExperimentalDesign mzAnalyzer: MZAnalyzerType.Orbitrap, totalIonCurrent: intensities.Sum(), injectionTime: 1.0, noiseData: null, nativeId: "scan=1"); // create the MS2 scan - var pep = new PeptideWithSetModifications(peptide, new Dictionary()); + var pep = new PeptideWithSetModifications(peptide, new Dictionary()); List frags = new List(); pep.Fragment(DissociationType.HCD, FragmentationTerminus.Both, frags); double[] mz2 = frags.Select(v => v.NeutralMass.ToMz(1)).ToArray(); diff --git a/MetaMorpheus/Test/RetentionTimeTest.cs b/MetaMorpheus/Test/RetentionTimeTest.cs index 41efd41aa..72102952c 100644 --- a/MetaMorpheus/Test/RetentionTimeTest.cs +++ b/MetaMorpheus/Test/RetentionTimeTest.cs @@ -3,6 +3,7 @@ using Proteomics.ProteolyticDigestion; using Proteomics.RetentionTimePrediction; using System.Collections.Generic; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/RobTest.cs b/MetaMorpheus/Test/RobTest.cs index 9a3d98f8f..9c7ce8f56 100644 --- a/MetaMorpheus/Test/RobTest.cs +++ b/MetaMorpheus/Test/RobTest.cs @@ -4,11 +4,13 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/SearchEngineTests.cs b/MetaMorpheus/Test/SearchEngineTests.cs index c2255f33f..15d7e8809 100644 --- a/MetaMorpheus/Test/SearchEngineTests.cs +++ b/MetaMorpheus/Test/SearchEngineTests.cs @@ -10,12 +10,14 @@ using NUnit.Framework; using Proteomics; using Proteomics.AminoAcidPolymer; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using Readers; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/SearchTaskTest.cs b/MetaMorpheus/Test/SearchTaskTest.cs index fbec1126d..dc3cb447c 100644 --- a/MetaMorpheus/Test/SearchTaskTest.cs +++ b/MetaMorpheus/Test/SearchTaskTest.cs @@ -3,13 +3,15 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; namespace Test diff --git a/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs b/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs index 3d0cf7f57..e7c44fe94 100644 --- a/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs +++ b/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/SeqCoverageTest.cs b/MetaMorpheus/Test/SeqCoverageTest.cs index b405bea77..620fb1c75 100644 --- a/MetaMorpheus/Test/SeqCoverageTest.cs +++ b/MetaMorpheus/Test/SeqCoverageTest.cs @@ -2,12 +2,14 @@ using EngineLayer; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; using System.Linq; using MassSpectrometry; using FlashLFQ; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; namespace Test @@ -121,10 +123,10 @@ public static void TestFragmentSequenceCoverage() Product producty1 = new (ProductType.y, FragmentationTerminus.C, 0, 1, 3, 0); Product producty2 = new (ProductType.y, FragmentationTerminus.C, 0, 2, 2, 0); - MatchedFragmentIon mfib1 = new MatchedFragmentIon(ref productb1, 0, 0, 1); - MatchedFragmentIon mfib2 = new MatchedFragmentIon(ref productb2, 0, 0, 2); - MatchedFragmentIon mfiy1 = new MatchedFragmentIon(ref producty1, 0, 0, 2); - MatchedFragmentIon mfiy2 = new MatchedFragmentIon(ref producty2, 0, 0, 2); + MatchedFragmentIon mfib1 = new MatchedFragmentIon(productb1, 0, 0, 1); + MatchedFragmentIon mfib2 = new MatchedFragmentIon(productb2, 0, 0, 2); + MatchedFragmentIon mfiy1 = new MatchedFragmentIon(producty1, 0, 0, 2); + MatchedFragmentIon mfiy2 = new MatchedFragmentIon(producty2, 0, 0, 2); List mfis1 = new List { mfib1 }; List mfis2 = new List { mfib2, mfiy1, mfiy2 }; diff --git a/MetaMorpheus/Test/SilacTest.cs b/MetaMorpheus/Test/SilacTest.cs index f9c17b02b..e62673798 100644 --- a/MetaMorpheus/Test/SilacTest.cs +++ b/MetaMorpheus/Test/SilacTest.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.IO; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/SpectralLibraryReaderTest.cs b/MetaMorpheus/Test/SpectralLibraryReaderTest.cs index c158fbc56..8170c7fc9 100644 --- a/MetaMorpheus/Test/SpectralLibraryReaderTest.cs +++ b/MetaMorpheus/Test/SpectralLibraryReaderTest.cs @@ -5,11 +5,12 @@ using EngineLayer; using TaskLayer; using System.Collections.Generic; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using System.Globalization; using Proteomics; using MassSpectrometry; using EngineLayer.ClassicSearch; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/SpectralRecoveryTest.cs b/MetaMorpheus/Test/SpectralRecoveryTest.cs index eb437e943..c26ed855a 100644 --- a/MetaMorpheus/Test/SpectralRecoveryTest.cs +++ b/MetaMorpheus/Test/SpectralRecoveryTest.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Text; using Easy.Common.Extensions; +using Omics.Modifications; using TaskLayer; using TaskLayer.MbrAnalysis; diff --git a/MetaMorpheus/Test/StefanParsimonyTest.cs b/MetaMorpheus/Test/StefanParsimonyTest.cs index 319980ed7..b836d9b30 100644 --- a/MetaMorpheus/Test/StefanParsimonyTest.cs +++ b/MetaMorpheus/Test/StefanParsimonyTest.cs @@ -2,11 +2,12 @@ using MassSpectrometry; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.Linq; +using Omics.Modifications; namespace Test { @@ -169,8 +170,8 @@ public static void ParsimonyWeirdCatch() Product productC3 = new Product(ProductType.y, FragmentationTerminus.C, 0, 3, 4, 0); Product productC4 = new Product(ProductType.y, FragmentationTerminus.C, 0, 4, 3, 0); - MatchedFragmentIon mfiC3 = new MatchedFragmentIon(ref productC3, 0, 0, 1); - MatchedFragmentIon mfiC4 = new MatchedFragmentIon(ref productC4, 0, 0, 1); + MatchedFragmentIon mfiC3 = new MatchedFragmentIon(productC3, 0, 0, 1); + MatchedFragmentIon mfiC4 = new MatchedFragmentIon(productC4, 0, 0, 1); List psms = new List { diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index acbe60418..63da5f2c8 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + diff --git a/MetaMorpheus/Test/TestDataFile.cs b/MetaMorpheus/Test/TestDataFile.cs index 012fe5553..4757672eb 100644 --- a/MetaMorpheus/Test/TestDataFile.cs +++ b/MetaMorpheus/Test/TestDataFile.cs @@ -1,6 +1,6 @@ using Chemistry; using MassSpectrometry; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; diff --git a/MetaMorpheus/Test/TestPsm.cs b/MetaMorpheus/Test/TestPsm.cs index 56a360d47..e34d4b3a1 100644 --- a/MetaMorpheus/Test/TestPsm.cs +++ b/MetaMorpheus/Test/TestPsm.cs @@ -6,13 +6,15 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; using PsmFromTsv = EngineLayer.PsmFromTsv; @@ -419,7 +421,7 @@ public static void TestComplementaryIons() for (int i = 0; i < myProducts.Count; i++) { var prod = myProducts[i]; - mfiList.Add(new MatchedFragmentIon(ref prod, 1, 1, 1)); + mfiList.Add(new MatchedFragmentIon(prod, 1, 1, 1)); } Dictionary> PTMF = new Dictionary>(); @@ -478,15 +480,15 @@ public static void TestPSMFragmentCoverage() Product productN6 = new Product(ProductType.b, FragmentationTerminus.N, 0, 6, 6, 0); Product productN8 = new Product(ProductType.b, FragmentationTerminus.N, 0, 8, 8, 0); Product productN13 = new Product(ProductType.b, FragmentationTerminus.N, 0, 13, 13, 0); - MatchedFragmentIon mfiC3 = new MatchedFragmentIon(ref productC3, 0, 0, 1); - MatchedFragmentIon mfiC4 = new MatchedFragmentIon(ref productC4, 0, 0, 1); - MatchedFragmentIon mfiC7 = new MatchedFragmentIon(ref productC7, 0, 0, 1); - MatchedFragmentIon mfiC13 = new MatchedFragmentIon(ref productC13, 0, 0, 1); - MatchedFragmentIon mfiN3 = new MatchedFragmentIon(ref productN3, 0, 0, 1); - MatchedFragmentIon mfiN4 = new MatchedFragmentIon(ref productN4, 0, 0, 1); - MatchedFragmentIon mfiN6 = new MatchedFragmentIon(ref productN6, 0, 0, 1); - MatchedFragmentIon mfiN8 = new MatchedFragmentIon(ref productN8, 0, 0, 1); - MatchedFragmentIon mfiN13 = new MatchedFragmentIon(ref productN13, 0, 0, 1); + MatchedFragmentIon mfiC3 = new MatchedFragmentIon(productC3, 0, 0, 1); + MatchedFragmentIon mfiC4 = new MatchedFragmentIon(productC4, 0, 0, 1); + MatchedFragmentIon mfiC7 = new MatchedFragmentIon(productC7, 0, 0, 1); + MatchedFragmentIon mfiC13 = new MatchedFragmentIon(productC13, 0, 0, 1); + MatchedFragmentIon mfiN3 = new MatchedFragmentIon(productN3, 0, 0, 1); + MatchedFragmentIon mfiN4 = new MatchedFragmentIon(productN4, 0, 0, 1); + MatchedFragmentIon mfiN6 = new MatchedFragmentIon(productN6, 0, 0, 1); + MatchedFragmentIon mfiN8 = new MatchedFragmentIon(productN8, 0, 0, 1); + MatchedFragmentIon mfiN13 = new MatchedFragmentIon(productN13, 0, 0, 1); List mfis1 = new List { mfiC3, mfiC4, mfiC7, mfiC13, mfiN3, mfiN4, mfiN6, mfiN8, mfiN13}; MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, 0, 1, null, new CommonParameters()); diff --git a/MetaMorpheus/Test/TestTopDown.cs b/MetaMorpheus/Test/TestTopDown.cs index 5c768533b..b99e13262 100644 --- a/MetaMorpheus/Test/TestTopDown.cs +++ b/MetaMorpheus/Test/TestTopDown.cs @@ -8,6 +8,7 @@ using IO.MzML; using MzLibUtil; using NUnit.Framework; +using Omics.Modifications; using Proteomics; using Proteomics.ProteolyticDigestion; using TaskLayer; diff --git a/MetaMorpheus/Test/VariantSearchTests.cs b/MetaMorpheus/Test/VariantSearchTests.cs index 82d20ba42..d13602de4 100644 --- a/MetaMorpheus/Test/VariantSearchTests.cs +++ b/MetaMorpheus/Test/VariantSearchTests.cs @@ -12,6 +12,7 @@ using TaskLayer; using UsefulProteomicsDatabases; using Nett; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/XLSearchOutputTest.cs b/MetaMorpheus/Test/XLSearchOutputTest.cs index 7066e2a1f..7a1406887 100644 --- a/MetaMorpheus/Test/XLSearchOutputTest.cs +++ b/MetaMorpheus/Test/XLSearchOutputTest.cs @@ -4,7 +4,7 @@ using TaskLayer; using EngineLayer; using System.Linq; -using Proteomics.Fragmentation; +using Omics.Fragmentation; namespace Test { @@ -99,9 +99,9 @@ public static void WriteXlSpectralLibraryTest() Assert.AreEqual(interSpectrum.AlphaPeptideSequence, "GVTVDKMTELR"); Assert.AreEqual(interSpectrum.BetaPeptideSequence, "SFTFVTKTPPAAVLLK"); Assert.True(interSpectrum.BetaPeptideSpectrum.IsBetaPeptide); - interLinkSpectrum.MatchedFragmentIons.Add(new MatchedFragmentIon(ref productWithNeutralLoss, 100, 100, 1)); + interLinkSpectrum.MatchedFragmentIons.Add(new MatchedFragmentIon(productWithNeutralLoss, 100, 100, 1)); CrosslinkLibrarySpectrum spectrumDup = (CrosslinkLibrarySpectrum)interLinkSpectrum; - spectrumDup.BetaPeptideSpectrum.MatchedFragmentIons.Add(new MatchedFragmentIon(ref productWithNeutralLoss20, 100, 100, 1)); + spectrumDup.BetaPeptideSpectrum.MatchedFragmentIons.Add(new MatchedFragmentIon(productWithNeutralLoss20, 100, 100, 1)); var spectrumString = spectrumDup.ToString(); // Check neutral loss fragments are written correctly StringAssert.Contains("\"Y1^1-10/0ppm\"", spectrumString); diff --git a/MetaMorpheus/Test/XLTest.cs b/MetaMorpheus/Test/XLTest.cs index a0f945fa4..b7f4af290 100644 --- a/MetaMorpheus/Test/XLTest.cs +++ b/MetaMorpheus/Test/XLTest.cs @@ -9,7 +9,7 @@ using NUnit.Framework; using Proteomics; using Proteomics.AminoAcidPolymer; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -18,6 +18,8 @@ using System.IO.Compression; using System.Linq; using System.Text; +using Omics.Digestion; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; diff --git a/MetaMorpheus/Test/XLTestNGlyco.cs b/MetaMorpheus/Test/XLTestNGlyco.cs index 7cac3f08f..34ad2ecd5 100644 --- a/MetaMorpheus/Test/XLTestNGlyco.cs +++ b/MetaMorpheus/Test/XLTestNGlyco.cs @@ -6,7 +6,7 @@ using MassSpectrometry; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -16,6 +16,7 @@ using UsefulProteomicsDatabases; using MzLibUtil; using Nett; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/XLTestOGlyco.cs b/MetaMorpheus/Test/XLTestOGlyco.cs index 5d15b6d21..ae85af0cb 100644 --- a/MetaMorpheus/Test/XLTestOGlyco.cs +++ b/MetaMorpheus/Test/XLTestOGlyco.cs @@ -2,7 +2,7 @@ using MassSpectrometry; using NUnit.Framework; using Proteomics; -using Proteomics.Fragmentation; +using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; @@ -19,6 +19,7 @@ using MzLibUtil; using Readers; using System.Text; +using Omics.Modifications; namespace Test { diff --git a/MetaMorpheus/Test/gptmdPrunedBdTests.cs b/MetaMorpheus/Test/gptmdPrunedBdTests.cs index b99c7cdda..586560fd0 100644 --- a/MetaMorpheus/Test/gptmdPrunedBdTests.cs +++ b/MetaMorpheus/Test/gptmdPrunedBdTests.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; @@ -359,7 +360,7 @@ public static void TestProteinPrunedWithModSelection() CommonParameters commonParam = new CommonParameters(useDeltaScore: false); double[,] noiseData = new double[10000, 10000]; noiseData[0,0] = 1.0; - List matchedFragmentIons = new List() { }; + List matchedFragmentIons = new List() { }; MzSpectrum spectrum = new MzSpectrum(noiseData); MsDataScan scan = new MsDataScan(spectrum , 1, 1, true, Polarity.Unknown, 2, new MzLibUtil.MzRange(10, 1000), "", MZAnalyzerType.Orbitrap, 10000, null, noiseData, ""); testPostTaskParameters.ProteinList = new List() { protein1, protein2 }; @@ -464,7 +465,7 @@ public static void TestProteinPrunedWithModSelectionAndVariants() CommonParameters commonParam = new CommonParameters(useDeltaScore: false); double[,] noiseData = new double[10000, 10000]; noiseData[0, 0] = 1.0; - List matchedFragmentIons = new List() { }; + List matchedFragmentIons = new List() { }; MzSpectrum spectrum = new MzSpectrum(noiseData); MsDataScan scan = new MsDataScan(spectrum, 1, 1, true, Polarity.Unknown, 2, new MzLibUtil.MzRange(10, 1000), "", MZAnalyzerType.Orbitrap, 10000, null, noiseData, ""); testPostTaskParameters.ProteinList = proteinList; From 976ab079a4158d407d494d065f340477f2b83e70 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 10 Jan 2024 10:57:56 -0600 Subject: [PATCH 02/39] Adjusted digestionparams toml --- .../EngineLayer/Indexing/IndexingEngine.cs | 16 +++++++++++++--- MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 13 +++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs index 3b2817b71..e3f3a5ffc 100644 --- a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs +++ b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs @@ -260,9 +260,19 @@ private void AddInteriorTerminalModsToPrecursorIndex(List[] precursorIndex, foreach (KeyValuePair> relevantDatabaseMod in databaseAnnotatedMods) { int fragmentNumber = relevantDatabaseMod.Key; - Product fragmentAtIndex = fragmentMasses.Where(x => x.FragmentNumber == fragmentNumber).FirstOrDefault(); - double basePrecursorMass = fragmentAtIndex.NeutralMass == default(Product).NeutralMass ? - peptide.MonoisotopicMass : fragmentAtIndex.NeutralMass - DissociationTypeCollection.GetMassShiftFromProductType(fragmentAtIndex.ProductType) + WaterMonoisotopicMass; + Product fragmentAtIndex = fragmentMasses.FirstOrDefault(x => x.FragmentNumber == fragmentNumber); + + double basePrecursorMass; + if (fragmentAtIndex.NeutralMass == 0.0) + { + basePrecursorMass = peptide.MonoisotopicMass; + } + else + { + basePrecursorMass = fragmentAtIndex.NeutralMass - + DissociationTypeCollection.GetMassShiftFromProductType(fragmentAtIndex.ProductType) + + WaterMonoisotopicMass; + } foreach (Modification mod in relevantDatabaseMod.Value) { diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index 31f6b2189..e4c56cdd4 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -14,6 +14,7 @@ using System.Globalization; using System.IO; using System.Linq; +using System.Reflection; using System.Reflection.Metadata.Ecma335; using System.Text; using System.Threading.Tasks; @@ -66,6 +67,18 @@ public abstract class MetaMorpheusTask tmlString.Value == "AverageDdaScansWithOverlap" ? SpectraFileAveragingType.AverageDdaScans : Enum.Parse(tmlString.Value)))) + .ConfigureType(type => type + .IgnoreProperty(p => p.DigestionAgent) + .IgnoreProperty(p => p.MaxModsForPeptide) + .IgnoreProperty(p => p.MaxPeptideLength) + .IgnoreProperty(p => p.MinPeptideLength) + //.Map("MaxMods").ToKey("MaxModsForPeptide") + //.Map("MaxLength").ToKey("MaxPeptideLength") + //.Map("MinLength").ToKey("MinPeptideLength") + + + ) + ); From 12129f8aa4a096b5292c57193deec552edf18d99 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 10 Jan 2024 11:05:22 -0600 Subject: [PATCH 03/39] fixed indexing engine without having a default product type --- MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs index e3f3a5ffc..c586fa394 100644 --- a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs +++ b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs @@ -263,7 +263,7 @@ private void AddInteriorTerminalModsToPrecursorIndex(List[] precursorIndex, Product fragmentAtIndex = fragmentMasses.FirstOrDefault(x => x.FragmentNumber == fragmentNumber); double basePrecursorMass; - if (fragmentAtIndex.NeutralMass == 0.0) + if (fragmentAtIndex is null) { basePrecursorMass = peptide.MonoisotopicMass; } From 9e4da0c7045a6b3ec552b2203cceea45bc395ef8 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 10 Jan 2024 11:18:45 -0600 Subject: [PATCH 04/39] Fixed silac test --- MetaMorpheus/Test/SilacTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MetaMorpheus/Test/SilacTest.cs b/MetaMorpheus/Test/SilacTest.cs index e62673798..778c65118 100644 --- a/MetaMorpheus/Test/SilacTest.cs +++ b/MetaMorpheus/Test/SilacTest.cs @@ -377,7 +377,7 @@ public static void TestSilacTurnover() string[] output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); Assert.IsTrue(output[1].Contains("PEPTKIDEK\t")); //test the unlabeled is present Assert.IsTrue(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tIntensity_silacPart2_Original\tIntensity_silacPart2_NewlySynthesized\t" + - "Detection Type_silac_Original\tDetection Type_silac_NewlySynthesized\tDetection Type_silacPart2_Original\tDetection Type_silacPart2_NewlySynthesized\t")); //test filename changes + "Detection Type_silac_Original\tDetection Type_silac_NewlySynthesized\tDetection Type_silacPart2_Original\tDetection Type_silacPart2_NewlySynthesized")); //test filename changes Assert.IsTrue(output[1].Contains("\t1093750\t437500\t")); //test intensities output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeaks.tsv"); From ad5097b4e4280d005cc5f1d46acdeb56ecec5560 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 10 Jan 2024 11:39:39 -0600 Subject: [PATCH 05/39] All Tests Pass! --- MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs | 2 ++ MetaMorpheus/Test/SilacTest.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs b/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs index 73b23a243..7dafc48b8 100644 --- a/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs +++ b/MetaMorpheus/Test/MetaDraw/MetaDrawTest.cs @@ -1125,6 +1125,8 @@ public static void TestMetaDrawLoadingWithWeirdFileNames() metadrawLogic.CleanUpResources(); // delete output + + File.Delete(pathWithPeriodInIt); Directory.Delete(outputFolder, true); } diff --git a/MetaMorpheus/Test/SilacTest.cs b/MetaMorpheus/Test/SilacTest.cs index 778c65118..74f86989a 100644 --- a/MetaMorpheus/Test/SilacTest.cs +++ b/MetaMorpheus/Test/SilacTest.cs @@ -412,7 +412,7 @@ public static void TestSilacTurnover() output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); Assert.IsTrue(output[1].Contains("PEPTKIDEK\t")); //test the unlabeled is present - Assert.IsTrue(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tDetection Type_silac_Original\tDetection Type_silac_NewlySynthesized\t")); //test filename changes + Assert.IsTrue(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tDetection Type_silac_Original\tDetection Type_silac_NewlySynthesized")); //test filename changes Assert.IsTrue(output[1].Contains("\t656250\t875000\t")); //test intensities output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllPSMs.psmtsv"); @@ -453,7 +453,7 @@ public static void TestSilacTurnover() output = File.ReadAllLines(TestContext.CurrentContext.TestDirectory + @"/TestSilac/AllQuantifiedPeptides.tsv"); Assert.IsTrue(output[1].Contains("PEPEPEPTK\t")); //test the unlabeled is present Assert.IsTrue(output[2].Contains("PEPTKIDEK\t")); //test the unlabeled is present - Assert.IsTrue(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tDetection Type_silac_Original\tDetection Type_silac_NewlySynthesized\t")); //test filename changes + Assert.IsTrue(output[0].Contains("\tIntensity_silac_Original\tIntensity_silac_NewlySynthesized\tDetection Type_silac_Original\tDetection Type_silac_NewlySynthesized")); //test filename changes Assert.IsTrue(output[1].Contains("\t2625000\t6125000\t")); //test the light intensity is not negative. Assert.IsTrue(output[2].Contains("\t10500000\t5250000\t")); //test intensities. The observation is 9/6/3. From c30b67cc5352b372307534740219d0c06f0926fc Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 11 Jan 2024 14:06:05 -0600 Subject: [PATCH 06/39] Added toml test for new digestionparams --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 13 ++---- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- MetaMorpheus/Test/TestToml.cs | 46 +++++++++++++++++++ 8 files changed, 55 insertions(+), 16 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index b275d6b86..85646b9f0 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index c072889ac..0f22bcc70 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index d4de3f8c0..29014e0f7 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index e8f232287..5f600feb4 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index e4c56cdd4..8dd270e14 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -69,16 +69,9 @@ public abstract class MetaMorpheusTask : Enum.Parse(tmlString.Value)))) .ConfigureType(type => type .IgnoreProperty(p => p.DigestionAgent) - .IgnoreProperty(p => p.MaxModsForPeptide) - .IgnoreProperty(p => p.MaxPeptideLength) - .IgnoreProperty(p => p.MinPeptideLength) - //.Map("MaxMods").ToKey("MaxModsForPeptide") - //.Map("MaxLength").ToKey("MaxPeptideLength") - //.Map("MinLength").ToKey("MinPeptideLength") - - - ) - + .IgnoreProperty(p => p.MaxMods) + .IgnoreProperty(p => p.MaxLength) + .IgnoreProperty(p => p.MinLength)) ); diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 8b1cbcfc6..68e09f204 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 63da5f2c8..49ca2eb5b 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + diff --git a/MetaMorpheus/Test/TestToml.cs b/MetaMorpheus/Test/TestToml.cs index 4a8bf2734..f17690598 100644 --- a/MetaMorpheus/Test/TestToml.cs +++ b/MetaMorpheus/Test/TestToml.cs @@ -10,6 +10,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Omics.Digestion; +using Omics.Fragmentation; using SpectralAveraging; using TaskLayer; using UsefulProteomicsDatabases; @@ -262,6 +264,50 @@ public static void TestFileSpecificAndCommonParametersNameEquality() Assert.That(commonProperty.GetType(), Is.EqualTo(fileSpecificProperty.GetType())); } } + + [Test] + public static void TestDigestionParamsTomlReadingWriting() + { + var digestionParams = new DigestionParams("top-down", 4, 5, 12345, 2012, + InitiatorMethionineBehavior.Undefined, 4, CleavageSpecificity.Semi, FragmentationTerminus.Both, false, + true, true); + var commonParams = new CommonParameters(digestionParams: digestionParams); + var searchTask = new SearchTask(); + searchTask.CommonParameters = commonParams; + + // check that digestion params are correct in search task + Assert.That(searchTask.CommonParameters.DigestionParams.FragmentationTerminus, Is.EqualTo(digestionParams.FragmentationTerminus)); + Assert.That(searchTask.CommonParameters.DigestionParams.SearchModeType, Is.EqualTo(digestionParams.SearchModeType)); + Assert.That(searchTask.CommonParameters.DigestionParams.InitiatorMethionineBehavior, Is.EqualTo(digestionParams.InitiatorMethionineBehavior)); + Assert.That(searchTask.CommonParameters.DigestionParams.MaxMissedCleavages, Is.EqualTo(digestionParams.MaxMissedCleavages)); + Assert.That(searchTask.CommonParameters.DigestionParams.MaxModificationIsoforms, Is.EqualTo(digestionParams.MaxModificationIsoforms)); + Assert.That(searchTask.CommonParameters.DigestionParams.MinPeptideLength, Is.EqualTo(digestionParams.MinPeptideLength)); + Assert.That(searchTask.CommonParameters.DigestionParams.MaxPeptideLength, Is.EqualTo(digestionParams.MaxPeptideLength)); + Assert.That(searchTask.CommonParameters.DigestionParams.Protease.Name, Is.EqualTo(digestionParams.Protease.Name)); + Assert.That(searchTask.CommonParameters.DigestionParams.GeneratehUnlabeledProteinsForSilac, Is.EqualTo(digestionParams.GeneratehUnlabeledProteinsForSilac)); + Assert.That(searchTask.CommonParameters.DigestionParams.KeepNGlycopeptide, Is.EqualTo(digestionParams.KeepNGlycopeptide)); + Assert.That(searchTask.CommonParameters.DigestionParams.KeepOGlycopeptide, Is.EqualTo(digestionParams.KeepOGlycopeptide)); + + // write and read file + string filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "testDigestionParams.toml"); + Toml.WriteFile(searchTask, filePath, MetaMorpheusTask.tomlConfig); + var searchTaskLoaded = Toml.ReadFile(filePath, MetaMorpheusTask.tomlConfig); + + // check that digestion params are correct in search task + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.FragmentationTerminus, Is.EqualTo(digestionParams.FragmentationTerminus)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.SearchModeType, Is.EqualTo(digestionParams.SearchModeType)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.InitiatorMethionineBehavior, Is.EqualTo(digestionParams.InitiatorMethionineBehavior)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.MaxMissedCleavages, Is.EqualTo(digestionParams.MaxMissedCleavages)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.MaxModificationIsoforms, Is.EqualTo(digestionParams.MaxModificationIsoforms)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.MinPeptideLength, Is.EqualTo(digestionParams.MinPeptideLength)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.MaxPeptideLength, Is.EqualTo(digestionParams.MaxPeptideLength)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.Protease.Name, Is.EqualTo(digestionParams.Protease.Name)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.GeneratehUnlabeledProteinsForSilac, Is.EqualTo(digestionParams.GeneratehUnlabeledProteinsForSilac)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.KeepNGlycopeptide, Is.EqualTo(digestionParams.KeepNGlycopeptide)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.KeepOGlycopeptide, Is.EqualTo(digestionParams.KeepOGlycopeptide)); + + File.Delete(filePath); + } } } \ No newline at end of file From ff98c7736b82c92baad812ef38e552764997f090 Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 18 Jan 2024 10:45:55 -0600 Subject: [PATCH 07/39] ope. Switched to proper version of mzLib --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index 85646b9f0..ebe4a9739 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 0f22bcc70..f73bd152a 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 29014e0f7..99be99737 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index 5f600feb4..fdb61d2d4 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 68e09f204..889bb446a 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 49ca2eb5b..ebf27cde9 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From bd1b1e9c76c124dfaded5c259c6665d7e7d0e08f Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 18 Jan 2024 15:16:59 -0600 Subject: [PATCH 08/39] Generalized Spectral Match --- MetaMorpheus/CMD/CMD.csproj | 2 +- .../Calibration/DataPointAcquisitionEngine.cs | 14 +- .../Calibration/DataPointAquisitionResults.cs | 6 +- .../Calibration/LabeledDataPoint.cs | 4 +- .../ClassicSearch/ClassicSearchEngine.cs | 8 +- .../ClassicSearch/MiniClassicSearchEngine.cs | 17 +- .../CrosslinkSearch/CrosslinkSearchEngine.cs | 6 +- .../CrosslinkSearch/CrosslinkSpectralMatch.cs | 56 +- .../CrosslinkSearch/CrosslinkedPeptides.cs | 8 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- .../FdrAnalysis/FdrAnalysisEngine.cs | 36 +- .../FdrAnalysis/PEPValueAnalysisGeneric.cs | 126 +++-- .../EngineLayer/GlycoSearch/GlycoPeptides.cs | 12 +- .../GlycoSearch/GlycoSearchEngine.cs | 4 +- .../GlycoSearch/GlycoSpectralMatch.cs | 22 +- MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs | 15 +- .../EngineLayer/HistogramAnalysis/Bin.cs | 14 +- .../HistogramAnalysis/BinTreeStructure.cs | 8 +- .../Localization/LocalizationEngine.cs | 13 +- .../ModernSearch/ModernSearchEngine.cs | 12 +- .../ModificationAnalysisEngine.cs | 32 +- .../NonSpecificEnzymeSearchEngine.cs | 72 +-- .../EngineLayer/PeptideSpectralMatch.cs | 496 ++---------------- .../ProteinParsimony/ParsimonySequence.cs | 5 +- .../ProteinParsimony/ProteinGroup.cs | 26 +- .../ProteinParsimonyEngine.cs | 67 +-- .../ProteinScoringAndFdrEngine.cs | 17 +- .../EngineLayer/PsmTsv/PsmTsvReader.cs | 2 +- .../EngineLayer/PsmTsv/PsmTsvWriter.cs | 71 +-- .../EngineLayer/Silac/SilacConversions.cs | 29 +- .../SpectralLibrarySearchFunction.cs | 11 +- MetaMorpheus/EngineLayer/SpectralMatch.cs | 496 ++++++++++++++++++ MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- .../CalibrationTask/CalibrationTask.cs | 16 +- MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs | 8 +- .../GlycoSearchTask/GlycoProteinParsimony.cs | 8 +- .../PostGlycoSearchAnalysisTask.cs | 30 +- .../MbrAnalysis/SpectralRecoveryPSM.cs | 12 +- .../MbrAnalysis/SpectralRecoveryRunner.cs | 31 +- MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 4 +- MetaMorpheus/TaskLayer/PepXMLWriter.cs | 14 +- .../TaskLayer/SearchTask/MzIdentMLWriter.cs | 26 +- .../PostSearchAnalysisParameters.cs | 2 +- .../SearchTask/PostSearchAnalysisTask.cs | 123 +++-- .../TaskLayer/SearchTask/SearchTask.cs | 27 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- .../XLSearchTask/PostXLSearchAnalysisTask.cs | 10 +- .../TaskLayer/XLSearchTask/WriteFile.cs | 48 +- .../TaskLayer/XLSearchTask/XLSearchTask.cs | 4 +- MetaMorpheus/Test/AddCompIonsTest.cs | 18 +- MetaMorpheus/Test/AmbiguityTest.cs | 12 +- MetaMorpheus/Test/AnalysisEngineTest.cs | 10 +- MetaMorpheus/Test/CoIsolationTests.cs | 2 +- MetaMorpheus/Test/EventArgsTest.cs | 4 +- MetaMorpheus/Test/FdrTest.cs | 117 +++-- MetaMorpheus/Test/GPTMDengineTest.cs | 16 +- MetaMorpheus/Test/LocalizationTest.cs | 4 +- MetaMorpheus/Test/MatchIonsOfAllCharges.cs | 22 +- MetaMorpheus/Test/ModificationAnalysisTest.cs | 8 +- .../Test/MultiProteaseParsimonyTest.cs | 78 +-- MetaMorpheus/Test/MyPeptideTest.cs | 10 +- MetaMorpheus/Test/PsmTsvWriterTests.cs | 2 +- MetaMorpheus/Test/RobTest.cs | 8 +- MetaMorpheus/Test/SearchEngineTests.cs | 68 +-- MetaMorpheus/Test/SearchTaskTest.cs | 6 +- MetaMorpheus/Test/SeqCoverageTest.cs | 4 +- .../Test/SpectralLibraryReaderTest.cs | 4 +- MetaMorpheus/Test/SpectralRecoveryTest.cs | 19 +- MetaMorpheus/Test/StefanParsimonyTest.cs | 24 +- MetaMorpheus/Test/Test.csproj | 2 +- MetaMorpheus/Test/TestPsm.cs | 81 +-- MetaMorpheus/Test/TestTopDown.cs | 4 +- MetaMorpheus/Test/XLTest.cs | 22 +- MetaMorpheus/Test/gptmdPrunedBdTests.cs | 4 +- 75 files changed, 1369 insertions(+), 1258 deletions(-) create mode 100644 MetaMorpheus/EngineLayer/SpectralMatch.cs diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index ebe4a9739..bd06f28ad 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/Calibration/DataPointAcquisitionEngine.cs b/MetaMorpheus/EngineLayer/Calibration/DataPointAcquisitionEngine.cs index e3b7c2d0f..021b1a86e 100644 --- a/MetaMorpheus/EngineLayer/Calibration/DataPointAcquisitionEngine.cs +++ b/MetaMorpheus/EngineLayer/Calibration/DataPointAcquisitionEngine.cs @@ -14,7 +14,7 @@ public class DataPointAcquisitionEngine : MetaMorpheusEngine { private const double FineResolutionForIsotopeDistCalculation = 0.1; - private readonly List GoodIdentifications; + private readonly List GoodIdentifications; private readonly List GoodScans; private readonly MsDataFile MyMsDataFile; private readonly Tolerance PrecursorMassTolerance; @@ -22,7 +22,7 @@ public class DataPointAcquisitionEngine : MetaMorpheusEngine private readonly int MinMS1isotopicPeaksNeededForConfirmedIdentification; public DataPointAcquisitionEngine( - List goodIdentifications, + List goodIdentifications, List goodScans, MsDataFile myMsDataFile, Tolerance precursorMassTolerance, @@ -65,16 +65,16 @@ protected override MetaMorpheusEngineResults RunSpecific() // Stop loop if canceled if (GlobalVariables.StopLoops) { return; } - PeptideSpectralMatch identification = GoodIdentifications[matchIndex]; + SpectralMatch identification = GoodIdentifications[matchIndex]; // Each identification has an MS2 spectrum attached to it. int ms2scanNumber = identification.ScanNumber; int peptideCharge = identification.ScanPrecursorCharge; //skip if ambiguous - if (identification.FullSequence == null || identification.BestMatchingPeptides.Any(p => p.Peptide.AllModsOneIsNterminus.Any(m => m.Value.ChemicalFormula == null))) + if (identification.FullSequence == null || identification.BestMatchingBioPolymersWithSetMods.Any(p => p.Peptide.AllModsOneIsNterminus.Any(m => m.Value.ChemicalFormula == null))) continue; - var representativeSinglePeptide = identification.BestMatchingPeptides.First().Peptide; + var representativeSinglePeptide = identification.BestMatchingBioPolymersWithSetMods.First().Peptide; // Get the peptide, don't forget to add the modifications!!!! var SequenceWithChemicalFormulas = representativeSinglePeptide.SequenceWithChemicalFormulas; @@ -126,7 +126,7 @@ protected override MetaMorpheusEngineResults RunSpecific() ); } - private (List, int, int) SearchMS1Spectra(double[] theoreticalMasses, double[] theoreticalIntensities, int ms2spectrumIndex, int direction, int peptideCharge, PeptideSpectralMatch identification) + private (List, int, int) SearchMS1Spectra(double[] theoreticalMasses, double[] theoreticalIntensities, int ms2spectrumIndex, int direction, int peptideCharge, SpectralMatch identification) { List result = new List(); int numMs1MassChargeCombinationsConsidered = 0; @@ -220,7 +220,7 @@ protected override MetaMorpheusEngineResults RunSpecific() return (result, numMs1MassChargeCombinationsConsidered, numMs1MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks); } - private static List SearchMS2Spectrum(Ms2ScanWithSpecificMass ms2DataScan, PeptideSpectralMatch identification, Tolerance ms2Tolerance) + private static List SearchMS2Spectrum(Ms2ScanWithSpecificMass ms2DataScan, SpectralMatch identification, Tolerance ms2Tolerance) { List result = new List(); diff --git a/MetaMorpheus/EngineLayer/Calibration/DataPointAquisitionResults.cs b/MetaMorpheus/EngineLayer/Calibration/DataPointAquisitionResults.cs index 449f2456e..8aaf2f9fc 100644 --- a/MetaMorpheus/EngineLayer/Calibration/DataPointAquisitionResults.cs +++ b/MetaMorpheus/EngineLayer/Calibration/DataPointAquisitionResults.cs @@ -11,7 +11,7 @@ public class DataPointAquisitionResults : MetaMorpheusEngineResults { public DataPointAquisitionResults( MetaMorpheusEngine dataPointAcquisitionEngine, - List psms, + List psms, List ms1List, List ms2List, int numMs1MassChargeCombinationsConsidered, @@ -41,7 +41,7 @@ public DataPointAquisitionResults( NumMs2MassChargeCombinationsConsidered = numMs2MassChargeCombinationsConsidered; NumMs2MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks = numMs2MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks; - var precursorErrors = psms.Select(p => (p.ScanPrecursorMass - p.PeptideMonisotopicMass.Value) / p.PeptideMonisotopicMass.Value * 1e6).ToList(); + var precursorErrors = psms.Select(p => (p.ScanPrecursorMass - p.BioPolymerWithSetModsMonoisotopicMass.Value) / p.BioPolymerWithSetModsMonoisotopicMass.Value * 1e6).ToList(); PsmPrecursorIqrPpmError = precursorErrors.InterquartileRange(); PsmPrecursorMedianPpmError = precursorErrors.Median(); @@ -67,7 +67,7 @@ public DataPointAquisitionResults( public readonly double PsmProductMedianPpmError; public readonly double PsmPrecursorIqrPpmError; public readonly double PsmProductIqrPpmError; - public readonly List Psms; + public readonly List Psms; public int Count { get { return Ms1List.Count + Ms2List.Count; } } diff --git a/MetaMorpheus/EngineLayer/Calibration/LabeledDataPoint.cs b/MetaMorpheus/EngineLayer/Calibration/LabeledDataPoint.cs index 4c8b29118..c7c14ac2d 100644 --- a/MetaMorpheus/EngineLayer/Calibration/LabeledDataPoint.cs +++ b/MetaMorpheus/EngineLayer/Calibration/LabeledDataPoint.cs @@ -9,9 +9,9 @@ public class LabeledDataPoint public readonly double LogIntensity; public readonly double TheoreticalMz; public readonly double RelativeMzError; - public readonly PeptideSpectralMatch Identification; + public readonly SpectralMatch Identification; - public LabeledDataPoint(double experimentalMz, int scanNumber, double logTotalIonCurrent, double logInjectionTime, double logIntensity, double theoreticalMz, PeptideSpectralMatch identification) + public LabeledDataPoint(double experimentalMz, int scanNumber, double logTotalIonCurrent, double logInjectionTime, double logIntensity, double theoreticalMz, SpectralMatch identification) { this.ExperimentalMz = experimentalMz; this.ScanNumber = scanNumber; diff --git a/MetaMorpheus/EngineLayer/ClassicSearch/ClassicSearchEngine.cs b/MetaMorpheus/EngineLayer/ClassicSearch/ClassicSearchEngine.cs index cf6a78717..ee15ab360 100644 --- a/MetaMorpheus/EngineLayer/ClassicSearch/ClassicSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/ClassicSearch/ClassicSearchEngine.cs @@ -20,12 +20,12 @@ public class ClassicSearchEngine : MetaMorpheusEngine private readonly List VariableModifications; private readonly List SilacLabels; private readonly (SilacLabel StartLabel, SilacLabel EndLabel)? TurnoverLabels; - private readonly PeptideSpectralMatch[] PeptideSpectralMatches; + private readonly SpectralMatch[] PeptideSpectralMatches; private readonly Ms2ScanWithSpecificMass[] ArrayOfSortedMS2Scans; private readonly double[] MyScanPrecursorMasses; private readonly bool WriteSpectralLibrary; - public ClassicSearchEngine(PeptideSpectralMatch[] globalPsms, Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans, + public ClassicSearchEngine(SpectralMatch[] globalPsms, Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans, List variableModifications, List fixedModifications, List silacLabels, SilacLabel startLabel, SilacLabel endLabel, List proteinList, MassDiffAcceptor searchMode, CommonParameters commonParameters, List<(string FileName, CommonParameters Parameters)> fileSpecificParameters, SpectralLibrary spectralLibrary, List nestedIds, bool writeSpectralLibrary) @@ -163,7 +163,7 @@ protected override MetaMorpheusEngineResults RunSpecific() }); } - foreach (PeptideSpectralMatch psm in PeptideSpectralMatches.Where(p => p != null)) + foreach (SpectralMatch psm in PeptideSpectralMatches.Where(p => p != null)) { psm.ResolveAllAmbiguities(); } @@ -201,7 +201,7 @@ private void AddPeptideCandidateToPsm(ScanWithIndexAndNotchInfo scan, object[] m // valid hit (met the cutoff score); lock the scan to prevent other threads from accessing it lock (myLocks[scan.ScanIndex]) { - bool scoreImprovement = PeptideSpectralMatches[scan.ScanIndex] == null || (thisScore - PeptideSpectralMatches[scan.ScanIndex].RunnerUpScore) > -PeptideSpectralMatch.ToleranceForScoreDifferentiation; + bool scoreImprovement = PeptideSpectralMatches[scan.ScanIndex] == null || (thisScore - PeptideSpectralMatches[scan.ScanIndex].RunnerUpScore) > -SpectralMatch.ToleranceForScoreDifferentiation; if (scoreImprovement) { diff --git a/MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs b/MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs index 6a3faca2d..854609313 100644 --- a/MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs @@ -1,6 +1,7 @@ using MassSpectrometry; using MassSpectrometry.MzSpectra; using MzLibUtil; +using Omics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; @@ -42,7 +43,7 @@ public MiniClassicSearchEngine( /// Ms2 scans in window are searched for matches to this donor peptide /// The center of the 2 minute window where the search occurs /// - public IEnumerable SearchAroundPeak(PeptideWithSetModifications donorPwsm, double peakApexRT) + public IEnumerable SearchAroundPeak(IBioPolymerWithSetMods donorPwsm, double peakApexRT) { var targetFragmentsForEachDissociationType = new Dictionary>(); @@ -66,7 +67,7 @@ public IEnumerable SearchAroundPeak(PeptideWithSetModifica return null; } - List acceptablePsms = new(); + List acceptablePsms = new(); foreach (ScanWithIndexAndNotchInfo scan in acceptableScans) { var dissociationType = FileSpecificParameters.DissociationType == DissociationType.Autodetect ? @@ -95,8 +96,8 @@ public IEnumerable SearchAroundPeak(PeptideWithSetModifica acceptablePsms.Add(new PeptideSpectralMatch(donorPwsm, scan.Notch, thisScore, scan.ScanIndex, scan.TheScan, FileSpecificParameters, matchedIons, 0)); } - IEnumerable matchedSpectra = acceptablePsms.Where(p => p != null); - foreach (PeptideSpectralMatch psm in matchedSpectra) + IEnumerable matchedSpectra = acceptablePsms.Where(p => p != null); + foreach (SpectralMatch psm in matchedSpectra) { psm.ResolveAllAmbiguities(); } @@ -106,7 +107,7 @@ public IEnumerable SearchAroundPeak(PeptideWithSetModifica return matchedSpectra; } - public static void CalculateSpectralAngles(SpectralLibrary spectralLibrary, PeptideSpectralMatch[] psms, + public static void CalculateSpectralAngles(SpectralLibrary spectralLibrary, SpectralMatch[] psms, Ms2ScanWithSpecificMass[] arrayOfSortedMs2Scans, CommonParameters commonParameters, CommonParameters fileSpecificParameters) { if (spectralLibrary != null) @@ -128,12 +129,12 @@ public static void CalculateSpectralAngles(SpectralLibrary spectralLibrary, Pept if (psms[i] != null) { Ms2ScanWithSpecificMass scan = arrayOfSortedMs2Scans[psms[i].ScanIndex]; - List<(int, PeptideWithSetModifications)> pwsms = new(); + List<(int, IBioPolymerWithSetMods)> pwsms = new(); List pwsmSpectralAngles = new(); - foreach (var (Notch, Peptide) in psms[i].BestMatchingPeptides) + foreach (var (Notch, Peptide) in psms[i].BestMatchingBioPolymersWithSetMods) { //if peptide is target, directly look for the target's spectrum in the spectral library - if (!Peptide.Protein.IsDecoy && spectralLibrary.TryGetSpectrum(Peptide.FullSequence, scan.PrecursorCharge, out var librarySpectrum)) + if (!Peptide.Parent.IsDecoy && spectralLibrary.TryGetSpectrum(Peptide.FullSequence, scan.PrecursorCharge, out var librarySpectrum)) { SpectralSimilarity s = new SpectralSimilarity(scan.TheScan.MassSpectrum, librarySpectrum.XArray, librarySpectrum.YArray, SpectralSimilarity.SpectrumNormalizationScheme.squareRootSpectrumSum, fileSpecificParameters.ProductMassTolerance.Value, false); diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs index 48ea48c44..e9cda06d3 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs @@ -734,7 +734,7 @@ private List ScoreChildScan(Ms2ScanWithSpecificMass parentSc } var peptideWithMod = new PeptideWithSetModifications(mainPeptide.Protein, mainPeptide.DigestionParams, - mainPeptide.OneBasedStartResidueInProtein, mainPeptide.OneBasedEndResidueInProtein, + mainPeptide.OneBasedStartResidue, mainPeptide.OneBasedEndResidue, mainPeptide.CleavageSpecificityForFdrCategory, mainPeptide.PeptideDescription, mainPeptide.MissedCleavages, mod, mainPeptide.NumFixedMods); @@ -784,8 +784,8 @@ private CrosslinkSpectralMatch LocalizeDeadEndSite(PeptideWithSetModifications o mods.Add(location + 1, deadEndMod); - var localizedPeptide = new PeptideWithSetModifications(originalPeptide.Protein, originalPeptide.DigestionParams, originalPeptide.OneBasedStartResidueInProtein, - originalPeptide.OneBasedEndResidueInProtein, originalPeptide.CleavageSpecificityForFdrCategory, originalPeptide.PeptideDescription, originalPeptide.MissedCleavages, mods, originalPeptide.NumFixedMods); + var localizedPeptide = new PeptideWithSetModifications(originalPeptide.Protein, originalPeptide.DigestionParams, originalPeptide.OneBasedStartResidue, + originalPeptide.OneBasedEndResidue, originalPeptide.CleavageSpecificityForFdrCategory, originalPeptide.PeptideDescription, originalPeptide.MissedCleavages, mods, originalPeptide.NumFixedMods); localizedPeptide.Fragment(commonParameters.DissociationType, FragmentationTerminus.Both, products); var matchedFragmentIons = MatchFragmentIons(theScan, products, commonParameters); diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSpectralMatch.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSpectralMatch.cs index 2a65083f2..4bdf2522c 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSpectralMatch.cs @@ -23,9 +23,9 @@ public CrosslinkSpectralMatch( { //The XLTotalScore is set here because some CSMs are not crosslinks and we need this score to be non-zero. XLTotalScore = score; - _BestMatchingPeptides.Clear(); + _BestMatchingBioPolymersWithSetMods.Clear(); - _BestMatchingPeptides.Add((0, theBestPeptide)); + _BestMatchingBioPolymersWithSetMods.Add((0, theBestPeptide)); } @@ -95,40 +95,40 @@ public void ResolveProteinPosAmbiguitiesForXl() if (CrossType == PsmCrossType.Cross) { // alpha peptide crosslink residue in the protein - XlProteinPos = OneBasedStartResidueInProtein == null ? (int?)null : OneBasedStartResidueInProtein.Value + LinkPositions[0] - 1; + XlProteinPos = OneBasedStartResidue == null ? (int?)null : OneBasedStartResidue.Value + LinkPositions[0] - 1; // beta crosslink residue in protein - BetaPeptide.XlProteinPos = BetaPeptide.OneBasedStartResidueInProtein == null ? (int?)null : BetaPeptide.OneBasedStartResidueInProtein.Value + BetaPeptide.LinkPositions[0] - 1; + BetaPeptide.XlProteinPos = BetaPeptide.OneBasedStartResidue == null ? (int?)null : BetaPeptide.OneBasedStartResidue.Value + BetaPeptide.LinkPositions[0] - 1; } else if (CrossType == PsmCrossType.DeadEnd || CrossType == PsmCrossType.DeadEndH2O || CrossType == PsmCrossType.DeadEndNH2 || CrossType == PsmCrossType.DeadEndTris) { - XlProteinPos = OneBasedStartResidueInProtein == null ? (int?)null : OneBasedStartResidueInProtein.Value + LinkPositions[0] - 1; + XlProteinPos = OneBasedStartResidue == null ? (int?)null : OneBasedStartResidue.Value + LinkPositions[0] - 1; } else if (CrossType == PsmCrossType.Loop) { - XlProteinPos = OneBasedStartResidueInProtein == null ? (int?)null : OneBasedStartResidueInProtein.Value + LinkPositions[0] - 1; + XlProteinPos = OneBasedStartResidue == null ? (int?)null : OneBasedStartResidue.Value + LinkPositions[0] - 1; - XlProteinPosLoop = OneBasedStartResidueInProtein == null ? (int?)null : OneBasedStartResidueInProtein.Value + LinkPositions[1] - 1; + XlProteinPosLoop = OneBasedStartResidue == null ? (int?)null : OneBasedStartResidue.Value + LinkPositions[1] - 1; } } public static bool IsIntraCsm(CrosslinkSpectralMatch csm) { //The pair "ProteinA and Decoy_ProteinA" is count for intra-crosslink. - if (csm.ProteinAccession != null && csm.BetaPeptide.ProteinAccession != null) + if (csm.Accession != null && csm.BetaPeptide.Accession != null) { - if (csm.ProteinAccession == csm.BetaPeptide.ProteinAccession || - csm.ProteinAccession == "DECOY_"+ csm.BetaPeptide.ProteinAccession || - csm.BetaPeptide.ProteinAccession == "DECOY_" + csm.ProteinAccession) + if (csm.Accession == csm.BetaPeptide.Accession || + csm.Accession == "DECOY_"+ csm.BetaPeptide.Accession || + csm.BetaPeptide.Accession == "DECOY_" + csm.Accession) { return true; } } - if (csm.ProteinAccession == null) + if (csm.Accession == null) { - var alphaProteins = csm.BestMatchingPeptides.Select(p => p.Peptide.Protein.Accession).ToList(); - var betaProteins = csm.BetaPeptide.BestMatchingPeptides.Select(p => p.Peptide.Protein.Accession).ToList(); + var alphaProteins = csm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide.Parent.Accession).ToList(); + var betaProteins = csm.BetaPeptide.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide.Parent.Accession).ToList(); foreach (var alpha in alphaProteins) { @@ -169,20 +169,20 @@ public static void ResolveProteinPosAmbiguitiesForXl(CrosslinkSpectralMatch csm) if (csm.CrossType == PsmCrossType.Cross || csm.CrossType == PsmCrossType.Intra || csm.CrossType == PsmCrossType.Inter) { // alpha peptide crosslink residue in the protein - csm.XlProteinPos = csm.OneBasedStartResidueInProtein == null ? (int?)null : csm.OneBasedStartResidueInProtein.Value + csm.LinkPositions[0] - 1; + csm.XlProteinPos = csm.OneBasedStartResidue == null ? (int?)null : csm.OneBasedStartResidue.Value + csm.LinkPositions[0] - 1; // beta crosslink residue in protein - csm.BetaPeptide.XlProteinPos = csm.BetaPeptide.OneBasedStartResidueInProtein == null ? (int?)null : csm.BetaPeptide.OneBasedStartResidueInProtein.Value + csm.BetaPeptide.LinkPositions[0] - 1; + csm.BetaPeptide.XlProteinPos = csm.BetaPeptide.OneBasedStartResidue == null ? (int?)null : csm.BetaPeptide.OneBasedStartResidue.Value + csm.BetaPeptide.LinkPositions[0] - 1; } else if (csm.CrossType == PsmCrossType.DeadEnd || csm.CrossType == PsmCrossType.DeadEndH2O || csm.CrossType == PsmCrossType.DeadEndNH2 || csm.CrossType == PsmCrossType.DeadEndTris) { - csm.XlProteinPos = csm.OneBasedStartResidueInProtein == null ? (int?)null : csm.OneBasedStartResidueInProtein.Value + csm.LinkPositions[0] - 1; + csm.XlProteinPos = csm.OneBasedStartResidue == null ? (int?)null : csm.OneBasedStartResidue.Value + csm.LinkPositions[0] - 1; } else if (csm.CrossType == PsmCrossType.Loop) { - csm.XlProteinPos = csm.OneBasedStartResidueInProtein == null ? (int?)null : csm.OneBasedStartResidueInProtein.Value + csm.LinkPositions[0] - 1; + csm.XlProteinPos = csm.OneBasedStartResidue == null ? (int?)null : csm.OneBasedStartResidue.Value + csm.LinkPositions[0] - 1; - csm.XlProteinPosLoop = csm.OneBasedStartResidueInProtein == null ? (int?)null : csm.OneBasedStartResidueInProtein.Value + csm.LinkPositions[1] - 1; + csm.XlProteinPosLoop = csm.OneBasedStartResidue == null ? (int?)null : csm.OneBasedStartResidue.Value + csm.LinkPositions[1] - 1; } } @@ -193,8 +193,8 @@ public static List GetPossibleCrosslinkerModSites(char[] crosslinkerModSite bool wildcard = crosslinkerModSites.Any(p => p == 'X'); var range = Enumerable.Range(0, peptide.BaseSequence.Length); - if (!CrosslinkAtCleavageSite && peptide.OneBasedEndResidueInProtein != peptide.Protein.Length - && !peptide.Protein.ProteolysisProducts.Any(x => x.OneBasedEndPosition == peptide.OneBasedEndResidueInProtein)) + if (!CrosslinkAtCleavageSite && peptide.OneBasedEndResidue != peptide.Protein.Length + && !peptide.Protein.ProteolysisProducts.Any(x => x.OneBasedEndPosition == peptide.OneBasedEndResidue)) { //The C termial cannot be crosslinked and cleaved. range = Enumerable.Range(0, peptide.BaseSequence.Length - 1); @@ -373,13 +373,13 @@ public override string ToString() } sb.Append("\t"); //Intentionally left empty for readability in the tsv file. - List pepsWithMods = BestMatchingPeptides.Select(p => p.Peptide).ToList(); - var proteinAccessionString = ProteinAccession ?? PsmTsvWriter.Resolve(pepsWithMods.Select(b => b.Protein.Accession), FullSequence).ResolvedString; + List pepsWithMods = BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide as PeptideWithSetModifications).ToList(); + var proteinAccessionString = Accession ?? PsmTsvWriter.Resolve(pepsWithMods.Select(b => b.Protein.Accession), FullSequence).ResolvedString; sb.Append(proteinAccessionString + "\t"); sb.Append(XlProteinPos + (XlProteinPosLoop.HasValue ? "~" + XlProteinPosLoop.Value : null) + "\t"); sb.Append(BaseSequence + "\t"); sb.Append(FullSequence + position + "\t"); - sb.Append((PeptideMonisotopicMass.HasValue ? PeptideMonisotopicMass.Value.ToString() : "---")); + sb.Append((BioPolymerWithSetModsMonoisotopicMass.HasValue ? BioPolymerWithSetModsMonoisotopicMass.Value.ToString() : "---")); sb.Append("\t"); sb.Append(Score + "\t"); @@ -422,13 +422,13 @@ public override string ToString() if (BetaPeptide != null) { sb.Append("\t"); //Intentionally left empty for readability in the tsv file. - List betaPepsWithMods = BetaPeptide.BestMatchingPeptides.Select(p => p.Peptide).ToList(); - var betaProteinAccessionString = BetaPeptide.ProteinAccession ?? PsmTsvWriter.Resolve(betaPepsWithMods.Select(b => b.Protein.Accession), FullSequence).ResolvedString; + List betaPepsWithMods = BetaPeptide.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide as PeptideWithSetModifications).ToList(); + var betaProteinAccessionString = BetaPeptide.Accession ?? PsmTsvWriter.Resolve(betaPepsWithMods.Select(b => b.Protein.Accession), FullSequence).ResolvedString; sb.Append(betaProteinAccessionString + "\t"); sb.Append(BetaPeptide.XlProteinPos + "\t"); sb.Append(BetaPeptide.BaseSequence + "\t"); sb.Append(BetaPeptide.FullSequence + "(" + BetaPeptide.LinkPositions[0].ToString() + ")" + "\t"); - sb.Append(BetaPeptide.PeptideMonisotopicMass.ToString() + "\t"); + sb.Append(BetaPeptide.BioPolymerWithSetModsMonoisotopicMass.ToString() + "\t"); sb.Append(BetaPeptide.Score + "\t"); if (BetaPeptide.ChildMatchedFragmentIons == null) @@ -469,7 +469,7 @@ public override string ToString() sb.Append(XLTotalScore + "\t"); // mass of crosslinker - sb.Append(((PeptideMonisotopicMass.HasValue) ? (ScanPrecursorMass - BetaPeptide.PeptideMonisotopicMass - PeptideMonisotopicMass.Value).ToString() : "---")); sb.Append("\t"); + sb.Append(((BioPolymerWithSetModsMonoisotopicMass.HasValue) ? (ScanPrecursorMass - BetaPeptide.BioPolymerWithSetModsMonoisotopicMass - BioPolymerWithSetModsMonoisotopicMass.Value).ToString() : "---")); sb.Append("\t"); sb.Append(XlRank.ToString() + "\t"); diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkedPeptides.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkedPeptides.cs index ef293057e..01270aec8 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkedPeptides.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkedPeptides.cs @@ -42,8 +42,8 @@ public static IEnumerable>> XlGetTheoreticalFragments(D testMods.Add(mod.Key, mod.Value); } - var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidueInProtein, - peptide.OneBasedEndResidueInProtein, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); + var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidue, + peptide.OneBasedEndResidue, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); testPeptide.Fragment(dissociationType, FragmentationTerminus.Both, fragments); @@ -110,7 +110,7 @@ public static Dictionary, List> XlLoopGetTheoreticalFra modDict.Add(position1 + 1, loopMass); } PeptideWithSetModifications peptideWithLoop = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, - peptide.OneBasedStartResidueInProtein, peptide.OneBasedEndResidueInProtein, peptide.CleavageSpecificityForFdrCategory, + peptide.OneBasedStartResidue, peptide.OneBasedEndResidue, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, modDict, peptide.NumFixedMods); peptideWithLoop.Fragment(dissociationType, FragmentationTerminus.Both, loopProducts); @@ -134,7 +134,7 @@ public static Dictionary, List> XlLoopGetTheoreticalFra modDict.Add(position2 + 1, loopMass); } peptideWithLoop = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, - peptide.OneBasedStartResidueInProtein, peptide.OneBasedEndResidueInProtein, peptide.CleavageSpecificityForFdrCategory, + peptide.OneBasedStartResidue, peptide.OneBasedEndResidue, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, modDict, peptide.NumFixedMods); peptideWithLoop.Fragment(dissociationType, FragmentationTerminus.Both, loopProducts); diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index f73bd152a..566646d8f 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs index 16640d0f0..563d22cf0 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs @@ -10,7 +10,7 @@ namespace EngineLayer.FdrAnalysis { public class FdrAnalysisEngine : MetaMorpheusEngine { - private List AllPsms; + private List AllPsms; private readonly int MassDiffAcceptorNumNotches; private readonly bool UseDeltaScore; private readonly double ScoreCutoff; @@ -18,7 +18,7 @@ public class FdrAnalysisEngine : MetaMorpheusEngine private readonly string OutputFolder; // used for storing PEP training models private readonly bool DoPEP; - public FdrAnalysisEngine(List psms, int massDiffAcceptorNumNotches, CommonParameters commonParameters, + public FdrAnalysisEngine(List psms, int massDiffAcceptorNumNotches, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds, string analysisType = "PSM", bool doPEP = true, string outputFolder = null) : base(commonParameters, fileSpecificParameters, nestedIds) { AllPsms = psms; @@ -60,20 +60,20 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults) { const double qValueCutoff = 0.01; //optimize to get the most PSMs at a 1% FDR - List scoreSorted = psms.OrderByDescending(b => b.Score).ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue).GroupBy(b => new Tuple(b.FullFilePath, b.ScanNumber, b.PeptideMonisotopicMass)).Select(b => b.First()).ToList(); + List scoreSorted = psms.OrderByDescending(b => b.Score).ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue).GroupBy(b => new Tuple(b.FullFilePath, b.ScanNumber, b.BioPolymerWithSetModsMonoisotopicMass)).Select(b => b.First()).ToList(); int ScorePSMs = GetNumPSMsAtqValueCutoff(scoreSorted, qValueCutoff); - scoreSorted = psms.OrderByDescending(b => b.DeltaScore).ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue).GroupBy(b => new Tuple(b.FullFilePath, b.ScanNumber, b.PeptideMonisotopicMass)).Select(b => b.First()).ToList(); + scoreSorted = psms.OrderByDescending(b => b.DeltaScore).ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue).GroupBy(b => new Tuple(b.FullFilePath, b.ScanNumber, b.BioPolymerWithSetModsMonoisotopicMass)).Select(b => b.First()).ToList(); int DeltaScorePSMs = GetNumPSMsAtqValueCutoff(scoreSorted, qValueCutoff); //sort by best method myAnalysisResults.DeltaScoreImprovement = DeltaScorePSMs > ScorePSMs; psms = myAnalysisResults.DeltaScoreImprovement ? - psms.OrderByDescending(b => b.DeltaScore).ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue).ToList() : - psms.OrderByDescending(b => b.Score).ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue).ToList(); + psms.OrderByDescending(b => b.DeltaScore).ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue).ToList() : + psms.OrderByDescending(b => b.Score).ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue).ToList(); } else //sort by score { - psms = psms.OrderByDescending(b => b.Score).ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue).ToList(); + psms = psms.OrderByDescending(b => b.Score).ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue).ToList(); } QValueTraditional(psms); @@ -94,7 +94,7 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults) for (int i = psms.Count - 1; i >= 0; i--) { - PeptideSpectralMatch psm = psms[i]; + SpectralMatch psm = psms[i]; // threshold q-values if (psm.FdrInfo.QValue > qValueThreshold) @@ -124,13 +124,13 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults) } } - private void QValueInverted(List psms) + private void QValueInverted(List psms) { psms.Reverse(); bool first = true; double previousQValue = 1.0; double previousQvalueNotch = 1.0; - foreach (PeptideSpectralMatch psm in psms) + foreach (SpectralMatch psm in psms) { double cumulativeTarget = psm.FdrInfo.CumulativeTarget; double cumulativeDecoy = psm.FdrInfo.CumulativeDecoy; @@ -165,7 +165,7 @@ private void QValueInverted(List psms) psms.Reverse(); //we inverted the psms for this calculation. now we need to put them back into the original order } - private void QValueTraditional(List psms) + private void QValueTraditional(List psms) { double cumulativeTarget = 0; double cumulativeDecoy = 0; @@ -180,7 +180,7 @@ private void QValueTraditional(List psms) // Stop if canceled if (GlobalVariables.StopLoops) { break; } - PeptideSpectralMatch psm = psms[i]; + SpectralMatch psm = psms[i]; int notch = psm.Notch ?? MassDiffAcceptorNumNotches; if (psm.IsDecoy) { @@ -189,10 +189,10 @@ private void QValueTraditional(List psms) // e.g. if the PSM matched to 1 target and 2 decoys, it counts as 2/3 decoy double decoyHits = 0; double totalHits = 0; - var hits = psm.BestMatchingPeptides.GroupBy(p => p.Peptide.FullSequence); + var hits = psm.BestMatchingBioPolymersWithSetMods.GroupBy(p => p.Peptide.FullSequence); foreach (var hit in hits) { - if (hit.First().Peptide.Protein.IsDecoy) + if (hit.First().Peptide.Parent.IsDecoy) { decoyHits++; } @@ -251,7 +251,7 @@ public void Compute_PEPValue(FdrAnalysisResults myAnalysisResults) } } - public static void Compute_PEPValue_Based_QValue(List psms) + public static void Compute_PEPValue_Based_QValue(List psms) { double[] allPEPValues = psms.Select(p => p.FdrInfo.PEP).ToArray(); int[] psmsArrayIndicies = Enumerable.Range(0, psms.Count).ToArray(); @@ -266,11 +266,11 @@ public static void Compute_PEPValue_Based_QValue(List psms } } - private static int GetNumPSMsAtqValueCutoff(List psms, double qValueCutoff) + private static int GetNumPSMsAtqValueCutoff(List psms, double qValueCutoff) { int cumulative_target = 0; int cumulative_decoy = 0; - foreach (PeptideSpectralMatch psm in psms) + foreach (SpectralMatch psm in psms) { if (psm.IsDecoy) { @@ -306,7 +306,7 @@ public void CountPsm() } } - foreach (PeptideSpectralMatch psm in allUnambiguousPsms) + foreach (SpectralMatch psm in allUnambiguousPsms) { if (sequenceToPsmCount.ContainsKey(psm.FullSequence)) { diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs index 1a1ccc6af..9969e01ed 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs @@ -16,6 +16,7 @@ using System.Text; using System.Threading.Tasks; using Omics.Modifications; +using Omics; namespace EngineLayer { @@ -26,13 +27,13 @@ public static class PEP_Analysis_Cross_Validation private static Dictionary>> fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified = new Dictionary>>(); private static Dictionary>> fileSpecificTimeDependantHydrophobicityAverageAndDeviation_CZE = new Dictionary>>(); - public static string ComputePEPValuesForAllPSMsGeneric(List psms, string searchType, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, string outputFolder) + public static string ComputePEPValuesForAllPSMsGeneric(List psms, string searchType, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, string outputFolder) { string[] trainingVariables = PsmData.trainingInfos[searchType]; //ensure that the order is always stable. psms = psms.OrderByDescending(p => p.Score).ThenBy(p => p.FdrInfo.QValue). - ThenBy(p => p.FullFilePath).ThenBy(x => x.ScanNumber).ThenBy(p => p.FullSequence).ThenBy(p => p.ProteinAccession).ToList(); + ThenBy(p => p.FullFilePath).ThenBy(x => x.ScanNumber).ThenBy(p => p.FullSequence).ThenBy(p => p.Accession).ToList(); //These two dictionaries contain the average and standard deviations of hydrophobicitys measured in 1 minute increments accross each raw //file separately. An individully measured hydrobophicty calculated for a specific PSM sequence is compared to these values by computing @@ -175,7 +176,7 @@ public static string AggregateMetricsForOutput(List psms, List psmIndices, MLContext mLContext, TransformerChain>> trainedModel, string searchType, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, Dictionary sequenceToPsmCount, Dictionary fileSpecificMedianFragmentMassErrors, int chargeStateMode, string outputFolder) + public static int Compute_PSM_PEP(List psms, List psmIndices, MLContext mLContext, TransformerChain>> trainedModel, string searchType, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, Dictionary sequenceToPsmCount, Dictionary fileSpecificMedianFragmentMassErrors, int chargeStateMode, string outputFolder) { int maxThreads = fileSpecificParameters.FirstOrDefault().fileSpecificParameters.MaxThreadsToUsePerFile; object lockObject = new object(); @@ -212,7 +213,7 @@ public static int Compute_PSM_PEP(List psms, List psm for (int i = range.Item1; i < range.Item2; i++) { - PeptideSpectralMatch psm = psms[psmIndices[i]]; + SpectralMatch psm = psms[psmIndices[i]]; if (psm != null) { @@ -222,13 +223,13 @@ public static int Compute_PSM_PEP(List psms, List psm //Here we compute the pepvalue predection for each ambiguous peptide in a PSM. Ambiguous peptides with lower pepvalue predictions are removed from the PSM. List allBmpNotches = new List(); - List allBmpPeptides = new List(); + List allBmpPeptides = new List(); - foreach (var (Notch, Peptide) in psm.BestMatchingPeptides) + foreach (var (Notch, Peptide) in psm.BestMatchingBioPolymersWithSetMods) { allBmpNotches.Add(Notch); allBmpPeptides.Add(Peptide); - PsmData pd = CreateOnePsmDataEntry(searchType, fileSpecificParameters, psm, sequenceToPsmCount, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified, fileSpecificMedianFragmentMassErrors, chargeStateMode, Peptide, Notch, !Peptide.Protein.IsDecoy); + PsmData pd = CreateOnePsmDataEntry(searchType, fileSpecificParameters, psm, sequenceToPsmCount, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified, fileSpecificMedianFragmentMassErrors, chargeStateMode, Peptide, Notch, !Peptide.Parent.IsDecoy); var pepValuePrediction = threadPredictionEngine.Predict(pd); pepValuePredictions.Add(pepValuePrediction.Probability); //A score is available using the variable pepvaluePrediction.Score @@ -251,7 +252,7 @@ public static int Compute_PSM_PEP(List psms, List psm //we add the indexes of the targets and decoys to the groups separately in the hope that we'll get at least one target and one decoy in each group. //then training can possibly be more successful. - public static List[] Get_PSM_Group_Indices(List psms, int numGroups) + public static List[] Get_PSM_Group_Indices(List psms, int numGroups) { List[] groupsOfIndicies = new List[numGroups]; for (int i = 0; i < numGroups; i++) @@ -303,7 +304,7 @@ public static List[] Get_PSM_Group_Indices(List psms, return groupsOfIndicies; } - public static void RemoveBestMatchingPeptidesWithLowPEP(PeptideSpectralMatch psm, List indiciesOfPeptidesToRemove, List notches, List pwsmList, List pepValuePredictions, ref int ambiguousPeptidesRemovedCount) + public static void RemoveBestMatchingPeptidesWithLowPEP(SpectralMatch psm, List indiciesOfPeptidesToRemove, List notches, List pwsmList, List pepValuePredictions, ref int ambiguousPeptidesRemovedCount) { foreach (int i in indiciesOfPeptidesToRemove) { @@ -314,7 +315,7 @@ public static void RemoveBestMatchingPeptidesWithLowPEP(PeptideSpectralMatch psm } /// - /// Given a set of PEP values, this method will find the indicies of BestMatchingPeptides that are not within the required tolerance + /// Given a set of PEP values, this method will find the indicies of BestMatchingBioPolymersWithSetMods that are not within the required tolerance /// This method will also remove the low scoring predictions from the set. /// public static void GetIndiciesOfPeptidesToRemove(List indiciesOfPeptidesToRemove, List pepValuePredictions) @@ -337,12 +338,12 @@ public static void GetIndiciesOfPeptidesToRemove(List indiciesOfPeptidesToR /// /// Here we're getting the most common charge state for precursors that are Targets with q<=0.01. - public static int GetChargeStateMode(List psms) + public static int GetChargeStateMode(List psms) { return psms.Where(p => p.IsDecoy != true && p.FdrInfo.QValue <= 0.01).Select(p => p.ScanPrecursorCharge).GroupBy(n => n).OrderByDescending(g => g.Count()).Select(g => g.Key).FirstOrDefault(); } - public static Dictionary>> ComputeHydrophobicityValues(List psms, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, bool computeHydrophobicitiesforModifiedPeptides) + public static Dictionary>> ComputeHydrophobicityValues(List psms, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, bool computeHydrophobicitiesforModifiedPeptides) { SSRCalc3 calc = new SSRCalc3("SSRCalc 3.0 (300A)", SSRCalc3.Column.A300); @@ -358,10 +359,10 @@ public static Dictionary>> Compute Dictionary> hydrophobicities = new Dictionary>(); Dictionary> averagesCommaStandardDeviations = new Dictionary>(); - foreach (PeptideSpectralMatch psm in psms.Where(f => (f.FullFilePath == null || Path.GetFileName(f.FullFilePath) == filename) && f.FdrInfo.QValue <= 0.01 && !f.IsDecoy)) + foreach (SpectralMatch psm in psms.Where(f => (f.FullFilePath == null || Path.GetFileName(f.FullFilePath) == filename) && f.FdrInfo.QValue <= 0.01 && !f.IsDecoy)) { List fullSequences = new List(); - foreach ((int notch, PeptideWithSetModifications pwsm) in psm.BestMatchingPeptides) + foreach ((int notch, IBioPolymerWithSetMods pwsm) in psm.BestMatchingBioPolymersWithSetMods) { if (fullSequences.Contains(pwsm.FullSequence)) { @@ -369,7 +370,7 @@ public static Dictionary>> Compute } fullSequences.Add(pwsm.FullSequence); - double predictedHydrophobicity = calc.ScoreSequence(pwsm); + double predictedHydrophobicity = pwsm is PeptideWithSetModifications pep ? calc.ScoreSequence(pep) : 0; //here i'm grouping this in 2 minute increments becuase there are cases where you get too few data points to get a good standard deviation an average. This is for stability. int possibleKey = (int)(2 * Math.Round(psm.ScanRetentionTime / 2d, 0)); @@ -447,7 +448,7 @@ public static Dictionary>> Compute return rtHydrophobicityAvgDev; } - public static Dictionary>> ComputeMobilityValues(List psms, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters) + public static Dictionary>> ComputeMobilityValues(List psms, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters) { Dictionary>> rtMobilityAvgDev = new Dictionary>>(); @@ -460,10 +461,10 @@ public static Dictionary>> Compute Dictionary> mobilities = new Dictionary>(); Dictionary> averagesCommaStandardDeviations = new Dictionary>(); - foreach (PeptideSpectralMatch psm in psms.Where(f => (f.FullFilePath == null || Path.GetFileName(f.FullFilePath) == filename) && f.FdrInfo.QValue <= 0.01 && !f.IsDecoy)) + foreach (SpectralMatch psm in psms.Where(f => (f.FullFilePath == null || Path.GetFileName(f.FullFilePath) == filename) && f.FdrInfo.QValue <= 0.01 && !f.IsDecoy)) { List fullSequences = new List(); - foreach ((int notch, PeptideWithSetModifications pwsm) in psm.BestMatchingPeptides) + foreach ((int notch, IBioPolymerWithSetMods pwsm) in psm.BestMatchingBioPolymersWithSetMods) { if (fullSequences.Contains(pwsm.FullSequence)) { @@ -471,7 +472,7 @@ public static Dictionary>> Compute } fullSequences.Add(pwsm.FullSequence); - double predictedMobility = 100.0 * GetCifuentesMobility(pwsm); + double predictedMobility = pwsm is PeptideWithSetModifications pep ? 100.0 * GetCifuentesMobility(pep) : 0; //here i'm grouping this in 2 minute increments becuase there are cases where you get too few data points to get a good standard deviation an average. This is for stability. int possibleKey = (int)(2 * Math.Round(psm.ScanRetentionTime / 2d, 0)); @@ -549,7 +550,7 @@ public static void UpdateOutOfRangeStDevsWithGlobalAverage(Dictionary f == 'K') + pwsm.BaseSequence.Count(f => f == 'R') + pwsm.BaseSequence.Count(f => f == 'H') - CountModificationsThatShiftMobility(pwsm.AllModsOneIsNterminus.Values.AsEnumerable());// the 1 + is for N-terminal @@ -558,7 +559,7 @@ private static double GetCifuentesMobility(PeptideWithSetModifications pwsm) return mobility; } - private static float GetSSRCalcHydrophobicityZScore(PeptideSpectralMatch psm, PeptideWithSetModifications Peptide, Dictionary>> d) + private static float GetSSRCalcHydrophobicityZScore(SpectralMatch psm, IBioPolymerWithSetMods Peptide, Dictionary>> d) { //Using SSRCalc3 but probably any number of different calculators could be used instead. One could also use the CE mobility. SSRCalc3 calc = new SSRCalc3("SSRCalc 3.0 (300A)", SSRCalc3.Column.A300); @@ -569,7 +570,7 @@ private static float GetSSRCalcHydrophobicityZScore(PeptideSpectralMatch psm, Pe int time = (int)(2 * Math.Round(psm.ScanRetentionTime / 2d, 0)); if (d[Path.GetFileName(psm.FullFilePath)].Keys.Contains(time)) { - double predictedHydrophobicity = calc.ScoreSequence(Peptide); + double predictedHydrophobicity = Peptide is PeptideWithSetModifications pep ? calc.ScoreSequence(pep) : 0; hydrophobicityZscore = Math.Abs(d[Path.GetFileName(psm.FullFilePath)][time].Item1 - predictedHydrophobicity) / d[Path.GetFileName(psm.FullFilePath)][time].Item2; } @@ -584,7 +585,7 @@ private static float GetSSRCalcHydrophobicityZScore(PeptideSpectralMatch psm, Pe return (float)hydrophobicityZscore; } - private static float GetMobilityZScore(PeptideSpectralMatch psm, PeptideWithSetModifications selectedPeptide) + private static float GetMobilityZScore(SpectralMatch psm, IBioPolymerWithSetMods selectedPeptide) { double mobilityZScore = double.NaN; @@ -608,16 +609,16 @@ private static float GetMobilityZScore(PeptideSpectralMatch psm, PeptideWithSetM return (float)mobilityZScore; } - public static Dictionary GetSequenceToPSMCount(List psms) + public static Dictionary GetSequenceToPSMCount(List psms) { Dictionary sequenceToPsmCount = new Dictionary(); List sequences = new List(); - foreach (PeptideSpectralMatch psm in psms) + foreach (SpectralMatch psm in psms) { List fullSeqs = new List(); - foreach ((int, PeptideWithSetModifications) bmp in psm.BestMatchingPeptides) + foreach ((int, PeptideWithSetModifications) bmp in psm.BestMatchingBioPolymersWithSetMods) { fullSeqs.Add(bmp.Item2.FullSequence); } @@ -634,7 +635,7 @@ public static Dictionary GetSequenceToPSMCount(List CreatePsmData(string searchType, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, - List psms, List psmIndicies, Dictionary sequenceToPsmCount, + List psms, List psmIndicies, Dictionary sequenceToPsmCount, Dictionary>> timeDependantHydrophobicityAverageAndDeviation_unmodified, Dictionary>> timeDependantHydrophobicityAverageAndDeviation_modified, Dictionary fileSpecificMedianFragmentMassErrors, int chargeStateMode) @@ -653,7 +654,7 @@ public static IEnumerable CreatePsmData(string searchType, List<(string List localPsmOrder = new List(); for (int i = range.Item1; i < range.Item2; i++) { - PeptideSpectralMatch psm = psms[psmIndicies[i]]; + SpectralMatch psm = psms[psmIndicies[i]]; // Stop loop if canceled if (GlobalVariables.StopLoops) { return; } @@ -667,12 +668,12 @@ public static IEnumerable CreatePsmData(string searchType, List<(string if (csm.IsDecoy || csm.BetaPeptide.IsDecoy) { label = false; - newPsmData = CreateOnePsmDataEntry(searchType, fileSpecificParameters, psm, sequenceToPsmCount, timeDependantHydrophobicityAverageAndDeviation_unmodified, timeDependantHydrophobicityAverageAndDeviation_modified, fileSpecificMedianFragmentMassErrors, chargeStateMode, csm.BestMatchingPeptides.First().Peptide, 0, label); + newPsmData = CreateOnePsmDataEntry(searchType, fileSpecificParameters, psm, sequenceToPsmCount, timeDependantHydrophobicityAverageAndDeviation_unmodified, timeDependantHydrophobicityAverageAndDeviation_modified, fileSpecificMedianFragmentMassErrors, chargeStateMode, csm.BestMatchingBioPolymersWithSetMods.First().Peptide, 0, label); } else if (!csm.IsDecoy && !csm.BetaPeptide.IsDecoy && psm.FdrInfo.QValue <= 0.0005) { label = true; - newPsmData = CreateOnePsmDataEntry(searchType, fileSpecificParameters, psm, sequenceToPsmCount, timeDependantHydrophobicityAverageAndDeviation_unmodified, timeDependantHydrophobicityAverageAndDeviation_modified, fileSpecificMedianFragmentMassErrors, chargeStateMode, csm.BestMatchingPeptides.First().Peptide, 0, label); + newPsmData = CreateOnePsmDataEntry(searchType, fileSpecificParameters, psm, sequenceToPsmCount, timeDependantHydrophobicityAverageAndDeviation_unmodified, timeDependantHydrophobicityAverageAndDeviation_modified, fileSpecificMedianFragmentMassErrors, chargeStateMode, csm.BestMatchingBioPolymersWithSetMods.First().Peptide, 0, label); } localPsmDataList.Add(newPsmData); localPsmOrder.Add(i); @@ -680,16 +681,16 @@ public static IEnumerable CreatePsmData(string searchType, List<(string else { double bmp = 0; - foreach (var (notch, peptideWithSetMods) in psm.BestMatchingPeptides) + foreach (var (notch, peptideWithSetMods) in psm.BestMatchingBioPolymersWithSetMods) { bool label; - double bmpc = psm.BestMatchingPeptides.Count(); - if (peptideWithSetMods.Protein.IsDecoy) + double bmpc = psm.BestMatchingBioPolymersWithSetMods.Count(); + if (peptideWithSetMods.Parent.IsDecoy) { label = false; newPsmData = CreateOnePsmDataEntry(searchType, fileSpecificParameters, psm, sequenceToPsmCount, timeDependantHydrophobicityAverageAndDeviation_unmodified, timeDependantHydrophobicityAverageAndDeviation_modified, fileSpecificMedianFragmentMassErrors, chargeStateMode, peptideWithSetMods, notch, label); } - else if (!peptideWithSetMods.Protein.IsDecoy && psm.FdrInfo.QValue <= 0.005) + else if (!peptideWithSetMods.Parent.IsDecoy && psm.FdrInfo.QValue <= 0.005) { label = true; newPsmData = CreateOnePsmDataEntry(searchType, fileSpecificParameters, psm, sequenceToPsmCount, timeDependantHydrophobicityAverageAndDeviation_unmodified, timeDependantHydrophobicityAverageAndDeviation_modified, fileSpecificMedianFragmentMassErrors, chargeStateMode, peptideWithSetMods, notch, label); @@ -714,7 +715,15 @@ public static IEnumerable CreatePsmData(string searchType, List<(string return pda.AsEnumerable(); } - public static PsmData CreateOnePsmDataEntry(string searchType, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, PeptideSpectralMatch psm, Dictionary sequenceToPsmCount, Dictionary>> timeDependantHydrophobicityAverageAndDeviation_unmodified, Dictionary>> timeDependantHydrophobicityAverageAndDeviation_modified, Dictionary fileSpecificMedianFragmentMassErrors, int chargeStateMode, PeptideWithSetModifications selectedPeptide, int notchToUse, bool label) + public static PsmData CreateOnePsmDataEntry(string searchType, + List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, SpectralMatch psm, + Dictionary sequenceToPsmCount, + Dictionary>> + timeDependantHydrophobicityAverageAndDeviation_unmodified, + Dictionary>> + timeDependantHydrophobicityAverageAndDeviation_modified, + Dictionary fileSpecificMedianFragmentMassErrors, int chargeStateMode, + IBioPolymerWithSetMods selectedPeptide, int notchToUse, bool label) { double normalizationFactor = selectedPeptide.BaseSequence.Length; float totalMatchingFragmentCount = 0; @@ -751,20 +760,20 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file { normalizationFactor /= 10.0; } - totalMatchingFragmentCount = (float)(Math.Round(psm.PeptidesToMatchingFragments[selectedPeptide].Count / normalizationFactor * 10, 0)); + totalMatchingFragmentCount = (float)(Math.Round(psm.BioPolymersWithSetModsToMatchingFragments[selectedPeptide].Count / normalizationFactor * 10, 0)); intensity = (float)Math.Min(50, Math.Round((psm.Score - (int)psm.Score) / normalizationFactor * 100.0, 0)); chargeDifference = -Math.Abs(chargeStateMode - psm.ScanPrecursorCharge); deltaScore = (float)Math.Round(psm.DeltaScore / normalizationFactor * 10.0, 0); notch = notchToUse; modCount = Math.Min((float)selectedPeptide.AllModsOneIsNterminus.Keys.Count(), 10); - if (psm.PeptidesToMatchingFragments[selectedPeptide]?.Count() > 0) + if (psm.BioPolymersWithSetModsToMatchingFragments[selectedPeptide]?.Count() > 0) { - absoluteFragmentMassError = (float)Math.Min(100.0, Math.Round(10.0 * Math.Abs(GetAverageFragmentMassError(psm.PeptidesToMatchingFragments[selectedPeptide]) - fileSpecificMedianFragmentMassErrors[Path.GetFileName(psm.FullFilePath)]))); + absoluteFragmentMassError = (float)Math.Min(100.0, Math.Round(10.0 * Math.Abs(GetAverageFragmentMassError(psm.BioPolymersWithSetModsToMatchingFragments[selectedPeptide]) - fileSpecificMedianFragmentMassErrors[Path.GetFileName(psm.FullFilePath)]))); } - ambiguity = Math.Min((float)(psm.PeptidesToMatchingFragments.Keys.Count - 1), 10); - longestSeq = (float)Math.Round(PeptideSpectralMatch.GetLongestIonSeriesBidirectional(psm.PeptidesToMatchingFragments, selectedPeptide) / normalizationFactor * 10, 0); - complementaryIonCount = (float)Math.Round(PeptideSpectralMatch.GetCountComplementaryIons(psm.PeptidesToMatchingFragments, selectedPeptide) / normalizationFactor * 10, 0); + ambiguity = Math.Min((float)(psm.BioPolymersWithSetModsToMatchingFragments.Keys.Count - 1), 10); + longestSeq = (float)Math.Round(SpectralMatch.GetLongestIonSeriesBidirectional(psm.BioPolymersWithSetModsToMatchingFragments, selectedPeptide) / normalizationFactor * 10, 0); + complementaryIonCount = (float)Math.Round(SpectralMatch.GetCountComplementaryIons(psm.BioPolymersWithSetModsToMatchingFragments, selectedPeptide) / normalizationFactor * 10, 0); //grouping psm counts as follows is done for stability. you get very nice numbers at low psms to get good statistics. But you get a few peptides with high psm counts that could be either targets or decoys and the values swing between extremes. So grouping psms in bundles really adds stability. psmCount = sequenceToPsmCount[selectedPeptide.FullSequence]; @@ -811,8 +820,8 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file else { CrosslinkSpectralMatch csm = (CrosslinkSpectralMatch)psm; - PeptideWithSetModifications selectedAlphaPeptide = csm.BestMatchingPeptides.Select(p => p.Peptide).First(); - PeptideWithSetModifications selectedBetaPeptide = csm.BetaPeptide?.BestMatchingPeptides.Select(p => p.Peptide).First(); + PeptideWithSetModifications selectedAlphaPeptide = csm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide as PeptideWithSetModifications).First(); + PeptideWithSetModifications selectedBetaPeptide = csm.BetaPeptide?.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide as PeptideWithSetModifications).First(); float alphaNormalizationFactor = selectedAlphaPeptide.BaseSequence.Length; float betaNormalizationFactor = selectedBetaPeptide == null ? (float)0 : selectedBetaPeptide.BaseSequence.Length; @@ -823,17 +832,17 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file //Compute fragment mass error int alphaCount = 0; float alphaError = 0; - if (csm.PeptidesToMatchingFragments[selectedAlphaPeptide]?.Count > 0) + if (csm.BioPolymersWithSetModsToMatchingFragments[selectedAlphaPeptide]?.Count > 0) { - alphaCount = csm.PeptidesToMatchingFragments[selectedAlphaPeptide].Count; - alphaError = Math.Abs(GetAverageFragmentMassError(csm.PeptidesToMatchingFragments[selectedAlphaPeptide])); + alphaCount = csm.BioPolymersWithSetModsToMatchingFragments[selectedAlphaPeptide].Count; + alphaError = Math.Abs(GetAverageFragmentMassError(csm.BioPolymersWithSetModsToMatchingFragments[selectedAlphaPeptide])); } int betaCount = 0; float betaError = 0; - if (csm.BetaPeptide.PeptidesToMatchingFragments[selectedBetaPeptide]?.Count > 0) + if (csm.BetaPeptide.BioPolymersWithSetModsToMatchingFragments[selectedBetaPeptide]?.Count > 0) { - betaCount = csm.BetaPeptide.PeptidesToMatchingFragments[selectedBetaPeptide].Count; - betaError = Math.Abs(GetAverageFragmentMassError(csm.BetaPeptide.PeptidesToMatchingFragments[selectedBetaPeptide])); + betaCount = csm.BetaPeptide.BioPolymersWithSetModsToMatchingFragments[selectedBetaPeptide].Count; + betaError = Math.Abs(GetAverageFragmentMassError(csm.BetaPeptide.BioPolymersWithSetModsToMatchingFragments[selectedBetaPeptide])); } float averageError = 0; @@ -849,8 +858,8 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file chargeDifference = -Math.Abs(chargeStateMode - psm.ScanPrecursorCharge); alphaIntensity = (float)Math.Min(100, Math.Round((csm.Score - (int)csm.Score) / alphaNormalizationFactor * 100.0, 0)); betaIntensity = csm.BetaPeptide == null ? (float)0 : (float)Math.Min(100.0, Math.Round((csm.BetaPeptide.Score - (int)csm.BetaPeptide.Score) / betaNormalizationFactor * 100.0, 0)); - longestFragmentIonSeries_Alpha = (float)Math.Round(PeptideSpectralMatch.GetLongestIonSeriesBidirectional(csm.PeptidesToMatchingFragments, selectedAlphaPeptide) / alphaNormalizationFactor * 10.0, 0); - longestFragmentIonSeries_Beta = selectedBetaPeptide == null ? (float)0 : PeptideSpectralMatch.GetLongestIonSeriesBidirectional(csm.BetaPeptide.PeptidesToMatchingFragments, selectedBetaPeptide) / betaNormalizationFactor; + longestFragmentIonSeries_Alpha = (float)Math.Round(SpectralMatch.GetLongestIonSeriesBidirectional(csm.BioPolymersWithSetModsToMatchingFragments, selectedAlphaPeptide) / alphaNormalizationFactor * 10.0, 0); + longestFragmentIonSeries_Beta = selectedBetaPeptide == null ? (float)0 : SpectralMatch.GetLongestIonSeriesBidirectional(csm.BetaPeptide.BioPolymersWithSetModsToMatchingFragments, selectedBetaPeptide) / betaNormalizationFactor; longestFragmentIonSeries_Beta = (float)Math.Round(longestFragmentIonSeries_Beta * 10.0, 0); isInter = Convert.ToSingle(csm.CrossType == PsmCrossType.Inter); isIntra = Convert.ToSingle(csm.CrossType == PsmCrossType.Intra); @@ -891,8 +900,11 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file return psm.PsmData_forPEPandPercolator; } - private static bool PeptideIsVariant(PeptideWithSetModifications pwsm) + private static bool PeptideIsVariant(IBioPolymerWithSetMods bpwsm) { + if (bpwsm is not PeptideWithSetModifications pwsm) + return false; + bool identifiedVariant = false; if (pwsm.Protein.AppliedSequenceVariations.Count() > 0) { @@ -908,7 +920,7 @@ private static bool PeptideIsVariant(PeptideWithSetModifications pwsm) return identifiedVariant; } - private static bool PsmHasSpectralAngle(PeptideSpectralMatch psm) + private static bool PsmHasSpectralAngle(SpectralMatch psm) { return psm.SpectralAngle >= 0; } @@ -933,7 +945,7 @@ public static int CountModificationsThatShiftMobility(IEnumerable return modifications.Select(n => n.OriginalId).Intersect(shiftingModifications).Count(); } - public static Dictionary GetFileSpecificMedianFragmentMassError(List psms) + public static Dictionary GetFileSpecificMedianFragmentMassError(List psms) { Dictionary fileSpecificMassErrors = new Dictionary(); foreach (string filename in psms.Select(p => Path.GetFileName(p.FullFilePath)).Distinct()) @@ -943,13 +955,13 @@ public static Dictionary GetFileSpecificMedianFragmentMassError(L return fileSpecificMassErrors; } - public static float GetMedianAverageMassError(IEnumerable psms) + public static float GetMedianAverageMassError(IEnumerable psms) { List averageMassErrors = new List(); - foreach (PeptideSpectralMatch psm in psms) + foreach (SpectralMatch psm in psms) { { - foreach (KeyValuePair> peptide_MFI in psm.PeptidesToMatchingFragments) + foreach (KeyValuePair> peptide_MFI in psm.BioPolymersWithSetModsToMatchingFragments) { if (peptide_MFI.Value != null && peptide_MFI.Value.Count > 0) { diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoPeptides.cs b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoPeptides.cs index 9a90f79ce..b7557c83e 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoPeptides.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoPeptides.cs @@ -162,8 +162,8 @@ public static PeptideWithSetModifications GenerateGlycopeptide(int position, Pep } } - var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidueInProtein, - peptide.OneBasedEndResidueInProtein, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); + var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidue, + peptide.OneBasedEndResidue, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); return testPeptide; @@ -272,8 +272,8 @@ public static PeptideWithSetModifications OGlyGetTheoreticalPeptide(int[] theMod testMods.Add(theModPositions.ElementAt(i), modifications[i]); } - var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidueInProtein, - peptide.OneBasedEndResidueInProtein, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); + var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidue, + peptide.OneBasedEndResidue, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); return testPeptide; } @@ -297,8 +297,8 @@ public static PeptideWithSetModifications OGlyGetTheoreticalPeptide(Route theMod testMods.Add(theModPositions.Mods[i].Item1, modifications[i]); } - var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidueInProtein, - peptide.OneBasedEndResidueInProtein, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); + var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidue, + peptide.OneBasedEndResidue, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); return testPeptide; } diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSearchEngine.cs b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSearchEngine.cs index 3a859f859..b1e8bccf4 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSearchEngine.cs @@ -250,9 +250,9 @@ private void Add2GlobalGsms(ref List gsms, int scanIndex) if (preString == currentString) { - foreach (var bestMatchPeptide in gsm.BestMatchingPeptides) + foreach ((int, PeptideWithSetModifications Peptide) bestMatchPeptide in gsm.BestMatchingBioPolymersWithSetMods) { - GlobalCsms[scanIndex].Last().AddProteinMatch(bestMatchPeptide, gsm.PeptidesToMatchingFragments[bestMatchPeptide.Peptide]); + GlobalCsms[scanIndex].Last().AddProteinMatch(bestMatchPeptide, gsm.BioPolymersWithSetModsToMatchingFragments[bestMatchPeptide.Peptide]); } } diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs index b4e4bbdf3..9855026e1 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs @@ -18,7 +18,7 @@ public enum LocalizationLevel Level3 } - public class GlycoSpectralMatch : PeptideSpectralMatch + public class GlycoSpectralMatch : SpectralMatch { public GlycoSpectralMatch(PeptideWithSetModifications theBestPeptide, int notch, double score, int scanIndex, Ms2ScanWithSpecificMass scan, CommonParameters commonParameters, List matchedFragmentIons) : base(theBestPeptide, notch, score, scanIndex, scan, commonParameters, matchedFragmentIons) @@ -264,16 +264,16 @@ public override string ToString() sb.Append(ScanPrecursorCharge + "\t"); sb.Append(ScanPrecursorMass + "\t"); - var proteinAccessionString = ProteinAccession ?? PsmTsvWriter.Resolve(BestMatchingPeptides.Select(p => p.Peptide.Protein.Accession), FullSequence).ResolvedString; + var proteinAccessionString = Accession ?? PsmTsvWriter.Resolve(BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide.Parent.Accession), FullSequence).ResolvedString; sb.Append(proteinAccessionString + "\t"); sb.Append(Organism + "\t"); - sb.Append(PsmTsvWriter.Resolve(BestMatchingPeptides.Select(b => b.Peptide.Protein.FullName), FullSequence).ResolvedString + "\t"); - int _FirstOneBasedStartResidueInProtein = OneBasedStartResidueInProtein.HasValue ? OneBasedStartResidueInProtein.Value : BestMatchingPeptides.First().Peptide.OneBasedStartResidueInProtein; - int _FirstOneBasedEndResidueInProtein = OneBasedEndResidueInProtein.HasValue ? OneBasedEndResidueInProtein.Value : BestMatchingPeptides.First().Peptide.OneBasedEndResidueInProtein; ; + sb.Append(PsmTsvWriter.Resolve(BestMatchingBioPolymersWithSetMods.Select(b => b.Peptide.Parent.FullName), FullSequence).ResolvedString + "\t"); + int _FirstOneBasedStartResidueInProtein = OneBasedStartResidue.HasValue ? OneBasedStartResidue.Value : BestMatchingBioPolymersWithSetMods.First().Peptide.OneBasedStartResidue; + int _FirstOneBasedEndResidueInProtein = OneBasedEndResidue.HasValue ? OneBasedEndResidue.Value : BestMatchingBioPolymersWithSetMods.First().Peptide.OneBasedEndResidue; ; - if (OneBasedStartResidueInProtein.HasValue) + if (OneBasedStartResidue.HasValue) { - sb.Append("[" + OneBasedStartResidueInProtein.Value.ToString() + " to " + OneBasedEndResidueInProtein.Value.ToString() + "]" + '\t'); + sb.Append("[" + OneBasedStartResidue.Value.ToString() + " to " + OneBasedEndResidue.Value.ToString() + "]" + '\t'); } else { @@ -281,11 +281,11 @@ public override string ToString() } sb.Append(BaseSequence + "\t"); - sb.Append(BestMatchingPeptides.First().Peptide.PreviousAminoAcid + "," + BestMatchingPeptides.First().Peptide.NextAminoAcid + "\t"); + sb.Append(BestMatchingBioPolymersWithSetMods.First().Peptide.PreviousResidue + "," + BestMatchingBioPolymersWithSetMods.First().Peptide.NextResidue + "\t"); sb.Append(FullSequence + "\t"); - sb.Append(BestMatchingPeptides.First().Peptide.AllModsOneIsNterminus.Count + "\t"); + sb.Append(BestMatchingBioPolymersWithSetMods.First().Peptide.AllModsOneIsNterminus.Count + "\t"); - sb.Append((PeptideMonisotopicMass.HasValue ? PeptideMonisotopicMass.Value.ToString() : "---")); sb.Append("\t"); + sb.Append((BioPolymerWithSetModsMonoisotopicMass.HasValue ? BioPolymerWithSetModsMonoisotopicMass.Value.ToString() : "---")); sb.Append("\t"); sb.Append(Score + "\t"); sb.Append(Rank + "\t"); @@ -390,7 +390,7 @@ public override string ToString() //sb.Append(localizedGlycan); sb.Append("\t"); string local_peptide = ""; string local_protein = ""; - LocalizedSiteSpeciLocalInfo(SiteSpeciLocalProb, LocalizedGlycan, OneBasedStartResidueInProtein, ref local_peptide, ref local_protein); + LocalizedSiteSpeciLocalInfo(SiteSpeciLocalProb, LocalizedGlycan, OneBasedStartResidue, ref local_peptide, ref local_protein); sb.Append(local_peptide); sb.Append("\t"); sb.Append(local_protein); sb.Append("\t"); diff --git a/MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs b/MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs index a4dcfff62..8c62576a6 100644 --- a/MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs +++ b/MetaMorpheus/EngineLayer/Gptmd/GptmdEngine.cs @@ -4,18 +4,19 @@ using System; using System.Collections.Generic; using System.Linq; +using Omics; using Omics.Modifications; namespace EngineLayer.Gptmd { public class GptmdEngine : MetaMorpheusEngine { - private readonly List AllIdentifications; + private readonly List AllIdentifications; private readonly IEnumerable> Combos; private readonly List GptmdModifications; private readonly Dictionary FilePathToPrecursorMassTolerance; // this exists because of file-specific tolerances - public GptmdEngine(List allIdentifications, List gptmdModifications, IEnumerable> combos, Dictionary filePathToPrecursorMassTolerance, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) + public GptmdEngine(List allIdentifications, List gptmdModifications, IEnumerable> combos, Dictionary filePathToPrecursorMassTolerance, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) { AllIdentifications = allIdentifications; GptmdModifications = gptmdModifications; @@ -23,7 +24,7 @@ public GptmdEngine(List allIdentifications, List v.Peptide)) + foreach (var pepWithSetMods in psm.BestMatchingBioPolymersWithSetMods.Select(v => v.Peptide as PeptideWithSetModifications)) { foreach (Modification mod in GetPossibleMods(psm.ScanPrecursorMass, GptmdModifications, Combos, precursorMassTolerance, pepWithSetMods)) { - var isVariantProtein = pepWithSetMods.Protein != pepWithSetMods.Protein.NonVariantProtein; + var isVariantProtein = pepWithSetMods.Parent != pepWithSetMods.Protein.NonVariantProtein; for (int i = 0; i < pepWithSetMods.Length; i++) { - int indexInProtein = pepWithSetMods.OneBasedStartResidueInProtein + i; + int indexInProtein = pepWithSetMods.OneBasedStartResidue + i; - if (ModFits(mod, pepWithSetMods.Protein, i + 1, pepWithSetMods.Length, indexInProtein)) + if (ModFits(mod, pepWithSetMods.Parent, i + 1, pepWithSetMods.Length, indexInProtein)) { // if not a variant protein, index to base protein sequence if (!isVariantProtein) diff --git a/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs b/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs index c1c81590b..ea119c94f 100644 --- a/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs +++ b/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs @@ -12,13 +12,13 @@ public class Bin { public string AA = "-"; public Dictionary ResidueCount; - public Dictionary> UniquePSMs; + public Dictionary> UniquePSMs; public Dictionary ModsInCommon; public Bin(double massShift) { this.MassShift = massShift; - UniquePSMs = new Dictionary>(); + UniquePSMs = new Dictionary>(); } public int PepNlocCount { get; private set; } @@ -87,13 +87,13 @@ public void IdentifyResidues() if (hehe.Item3.LocalizedScores.Max() - hehe.Item3.LocalizedScores[0] < 0.5) { PepNlocCount++; - if (hehe.Item3.OneBasedStartResidueInProtein.HasValue && hehe.Item3.OneBasedStartResidueInProtein.Value <= 2) + if (hehe.Item3.OneBasedStartResidue.HasValue && hehe.Item3.OneBasedStartResidue.Value <= 2) ProtNlocCount++; } if (hehe.Item3.LocalizedScores.Max() - hehe.Item3.LocalizedScores.Last() < 0.5) { PepClocCount++; - if (hehe.Item3.OneBasedEndResidueInProtein.HasValue && hehe.Item3.ProteinLength.HasValue && hehe.Item3.OneBasedEndResidueInProtein.Value == hehe.Item3.ProteinLength.Value) + if (hehe.Item3.OneBasedEndResidue.HasValue && hehe.Item3.ParentLength.HasValue && hehe.Item3.OneBasedEndResidue.Value == hehe.Item3.ParentLength.Value) ProtClocCount++; } } @@ -173,7 +173,7 @@ public void IdentifyUnimodBins(double v) UnimodDiffs = string.Join("|", okDiff); } - internal void Add(PeptideSpectralMatch ok) + internal void Add(SpectralMatch ok) { if (ok.FullSequence != null) { @@ -181,10 +181,10 @@ internal void Add(PeptideSpectralMatch ok) { var current = UniquePSMs[ok.FullSequence]; if (current.Item3.Score < ok.Score) - UniquePSMs[ok.FullSequence] = new Tuple(ok.BaseSequence, ok.FullSequence, ok); + UniquePSMs[ok.FullSequence] = new Tuple(ok.BaseSequence, ok.FullSequence, ok); } else - UniquePSMs.Add(ok.FullSequence, new Tuple(ok.BaseSequence, ok.FullSequence, ok)); + UniquePSMs.Add(ok.FullSequence, new Tuple(ok.BaseSequence, ok.FullSequence, ok)); } } } diff --git a/MetaMorpheus/EngineLayer/HistogramAnalysis/BinTreeStructure.cs b/MetaMorpheus/EngineLayer/HistogramAnalysis/BinTreeStructure.cs index 8da75929d..51a338a5c 100644 --- a/MetaMorpheus/EngineLayer/HistogramAnalysis/BinTreeStructure.cs +++ b/MetaMorpheus/EngineLayer/HistogramAnalysis/BinTreeStructure.cs @@ -14,9 +14,9 @@ public class BinTreeStructure public List FinalBins { get; private set; } - public void GenerateBins(List targetAndDecoyMatches, double dc) + public void GenerateBins(List targetAndDecoyMatches, double dc) { - List listOfMassShifts = targetAndDecoyMatches.Where(b => b.PeptideMonisotopicMass.HasValue).Select(b => b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value).OrderBy(b => b).ToList(); + List listOfMassShifts = targetAndDecoyMatches.Where(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue).Select(b => b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value).OrderBy(b => b).ToList(); double minMassShift = listOfMassShifts.Min(); double maxMassShift = listOfMassShifts.Max(); @@ -88,7 +88,7 @@ public void GenerateBins(List targetAndDecoyMatches, doubl for (int i = 0; i < targetAndDecoyMatches.Count; i++) { foreach (Bin bin in FinalBins) - if (targetAndDecoyMatches[i].PeptideMonisotopicMass.HasValue && Math.Abs(targetAndDecoyMatches[i].ScanPrecursorMass - targetAndDecoyMatches[i].PeptideMonisotopicMass.Value - bin.MassShift) <= dc) + if (targetAndDecoyMatches[i].BioPolymerWithSetModsMonoisotopicMass.HasValue && Math.Abs(targetAndDecoyMatches[i].ScanPrecursorMass - targetAndDecoyMatches[i].BioPolymerWithSetModsMonoisotopicMass.Value - bin.MassShift) <= dc) bin.Add(targetAndDecoyMatches[i]); } @@ -155,7 +155,7 @@ private void IdentifyMedianLength() { var numTarget = bin.UniquePSMs.Values.Count(b => !b.Item3.IsDecoy); if (numTarget > 0) - bin.MedianLength = Statistics.Median(bin.UniquePSMs.Values.Where(b => !b.Item3.IsDecoy).Where(b => b.Item3.PeptideLength.HasValue).Select(b => (double)b.Item3.PeptideLength.Value)); + bin.MedianLength = Statistics.Median(bin.UniquePSMs.Values.Where(b => !b.Item3.IsDecoy).Where(b => b.Item3.BioPolymerWithSetModsLength.HasValue).Select(b => (double)b.Item3.BioPolymerWithSetModsLength.Value)); } } diff --git a/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs b/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs index ed0662d46..920ed6b34 100644 --- a/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs +++ b/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs @@ -1,4 +1,5 @@ using MassSpectrometry; +using Omics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System.Collections.Concurrent; @@ -16,10 +17,10 @@ namespace EngineLayer.Localization /// public class LocalizationEngine : MetaMorpheusEngine { - private readonly IEnumerable AllResultingIdentifications; + private readonly IEnumerable AllResultingIdentifications; private readonly MsDataFile MyMsDataFile; - public LocalizationEngine(IEnumerable allResultingIdentifications, MsDataFile myMsDataFile, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) + public LocalizationEngine(IEnumerable allResultingIdentifications, MsDataFile myMsDataFile, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) { AllResultingIdentifications = allResultingIdentifications; MyMsDataFile = myMsDataFile; @@ -28,7 +29,7 @@ public LocalizationEngine(IEnumerable allResultingIdentifi protected override MetaMorpheusEngineResults RunSpecific() { // don't try to localize mass differences for ambiguous peptides - PeptideSpectralMatch[] unambiguousPsms = AllResultingIdentifications.Where(b => b.FullSequence != null).ToArray(); + SpectralMatch[] unambiguousPsms = AllResultingIdentifications.Where(b => b.FullSequence != null).ToArray(); double psmsSearched = 0; int oldPercentProgress = 0; @@ -43,14 +44,14 @@ protected override MetaMorpheusEngineResults RunSpecific() for (int i = range.Item1; i < range.Item2; i++) { - PeptideSpectralMatch psm = unambiguousPsms[i]; + SpectralMatch psm = unambiguousPsms[i]; // Stop loop if canceled if (GlobalVariables.StopLoops) { break; } MsDataScan scan = MyMsDataFile.GetOneBasedScan(psm.ScanNumber); Ms2ScanWithSpecificMass scanWithSpecificMass = new Ms2ScanWithSpecificMass(scan, psm.ScanPrecursorMonoisotopicPeakMz, psm.ScanPrecursorCharge, psm.FullFilePath, CommonParameters); - PeptideWithSetModifications peptide = psm.BestMatchingPeptides.First().Peptide; + IBioPolymerWithSetMods peptide = psm.BestMatchingBioPolymersWithSetMods.First().Peptide; double massDifference = psm.ScanPrecursorMass - peptide.MonoisotopicMass; // this section will iterate through all residues of the peptide and try to localize the mass-diff at each residue and report a score for each residue @@ -58,7 +59,7 @@ protected override MetaMorpheusEngineResults RunSpecific() for (int r = 0; r < peptide.Length; r++) { // create new PeptideWithSetMods with unidentified mass difference at the given residue - PeptideWithSetModifications peptideWithLocalizedMassDiff = peptide.Localize(r, massDifference); + IBioPolymerWithSetMods peptideWithLocalizedMassDiff = peptide.Localize(r, massDifference); // this is the list of theoretical products for this peptide with mass-difference on this residue peptideWithLocalizedMassDiff.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus, productsWithLocalizedMassDiff); diff --git a/MetaMorpheus/EngineLayer/ModernSearch/ModernSearchEngine.cs b/MetaMorpheus/EngineLayer/ModernSearch/ModernSearchEngine.cs index 8bf1666cf..137bc00fb 100644 --- a/MetaMorpheus/EngineLayer/ModernSearch/ModernSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/ModernSearch/ModernSearchEngine.cs @@ -13,7 +13,7 @@ public class ModernSearchEngine : MetaMorpheusEngine { protected const int FragmentBinsPerDalton = 1000; protected readonly List[] FragmentIndex; - protected readonly PeptideSpectralMatch[] PeptideSpectralMatches; + protected readonly SpectralMatch[] PeptideSpectralMatches; protected readonly Ms2ScanWithSpecificMass[] ListOfSortedMs2Scans; protected readonly List PeptideIndex; protected readonly int CurrentPartition; @@ -21,7 +21,7 @@ public class ModernSearchEngine : MetaMorpheusEngine protected readonly DissociationType DissociationType; protected readonly double MaxMassThatFragmentIonScoreIsDoubled; - public ModernSearchEngine(PeptideSpectralMatch[] globalPsms, Ms2ScanWithSpecificMass[] listOfSortedms2Scans, List peptideIndex, + public ModernSearchEngine(SpectralMatch[] globalPsms, Ms2ScanWithSpecificMass[] listOfSortedms2Scans, List peptideIndex, List[] fragmentIndex, int currentPartition, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, MassDiffAcceptor massDiffAcceptor, double maximumMassThatFragmentIonScoreIsDoubled, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) { @@ -82,7 +82,7 @@ protected override MetaMorpheusEngineResults RunSpecific() } }); - foreach (PeptideSpectralMatch psm in PeptideSpectralMatches.Where(p => p != null)) + foreach (SpectralMatch psm in PeptideSpectralMatches.Where(p => p != null)) { psm.ResolveAllAmbiguities(); } @@ -336,7 +336,7 @@ protected void IncrementPeptideScoresInBin(int start, int end, List bin, by /// This is a second-pass scoring method which is costly (in terms of computational time and RAM) but calculates the "normal" MetaMorpheus score instead /// of the approximation computed by the IndexScoreScan method. /// - protected PeptideSpectralMatch FineScorePeptide(int id, Ms2ScanWithSpecificMass scan, int scanIndex, List peptideTheorProducts) + protected SpectralMatch FineScorePeptide(int id, Ms2ScanWithSpecificMass scan, int scanIndex, List peptideTheorProducts) { PeptideWithSetModifications peptide = PeptideIndex[id]; @@ -348,7 +348,7 @@ protected PeptideSpectralMatch FineScorePeptide(int id, Ms2ScanWithSpecificMass int notch = MassDiffAcceptor.Accepts(scan.PrecursorMass, peptide.MonoisotopicMass); bool meetsScoreCutoff = thisScore >= CommonParameters.ScoreCutoff; - bool scoreImprovement = PeptideSpectralMatches[scanIndex] == null || (thisScore - PeptideSpectralMatches[scanIndex].RunnerUpScore) > -PeptideSpectralMatch.ToleranceForScoreDifferentiation; + bool scoreImprovement = PeptideSpectralMatches[scanIndex] == null || (thisScore - PeptideSpectralMatches[scanIndex].RunnerUpScore) > -SpectralMatch.ToleranceForScoreDifferentiation; if (meetsScoreCutoff && scoreImprovement) { @@ -384,7 +384,7 @@ protected void FineScorePeptides(List peptideIds, Ms2ScanWithSpecificMass s break; } - PeptideSpectralMatch psm = FineScorePeptide(id, scan, scanIndex, peptideTheorProducts); + SpectralMatch psm = FineScorePeptide(id, scan, scanIndex, peptideTheorProducts); if (psm != null && psm.Score > bestScore) { diff --git a/MetaMorpheus/EngineLayer/ModificationAnalysis/ModificationAnalysisEngine.cs b/MetaMorpheus/EngineLayer/ModificationAnalysis/ModificationAnalysisEngine.cs index 40d5f3357..44350e1cb 100644 --- a/MetaMorpheus/EngineLayer/ModificationAnalysis/ModificationAnalysisEngine.cs +++ b/MetaMorpheus/EngineLayer/ModificationAnalysis/ModificationAnalysisEngine.cs @@ -6,9 +6,9 @@ namespace EngineLayer.ModificationAnalysis { public class ModificationAnalysisEngine : MetaMorpheusEngine { - private readonly List NewPsms; + private readonly List NewPsms; - public ModificationAnalysisEngine(List newPsms, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) + public ModificationAnalysisEngine(List newPsms, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) { NewPsms = newPsms; } @@ -23,17 +23,17 @@ protected override MetaMorpheusEngineResults RunSpecific() // For the database ones, only need un-ambiguous protein and location in protein var forObserved = confidentTargetPsms - .Where(b => b.ProteinAccession != null && b.OneBasedEndResidueInProtein != null && b.OneBasedStartResidueInProtein != null); + .Where(b => b.Accession != null && b.OneBasedEndResidue != null && b.OneBasedStartResidue != null); // For the unambiguously localized ones, need FullSequence and un-ambiguous protein and location in protein var forUnambiguouslyLocalized = confidentTargetPsms - .Where(b => b.FullSequence != null && b.ProteinAccession != null && b.OneBasedEndResidueInProtein != null && b.OneBasedStartResidueInProtein != null); + .Where(b => b.FullSequence != null && b.Accession != null && b.OneBasedEndResidue != null && b.OneBasedStartResidue != null); //**DEBUG - List toby = new List(); - foreach (PeptideSpectralMatch psm in confidentTargetPsms) + List toby = new List(); + foreach (SpectralMatch psm in confidentTargetPsms) { - if (psm.FullSequence != null && psm.ProteinAccession != null && psm.OneBasedEndResidueInProtein != null && psm.OneBasedStartResidueInProtein != null) + if (psm.FullSequence != null && psm.Accession != null && psm.OneBasedEndResidue != null && psm.OneBasedStartResidue != null) toby.Add(psm); } @@ -42,7 +42,7 @@ protected override MetaMorpheusEngineResults RunSpecific() // For the localized but ambiguous ones, need FullSequence var forAmbiguousButLocalized = confidentTargetPsms - .Where(b => b.FullSequence != null && !(b.ProteinAccession != null && b.OneBasedEndResidueInProtein != null && b.OneBasedStartResidueInProtein != null)) + .Where(b => b.FullSequence != null && !(b.Accession != null && b.OneBasedEndResidue != null && b.OneBasedStartResidue != null)) .GroupBy(b => b.FullSequence); // For unlocalized but identified modifications, skip ones with full sequences! @@ -59,28 +59,28 @@ protected override MetaMorpheusEngineResults RunSpecific() HashSet<(string, string, int)> modsOnProteins = new HashSet<(string, string, int)>(); foreach (var psm in forObserved) { - var singlePeptide = psm.BestMatchingPeptides.First().Peptide; - foreach (var modInProtein in singlePeptide.Protein.OneBasedPossibleLocalizedModifications.Where(b => b.Key >= singlePeptide.OneBasedStartResidueInProtein && b.Key <= singlePeptide.OneBasedEndResidueInProtein)) + var singlePeptide = psm.BestMatchingBioPolymersWithSetMods.First().Peptide; + foreach (var modInProtein in singlePeptide.Parent.OneBasedPossibleLocalizedModifications.Where(b => b.Key >= singlePeptide.OneBasedStartResidue && b.Key <= singlePeptide.OneBasedEndResidue)) foreach (var huh in modInProtein.Value) - modsOnProteins.Add((singlePeptide.Protein.Accession, huh.IdWithMotif, modInProtein.Key)); + modsOnProteins.Add((singlePeptide.Parent.Accession, huh.IdWithMotif, modInProtein.Key)); } // We do not want to double-count modifications. Hence the HashSet!!! HashSet<(string, string, int)> modsSeenAndLocalized = new HashSet<(string, string, int)>(); foreach (var psm in forUnambiguouslyLocalized) { - var singlePeptide = psm.BestMatchingPeptides.First().Peptide; + var singlePeptide = psm.BestMatchingBioPolymersWithSetMods.First().Peptide; foreach (var nice in singlePeptide.AllModsOneIsNterminus) { int locInProtein; if (nice.Key == 1) - locInProtein = singlePeptide.OneBasedStartResidueInProtein; + locInProtein = singlePeptide.OneBasedStartResidue; else if (nice.Key == singlePeptide.Length + 2) - locInProtein = singlePeptide.OneBasedEndResidueInProtein; + locInProtein = singlePeptide.OneBasedEndResidue; else - locInProtein = singlePeptide.OneBasedStartResidueInProtein + nice.Key - 2; - modsSeenAndLocalized.Add((singlePeptide.Protein.Accession, nice.Value.IdWithMotif, locInProtein)); + locInProtein = singlePeptide.OneBasedStartResidue + nice.Key - 2; + modsSeenAndLocalized.Add((singlePeptide.Parent.Accession, nice.Value.IdWithMotif, locInProtein)); } } diff --git a/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs b/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs index b35eb8f15..1426bd4aa 100644 --- a/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs @@ -22,13 +22,13 @@ public class NonSpecificEnzymeSearchEngine : ModernSearchEngine private readonly List[] PrecursorIndex; private readonly int MinimumPeptideLength; - readonly PeptideSpectralMatch[][] GlobalCategorySpecificPsms; + readonly SpectralMatch[][] GlobalCategorySpecificPsms; readonly CommonParameters ModifiedParametersNoComp; readonly List ProductTypesToSearch; readonly List VariableTerminalModifications; readonly List[] CoisolationIndex; - public NonSpecificEnzymeSearchEngine(PeptideSpectralMatch[][] globalPsms, Ms2ScanWithSpecificMass[] listOfSortedms2Scans, List[] coisolationIndex, + public NonSpecificEnzymeSearchEngine(SpectralMatch[][] globalPsms, Ms2ScanWithSpecificMass[] listOfSortedms2Scans, List[] coisolationIndex, List peptideIndex, List[] fragmentIndex, List[] precursorIndex, int currentPartition, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List variableModifications, MassDiffAcceptor massDiffAcceptor, double maximumMassThatFragmentIonScoreIsDoubled, List nestedIds) : base(null, listOfSortedms2Scans, peptideIndex, fragmentIndex, currentPartition, commonParameters, fileSpecificParameters, massDiffAcceptor, maximumMassThatFragmentIonScoreIsDoubled, nestedIds) @@ -136,7 +136,7 @@ protected override MetaMorpheusEngineResults RunSpecific() double thisScore = CalculatePeptideScore(scan.TheScan, matchedIons); if (thisScore > CommonParameters.ScoreCutoff) { - PeptideSpectralMatch[] localPeptideSpectralMatches = GlobalCategorySpecificPsms[(int)FdrClassifier.GetCleavageSpecificityCategory(peptide.CleavageSpecificityForFdrCategory)]; + SpectralMatch[] localPeptideSpectralMatches = GlobalCategorySpecificPsms[(int)FdrClassifier.GetCleavageSpecificityCategory(peptide.CleavageSpecificityForFdrCategory)]; if (localPeptideSpectralMatches[ms2ArrayIndex] == null) { localPeptideSpectralMatches[ms2ArrayIndex] = new PeptideSpectralMatch(peptide, notch, thisScore, ms2ArrayIndex, scan, CommonParameters, matchedIons); @@ -349,11 +349,11 @@ private Tuple Accepts(List fragments, PeptideWithSetModifications updatedPwsm = null; if (fragmentationTerminus == FragmentationTerminus.N) { - int endResidue = peptide.OneBasedStartResidueInProtein + fragment.FragmentNumber - 1; //-1 for one based index + int endResidue = peptide.OneBasedStartResidue + fragment.FragmentNumber - 1; //-1 for one based index Dictionary updatedMods = new Dictionary(); foreach (KeyValuePair mod in peptide.AllModsOneIsNterminus) { - if (mod.Key < endResidue - peptide.OneBasedStartResidueInProtein + 3) //check if we cleaved it off, +1 for N-terminus being mod 1 and first residue being mod 2, +1 again for the -1 on end residue for one based index, +1 (again) for the one-based start residue + if (mod.Key < endResidue - peptide.OneBasedStartResidue + 3) //check if we cleaved it off, +1 for N-terminus being mod 1 and first residue being mod 2, +1 again for the -1 on end residue for one based index, +1 (again) for the one-based start residue { updatedMods.Add(mod.Key, mod.Value); } @@ -362,13 +362,13 @@ private Tuple Accepts(List fragments, { updatedMods.Add(endResidue, terminalMod); } - updatedPwsm = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidueInProtein, endResidue, CleavageSpecificity.Unknown, "", 0, updatedMods, 0); + updatedPwsm = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidue, endResidue, CleavageSpecificity.Unknown, "", 0, updatedMods, 0); } else //if C terminal ions, shave off the n-terminus { - int startResidue = peptide.OneBasedEndResidueInProtein - fragment.FragmentNumber + 1; //plus one for one based index + int startResidue = peptide.OneBasedEndResidue - fragment.FragmentNumber + 1; //plus one for one based index Dictionary updatedMods = new Dictionary(); //updateMods - int indexShift = startResidue - peptide.OneBasedStartResidueInProtein; + int indexShift = startResidue - peptide.OneBasedStartResidue; foreach (KeyValuePair mod in peptide.AllModsOneIsNterminus) { if (mod.Key > indexShift + 1) //check if we cleaved it off, +1 for N-terminus being mod 1 and first residue being 2 @@ -381,7 +381,7 @@ private Tuple Accepts(List fragments, { updatedMods.Add(startResidue - 1, terminalMod); } - updatedPwsm = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, startResidue, peptide.OneBasedEndResidueInProtein, CleavageSpecificity.Unknown, "", 0, updatedMods, 0); + updatedPwsm = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, startResidue, peptide.OneBasedEndResidue, CleavageSpecificity.Unknown, "", 0, updatedMods, 0); } return new Tuple(notch, updatedPwsm); } @@ -399,7 +399,7 @@ private Tuple Accepts(List fragments, if (notch >= 0) { //need to update so that the cleavage specificity is recorded - PeptideWithSetModifications updatedPwsm = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidueInProtein, peptide.OneBasedEndResidueInProtein, CleavageSpecificity.Unknown, "", 0, peptide.AllModsOneIsNterminus, peptide.NumFixedMods); + PeptideWithSetModifications updatedPwsm = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidue, peptide.OneBasedEndResidue, CleavageSpecificity.Unknown, "", 0, peptide.AllModsOneIsNterminus, peptide.NumFixedMods); return new Tuple(notch, updatedPwsm); } else //try a terminal mod (if it exists) @@ -421,14 +421,14 @@ private Tuple Accepts(List fragments, //add the terminal mod if (fragmentationTerminus == FragmentationTerminus.N) { - updatedMods[peptide.OneBasedEndResidueInProtein] = terminalMod; + updatedMods[peptide.OneBasedEndResidue] = terminalMod; } else { - updatedMods[peptide.OneBasedStartResidueInProtein - 1] = terminalMod; + updatedMods[peptide.OneBasedStartResidue - 1] = terminalMod; } - PeptideWithSetModifications updatedPwsm = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidueInProtein, peptide.OneBasedEndResidueInProtein, CleavageSpecificity.Unknown, "", 0, updatedMods, peptide.NumFixedMods); + PeptideWithSetModifications updatedPwsm = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidue, peptide.OneBasedEndResidue, CleavageSpecificity.Unknown, "", 0, updatedMods, peptide.NumFixedMods); return new Tuple(notch, updatedPwsm); } } @@ -438,7 +438,7 @@ private Tuple Accepts(List fragments, return new Tuple(-1, null); } - public static List ResolveFdrCategorySpecificPsms(List[] AllPsms, int numNotches, string taskId, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters) + public static List ResolveFdrCategorySpecificPsms(List[] AllPsms, int numNotches, string taskId, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters) { //update all psms with peptide info AllPsms.ToList() @@ -446,13 +446,13 @@ public static List ResolveFdrCategorySpecificPsms(List psmArray.Where(psm => psm != null).ToList() .ForEach(psm => psm.ResolveAllAmbiguities())); - foreach (List psmsArray in AllPsms) + foreach (List psmsArray in AllPsms) { if (psmsArray != null) { - List cleanedPsmsArray = psmsArray.Where(b => b != null).OrderByDescending(b => b.Score) - .ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue) - .GroupBy(b => (b.FullFilePath, b.ScanNumber, b.PeptideMonisotopicMass)).Select(b => b.First()).ToList(); + List cleanedPsmsArray = psmsArray.Where(b => b != null).OrderByDescending(b => b.Score) + .ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue) + .GroupBy(b => (b.FullFilePath, b.ScanNumber, b.BioPolymerWithSetModsMonoisotopicMass)).Select(b => b.First()).ToList(); new FdrAnalysisEngine(cleanedPsmsArray, numNotches, commonParameters, fileSpecificParameters, new List { taskId }).Run(); @@ -495,19 +495,19 @@ public static List ResolveFdrCategorySpecificPsms(List majorCategoryPsms = AllPsms[majorCategoryIndex].Where(x => x != null).OrderByDescending(x => x.Score).ToList(); //get sorted major category + List majorCategoryPsms = AllPsms[majorCategoryIndex].Where(x => x != null).OrderByDescending(x => x.Score).ToList(); //get sorted major category for (int i = 0; i < indexesOfInterest.Count; i++) { int minorCategoryIndex = indexesOfInterest[i]; if (minorCategoryIndex != majorCategoryIndex) { - List minorCategoryPsms = AllPsms[minorCategoryIndex].Where(x => x != null).OrderByDescending(x => x.Score).ToList(); //get sorted minor category + List minorCategoryPsms = AllPsms[minorCategoryIndex].Where(x => x != null).OrderByDescending(x => x.Score).ToList(); //get sorted minor category int minorPsmIndex = 0; int majorPsmIndex = 0; while (minorPsmIndex < minorCategoryPsms.Count && majorPsmIndex < majorCategoryPsms.Count) //while in the lists { - PeptideSpectralMatch majorPsm = majorCategoryPsms[majorPsmIndex]; - PeptideSpectralMatch minorPsm = minorCategoryPsms[minorPsmIndex]; + SpectralMatch majorPsm = majorCategoryPsms[majorPsmIndex]; + SpectralMatch minorPsm = minorCategoryPsms[minorPsmIndex]; //major needs to be a lower score than the minor if (majorPsm.Score > minorPsm.Score) { @@ -525,8 +525,8 @@ public static List ResolveFdrCategorySpecificPsms(List minorPsm.FdrInfo.QValue) { minorPsm.FdrInfo.QValue = majorPsm.FdrInfo.QValue; @@ -537,15 +537,15 @@ public static List ResolveFdrCategorySpecificPsms(List bestPsmsList = new List(); + List bestPsmsList = new List(); for (int i = 0; i < numTotalSpectraWithPrecursors; i++) { - PeptideSpectralMatch bestPsm = null; + SpectralMatch bestPsm = null; double lowestQ = double.MaxValue; int bestIndex = -1; foreach (int index in indexesOfInterest) //foreach category { - PeptideSpectralMatch currentPsm = AllPsms[index][i]; + SpectralMatch currentPsm = AllPsms[index][i]; if (currentPsm != null) { double currentQValue = currentPsm.FdrInfo.QValue; @@ -575,12 +575,12 @@ public static List ResolveFdrCategorySpecificPsms(List psmsArray in AllPsms) + foreach (List psmsArray in AllPsms) { if (psmsArray != null) { - List cleanedPsmsArray = psmsArray.Where(b => b != null).OrderByDescending(b => b.Score) - .ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue) + List cleanedPsmsArray = psmsArray.Where(b => b != null).OrderByDescending(b => b.Score) + .ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue) .ToList(); new FdrAnalysisEngine(cleanedPsmsArray, numNotches, commonParameters, fileSpecificParameters, new List { taskId }).Run(); @@ -605,11 +605,11 @@ public static Dictionary> GetTerminalModPositions(Peptid //determine the start and end index ranges when considering the minimum peptide length int startResidue = nTerminus ? - peptide.OneBasedStartResidueInProtein + digestionParams.MinPeptideLength - 1 : - peptide.OneBasedStartResidueInProtein; + peptide.OneBasedStartResidue + digestionParams.MinPeptideLength - 1 : + peptide.OneBasedStartResidue; int endResidue = nTerminus ? - peptide.OneBasedEndResidueInProtein : - peptide.OneBasedEndResidueInProtein - digestionParams.MinPeptideLength + 1; + peptide.OneBasedEndResidue : + peptide.OneBasedEndResidue - digestionParams.MinPeptideLength + 1; string terminalStringToFind = nTerminus ? "C-terminal" : "N-terminal"; //if singleN, want to find c-terminal mods and vice-versa //get all the mods for this protein @@ -627,11 +627,11 @@ public static Dictionary> GetTerminalModPositions(Peptid { if (nTerminus) { - annotatedTerminalModDictionary.Add(index - peptide.OneBasedStartResidueInProtein + 1, terminalModsHere); + annotatedTerminalModDictionary.Add(index - peptide.OneBasedStartResidue + 1, terminalModsHere); } else { - annotatedTerminalModDictionary.Add(peptide.OneBasedEndResidueInProtein - index + 1, terminalModsHere); + annotatedTerminalModDictionary.Add(peptide.OneBasedEndResidue - index + 1, terminalModsHere); } } } diff --git a/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs b/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs index ba65d0c1a..89fd15e45 100644 --- a/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs @@ -1,400 +1,27 @@ using System; -using Chemistry; -using EngineLayer.FdrAnalysis; -using MassSpectrometry; -using Proteomics; -using Omics.Fragmentation; -using Proteomics.ProteolyticDigestion; using System.Collections.Generic; -using System.Collections.Immutable; using System.Linq; -using System.Runtime.CompilerServices; -using Easy.Common.Extensions; +using System.Text; +using System.Threading.Tasks; using Omics; +using Omics.Fragmentation; using Omics.Modifications; -using Proteomics.AminoAcidPolymer; -using ThermoFisher.CommonCore.Data; +using Proteomics.ProteolyticDigestion; +using Transcriptomics; namespace EngineLayer { - public class PeptideSpectralMatch + public class PeptideSpectralMatch : SpectralMatch { - public const double ToleranceForScoreDifferentiation = 1e-9; - protected List<(int Notch, PeptideWithSetModifications Pwsm)> _BestMatchingPeptides; - - public PeptideSpectralMatch(PeptideWithSetModifications peptide, int notch, double score, int scanIndex, Ms2ScanWithSpecificMass scan, CommonParameters commonParameters, List matchedFragmentIons, double xcorr = 0) - { - _BestMatchingPeptides = new List<(int, PeptideWithSetModifications)>(); - ScanIndex = scanIndex; - FullFilePath = scan.FullFilePath; - ScanNumber = scan.OneBasedScanNumber; - PrecursorScanNumber = scan.OneBasedPrecursorScanNumber; - ScanRetentionTime = scan.RetentionTime; - ScanExperimentalPeaks = scan.NumPeaks; - TotalIonCurrent = scan.TotalIonCurrent; - ScanPrecursorCharge = scan.PrecursorCharge; - ScanPrecursorMonoisotopicPeakMz = scan.PrecursorMonoisotopicPeakMz; - ScanPrecursorMass = scan.PrecursorMass; - DigestionParams = commonParameters.DigestionParams; - PeptidesToMatchingFragments = new Dictionary>(); - Xcorr = xcorr; - NativeId = scan.NativeId; - RunnerUpScore = commonParameters.ScoreCutoff; - MsDataScan = scan.TheScan; - SpectralAngle = -1; - - AddOrReplace(peptide, score, notch, true, matchedFragmentIons, xcorr); - } - - public MsDataScan MsDataScan { get; set; } - public ChemicalFormula ModsChemicalFormula { get; private set; } // these fields will be null if they are ambiguous - public string FullSequence { get; private set; } - public string EssentialSequence { get; private set; } - public int? Notch { get; private set; } - public string BaseSequence { get; private set; } - public int? PeptideLength { get; private set; } - public int? OneBasedStartResidueInProtein { get; private set; } - public int? OneBasedEndResidueInProtein { get; private set; } - public double? PeptideMonisotopicMass { get; private set; } - public int? ProteinLength { get; private set; } - public string ProteinAccession { get; private set; } - public string Organism { get; private set; } - public List MatchedFragmentIons { get; protected set; } - public int PsmCount { get; internal set; } - public Dictionary ModsIdentified { get; private set; } // these should never be null under normal circumstances - public List LocalizedScores { get; internal set; } - public int ScanNumber { get; } - public int? PrecursorScanNumber { get; } - public double ScanRetentionTime { get; } - public int ScanExperimentalPeaks { get; } - public double TotalIonCurrent { get; } - public int ScanPrecursorCharge { get; } - public double ScanPrecursorMonoisotopicPeakMz { get; } - public double ScanPrecursorMass { get; } - public string FullFilePath { get; private set; } - public int ScanIndex { get; } - public int NumDifferentMatchingPeptides { get { return _BestMatchingPeptides.Count; } } - public FdrInfo FdrInfo { get; private set; } - public PsmData PsmData_forPEPandPercolator { get; set; } - - public double Score { get; private set; } - public double Xcorr; - public double SpectralAngle { get; set; } - public string NativeId; // this is a property of the scan. used for mzID writing - - public double DeltaScore { get { return (Score - RunnerUpScore); } } - - public double RunnerUpScore { get; set; } - public bool IsDecoy { get; private set; } - public bool IsContaminant { get; private set; } - - //One-based positions in peptide that are covered by fragments on both sides of amino acids - public List FragmentCoveragePositionInPeptide { get; private set; } - - - public DigestionParams DigestionParams { get; } - public Dictionary> PeptidesToMatchingFragments { get; private set; } - - public IEnumerable<(int Notch, PeptideWithSetModifications Peptide)> BestMatchingPeptides - { - get - { - return _BestMatchingPeptides.OrderBy(p => p.Pwsm.FullSequence) - .ThenBy(p => p.Pwsm.Protein.Accession) - .ThenBy(p => p.Pwsm.OneBasedStartResidueInProtein); - } - } - - public static string GetTabSeparatedHeader() - { - return string.Join("\t", DataDictionary(null, null).Keys); - } - - public void AddOrReplace(PeptideWithSetModifications pwsm, double newScore, int notch, bool reportAllAmbiguity, List matchedFragmentIons, double newXcorr) - { - if (newScore - Score > ToleranceForScoreDifferentiation) //if new score beat the old score, overwrite it - { - _BestMatchingPeptides.Clear(); - _BestMatchingPeptides.Add((notch, pwsm)); - - if (Score - RunnerUpScore > ToleranceForScoreDifferentiation) - { - RunnerUpScore = Score; - } - - Score = newScore; - Xcorr = newXcorr; - - PeptidesToMatchingFragments.Clear(); - PeptidesToMatchingFragments.Add(pwsm, matchedFragmentIons); - } - else if (newScore - Score > -ToleranceForScoreDifferentiation && reportAllAmbiguity) //else if the same score and ambiguity is allowed - { - _BestMatchingPeptides.Add((notch, pwsm)); - - if (!PeptidesToMatchingFragments.ContainsKey(pwsm)) - { - PeptidesToMatchingFragments.Add(pwsm, matchedFragmentIons); - } - } - else if (newScore - RunnerUpScore > ToleranceForScoreDifferentiation) - { - RunnerUpScore = newScore; - } - } - - //PEP-Value analysis identifies ambiguous peptides with lower probability. These are removed from the bestmatchingpeptides dictionary, which lowers ambiguity. - public void RemoveThisAmbiguousPeptide(int notch, PeptideWithSetModifications pwsm) - { - _BestMatchingPeptides.Remove((notch, pwsm)); - if (!_BestMatchingPeptides.Any(x => x.Pwsm.Equals(pwsm))) - { - PeptidesToMatchingFragments.Remove(pwsm); - } - this.ResolveAllAmbiguities(); - } - - public override string ToString() - { - return ToString(new Dictionary()); - } - - public string ToString(IReadOnlyDictionary ModstoWritePruned) + public PeptideSpectralMatch(IBioPolymerWithSetMods peptide, int notch, double score, int scanIndex, + Ms2ScanWithSpecificMass scan, CommonParameters commonParameters, + List matchedFragmentIons, double xcorr = 0) : base(peptide, notch, score, scanIndex, + scan, commonParameters, matchedFragmentIons, xcorr) { - return string.Join("\t", DataDictionary(this, ModstoWritePruned).Values); - } - public static Dictionary DataDictionary(PeptideSpectralMatch psm, IReadOnlyDictionary ModsToWritePruned) - { - Dictionary s = new Dictionary(); - PsmTsvWriter.AddBasicMatchData(s, psm); - PsmTsvWriter.AddPeptideSequenceData(s, psm, ModsToWritePruned); - PsmTsvWriter.AddMatchedIonsData(s, psm?.MatchedFragmentIons); - PsmTsvWriter.AddMatchScoreData(s, psm); - return s; } - public void SetFdrValues(double cumulativeTarget, double cumulativeDecoy, double qValue, double cumulativeTargetNotch, double cumulativeDecoyNotch, double qValueNotch, double pep, double pepQValue) - { - FdrInfo = new FdrInfo - { - CumulativeTarget = cumulativeTarget, - CumulativeDecoy = cumulativeDecoy, - QValue = qValue, - CumulativeTargetNotch = cumulativeTargetNotch, - CumulativeDecoyNotch = cumulativeDecoyNotch, - QValueNotch = qValueNotch, - PEP = pep, - PEP_QValue = pepQValue - }; - } - - /// - /// This method saves properties of this PSM for internal use. It is NOT used for any output. - /// These resolved fields are (usually) null if there is more than one option. - /// e.g., if this PSM can be explained by more than one base sequence, the BaseSequence property will be null - /// - public void ResolveAllAmbiguities() - { - IsDecoy = _BestMatchingPeptides.Any(p => p.Pwsm.Protein.IsDecoy); - IsContaminant = _BestMatchingPeptides.Any(p => p.Pwsm.Protein.IsContaminant); - FullSequence = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.FullSequence)).ResolvedValue; - BaseSequence = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.BaseSequence)).ResolvedValue; - PeptideLength = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.Length)).ResolvedValue; - OneBasedStartResidueInProtein = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.OneBasedStartResidueInProtein)).ResolvedValue; - OneBasedEndResidueInProtein = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.OneBasedEndResidueInProtein)).ResolvedValue; - ProteinLength = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.Protein.Length)).ResolvedValue; - PeptideMonisotopicMass = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.MonoisotopicMass)).ResolvedValue; - ProteinAccession = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.Protein.Accession)).ResolvedValue; - Organism = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.Protein.Organism)).ResolvedValue; - ModsIdentified = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.AllModsOneIsNterminus)).ResolvedValue; - ModsChemicalFormula = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.AllModsOneIsNterminus.Select(c => (c.Value)))).ResolvedValue; - Notch = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Notch)).ResolvedValue; - - // if the PSM matches a target and a decoy and they are the SAME SEQUENCE, remove the decoy - if (IsDecoy) - { - bool removedPeptides = false; - var hits = _BestMatchingPeptides.GroupBy(p => p.Pwsm.FullSequence); - - foreach (var hit in hits) - { - if (hit.Any(p => p.Pwsm.Protein.IsDecoy) && hit.Any(p => !p.Pwsm.Protein.IsDecoy)) - { - // at least one peptide with this sequence is a target and at least one is a decoy - // remove the decoys with this sequence - var pwsmToRemove = _BestMatchingPeptides.Where(p => p.Pwsm.FullSequence == hit.Key && p.Pwsm.Protein.IsDecoy).ToList(); - _BestMatchingPeptides.RemoveAll(p => p.Pwsm.FullSequence == hit.Key && p.Pwsm.Protein.IsDecoy); - foreach ((int, PeptideWithSetModifications) pwsm in pwsmToRemove) - { - PeptidesToMatchingFragments.Remove(pwsm.Item2); - } - - removedPeptides = true; - } - } - - if (removedPeptides) - { - ResolveAllAmbiguities(); - } - } - - // TODO: technically, different peptide options for this PSM can have different matched ions - // we can write a Resolve method for this if we want... - MatchedFragmentIons = PeptidesToMatchingFragments.First().Value; - } - - public static int GetLongestIonSeriesBidirectional(Dictionary> PeptidesToMatchingFragments, PeptideWithSetModifications peptide) - { - List maxDiffs = new List { 1 }; - if (PeptidesToMatchingFragments != null && PeptidesToMatchingFragments.TryGetValue(peptide, out var matchedFragments) && matchedFragments != null && matchedFragments.Any()) - { - var jointSeries = matchedFragments.Select(p => p.NeutralTheoreticalProduct.AminoAcidPosition).Distinct().ToList(); - - if (jointSeries.Count > 0) - { - jointSeries.Sort(); - - List aminoAcidPostionsThatCouldBeObserved = Enumerable.Range(1, peptide.BaseSequence.Length).ToList(); - - List missing = aminoAcidPostionsThatCouldBeObserved.Except(jointSeries).ToList(); - - int localMaxDiff = 0; - for (int i = 0; i < aminoAcidPostionsThatCouldBeObserved.Count; i++) - { - if (!missing.Contains(aminoAcidPostionsThatCouldBeObserved[i])) - { - localMaxDiff++; - } - else - { - maxDiffs.Add(localMaxDiff); - localMaxDiff = 0; - } - } - maxDiffs.Add(localMaxDiff); - } - } - - return maxDiffs.Max(); - } - - /// - /// Determine the Fragment Coverage the PSM - /// Assigns fragment coverage indices for the PSM and the protein based on Amino Acid Position in Matched Ion Fragments - /// - public void GetAminoAcidCoverage() - { - if (string.IsNullOrEmpty(this.BaseSequence) || - !this.MatchedFragmentIons.Any()) return; - //Pull C terminal and N terminal Fragments and amino acid numbers - var nTermFragmentAAPositions = this.MatchedFragmentIons.Where(p => - p.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.N) - .Select(j => j.NeutralTheoreticalProduct.AminoAcidPosition).Distinct().ToList(); - - var cTermFragmentAAPositions = this.MatchedFragmentIons.Where(p => - p.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.C) - .Select(j => j.NeutralTheoreticalProduct.AminoAcidPosition).Distinct().ToList(); - - //Create a hashset to store the covered amino acid positions - HashSet fragmentCoveredAminoAcids = new(); - - //Check N term frags first - if (nTermFragmentAAPositions.Any()) - { - nTermFragmentAAPositions.Sort(); - - //if the final NFragment is present, last AA is covered - if (nTermFragmentAAPositions.Contains(this.BaseSequence.Length - 1)) - { - fragmentCoveredAminoAcids.Add(this.BaseSequence.Length); - } - - // if the first NFragment is present, first AA is covered - if (nTermFragmentAAPositions.Contains(1)) - { - fragmentCoveredAminoAcids.Add(1); - } - - //Check all amino acids except for the last one in the list - for (int i = 0; i < nTermFragmentAAPositions.Count - 1; i++) - { - //sequential AA, second one is covered - if (nTermFragmentAAPositions[i + 1] - nTermFragmentAAPositions[i] == 1) - { - fragmentCoveredAminoAcids.Add(nTermFragmentAAPositions[i + 1]); - } - - //check to see if the position is covered from both directions, inclusive - if (cTermFragmentAAPositions.Contains(nTermFragmentAAPositions[i + 1])) - { - fragmentCoveredAminoAcids.Add(nTermFragmentAAPositions[i + 1]); - } - - //check to see if the position is covered from both directions, exclusive - if (cTermFragmentAAPositions.Contains(nTermFragmentAAPositions[i + 1] + 2)) - { - fragmentCoveredAminoAcids.Add(nTermFragmentAAPositions[i + 1] + 1); - } - } - - } - - //Check C term frags - if (cTermFragmentAAPositions.Any()) - { - cTermFragmentAAPositions.Sort(); - - //if the second AA is present, the first AA is covered - if (cTermFragmentAAPositions.Contains(2)) - { - fragmentCoveredAminoAcids.Add(1); - } - - //if the last AA is present, the final AA is covered - if (cTermFragmentAAPositions.Contains(this.BaseSequence.Length)) - { - fragmentCoveredAminoAcids.Add(this.BaseSequence.Length); - } - - //check all amino acids except for the last one in the list - for (int i = 0; i < cTermFragmentAAPositions.Count - 1; i++) - { - //sequential AA, the first one is covered - if (cTermFragmentAAPositions[i + 1] - cTermFragmentAAPositions[i] == 1) - { - fragmentCoveredAminoAcids.Add(cTermFragmentAAPositions[i]); - } - } - } - - //store in PSM - var fragmentCoveredAminoAcidsList = fragmentCoveredAminoAcids.ToList(); - fragmentCoveredAminoAcidsList.Sort(); - this.FragmentCoveragePositionInPeptide = fragmentCoveredAminoAcidsList; - } - - public static int GetCountComplementaryIons(Dictionary> PeptidesToMatchingFragments, PeptideWithSetModifications peptide) - { - if (PeptidesToMatchingFragments != null && PeptidesToMatchingFragments.TryGetValue(peptide, out var matchedFragments) && matchedFragments != null && matchedFragments.Any()) - { - List nIons = matchedFragments.Where(f => f.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.N).Select(f => f.NeutralTheoreticalProduct.FragmentNumber).ToList(); - List cIons = matchedFragments.Where(f => f.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.C).Select(f => (peptide.BaseSequence.Length - f.NeutralTheoreticalProduct.FragmentNumber)).ToList(); - if (nIons.Any() && cIons.Any()) - { - return nIons.Intersect(cIons).Count(); - } - else - { - return 0; - } - } - else - { - return 0; - } - } + #region Silac /// /// This method changes the base and full sequences to reflect heavy silac labels @@ -403,103 +30,46 @@ public static int GetCountComplementaryIons(Dictionary labels, IReadOnlyDictionary modsToWritePruned) { //FullSequence - FullSequence = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.FullSequence)).ResolvedString; //string, not value + FullSequence = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.FullSequence)).ResolvedString; //string, not value FullSequence = SilacConversions.GetAmbiguousLightSequence(FullSequence, labels, false); //BaseSequence - BaseSequence = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.BaseSequence)).ResolvedString; //string, not value + BaseSequence = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.BaseSequence)).ResolvedString; //string, not value BaseSequence = SilacConversions.GetAmbiguousLightSequence(BaseSequence, labels, true); //EssentialSequence - EssentialSequence = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.EssentialSequence(modsToWritePruned))).ResolvedString; //string, not value + EssentialSequence = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.EssentialSequence(modsToWritePruned))).ResolvedString; //string, not value EssentialSequence = SilacConversions.GetAmbiguousLightSequence(EssentialSequence, labels, false); } - /// - /// This method is used by protein parsimony to remove PeptideWithSetModifications objects that have non-parsimonious protein associations - /// - public void TrimProteinMatches(HashSet parsimoniousProteins) - { - if (IsDecoy) - { - if (_BestMatchingPeptides.Any(p => parsimoniousProteins.Contains(p.Pwsm.Protein) && p.Pwsm.Protein.IsDecoy)) - { - _BestMatchingPeptides.RemoveAll(p => !parsimoniousProteins.Contains(p.Pwsm.Protein)); - } - // else do nothing - } - else - { - _BestMatchingPeptides.RemoveAll(p => !parsimoniousProteins.Contains(p.Pwsm.Protein)); - } - - ResolveAllAmbiguities(); - } - - /// - /// This method is used by protein parsimony to add PeptideWithSetModifications objects for modification-agnostic parsimony - /// - public void AddProteinMatch((int, PeptideWithSetModifications) peptideWithNotch, List mfi) - { - if (!_BestMatchingPeptides.Select(p => p.Pwsm).Contains(peptideWithNotch.Item2)) - { - _BestMatchingPeptides.Add(peptideWithNotch); - if (!PeptidesToMatchingFragments.ContainsKey(peptideWithNotch.Item2)) - { - PeptidesToMatchingFragments.Add(peptideWithNotch.Item2, mfi); - } - ResolveAllAmbiguities(); - } - } - /// /// This method is used by SILAC quantification to add heavy/light psms /// Don't have access to the scans at that point, so a new contructor is needed /// - public PeptideSpectralMatch Clone(List<(int Notch, PeptideWithSetModifications Peptide)> bestMatchingPeptides) + public PeptideSpectralMatch Clone(List<(int Notch, IBioPolymerWithSetMods Peptide)> bestMatchingPeptides) => new PeptideSpectralMatch(this, bestMatchingPeptides); + + protected PeptideSpectralMatch(SpectralMatch psm, List<(int Notch, IBioPolymerWithSetMods Peptide)> bestMatchingPeptides) + : base(psm, bestMatchingPeptides) { - return new PeptideSpectralMatch(this, bestMatchingPeptides); } - protected PeptideSpectralMatch(PeptideSpectralMatch psm, List<(int Notch, PeptideWithSetModifications Peptide)> bestMatchingPeptides) + #endregion + + } + + public class OligoSpectralMatch : SpectralMatch + { + public OligoSpectralMatch(IBioPolymerWithSetMods peptide, int notch, double score, int scanIndex, + Ms2ScanWithSpecificMass scan, CommonParameters commonParameters, + List matchedFragmentIons, double xcorr = 0) : base(peptide, notch, score, scanIndex, + scan, commonParameters, matchedFragmentIons, xcorr) { - _BestMatchingPeptides = bestMatchingPeptides; - BaseSequence = PsmTsvWriter.Resolve(bestMatchingPeptides.Select(b => b.Peptide.BaseSequence)).ResolvedValue; - FullSequence = PsmTsvWriter.Resolve(bestMatchingPeptides.Select(b => b.Peptide.FullSequence)).ResolvedValue; - ModsChemicalFormula = psm.ModsChemicalFormula; - Notch = psm.Notch; - PeptideLength = psm.PeptideLength; - OneBasedStartResidueInProtein = psm.OneBasedStartResidueInProtein; - OneBasedEndResidueInProtein = psm.OneBasedEndResidueInProtein; - PeptideMonisotopicMass = psm.PeptideMonisotopicMass; - ProteinLength = psm.ProteinLength; - ProteinAccession = psm.ProteinAccession; - Organism = psm.Organism; - MatchedFragmentIons = psm.MatchedFragmentIons; - PsmCount = psm.PsmCount; - ModsIdentified = psm.ModsIdentified; - LocalizedScores = psm.LocalizedScores; - ScanNumber = psm.ScanNumber; - PrecursorScanNumber = psm.PrecursorScanNumber; - ScanRetentionTime = psm.ScanRetentionTime; - ScanExperimentalPeaks = psm.ScanExperimentalPeaks; - TotalIonCurrent = psm.TotalIonCurrent; - ScanPrecursorCharge = psm.ScanPrecursorCharge; - ScanPrecursorMonoisotopicPeakMz = psm.ScanPrecursorMonoisotopicPeakMz; - ScanPrecursorMass = psm.ScanPrecursorMass; - FullFilePath = psm.FullFilePath; - ScanIndex = psm.ScanIndex; - FdrInfo = psm.FdrInfo; - Score = psm.Score; - Xcorr = psm.Xcorr; - RunnerUpScore = psm.RunnerUpScore; - IsDecoy = psm.IsDecoy; - IsContaminant = psm.IsContaminant; - DigestionParams = psm.DigestionParams; - PeptidesToMatchingFragments = psm.PeptidesToMatchingFragments; - SpectralAngle = psm.SpectralAngle; } + protected OligoSpectralMatch(SpectralMatch psm, List<(int Notch, IBioPolymerWithSetMods Peptide)> bestMatchingPeptides) + : base(psm, bestMatchingPeptides) + { + } } -} \ No newline at end of file +} diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs index 64d4f7b5f..180a4f1a8 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs @@ -1,10 +1,11 @@ -using Proteomics.ProteolyticDigestion; +using Omics; +using Proteomics.ProteolyticDigestion; namespace EngineLayer.ProteinParsimony { internal class ParsimonySequence { - public ParsimonySequence(PeptideWithSetModifications pwsm, bool TreatModPeptidesAsDifferentPeptides) + public ParsimonySequence(IBioPolymerWithSetMods pwsm, bool TreatModPeptidesAsDifferentPeptides) { Sequence = TreatModPeptidesAsDifferentPeptides ? pwsm.FullSequence : pwsm.BaseSequence; Protease = pwsm.DigestionParams.DigestionAgent as Protease ?? throw new MetaMorpheusException("Digestion agent is not of type protease"); diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs index b8252a28c..e882391b0 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinGroup.cs @@ -20,7 +20,7 @@ public ProteinGroup(HashSet proteins, HashSet p.Accession)); AllPeptides = peptides; UniquePeptides = uniquePeptides; - AllPsmsBelowOnePercentFDR = new HashSet(); + AllPsmsBelowOnePercentFDR = new HashSet(); SequenceCoverageFraction = new List(); SequenceCoverageDisplayList = new List(); SequenceCoverageDisplayListWithMods = new List(); @@ -65,7 +65,7 @@ public ProteinGroup(HashSet proteins, HashSet UniquePeptides { get; set; } - public HashSet AllPsmsBelowOnePercentFDR { get; set; } + public HashSet AllPsmsBelowOnePercentFDR { get; set; } public List SequenceCoverageFraction { get; private set; } @@ -404,7 +404,7 @@ public void CalculateSequenceCoverage() { psm.GetAminoAcidCoverage(); - foreach (var peptide in psm.BestMatchingPeptides.Select(psm => psm.Peptide).DistinctBy(pep => pep.FullSequence)) + foreach (var peptide in psm.BestMatchingBioPolymersWithSetMods.Select(psm => psm.Peptide as PeptideWithSetModifications).DistinctBy(pep => pep.FullSequence)) { // might be unambiguous but also shared; make sure this protein group contains this peptide+protein combo if (Proteins.Contains(peptide.Protein)) @@ -430,13 +430,13 @@ public void CalculateSequenceCoverage() HashSet coveredResiduesInProteinOneBased = new(); //loop through PSMs - foreach (PeptideSpectralMatch psm in AllPsmsBelowOnePercentFDR.Where(psm => psm.BaseSequence != null)) + foreach (SpectralMatch psm in AllPsmsBelowOnePercentFDR.Where(psm => psm.BaseSequence != null)) { //Calculate the covered bases within the psm. This is one based numbering for the peptide only psm.GetAminoAcidCoverage(); if (psm.FragmentCoveragePositionInPeptide == null) continue; //loop through each peptide within the psm - IEnumerable pwsms = psm.BestMatchingPeptides.Select(p => p.Peptide) + IEnumerable pwsms = psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide as PeptideWithSetModifications) .Where(p => p.Protein.Accession == protein.Accession); foreach (PeptideWithSetModifications pwsm in pwsms) { @@ -445,7 +445,7 @@ public void CalculateSequenceCoverage() //add the peptide start position within the protein to each covered index of the psm foreach (var position in psm.FragmentCoveragePositionInPeptide) { - coveredResiduesInPeptide.Add(position + pwsm.OneBasedStartResidueInProtein - + coveredResiduesInPeptide.Add(position + pwsm.OneBasedStartResidue - 1); //subtract one because these are both one based } @@ -472,7 +472,7 @@ public void CalculateSequenceCoverage() // get residue numbers of each peptide in the protein and identify them as observed if the sequence is unambiguous foreach (var peptide in proteinsWithUnambigSeqPsms[protein]) { - for (int i = peptide.OneBasedStartResidueInProtein; i <= peptide.OneBasedEndResidueInProtein; i++) + for (int i = peptide.OneBasedStartResidue; i <= peptide.OneBasedEndResidue; i++) { coveredOneBasedResidues.Add(i); } @@ -509,7 +509,7 @@ public void CalculateSequenceCoverage() && !mod.Value.ModificationType.Contains("Common Fixed")) { modsOnThisProtein.Add( - new KeyValuePair(pep.OneBasedStartResidueInProtein + mod.Key - 2, + new KeyValuePair(pep.OneBasedStartResidue + mod.Key - 2, mod.Value)); } } @@ -572,7 +572,7 @@ public void CalculateSequenceCoverage() } else if (mod.Value.LocationRestriction.Equals("Anywhere.")) { - indexInProtein = pep.OneBasedStartResidueInProtein + mod.Key - 2; + indexInProtein = pep.OneBasedStartResidue + mod.Key - 2; } else if (mod.Value.LocationRestriction.Equals("C-terminal.")) { @@ -595,8 +595,8 @@ public void CalculateSequenceCoverage() modIndex.Add(modKey); foreach (var pept in proteinsWithPsmsWithLocalizedMods[protein]) { - if (indexInProtein >= pept.OneBasedStartResidueInProtein - (indexInProtein == 1 ? 1 : 0) - && indexInProtein <= pept.OneBasedEndResidueInProtein) + if (indexInProtein >= pept.OneBasedStartResidue - (indexInProtein == 1 ? 1 : 0) + && indexInProtein <= pept.OneBasedEndResidue) { pepNumTotal += 1; } @@ -644,11 +644,11 @@ public void MergeProteinGroupWith(ProteinGroup other) public ProteinGroup ConstructSubsetProteinGroup(string fullFilePath, List silacLabels = null) { var allPsmsForThisFile = - new HashSet( + new HashSet( AllPsmsBelowOnePercentFDR.Where(p => p.FullFilePath.Equals(fullFilePath))); var allPeptidesForThisFile = new HashSet( - allPsmsForThisFile.SelectMany(p => p.BestMatchingPeptides.Select(v => v.Peptide))); + allPsmsForThisFile.SelectMany(p => p.BestMatchingBioPolymersWithSetMods.Select(v => v.Peptide as PeptideWithSetModifications))); var allUniquePeptidesForThisFile = new HashSet(UniquePeptides.Intersect(allPeptidesForThisFile)); diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs index 6139fcd7c..d57cc666b 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs @@ -5,7 +5,9 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Reflection.Metadata.Ecma335; using System.Threading.Tasks; +using Omics; using IDigestionParams = Omics.Digestion.IDigestionParams; namespace EngineLayer @@ -15,10 +17,10 @@ public class ProteinParsimonyEngine : MetaMorpheusEngine /// /// All peptides meeting the prefiltering criteria for parsimony (e.g., peptides from non-ambiguous high-confidence PSMs) /// - private readonly HashSet _fdrFilteredPeptides; + private readonly HashSet _fdrFilteredPeptides; - private readonly List _fdrFilteredPsms; - private readonly List _allPsms; + private readonly List _fdrFilteredPsms; + private readonly List _allPsms; private const double FdrCutoffForParsimony = 0.01; /// @@ -26,13 +28,13 @@ public class ProteinParsimonyEngine : MetaMorpheusEngine /// private readonly bool _treatModPeptidesAsDifferentPeptides; - public ProteinParsimonyEngine(List allPsms, bool modPeptidesAreDifferent, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) + public ProteinParsimonyEngine(List allPsms, bool modPeptidesAreDifferent, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) { _treatModPeptidesAsDifferentPeptides = modPeptidesAreDifferent; if (!allPsms.Any()) { - _fdrFilteredPsms = new List(); + _fdrFilteredPsms = new List(); } // parsimony will only use non-ambiguous, high-confidence PSMs @@ -47,10 +49,10 @@ public ProteinParsimonyEngine(List allPsms, bool modPeptid } // peptides to use in parsimony = peptides observed in high-confidence PSMs (including decoys) - _fdrFilteredPeptides = new HashSet(); + _fdrFilteredPeptides = new HashSet(); foreach (var psm in _fdrFilteredPsms) { - foreach (var peptide in psm.BestMatchingPeptides.Select(p => p.Peptide)) + foreach (var peptide in psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide)) { _fdrFilteredPeptides.Add(peptide); } @@ -96,18 +98,18 @@ private List RunProteinParsimonyEngine() { foreach (var protease in _fdrFilteredPsms.GroupBy(p => p.DigestionParams.Protease)) { - Dictionary> sequenceWithPsms = new Dictionary>(); + Dictionary> sequenceWithPsms = new Dictionary>(); // for each protease, match the base sequence of each peptide to its PSMs - foreach (PeptideSpectralMatch psm in protease) + foreach (SpectralMatch psm in protease) { - if (sequenceWithPsms.TryGetValue(psm.BaseSequence, out List peptidesForThisBaseSequence)) + if (sequenceWithPsms.TryGetValue(psm.BaseSequence, out List peptidesForThisBaseSequence)) { peptidesForThisBaseSequence.Add(psm); } else { - sequenceWithPsms[psm.BaseSequence] = new List { psm }; + sequenceWithPsms[psm.BaseSequence] = new List { psm }; } } @@ -122,7 +124,7 @@ private List RunProteinParsimonyEngine() { var baseSequence = sequenceWithPsmsList[i]; - var peptidesWithNotchInfo = baseSequence.Value.SelectMany(p => p.BestMatchingPeptides).Distinct().ToList(); + var peptidesWithNotchInfo = baseSequence.Value.SelectMany(p => p.BestMatchingBioPolymersWithSetMods).Distinct().ToList(); // if the base seq has >1 PeptideWithSetMods object and has >0 mods, it might need to be matched to new proteins if (peptidesWithNotchInfo.Count > 1 && peptidesWithNotchInfo.Any(p => p.Peptide.NumMods > 0)) @@ -130,7 +132,7 @@ private List RunProteinParsimonyEngine() bool needToAddPeptideToProteinAssociations = false; // numProteinsForThisBaseSequence is the total number of proteins that this base sequence is a digestion product of - int numProteinsForThisBaseSequence = peptidesWithNotchInfo.Select(p => p.Peptide.Protein).Distinct().Count(); + int numProteinsForThisBaseSequence = peptidesWithNotchInfo.Select(p => p.Peptide.Parent).Distinct().Count(); if (numProteinsForThisBaseSequence == 1) { @@ -140,7 +142,7 @@ private List RunProteinParsimonyEngine() foreach (var psm in baseSequence.Value) { // numProteinsForThisPsm is the number of proteins that this PSM's peptides are associated with - int numProteinsForThisPsm = psm.BestMatchingPeptides.Select(p => p.Peptide.Protein).Distinct().Count(); + int numProteinsForThisPsm = psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide.Parent).Distinct().Count(); if (numProteinsForThisPsm != numProteinsForThisBaseSequence) { @@ -160,19 +162,19 @@ private List RunProteinParsimonyEngine() (IDigestionParams DigestParams, int OneBasedStart, int OneBasedEnd, int MissedCleavages, int Notch, Omics.Digestion.CleavageSpecificity CleavageSpecificity)>(); - foreach (PeptideSpectralMatch psm in baseSequence.Value) + foreach (SpectralMatch psm in baseSequence.Value) { - foreach (var peptideWithNotch in psm.BestMatchingPeptides) + foreach (var peptideWithNotch in psm.BestMatchingBioPolymersWithSetMods) { - PeptideWithSetModifications peptide = peptideWithNotch.Peptide; + PeptideWithSetModifications peptide = peptideWithNotch.Peptide as PeptideWithSetModifications; Protein protein = peptide.Protein; if (!proteinToPeptideInfo.ContainsKey(protein)) { proteinToPeptideInfo.Add(protein, (peptideWithNotch.Peptide.DigestionParams, - peptideWithNotch.Peptide.OneBasedStartResidueInProtein, - peptideWithNotch.Peptide.OneBasedEndResidueInProtein, + peptideWithNotch.Peptide.OneBasedStartResidue, + peptideWithNotch.Peptide.OneBasedEndResidue, peptideWithNotch.Peptide.MissedCleavages, peptideWithNotch.Notch, peptideWithNotch.Peptide.CleavageSpecificityForFdrCategory)); @@ -183,9 +185,9 @@ private List RunProteinParsimonyEngine() // create any new associations that need to be made foreach (PeptideSpectralMatch psm in baseSequence.Value) { - PeptideWithSetModifications originalPeptide = psm.BestMatchingPeptides.First().Peptide; - List mfi = psm.PeptidesToMatchingFragments[originalPeptide]; - HashSet psmProteins = new HashSet(psm.BestMatchingPeptides.Select(p => p.Peptide.Protein)); + IBioPolymerWithSetMods originalPeptide = psm.BestMatchingBioPolymersWithSetMods.First().Peptide; + List mfi = psm.BioPolymersWithSetModsToMatchingFragments[originalPeptide]; + HashSet psmProteins = new HashSet(psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide.Parent as Protein)); foreach (var proteinWithDigestInfo in proteinToPeptideInfo) { @@ -197,7 +199,7 @@ private List RunProteinParsimonyEngine() proteinWithDigestInfo.Value.OneBasedStart, proteinWithDigestInfo.Value.OneBasedEnd, proteinWithDigestInfo.Value.CleavageSpecificity, - originalPeptide.PeptideDescription, + originalPeptide.Description, proteinWithDigestInfo.Value.MissedCleavages, originalPeptide.AllModsOneIsNterminus, originalPeptide.NumFixedMods); @@ -276,23 +278,27 @@ private List RunProteinParsimonyEngine() foreach (var peptide in _fdrFilteredPeptides) { ParsimonySequence sequence = new ParsimonySequence(peptide, _treatModPeptidesAsDifferentPeptides); + if (peptide.Parent is not Protein protein) + { + continue; + } if (peptideSequenceToProteins.TryGetValue(sequence, out List proteinsForThisPeptideSequence)) { - proteinsForThisPeptideSequence.Add(peptide.Protein); + proteinsForThisPeptideSequence.Add(protein); } else { - peptideSequenceToProteins.Add(sequence, new List { peptide.Protein }); + peptideSequenceToProteins.Add(sequence, new List { protein }); } - if (proteinToPepSeqMatch.TryGetValue(peptide.Protein, out var peptideSequences)) + if (proteinToPepSeqMatch.TryGetValue(protein, out var peptideSequences)) { peptideSequences.Add(sequence); } else { - proteinToPepSeqMatch.Add(peptide.Protein, new HashSet { sequence }); + proteinToPepSeqMatch.Add(protein, new HashSet { sequence }); } } @@ -421,12 +427,12 @@ private List RunProteinParsimonyEngine() } // Parsimony stage 5: remove peptide objects that do not have proteins in the parsimonious list - foreach (PeptideSpectralMatch psm in _allPsms) + foreach (SpectralMatch psm in _allPsms) { // if this PSM has a protein in the parsimonious list, it removes the proteins NOT in the parsimonious list // otherwise, no proteins are removed (i.e., for PSMs that cannot be explained by a parsimonious protein, // no protein associations are removed) - if (psm.BestMatchingPeptides.Any(p => parsimoniousProteinList.Contains(p.Peptide.Protein))) + if (psm.BestMatchingBioPolymersWithSetMods.Any(p => parsimoniousProteinList.Contains(p.Peptide.Parent as Protein))) { psm.TrimProteinMatches(parsimoniousProteinList); } @@ -449,8 +455,9 @@ private List ConstructProteinGroups(HashSet proteinGroups = new List(); var proteinToPeptidesMatching = new Dictionary>(); - foreach (var peptide in _fdrFilteredPeptides) + foreach (var bioPolymerWithSetMods in _fdrFilteredPeptides) { + var peptide = (PeptideWithSetModifications)bioPolymerWithSetMods; if (proteinToPeptidesMatching.TryGetValue(peptide.Protein, out HashSet peptidesHere)) { peptidesHere.Add(peptide); diff --git a/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs b/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs index 28924565d..d1459cc87 100644 --- a/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs +++ b/MetaMorpheus/EngineLayer/ProteinScoringAndFdr/ProteinScoringAndFdrEngine.cs @@ -1,18 +1,19 @@ using Proteomics.ProteolyticDigestion; using System.Collections.Generic; using System.Linq; +using Omics; namespace EngineLayer { public class ProteinScoringAndFdrEngine : MetaMorpheusEngine { - private readonly IEnumerable NewPsms; + private readonly IEnumerable NewPsms; private readonly bool NoOneHitWonders; private readonly bool TreatModPeptidesAsDifferentPeptides; private readonly bool MergeIndistinguishableProteinGroups; private readonly List ProteinGroups; - public ProteinScoringAndFdrEngine(List proteinGroups, List newPsms, bool noOneHitWonders, bool treatModPeptidesAsDifferentPeptides, bool mergeIndistinguishableProteinGroups, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) + public ProteinScoringAndFdrEngine(List proteinGroups, List newPsms, bool noOneHitWonders, bool treatModPeptidesAsDifferentPeptides, bool mergeIndistinguishableProteinGroups, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds) : base(commonParameters, fileSpecificParameters, nestedIds) { NewPsms = newPsms; ProteinGroups = proteinGroups; @@ -35,20 +36,20 @@ protected override MetaMorpheusEngineResults RunSpecific() return proteinGroupName.Contains("DECOY_") ? proteinGroupName.Replace("DECOY_", "") : proteinGroupName; } - private void ScoreProteinGroups(List proteinGroups, IEnumerable psmList) + private void ScoreProteinGroups(List proteinGroups, IEnumerable psmList) { // add each protein groups PSMs - var peptideToPsmMatching = new Dictionary>(); + var peptideToPsmMatching = new Dictionary>(); foreach (var psm in psmList) { if (psm.FdrInfo.QValueNotch <= 0.01 && psm.FdrInfo.QValue <= 0.01) { if ((TreatModPeptidesAsDifferentPeptides && psm.FullSequence != null) || (!TreatModPeptidesAsDifferentPeptides && psm.BaseSequence != null)) { - foreach (var pepWithSetMods in psm.BestMatchingPeptides.Select(p => p.Peptide)) + foreach (var pepWithSetMods in psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide)) { - if (!peptideToPsmMatching.TryGetValue(pepWithSetMods, out HashSet psmsForThisPeptide)) - peptideToPsmMatching.Add(pepWithSetMods, new HashSet { psm }); + if (!peptideToPsmMatching.TryGetValue(pepWithSetMods, out HashSet psmsForThisPeptide)) + peptideToPsmMatching.Add(pepWithSetMods, new HashSet { psm }); else psmsForThisPeptide.Add(psm); } @@ -62,7 +63,7 @@ private void ScoreProteinGroups(List proteinGroups, IEnumerable psms)) + if (peptideToPsmMatching.TryGetValue(peptide, out HashSet psms)) proteinGroup.AllPsmsBelowOnePercentFDR.UnionWith(psms); else pepsToRemove.Add(peptide); diff --git a/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvReader.cs b/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvReader.cs index 3f7f6d7d5..524805427 100644 --- a/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvReader.cs +++ b/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvReader.cs @@ -44,7 +44,7 @@ public static List ReadTsv(string filePath, out List warning { psms.Add(new PsmFromTsv(line, Split, parsedHeader)); } - catch (Exception) + catch (Exception e) { warnings.Add("Could not read line: " + lineCount); } diff --git a/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs b/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs index fa2dfbb54..786b72c3b 100644 --- a/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs +++ b/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs @@ -176,7 +176,7 @@ internal static (string ResolvedString, string ResolvedValue) Resolve(IEnumerabl } } - internal static void AddBasicMatchData(Dictionary s, PeptideSpectralMatch psm) + internal static void AddBasicMatchData(Dictionary s, SpectralMatch psm) { s[PsmTsvHeader.FileName] = psm == null ? " " : Path.GetFileNameWithoutExtension(psm.FullFilePath); s[PsmTsvHeader.Ms2ScanNumber] = psm == null ? " " : psm.ScanNumber.ToString(CultureInfo.InvariantCulture); @@ -189,21 +189,21 @@ internal static void AddBasicMatchData(Dictionary s, PeptideSpec s[PsmTsvHeader.PrecursorMass] = psm == null ? " " : psm.ScanPrecursorMass.ToString("F5", CultureInfo.InvariantCulture); s[PsmTsvHeader.Score] = psm == null ? " " : psm.Score.ToString("F3", CultureInfo.InvariantCulture); s[PsmTsvHeader.DeltaScore] = psm == null ? " " : psm.DeltaScore.ToString("F3", CultureInfo.InvariantCulture); - s[PsmTsvHeader.Notch] = psm == null ? " " : Resolve(psm.BestMatchingPeptides.Select(p => p.Notch)).ResolvedString; + s[PsmTsvHeader.Notch] = psm == null ? " " : Resolve(psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Notch)).ResolvedString; } - internal static void AddPeptideSequenceData(Dictionary s, PeptideSpectralMatch psm, IReadOnlyDictionary ModsToWritePruned) + internal static void AddPeptideSequenceData(Dictionary s, SpectralMatch sm, IReadOnlyDictionary ModsToWritePruned) { - bool pepWithModsIsNull = psm == null || psm.BestMatchingPeptides == null || !psm.BestMatchingPeptides.Any(); + bool pepWithModsIsNull = sm == null || sm.BestMatchingBioPolymersWithSetMods == null || !sm.BestMatchingBioPolymersWithSetMods.Any(); - List pepsWithMods = pepWithModsIsNull ? null : psm.BestMatchingPeptides.Select(p => p.Peptide).ToList(); + List pepsWithMods = pepWithModsIsNull ? null : sm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).ToList(); - s[PsmTsvHeader.BaseSequence] = pepWithModsIsNull ? " " : (psm.BaseSequence ?? Resolve(pepWithModsIsNull ? null : pepsWithMods.Select(b => b.BaseSequence)).ResolvedString); - s[PsmTsvHeader.FullSequence] = pepWithModsIsNull ? " " : (psm.FullSequence != null ? psm.FullSequence : Resolve(pepWithModsIsNull ? null : pepsWithMods.Select(b => b.FullSequence)).ResolvedString); - s[PsmTsvHeader.EssentialSequence] = pepWithModsIsNull ? " " : (psm.EssentialSequence != null ? psm.EssentialSequence : Resolve(pepWithModsIsNull ? null : pepsWithMods.Select(b => b.EssentialSequence(ModsToWritePruned))).ResolvedString); - string geneString = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => string.Join(", ", b.Protein.GeneNames.Select(d => $"{d.Item1}:{d.Item2}"))), psm.FullSequence).ResolvedString; + s[PsmTsvHeader.BaseSequence] = pepWithModsIsNull ? " " : (sm.BaseSequence ?? Resolve(pepWithModsIsNull ? null : pepsWithMods.Select(b => b.BaseSequence)).ResolvedString); + s[PsmTsvHeader.FullSequence] = pepWithModsIsNull ? " " : (sm.FullSequence != null ? sm.FullSequence : Resolve(pepWithModsIsNull ? null : pepsWithMods.Select(b => b.FullSequence)).ResolvedString); + s[PsmTsvHeader.EssentialSequence] = pepWithModsIsNull ? " " : (sm.EssentialSequence != null ? sm.EssentialSequence : Resolve(pepWithModsIsNull ? null : pepsWithMods.Select(b => b.EssentialSequence(ModsToWritePruned))).ResolvedString); + string geneString = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => string.Join(", ", b.Parent.GeneNames.Select(d => $"{d.Item1}:{d.Item2}"))), sm.FullSequence).ResolvedString; s[PsmTsvHeader.AmbiguityLevel] = ProteoformLevelClassifier.ClassifyPrSM(s[PsmTsvHeader.FullSequence], geneString); - s[PsmTsvHeader.PsmCount] = pepWithModsIsNull ? " " : psm.PsmCount.ToString(); + s[PsmTsvHeader.PsmCount] = pepWithModsIsNull ? " " : sm.PsmCount.ToString(); s[PsmTsvHeader.Mods] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.AllModsOneIsNterminus)).ResolvedString; s[PsmTsvHeader.ModsChemicalFormulas] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(p => p.AllModsOneIsNterminus.Select(v => v.Value))).ResolvedString; @@ -211,31 +211,38 @@ internal static void AddPeptideSequenceData(Dictionary s, Peptid s[PsmTsvHeader.NumVariableMods] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.NumVariableMods)).ResolvedString; s[PsmTsvHeader.MissedCleavages] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.MissedCleavages.ToString(CultureInfo.InvariantCulture))).ResolvedString; s[PsmTsvHeader.PeptideMonoMass] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.MonoisotopicMass)).ResolvedString; - s[PsmTsvHeader.MassDiffDa] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => psm.ScanPrecursorMass - b.MonoisotopicMass)).ResolvedString; - s[PsmTsvHeader.MassDiffPpm] = pepWithModsIsNull ? " " : ResolveF2(pepsWithMods.Select(b => ((psm.ScanPrecursorMass - b.MonoisotopicMass) / b.MonoisotopicMass * 1e6))).ResolvedString; - s[PsmTsvHeader.ProteinAccession] = pepWithModsIsNull ? " " : (psm.ProteinAccession != null ? psm.ProteinAccession : Resolve(pepsWithMods.Select(b => b.Protein.Accession), psm.FullSequence).ResolvedString); - s[PsmTsvHeader.ProteinName] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Protein.FullName), psm.FullSequence).ResolvedString; + s[PsmTsvHeader.MassDiffDa] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => sm.ScanPrecursorMass - b.MonoisotopicMass)).ResolvedString; + s[PsmTsvHeader.MassDiffPpm] = pepWithModsIsNull ? " " : ResolveF2(pepsWithMods.Select(b => ((sm.ScanPrecursorMass - b.MonoisotopicMass) / b.MonoisotopicMass * 1e6))).ResolvedString; + s[PsmTsvHeader.ProteinAccession] = pepWithModsIsNull ? " " : (sm.Accession != null ? sm.Accession : Resolve(pepsWithMods.Select(b => b.Parent.Accession), sm.FullSequence).ResolvedString); + s[PsmTsvHeader.ProteinName] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Parent.FullName), sm.FullSequence).ResolvedString; s[PsmTsvHeader.GeneName] = geneString; - s[PsmTsvHeader.OrganismName] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Protein.Organism)).ResolvedString; - s[PsmTsvHeader.IdentifiedSequenceVariations] = pepWithModsIsNull ? " " : - Resolve(pepsWithMods.Select(b => string.Join(", ", b.Protein.AppliedSequenceVariations - .Where(av => b.IntersectsAndIdentifiesVariation(av).identifies) - .Select(av => b.SequenceVariantString(av, b.IntersectsAndIdentifiesVariation(av).intersects))))).ResolvedString; - s[PsmTsvHeader.SpliceSites] = pepWithModsIsNull ? " " : - Resolve(pepsWithMods.Select(b => string.Join(", ", b.Protein.SpliceSites - .Where(d => Includes(b, d)) - .Select(d => $"{d.OneBasedBeginPosition.ToString()}-{d.OneBasedEndPosition.ToString()}")))).ResolvedString; - s[PsmTsvHeader.Contaminant] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Protein.IsContaminant ? "Y" : "N")).ResolvedString; - s[PsmTsvHeader.Decoy] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Protein.IsDecoy ? "Y" : "N")).ResolvedString; - s[PsmTsvHeader.PeptideDesicription] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.PeptideDescription)).ResolvedString; + s[PsmTsvHeader.OrganismName] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Parent.Organism)).ResolvedString; + + if (sm is PeptideSpectralMatch psm || sm is null) + { + s[PsmTsvHeader.IdentifiedSequenceVariations] = pepWithModsIsNull ? " " : + Resolve(pepsWithMods.Select(p => p as PeptideWithSetModifications) + .Select(b => string.Join(", ", b.Protein.AppliedSequenceVariations + .Where(av => b.IntersectsAndIdentifiesVariation(av).identifies) + .Select(av => b.SequenceVariantString(av, b.IntersectsAndIdentifiesVariation(av).intersects))))).ResolvedString; + s[PsmTsvHeader.SpliceSites] = pepWithModsIsNull ? " " : + Resolve(pepsWithMods.Select(p => p as PeptideWithSetModifications) + .Select(b => string.Join(", ", b.Protein.SpliceSites + .Where(d => Includes(b, d)) + .Select(d => $"{d.OneBasedBeginPosition.ToString()}-{d.OneBasedEndPosition.ToString()}")))).ResolvedString; + } + + s[PsmTsvHeader.Contaminant] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Parent.IsContaminant ? "Y" : "N")).ResolvedString; + s[PsmTsvHeader.Decoy] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Parent.IsDecoy ? "Y" : "N")).ResolvedString; + s[PsmTsvHeader.PeptideDesicription] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Description)).ResolvedString; s[PsmTsvHeader.StartAndEndResiduesInProtein] = pepWithModsIsNull ? " " : - Resolve(pepsWithMods.Select(b => ($"[{b.OneBasedStartResidueInProtein.ToString(CultureInfo.InvariantCulture)} to {b.OneBasedEndResidueInProtein.ToString(CultureInfo.InvariantCulture)}]")), psm.FullSequence).ResolvedString; - s[PsmTsvHeader.PreviousAminoAcid] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.PreviousAminoAcid.ToString())).ResolvedString; - s[PsmTsvHeader.NextAminoAcid] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.NextAminoAcid.ToString())).ResolvedString; + Resolve(pepsWithMods.Select(b => ($"[{b.OneBasedStartResidue.ToString(CultureInfo.InvariantCulture)} to {b.OneBasedEndResidue.ToString(CultureInfo.InvariantCulture)}]")), sm.FullSequence).ResolvedString; + s[PsmTsvHeader.PreviousAminoAcid] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.PreviousResidue.ToString())).ResolvedString; + s[PsmTsvHeader.NextAminoAcid] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.NextResidue.ToString())).ResolvedString; string theoreticalsSearched = " "; s[PsmTsvHeader.TheoreticalsSearched] = theoreticalsSearched; - s[PsmTsvHeader.DecoyContaminantTarget] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Protein.IsDecoy ? "D" : b.Protein.IsContaminant ? "C" : "T")).ResolvedString; + s[PsmTsvHeader.DecoyContaminantTarget] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Parent.IsDecoy ? "D" : b.Parent.IsContaminant ? "C" : "T")).ResolvedString; } /// @@ -246,7 +253,7 @@ internal static void AddPeptideSequenceData(Dictionary s, Peptid /// private static bool Includes(PeptideWithSetModifications pep, SpliceSite site) { - return pep.OneBasedStartResidueInProtein <= site.OneBasedBeginPosition && pep.OneBasedEndResidueInProtein >= site.OneBasedEndPosition; + return pep.OneBasedStartResidue <= site.OneBasedBeginPosition && pep.OneBasedEndResidue >= site.OneBasedEndPosition; } internal static void AddMatchedIonsData(Dictionary s, List matchedIons) @@ -322,7 +329,7 @@ internal static void AddMatchedIonsData(Dictionary s, List s, PeptideSpectralMatch peptide) + internal static void AddMatchScoreData(Dictionary s, SpectralMatch peptide) { string spectralAngle = peptide == null ? " " : peptide.SpectralAngle.ToString("F4"); string localizedScores = " "; diff --git a/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs b/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs index 5b7a90dbe..42d8cff0d 100644 --- a/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs +++ b/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using Omics.Modifications; +using Omics; namespace EngineLayer { @@ -40,36 +41,36 @@ public static PeptideSpectralMatch GetLabeledPsm(PeptideSpectralMatch psm, int n PeptideWithSetModifications labeledPwsm = new PeptideWithSetModifications( pwsm.Protein, pwsm.DigestionParams, - pwsm.OneBasedStartResidueInProtein, - pwsm.OneBasedEndResidueInProtein, + pwsm.OneBasedStartResidue, + pwsm.OneBasedEndResidue, pwsm.CleavageSpecificityForFdrCategory, pwsm.PeptideDescription, pwsm.MissedCleavages, pwsm.AllModsOneIsNterminus, pwsm.NumFixedMods, labeledBaseSequence); - return psm.Clone(new List<(int Notch, PeptideWithSetModifications Peptide)> { (notch, labeledPwsm) }); + return psm.Clone(new List<(int Notch, IBioPolymerWithSetMods Peptide)> { (notch, labeledPwsm) }); } public static PeptideSpectralMatch GetSilacPsm(PeptideSpectralMatch psm, SilacLabel silacLabel) { - List<(int Notch, PeptideWithSetModifications Peptide)> updatedBestMatchingPeptides = new List<(int Notch, PeptideWithSetModifications Peptide)>(); - foreach ((int Notch, PeptideWithSetModifications Peptide) notchAndPwsm in psm.BestMatchingPeptides) + List<(int Notch, IBioPolymerWithSetMods Peptide)> updatedBestMatchingPeptides = new List<(int Notch, IBioPolymerWithSetMods Peptide)>(); + foreach ((int Notch, PeptideWithSetModifications Peptide) notchAndPwsm in psm.BestMatchingBioPolymersWithSetMods) { PeptideWithSetModifications modifiedPwsm = CreateSilacPwsm(silacLabel, notchAndPwsm.Peptide); updatedBestMatchingPeptides.Add((notchAndPwsm.Notch, modifiedPwsm)); } - return psm.Clone(updatedBestMatchingPeptides); + return psm.Clone(updatedBestMatchingPeptides) as PeptideSpectralMatch; } //modify the proteins to appear only light (we want a protein sequence to look like PROTEINK instead of PROTEINa) - public static List UpdateProteinSequencesToLight(List originalPsms, List labels) + public static List UpdateProteinSequencesToLight(List originalPsms, List labels) { - List psmsToReturn = new List(); + List psmsToReturn = new List(); foreach (PeptideSpectralMatch psm in originalPsms) { - List<(int Notch, PeptideWithSetModifications Peptide)> originalPeptides = psm.BestMatchingPeptides.ToList(); - List<(int Notch, PeptideWithSetModifications Peptide)> updatedPeptides = new List<(int Notch, PeptideWithSetModifications Peptide)>(); + List<(int Notch, IBioPolymerWithSetMods Peptide)> originalPeptides = psm.BestMatchingBioPolymersWithSetMods.ToList(); + List<(int Notch, IBioPolymerWithSetMods Peptide)> updatedPeptides = new List<(int Notch, IBioPolymerWithSetMods Peptide)>(); foreach ((int Notch, PeptideWithSetModifications Peptide) notchPwsm in originalPeptides) { PeptideWithSetModifications pwsm = notchPwsm.Peptide; @@ -91,8 +92,8 @@ public static List UpdateProteinSequencesToLight(List pwsms = new(); + List<(int, IBioPolymerWithSetMods)> pwsms = new(); List pwsmSpectralAngles = new(); - foreach (var (Notch, Peptide) in psms[i].BestMatchingPeptides) + foreach (var (Notch, Peptide) in psms[i].BestMatchingBioPolymersWithSetMods) { //if peptide is target, directly look for the target's spectrum in the spectral library - if (!Peptide.Protein.IsDecoy && spectralLibrary.TryGetSpectrum(Peptide.FullSequence, scan.PrecursorCharge, out var librarySpectrum)) + if (!Peptide.Parent.IsDecoy && spectralLibrary.TryGetSpectrum(Peptide.FullSequence, scan.PrecursorCharge, out var librarySpectrum)) { SpectralSimilarity s = new SpectralSimilarity(scan.TheScan.MassSpectrum, librarySpectrum.XArray, librarySpectrum.YArray, SpectralSimilarity.SpectrumNormalizationScheme.squareRootSpectrumSum, commonParameters.ProductMassTolerance.Value, false); if (s.SpectralContrastAngle().HasValue) @@ -54,7 +55,7 @@ public static void CalculateSpectralAngles(SpectralLibrary spectralLibrary, Pept } //if peptide is decoy, look for the decoy's corresponding target's spectrum in the spectral library and generate decoy spectrum by function GetDecoyLibrarySpectrumFromTargetByRevers - else if (Peptide.Protein.IsDecoy && spectralLibrary.TryGetSpectrum(Peptide.PeptideDescription, scan.PrecursorCharge, out var targetlibrarySpectrum)) + else if (Peptide.Parent.IsDecoy && spectralLibrary.TryGetSpectrum(Peptide.Description, scan.PrecursorCharge, out var targetlibrarySpectrum)) { var decoyPeptideTheorProducts = new List(); Peptide.Fragment(commonParameters.DissociationType, commonParameters.DigestionParams.FragmentationTerminus, decoyPeptideTheorProducts); diff --git a/MetaMorpheus/EngineLayer/SpectralMatch.cs b/MetaMorpheus/EngineLayer/SpectralMatch.cs new file mode 100644 index 000000000..5001a6e6c --- /dev/null +++ b/MetaMorpheus/EngineLayer/SpectralMatch.cs @@ -0,0 +1,496 @@ +using System; +using Chemistry; +using EngineLayer.FdrAnalysis; +using MassSpectrometry; +using Proteomics; +using Omics.Fragmentation; +using Proteomics.ProteolyticDigestion; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Runtime.CompilerServices; +using Easy.Common.Extensions; +using Omics; +using Omics.Modifications; +using Proteomics.AminoAcidPolymer; +using ThermoFisher.CommonCore.Data; + +namespace EngineLayer +{ + public abstract class SpectralMatch + { + public const double ToleranceForScoreDifferentiation = 1e-9; + + protected SpectralMatch(IBioPolymerWithSetMods peptide, int notch, double score, int scanIndex, Ms2ScanWithSpecificMass scan, CommonParameters commonParameters, List matchedFragmentIons, double xcorr = 0) + { + _BestMatchingBioPolymersWithSetMods = new List<(int, IBioPolymerWithSetMods)>(); + ScanIndex = scanIndex; + FullFilePath = scan.FullFilePath; + ScanNumber = scan.OneBasedScanNumber; + PrecursorScanNumber = scan.OneBasedPrecursorScanNumber; + ScanRetentionTime = scan.RetentionTime; + ScanExperimentalPeaks = scan.NumPeaks; + TotalIonCurrent = scan.TotalIonCurrent; + ScanPrecursorCharge = scan.PrecursorCharge; + ScanPrecursorMonoisotopicPeakMz = scan.PrecursorMonoisotopicPeakMz; + ScanPrecursorMass = scan.PrecursorMass; + DigestionParams = commonParameters.DigestionParams; + BioPolymersWithSetModsToMatchingFragments = new Dictionary>(); + Xcorr = xcorr; + NativeId = scan.NativeId; + RunnerUpScore = commonParameters.ScoreCutoff; + MsDataScan = scan.TheScan; + SpectralAngle = -1; + + AddOrReplace(peptide, score, notch, true, matchedFragmentIons, xcorr); + } + + public MsDataScan MsDataScan { get; set; } + public ChemicalFormula ModsChemicalFormula { get; private set; } // these fields will be null if they are ambiguous + public string FullSequence { get; protected set; } + public string EssentialSequence { get; protected set; } + public int? Notch { get; private set; } + public string BaseSequence { get; protected set; } + public int? BioPolymerWithSetModsLength { get; private set; } + public int? OneBasedStartResidue { get; private set; } + public int? OneBasedEndResidue { get; private set; } + public double? BioPolymerWithSetModsMonoisotopicMass { get; private set; } + public int? ParentLength { get; private set; } + public string Accession { get; private set; } + public string Organism { get; private set; } + public List MatchedFragmentIons { get; protected set; } + public int PsmCount { get; internal set; } + public Dictionary ModsIdentified { get; private set; } // these should never be null under normal circumstances + public List LocalizedScores { get; internal set; } + public int ScanNumber { get; } + public int? PrecursorScanNumber { get; } + public double ScanRetentionTime { get; } + public int ScanExperimentalPeaks { get; } + public double TotalIonCurrent { get; } + public int ScanPrecursorCharge { get; } + public double ScanPrecursorMonoisotopicPeakMz { get; } + public double ScanPrecursorMass { get; } + public string FullFilePath { get; private set; } + public int ScanIndex { get; } + public int NumDifferentMatchingPeptides { get { return _BestMatchingBioPolymersWithSetMods.Count; } } + public FdrInfo FdrInfo { get; private set; } + public PsmData PsmData_forPEPandPercolator { get; set; } + + public double Score { get; private set; } + public double Xcorr; + public double SpectralAngle { get; set; } + public string NativeId; // this is a property of the scan. used for mzID writing + + public double DeltaScore { get { return (Score - RunnerUpScore); } } + + public double RunnerUpScore { get; set; } + public bool IsDecoy { get; private set; } + public bool IsContaminant { get; private set; } + + //One-based positions in peptide that are covered by fragments on both sides of amino acids + public List FragmentCoveragePositionInPeptide { get; private set; } + + + + #region Search + public DigestionParams DigestionParams { get; } + public Dictionary> BioPolymersWithSetModsToMatchingFragments { get; private set; } + + protected List<(int Notch, IBioPolymerWithSetMods Pwsm)> _BestMatchingBioPolymersWithSetMods; + public IEnumerable<(int Notch, IBioPolymerWithSetMods Peptide)> BestMatchingBioPolymersWithSetMods + { + get + { + return _BestMatchingBioPolymersWithSetMods.OrderBy(p => p.Pwsm.FullSequence) + .ThenBy(p => p.Pwsm.Parent.Accession) + .ThenBy(p => p.Pwsm.OneBasedStartResidue); + } + } + + public void AddOrReplace(IBioPolymerWithSetMods pwsm, double newScore, int notch, bool reportAllAmbiguity, List matchedFragmentIons, double newXcorr) + { + if (newScore - Score > ToleranceForScoreDifferentiation) //if new score beat the old score, overwrite it + { + _BestMatchingBioPolymersWithSetMods.Clear(); + _BestMatchingBioPolymersWithSetMods.Add((notch, pwsm)); + + if (Score - RunnerUpScore > ToleranceForScoreDifferentiation) + { + RunnerUpScore = Score; + } + + Score = newScore; + Xcorr = newXcorr; + + BioPolymersWithSetModsToMatchingFragments.Clear(); + BioPolymersWithSetModsToMatchingFragments.Add(pwsm, matchedFragmentIons); + } + else if (newScore - Score > -ToleranceForScoreDifferentiation && reportAllAmbiguity) //else if the same score and ambiguity is allowed + { + _BestMatchingBioPolymersWithSetMods.Add((notch, pwsm)); + + if (!BioPolymersWithSetModsToMatchingFragments.ContainsKey(pwsm)) + { + BioPolymersWithSetModsToMatchingFragments.Add(pwsm, matchedFragmentIons); + } + } + else if (newScore - RunnerUpScore > ToleranceForScoreDifferentiation) + { + RunnerUpScore = newScore; + } + } + + //PEP-Value analysis identifies ambiguous peptides with lower probability. These are removed from the bestmatchingpeptides dictionary, which lowers ambiguity. + public void RemoveThisAmbiguousPeptide(int notch, IBioPolymerWithSetMods pwsm) + { + _BestMatchingBioPolymersWithSetMods.Remove((notch, pwsm)); + if (!_BestMatchingBioPolymersWithSetMods.Any(x => x.Pwsm.Equals(pwsm))) + { + BioPolymersWithSetModsToMatchingFragments.Remove(pwsm); + } + this.ResolveAllAmbiguities(); + } + + /// + /// This method saves properties of this PSM for internal use. It is NOT used for any output. + /// These resolved fields are (usually) null if there is more than one option. + /// e.g., if this PSM can be explained by more than one base sequence, the BaseSequence property will be null + /// + public void ResolveAllAmbiguities() + { + IsDecoy = _BestMatchingBioPolymersWithSetMods.Any(p => p.Pwsm.Parent.IsDecoy); + IsContaminant = _BestMatchingBioPolymersWithSetMods.Any(p => p.Pwsm.Parent.IsContaminant); + FullSequence = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.FullSequence)).ResolvedValue; + BaseSequence = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.BaseSequence)).ResolvedValue; + BioPolymerWithSetModsLength = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.Length)).ResolvedValue; + OneBasedStartResidue = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.OneBasedStartResidue)).ResolvedValue; + OneBasedEndResidue = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.OneBasedEndResidue)).ResolvedValue; + ParentLength = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.Parent.Length)).ResolvedValue; + BioPolymerWithSetModsMonoisotopicMass = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.MonoisotopicMass)).ResolvedValue; + Accession = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.Parent.Accession)).ResolvedValue; + Organism = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.Parent.Organism)).ResolvedValue; + ModsIdentified = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.AllModsOneIsNterminus)).ResolvedValue; + ModsChemicalFormula = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Pwsm.AllModsOneIsNterminus.Select(c => (c.Value)))).ResolvedValue; + Notch = PsmTsvWriter.Resolve(_BestMatchingBioPolymersWithSetMods.Select(b => b.Notch)).ResolvedValue; + + // if the PSM matches a target and a decoy and they are the SAME SEQUENCE, remove the decoy + if (IsDecoy) + { + bool removedPeptides = false; + var hits = _BestMatchingBioPolymersWithSetMods.GroupBy(p => p.Pwsm.FullSequence); + + foreach (var hit in hits) + { + if (hit.Any(p => p.Pwsm.Parent.IsDecoy) && hit.Any(p => !p.Pwsm.Parent.IsDecoy)) + { + // at least one peptide with this sequence is a target and at least one is a decoy + // remove the decoys with this sequence + var pwsmToRemove = _BestMatchingBioPolymersWithSetMods.Where(p => p.Pwsm.FullSequence == hit.Key && p.Pwsm.Parent.IsDecoy).ToList(); + _BestMatchingBioPolymersWithSetMods.RemoveAll(p => p.Pwsm.FullSequence == hit.Key && p.Pwsm.Parent.IsDecoy); + foreach ((int, PeptideWithSetModifications) pwsm in pwsmToRemove) + { + BioPolymersWithSetModsToMatchingFragments.Remove(pwsm.Item2); + } + + removedPeptides = true; + } + } + + if (removedPeptides) + { + ResolveAllAmbiguities(); + } + } + + // TODO: technically, different peptide options for this PSM can have different matched ions + // we can write a Resolve method for this if we want... + MatchedFragmentIons = BioPolymersWithSetModsToMatchingFragments.First().Value; + } + + public void SetFdrValues(double cumulativeTarget, double cumulativeDecoy, double qValue, double cumulativeTargetNotch, double cumulativeDecoyNotch, double qValueNotch, double pep, double pepQValue) + { + FdrInfo = new FdrInfo + { + CumulativeTarget = cumulativeTarget, + CumulativeDecoy = cumulativeDecoy, + QValue = qValue, + CumulativeTargetNotch = cumulativeTargetNotch, + CumulativeDecoyNotch = cumulativeDecoyNotch, + QValueNotch = qValueNotch, + PEP = pep, + PEP_QValue = pepQValue + }; + } + + #endregion + + #region IO + + public static string GetTabSeparatedHeader() + { + return string.Join("\t", DataDictionary(null, null).Keys); + } + + public override string ToString() + { + return ToString(new Dictionary()); + } + + public string ToString(IReadOnlyDictionary ModstoWritePruned) + { + return string.Join("\t", DataDictionary(this, ModstoWritePruned).Values); + } + + public static Dictionary DataDictionary(SpectralMatch psm, IReadOnlyDictionary ModsToWritePruned) + { + Dictionary s = new Dictionary(); + PsmTsvWriter.AddBasicMatchData(s, psm); + PsmTsvWriter.AddPeptideSequenceData(s, psm, ModsToWritePruned); + PsmTsvWriter.AddMatchedIonsData(s, psm?.MatchedFragmentIons); + PsmTsvWriter.AddMatchScoreData(s, psm); + return s; + } + + #endregion + + #region Parsimony + + /// + /// This method is used by protein parsimony to remove PeptideWithSetModifications objects that have non-parsimonious protein associations + /// + public void TrimProteinMatches(HashSet parsimoniousProteins) + { + if (IsDecoy) + { + if (_BestMatchingBioPolymersWithSetMods.Any(p => parsimoniousProteins.Contains(p.Pwsm.Parent) && p.Pwsm.Parent.IsDecoy)) + { + _BestMatchingBioPolymersWithSetMods.RemoveAll(p => !parsimoniousProteins.Contains(p.Pwsm.Parent)); + } + // else do nothing + } + else + { + _BestMatchingBioPolymersWithSetMods.RemoveAll(p => !parsimoniousProteins.Contains(p.Pwsm.Parent)); + } + + ResolveAllAmbiguities(); + } + + /// + /// This method is used by protein parsimony to add PeptideWithSetModifications objects for modification-agnostic parsimony + /// + public void AddProteinMatch((int, IBioPolymerWithSetMods) peptideWithNotch, List mfi) + { + if (!_BestMatchingBioPolymersWithSetMods.Select(p => p.Pwsm).Contains(peptideWithNotch.Item2)) + { + _BestMatchingBioPolymersWithSetMods.Add(peptideWithNotch); + if (!BioPolymersWithSetModsToMatchingFragments.ContainsKey(peptideWithNotch.Item2)) + { + BioPolymersWithSetModsToMatchingFragments.Add(peptideWithNotch.Item2, mfi); + } + ResolveAllAmbiguities(); + } + } + + #endregion + + #region Silac + + protected SpectralMatch(SpectralMatch psm, List<(int Notch, IBioPolymerWithSetMods Peptide)> bestMatchingPeptides) + { + _BestMatchingBioPolymersWithSetMods = bestMatchingPeptides; + BaseSequence = PsmTsvWriter.Resolve(bestMatchingPeptides.Select(b => b.Peptide.BaseSequence)).ResolvedValue; + FullSequence = PsmTsvWriter.Resolve(bestMatchingPeptides.Select(b => b.Peptide.FullSequence)).ResolvedValue; + + ModsChemicalFormula = psm.ModsChemicalFormula; + Notch = psm.Notch; + BioPolymerWithSetModsLength = psm.BioPolymerWithSetModsLength; + OneBasedStartResidue = psm.OneBasedStartResidue; + OneBasedEndResidue = psm.OneBasedEndResidue; + BioPolymerWithSetModsMonoisotopicMass = psm.BioPolymerWithSetModsMonoisotopicMass; + ParentLength = psm.ParentLength; + Accession = psm.Accession; + Organism = psm.Organism; + MatchedFragmentIons = psm.MatchedFragmentIons; + PsmCount = psm.PsmCount; + ModsIdentified = psm.ModsIdentified; + LocalizedScores = psm.LocalizedScores; + ScanNumber = psm.ScanNumber; + PrecursorScanNumber = psm.PrecursorScanNumber; + ScanRetentionTime = psm.ScanRetentionTime; + ScanExperimentalPeaks = psm.ScanExperimentalPeaks; + TotalIonCurrent = psm.TotalIonCurrent; + ScanPrecursorCharge = psm.ScanPrecursorCharge; + ScanPrecursorMonoisotopicPeakMz = psm.ScanPrecursorMonoisotopicPeakMz; + ScanPrecursorMass = psm.ScanPrecursorMass; + FullFilePath = psm.FullFilePath; + ScanIndex = psm.ScanIndex; + FdrInfo = psm.FdrInfo; + Score = psm.Score; + Xcorr = psm.Xcorr; + RunnerUpScore = psm.RunnerUpScore; + IsDecoy = psm.IsDecoy; + IsContaminant = psm.IsContaminant; + DigestionParams = psm.DigestionParams; + BioPolymersWithSetModsToMatchingFragments = psm.BioPolymersWithSetModsToMatchingFragments; + SpectralAngle = psm.SpectralAngle; + } + + #endregion + + + public static int GetLongestIonSeriesBidirectional(Dictionary> PeptidesToMatchingFragments, IBioPolymerWithSetMods peptide) + { + List maxDiffs = new List { 1 }; + if (PeptidesToMatchingFragments != null && PeptidesToMatchingFragments.TryGetValue(peptide, out var matchedFragments) && matchedFragments != null && matchedFragments.Any()) + { + var jointSeries = matchedFragments.Select(p => p.NeutralTheoreticalProduct.AminoAcidPosition).Distinct().ToList(); + + if (jointSeries.Count > 0) + { + jointSeries.Sort(); + + List aminoAcidPostionsThatCouldBeObserved = Enumerable.Range(1, peptide.BaseSequence.Length).ToList(); + + List missing = aminoAcidPostionsThatCouldBeObserved.Except(jointSeries).ToList(); + + int localMaxDiff = 0; + for (int i = 0; i < aminoAcidPostionsThatCouldBeObserved.Count; i++) + { + if (!missing.Contains(aminoAcidPostionsThatCouldBeObserved[i])) + { + localMaxDiff++; + } + else + { + maxDiffs.Add(localMaxDiff); + localMaxDiff = 0; + } + } + maxDiffs.Add(localMaxDiff); + } + } + + return maxDiffs.Max(); + } + + /// + /// Determine the Fragment Coverage the PSM + /// Assigns fragment coverage indices for the PSM and the protein based on Amino Acid Position in Matched Ion Fragments + /// + public void GetAminoAcidCoverage() + { + if (string.IsNullOrEmpty(this.BaseSequence) || + !this.MatchedFragmentIons.Any()) return; + //Pull C terminal and N terminal Fragments and amino acid numbers + var nTermFragmentAAPositions = this.MatchedFragmentIons.Where(p => + p.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.N) + .Select(j => j.NeutralTheoreticalProduct.AminoAcidPosition).Distinct().ToList(); + + var cTermFragmentAAPositions = this.MatchedFragmentIons.Where(p => + p.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.C) + .Select(j => j.NeutralTheoreticalProduct.AminoAcidPosition).Distinct().ToList(); + + //Create a hashset to store the covered amino acid positions + HashSet fragmentCoveredAminoAcids = new(); + + //Check N term frags first + if (nTermFragmentAAPositions.Any()) + { + nTermFragmentAAPositions.Sort(); + + //if the final NFragment is present, last AA is covered + if (nTermFragmentAAPositions.Contains(this.BaseSequence.Length - 1)) + { + fragmentCoveredAminoAcids.Add(this.BaseSequence.Length); + } + + // if the first NFragment is present, first AA is covered + if (nTermFragmentAAPositions.Contains(1)) + { + fragmentCoveredAminoAcids.Add(1); + } + + //Check all amino acids except for the last one in the list + for (int i = 0; i < nTermFragmentAAPositions.Count - 1; i++) + { + //sequential AA, second one is covered + if (nTermFragmentAAPositions[i + 1] - nTermFragmentAAPositions[i] == 1) + { + fragmentCoveredAminoAcids.Add(nTermFragmentAAPositions[i + 1]); + } + + //check to see if the position is covered from both directions, inclusive + if (cTermFragmentAAPositions.Contains(nTermFragmentAAPositions[i + 1])) + { + fragmentCoveredAminoAcids.Add(nTermFragmentAAPositions[i + 1]); + } + + //check to see if the position is covered from both directions, exclusive + if (cTermFragmentAAPositions.Contains(nTermFragmentAAPositions[i + 1] + 2)) + { + fragmentCoveredAminoAcids.Add(nTermFragmentAAPositions[i + 1] + 1); + } + } + + } + + //Check C term frags + if (cTermFragmentAAPositions.Any()) + { + cTermFragmentAAPositions.Sort(); + + //if the second AA is present, the first AA is covered + if (cTermFragmentAAPositions.Contains(2)) + { + fragmentCoveredAminoAcids.Add(1); + } + + //if the last AA is present, the final AA is covered + if (cTermFragmentAAPositions.Contains(this.BaseSequence.Length)) + { + fragmentCoveredAminoAcids.Add(this.BaseSequence.Length); + } + + //check all amino acids except for the last one in the list + for (int i = 0; i < cTermFragmentAAPositions.Count - 1; i++) + { + //sequential AA, the first one is covered + if (cTermFragmentAAPositions[i + 1] - cTermFragmentAAPositions[i] == 1) + { + fragmentCoveredAminoAcids.Add(cTermFragmentAAPositions[i]); + } + } + } + + //store in PSM + var fragmentCoveredAminoAcidsList = fragmentCoveredAminoAcids.ToList(); + fragmentCoveredAminoAcidsList.Sort(); + this.FragmentCoveragePositionInPeptide = fragmentCoveredAminoAcidsList; + } + + public static int GetCountComplementaryIons(Dictionary> PeptidesToMatchingFragments, IBioPolymerWithSetMods peptide) + { + if (PeptidesToMatchingFragments != null && PeptidesToMatchingFragments.TryGetValue(peptide, out var matchedFragments) && matchedFragments != null && matchedFragments.Any()) + { + List nIons = matchedFragments.Where(f => f.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.N).Select(f => f.NeutralTheoreticalProduct.FragmentNumber).ToList(); + List cIons = matchedFragments.Where(f => f.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.C).Select(f => (peptide.BaseSequence.Length - f.NeutralTheoreticalProduct.FragmentNumber)).ToList(); + if (nIons.Any() && cIons.Any()) + { + return nIons.Intersect(cIons).Count(); + } + else + { + return 0; + } + } + else + { + return 0; + } + } + + + + } +} \ No newline at end of file diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 99be99737..f9d072025 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index fdb61d2d4..5b5a9ca6a 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs b/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs index 669a09399..82b2762a1 100644 --- a/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs +++ b/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs @@ -262,7 +262,7 @@ private DataPointAquisitionResults GetDataAcquisitionResults(MsDataFile myMsData new SingleAbsoluteAroundZeroSearchMode(initPrecTol.Value); Ms2ScanWithSpecificMass[] listOfSortedms2Scans = GetMs2Scans(myMsDataFile, currentDataFile, combinedParameters).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; Log("Searching with searchMode: " + searchMode, new List { taskId, "Individual Spectra Files", fileNameWithoutExtension }); Log("Searching with productMassTolerance: " + initProdTol, new List { taskId, "Individual Spectra Files", fileNameWithoutExtension }); @@ -270,25 +270,25 @@ private DataPointAquisitionResults GetDataAcquisitionResults(MsDataFile myMsData bool writeSpectralLibrary = false; _ = new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, combinedParameters, FileSpecificParameters, null, new List { taskId, "Individual Spectra Files", fileNameWithoutExtension }, writeSpectralLibrary).Run(); - List allPsms = allPsmsArray.Where(b => b != null).ToList(); + List allPsms = allPsmsArray.Where(b => b != null).ToList(); allPsms = allPsms.OrderByDescending(b => b.Score) - .ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue) - .GroupBy(b => (b.FullFilePath, b.ScanNumber, b.PeptideMonisotopicMass)).Select(b => b.First()).ToList(); + .ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue) + .GroupBy(b => (b.FullFilePath, b.ScanNumber, b.BioPolymerWithSetModsMonoisotopicMass)).Select(b => b.First()).ToList(); _ = new FdrAnalysisEngine(allPsms, searchMode.NumNotches, CommonParameters, FileSpecificParameters, new List { taskId, "Individual Spectra Files", fileNameWithoutExtension }, doPEP: false).Run(); - List goodIdentifications = allPsms.Where(b => b.FdrInfo.QValueNotch < 0.001 && !b.IsDecoy && b.FullSequence != null).ToList(); + List goodIdentifications = allPsms.Where(b => b.FdrInfo.QValueNotch < 0.001 && !b.IsDecoy && b.FullSequence != null).ToList(); if (!goodIdentifications.Any()) { - return new DataPointAquisitionResults(null, new List(), new List(), new List(), 0, 0, 0, 0); + return new DataPointAquisitionResults(null, new List(), new List(), new List(), 0, 0, 0, 0); } //get the deconvoluted ms2scans for the good identifications List goodScans = new List(); - List unfilteredPsms = allPsmsArray.ToList(); - foreach (PeptideSpectralMatch psm in goodIdentifications) + List unfilteredPsms = allPsmsArray.ToList(); + foreach (SpectralMatch psm in goodIdentifications) { goodScans.Add(listOfSortedms2Scans[unfilteredPsms.IndexOf(psm)]); } diff --git a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs index cde4fad40..5d04226cc 100644 --- a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs +++ b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs @@ -39,7 +39,7 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List proteinList = LoadProteins(taskId, dbFilenameList, true, DecoyType.Reverse, localizeableModificationTypes, CommonParameters); - List allPsms = new List(); + List allPsms = new List(); var numRawFiles = currentRawFileList.Count; @@ -98,7 +98,7 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List { taskId, "Individual Spectra Files", origDataFile }); Ms2ScanWithSpecificMass[] arrayOfMs2ScansSortedByMass = GetMs2Scans(myMsDataFile, origDataFile, combinedParams).OrderBy(b => b.PrecursorMass).ToArray(); myFileManager.DoneWithFile(origDataFile); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; //spectral Library search and library generation have't applied to GPTMD yet bool writeSpctralLibrary = false; @@ -111,8 +111,8 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List { taskId, "Individual Spectra Files" })); allPsms = allPsms.OrderByDescending(b => b.Score) - .ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue) - .GroupBy(b => new Tuple(b.FullFilePath, b.ScanNumber, b.PeptideMonisotopicMass)) + .ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue) + .GroupBy(b => new Tuple(b.FullFilePath, b.ScanNumber, b.BioPolymerWithSetModsMonoisotopicMass)) .Select(b => b.First()).ToList(); new FdrAnalysisEngine(allPsms, tempSearchMode.NumNotches, CommonParameters, this.FileSpecificParameters, new List { taskId }).Run(); diff --git a/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoProteinParsimony.cs b/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoProteinParsimony.cs index e22f1d9ba..9d90d65d5 100644 --- a/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoProteinParsimony.cs +++ b/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoProteinParsimony.cs @@ -9,7 +9,7 @@ namespace TaskLayer { public class GlycoProteinParsimony { - //id: ProteinAccession, ProtienPos, GlycanId.islocalized, minQValue, maxProb + //id: Accession, ProtienPos, GlycanId.islocalized, minQValue, maxProb public GlycoProteinParsimony(string proteinAccess, int proteinPos, char aminoAcid, bool isLocalized, double minQValue, LocalizationLevel bestLocalizeLevel, double maxProb) { @@ -57,9 +57,9 @@ public GlycoProteinParsimony(string proteinAccess, int proteinPos, char aminoAci { foreach (var local in gsm.LocalizedGlycan) { - int proteinPos = local.Item1 + gsm.OneBasedStartResidueInProtein.Value - 2; + int proteinPos = local.Item1 + gsm.OneBasedStartResidue.Value - 2; - (string,string,int) proPosId = new (gsm.ProteinAccession, proteinPos.ToString(), local.Item2); + (string,string,int) proPosId = new (gsm.Accession, proteinPos.ToString(), local.Item2); double prob = -1; if (gsm.SiteSpeciLocalProb != null && gsm.SiteSpeciLocalProb.ContainsKey(local.Item1)) @@ -70,7 +70,7 @@ public GlycoProteinParsimony(string proteinAccess, int proteinPos, char aminoAci if (!localizedGlycan.ContainsKey(proPosId)) { - GlycoProteinParsimony gpp = new GlycoProteinParsimony(gsm.ProteinAccession, proteinPos, gsm.BaseSequence[local.Item1-2], local.Item3, gsm.FdrInfo.QValue, gsm.LocalizationLevel, prob); + GlycoProteinParsimony gpp = new GlycoProteinParsimony(gsm.Accession, proteinPos, gsm.BaseSequence[local.Item1-2], local.Item3, gsm.FdrInfo.QValue, gsm.LocalizationLevel, prob); localizedGlycan.Add(proPosId, gpp); } else diff --git a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs index 4b205c6c1..84c4d70de 100644 --- a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs @@ -144,7 +144,7 @@ private void DividePsmsIntoGroupsWriteToTsv(GlycoSearchType glycoSearchType, Lis var writtenFileOGlyco = Path.Combine(individualFileFolderPath, individualFileFolder + "oglyco" + ".psmtsv"); WriteFile.WritePsmGlycoToTsv(allPsmsOgly, writtenFileOGlyco, 2); - var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsOgly.Where(p => p.ProteinAccession != null && p.OneBasedStartResidueInProtein.HasValue).ToList()); + var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsOgly.Where(p => p.Accession != null && p.OneBasedStartResidue.HasValue).ToList()); var seen_oglyco_localization_file = Path.Combine(individualFileFolderPath, individualFileFolder + "seen_oglyco_localization" + ".tsv"); WriteFile.WriteSeenProteinGlycoLocalization(ProteinLevelLocalization, seen_oglyco_localization_file); @@ -160,7 +160,7 @@ private void DividePsmsIntoGroupsWriteToTsv(GlycoSearchType glycoSearchType, Lis var writtenFileOGlyco = Path.Combine(individualFileFolderPath, individualFileFolder + "nglyco" + ".psmtsv"); WriteFile.WritePsmGlycoToTsv(allPsmsNgly, writtenFileOGlyco, 2); - var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsNgly.Where(p => p.ProteinAccession != null && p.OneBasedStartResidueInProtein.HasValue).ToList()); + var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsNgly.Where(p => p.Accession != null && p.OneBasedStartResidue.HasValue).ToList()); var seen_nglyco_localization_file = Path.Combine(individualFileFolderPath, individualFileFolder + "seen_nglyco_localization" + ".tsv"); WriteFile.WriteSeenProteinGlycoLocalization(ProteinLevelLocalization, seen_nglyco_localization_file); @@ -176,7 +176,7 @@ private void DividePsmsIntoGroupsWriteToTsv(GlycoSearchType glycoSearchType, Lis var writtenFileOGlyco = Path.Combine(individualFileFolderPath, individualFileFolder + "nglyco" + ".psmtsv"); WriteFile.WritePsmGlycoToTsv(allPsmsGly, writtenFileOGlyco, 2); - var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsGly.Where(p => p.ProteinAccession != null && p.OneBasedStartResidueInProtein.HasValue).ToList()); + var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsGly.Where(p => p.Accession != null && p.OneBasedStartResidue.HasValue).ToList()); var seen_oglyco_localization_file = Path.Combine(individualFileFolderPath, individualFileFolder + "seen_nglyco_localization" + ".tsv"); WriteFile.WriteSeenProteinGlycoLocalization(ProteinLevelLocalization, seen_oglyco_localization_file); @@ -191,14 +191,14 @@ private void DividePsmsIntoGroupsWriteToTsv(GlycoSearchType glycoSearchType, Lis private void SingleFDRAnalysis(List items, CommonParameters commonParameters, List taskIds) { // calculate single PSM FDR - List psms = items.Select(p => p as PeptideSpectralMatch).ToList(); + List psms = items.Select(p => p as SpectralMatch).ToList(); new FdrAnalysisEngine(psms, 0, commonParameters, this.FileSpecificParameters, taskIds).Run(); } private void GlycoProteinAnalysis(List gsms, string outputFolder, string individualFileFolder = null) { // convert gsms to psms - List psmsForProteinParsimony = gsms.Select(p => p as PeptideSpectralMatch).ToList(); + List psmsForProteinParsimony = gsms.Select(p => p as SpectralMatch).ToList(); Status("Constructing protein groups...", Parameters.SearchTaskId); @@ -219,7 +219,7 @@ private void GlycoAccessionAnalysis(List gsms, string indivi List _proteinGroups = new List(); // convert gsms to psms - List psmsForProteinParsimony = gsms.Select(p => p as PeptideSpectralMatch).ToList(); + List psmsForProteinParsimony = gsms.Select(p => p as SpectralMatch).ToList(); foreach (var psm in psmsForProteinParsimony) { @@ -227,16 +227,16 @@ private void GlycoAccessionAnalysis(List gsms, string indivi } //get non-ambigous psms above cutoffs that are normally used for parsimony - List _filteredPsms = psmsForProteinParsimony.Where(p => p.FullSequence != null && p.FdrInfo.QValue <= 0.01 && p.FdrInfo.QValueNotch <= 0.01).ToList(); + List _filteredPsms = psmsForProteinParsimony.Where(p => p.FullSequence != null && p.FdrInfo.QValue <= 0.01 && p.FdrInfo.QValueNotch <= 0.01).ToList(); // if there are no peptides observed, there are no proteins; return an empty list of protein groups if (_filteredPsms.Count != 0) { foreach (var psm in _filteredPsms) { - List proteinList = psm.BestMatchingPeptides.Select(p => p.Peptide.Protein).ToList(); + List proteinList = psm.BestMatchingBioPolymersWithSetMods.Select(p => ((PeptideWithSetModifications)p.Peptide).Protein).ToList(); ProteinGroup newProteinGroup = new ProteinGroup(new HashSet(proteinList), - new HashSet(new List(psm.BestMatchingPeptides.Select(p=>p.Peptide).ToList())), new HashSet()); + new HashSet(new List(psm.BestMatchingBioPolymersWithSetMods.Select(p=> (PeptideWithSetModifications)p.Peptide).ToList())), new HashSet()); if (_proteinGroups.Any(p => p.Equals(newProteinGroup))) { @@ -336,7 +336,7 @@ private void QuantificationAnalysis() && p.FullSequence != null).ToList(); // pass protein group info for each PSM - var psmToProteinGroups = new Dictionary>(); + var psmToProteinGroups = new Dictionary>(); if (ProteinGroups != null && ProteinGroups.Count != 0) //ProteinGroups can be null if parsimony wasn't done, and it can be empty if you're doing the two peptide rule { foreach (var proteinGroup in ProteinGroups) @@ -365,7 +365,7 @@ private void QuantificationAnalysis() var accessionToPg = new Dictionary(); foreach (var psm in unambiguousPsmsBelowOnePercentFdr) { - var proteins = psm.BestMatchingPeptides.Select(b => b.Peptide.Protein).Distinct(); + var proteins = psm.BestMatchingBioPolymersWithSetMods.Select(b => ((PeptideWithSetModifications)b.Peptide).Protein).Distinct(); foreach (var protein in proteins) { @@ -375,7 +375,7 @@ private void QuantificationAnalysis() } } - psmToProteinGroups.Add(psm, new List { accessionToPg[psm.ProteinAccession] }); + psmToProteinGroups.Add(psm, new List { accessionToPg[psm.Accession] }); } } @@ -386,14 +386,14 @@ private void QuantificationAnalysis() // the peptides should still be quantified but not considered for protein quantification var undefinedPg = new FlashLFQ.ProteinGroup("UNDEFINED", "", ""); //sort the unambiguous psms by protease to make MBR compatible with multiple proteases - Dictionary> proteaseSortedPsms = new Dictionary>(); + Dictionary> proteaseSortedPsms = new Dictionary>(); Dictionary proteaseSortedFlashLFQResults = new Dictionary(); foreach (DigestionParams dp in Parameters.ListOfDigestionParams) { if (!proteaseSortedPsms.ContainsKey(dp.Protease)) { - proteaseSortedPsms.Add(dp.Protease, new List()); + proteaseSortedPsms.Add(dp.Protease, new List()); } } foreach (var psm in unambiguousPsmsBelowOnePercentFdr) @@ -415,7 +415,7 @@ private void QuantificationAnalysis() foreach (var psm in spectraFile) { flashLFQIdentifications.Add(new Identification(rawfileinfo, psm.BaseSequence, psm.FullSequence, - psm.PeptideMonisotopicMass.Value, psm.ScanRetentionTime, psm.ScanPrecursorCharge, psmToProteinGroups[psm])); + psm.BioPolymerWithSetModsMonoisotopicMass.Value, psm.ScanRetentionTime, psm.ScanPrecursorCharge, psmToProteinGroups[psm])); } } diff --git a/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryPSM.cs b/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryPSM.cs index ac87103d1..a1543e674 100644 --- a/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryPSM.cs +++ b/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryPSM.cs @@ -9,28 +9,28 @@ namespace TaskLayer.MbrAnalysis { public class SpectralRecoveryPSM { - public PeptideSpectralMatch spectralLibraryMatch { get; set; } + public SpectralMatch spectralLibraryMatch { get; set; } public ChromatographicPeak acceptorPeak { get; set; } public bool originalMatchFound { get; private set; } - public PeptideSpectralMatch originalSpectralMatch { get; private set; } + public SpectralMatch originalSpectralMatch { get; private set; } - public SpectralRecoveryPSM(PeptideSpectralMatch spectralLibraryMatch, ChromatographicPeak acceptorPeak) + public SpectralRecoveryPSM(SpectralMatch spectralLibraryMatch, ChromatographicPeak acceptorPeak) { this.spectralLibraryMatch = spectralLibraryMatch; this.acceptorPeak = acceptorPeak; originalMatchFound = false; } - public void FindOriginalPsm(List originalSearchPsms) + public void FindOriginalPsm(List originalSearchPsms) { if (spectralLibraryMatch == null) return; int oneBasedScanNumber = spectralLibraryMatch.ScanNumber; string spectraFile = spectralLibraryMatch.FullFilePath; string fullSequence = spectralLibraryMatch.FullSequence; - PeptideSpectralMatch originalPsm = null; + SpectralMatch originalPsm = null; originalPsm = @@ -53,7 +53,7 @@ public static string TabSeparatedHeader get { var sb = new StringBuilder(); - sb.Append(PeptideSpectralMatch.GetTabSeparatedHeader()); + sb.Append(SpectralMatch.GetTabSeparatedHeader()); sb.Append('\t'); sb.Append("Initial Search Q-Value"); sb.Append('\t'); diff --git a/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryRunner.cs b/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryRunner.cs index 5cd52183e..d098271ae 100644 --- a/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryRunner.cs +++ b/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryRunner.cs @@ -12,6 +12,7 @@ using System.Collections.Concurrent; using Microsoft.ML; using Microsoft.ML.Data; +using Omics; namespace TaskLayer.MbrAnalysis { @@ -40,7 +41,7 @@ public static SpectralRecoveryResults RunSpectralRecoveryAlgorithm( } List spectraFiles = parameters.FlashLfqResults.Peaks.Select(p => p.Key).ToList(); - List allPeptides = GetAllPeptides(parameters, commonParameters, fileSpecificParameters); + List allPeptides = GetAllPeptides(parameters, commonParameters, fileSpecificParameters); int maxThreadsPerFile = commonParameters.MaxThreadsToUsePerFile; int[] threads = Enumerable.Range(0, maxThreadsPerFile).ToArray(); @@ -87,15 +88,15 @@ public static SpectralRecoveryResults RunSpectralRecoveryAlgorithm( for (; i < fileSpecificMbrPeaks.Count; i += maxThreadsPerFile) { ChromatographicPeak mbrPeak = fileSpecificMbrPeaks[i]; - PeptideSpectralMatch bestDonorPsm = allPeptides.Where(p => + SpectralMatch bestDonorPsm = allPeptides.Where(p => p.FullSequence == mbrPeak.Identifications.First().ModifiedSequence).FirstOrDefault(); if (bestDonorPsm == null) { break; } - PeptideWithSetModifications bestDonorPwsm = bestDonorPsm.BestMatchingPeptides.First().Peptide; + IBioPolymerWithSetMods bestDonorPwsm = bestDonorPsm.BestMatchingBioPolymersWithSetMods.First().Peptide; - IEnumerable peptideSpectralMatches = + IEnumerable peptideSpectralMatches = mcse.SearchAroundPeak(bestDonorPwsm, mbrPeak.Apex.IndexedPeak.RetentionTime); if (peptideSpectralMatches == null || !peptideSpectralMatches.Any()) @@ -115,13 +116,13 @@ public static SpectralRecoveryResults RunSpectralRecoveryAlgorithm( if (bestMbrMatches.Any()) { - List allPsms = parameters.AllPsms. + List allPsms = parameters.AllPsms. OrderByDescending(p => p.Score). ThenBy(p => p.FdrInfo.QValue). ThenBy(p => p.FullFilePath). ThenBy(x => x.ScanNumber). ThenBy(p => p.FullSequence). - ThenBy(p => p.ProteinAccession).ToList(); + ThenBy(p => p.Accession).ToList(); AssignEstimatedPsmQvalue(bestMbrMatches, allPsms); FDRAnalysisOfMbrPsms(bestMbrMatches, allPsms, parameters, fileSpecificParameters); @@ -135,12 +136,12 @@ public static SpectralRecoveryResults RunSpectralRecoveryAlgorithm( return new SpectralRecoveryResults(bestMbrMatches, parameters.FlashLfqResults); } - private static List GetAllPeptides( + private static List GetAllPeptides( PostSearchAnalysisParameters parameters, CommonParameters commonParameters, List<(string, CommonParameters)> fileSpecificParameters) { - List peptides = new(); + List peptides = new(); peptides = parameters.AllPsms.Where(b => b.FullSequence != null).GroupBy(b => b.FullSequence).Select(b => b.FirstOrDefault()).ToList(); new FdrAnalysisEngine(peptides, parameters.NumNotches, commonParameters, fileSpecificParameters, new List { parameters.SearchTaskId }, "Peptide").Run(); @@ -167,14 +168,14 @@ private static List GetAllPeptides( return peptides; } - private static PeptideSpectralMatch BestPsmForMbrPeak(IEnumerable peptideSpectralMatches) + private static SpectralMatch BestPsmForMbrPeak(IEnumerable peptideSpectralMatches) { - List nonNullPsms = peptideSpectralMatches.Where(p => p != null).ToList(); + List nonNullPsms = peptideSpectralMatches.Where(p => p != null).ToList(); if (nonNullPsms.Any()) { // Setting Qvalue, QValueNotch, PEP, and PEP_Qvalue equal to 0 is necessary for MetaDraw to read the .psmtsv - foreach (PeptideSpectralMatch psm in nonNullPsms) + foreach (SpectralMatch psm in nonNullPsms) { psm.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); } @@ -187,7 +188,7 @@ private static PeptideSpectralMatch BestPsmForMbrPeak(IEnumerable bestMbrMatches, List allPsms) + private static void AssignEstimatedPsmQvalue(ConcurrentDictionary bestMbrMatches, List allPsms) { double[] allScores = allPsms.Select(s => s.Score).OrderByDescending(s => s).ToArray(); double[] allQValues = allPsms.OrderByDescending(s => s.Score).Select(q => q.FdrInfo.QValue).ToArray(); @@ -213,10 +214,10 @@ private static void AssignEstimatedPsmQvalue(ConcurrentDictionary bestMbrMatches, List allPsms, + private static void FDRAnalysisOfMbrPsms(ConcurrentDictionary bestMbrMatches, List allPsms, PostSearchAnalysisParameters parameters, List<(string, CommonParameters)> fileSpecificParameters) { - List psms = bestMbrMatches. + List psms = bestMbrMatches. Select(p => p.Value.spectralLibraryMatch). Where(v => v != null). ToList(); @@ -257,7 +258,7 @@ private static void FDRAnalysisOfMbrPsms(ConcurrentDictionary bestMbrMatches, List allPsms) + private static void AssignEstimatedPsmPepQValue(ConcurrentDictionary bestMbrMatches, List allPsms) { List pepValues = bestMbrMatches. Select(p => p.Value.spectralLibraryMatch). diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index 8dd270e14..8aa93e245 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -664,11 +664,11 @@ protected void LoadModifications(string taskId, out List variableM } } - protected static void WritePsmsToTsv(IEnumerable psms, string filePath, IReadOnlyDictionary modstoWritePruned) + protected static void WritePsmsToTsv(IEnumerable psms, string filePath, IReadOnlyDictionary modstoWritePruned) { using (StreamWriter output = new StreamWriter(filePath)) { - output.WriteLine(PeptideSpectralMatch.GetTabSeparatedHeader()); + output.WriteLine(SpectralMatch.GetTabSeparatedHeader()); foreach (var psm in psms) { output.WriteLine(psm.ToString(modstoWritePruned)); diff --git a/MetaMorpheus/TaskLayer/PepXMLWriter.cs b/MetaMorpheus/TaskLayer/PepXMLWriter.cs index e4e2b3c68..3b30ab068 100644 --- a/MetaMorpheus/TaskLayer/PepXMLWriter.cs +++ b/MetaMorpheus/TaskLayer/PepXMLWriter.cs @@ -14,7 +14,7 @@ namespace TaskLayer { public static class PepXMLWriter { - public static void WritePepXml(List psms, List database, List variableModifications, List fixedModifications, CommonParameters CommonParameters, string outputPath) + public static void WritePepXml(List psms, List database, List variableModifications, List fixedModifications, CommonParameters CommonParameters, string outputPath) { if (!psms.Any()) { @@ -119,7 +119,7 @@ public static void WritePepXml(List psms, List foreach (var psm in psms) { - PeptideWithSetModifications peptide = psm.BestMatchingPeptides.First().Peptide; + PeptideWithSetModifications peptide = psm.BestMatchingBioPolymersWithSetMods.First().Peptide as PeptideWithSetModifications; var mods = new List(); foreach (var mod in peptide.AllModsOneIsNterminus) @@ -132,7 +132,7 @@ public static void WritePepXml(List psms, List mods.Add(pepXmlMod); } - var proteinAccessions = psm.BestMatchingPeptides.Select(p => p.Peptide.Protein.Accession).Distinct(); + var proteinAccessions = psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide.Parent.Accession).Distinct(); var searchHit = new pepXML.Generated.msms_pipeline_analysisMsms_run_summarySpectrum_querySearch_resultSearch_hit { @@ -141,12 +141,12 @@ public static void WritePepXml(List psms, List // TODO: add amino acid substitution hit_rank = 1, peptide = ((psm.BaseSequence != null) ? psm.BaseSequence : "Ambiguous"), - peptide_prev_aa = peptide.PreviousAminoAcid.ToString(), - peptide_next_aa = peptide.NextAminoAcid.ToString(), + peptide_prev_aa = peptide.PreviousResidue.ToString(), + peptide_next_aa = peptide.NextResidue.ToString(), protein = ((peptide.Protein.Accession != null) ? peptide.Protein.Accession : string.Join("|", proteinAccessions)), num_tot_proteins = (uint)proteinAccessions.Count(), - calc_neutral_pep_mass = (float)((psm.PeptideMonisotopicMass != null) ? psm.PeptideMonisotopicMass : float.NaN), - massdiff = ((psm.PeptideMonisotopicMass != null) ? (psm.ScanPrecursorMass - psm.PeptideMonisotopicMass.Value).ToString() : "Ambiguous"), + calc_neutral_pep_mass = (float)((psm.BioPolymerWithSetModsMonoisotopicMass != null) ? psm.BioPolymerWithSetModsMonoisotopicMass : float.NaN), + massdiff = ((psm.BioPolymerWithSetModsMonoisotopicMass != null) ? (psm.ScanPrecursorMass - psm.BioPolymerWithSetModsMonoisotopicMass.Value).ToString() : "Ambiguous"), modification_info = (mods.Count == 0 ? new pepXML.Generated.modInfoDataType { mod_aminoacid_mass = mods.ToArray() } : null), search_score = new pepXML.Generated.nameValueType[] { diff --git a/MetaMorpheus/TaskLayer/SearchTask/MzIdentMLWriter.cs b/MetaMorpheus/TaskLayer/SearchTask/MzIdentMLWriter.cs index 05ecd5a7c..4b842483d 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/MzIdentMLWriter.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/MzIdentMLWriter.cs @@ -17,7 +17,7 @@ namespace TaskLayer { public static class MzIdentMLWriter { - public static void WriteMzIdentMl(IEnumerable psms, List groups, List variableMods, + public static void WriteMzIdentMl(IEnumerable psms, List groups, List variableMods, List fixedMods, List silacLabels, List proteases, Tolerance productTolerance, Tolerance parentTolerance, int missedCleavages, string outputPath, bool appendMotifToModNames) { @@ -40,7 +40,7 @@ public static void WriteMzIdentMl(IEnumerable psms, List p.BaseSequence != null && !p.FullSequence.Contains("|") && !labelsToSearch.Any(x => p.BaseSequence.Contains(x))); } - List peptides = psms.SelectMany(i => i.BestMatchingPeptides.Select(v => v.Peptide)).Distinct().ToList(); + List peptides = psms.SelectMany(i => i.BestMatchingBioPolymersWithSetMods.Select(v => v.Peptide as PeptideWithSetModifications)).Distinct().ToList(); List proteins = peptides.Select(p => p.Protein).Distinct().ToList(); List filenames = psms.Select(i => i.FullFilePath).Distinct().ToList(); Dictionary database_reference = new Dictionary(); @@ -325,9 +325,9 @@ public static void WriteMzIdentMl(IEnumerable psms, List psm.FullSequence != null); - foreach (PeptideSpectralMatch psm in unambiguousPsms) + foreach (SpectralMatch psm in unambiguousPsms) { - foreach (PeptideWithSetModifications peptide in psm.BestMatchingPeptides.Select(p => p.Peptide).Distinct()) + foreach (PeptideWithSetModifications peptide in psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).Distinct()) { //if first peptide on list hasn't been added, add peptide and peptide evidence if (!peptide_ids.TryGetValue(peptide.FullSequence, out Tuple> peptide_id)) @@ -369,11 +369,11 @@ public static void WriteMzIdentMl(IEnumerable psms, List psms, List(psm.FullFilePath, psm.ScanNumber)] = new Tuple(scan_result_scan_item.Item1, scan_result_scan_item.Item2 + 1); scan_result_scan_item = psm_per_scan[new Tuple(psm.FullFilePath, psm.ScanNumber)]; } - foreach (PeptideWithSetModifications p in psm.BestMatchingPeptides.Select(p => p.Peptide).Distinct()) + foreach (PeptideWithSetModifications p in psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).Distinct()) { peptide_ids[p.FullSequence].Item2.Add("SII_" + scan_result_scan_item.Item1 + "_" + scan_result_scan_item.Item2); } @@ -421,7 +421,7 @@ public static void WriteMzIdentMl(IEnumerable psms, List p.Peptide).Distinct().Count()], + PeptideEvidenceRef = new mzIdentML110.Generated.PeptideEvidenceRefType[psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).Distinct().Count()], cvParam = new mzIdentML110.Generated.CVParamType[2] { new mzIdentML110.Generated.CVParamType @@ -440,14 +440,14 @@ public static void WriteMzIdentMl(IEnumerable psms, List p.Peptide).Distinct()) + foreach (PeptideWithSetModifications p in psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).Distinct()) { _mzid.DataCollection.AnalysisData.SpectrumIdentificationList[0].SpectrumIdentificationResult[scan_result_scan_item.Item1].SpectrumIdentificationItem[scan_result_scan_item.Item2].PeptideEvidenceRef[pe] = new mzIdentML110.Generated.PeptideEvidenceRefType diff --git a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs index 1251e6dd0..58a0dafda 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs @@ -17,7 +17,7 @@ public class PostSearchAnalysisParameters public List FixedModifications { get; set; } public Modification MultiplexModification { get; set; } public HashSet ListOfDigestionParams { get; set; } - public List AllPsms { get; set; } + public List AllPsms { get; set; } public FlashLfqResults FlashLfqResults { get; set; } public int NumNotches { get; set; } public string OutputFolder { get; set; } diff --git a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs index f131b32ab..5c5fe3747 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs @@ -30,9 +30,9 @@ public class PostSearchAnalysisTask : MetaMorpheusTask { public PostSearchAnalysisParameters Parameters { get; set; } private List ProteinGroups { get; set; } - private IEnumerable> PsmsGroupedByFile { get; set; } + private IEnumerable> PsmsGroupedByFile { get; set; } private SpectralRecoveryResults SpectralRecoveryResults { get; set; } - private List _filteredPsms; + private List _filteredPsms; private bool _pepFilteringNotPerformed; private string _filterType; private double _filterThreshold; @@ -66,8 +66,8 @@ public MyTaskResults Run() Parameters.AllPsms = Parameters.AllPsms.Where(psm => psm != null).ToList(); Parameters.AllPsms.ForEach(psm => psm.ResolveAllAmbiguities()); Parameters.AllPsms = Parameters.AllPsms.OrderByDescending(b => b.Score) - .ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue) - .GroupBy(b => (b.FullFilePath, b.ScanNumber, b.PeptideMonisotopicMass)).Select(b => b.First()).ToList(); + .ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue) + .GroupBy(b => (b.FullFilePath, b.ScanNumber, b.BioPolymerWithSetModsMonoisotopicMass)).Select(b => b.First()).ToList(); CalculatePsmFdr(); } @@ -156,7 +156,7 @@ private void FilterAllPsms() PsmsGroupedByFile = Parameters.AllPsms.GroupBy(p => p.FullFilePath); } - public IEnumerable GetFilteredPsms(bool includeDecoys, bool includeContaminants, + public IEnumerable GetFilteredPsms(bool includeDecoys, bool includeContaminants, bool includeAmbiguous) { return _filteredPsms.Where(p => @@ -170,7 +170,7 @@ public IEnumerable GetFilteredPsms(bool includeDecoys, boo /// /// A list of PSMs to be modified in place /// The number of target psms scoring below threshold - private void FilterSpecificPsms(List fileSpecificPsmsOrPeptides, out int psmOrPeptideCountForResults) + private void FilterSpecificPsms(List fileSpecificPsmsOrPeptides, out int psmOrPeptideCountForResults) { psmOrPeptideCountForResults = _filterType.Equals("q-value") ? fileSpecificPsmsOrPeptides.Count(p => @@ -238,17 +238,17 @@ private void ProteinAnalysis() Status("Constructing protein groups...", Parameters.SearchTaskId); //if SILAC, modify the proteins to appear only light (we want a protein sequence to look like PROTEINK instead of PROTEINa) - if (Parameters.SearchParameters.SilacLabels != null) + if (Parameters.SearchParameters.SilacLabels != null && Parameters.AllPsms.First() is PeptideSpectralMatch) { - Parameters.AllPsms = SilacConversions.UpdateProteinSequencesToLight(Parameters.AllPsms, Parameters.SearchParameters.SilacLabels); - foreach (PeptideSpectralMatch psm in Parameters.AllPsms) + Parameters.AllPsms = SilacConversions.UpdateProteinSequencesToLight(Parameters.AllPsms.Cast().ToList(), Parameters.SearchParameters.SilacLabels); + foreach (SpectralMatch psm in Parameters.AllPsms) { psm.ResolveAllAmbiguities(); } FilterAllPsms(); } - List psmsForProteinParsimony = Parameters.AllPsms; + List psmsForProteinParsimony = Parameters.AllPsms; // run parsimony ProteinParsimonyResults proteinAnalysisResults = (ProteinParsimonyResults)(new ProteinParsimonyEngine(psmsForProteinParsimony, Parameters.SearchParameters.ModPeptidesAreDifferent, CommonParameters, this.FileSpecificParameters, new List { Parameters.SearchTaskId }).Run()); @@ -364,7 +364,7 @@ private void QuantificationAnalysis() includeAmbiguous: false); // pass protein group info for each PSM - var psmToProteinGroups = new Dictionary>(); + var psmToProteinGroups = new Dictionary>(); if (ProteinGroups != null && ProteinGroups.Count != 0) //ProteinGroups can be null if parsimony wasn't done, and it can be empty if you're doing the two peptide rule { foreach (var proteinGroup in ProteinGroups) @@ -394,7 +394,7 @@ private void QuantificationAnalysis() var accessionToPg = new Dictionary(); foreach (var psm in unambiguousPsmsBelowOnePercentFdr) { - var proteins = psm.BestMatchingPeptides.Select(b => b.Peptide.Protein).Distinct(); + var proteins = psm.BestMatchingBioPolymersWithSetMods.Select(b => b.Peptide.Parent).Distinct(); foreach (var protein in proteins) { @@ -445,8 +445,8 @@ private void QuantificationAnalysis() //get easy access to values we need for new psm generation string unlabeledBaseSequence = lightPsm.BaseSequence; - int notch = psm.BestMatchingPeptides.First().Notch; - PeptideWithSetModifications pwsm = psm.BestMatchingPeptides.First().Peptide; + int notch = psm.BestMatchingBioPolymersWithSetMods.First().Notch; + PeptideWithSetModifications pwsm = psm.BestMatchingBioPolymersWithSetMods.First().Peptide as PeptideWithSetModifications; //check if turnover or multiplex experiment if (startLabel == null && endLabel == null) //if multiplex @@ -547,14 +547,14 @@ private void QuantificationAnalysis() // the peptides should still be quantified but not considered for protein quantification var undefinedPg = new FlashLFQ.ProteinGroup("UNDEFINED", "", ""); //sort the unambiguous psms by protease to make MBR compatible with multiple proteases - Dictionary> proteaseSortedPsms = new Dictionary>(); + Dictionary> proteaseSortedPsms = new Dictionary>(); Dictionary proteaseSortedFlashLFQResults = new Dictionary(); foreach (DigestionParams dp in Parameters.ListOfDigestionParams) { if (!proteaseSortedPsms.ContainsKey(dp.Protease)) { - proteaseSortedPsms.Add(dp.Protease, new List()); + proteaseSortedPsms.Add(dp.Protease, new List()); } } foreach (var psm in unambiguousPsmsBelowOnePercentFdr) @@ -576,7 +576,7 @@ private void QuantificationAnalysis() foreach (var psm in spectraFile) { flashLFQIdentifications.Add(new Identification(rawfileinfo, psm.BaseSequence, psm.FullSequence, - psm.PeptideMonisotopicMass.Value, psm.ScanRetentionTime, psm.ScanPrecursorCharge, psmToProteinGroups[psm])); + psm.BioPolymerWithSetModsMonoisotopicMass.Value, psm.ScanRetentionTime, psm.ScanPrecursorCharge, psmToProteinGroups[psm])); } } @@ -618,10 +618,10 @@ private void QuantificationAnalysis() } //Silac stuff for post-quantification - if (Parameters.SearchParameters.SilacLabels != null) //if we're doing silac + if (Parameters.SearchParameters.SilacLabels != null && Parameters.AllPsms.First() is PeptideSpectralMatch) //if we're doing silac { SilacConversions.SilacConversionsPostQuantification(allSilacLabels, startLabel, endLabel, spectraFileInfo, ProteinGroups, Parameters.ListOfDigestionParams, - Parameters.FlashLfqResults, Parameters.AllPsms, Parameters.SearchParameters.ModsToWriteSelection, quantifyUnlabeledPeptides); + Parameters.FlashLfqResults, Parameters.AllPsms.Cast().ToList(), Parameters.SearchParameters.ModsToWriteSelection, quantifyUnlabeledPeptides); } } @@ -651,11 +651,11 @@ private void HistogramAnalysis() /// /// PSMs to be written /// Full file path, up to and including the filename and extensioh. - protected void WritePsmsToTsv(IEnumerable psms, string filePath) + protected void WritePsmsToTsv(IEnumerable psms, string filePath) { if (Parameters.SearchParameters.DoMultiplexQuantification && Parameters.MultiplexModification != null && - psms.Any(p => p.BestMatchingPeptides + psms.Any(p => p.BestMatchingBioPolymersWithSetMods .SelectMany(pwsm => pwsm.Peptide.AllModsOneIsNterminus.Values) .Any(mod => mod.OriginalId.Equals(Parameters.MultiplexModification.OriginalId)))) { @@ -677,7 +677,7 @@ private void WritePsmResults() includeAmbiguous: true).ToList(); // If filter output is false, we need to write all psms, not just ones with Q-value < threshold - List filteredPsmListForOutput = Parameters.SearchParameters.WriteHighQValuePsms + List filteredPsmListForOutput = Parameters.SearchParameters.WriteHighQValuePsms ? Parameters.AllPsms.Where(p => (Parameters.SearchParameters.WriteDecoys || !p.IsDecoy) && (Parameters.SearchParameters.WriteContaminants || !p.IsContaminant)) @@ -762,10 +762,10 @@ private void UpdateSpectralLibrary() includeAmbiguous: false); //group psms by peptide and charge, the psms having same sequence and same charge will be in the same group - Dictionary<(String, int), List> PsmsGroupByPeptideAndCharge = new Dictionary<(String, int), List>(); + Dictionary<(String, int), List> PsmsGroupByPeptideAndCharge = new Dictionary<(String, int), List>(); foreach (var x in filteredPsmList) { - List psmsWithSamePeptideAndSameCharge = filteredPsmList.Where(b => b.FullSequence == x.FullSequence && b.ScanPrecursorCharge == x.ScanPrecursorCharge).OrderByDescending(p => p.Score).ToList(); + List psmsWithSamePeptideAndSameCharge = filteredPsmList.Where(b => b.FullSequence == x.FullSequence && b.ScanPrecursorCharge == x.ScanPrecursorCharge).OrderByDescending(p => p.Score).ToList(); (String, int) peptideWithChargeState = (x.FullSequence, x.ScanPrecursorCharge); if (!PsmsGroupByPeptideAndCharge.ContainsKey(peptideWithChargeState)) @@ -775,7 +775,7 @@ private void UpdateSpectralLibrary() } //group psms by peptide and charge, then write highest scoring PSM to dictionary - Dictionary<(string, int), PeptideSpectralMatch> psmSeqChargeDictionary = filteredPsmList + Dictionary<(string, int), SpectralMatch> psmSeqChargeDictionary = filteredPsmList .GroupBy(p => (p.FullSequence, p.ScanPrecursorCharge)) .ToDictionary( // Key is a (FullSequence, Charge) tuple @@ -845,7 +845,7 @@ private void SpectralLibraryGeneration() List spectraLibrary = new(); foreach (var matchGroup in fullSeqChargeGrouping) { - PeptideSpectralMatch bestPsm = matchGroup.MaxBy(p => p.Score); + SpectralMatch bestPsm = matchGroup.MaxBy(p => p.Score); if (bestPsm == null) continue; spectraLibrary.Add(new LibrarySpectrum( bestPsm.FullSequence, @@ -892,7 +892,7 @@ private void WriteProteinResults() EngineLayer.ProteinGroup firstProteinGroup = ProteinGroups.FirstOrDefault(); //grab the first protein to extract the files used for quantification if (firstProteinGroup != null) //check that we even have a protein group to write { - var tempPsmsGroupedByFile = new List>(); + var tempPsmsGroupedByFile = new List>(); //foreach original file foreach (string originalFile in fileNamesThatHadPsms) { @@ -907,7 +907,7 @@ private void WriteProteinResults() } //rename the file group for all of the relevant psms to their original file - List psms = PsmsGroupedByFile.Where(g => labeledFiles.Contains(g.Key)).SelectMany(x => x).ToList(); //grab all the psms + List psms = PsmsGroupedByFile.Where(g => labeledFiles.Contains(g.Key)).SelectMany(x => x).ToList(); //grab all the psms tempPsmsGroupedByFile.AddRange(psms.GroupBy(x => originalFile)); } //overwrite the grouping for downstream processing @@ -920,7 +920,7 @@ private void WriteProteinResults() { string strippedFileName = Path.GetFileNameWithoutExtension(fullFilePath); - List psmsForThisFile = PsmsGroupedByFile.Where(p => p.Key == fullFilePath).SelectMany(g => g).ToList(); + List psmsForThisFile = PsmsGroupedByFile.Where(p => p.Key == fullFilePath).SelectMany(g => g).ToList(); var subsetProteinGroupsForThisFile = ProteinGroups.Select(p => p.ConstructSubsetProteinGroup(fullFilePath, Parameters.SearchParameters.SilacLabels)).ToList(); ProteinScoringAndFdrResults subsetProteinScoringAndFdrResults = (ProteinScoringAndFdrResults)new ProteinScoringAndFdrEngine(subsetProteinGroupsForThisFile, psmsForThisFile, @@ -1046,11 +1046,11 @@ private void WritePrunedDatabase() var proteinToConfidentBaseSequences = new Dictionary>(); // associate all confident PSMs with all possible proteins they could be digest products of (before or after parsimony) - foreach (PeptideSpectralMatch psm in confidentPsms) + foreach (SpectralMatch psm in confidentPsms) { - var myPepsWithSetMods = psm.BestMatchingPeptides.Select(p => p.Peptide); + var myPepsWithSetMods = psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide); - foreach (var peptide in myPepsWithSetMods) + foreach (PeptideWithSetModifications peptide in myPepsWithSetMods) { if (proteinToConfidentBaseSequences.TryGetValue(peptide.Protein.NonVariantProtein, out var myPepList)) { @@ -1096,11 +1096,11 @@ private void WritePrunedDatabase() HashSet originalModPsmsFullSeq = originalModPsms.Select(p => p.FullSequence).ToHashSet(); modPsmsFullSeq.ExceptWith(originalModPsmsFullSeq); - foreach (PeptideSpectralMatch psm in modPsms) + foreach (SpectralMatch psm in modPsms) { - var myPepsWithSetMods = psm.BestMatchingPeptides.Select(p => p.Peptide); + var myPepsWithSetMods = psm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide); - foreach (var peptide in myPepsWithSetMods) + foreach (PeptideWithSetModifications peptide in myPepsWithSetMods) { if (proteinToConfidentModifiedSequences.TryGetValue(peptide.Protein.NonVariantProtein, out var myPepList)) { @@ -1317,7 +1317,7 @@ private void WritePeptideResults() // write best (highest-scoring) PSM per peptide string filename = "All" + GlobalVariables.AnalyteType + "s.psmtsv"; string writtenFile = Path.Combine(Parameters.OutputFolder, filename); - List peptides = Parameters.AllPsms + List peptides = Parameters.AllPsms .GroupBy(b => b.FullSequence) .Select(b => b.FirstOrDefault()).ToList(); @@ -1372,7 +1372,7 @@ private void WritePeptideResults() } } - private void WritePsmPlusMultiplexIons(IEnumerable psms, string filePath) + private void WritePsmPlusMultiplexIons(IEnumerable psms, string filePath) { PpmTolerance ionTolerance = new PpmTolerance(10); double[] reporterIonMzs = Parameters.MultiplexModification.DiagnosticIons.First().Value @@ -1382,7 +1382,7 @@ private void WritePsmPlusMultiplexIons(IEnumerable psms, s using (StreamWriter output = new StreamWriter(filePath)) { - string headerWithReporterIons = PeptideSpectralMatch.GetTabSeparatedHeader().Trim() + '\t' + + string headerWithReporterIons = SpectralMatch.GetTabSeparatedHeader().Trim() + '\t' + GetMultiplexHeader(); output.WriteLine(headerWithReporterIons); foreach (var psm in psms) @@ -1492,7 +1492,7 @@ private void WriteVariantResults() .ToList(); var possibleVariantPsms = fdrPsms.Where(p => - p.BestMatchingPeptides.Any(pep => pep.Peptide.IsVariantPeptide())) + p.BestMatchingBioPolymersWithSetMods.Any(pep => pep.Peptide is PeptideWithSetModifications pwsm && pwsm.IsVariantPeptide())) .OrderByDescending(pep => pep.Score) .ToList(); @@ -1508,12 +1508,12 @@ private void WriteVariantResults() FilterSpecificPsms(possibleVariantPsms, out int countOfConfidentPsms); WritePsmsToTsv(possibleVariantPsms, variantPsmFile); - List variantPeptides = possibleVariantPsms + List variantPeptides = possibleVariantPsms .GroupBy(b => b.FullSequence) .Select(b => b.FirstOrDefault()) .OrderByDescending(b => b.Score) .ToList(); - List confidentVariantPeps = new List(); + List confidentVariantPeps = new List(); new FdrAnalysisEngine(variantPeptides, Parameters.NumNotches, CommonParameters, FileSpecificParameters, new List { Parameters.SearchTaskId }, "variant_Peptides").Run(); @@ -1524,8 +1524,8 @@ private void WriteVariantResults() //because it is most probable that the peptide originated from the canonical protien. foreach (var entry in variantPeptides) { - var pwsm = entry.BestMatchingPeptides; - var nonVariantOption = pwsm.Any(p => p.Peptide.IsVariantPeptide() == false); + var pwsm = entry.BestMatchingBioPolymersWithSetMods; + var nonVariantOption = pwsm.Any(p => p.Peptide is PeptideWithSetModifications pwsm && pwsm.IsVariantPeptide() == false); if (nonVariantOption == false) { confidentVariantPeps.Add(entry); @@ -1552,16 +1552,19 @@ private void WriteVariantResults() FilterSpecificPsms(confidentVariantPeps, out int countOfConfidentPeptides); // Filter psms in place List modifiedVariantPeptides = confidentVariantPeps - .Where(p => p.ModsIdentified != null && p.ModsIdentified.Count > 0) + .Where(p => p.ModsIdentified != null && p.ModsIdentified.Count > 0 && p is PeptideSpectralMatch) + .Select(p => (PeptideSpectralMatch)p) .ToList(); //modification can be on any AA in variant peptide List modifiedVariantSitePeptides = new();// modification is speciifcally on the variant residue within the peptide - foreach (var entry in modifiedVariantPeptides) + foreach (PeptideSpectralMatch entry in modifiedVariantPeptides) { - var variantPWSM = entry.BestMatchingPeptides.FirstOrDefault().Peptide; + PeptideWithSetModifications firstOrDefault = entry.BestMatchingBioPolymersWithSetMods.FirstOrDefault().Peptide as PeptideWithSetModifications; + + var variantPWSM = firstOrDefault; var peptideMods = variantPWSM.AllModsOneIsNterminus.Values.ToList(); - var variantProteinModifications = variantPWSM.Protein.OneBasedPossibleLocalizedModifications.Where(k => k.Key >= variantPWSM.OneBasedStartResidueInProtein && k.Key <= variantPWSM.OneBasedEndResidueInProtein).ToList(); - var variants = entry.BestMatchingPeptides.FirstOrDefault().Peptide.Protein.AppliedSequenceVariations.Where(v => entry.BestMatchingPeptides.FirstOrDefault().Peptide.IntersectsAndIdentifiesVariation(v).identifies).ToList(); + var variantProteinModifications = variantPWSM.Parent.OneBasedPossibleLocalizedModifications.Where(k => k.Key >= variantPWSM.OneBasedStartResidue && k.Key <= variantPWSM.OneBasedEndResidue).ToList(); + var variants = firstOrDefault.Protein.AppliedSequenceVariations.Where(v => firstOrDefault.IntersectsAndIdentifiesVariation(v).identifies).ToList(); bool modifiedVariant = false; foreach (var mod in variantProteinModifications) { @@ -1580,7 +1583,11 @@ private void WriteVariantResults() } foreach (var peptide in confidentVariantPeps) { - var variantPWSM = peptide.BestMatchingPeptides.FirstOrDefault();//TODO: expand to all peptide options not just the first + var variantPWSM = + peptide.BestMatchingBioPolymersWithSetMods.FirstOrDefault() is (_, PeptideWithSetModifications) + ? ((int Notch, PeptideWithSetModifications Peptide))peptide.BestMatchingBioPolymersWithSetMods + .FirstOrDefault() + : (0, null);//TODO: expand to all peptide options not just the first var variants = variantPWSM.Peptide.Protein.AppliedSequenceVariations; var culture = CultureInfo.CurrentCulture; // these bools allow for us to accurrately count the number of peptides that have at least one variants of a given type. @@ -1790,13 +1797,13 @@ private static int GetOneBasedIndexInProtein(int oneIsNterminus, PeptideWithSetM { if (oneIsNterminus == 1) { - return peptideWithSetModifications.OneBasedStartResidueInProtein; + return peptideWithSetModifications.OneBasedStartResidue; } if (oneIsNterminus == peptideWithSetModifications.Length + 2) { - return peptideWithSetModifications.OneBasedEndResidueInProtein; + return peptideWithSetModifications.OneBasedEndResidue; } - return peptideWithSetModifications.OneBasedStartResidueInProtein + oneIsNterminus - 2; + return peptideWithSetModifications.OneBasedStartResidue + oneIsNterminus - 2; } private static void WriteTree(BinTreeStructure myTreeStructure, string writtenFile) @@ -1837,7 +1844,7 @@ private static void WriteTree(BinTreeStructure myTreeStructure, string writtenFi } } - private static void WritePsmsForPercolator(List psmList, string writtenFileForPercolator) + private static void WritePsmsForPercolator(List psmList, string writtenFileForPercolator) { using (StreamWriter output = new StreamWriter(writtenFileForPercolator)) { @@ -1870,16 +1877,16 @@ private static void WritePsmsForPercolator(List psmList, s int idNumber = 0; psmList.OrderByDescending(p => p.Score); - foreach (PeptideSpectralMatch psm in psmList.Where(p => p.PsmData_forPEPandPercolator != null)) + foreach (SpectralMatch psm in psmList.Where(p => p.PsmData_forPEPandPercolator != null)) { - foreach (var peptide in psm.BestMatchingPeptides) + foreach (var peptide in psm.BestMatchingBioPolymersWithSetMods) { output.Write(idNumber.ToString()); - output.Write('\t' + (peptide.Peptide.Protein.IsDecoy ? -1 : 1).ToString()); + output.Write('\t' + (peptide.Peptide.Parent.IsDecoy ? -1 : 1).ToString()); output.Write('\t' + psm.ScanNumber.ToString()); output.Write(psm.PsmData_forPEPandPercolator.ToString(searchType)); - output.Write('\t' + (peptide.Peptide.PreviousAminoAcid + "." + peptide.Peptide.FullSequence + "." + peptide.Peptide.NextAminoAcid).ToString()); - output.Write('\t' + (peptide.Peptide.Protein.Accession).ToString()); + output.Write('\t' + (peptide.Peptide.PreviousResidue + "." + peptide.Peptide.FullSequence + "." + peptide.Peptide.NextResidue).ToString()); + output.Write('\t' + (peptide.Peptide.Parent.Accession).ToString()); output.WriteLine(); } idNumber++; diff --git a/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs b/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs index 2565349e6..1d9245347 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs @@ -16,6 +16,7 @@ using System.Linq; using Omics.Digestion; using Omics.Modifications; +using Omics; namespace TaskLayer { @@ -166,14 +167,14 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List allPsms = new List(); + List allPsms = new List(); //generate an array to store category specific fdr values (for speedy semi/nonspecific searches) int numFdrCategories = (int)(Enum.GetValues(typeof(FdrCategory)).Cast().Last() + 1); //+1 because it starts at zero - List[] allCategorySpecificPsms = new List[numFdrCategories]; + List[] allCategorySpecificPsms = new List[numFdrCategories]; for (int i = 0; i < numFdrCategories; i++) { - allCategorySpecificPsms[i] = new List(); + allCategorySpecificPsms[i] = new List(); } FlashLfqResults flashLfqResults = null; @@ -212,7 +213,7 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List p.MsnOrder == 2), arrayOfMs2ScansSortedByMass.Length }); myFileManager.DoneWithFile(origDataFile); - PeptideSpectralMatch[] fileSpecificPsms = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; + SpectralMatch[] fileSpecificPsms = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; // modern search if (SearchParameters.SearchType == SearchType.Modern) @@ -247,7 +248,7 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List 0) + SpectralMatch psm = fileSpecificPsms[index]; + if (psm != null && psm.BestMatchingBioPolymersWithSetMods.Count() > 0) { //Get the scan Ms2ScanWithSpecificMass scanForThisPsm = arrayOfMs2ScansSortedByMass[index]; @@ -494,9 +495,9 @@ public static void MatchInternalFragmentIons(PeptideSpectralMatch[] fileSpecific scanForThisPsm.TheScan.DissociationType.Value : combinedParams.DissociationType; //Get the theoretical peptides - List ambiguousPeptides = new List(); + List ambiguousPeptides = new List(); List notches = new List(); - foreach (var (Notch, Peptide) in psm.BestMatchingPeptides) + foreach (var (Notch, Peptide) in psm.BestMatchingBioPolymersWithSetMods) { ambiguousPeptides.Add(Peptide); notches.Add(Notch); @@ -518,7 +519,7 @@ public static void MatchInternalFragmentIons(PeptideSpectralMatch[] fileSpecific //remove peptides if they have fewer than max-1 matched ions, thus requiring at least two internal ions to disambiguate an ID //if not removed, then add the matched internal ions - HashSet PeptidesToMatchingInternalFragments = new HashSet(); + HashSet PeptidesToMatchingInternalFragments = new HashSet(); for (int peptideIndex = 0; peptideIndex < ambiguousPeptides.Count; peptideIndex++) { //if we should remove the theoretical, remove it @@ -529,12 +530,12 @@ public static void MatchInternalFragmentIons(PeptideSpectralMatch[] fileSpecific // otherwise add the matched internal ions to the total ions else { - PeptideWithSetModifications currentPwsm = ambiguousPeptides[peptideIndex]; + IBioPolymerWithSetMods currentPwsm = ambiguousPeptides[peptideIndex]; //check that we haven't already added the matched ions for this peptide if (!PeptidesToMatchingInternalFragments.Contains(currentPwsm)) { PeptidesToMatchingInternalFragments.Add(currentPwsm); //record that we've seen this peptide - psm.PeptidesToMatchingFragments[currentPwsm].AddRange(matchedIonsForAllAmbiguousPeptides[peptideIndex]); //add the matched ions + psm.BioPolymersWithSetModsToMatchingFragments[currentPwsm].AddRange(matchedIonsForAllAmbiguousPeptides[peptideIndex]); //add the matched ions } } } diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 889bb446a..b1383bb38 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs index 37057a572..6c53ae85d 100644 --- a/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs @@ -176,10 +176,10 @@ public void WriteCsvFiles(string outputFolder, List inte public void ComputeXlinkQandPValues(List allPsms, List intraCsms, List interCsms, CommonParameters commonParameters, string taskId) { List crossCsms = allPsms.Where(p => p.CrossType == PsmCrossType.Inter || p.CrossType == PsmCrossType.Intra).OrderByDescending(p => p.XLTotalScore).ToList(); - new FdrAnalysisEngine(crossCsms.ToList(), 0, commonParameters, this.FileSpecificParameters, new List { taskId }, "crosslink").Run(); + new FdrAnalysisEngine(crossCsms.ToList(), 0, commonParameters, this.FileSpecificParameters, new List { taskId }, "crosslink").Run(); List singles = allPsms.Where(p => p.CrossType != PsmCrossType.Inter).Where(p => p.CrossType != PsmCrossType.Intra).OrderByDescending(p => p.Score).ToList(); - new FdrAnalysisEngine(singles.ToList(), 0, commonParameters, this.FileSpecificParameters, new List { taskId }, "PSM").Run(); + new FdrAnalysisEngine(singles.ToList(), 0, commonParameters, this.FileSpecificParameters, new List { taskId }, "PSM").Run(); SingleFDRAnalysis(singles, commonParameters, new List { taskId }); // calculate FDR @@ -191,18 +191,18 @@ public void ComputeXlinkQandPValues(List allPsms, List items, CommonParameters commonParameters, List taskIds) { // calculate single PSM FDR - List psms = items.Where(p => p.CrossType == PsmCrossType.Single).Select(p => p as PeptideSpectralMatch).OrderByDescending(p => p.Score).ToList(); + List psms = items.Where(p => p.CrossType == PsmCrossType.Single).Select(p => p as SpectralMatch).OrderByDescending(p => p.Score).ToList(); new FdrAnalysisEngine(psms, 0, commonParameters, this.FileSpecificParameters, taskIds, "skippep").Run(); // calculate loop PSM FDR - psms = items.Where(p => p.CrossType == PsmCrossType.Loop).Select(p => p as PeptideSpectralMatch).OrderByDescending(p => p.Score).ToList(); + psms = items.Where(p => p.CrossType == PsmCrossType.Loop).Select(p => p as SpectralMatch).OrderByDescending(p => p.Score).ToList(); new FdrAnalysisEngine(psms, 0, commonParameters, this.FileSpecificParameters, taskIds, "skippep").Run(); // calculate deadend FDR psms = items.Where(p => p.CrossType == PsmCrossType.DeadEnd || p.CrossType == PsmCrossType.DeadEndH2O || p.CrossType == PsmCrossType.DeadEndNH2 || - p.CrossType == PsmCrossType.DeadEndTris).Select(p => p as PeptideSpectralMatch).OrderByDescending(p => p.Score).ToList(); + p.CrossType == PsmCrossType.DeadEndTris).Select(p => p as SpectralMatch).OrderByDescending(p => p.Score).ToList(); new FdrAnalysisEngine(psms, 0, commonParameters, this.FileSpecificParameters, taskIds, "skippep").Run(); } diff --git a/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs b/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs index 750199ce5..32fadc5c1 100644 --- a/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs +++ b/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs @@ -58,7 +58,7 @@ public static void WriteCrosslinkToTxtForPercolator(List "\tPeptide\tProtein"); foreach (var item in items) { - if (item.BaseSequence != null && item.BetaPeptide.BaseSequence != null && item.ProteinAccession != null && item.BetaPeptide.ProteinAccession != null) + if (item.BaseSequence != null && item.BetaPeptide.BaseSequence != null && item.Accession != null && item.BetaPeptide.Accession != null) { string x = "T"; int label = 1; if (item.IsDecoy || item.BetaPeptide.IsDecoy) @@ -73,14 +73,14 @@ public static void WriteCrosslinkToTxtForPercolator(List + "\t" + item.DeltaScore.ToString(CultureInfo.InvariantCulture) + "\t" + item.ScanPrecursorCharge.ToString(CultureInfo.InvariantCulture) + "\t" + item.ScanPrecursorMass.ToString(CultureInfo.InvariantCulture) - + "\t" + ((item.PeptideMonisotopicMass.HasValue && item.BetaPeptide.PeptideMonisotopicMass.HasValue) ? ((item.ScanPrecursorMass - item.BetaPeptide.PeptideMonisotopicMass.Value - item.PeptideMonisotopicMass.Value - crosslinker.TotalMass) / item.ScanPrecursorMass * 1E6).ToString(CultureInfo.InvariantCulture) : "---") + + "\t" + ((item.BioPolymerWithSetModsMonoisotopicMass.HasValue && item.BetaPeptide.BioPolymerWithSetModsMonoisotopicMass.HasValue) ? ((item.ScanPrecursorMass - item.BetaPeptide.BioPolymerWithSetModsMonoisotopicMass.Value - item.BioPolymerWithSetModsMonoisotopicMass.Value - crosslinker.TotalMass) / item.ScanPrecursorMass * 1E6).ToString(CultureInfo.InvariantCulture) : "---") + "\t" + item.BetaPeptide.BaseSequence.Length.ToString(CultureInfo.InvariantCulture) + "\t" + item.BaseSequence.Length.ToString(CultureInfo.InvariantCulture) + "\t" + (item.BetaPeptide.BaseSequence.Length + item.BaseSequence.Length).ToString(CultureInfo.InvariantCulture) + "\t" + "-." + item.FullSequence + item.LinkPositions.First().ToString(CultureInfo.InvariantCulture) + "--" + item.BetaPeptide.FullSequence + item.BetaPeptide.LinkPositions.First().ToString(CultureInfo.InvariantCulture) + ".-" - + "\t" + item.BestMatchingPeptides.First().Peptide.Protein.Accession.ToString(CultureInfo.InvariantCulture) + + "\t" + item.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.Accession.ToString(CultureInfo.InvariantCulture) + "(" + (item.XlProteinPos.HasValue ? item.XlProteinPos.Value.ToString(CultureInfo.InvariantCulture) : string.Empty) + ")" - + "\t" + item.BetaPeptide.BestMatchingPeptides.First().Peptide.Protein.Accession.ToString(CultureInfo.InvariantCulture) + + "\t" + item.BetaPeptide.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.Accession.ToString(CultureInfo.InvariantCulture) + "(" + (item.BetaPeptide.XlProteinPos.HasValue ? item.BetaPeptide.XlProteinPos.Value.ToString(CultureInfo.InvariantCulture) : string.Empty) + ")" ); } @@ -199,7 +199,7 @@ public static void WritePepXML_xl(List items, List(); - var alphaPeptide = items[i].BestMatchingPeptides.First().Peptide; + var alphaPeptide = items[i].BestMatchingBioPolymersWithSetMods.First().Peptide; foreach (var modification in alphaPeptide.AllModsOneIsNterminus) { @@ -220,12 +220,12 @@ public static void WritePepXML_xl(List items, List items, List items, List(); foreach (var mod in betaPeptide.AllModsOneIsNterminus) @@ -295,11 +295,11 @@ public static void WritePepXML_xl(List items, List items, List items, List RemoveDuplicateFromCsmsPerScan(List(); fsp.Add(("", CommonParameters)); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, @@ -61,7 +61,7 @@ public static void TestAddCompIonsClassic() addCompIons: true); var fsp2 = new List<(string fileName, CommonParameters fileSpecificParameters)>(); fsp2.Add(("", CommonParameters2)); - PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray2, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters2, fsp2, null, new List(), writeSpectralLibrary).Run(); @@ -137,11 +137,11 @@ public static void TestCompIons_ModernSearch() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); // without complementary ions - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // with complementary ions - PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, withCompIons, fspComp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode @@ -215,11 +215,11 @@ public static void TestCompIons_ETHCD_ModernSearch() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); // without complementary ions - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // with complementary ions - PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, withCompIons, fspComp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode @@ -292,11 +292,11 @@ public static void TestCompIons_LowCID_ModernSearch() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); // without complementary ions - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // with complementary ions - PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, withCompIons, fspComp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode @@ -440,7 +440,7 @@ public static void AddCompIonsCommonParams() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(cp.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); // without complementary ions - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; var mse = new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, cp, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); } diff --git a/MetaMorpheus/Test/AmbiguityTest.cs b/MetaMorpheus/Test/AmbiguityTest.cs index 96dbc0e13..1ba0b4186 100644 --- a/MetaMorpheus/Test/AmbiguityTest.cs +++ b/MetaMorpheus/Test/AmbiguityTest.cs @@ -55,9 +55,9 @@ public static void TestResolveAmbiguities() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray_withAmbiguity = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray_withAmbiguity = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray_withOutAmbiguity = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray_withOutAmbiguity = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray_withAmbiguity, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, @@ -67,10 +67,10 @@ public static void TestResolveAmbiguities() Assert.AreEqual("QQQ", allPsmsArray_withAmbiguity[0].BaseSequence); Assert.AreEqual("QQQ", allPsmsArray_withOutAmbiguity[0].BaseSequence); - Assert.IsTrue(allPsmsArray_withAmbiguity[0].ProteinLength == null); - Assert.IsTrue(allPsmsArray_withOutAmbiguity[0].ProteinLength != null); - Assert.IsTrue(allPsmsArray_withAmbiguity[0].OneBasedStartResidueInProtein == null); - Assert.IsTrue(allPsmsArray_withOutAmbiguity[0].OneBasedStartResidueInProtein != null); + Assert.IsTrue(allPsmsArray_withAmbiguity[0].ParentLength == null); + Assert.IsTrue(allPsmsArray_withOutAmbiguity[0].ParentLength != null); + Assert.IsTrue(allPsmsArray_withAmbiguity[0].OneBasedStartResidue == null); + Assert.IsTrue(allPsmsArray_withOutAmbiguity[0].OneBasedStartResidue != null); } [Test] diff --git a/MetaMorpheus/Test/AnalysisEngineTest.cs b/MetaMorpheus/Test/AnalysisEngineTest.cs index a4cd54884..548cedb1e 100644 --- a/MetaMorpheus/Test/AnalysisEngineTest.cs +++ b/MetaMorpheus/Test/AnalysisEngineTest.cs @@ -77,16 +77,16 @@ public static void TestAnalysisEngineTests() Ms2ScanWithSpecificMass scanB = new Ms2ScanWithSpecificMass(new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 3, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=2", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 1, null), 2 + 132.040, 1, null, new CommonParameters()); Ms2ScanWithSpecificMass scanC = new Ms2ScanWithSpecificMass(new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 4, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=3", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 1, null), 3, 1, null, new CommonParameters()); - PeptideSpectralMatch matchA = new PeptideSpectralMatch(compactPeptide1, 0, 0, 0, scanA, CommonParameters, new List()); - PeptideSpectralMatch matchB = new PeptideSpectralMatch(compactPeptide2, 0, 0, 0, scanB, CommonParameters, new List()); - PeptideSpectralMatch matchC = new PeptideSpectralMatch(compactPeptide3, 0, 0, 0, scanC, CommonParameters, new List()); + SpectralMatch matchA = new PeptideSpectralMatch(compactPeptide1, 0, 0, 0, scanA, CommonParameters, new List()); + SpectralMatch matchB = new PeptideSpectralMatch(compactPeptide2, 0, 0, 0, scanB, CommonParameters, new List()); + SpectralMatch matchC = new PeptideSpectralMatch(compactPeptide3, 0, 0, 0, scanC, CommonParameters, new List()); - var newPsms = new List { matchA, matchB, matchC }; + var newPsms = new List { matchA, matchB, matchC }; MsDataFile myMsDataFile = new TestDataFile(new List { value1.First(), value2.First(), value3.First() }); var searchMode = new SinglePpmAroundZeroSearchMode(5); - Action, string, List> action2 = (List l, string s, List sdf) => {; }; + Action, string, List> action2 = (List l, string s, List sdf) => {; }; Tolerance DeconvolutionMassTolerance = new PpmTolerance(5); diff --git a/MetaMorpheus/Test/CoIsolationTests.cs b/MetaMorpheus/Test/CoIsolationTests.cs index 5f932119f..0c4748ca9 100644 --- a/MetaMorpheus/Test/CoIsolationTests.cs +++ b/MetaMorpheus/Test/CoIsolationTests.cs @@ -63,7 +63,7 @@ public static void TestCoIsolation() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters(deconvolutionIntensityRatio: 50)).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; ; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; ; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, diff --git a/MetaMorpheus/Test/EventArgsTest.cs b/MetaMorpheus/Test/EventArgsTest.cs index 986630c16..9a489d430 100644 --- a/MetaMorpheus/Test/EventArgsTest.cs +++ b/MetaMorpheus/Test/EventArgsTest.cs @@ -44,9 +44,9 @@ public static void SingleEventArgsTest() ps.Fragment(DissociationType.HCD, FragmentationTerminus.Both, theoreticalProducts); var matchedIons = MetaMorpheusEngine.MatchFragmentIons(scan, theoreticalProducts, new CommonParameters()); - PeptideSpectralMatch newPsm = new PeptideSpectralMatch(ps, 0, 0, 2, scan, commonParameters, matchedIons); + SpectralMatch newPsm = new PeptideSpectralMatch(ps, 0, 0, 2, scan, commonParameters, matchedIons); - LocalizationEngine f = new LocalizationEngine(new List { newPsm }, myMsDataFile, new CommonParameters(), fsp, new List()); + LocalizationEngine f = new LocalizationEngine(new List { newPsm }, myMsDataFile, new CommonParameters(), fsp, new List()); var singleEngine= new SingleEngineEventArgs(f); Assert.That(singleEngine.MyEngine.Equals(f)); diff --git a/MetaMorpheus/Test/FdrTest.cs b/MetaMorpheus/Test/FdrTest.cs index 80de8d810..489cf247e 100644 --- a/MetaMorpheus/Test/FdrTest.cs +++ b/MetaMorpheus/Test/FdrTest.cs @@ -18,6 +18,7 @@ using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; +using Omics; namespace Test { @@ -65,20 +66,20 @@ public static void FdrTestMethod() MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, pep1.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 3, 0, scan1, commonParameters, new List()); + SpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 3, 0, scan1, commonParameters, new List()); MsDataScan mzLibScan2 = t.GetOneBasedScan(4); Ms2ScanWithSpecificMass scan2 = new Ms2ScanWithSpecificMass(mzLibScan2, pep2.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); - PeptideSpectralMatch psm2 = new PeptideSpectralMatch(pep2, 1, 2, 1, scan2, commonParameters, new List()); + SpectralMatch psm2 = new PeptideSpectralMatch(pep2, 1, 2, 1, scan2, commonParameters, new List()); MsDataScan mzLibScan3 = t.GetOneBasedScan(6); Ms2ScanWithSpecificMass scan3 = new Ms2ScanWithSpecificMass(mzLibScan3, pep3.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); - PeptideSpectralMatch psm3 = new PeptideSpectralMatch(pep3, 0, 1, 2, scan3, commonParameters, new List()); + SpectralMatch psm3 = new PeptideSpectralMatch(pep3, 0, 1, 2, scan3, commonParameters, new List()); psm3.AddOrReplace(pep4, 1, 1, true, new List(), 0); - var newPsms = new List { psm1, psm2, psm3 }; - foreach (PeptideSpectralMatch psm in newPsms) + var newPsms = new List { psm1, psm2, psm3 }; + foreach (SpectralMatch psm in newPsms) { psm.ResolveAllAmbiguities(); } @@ -125,20 +126,20 @@ public static void FdrAnalysisEngineFileSpecificParametersNotNull() MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, pep1.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 3, 0, scan1, commonParameters, new List()); + SpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 3, 0, scan1, commonParameters, new List()); MsDataScan mzLibScan2 = t.GetOneBasedScan(4); Ms2ScanWithSpecificMass scan2 = new Ms2ScanWithSpecificMass(mzLibScan2, pep2.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); - PeptideSpectralMatch psm2 = new PeptideSpectralMatch(pep2, 1, 2, 1, scan2, commonParameters, new List()); + SpectralMatch psm2 = new PeptideSpectralMatch(pep2, 1, 2, 1, scan2, commonParameters, new List()); MsDataScan mzLibScan3 = t.GetOneBasedScan(6); Ms2ScanWithSpecificMass scan3 = new Ms2ScanWithSpecificMass(mzLibScan3, pep3.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); - PeptideSpectralMatch psm3 = new PeptideSpectralMatch(pep3, 0, 1, 2, scan3, commonParameters, new List()); + SpectralMatch psm3 = new PeptideSpectralMatch(pep3, 0, 1, 2, scan3, commonParameters, new List()); psm3.AddOrReplace(pep4, 1, 1, true, new List(), 0); - var newPsms = new List { psm1, psm2, psm3 }; - foreach (PeptideSpectralMatch psm in newPsms) + var newPsms = new List { psm1, psm2, psm3 }; + foreach (SpectralMatch psm in newPsms) { psm.ResolveAllAmbiguities(); } @@ -184,7 +185,7 @@ public static void TestDeltaValues() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); //check better when using delta - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, fsp, null, new List(), SearchParameters.WriteSpectralLibrary).Run(); @@ -193,7 +194,7 @@ public static void TestDeltaValues() var indexResults = (IndexingResults)indexEngine.Run(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[] allPsmsArrayModern = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArrayModern = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArrayModern, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, fsp, massDiffAcceptor, 0, new List()).Run(); FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, fsp, new List()).Run()); @@ -279,7 +280,7 @@ public static void TestComputePEPValue() List proteinList = ProteinDbLoader.LoadProteinFasta(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\hela_snip_for_unitTest.fasta"), true, DecoyType.Reverse, false, out var dbErrors, ProteinDbLoader.UniprotAccessionRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotGeneNameRegex, ProteinDbLoader.UniprotOrganismRegex, -1); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML", CommonParameters).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, fsp, null, new List(), SearchParameters.WriteSpectralLibrary).Run(); FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.Where(p => p != null).ToList(), 1, @@ -289,14 +290,14 @@ public static void TestComputePEPValue() var nonNullPsmsOriginalCopy = allPsmsArray.Where(p => p != null).ToList(); var maxScore = nonNullPsms.Select(n => n.Score).Max(); - PeptideSpectralMatch maxScorePsm = nonNullPsms.Where(n => n.Score == maxScore).First(); + SpectralMatch maxScorePsm = nonNullPsms.Where(n => n.Score == maxScore).First(); Dictionary sequenceToPsmCount = new Dictionary(); List sequences = new List(); - foreach (PeptideSpectralMatch psm in nonNullPsms) + foreach (SpectralMatch psm in nonNullPsms) { - var ss = psm.BestMatchingPeptides.Select(b => b.Peptide.FullSequence).ToList(); + var ss = psm.BestMatchingBioPolymersWithSetMods.Select(b => b.Peptide.FullSequence).ToList(); sequences.Add(String.Join("|", ss)); } @@ -321,30 +322,30 @@ public static void TestComputePEPValue() fileSpecificRetTimeHI_behavior.Add("TaGe_SA_HeLa_04_subset_longestSeq.mzML", HI_Time_avg_dev); int chargeStateMode = 4; - var (notch, pwsm) = maxScorePsm.BestMatchingPeptides.First(); + var (notch, pwsm) = maxScorePsm.BestMatchingBioPolymersWithSetMods.First(); Dictionary massError = new Dictionary { { Path.GetFileName(maxScorePsm.FullFilePath), 0 } }; - var maxPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("standard", fsp, maxScorePsm, sequenceToPsmCount, fileSpecificRetTimeHI_behavior, fileSpecificRetTemHI_behaviorModifiedPeptides, massError, chargeStateMode, pwsm, notch, !pwsm.Protein.IsDecoy); - Assert.That(maxScorePsm.PeptidesToMatchingFragments.Count - 1, Is.EqualTo(maxPsmData.Ambiguity)); + var maxPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("standard", fsp, maxScorePsm, sequenceToPsmCount, fileSpecificRetTimeHI_behavior, fileSpecificRetTemHI_behaviorModifiedPeptides, massError, chargeStateMode, pwsm, notch, !pwsm.Parent.IsDecoy); + Assert.That(maxScorePsm.BioPolymersWithSetModsToMatchingFragments.Count - 1, Is.EqualTo(maxPsmData.Ambiguity)); double normalizationFactor = (double)pwsm.BaseSequence.Length; float maxPsmDeltaScore = (float)Math.Round(maxScorePsm.DeltaScore / normalizationFactor * 10.0, 0); Assert.That(maxPsmDeltaScore, Is.EqualTo(maxPsmData.DeltaScore).Within(0.05)); float maxPsmIntensity = Math.Min(50, (float)Math.Round((maxScorePsm.Score - (int)maxScorePsm.Score) / normalizationFactor * 100.0, 0)); Assert.That(maxPsmIntensity, Is.EqualTo(maxPsmData.Intensity).Within(0.05)); Assert.That(maxPsmData.HydrophobicityZScore, Is.EqualTo(52.0).Within(0.05)); - Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().MissedCleavages, Is.EqualTo(maxPsmData.MissedCleavagesCount)); - Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount)); + Assert.That(maxScorePsm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).First().MissedCleavages, Is.EqualTo(maxPsmData.MissedCleavagesCount)); + Assert.That(maxScorePsm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount)); Assert.That(maxScorePsm.Notch ?? 0, Is.EqualTo(maxPsmData.Notch)); Assert.That(maxScorePsm.PsmCount, Is.EqualTo(maxPsmData.PsmCount)); Assert.That(-Math.Abs(chargeStateMode - maxScorePsm.ScanPrecursorCharge), Is.EqualTo(maxPsmData.PrecursorChargeDiffToMode)); Assert.AreEqual((float)0, maxPsmData.IsVariantPeptide); - List psmCopyForCZETest = nonNullPsms.ToList(); - List psmCopyForPEPFailure = nonNullPsms.ToList(); - List psmCopyForNoOutputFolder = nonNullPsms.ToList(); + List psmCopyForCZETest = nonNullPsms.ToList(); + List psmCopyForPEPFailure = nonNullPsms.ToList(); + List psmCopyForNoOutputFolder = nonNullPsms.ToList(); PEP_Analysis_Cross_Validation.ComputePEPValuesForAllPSMsGeneric(nonNullPsms, "standard", fsp, Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\")); @@ -359,11 +360,11 @@ public static void TestComputePEPValue() } } - List moreNonNullPSMs = new List(); + List moreNonNullPSMs = new List(); for (int i = 0; i < 3; i++) { - foreach (PeptideSpectralMatch psm in nonNullPsms) + foreach (SpectralMatch psm in nonNullPsms) { moreNonNullPSMs.Add(psm); } @@ -382,14 +383,14 @@ public static void TestComputePEPValue() Product prod = new Product(ProductType.b, FragmentationTerminus.N, 1, 1, 1, 0); List mfi = new List { new MatchedFragmentIon(prod, 1, 1.0, 1) }; - PeptideSpectralMatch variantPSM = new PeptideSpectralMatch(varPep, 0, maxScorePsm.Score, maxScorePsm.ScanIndex, scan, new CommonParameters(), mfi); + SpectralMatch variantPSM = new PeptideSpectralMatch(varPep, 0, maxScorePsm.Score, maxScorePsm.ScanIndex, scan, new CommonParameters(), mfi); sequenceToPsmCount = new Dictionary(); sequences = new List(); nonNullPsms.Add(variantPSM); - foreach (PeptideSpectralMatch psm in nonNullPsms) + foreach (SpectralMatch psm in nonNullPsms) { - var ss = psm.BestMatchingPeptides.Select(b => b.Peptide.FullSequence).ToList(); + var ss = psm.BestMatchingBioPolymersWithSetMods.Select(b => b.Peptide.FullSequence).ToList(); sequences.Add(String.Join("|", ss)); } @@ -399,7 +400,7 @@ public static void TestComputePEPValue() { sequenceToPsmCount.Add(grp.Key, grp.Count()); } - var (vnotch, vpwsm) = variantPSM.BestMatchingPeptides.First(); + var (vnotch, vpwsm) = variantPSM.BestMatchingBioPolymersWithSetMods.First(); massError.Add(Path.GetFileName(variantPSM.FullFilePath), 0); PsmData variantPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("standard", fsp, variantPSM, sequenceToPsmCount, fileSpecificRetTimeHI_behavior, fileSpecificRetTemHI_behaviorModifiedPeptides, massError, chargeStateMode, vpwsm, vnotch, !maxScorePsm.IsDecoy); @@ -425,11 +426,11 @@ public static void TestComputePEPValue() } } - List moreNonNullPSMsCZE = new List(); + List moreNonNullPSMsCZE = new List(); for (int i = 0; i < 3; i++) { - foreach (PeptideSpectralMatch psm in psmCopyForCZETest) + foreach (SpectralMatch psm in psmCopyForCZETest) { moreNonNullPSMsCZE.Add(psm); } @@ -477,18 +478,18 @@ public static void TestComputePEPValueTopDown() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, origDataFile, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, fsp, null, new List(), writeSpectralLibrary).Run(); var nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); - List moreNonNullPSMs = new List(); + List moreNonNullPSMs = new List(); int reps = 10; for (int i = 0; i < reps; i++) { - foreach (PeptideSpectralMatch psm in nonNullPsms) + foreach (SpectralMatch psm in nonNullPsms) { moreNonNullPSMs.Add(psm); } @@ -497,12 +498,12 @@ public static void TestComputePEPValueTopDown() FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(moreNonNullPSMs.Where(p => p != null).OrderByDescending(f=>f.Score).ToList(), 1, CommonParameters, fsp, new List(), analysisType: "PSM", outputFolder: Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\")).Run()); var maxScore = nonNullPsms.Select(n => n.Score).Max(); - PeptideSpectralMatch maxScorePsm = nonNullPsms.Where(n => n.Score == maxScore).First(); + SpectralMatch maxScorePsm = nonNullPsms.Where(n => n.Score == maxScore).First(); Dictionary sequenceToPsmCount = new Dictionary(); List sequences = new List(); - foreach (PeptideSpectralMatch psm in nonNullPsms) + foreach (SpectralMatch psm in nonNullPsms) { - var ss = psm.BestMatchingPeptides.Select(b => b.Peptide.FullSequence).ToList(); + var ss = psm.BestMatchingBioPolymersWithSetMods.Select(b => b.Peptide.FullSequence).ToList(); sequences.Add(String.Join(" | ", ss)); } var s = sequences.GroupBy(i => i); @@ -516,22 +517,22 @@ public static void TestComputePEPValueTopDown() Dictionary>> fileSpecificRetTemHI_behaviorModifiedPeptides = new Dictionary>>(); int chargeStateMode = 4; - var (notch, pwsm) = maxScorePsm.BestMatchingPeptides.First(); + var (notch, pwsm) = maxScorePsm.BestMatchingBioPolymersWithSetMods.First(); Dictionary massError = new Dictionary { { Path.GetFileName(maxScorePsm.FullFilePath), 0 } }; - var maxPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("top-down", fsp, maxScorePsm, sequenceToPsmCount, fileSpecificRetTimeHI_behavior, fileSpecificRetTemHI_behaviorModifiedPeptides, massError, chargeStateMode, pwsm, notch, !pwsm.Protein.IsDecoy); - Assert.That(maxScorePsm.PeptidesToMatchingFragments.Count - 1, Is.EqualTo(maxPsmData.Ambiguity)); + var maxPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("top-down", fsp, maxScorePsm, sequenceToPsmCount, fileSpecificRetTimeHI_behavior, fileSpecificRetTemHI_behaviorModifiedPeptides, massError, chargeStateMode, pwsm, notch, !pwsm.Parent.IsDecoy); + Assert.That(maxScorePsm.BioPolymersWithSetModsToMatchingFragments.Count - 1, Is.EqualTo(maxPsmData.Ambiguity)); double normalizationFactor = (double)pwsm.BaseSequence.Length / 10.0; float maxPsmDeltaScore = (float)Math.Round(maxScorePsm.DeltaScore / normalizationFactor * 10.0, 0); Assert.That(maxPsmDeltaScore, Is.EqualTo(maxPsmData.DeltaScore).Within(0.05)); float maxPsmIntensity = (float)Math.Min(50, Math.Round((maxScorePsm.Score - (int)maxScorePsm.Score) / normalizationFactor * 100.0, 0)); Assert.That(maxPsmIntensity, Is.EqualTo(maxPsmData.Intensity).Within(0.05)); Assert.AreEqual(maxPsmData.HydrophobicityZScore, float.NaN); - Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().MissedCleavages, Is.EqualTo(maxPsmData.MissedCleavagesCount)); - Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount)); + Assert.That(maxScorePsm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).First().MissedCleavages, Is.EqualTo(maxPsmData.MissedCleavagesCount)); + Assert.That(maxScorePsm.BestMatchingBioPolymersWithSetMods.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount)); Assert.That(maxScorePsm.Notch ?? 0, Is.EqualTo(maxPsmData.Notch)); Assert.That(maxScorePsm.PsmCount, Is.EqualTo(maxPsmData.PsmCount * reps)); Assert.That(-Math.Abs(chargeStateMode - maxScorePsm.ScanPrecursorCharge), Is.EqualTo(maxPsmData.PrecursorChargeDiffToMode)); @@ -551,7 +552,7 @@ public static void TestPEP_peptideRemoval() PeptideWithSetModifications pwsm = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); - PeptideSpectralMatch psm = new PeptideSpectralMatch(pwsm, 0, 1, 1, scan, new CommonParameters(), new List()); + SpectralMatch psm = new PeptideSpectralMatch(pwsm, 0, 1, 1, scan, new CommonParameters(), new List()); psm.AddOrReplace(pwsm, 1, 1, true, new List(), 0); psm.AddOrReplace(pwsm, 1, 2, true, new List(), 0); psm.SetFdrValues(1, 0, 0, 1, 0, 0, 1, 0); @@ -566,8 +567,8 @@ public static void TestPEP_peptideRemoval() Assert.AreEqual(2, pepValuePredictions.Count); List notches = new List(); - List peptides = new List(); - foreach (var bmp in psm.BestMatchingPeptides) + List peptides = new List(); + foreach (var bmp in psm.BestMatchingBioPolymersWithSetMods) { notches.Add(bmp.Notch); peptides.Add(bmp.Peptide); @@ -575,7 +576,7 @@ public static void TestPEP_peptideRemoval() PEP_Analysis_Cross_Validation.RemoveBestMatchingPeptidesWithLowPEP(psm, indiciesOfPeptidesToRemove, notches, peptides, pepValuePredictions, ref ambiguousPeptidesRemovedCount); Assert.AreEqual(1, ambiguousPeptidesRemovedCount); - Assert.AreEqual(2, psm.BestMatchingPeptides.Select(b => b.Notch).ToList().Count); + Assert.AreEqual(2, psm.BestMatchingBioPolymersWithSetMods.Select(b => b.Notch).ToList().Count); } [Test] @@ -641,14 +642,14 @@ public static void ReplaceBadStdevOne() extendedArray = extendedArray.OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[extendedArray.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[extendedArray.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, extendedArray, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, fsp, null, new List(), writeSpectralLibrary).Run(); - List nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); + List nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); nonNullPsms = nonNullPsms.OrderByDescending(p => p.Score).ToList(); - List psmBloated = new List(); + List psmBloated = new List(); psmBloated.AddRange(nonNullPsms); int arrayMax = nonNullPsms.Count; psmBloated.AddRange(nonNullPsms.GetRange(2, arrayMax - 2)); @@ -695,22 +696,22 @@ public static void ReplaceBadStdevTwo() extendedArray = extendedArray.OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[extendedArray.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[extendedArray.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, extendedArray, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, fsp, null, new List(), writeSpectralLibrary).Run(); - List nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); + List nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); nonNullPsms = nonNullPsms.OrderByDescending(p => p.Score).ToList(); - List psmBloated = new List(); + List psmBloated = new List(); psmBloated.AddRange(nonNullPsms); int arrayMax = nonNullPsms.Count; psmBloated.AddRange(nonNullPsms.GetRange(2, arrayMax - 2)); psmBloated.AddRange(nonNullPsms.GetRange(2, arrayMax - 2)); - PeptideSpectralMatch pp = psmBloated.OrderBy(p => p.ScanRetentionTime).First(); + SpectralMatch pp = psmBloated.OrderBy(p => p.ScanRetentionTime).First(); PeptideWithSetModifications newPwsmTwo = new PeptideWithSetModifications(new Protein("WAGVLPWFPWAAVVWGFWF", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); - PeptideSpectralMatch newPsmTwo = new PeptideSpectralMatch(newPwsmTwo, pp.BestMatchingPeptides.First().Notch, pp.Score, pp.ScanIndex, mwsm, new CommonParameters(), pp.MatchedFragmentIons); + SpectralMatch newPsmTwo = new PeptideSpectralMatch(newPwsmTwo, pp.BestMatchingBioPolymersWithSetMods.First().Notch, pp.Score, pp.ScanIndex, mwsm, new CommonParameters(), pp.MatchedFragmentIons); psmBloated.Add(newPsmTwo); @@ -726,17 +727,17 @@ public static void TestRemoveThisAmbiguousePeptide() 2, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 1, null), 100, 1, null, new CommonParameters(), null); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0), 0, 10, 1, scanB, new CommonParameters(), new List(), 0); + SpectralMatch psm1 = new PeptideSpectralMatch(new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0), 0, 10, 1, scanB, new CommonParameters(), new List(), 0); PeptideWithSetModifications pwsm = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); psm1.AddOrReplace(pwsm, 10, 1, true, new List(), 0); - Assert.AreEqual(2, psm1.BestMatchingPeptides.Count()); + Assert.AreEqual(2, psm1.BestMatchingBioPolymersWithSetMods.Count()); psm1.RemoveThisAmbiguousPeptide(1, pwsm); - Assert.AreEqual(1, psm1.BestMatchingPeptides.Count()); + Assert.AreEqual(1, psm1.BestMatchingBioPolymersWithSetMods.Count()); } [Test] diff --git a/MetaMorpheus/Test/GPTMDengineTest.cs b/MetaMorpheus/Test/GPTMDengineTest.cs index dfc0fcef3..622d1f25f 100644 --- a/MetaMorpheus/Test/GPTMDengineTest.cs +++ b/MetaMorpheus/Test/GPTMDengineTest.cs @@ -24,13 +24,13 @@ public static class GptmdEngineTest [TestCase("NNNNN", "accession", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", 4)] public static void TestGptmdEngine(string proteinSequence, string accession, string sequenceVariantDescription, int numModifiedResidues) { - List allResultingIdentifications = null; + List allResultingIdentifications = null; ModificationMotif.TryGetMotif("N", out ModificationMotif motifN); var gptmdModifications = new List { new Modification(_originalId: "21", _modificationType: "mt", _target: motifN, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943) }; IEnumerable> combos = new List>(); Tolerance precursorMassTolerance = new PpmTolerance(10); - allResultingIdentifications = new List(); + allResultingIdentifications = new List(); var fsp = new List<(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", new CommonParameters())); @@ -50,7 +50,7 @@ public static void TestGptmdEngine(string proteinSequence, string accession, str Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null), (new Proteomics.AminoAcidPolymer.Peptide(modPep.BaseSequence).MonoisotopicMass + 21.981943).ToMz(1), 1, "filepath", new CommonParameters()); var peptidesWithSetModifications = new List { modPep }; - PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, commonParameters, new List()); + SpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, commonParameters, new List()); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); @@ -69,7 +69,7 @@ public static void TestGptmdEngine(string proteinSequence, string accession, str [TestCase("NNNPPP", "accession", "P", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", 2, 5, 2, 3, 1)] public static void TestCombos(string proteinSequence, string accession, string variantAA, string sequenceVariantDescription, int numModHashes, int numModifiedResidues, int numModifiedResiduesN, int numModifiedResiduesP, int numModifiedResiduesNP) { - List allIdentifications = null; + List allIdentifications = null; ModificationMotif.TryGetMotif("N", out ModificationMotif motifN); ModificationMotif.TryGetMotif("P", out ModificationMotif motifP); var gptmdModifications = new List { new Modification(_originalId: "21", _modificationType: "mt", _target: motifN, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943), @@ -88,12 +88,12 @@ public static void TestCombos(string proteinSequence, string accession, string v Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfd, (new Proteomics.AminoAcidPolymer.Peptide(modPep.BaseSequence).MonoisotopicMass + 21.981943 + 15.994915).ToMz(1), 1, "filepath", new CommonParameters()); var peptidesWithSetModifications = new List { modPep }; - PeptideSpectralMatch match = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, commonParameters, new List()); + SpectralMatch match = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, commonParameters, new List()); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); match.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0); - allIdentifications = new List { match }; + allIdentifications = new List { match }; var engine = new GptmdEngine(allIdentifications, gptmdModifications, combos, new Dictionary { { "filepath", precursorMassTolerance } }, new CommonParameters(), null, new List()); var res = (GptmdResults)engine.Run(); @@ -240,7 +240,7 @@ public static void TestUniProtGptmdConflict() // mod should not fit anywhere on the protein for (int i = 0; i < pep.Length; i++) { - bool modFits = GptmdEngine.ModFits(mmPhospho, protein, i + 1, pep.Length, pep.OneBasedStartResidueInProtein + i); + bool modFits = GptmdEngine.ModFits(mmPhospho, protein, i + 1, pep.Length, pep.OneBasedStartResidue + i); Assert.That(!modFits); } @@ -257,7 +257,7 @@ public static void TestUniProtGptmdConflict() // mod should fit at position 8 for (int i = 0; i < pep.Length; i++) { - bool modFits = GptmdEngine.ModFits(mmPhospho, protein, i + 1, pep.Length, pep.OneBasedStartResidueInProtein + i); + bool modFits = GptmdEngine.ModFits(mmPhospho, protein, i + 1, pep.Length, pep.OneBasedStartResidue + i); if (i + 1 == 8) { diff --git a/MetaMorpheus/Test/LocalizationTest.cs b/MetaMorpheus/Test/LocalizationTest.cs index cc553ff84..4df8a6c79 100644 --- a/MetaMorpheus/Test/LocalizationTest.cs +++ b/MetaMorpheus/Test/LocalizationTest.cs @@ -51,10 +51,10 @@ public static void TestLocalization() var theoreticalProducts = new List(); ps.Fragment(DissociationType.HCD, FragmentationTerminus.Both, theoreticalProducts); var matchedIons = MetaMorpheusEngine.MatchFragmentIons(scan, theoreticalProducts, new CommonParameters()); - PeptideSpectralMatch newPsm = new PeptideSpectralMatch(ps, 0, 0, 2, scan, commonParameters, matchedIons); + SpectralMatch newPsm = new PeptideSpectralMatch(ps, 0, 0, 2, scan, commonParameters, matchedIons); newPsm.ResolveAllAmbiguities(); - LocalizationEngine f = new LocalizationEngine(new List { newPsm }, myMsDataFile, commonParameters, fsp, new List()); + LocalizationEngine f = new LocalizationEngine(new List { newPsm }, myMsDataFile, commonParameters, fsp, new List()); f.Run(); // single peak matches diff --git a/MetaMorpheus/Test/MatchIonsOfAllCharges.cs b/MetaMorpheus/Test/MatchIonsOfAllCharges.cs index 9635645b6..812635040 100644 --- a/MetaMorpheus/Test/MatchIonsOfAllCharges.cs +++ b/MetaMorpheus/Test/MatchIonsOfAllCharges.cs @@ -48,7 +48,7 @@ public static void TestMatchIonsOfAllChargesBottomUp() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); //search by new method of looking for all charges - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, null, new List(), true).Run(); @@ -62,7 +62,7 @@ public static void TestMatchIonsOfAllChargesBottomUp() Assert.That(psm[4].MatchedFragmentIons.Count == 16); //search by old method of looking for only one charge - PeptideSpectralMatch[] allPsmsArray_oneCharge = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray_oneCharge = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray_oneCharge, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, null, new List(), false).Run(); var psm_oneCharge = allPsmsArray_oneCharge.Where(p => p != null).ToList(); @@ -76,7 +76,7 @@ public static void TestMatchIonsOfAllChargesBottomUp() var peptideTheorProducts = new List(); Assert.That(psm_oneCharge[1].MatchedFragmentIons.Count == 12); var differences = psm[1].MatchedFragmentIons.Except(psm_oneCharge[1].MatchedFragmentIons); - psm[1].BestMatchingPeptides.First().Peptide.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus, peptideTheorProducts); + psm[1].BestMatchingBioPolymersWithSetMods.First().Peptide.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus, peptideTheorProducts); foreach (var ion in differences) { foreach (var product in peptideTheorProducts) @@ -111,7 +111,7 @@ public static void TestMatchIonsOfAllChargesBottomUp() addCompIons: false); var fsp = new List<(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); - PeptideSpectralMatch[] allPsmsArray1 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray1 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = true; new ClassicSearchEngine(allPsmsArray1, listOfSortedms2Scans1, variableModifications1, fixedModifications1, null, null, null, @@ -150,7 +150,7 @@ public static void TestMatchIonsOfAllChargesTopDown() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); //search by new method of looking for all charges - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, null, new List(), true).Run(); @@ -159,7 +159,7 @@ public static void TestMatchIonsOfAllChargesTopDown() //search by old method of looking for only one charge - PeptideSpectralMatch[] allPsmsArray_oneCharge = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray_oneCharge = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray_oneCharge, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, null, new List(), false).Run(); @@ -174,7 +174,7 @@ public static void TestMatchIonsOfAllChargesTopDown() //compare 2 results and evaluate the different matched ions var peptideTheorProducts = new List(); var differences = psm.MatchedFragmentIons.Except(psm_oneCharge.MatchedFragmentIons); - psm.BestMatchingPeptides.First().Peptide.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus, peptideTheorProducts); + psm.BestMatchingBioPolymersWithSetMods.First().Peptide.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus, peptideTheorProducts); foreach (var ion in differences) { foreach (var product in peptideTheorProducts) @@ -273,7 +273,7 @@ public static void TestReverseDecoyGenerationDuringSearch() //test when doing spectral library search without generating library - PeptideSpectralMatch[] allPsmsArray1 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray1 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray1, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, testLibrary, new List(), false).Run(); var psm1 = allPsmsArray1.Where(p => p != null).ToList(); @@ -288,7 +288,7 @@ public static void TestReverseDecoyGenerationDuringSearch() proteinList.Add(new Protein("LSISNVAK", "", isDecoy: true)); //test when doing spectral library search with generating library; non spectral search won't generate decoy by "decoy on the fly" , so proteinlist used by non spectral library search would contain decoys - PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray2, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, testLibrary, new List(), true).Run(); var psm2 = allPsmsArray2.Where(p => p != null).ToList(); @@ -301,7 +301,7 @@ public static void TestReverseDecoyGenerationDuringSearch() Assert.That(psm2[6].IsDecoy == false && psm2[6].FullSequence == "EKAEAEAEK"); //test when doing non spectral library search without generating library - PeptideSpectralMatch[] allPsmsArray3 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray3 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray3, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, null, new List(), false).Run(); var psm3 = allPsmsArray3.Where(p => p != null).ToList(); @@ -315,7 +315,7 @@ public static void TestReverseDecoyGenerationDuringSearch() //test when doing non spectral library search with generating library - PeptideSpectralMatch[] allPsmsArray4 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray4 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray4, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, null, new List(), true).Run(); var psm4 = allPsmsArray4.Where(p => p != null).ToList(); diff --git a/MetaMorpheus/Test/ModificationAnalysisTest.cs b/MetaMorpheus/Test/ModificationAnalysisTest.cs index ae6275616..c184f94fe 100644 --- a/MetaMorpheus/Test/ModificationAnalysisTest.cs +++ b/MetaMorpheus/Test/ModificationAnalysisTest.cs @@ -71,7 +71,7 @@ public static void TestModificationAnalysis() var fsp = new List<(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); - var newPsms = new List + var newPsms = new List { new PeptideSpectralMatch(pwsm1, 0, 10, 0, scan, CommonParameters, new List()), new PeptideSpectralMatch(pwsm1, 0, 10, 0, scan, CommonParameters, new List()), @@ -139,7 +139,7 @@ public static void TestModificationAnalysisWithNonLocalizedPtms() var fsp = new List<(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); - PeptideSpectralMatch myPsm = new PeptideSpectralMatch(pwsm1, 0, 10, 0, scan, new CommonParameters(), new List()); + SpectralMatch myPsm = new PeptideSpectralMatch(pwsm1, 0, 10, 0, scan, new CommonParameters(), new List()); myPsm.AddOrReplace(pwsm2, 10, 0, true, new List(),0); myPsm.ResolveAllAmbiguities(); @@ -147,9 +147,9 @@ public static void TestModificationAnalysisWithNonLocalizedPtms() MassDiffAcceptor searchMode = new SinglePpmAroundZeroSearchMode(5); List proteinList = new List { protein1 }; - FdrAnalysisEngine fdrAnalysisEngine = new FdrAnalysisEngine(new List { myPsm }, searchMode.NumNotches, CommonParameters, fsp, new List()); + FdrAnalysisEngine fdrAnalysisEngine = new FdrAnalysisEngine(new List { myPsm }, searchMode.NumNotches, CommonParameters, fsp, new List()); fdrAnalysisEngine.Run(); - ModificationAnalysisEngine modificationAnalysisEngine = new ModificationAnalysisEngine(new List { myPsm }, new CommonParameters(), fsp, new List()); + ModificationAnalysisEngine modificationAnalysisEngine = new ModificationAnalysisEngine(new List { myPsm }, new CommonParameters(), fsp, new List()); var res = (ModificationAnalysisResults)modificationAnalysisEngine.Run(); Assert.AreEqual(1, res.CountOfEachModSeenOnProteins.Count()); diff --git a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs index 2fdd76fc4..5865d0a67 100644 --- a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs +++ b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs @@ -52,14 +52,14 @@ public static void MultiProteaseTest() MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psmPEPR_T = new PeptideSpectralMatch(pepA_1T, 0, 10, 0, scan, commonParameters_Tryp, new List()); + SpectralMatch psmPEPR_T = new PeptideSpectralMatch(pepA_1T, 0, 10, 0, scan, commonParameters_Tryp, new List()); psmPEPR_T.AddOrReplace(pepA_2T, 10, 0, true, new List(),0); psmPEPR_T.AddOrReplace(pepA_3T, 10, 0, true, new List(),0); - PeptideSpectralMatch psmPEPR_A = new PeptideSpectralMatch(pepA_2A, 0, 10, 0, scan, commonParameters_ArgC, new List()); + SpectralMatch psmPEPR_A = new PeptideSpectralMatch(pepA_2A, 0, 10, 0, scan, commonParameters_ArgC, new List()); psmPEPR_A.AddOrReplace(pepA_3A, 10, 0, true, new List(),0); - PeptideSpectralMatch psmABCK_T = new PeptideSpectralMatch(pepB_1T, 0, 10, 0, scan, commonParameters_Tryp, new List()); + SpectralMatch psmABCK_T = new PeptideSpectralMatch(pepB_1T, 0, 10, 0, scan, commonParameters_Tryp, new List()); - List psms = new List { psmPEPR_T, psmPEPR_A, psmABCK_T }; + List psms = new List { psmPEPR_T, psmPEPR_A, psmABCK_T }; psms.ForEach(j => j.ResolveAllAmbiguities()); psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); @@ -139,14 +139,14 @@ public static void MultiProteaseSamePeptideSameProteinsDifferentProteases() MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psmABC_Dp1 = new PeptideSpectralMatch(pepA_1Dp1, 0, 10, 0, scan, commonParameters1, new List()); + SpectralMatch psmABC_Dp1 = new PeptideSpectralMatch(pepA_1Dp1, 0, 10, 0, scan, commonParameters1, new List()); psmABC_Dp1.AddOrReplace(pepA_2Dp1, 10, 0, true, new List(),0); - PeptideSpectralMatch psmABC_Dp2 = new PeptideSpectralMatch(pepA_1Dp2, 0, 10, 0, scan, commonParameters2, new List()); + SpectralMatch psmABC_Dp2 = new PeptideSpectralMatch(pepA_1Dp2, 0, 10, 0, scan, commonParameters2, new List()); psmABC_Dp2.AddOrReplace(pepA_2Dp2, 10, 0, true, new List(),0); - PeptideSpectralMatch psmEFG_Dp1 = new PeptideSpectralMatch(pepB_2Dp1, 0, 10, 0, scan, commonParameters1, new List()); + SpectralMatch psmEFG_Dp1 = new PeptideSpectralMatch(pepB_2Dp1, 0, 10, 0, scan, commonParameters1, new List()); // builds psm list to match to peptides - List psms = new List() { psmABC_Dp1, psmABC_Dp2, psmEFG_Dp1 }; + List psms = new List() { psmABC_Dp1, psmABC_Dp2, psmEFG_Dp1 }; psms.ForEach(p => p.ResolveAllAmbiguities()); psms.ForEach(p => p.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); @@ -217,14 +217,14 @@ public static void MultiProteaseParsimony_SharedSequenceCanBeUniquePeptide() MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psmABC_Dp1 = new PeptideSpectralMatch(pepB_1Dp1, 0, 10, 0, scan, commonParameters, new List()); - PeptideSpectralMatch psmABC_Dp2 = new PeptideSpectralMatch(pepB_2Dp2, 0, 10, 0, scan, commonParameters2, new List()); - PeptideSpectralMatch psmEFGABC_Dp1 = new PeptideSpectralMatch(pepC_2Dp1, 0, 10, 0, scan, commonParameters, new List()); - PeptideSpectralMatch psmXYZ_Dp1 = new PeptideSpectralMatch(pepA_1Dp1, 0, 10, 0, scan, commonParameters, new List()); + SpectralMatch psmABC_Dp1 = new PeptideSpectralMatch(pepB_1Dp1, 0, 10, 0, scan, commonParameters, new List()); + SpectralMatch psmABC_Dp2 = new PeptideSpectralMatch(pepB_2Dp2, 0, 10, 0, scan, commonParameters2, new List()); + SpectralMatch psmEFGABC_Dp1 = new PeptideSpectralMatch(pepC_2Dp1, 0, 10, 0, scan, commonParameters, new List()); + SpectralMatch psmXYZ_Dp1 = new PeptideSpectralMatch(pepA_1Dp1, 0, 10, 0, scan, commonParameters, new List()); psmXYZ_Dp1.AddOrReplace(pepA_2Dp1, 10, 0, true, new List(),0); // builds psm list to match to peptides - List psms = new List() { psmABC_Dp1, psmABC_Dp2, psmEFGABC_Dp1, psmXYZ_Dp1 }; + List psms = new List() { psmABC_Dp1, psmABC_Dp2, psmEFGABC_Dp1, psmXYZ_Dp1 }; psms.ForEach(p => p.ResolveAllAmbiguities()); psms.ForEach(p => p.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); @@ -320,13 +320,13 @@ public static void MultiProteaseParsimony_IndistringuishableProteinsNowDistingui MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psmABC_Dp1 = new PeptideSpectralMatch(pepA_1Dp1, 0, 10, 0, scan, commonParameters, new List()); - PeptideSpectralMatch psmABC_Dp2 = new PeptideSpectralMatch(pepA_2Dp2, 0, 10, 0, scan, commonParameters2, new List()); - PeptideSpectralMatch psmEFG_Dp1 = new PeptideSpectralMatch(pepB_1Dp1, 0, 10, 0, scan, commonParameters, new List()); - PeptideSpectralMatch psmEFG_Dp2 = new PeptideSpectralMatch(pepB_2Dp2, 0, 10, 0, scan, commonParameters2, new List()); + SpectralMatch psmABC_Dp1 = new PeptideSpectralMatch(pepA_1Dp1, 0, 10, 0, scan, commonParameters, new List()); + SpectralMatch psmABC_Dp2 = new PeptideSpectralMatch(pepA_2Dp2, 0, 10, 0, scan, commonParameters2, new List()); + SpectralMatch psmEFG_Dp1 = new PeptideSpectralMatch(pepB_1Dp1, 0, 10, 0, scan, commonParameters, new List()); + SpectralMatch psmEFG_Dp2 = new PeptideSpectralMatch(pepB_2Dp2, 0, 10, 0, scan, commonParameters2, new List()); // builds psm list to match to peptides - List psms = new List() { psmABC_Dp1, psmABC_Dp2, psmEFG_Dp1, psmEFG_Dp2 }; + List psms = new List() { psmABC_Dp1, psmABC_Dp2, psmEFG_Dp1, psmEFG_Dp2 }; psms.ForEach(h => h.ResolveAllAmbiguities()); psms.ForEach(h => h.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); @@ -404,7 +404,7 @@ public static void MultiProteaseParsimony_SameAminoAcidsResultInTwoUniquePeptide }; // builds psm list to match to peptides - List psms = new List(); + List psms = new List(); MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); @@ -477,12 +477,12 @@ public static void MultiProteaseParsimony_TestingPeptideBaseSequenceCanBeBothSha MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psmABC_Dp1 = new PeptideSpectralMatch(pepA_1Dp1, 0, 10, 0, scan, commonParameters, new List()); - PeptideSpectralMatch psmABC_Dp2 = new PeptideSpectralMatch(pepA_2Dp2, 0, 10, 0, scan, commonParameters2, new List()); + SpectralMatch psmABC_Dp1 = new PeptideSpectralMatch(pepA_1Dp1, 0, 10, 0, scan, commonParameters, new List()); + SpectralMatch psmABC_Dp2 = new PeptideSpectralMatch(pepA_2Dp2, 0, 10, 0, scan, commonParameters2, new List()); psmABC_Dp2.AddOrReplace(pepA_3Dp2, 10, 0, true, new List(),0); // builds psm list to match to peptides - List psms = new List() { psmABC_Dp1, psmABC_Dp2 }; + List psms = new List() { psmABC_Dp1, psmABC_Dp2 }; psms.ForEach(h => h.ResolveAllAmbiguities()); psms.ForEach(h => h.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); @@ -564,7 +564,7 @@ public static void MultiProteaseParsimony_BaseSequenceCanBeSharedOrUniqueButOnly } // builds psm list to match to peptides - List psms = new List(); + List psms = new List(); MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); @@ -647,7 +647,7 @@ public static void TestPSMFdrFiltering_Simulated() } // builds psm list to match to peptides - List psms = new List(); + List psms = new List(); MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); @@ -707,8 +707,8 @@ public static void TestPSMFdrFiltering_Simulated() psms.ElementAt(5).SetFdrValues(0, 0, goodFdr, 0, goodFdr, 0, 0, 0); //this iscopy of code that filteres psms in PostSearch Analysis Task - var fdrFilteredPsms = new List(); - foreach (PeptideSpectralMatch psm in psms) + var fdrFilteredPsms = new List(); + foreach (SpectralMatch psm in psms) { if (psm != null && psm.FdrInfo.QValue <= 0.0100 && psm.FdrInfo.QValueNotch <= 0.0100) { @@ -812,13 +812,13 @@ public static void MultiProteaseParsimony_TestingSameBaseSequenceSharedandUnique MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psmABC_Alpha = new PeptideSpectralMatch(pepABC_1Alpha, 0, 10, 0, scan, commonParameters, new List()); - PeptideSpectralMatch psmABC_Beta = new PeptideSpectralMatch(pepABC_2Beta, 0, 10, 0, scan, commonParameters2, new List()); + SpectralMatch psmABC_Alpha = new PeptideSpectralMatch(pepABC_1Alpha, 0, 10, 0, scan, commonParameters, new List()); + SpectralMatch psmABC_Beta = new PeptideSpectralMatch(pepABC_2Beta, 0, 10, 0, scan, commonParameters2, new List()); psmABC_Beta.AddOrReplace(pepABC_4Beta, 10, 0, true, new List(),0); - PeptideSpectralMatch psmEFG_Beta = new PeptideSpectralMatch(pepEFG_3Beta, 0, 10, 0, scan, commonParameters2, new List()); + SpectralMatch psmEFG_Beta = new PeptideSpectralMatch(pepEFG_3Beta, 0, 10, 0, scan, commonParameters2, new List()); psmEFG_Beta.AddOrReplace(pepEFG_4Beta, 10, 0, true, new List(),0); - List psms = new List { psmABC_Alpha, psmABC_Beta, psmEFG_Beta }; + List psms = new List { psmABC_Alpha, psmABC_Beta, psmEFG_Beta }; psms.ForEach(j => j.ResolveAllAmbiguities()); psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); @@ -882,16 +882,16 @@ public static void MultiProteaseParsimony_TestingActuallyIndistinguisableProtein MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psmABCK_T = new PeptideSpectralMatch(pepABCK_1T, 0, 10, 0, scan, commonParameters_tryp, new List()); + SpectralMatch psmABCK_T = new PeptideSpectralMatch(pepABCK_1T, 0, 10, 0, scan, commonParameters_tryp, new List()); psmABCK_T.AddOrReplace(pepABCK_2T, 10, 0, true, new List(),0); - PeptideSpectralMatch psmABCK_L = new PeptideSpectralMatch(pepABCK_1L, 0, 10, 0, scan, commonParameters_LysC, new List()); + SpectralMatch psmABCK_L = new PeptideSpectralMatch(pepABCK_1L, 0, 10, 0, scan, commonParameters_LysC, new List()); psmABCK_L.AddOrReplace(pepABCK_2L, 10, 0, true, new List(),0); - PeptideSpectralMatch psmXYZK_T = new PeptideSpectralMatch(pepXYZK_1T, 0, 10, 0, scan, commonParameters_LysC, new List()); + SpectralMatch psmXYZK_T = new PeptideSpectralMatch(pepXYZK_1T, 0, 10, 0, scan, commonParameters_LysC, new List()); psmXYZK_T.AddOrReplace(pepXYZK_2T, 10, 0, true, new List(),0); - PeptideSpectralMatch psmXYZK_L = new PeptideSpectralMatch(pepXYZK_1L, 0, 10, 0, scan, commonParameters_LysC, new List()); + SpectralMatch psmXYZK_L = new PeptideSpectralMatch(pepXYZK_1L, 0, 10, 0, scan, commonParameters_LysC, new List()); psmXYZK_L.AddOrReplace(pepXYZK_2L, 10, 0, true, new List(),0); - List psms = new List { psmABCK_T, psmABCK_L, psmXYZK_T, psmXYZK_L }; + List psms = new List { psmABCK_T, psmABCK_L, psmXYZK_T, psmXYZK_L }; psms.ForEach(j => j.ResolveAllAmbiguities()); psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); @@ -956,12 +956,12 @@ public static void MultiProteaseParsimony_TestingGreedyAlgorithm() MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psmABC_Dash = new PeptideSpectralMatch(pepABC_1Dash, 0, 10, 0, scan, commonParameters, new List()); + SpectralMatch psmABC_Dash = new PeptideSpectralMatch(pepABC_1Dash, 0, 10, 0, scan, commonParameters, new List()); psmABC_Dash.AddOrReplace(pepABC_2Dash, 10, 0, true, new List(),0); - PeptideSpectralMatch psmABC_G = new PeptideSpectralMatch(pepABC_2G, 0, 10, 0, scan, commonParameters2, new List()); + SpectralMatch psmABC_G = new PeptideSpectralMatch(pepABC_2G, 0, 10, 0, scan, commonParameters2, new List()); psmABC_G.AddOrReplace(pepABC_3G, 10, 0, true, new List(),0); - List psms = new List { psmABC_Dash, psmABC_G }; + List psms = new List { psmABC_Dash, psmABC_G }; psms.ForEach(j => j.ResolveAllAmbiguities()); psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); @@ -1011,7 +1011,7 @@ public static void MultiProteaseParsimony_TestingProteaseSpecificFDRCalculations Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); List f = new List(); - List psms = new List + List psms = new List { new PeptideSpectralMatch(new PeptideWithSetModifications("P", null, digestionParams: commonParameters_tryp.DigestionParams, p: t), 0, 20, 1, scan, commonParameters_tryp, f), new PeptideSpectralMatch(new PeptideWithSetModifications("P", null, digestionParams: commonParameters_gluC.DigestionParams, p: t), 0, 19, 1, scan, commonParameters_gluC, f), diff --git a/MetaMorpheus/Test/MyPeptideTest.cs b/MetaMorpheus/Test/MyPeptideTest.cs index 04af2371e..4d82c08a8 100644 --- a/MetaMorpheus/Test/MyPeptideTest.cs +++ b/MetaMorpheus/Test/MyPeptideTest.cs @@ -40,7 +40,7 @@ public static void TestIdenticalPeaks() MzSpectrum massSpectrum = new MzSpectrum(mz, intensities, false); MsDataScan scan = new MsDataScan(massSpectrum, 1, 1, true, Polarity.Positive, 1, new MzRange(300, 2000), "", MZAnalyzerType.Unknown, massSpectrum.SumOfAllY, null, null, "scan=1", 0, null, null, 0, null, DissociationType.Unknown, 1, null); - PeptideSpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; + SpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans = { new Ms2ScanWithSpecificMass(scan, 0, 1, null, new CommonParameters()) }; CommonParameters CommonParameters = new CommonParameters( productMassTolerance: new PpmTolerance(5), @@ -75,7 +75,7 @@ public static void TestLastPeaks() MzSpectrum massSpectrum = new MzSpectrum(mz, intensities, false); MsDataScan scan = new MsDataScan(massSpectrum, 1, 1, true, Polarity.Positive, 1, new MzRange(300, 2000), "", MZAnalyzerType.Unknown, massSpectrum.SumOfAllY, null, null, "scan=1", 0, null, null, 0, null, DissociationType.Unknown, 1, null); - PeptideSpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; + SpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans = { new Ms2ScanWithSpecificMass(scan, 0, 1, null, new CommonParameters()) }; CommonParameters CommonParameters = new CommonParameters( scoreCutoff: 1, @@ -112,7 +112,7 @@ public static void TestVeryCloseExperimentalsClassic() MzSpectrum massSpectrum = new MzSpectrum(mz, intensities, false); MsDataScan scan = new MsDataScan(massSpectrum, 1, 1, true, Polarity.Positive, 1, new MzRange(300, 2000), "", MZAnalyzerType.Unknown, massSpectrum.SumOfAllY, null, null, "scan=1", 0, null, null, 0, null, DissociationType.Unknown, 1, null); - PeptideSpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; + SpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans = { new Ms2ScanWithSpecificMass(scan, 0, 1, null, new CommonParameters()) }; CommonParameters CommonParameters = new CommonParameters( productMassTolerance: new PpmTolerance(5), @@ -149,7 +149,7 @@ public static void TestVeryCloseExperimentalsModern() MzSpectrum massSpectrum = new MzSpectrum(mz, intensities, false); MsDataScan scan = new MsDataScan(massSpectrum, 1, 1, true, Polarity.Positive, 1, new MzRange(300, 2000), "", MZAnalyzerType.Unknown, massSpectrum.SumOfAllY, null, null, "scan=1", 0, null, null, 0, null, DissociationType.Unknown, 1, null); - PeptideSpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; + SpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans = { new Ms2ScanWithSpecificMass(scan, 600, 1, null, new CommonParameters()) }; CommonParameters CommonParameters = new CommonParameters(productMassTolerance: new PpmTolerance(5), scoreCutoff: 1, digestionParams: new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, maxModificationIsoforms: int.MaxValue, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain)); @@ -180,7 +180,7 @@ public static void TestAllNaN() MzSpectrum massSpectrum = new MzSpectrum(mz, intensities, false); MsDataScan scan = new MsDataScan(massSpectrum, 1, 1, true, Polarity.Positive, 1, new MzRange(300, 2000), "", MZAnalyzerType.Unknown, massSpectrum.SumOfAllY, null, null, "scan=1", 0, null, null, 0, null, DissociationType.Unknown, 1, null); - PeptideSpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; + SpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans = { new Ms2ScanWithSpecificMass(scan, 0, 0, null, new CommonParameters()) }; CommonParameters CommonParameters = new CommonParameters(productMassTolerance: new PpmTolerance(5), scoreCutoff: 1, digestionParams: new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, maxModificationIsoforms: int.MaxValue, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain)); bool writeSpetralLibrary = false; diff --git a/MetaMorpheus/Test/PsmTsvWriterTests.cs b/MetaMorpheus/Test/PsmTsvWriterTests.cs index db9b9f74f..2f27be8b8 100644 --- a/MetaMorpheus/Test/PsmTsvWriterTests.cs +++ b/MetaMorpheus/Test/PsmTsvWriterTests.cs @@ -57,7 +57,7 @@ public static void ResolveModificationsTest() //we're adding a neutral loss of 5 to the product to make sure we hit the right spot in the unit test to add that loss to the product ion string Product p = new Product(ProductType.b, FragmentationTerminus.N, 1, 1, 1, 5); mfi.Add(new MatchedFragmentIon(p, 1, 1, 1)); - PeptideSpectralMatch myPsm = new PeptideSpectralMatch(pwsm1, 0, 10, 0, scan, new CommonParameters(), mfi); + SpectralMatch myPsm = new PeptideSpectralMatch(pwsm1, 0, 10, 0, scan, new CommonParameters(), mfi); myPsm.AddOrReplace(pwsm2, 10, 0, true, mfi, 10); diff --git a/MetaMorpheus/Test/RobTest.cs b/MetaMorpheus/Test/RobTest.cs index 9c7ce8f56..1b87dcd13 100644 --- a/MetaMorpheus/Test/RobTest.cs +++ b/MetaMorpheus/Test/RobTest.cs @@ -86,7 +86,7 @@ public static void TestParsimony() } // create PSMs for the peptides - Dictionary temp = new Dictionary(); + Dictionary temp = new Dictionary(); MsDataScan fakeScan = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, @@ -106,7 +106,7 @@ public static void TestParsimony() } } - List psms = temp.Values.ToList(); + List psms = temp.Values.ToList(); foreach (var psm in psms) { @@ -124,7 +124,7 @@ public static void TestParsimony() proteinGroups = proteinScoringAndFdrResults.SortedAndScoredProteinGroups; // select the PSMs' proteins - List parsimonyProteinSequences = psms.SelectMany(p => p.BestMatchingPeptides.Select(v => v.Peptide.Protein)).Select(v => v.BaseSequence).Distinct().ToList(); + List parsimonyProteinSequences = psms.SelectMany(p => p.BestMatchingBioPolymersWithSetMods.Select(v => v.Peptide.Parent)).Select(v => v.BaseSequence).Distinct().ToList(); // check that correct proteins are in parsimony list Assert.Contains("AB--------", parsimonyProteinSequences); @@ -230,7 +230,7 @@ public static void TestPTMOutput() match66.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); - List psms = new List + List psms = new List { match1, match2, diff --git a/MetaMorpheus/Test/SearchEngineTests.cs b/MetaMorpheus/Test/SearchEngineTests.cs index 5d02cefce..2721fe645 100644 --- a/MetaMorpheus/Test/SearchEngineTests.cs +++ b/MetaMorpheus/Test/SearchEngineTests.cs @@ -48,7 +48,7 @@ public static void TestClassicSearchEngine() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, null, null, new List(), writeSpectralLibrary).Run(); @@ -282,7 +282,7 @@ public static void TestClassicSearchEngineXcorr() scan.TheScan.MassSpectrum.XCorrPrePreprocessing(0, 1969, scan.TheScan.IsolationMz.Value); } - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedXcorrms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedXcorrms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedXcorrms2Scans, variableModifications, fixedModifications, null, null, null, @@ -335,7 +335,7 @@ public static void TestClassicSearchEngineWithWeirdPeptide() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, @@ -383,7 +383,7 @@ public static void TestModernSearchEngine() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode @@ -437,7 +437,7 @@ public static void TestModernSearchEngineLowResTrivial() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // Single search mode @@ -539,7 +539,7 @@ public static void TestModernSearchEngineLowResOneRealSpectrum() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, losm2, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); var nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); @@ -601,7 +601,7 @@ public static void TestClassicSearchEngineLowResSimple() Assert.AreEqual(147, numSpectra); - PeptideSpectralMatch[] fileSpecificPsms = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; + SpectralMatch[] fileSpecificPsms = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestClassicSearchEngineLowResSimple"); string myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\TaGe_SA_A549_3_snip.fasta"); @@ -638,7 +638,7 @@ public static void TestClassicSearchEngineLowResSimple() Assert.AreEqual(535, listOfSortedXcorrms2Scans.Count()); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedXcorrms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedXcorrms2Scans.Length]; var fsp = new List<(string, CommonParameters)>(); fsp.Add(("sliced_b6.mzML", CommonParameters)); @@ -697,7 +697,7 @@ public static void TestModernSearchEngineLowResSimple() Ms2ScanWithSpecificMass[] arrayOfMs2ScansSortedByMass = MetaMorpheusTask.GetMs2Scans(myMsDataFile, origDataFile, CommonParameters).OrderBy(b => b.PrecursorMass).ToArray(); int numSpectra = myMsDataFile.GetAllScansList().Count(p => p.MsnOrder == 2); - PeptideSpectralMatch[] fileSpecificPsms = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; + SpectralMatch[] fileSpecificPsms = new PeptideSpectralMatch[arrayOfMs2ScansSortedByMass.Length]; string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestModernSearchEngineLowResSimple"); //string myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\LowResSnip_B6_mouse_11700_117500.xml.gz"); @@ -737,7 +737,7 @@ public static void TestModernSearchEngineLowResSimple() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); var nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); @@ -780,7 +780,7 @@ public static void TestModernSearchFragmentEdges() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()).Run(); // no assertions... just don't crash... @@ -813,9 +813,9 @@ public static void TestNonViablePSM() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[1][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[1][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray = allPsmsArrays[0]; + SpectralMatch[] allPsmsArray = allPsmsArrays[0]; //Classic bool writeSpectralLibrary = false; @@ -864,7 +864,7 @@ public static void TestModernSearchEngineWithWeirdPeptide() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; var engine = new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List()); var searchResults = engine.Run(); @@ -925,11 +925,11 @@ public static void TestNonSpecificEnzymeSearchEngineSingleN() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[1] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[2] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray = allPsmsArrays[2]; + SpectralMatch[] allPsmsArray = allPsmsArrays[2]; //coisolation index List[] coisolationIndex = new List[listOfSortedms2Scans.Length]; @@ -1001,11 +1001,11 @@ public static void TestNonSpecificEnzymeSearchEngineSingleNLowCID() MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[1] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[2] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray = allPsmsArrays[2]; + SpectralMatch[] allPsmsArray = allPsmsArrays[2]; //coisolation index List[] coisolationIndex = new List[listOfSortedms2Scans.Length]; @@ -1078,11 +1078,11 @@ public static void TestNonSpecificEnzymeSearchEngineSingleCModifications() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[1] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[2] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray = allPsmsArrays[2]; + SpectralMatch[] allPsmsArray = allPsmsArrays[2]; //coisolation index List[] coisolationIndex = new List[listOfSortedms2Scans.Length]; @@ -1185,11 +1185,11 @@ public static void TestNonSpecificEnzymeSearchEngineSingleNModifications() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[1] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[2] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray = allPsmsArrays[2]; + SpectralMatch[] allPsmsArray = allPsmsArrays[2]; //coisolation index List[] coisolationIndex = new List[listOfSortedms2Scans.Length]; @@ -1255,7 +1255,7 @@ public static void TestSnesFifteenMer() PeptideWithSetModifications pwsm = new PeptideWithSetModifications("ACDEFGHIKLMNPQR", new Dictionary()); TestDataFile msFile = new TestDataFile(pwsm); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(msFile, null, new CommonParameters()).ToArray(); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[1] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[2] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; @@ -1330,11 +1330,11 @@ public static void TestNonSpecificEnzymeSearchEngineSingleC() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[1] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[2] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray = allPsmsArrays[2]; + SpectralMatch[] allPsmsArray = allPsmsArrays[2]; //coisolation index List[] coisolationIndex = new List[listOfSortedms2Scans.Length]; @@ -1473,10 +1473,10 @@ public static void TestSemiSpecificEnzymeEngineSingleN() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[2][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[2][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[1] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray = allPsmsArrays[1]; + SpectralMatch[] allPsmsArray = allPsmsArrays[1]; //coisolation index List[] coisolationIndex = new List[listOfSortedms2Scans.Length]; @@ -1547,11 +1547,11 @@ public static void TestSemiSpecificEnzymeEngineSingleC() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; allPsmsArrays[0] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[1] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; allPsmsArrays[2] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; - PeptideSpectralMatch[] allPsmsArray = allPsmsArrays[2]; + SpectralMatch[] allPsmsArray = allPsmsArrays[2]; //coisolation index List[] coisolationIndex = new List[listOfSortedms2Scans.Length]; @@ -1627,7 +1627,7 @@ public static void TestClassicSemiProtease() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, @@ -1647,7 +1647,7 @@ public static void TestClassicSemiProtease() var listOfSortedms2Scans2 = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray2, listOfSortedms2Scans2, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters2, null, null, new List(), writeSpectralLibrary).Run(); @@ -1768,7 +1768,7 @@ public static void TestClassicSearchOneNterminalModifiedPeptideOneScan() CommonParameters commonParameters = new CommonParameters(dissociationType: d, precursorMassTolerance: precursorTolerance, productMassTolerance: productTolerance, digestionParams: testDigestionParams); //Search the scan against the protein - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[1]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[1]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, scans, new List(), new List(), null, null, null, @@ -1842,7 +1842,7 @@ public static void TestTerminalModificationsForSnes() var peptideIndex = indexResults.PeptideIndex; var fragmentIndexDict = indexResults.FragmentIndex; var precursorIndexDict = indexResults.PrecursorIndex; - PeptideSpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; + SpectralMatch[][] allPsmsArrays = new PeptideSpectralMatch[3][]; allPsmsArrays[2] = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; //coisolation index @@ -1855,7 +1855,7 @@ public static void TestTerminalModificationsForSnes() var searchResults = engine.Run(); for (int i = 0; i < listOfSortedms2Scans.Length; i++) { - PeptideSpectralMatch testPsm = allPsmsArrays[2][i]; + SpectralMatch testPsm = allPsmsArrays[2][i]; Assert.IsTrue(testPsm != null); testPsm.ResolveAllAmbiguities(); Assert.IsTrue(psmAnswer[1 - i].Equals(testPsm.FullSequence)); diff --git a/MetaMorpheus/Test/SearchTaskTest.cs b/MetaMorpheus/Test/SearchTaskTest.cs index dc3cb447c..cce514a40 100644 --- a/MetaMorpheus/Test/SearchTaskTest.cs +++ b/MetaMorpheus/Test/SearchTaskTest.cs @@ -447,7 +447,7 @@ public static void TestMzIdentMlWriterWithUniprotResId() string path = Path.Combine(TestContext.CurrentContext.TestDirectory, "ResIdOutput.mzID"); - MzIdentMLWriter.WriteMzIdentMl(new List { psm }, new List(), new List(), + MzIdentMLWriter.WriteMzIdentMl(new List { psm }, new List(), new List(), new List(), new List(), new List(), new PpmTolerance(20), new PpmTolerance(20), 0, path, true); @@ -489,7 +489,7 @@ public static void TestMzIdentMlWriterWithUniprotPsiMod() string path = Path.Combine(TestContext.CurrentContext.TestDirectory, "ResIdOutput.mzID"); - MzIdentMLWriter.WriteMzIdentMl(new List { psm }, new List(), new List(), + MzIdentMLWriter.WriteMzIdentMl(new List { psm }, new List(), new List(), new List(), new List(), new List(), new PpmTolerance(20), new PpmTolerance(20), 0, path, true); @@ -505,7 +505,7 @@ public static void TestMzIdentMlWriterWithUniprotPsiMod() Assert.That(found); // test again w/ NOT appending motifs onto mod names - MzIdentMLWriter.WriteMzIdentMl(new List { psm }, new List(), new List(), + MzIdentMLWriter.WriteMzIdentMl(new List { psm }, new List(), new List(), new List(), new List(), new List(), new PpmTolerance(20), new PpmTolerance(20), 0, path, false); diff --git a/MetaMorpheus/Test/SeqCoverageTest.cs b/MetaMorpheus/Test/SeqCoverageTest.cs index 620fb1c75..81d7bda7c 100644 --- a/MetaMorpheus/Test/SeqCoverageTest.cs +++ b/MetaMorpheus/Test/SeqCoverageTest.cs @@ -74,7 +74,7 @@ public static void TryFailSequenceCoverage() psm3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); - List newPsms = new List + List newPsms = new List { psm1, psm2, @@ -143,7 +143,7 @@ public static void TestFragmentSequenceCoverage() var psm3 = new PeptideSpectralMatch(pwsm3, 0, 1, 0, scan, new CommonParameters(), new List()); psm3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); - List newPsms = new List + List newPsms = new List { psm1, psm2, diff --git a/MetaMorpheus/Test/SpectralLibraryReaderTest.cs b/MetaMorpheus/Test/SpectralLibraryReaderTest.cs index 8170c7fc9..25244e2c4 100644 --- a/MetaMorpheus/Test/SpectralLibraryReaderTest.cs +++ b/MetaMorpheus/Test/SpectralLibraryReaderTest.cs @@ -180,7 +180,7 @@ public static void AnotherSpectralLibrarySearchTest() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, commonParameters,null, sl, new List(), writeSpectralLibrary).Run(); @@ -222,7 +222,7 @@ public static void AnotherSpectralLibrarySearchTestDecoy() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, commonParameters, null, sl, new List(), writeSpectralLibrary).Run(); diff --git a/MetaMorpheus/Test/SpectralRecoveryTest.cs b/MetaMorpheus/Test/SpectralRecoveryTest.cs index c26ed855a..e46ca8994 100644 --- a/MetaMorpheus/Test/SpectralRecoveryTest.cs +++ b/MetaMorpheus/Test/SpectralRecoveryTest.cs @@ -14,6 +14,7 @@ using Omics.Modifications; using TaskLayer; using TaskLayer.MbrAnalysis; +using Omics; namespace Test { @@ -23,7 +24,7 @@ public class { private static MyTaskResults searchTaskResults; private static List tsvPsms; - private static List psms; + private static List psms; private static List proteinList; private static MyFileManager myFileManager; private static List rawSlices; @@ -34,10 +35,10 @@ public class [OneTimeSetUp] public void SpectralRecoveryTestSetup() { - // This block of code converts from PsmFromTsv to PeptideSpectralMatch objects + // This block of code converts from PsmFromTsv to SpectralMatch objects string psmtsvPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", @"SpectralRecoveryTest\MSMSids.psmtsv"); tsvPsms = PsmTsvReader.ReadTsv(psmtsvPath, out var warnings); - psms = new List(); + psms = new List(); proteinList = new List(); myFileManager = new MyFileManager(true); @@ -58,7 +59,7 @@ public void SpectralRecoveryTestSetup() PeptideWithSetModifications pwsm = new PeptideWithSetModifications( readPsm.FullSequence, null, p: protein, digestionParams: new DigestionParams(), oneBasedStartResidueInProtein: startResidue, oneBasedEndResidueInProtein: endResidue); - PeptideSpectralMatch psm = new PeptideSpectralMatch(pwsm, 0, readPsm.Score, readPsm.Ms2ScanNumber, ms2Scan, + SpectralMatch psm = new PeptideSpectralMatch(pwsm, 0, readPsm.Score, readPsm.Ms2ScanNumber, ms2Scan, new CommonParameters(), readPsm.MatchedIons); psm.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); if (readPsm.Ms2ScanNumber == 206 && readPsm.BaseSeq.Equals("HADIVTTTTHK")) psm.SetFdrValues(0, 0, 0, 0, 0, 0, 0.0046, 0); // Necessary for to be implemented "original pep" test @@ -224,7 +225,7 @@ public static void MiniClassicSearchEngineTest() Ms2ScanWithSpecificMass[] listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpectralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, commonParameters, null, sl, new List(), writeSpectralLibrary).Run(); @@ -238,9 +239,9 @@ public static void MiniClassicSearchEngineTest() SpectralLibrarySearchFunction.CalculateSpectralAngles(sl, allPsmsArray, listOfSortedms2Scans, commonParameters); Assert.That(allPsmsArray[5].SpectralAngle, Is.EqualTo(0.82).Within(0.01)); - foreach (PeptideSpectralMatch psm in allPsmsArray.Where(p => p != null)) + foreach (SpectralMatch psm in allPsmsArray.Where(p => p != null)) { - PeptideWithSetModifications pwsm = psm.BestMatchingPeptides.First().Peptide; + IBioPolymerWithSetMods pwsm = psm.BestMatchingBioPolymersWithSetMods.First().Peptide; MiniClassicSearchEngine mcse = new MiniClassicSearchEngine( listOfSortedms2Scans.OrderBy(p => p.RetentionTime).ToArray(), @@ -249,7 +250,7 @@ public static void MiniClassicSearchEngineTest() sl, null); - PeptideSpectralMatch[] peptideSpectralMatches = + SpectralMatch[] peptideSpectralMatches = mcse.SearchAroundPeak(pwsm, allPsmsArray[5].ScanRetentionTime).ToArray(); Assert.AreEqual(allPsmsArray[5].BaseSequence, peptideSpectralMatches[0].BaseSequence); @@ -363,7 +364,7 @@ public static void SpectralWriterTest() [Test] public static void SpectralRecoveryHeaderTest() { - string psmHeader = PeptideSpectralMatch.GetTabSeparatedHeader().Trim(); + string psmHeader = SpectralMatch.GetTabSeparatedHeader().Trim(); StringBuilder sb = new(); sb.Append(psmHeader); sb.Append('\t'); diff --git a/MetaMorpheus/Test/StefanParsimonyTest.cs b/MetaMorpheus/Test/StefanParsimonyTest.cs index b836d9b30..7fb4ea560 100644 --- a/MetaMorpheus/Test/StefanParsimonyTest.cs +++ b/MetaMorpheus/Test/StefanParsimonyTest.cs @@ -43,7 +43,7 @@ public static void ParsimonyTreatModifiedFormsAsUnique() Assert.That(unmodifiedPeptide.NumMods == 0); // there was no modification on this protein // build PSMs for parsimony - List psmsForParsimony = new List(); + List psmsForParsimony = new List(); MsDataScan fakeScan = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, @@ -51,11 +51,11 @@ public static void ParsimonyTreatModifiedFormsAsUnique() Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(fakeScan, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(modifiedPeptide, 0, 10, 1, scan, new CommonParameters(), new List()); + SpectralMatch psm1 = new PeptideSpectralMatch(modifiedPeptide, 0, 10, 1, scan, new CommonParameters(), new List()); psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); psm1.ResolveAllAmbiguities(); - PeptideSpectralMatch psm2 = new PeptideSpectralMatch(unmodifiedPeptide, 0, 10, 2, scan, new CommonParameters(), new List()); + SpectralMatch psm2 = new PeptideSpectralMatch(unmodifiedPeptide, 0, 10, 2, scan, new CommonParameters(), new List()); psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); psm2.ResolveAllAmbiguities(); @@ -77,8 +77,8 @@ public static void ParsimonyTreatModifiedFormsAsUnique() // because modified peptides were considered as unique, then there should be two protein groups after parsimony, and one protein accession for each peptide Assert.That(countOfProteinGroups == 2); Assert.That(results.SortedAndScoredProteinGroups.All(p => p.Proteins.Count == 1)); - Assert.That(psm1.ProteinAccession == "accession1"); - Assert.That(psm2.ProteinAccession == "accession2"); + Assert.That(psm1.Accession == "accession1"); + Assert.That(psm2.Accession == "accession2"); } [Test] @@ -110,7 +110,7 @@ public static void ParsimonyDontTreatModifiedFormsAsUnique() Assert.That(unmodifiedPeptide.NumMods == 0); // there was no modification on this protein // build PSMs for parsimony - List psmsForParsimony = new List(); + List psmsForParsimony = new List(); MsDataScan fakeScan = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, @@ -118,11 +118,11 @@ public static void ParsimonyDontTreatModifiedFormsAsUnique() Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(fakeScan, 2, 0, "File", new CommonParameters()); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(modifiedPeptide, 0, 10, 1, scan, new CommonParameters(), new List()); + SpectralMatch psm1 = new PeptideSpectralMatch(modifiedPeptide, 0, 10, 1, scan, new CommonParameters(), new List()); psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); psm1.ResolveAllAmbiguities(); - PeptideSpectralMatch psm2 = new PeptideSpectralMatch(unmodifiedPeptide, 0, 10, 2, scan, new CommonParameters(), new List()); + SpectralMatch psm2 = new PeptideSpectralMatch(unmodifiedPeptide, 0, 10, 2, scan, new CommonParameters(), new List()); psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); psm2.ResolveAllAmbiguities(); @@ -146,8 +146,8 @@ public static void ParsimonyDontTreatModifiedFormsAsUnique() // and two protein accessions for each peptide Assert.AreEqual(1, countOfProteinGroups); Assert.AreEqual(2, results.SortedAndScoredProteinGroups.First().Proteins.Count); - Assert.IsNull(psm1.ProteinAccession); - Assert.IsNull(psm2.ProteinAccession); + Assert.IsNull(psm1.Accession); + Assert.IsNull(psm2.Accession); } [Test] @@ -173,7 +173,7 @@ public static void ParsimonyWeirdCatch() MatchedFragmentIon mfiC3 = new MatchedFragmentIon(productC3, 0, 0, 1); MatchedFragmentIon mfiC4 = new MatchedFragmentIon(productC4, 0, 0, 1); - List psms = new List + List psms = new List { new PeptideSpectralMatch(pep1,0,1,0, scan, new CommonParameters(), new List() {mfiC3, mfiC4}), }; @@ -222,7 +222,7 @@ public static void TopPickedFdrTest() MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); - List psms = new List + List psms = new List { new PeptideSpectralMatch(fillerPep,0,30,0, scan, new CommonParameters(), new List()), new PeptideSpectralMatch(decoyPep,0,15.11,0, scan, new CommonParameters(), new List()), diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index bedb648ad..ee30e3494 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + diff --git a/MetaMorpheus/Test/TestPsm.cs b/MetaMorpheus/Test/TestPsm.cs index e34d4b3a1..f7cba663f 100644 --- a/MetaMorpheus/Test/TestPsm.cs +++ b/MetaMorpheus/Test/TestPsm.cs @@ -18,6 +18,7 @@ using TaskLayer; using UsefulProteomicsDatabases; using PsmFromTsv = EngineLayer.PsmFromTsv; +using Omics; namespace Test { @@ -45,23 +46,23 @@ public static void TestPsmHeader() var theoreticalIons = new List(); pepWithSetMods.Fragment(DissociationType.HCD, FragmentationTerminus.Both, theoreticalIons); var matchedIons = MetaMorpheusEngine.MatchFragmentIons(scan, theoreticalIons, new CommonParameters()); - PeptideSpectralMatch psm = new PeptideSpectralMatch(pepWithSetMods, 1, 2, 3, scan, commonParameters, matchedIons); + SpectralMatch psm = new PeptideSpectralMatch(pepWithSetMods, 1, 2, 3, scan, commonParameters, matchedIons); psm.ResolveAllAmbiguities(); var t = psm.ToString(); - var tabsepheader = PeptideSpectralMatch.GetTabSeparatedHeader(); - Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); + var tabsepheader = SpectralMatch.GetTabSeparatedHeader(); + Assert.AreEqual(psm.ToString().Count(f => f == '\t'), SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); - Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); + Assert.AreEqual(psm.ToString().Count(f => f == '\t'), SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Tolerance fragmentTolerance = new PpmTolerance(10); - new LocalizationEngine(new List { psm }, myMsDataFile, new CommonParameters(productMassTolerance: fragmentTolerance), null, new List()).Run(); + new LocalizationEngine(new List { psm }, myMsDataFile, new CommonParameters(productMassTolerance: fragmentTolerance), null, new List()).Run(); - Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); + Assert.AreEqual(psm.ToString().Count(f => f == '\t'), SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); psm.SetFdrValues(6, 6, 6, 6, 6, 0, 0, 0); - Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); + Assert.AreEqual(psm.ToString().Count(f => f == '\t'), SpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); } [Test] @@ -116,7 +117,7 @@ public static void TestLongestFragmentIonSequence() ProteinDbLoader.UniprotOrganismRegex, -1); string myDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\DbForPrunedDb.fasta"); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpetralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, new CommonParameters(), null, null, new List(), writeSpetralLibrary).Run(); @@ -125,13 +126,13 @@ public static void TestLongestFragmentIonSequence() List longestSeriesExpected = new List { 4, 3, 3, 7, 7, 7, 7, 3, 3, 12, 8, 4, 4, 13, 7, 7, 7, 12, 12, 3, 3, 3, 2, 2, 2, 2, 2, 2, 11, 11, 11, 11, 11, 11, 4, 4, 4, 4, 4, 4, 10, 10, 13, 13, 5, 5, 5, 5, 15, 15, 15, 15, 3, 3, 3, 15, 15, 15, 3, 3, 3, 16, 6, 2, 2, 18, 3, 2, 2, 2, 2, 2, 9, 9, 9, 3, 2, 2, 2, 2, 2, 3, 3, 12, 6, 3, }; - foreach (PeptideSpectralMatch psm in allPsmsArray) + foreach (SpectralMatch psm in allPsmsArray) { if (psm != null) { - foreach (var (Notch, Peptide) in psm.BestMatchingPeptides) + foreach (var (Notch, Peptide) in psm.BestMatchingBioPolymersWithSetMods) { - longestSeriesObserved.Add(PeptideSpectralMatch.GetLongestIonSeriesBidirectional(psm.PeptidesToMatchingFragments, Peptide)); + longestSeriesObserved.Add(SpectralMatch.GetLongestIonSeriesBidirectional(psm.BioPolymersWithSetModsToMatchingFragments, Peptide)); } } } @@ -228,16 +229,16 @@ public static void TestPsmMatchingToTargetAndDecoyWithSameSequence() MsDataScan msDataScan = msDataFile.GetOneBasedScan(2); Ms2ScanWithSpecificMass scanWithMass = new Ms2ScanWithSpecificMass(msDataScan, 4, 1, null, commonParameters); - PeptideSpectralMatch psm = new PeptideSpectralMatch(target, 0, 1, 1, scanWithMass, commonParameters, null); + SpectralMatch psm = new PeptideSpectralMatch(target, 0, 1, 1, scanWithMass, commonParameters, null); psm.AddOrReplace(decoy, 1, 0, true, null, 0); - Assert.AreEqual(2, psm.BestMatchingPeptides.Count()); - Assert.That(psm.BestMatchingPeptides.Any(p => p.Peptide.Protein.IsDecoy)); + Assert.AreEqual(2, psm.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm.BestMatchingBioPolymersWithSetMods.Any(p => p.Peptide.Parent.IsDecoy)); psm.ResolveAllAmbiguities(); - Assert.AreEqual(1, psm.BestMatchingPeptides.Count()); - Assert.That(psm.BestMatchingPeptides.All(p => !p.Peptide.Protein.IsDecoy)); + Assert.AreEqual(1, psm.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm.BestMatchingBioPolymersWithSetMods.All(p => !p.Peptide.Parent.IsDecoy)); Assert.That(!psm.IsDecoy); } @@ -254,20 +255,20 @@ public static void TestPsmMatchingToTargetAndDecoyWithDifferentSequences() MsDataScan msDataScan = msDataFile.GetOneBasedScan(2); Ms2ScanWithSpecificMass scanWithMass = new Ms2ScanWithSpecificMass(msDataScan, 4, 1, null, commonParameters); - PeptideSpectralMatch psm = new PeptideSpectralMatch(target, 0, 1, 1, scanWithMass, commonParameters, null); + SpectralMatch psm = new PeptideSpectralMatch(target, 0, 1, 1, scanWithMass, commonParameters, null); psm.AddOrReplace(decoy, 1, 0, true, null, 0); - Assert.AreEqual(2, psm.BestMatchingPeptides.Count()); - Assert.That(psm.BestMatchingPeptides.Any(p => p.Peptide.Protein.IsDecoy)); + Assert.AreEqual(2, psm.BestMatchingBioPolymersWithSetMods.Count()); + Assert.That(psm.BestMatchingBioPolymersWithSetMods.Any(p => p.Peptide.Parent.IsDecoy)); psm.ResolveAllAmbiguities(); - Assert.AreEqual(2, psm.BestMatchingPeptides.Count()); + Assert.AreEqual(2, psm.BestMatchingBioPolymersWithSetMods.Count()); Assert.That(psm.IsDecoy); List<(string fileName, CommonParameters fileSpecificParameters)> fsp = new List<(string fileName, CommonParameters fileSpecificParameters)> { ("filename", commonParameters) }; - new FdrAnalysisEngine(new List { psm }, 1, new CommonParameters(), fsp, new List()).Run(); + new FdrAnalysisEngine(new List { psm }, 1, new CommonParameters(), fsp, new List()).Run(); Assert.AreEqual(0.5, psm.FdrInfo.CumulativeDecoy); } @@ -288,15 +289,15 @@ public static void TestPsmCount() MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, 0, 1, null, new CommonParameters()); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 0, 0, scan1, commonParameters, new List()); + SpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 0, 0, scan1, commonParameters, new List()); MsDataScan mzLibScan2 = t.GetOneBasedScan(4); Ms2ScanWithSpecificMass scan2 = new Ms2ScanWithSpecificMass(mzLibScan2, 0, 1, null, new CommonParameters()); - PeptideSpectralMatch psm2 = new PeptideSpectralMatch(pep2, 0, 0, 0, scan2, commonParameters, new List()); + SpectralMatch psm2 = new PeptideSpectralMatch(pep2, 0, 0, 0, scan2, commonParameters, new List()); MsDataScan mzLibScan3 = t.GetOneBasedScan(6); Ms2ScanWithSpecificMass scan3 = new Ms2ScanWithSpecificMass(mzLibScan3, 0, 1, null, new CommonParameters()); - PeptideSpectralMatch psm3 = new PeptideSpectralMatch(pep3, 0, 0, 0, scan3, commonParameters, new List()); + SpectralMatch psm3 = new PeptideSpectralMatch(pep3, 0, 0, 0, scan3, commonParameters, new List()); psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); // valid psm psm1.ResolveAllAmbiguities(); @@ -306,7 +307,7 @@ public static void TestPsmCount() psm3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); // ambiguous psm - var allPsms = new List { psm1, psm2, psm3 }; + var allPsms = new List { psm1, psm2, psm3 }; List<(string fileName, CommonParameters fileSpecificParameters)> fsp = new List<(string fileName, CommonParameters fileSpecificParameters)> { ("filename", new CommonParameters()) }; @@ -378,13 +379,13 @@ public static void TestPsmAddOrReplace() 2, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 1, null), 100, 1, null, new CommonParameters(), null); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0), 0, 10, 1, scanB, new CommonParameters(), new List(), 0); + SpectralMatch psm1 = new PeptideSpectralMatch(new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0), 0, 10, 1, scanB, new CommonParameters(), new List(), 0); PeptideWithSetModifications pwsm = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); psm1.AddOrReplace(pwsm, 11, 1, true, new List(), 0); - Assert.AreEqual(1, psm1.BestMatchingPeptides.Count()); + Assert.AreEqual(1, psm1.BestMatchingBioPolymersWithSetMods.Count()); Assert.AreEqual(11, psm1.Score); @@ -401,17 +402,17 @@ public static void TestComplementaryIons() 2, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 1, null), 100, 1, null, new CommonParameters(), null); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0), 0, 10, 1, scanB, new CommonParameters(), new List(), 0); + SpectralMatch psm1 = new PeptideSpectralMatch(new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0), 0, 10, 1, scanB, new CommonParameters(), new List(), 0); PeptideWithSetModifications pwsm = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); - int count = PeptideSpectralMatch.GetCountComplementaryIons(psm1.PeptidesToMatchingFragments, pwsm); + int count = SpectralMatch.GetCountComplementaryIons(psm1.BioPolymersWithSetModsToMatchingFragments, pwsm); //No Matched Fragment Ions Returns 0 Assert.AreEqual(0, count); - count = PeptideSpectralMatch.GetCountComplementaryIons(null, pwsm); - //PeptidesToMatchingFragments Null Returns 0 + count = SpectralMatch.GetCountComplementaryIons(null, pwsm); + //BioPolymersWithSetModsToMatchingFragments Null Returns 0 Assert.AreEqual(0, count); List myProducts = new List(); @@ -424,11 +425,11 @@ public static void TestComplementaryIons() mfiList.Add(new MatchedFragmentIon(prod, 1, 1, 1)); } - Dictionary> PTMF = new Dictionary>(); + Dictionary> PTMF = new Dictionary>(); PTMF.Add(pwsm, mfiList); - count = PeptideSpectralMatch.GetCountComplementaryIons(PTMF, pwsm); - //PeptidesToMatchingFragments Contains one N and one C ion so intersection Returns 1 + count = SpectralMatch.GetCountComplementaryIons(PTMF, pwsm); + //BioPolymersWithSetModsToMatchingFragments Contains one N and one C ion so intersection Returns 1 Assert.AreEqual(1, count); } @@ -445,15 +446,15 @@ public static void Test_PSM_GetLongestIonSeries_NullChecks() PeptideWithSetModifications pwsm = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary(), 0); - //PeptidesToMatchingFragments == null returns 1 - longestSeries = PeptideSpectralMatch.GetLongestIonSeriesBidirectional(null, pwsm); + //BioPolymersWithSetModsToMatchingFragments == null returns 1 + longestSeries = SpectralMatch.GetLongestIonSeriesBidirectional(null, pwsm); Assert.AreEqual(1, longestSeries); //matchedFragments == null returns 1 - Dictionary> PeptidesToMatchingFragments = new Dictionary>(); + Dictionary> PeptidesToMatchingFragments = new Dictionary>(); PeptidesToMatchingFragments.Add(pwsm, null); - longestSeries = PeptideSpectralMatch.GetLongestIonSeriesBidirectional(PeptidesToMatchingFragments, pwsm); + longestSeries = SpectralMatch.GetLongestIonSeriesBidirectional(PeptidesToMatchingFragments, pwsm); Assert.AreEqual(1, longestSeries); } @@ -492,7 +493,7 @@ public static void TestPSMFragmentCoverage() List mfis1 = new List { mfiC3, mfiC4, mfiC7, mfiC13, mfiN3, mfiN4, mfiN6, mfiN8, mfiN13}; MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, 0, 1, null, new CommonParameters()); - PeptideSpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 0, 0, scan1, commonParameters, mfis1); + SpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 0, 0, scan1, commonParameters, mfis1); psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); // valid psm psm1.ResolveAllAmbiguities(); psm1.GetAminoAcidCoverage(); @@ -512,7 +513,7 @@ public static void TestPSMFragmentCoverage() Assert.IsFalse(psm1.FragmentCoveragePositionInPeptide.Contains(5)); - PeptideSpectralMatch psm2 = new PeptideSpectralMatch(pep2, 0, 0, 0, scan1, commonParameters, mfis1); + SpectralMatch psm2 = new PeptideSpectralMatch(pep2, 0, 0, 0, scan1, commonParameters, mfis1); psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); // valid psm psm2.ResolveAllAmbiguities(); psm2.GetAminoAcidCoverage(); diff --git a/MetaMorpheus/Test/TestTopDown.cs b/MetaMorpheus/Test/TestTopDown.cs index b99e13262..c76f95057 100644 --- a/MetaMorpheus/Test/TestTopDown.cs +++ b/MetaMorpheus/Test/TestTopDown.cs @@ -47,7 +47,7 @@ public static void TestClassicSearchEngineTopDown() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; bool writeSpetralLibrary = false; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, null, null, new List(), writeSpetralLibrary).Run(); @@ -79,7 +79,7 @@ public static void TestModernSearchEngineTopDown() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); - PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; + SpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.Reverse, CommonParameters, null, 30000, false, new List(), TargetContaminantAmbiguity.RemoveContaminant, new List()); diff --git a/MetaMorpheus/Test/XLTest.cs b/MetaMorpheus/Test/XLTest.cs index ae600c76b..b1b041f46 100644 --- a/MetaMorpheus/Test/XLTest.cs +++ b/MetaMorpheus/Test/XLTest.cs @@ -203,7 +203,7 @@ public static void XlTest_BSA_DSSO() List<(string fileName, CommonParameters fileSpecificParameters)> fsp = new List<(string fileName, CommonParameters fileSpecificParameters)> { ("filename", commonParameters) }; - FdrAnalysisEngine fdrAnalysisEngine = new FdrAnalysisEngine(newPsms.ToList(), 0, commonParameters, fsp, new List(), ""); + FdrAnalysisEngine fdrAnalysisEngine = new FdrAnalysisEngine(newPsms.ToList(), 0, commonParameters, fsp, new List(), ""); Assert.AreEqual(4, newPsms.Count); Assert.That(newPsms[0].XlProteinPos == 2 && newPsms[0].BetaPeptide.XlProteinPos == 4); //cross @@ -529,9 +529,9 @@ public static void XlTest_MoreComprehensive() Assert.AreEqual(0, deadendTris); Assert.AreEqual(0, unnasignedCrossType); - var fdrResultsXLink = new FdrAnalysisEngine(firstCsmsFromListsOfCsms.Where(c => c.CrossType == PsmCrossType.Inter || c.CrossType == PsmCrossType.Intra).ToList(), 1, CommonParameters, fsp, new List(), "crosslink").Run(); + var fdrResultsXLink = new FdrAnalysisEngine(firstCsmsFromListsOfCsms.Where(c => c.CrossType == PsmCrossType.Inter || c.CrossType == PsmCrossType.Intra).ToList(), 1, CommonParameters, fsp, new List(), "crosslink").Run(); - fdrResultsXLink = new FdrAnalysisEngine(firstCsmsFromListsOfCsms.Where(c => c.CrossType != PsmCrossType.Inter && c.CrossType != PsmCrossType.Intra).ToList(), 1, CommonParameters, fsp, new List(), "standard").Run(); + fdrResultsXLink = new FdrAnalysisEngine(firstCsmsFromListsOfCsms.Where(c => c.CrossType != PsmCrossType.Inter && c.CrossType != PsmCrossType.Intra).ToList(), 1, CommonParameters, fsp, new List(), "standard").Run(); unnasignedCrossType = 0; inter = 0; @@ -634,7 +634,7 @@ public static void XlTest_MoreComprehensive() { Path.GetFileName(intraCsm.FullFilePath), 0 } }; - var intraPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("crosslink", fsp, intraCsm, sequenceToPsmCount, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified, medianFragmentMassError, chargeStateMode, intraCsm.BestMatchingPeptides.First().Peptide, intraCsm.BestMatchingPeptides.First().Notch, !intraCsm.BestMatchingPeptides.First().Peptide.Protein.IsDecoy); + var intraPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("crosslink", fsp, intraCsm, sequenceToPsmCount, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified, medianFragmentMassError, chargeStateMode, intraCsm.BestMatchingBioPolymersWithSetMods.First().Peptide, intraCsm.BestMatchingBioPolymersWithSetMods.First().Notch, !intraCsm.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.IsDecoy); Assert.That(intraPsmData.AbsoluteAverageFragmentMassErrorFromMedian, Is.EqualTo(1.0).Within(0.1)); Assert.That(intraPsmData.AlphaIntensity, Is.EqualTo(1).Within(0.1)); Assert.AreEqual(intraPsmData.Ambiguity, 0); @@ -660,13 +660,13 @@ public static void XlTest_MoreComprehensive() CrosslinkSpectralMatch singleCsm = firstCsmsFromListsOfCsms.Where(c => c.CrossType == PsmCrossType.Single).OrderBy(c => -c.Score).First(); - List psms = new List(); + List psms = new List(); psms.AddRange(firstCsmsFromListsOfCsms); fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified = PEP_Analysis_Cross_Validation.ComputeHydrophobicityValues(psms, fsp, false); fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified = PEP_Analysis_Cross_Validation.ComputeHydrophobicityValues(psms, fsp, true); - var singleCsmPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("standard", fsp, singleCsm, sequenceToPsmCount, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified, medianFragmentMassError, chargeStateMode, singleCsm.BestMatchingPeptides.First().Peptide, singleCsm.BestMatchingPeptides.First().Notch, !singleCsm.BestMatchingPeptides.First().Peptide.Protein.IsDecoy); + var singleCsmPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("standard", fsp, singleCsm, sequenceToPsmCount, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified, medianFragmentMassError, chargeStateMode, singleCsm.BestMatchingBioPolymersWithSetMods.First().Peptide, singleCsm.BestMatchingBioPolymersWithSetMods.First().Notch, !singleCsm.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.IsDecoy); Assert.That(singleCsmPsmData.AbsoluteAverageFragmentMassErrorFromMedian, Is.EqualTo(8).Within(0.1)); Assert.AreEqual(singleCsmPsmData.AlphaIntensity, 0); Assert.AreEqual(singleCsmPsmData.Ambiguity, 0); @@ -692,7 +692,7 @@ public static void XlTest_MoreComprehensive() Assert.That(singleCsmPsmData.TotalMatchingFragmentCount, Is.EqualTo(8).Within(0.1)); CrosslinkSpectralMatch loopCsm = firstCsmsFromListsOfCsms.Where(c => c.CrossType == PsmCrossType.Loop).OrderBy(c => -c.Score).First(); - var loopCsmPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("standard", fsp, loopCsm, sequenceToPsmCount, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified, medianFragmentMassError, chargeStateMode, loopCsm.BestMatchingPeptides.First().Peptide, loopCsm.BestMatchingPeptides.First().Notch, !loopCsm.BestMatchingPeptides.First().Peptide.Protein.IsDecoy); + var loopCsmPsmData = PEP_Analysis_Cross_Validation.CreateOnePsmDataEntry("standard", fsp, loopCsm, sequenceToPsmCount, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_unmodified, fileSpecificTimeDependantHydrophobicityAverageAndDeviation_modified, medianFragmentMassError, chargeStateMode, loopCsm.BestMatchingBioPolymersWithSetMods.First().Peptide, loopCsm.BestMatchingBioPolymersWithSetMods.First().Notch, !loopCsm.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.IsDecoy); Assert.That(loopCsmPsmData.AbsoluteAverageFragmentMassErrorFromMedian, Is.EqualTo(6).Within(0.1)); Assert.AreEqual(loopCsmPsmData.AlphaIntensity, 0); Assert.AreEqual(loopCsmPsmData.Ambiguity, 0); @@ -1228,11 +1228,11 @@ public static void XLSearchTastWriteFileTest() //check decoy label csmAlpha.BetaPeptide = csmBeta; Crosslinker xlinker = Crosslinker.ParseCrosslinkerFromString("DSSO\tK\tK\tT\tCID|HCD\t158.0038\t54.01056\t85.982635\t176.0143\t175.0303\t279.0777"); - double someSortOfMass = csmAlpha.ScanPrecursorMass - csmAlpha.BetaPeptide.PeptideMonisotopicMass.Value - csmAlpha.PeptideMonisotopicMass.Value - xlinker.TotalMass; + double someSortOfMass = csmAlpha.ScanPrecursorMass - csmAlpha.BetaPeptide.BioPolymerWithSetModsMonoisotopicMass.Value - csmAlpha.BioPolymerWithSetModsMonoisotopicMass.Value - xlinker.TotalMass; string someLongString = "-." + csmAlpha.FullSequence + csmAlpha.LinkPositions.First().ToString(CultureInfo.InvariantCulture) + "--" + csmAlpha.BetaPeptide.FullSequence + csmAlpha.BetaPeptide.LinkPositions.First().ToString(CultureInfo.InvariantCulture) + ".-"; - string someOtherString = csmAlpha.BestMatchingPeptides.First().Peptide.Protein.Accession.ToString(CultureInfo.InvariantCulture) + string someOtherString = csmAlpha.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.Accession.ToString(CultureInfo.InvariantCulture) + "(" + (csmAlpha.XlProteinPos.HasValue ? csmAlpha.XlProteinPos.Value.ToString(CultureInfo.InvariantCulture) : string.Empty) + ")"; - string lastRandomString = csmAlpha.BetaPeptide.BestMatchingPeptides.First().Peptide.Protein.Accession.ToString(CultureInfo.InvariantCulture) + string lastRandomString = csmAlpha.BetaPeptide.BestMatchingBioPolymersWithSetMods.First().Peptide.Parent.Accession.ToString(CultureInfo.InvariantCulture) + "(" + (csmAlpha.BetaPeptide.XlProteinPos.HasValue ? csmAlpha.BetaPeptide.XlProteinPos.Value.ToString(CultureInfo.InvariantCulture) : string.Empty) + ")"; Assert.AreEqual("NaN", csmAlpha.ScanRetentionTime.ToString(CultureInfo.InvariantCulture)); @@ -1439,7 +1439,7 @@ public static void TestMixedMs2Ms2() && psmFromTsv.ProteinLinkSite == 455 && psmFromTsv.ParentIons.Equals("2;2")); - Assert.That(csm.ProteinAccession == null && csm.BetaPeptide.ProteinAccession == null); + Assert.That(csm.Accession == null && csm.BetaPeptide.Accession == null); Assert.That(psmFromTsv.ProteinAccession == "BSA|BSA2"); Assert.That(psmFromTsv.UniqueSequence, Is.EqualTo(psmFromTsv.FullSequence + psmFromTsv.BetaPeptideFullSequence)); diff --git a/MetaMorpheus/Test/gptmdPrunedBdTests.cs b/MetaMorpheus/Test/gptmdPrunedBdTests.cs index 586560fd0..a24149ba4 100644 --- a/MetaMorpheus/Test/gptmdPrunedBdTests.cs +++ b/MetaMorpheus/Test/gptmdPrunedBdTests.cs @@ -364,7 +364,7 @@ public static void TestProteinPrunedWithModSelection() MzSpectrum spectrum = new MzSpectrum(noiseData); MsDataScan scan = new MsDataScan(spectrum , 1, 1, true, Polarity.Unknown, 2, new MzLibUtil.MzRange(10, 1000), "", MZAnalyzerType.Orbitrap, 10000, null, noiseData, ""); testPostTaskParameters.ProteinList = new List() { protein1, protein2 }; - testPostTaskParameters.AllPsms = new List { new PeptideSpectralMatch(peptideObserved, 0, 20, 1, new Ms2ScanWithSpecificMass(scan, 100, 1, @"", commonParam), commonParam, matchedFragmentIons) }; + testPostTaskParameters.AllPsms = new List { new PeptideSpectralMatch(peptideObserved, 0, 20, 1, new Ms2ScanWithSpecificMass(scan, 100, 1, @"", commonParam), commonParam, matchedFragmentIons) }; testPostTaskParameters.SearchParameters = new SearchParameters(); testPostTaskParameters.SearchParameters.WritePrunedDatabase = true; testPostTaskParameters.SearchParameters.DoLabelFreeQuantification = false; @@ -469,7 +469,7 @@ public static void TestProteinPrunedWithModSelectionAndVariants() MzSpectrum spectrum = new MzSpectrum(noiseData); MsDataScan scan = new MsDataScan(spectrum, 1, 1, true, Polarity.Unknown, 2, new MzLibUtil.MzRange(10, 1000), "", MZAnalyzerType.Orbitrap, 10000, null, noiseData, ""); testPostTaskParameters.ProteinList = proteinList; - testPostTaskParameters.AllPsms = new List { new PeptideSpectralMatch(peptideObserved, 0, 20, 1, new Ms2ScanWithSpecificMass(scan, 100, 1, @"", commonParam), commonParam, matchedFragmentIons) }; + testPostTaskParameters.AllPsms = new List { new PeptideSpectralMatch(peptideObserved, 0, 20, 1, new Ms2ScanWithSpecificMass(scan, 100, 1, @"", commonParam), commonParam, matchedFragmentIons) }; testPostTaskParameters.SearchParameters = new SearchParameters(); testPostTaskParameters.SearchParameters.WritePrunedDatabase = true; testPostTaskParameters.SearchParameters.DoLabelFreeQuantification = false; From 031c96292f6bd9b3e461f5d147cbaf322171092d Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 18 Jan 2024 16:16:21 -0600 Subject: [PATCH 09/39] Added Omics to project.wxs --- MetaMorpheus/MetaMorpheusSetup/Product.wxs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MetaMorpheus/MetaMorpheusSetup/Product.wxs b/MetaMorpheus/MetaMorpheusSetup/Product.wxs index 5d9ec87f8..4bb106375 100644 --- a/MetaMorpheus/MetaMorpheusSetup/Product.wxs +++ b/MetaMorpheus/MetaMorpheusSetup/Product.wxs @@ -271,6 +271,9 @@ + + + From 87d9844298ace9fce7ddf0f5a0157107a8296288 Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 18 Jan 2024 19:00:28 -0600 Subject: [PATCH 10/39] Updated ParsimonySequence to use interfaces --- .../ProteinParsimony/ParsimonySequence.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs index 64d4f7b5f..139670fe2 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs @@ -1,29 +1,30 @@ -using Proteomics.ProteolyticDigestion; +using Omics; +using Omics.Digestion; namespace EngineLayer.ProteinParsimony { internal class ParsimonySequence { - public ParsimonySequence(PeptideWithSetModifications pwsm, bool TreatModPeptidesAsDifferentPeptides) + public ParsimonySequence(IBioPolymerWithSetMods pwsm, bool TreatModPeptidesAsDifferentPeptides) { Sequence = TreatModPeptidesAsDifferentPeptides ? pwsm.FullSequence : pwsm.BaseSequence; - Protease = pwsm.DigestionParams.DigestionAgent as Protease ?? throw new MetaMorpheusException("Digestion agent is not of type protease"); + DigestionAgent = pwsm.DigestionParams.DigestionAgent; } public string Sequence { get; } - public Protease Protease { get; } + public DigestionAgent DigestionAgent { get; } public override bool Equals(object obj) { ParsimonySequence other = (ParsimonySequence)obj; return other != null && (Sequence == null && other.Sequence == null || Sequence.Equals(other.Sequence)) - && (Protease == null && other.Protease == null || Protease.Equals(other.Protease)); + && (DigestionAgent == null && other.DigestionAgent == null || DigestionAgent.Equals(other.DigestionAgent)); } public override int GetHashCode() { - return Sequence.GetHashCode() ^ Protease.GetHashCode(); + return Sequence.GetHashCode() ^ DigestionAgent.GetHashCode(); } } } \ No newline at end of file From 75d1bc22bb76ba203908ea4796961d67880daf57 Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 22 Jan 2024 16:13:59 -0600 Subject: [PATCH 11/39] a --- MetaMorpheus/EngineLayer/SpectralMatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MetaMorpheus/EngineLayer/SpectralMatch.cs b/MetaMorpheus/EngineLayer/SpectralMatch.cs index 5001a6e6c..2341e12fc 100644 --- a/MetaMorpheus/EngineLayer/SpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/SpectralMatch.cs @@ -187,7 +187,7 @@ public void ResolveAllAmbiguities() // remove the decoys with this sequence var pwsmToRemove = _BestMatchingBioPolymersWithSetMods.Where(p => p.Pwsm.FullSequence == hit.Key && p.Pwsm.Parent.IsDecoy).ToList(); _BestMatchingBioPolymersWithSetMods.RemoveAll(p => p.Pwsm.FullSequence == hit.Key && p.Pwsm.Parent.IsDecoy); - foreach ((int, PeptideWithSetModifications) pwsm in pwsmToRemove) + foreach ((int, IBioPolymerWithSetMods) pwsm in pwsmToRemove) { BioPolymersWithSetModsToMatchingFragments.Remove(pwsm.Item2); } From 569edd708bda4a2a7b683b506416536b385dea97 Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 22 Jan 2024 16:23:40 -0600 Subject: [PATCH 12/39] Udpated to mzlib pr 757 --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index bd06f28ad..d0d281642 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 566646d8f..6740db347 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index f9d072025..392593033 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index 5b5a9ca6a..c7472aefe 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index b1383bb38..0279b1ba6 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index ee30e3494..05e7eb14d 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From 1b83e1ac7ac2de82c64f07aab9e1d4a5af1f8494 Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 22 Jan 2024 16:24:15 -0600 Subject: [PATCH 13/39] Updated to mzlib pr 757 --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index bd06f28ad..d0d281642 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 566646d8f..6740db347 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index f9d072025..392593033 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index 5b5a9ca6a..c7472aefe 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index b1383bb38..0279b1ba6 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index ee30e3494..05e7eb14d 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From bf78cae79060f5a69316a0e2f7d888ca23a9bc6f Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 22 Jan 2024 16:30:16 -0600 Subject: [PATCH 14/39] Changed names of digestion params MinLength, MaxLength, and MaxMods to new naming convention --- MetaMorpheus/EngineLayer/CommonParameters.cs | 6 +++--- .../CrosslinkSearch/CrosslinkSearchEngine.cs | 2 +- MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs | 6 +++--- .../NonSpecificEnzymeSearchEngine.cs | 12 ++++++------ .../GUI/TaskWindows/CalibrateTaskWindow.xaml.cs | 6 +++--- MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs | 6 +++--- .../GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs | 6 +++--- .../GUI/TaskWindows/SearchTaskWindow.xaml.cs | 6 +++--- .../GUI/TaskWindows/XLSearchTaskWindow.xaml.cs | 4 ++-- .../GUI/Views/FileSpecificParametersWindow.xaml.cs | 6 +++--- .../TaskLayer/CalibrationTask/CalibrationTask.cs | 8 ++++---- MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs | 6 +++--- .../TaskLayer/GlycoSearchTask/GlycoSearchTask.cs | 6 +++--- MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 6 +++--- MetaMorpheus/TaskLayer/PepXMLWriter.cs | 4 ++-- MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs | 8 ++++---- MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs | 4 ++-- MetaMorpheus/TaskLayer/XLSearchTask/XLSearchTask.cs | 6 +++--- MetaMorpheus/Test/ParameterTest.cs | 6 +++--- MetaMorpheus/Test/TestToml.cs | 8 ++++---- 20 files changed, 61 insertions(+), 61 deletions(-) diff --git a/MetaMorpheus/EngineLayer/CommonParameters.cs b/MetaMorpheus/EngineLayer/CommonParameters.cs index f39ff3394..b7e4c33f4 100644 --- a/MetaMorpheus/EngineLayer/CommonParameters.cs +++ b/MetaMorpheus/EngineLayer/CommonParameters.cs @@ -215,11 +215,11 @@ public CommonParameters CloneWithNewTerminus(FragmentationTerminus? terminus = n new DigestionParams( DigestionParams.Protease.Name, DigestionParams.MaxMissedCleavages, - DigestionParams.MinPeptideLength, - DigestionParams.MaxPeptideLength, + DigestionParams.MinLength, + DigestionParams.MaxLength, DigestionParams.MaxModificationIsoforms, DigestionParams.InitiatorMethionineBehavior, - DigestionParams.MaxModsForPeptide, + DigestionParams.MaxMods, DigestionParams.SearchModeType, terminus.Value //possibly changed ), diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs index e9cda06d3..abfda1a6f 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs @@ -400,7 +400,7 @@ private void FindCrosslinkedPeptide(Ms2ScanWithSpecificMass scan, List<(double, } } } - else if (pre.Item1 - PrecursorMassTable[id] >= (CommonParameters.DigestionParams.MinPeptideLength * 50)) + else if (pre.Item1 - PrecursorMassTable[id] >= (CommonParameters.DigestionParams.MinLength * 50)) { if (possibleCrosslinkLocations == null) { diff --git a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs index c586fa394..5c750f96f 100644 --- a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs +++ b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs @@ -71,11 +71,11 @@ public override string ToString() sb.AppendLine("protease: " + CommonParameters.DigestionParams.Protease); sb.AppendLine("initiatorMethionineBehavior: " + CommonParameters.DigestionParams.InitiatorMethionineBehavior); sb.AppendLine("maximumMissedCleavages: " + CommonParameters.DigestionParams.MaxMissedCleavages); - sb.AppendLine("minPeptideLength: " + CommonParameters.DigestionParams.MinPeptideLength); - sb.AppendLine("maxPeptideLength: " + CommonParameters.DigestionParams.MaxPeptideLength); + sb.AppendLine("minPeptideLength: " + CommonParameters.DigestionParams.MinLength); + sb.AppendLine("maxPeptideLength: " + CommonParameters.DigestionParams.MaxLength); sb.AppendLine("maximumVariableModificationIsoforms: " + CommonParameters.DigestionParams.MaxModificationIsoforms); sb.AppendLine("digestionTerminus: " + CommonParameters.DigestionParams.FragmentationTerminus); - sb.AppendLine("maxModsForEachPeptide: " + CommonParameters.DigestionParams.MaxModsForPeptide); + sb.AppendLine("maxModsForEachPeptide: " + CommonParameters.DigestionParams.MaxMods); sb.AppendLine("cleavageSpecificity: " + CommonParameters.DigestionParams.SearchModeType); sb.AppendLine("specificProtease: " + CommonParameters.DigestionParams.SpecificProtease); sb.AppendLine("maximumFragmentSize" + (int)Math.Round(MaxFragmentSize)); diff --git a/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs b/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs index 1426bd4aa..a05a5c539 100644 --- a/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs @@ -35,7 +35,7 @@ public NonSpecificEnzymeSearchEngine(SpectralMatch[][] globalPsms, Ms2ScanWithSp { CoisolationIndex = coisolationIndex; PrecursorIndex = precursorIndex; - MinimumPeptideLength = commonParameters.DigestionParams.MinPeptideLength; + MinimumPeptideLength = commonParameters.DigestionParams.MinLength; GlobalCategorySpecificPsms = globalPsms; ModifiedParametersNoComp = commonParameters.CloneWithNewTerminus(addCompIons: false); ProductTypesToSearch = DissociationTypeCollection.ProductsFromDissociationType[commonParameters.DissociationType].Intersect(TerminusSpecificProductTypes.ProductIonTypesFromSpecifiedTerminus[commonParameters.DigestionParams.FragmentationTerminus]).ToList(); @@ -318,7 +318,7 @@ private void SnesIndexedScoring(Ms2ScanWithSpecificMass scan, List[] Fragme private Tuple Accepts(List fragments, double scanPrecursorMass, PeptideWithSetModifications peptide, FragmentationTerminus fragmentationTerminus, MassDiffAcceptor searchMode, bool semiSpecificSearch) { - int localminPeptideLength = CommonParameters.DigestionParams.MinPeptideLength; + int localminPeptideLength = CommonParameters.DigestionParams.MinLength; //Get terminal modifications, if any Dictionary> databaseAnnotatedMods = semiSpecificSearch ? null : GetTerminalModPositions(peptide, CommonParameters.DigestionParams, VariableTerminalModifications); @@ -605,11 +605,11 @@ public static Dictionary> GetTerminalModPositions(Peptid //determine the start and end index ranges when considering the minimum peptide length int startResidue = nTerminus ? - peptide.OneBasedStartResidue + digestionParams.MinPeptideLength - 1 : + peptide.OneBasedStartResidue + digestionParams.MinLength - 1 : peptide.OneBasedStartResidue; int endResidue = nTerminus ? peptide.OneBasedEndResidue : - peptide.OneBasedEndResidue - digestionParams.MinPeptideLength + 1; + peptide.OneBasedEndResidue - digestionParams.MinLength + 1; string terminalStringToFind = nTerminus ? "C-terminal" : "N-terminal"; //if singleN, want to find c-terminal mods and vice-versa //get all the mods for this protein @@ -647,7 +647,7 @@ public static Dictionary> GetTerminalModPositions(Peptid if (nTerminus) { //if singleN, then we're looking at C-terminal - if (index >= digestionParams.MinPeptideLength) + if (index >= digestionParams.MinLength) { if (annotatedTerminalModDictionary.ContainsKey(index)) { @@ -663,7 +663,7 @@ public static Dictionary> GetTerminalModPositions(Peptid { int fragmentIndex = peptide.BaseSequence.Length - index + 1; //if index == 0, length should be the peptide length //if singleC, then we're looking at N-terminal - if (fragmentIndex >= digestionParams.MinPeptideLength) + if (fragmentIndex >= digestionParams.MinLength) { if (annotatedTerminalModDictionary.ContainsKey(fragmentIndex)) { diff --git a/MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs index 68aa2fc4c..5e3d87bad 100644 --- a/MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs @@ -53,10 +53,10 @@ private void UpdateFieldsFromTask(CalibrationTask task) { ProteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; //protease needs to come first or recommended settings can overwrite the actual settings MissedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); - MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinPeptideLength.ToString(CultureInfo.InvariantCulture); - MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxPeptideLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxPeptideLength.ToString(CultureInfo.InvariantCulture); + MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinLength.ToString(CultureInfo.InvariantCulture); + MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxLength.ToString(CultureInfo.InvariantCulture); - MaxModsPerPeptideTextBox.Text = task.CommonParameters.DigestionParams.MaxModsForPeptide.ToString(CultureInfo.InvariantCulture); + MaxModsPerPeptideTextBox.Text = task.CommonParameters.DigestionParams.MaxMods.ToString(CultureInfo.InvariantCulture); MaxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; DissociationTypeComboBox.SelectedItem = task.CommonParameters.DissociationType.ToString(); diff --git a/MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs index fa0270c33..62c42e428 100644 --- a/MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs @@ -67,11 +67,11 @@ private void UpdateFieldsFromTask(GptmdTask task) DeconvolutePrecursors.IsChecked = task.CommonParameters.DoPrecursorDeconvolution; DeconvolutionMaxAssumedChargeStateTextBox.Text = task.CommonParameters.DeconvolutionMaxAssumedChargeState.ToString(); MissedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); - MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinPeptideLength.ToString(CultureInfo.InvariantCulture); - MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxPeptideLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxPeptideLength.ToString(CultureInfo.InvariantCulture); + MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinLength.ToString(CultureInfo.InvariantCulture); + MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxLength.ToString(CultureInfo.InvariantCulture); MaxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); - MaxModsPerPeptideTextBox.Text = task.CommonParameters.DigestionParams.MaxModsForPeptide.ToString(CultureInfo.InvariantCulture); + MaxModsPerPeptideTextBox.Text = task.CommonParameters.DigestionParams.MaxMods.ToString(CultureInfo.InvariantCulture); InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; DissociationTypeComboBox.SelectedItem = task.CommonParameters.DissociationType.ToString(); ProductMassToleranceTextBox.Text = task.CommonParameters.ProductMassTolerance.Value.ToString(CultureInfo.InvariantCulture); diff --git a/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs index b3d7847e3..2af1b19e9 100644 --- a/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs @@ -166,11 +166,11 @@ private void UpdateFieldsFromTask(GlycoSearchTask task) deconvolutePrecursors.IsChecked = task.CommonParameters.DoPrecursorDeconvolution; useProvidedPrecursor.IsChecked = task.CommonParameters.UseProvidedPrecursorInfo; missedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); - MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinPeptideLength.ToString(CultureInfo.InvariantCulture); - MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxPeptideLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxPeptideLength.ToString(CultureInfo.InvariantCulture); + MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinLength.ToString(CultureInfo.InvariantCulture); + MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxLength.ToString(CultureInfo.InvariantCulture); proteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; maxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); - TxtBoxMaxModPerPep.Text = task.CommonParameters.DigestionParams.MaxModsForPeptide.ToString(CultureInfo.InvariantCulture); + TxtBoxMaxModPerPep.Text = task.CommonParameters.DigestionParams.MaxMods.ToString(CultureInfo.InvariantCulture); initiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; productMassToleranceTextBox.Text = task.CommonParameters.ProductMassTolerance.Value.ToString(CultureInfo.InvariantCulture); productMassToleranceComboBox.SelectedIndex = task.CommonParameters.ProductMassTolerance is AbsoluteTolerance ? 0 : 1; diff --git a/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs index 73567143f..f9e292883 100644 --- a/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs @@ -272,11 +272,11 @@ private void UpdateFieldsFromTask(SearchTask task) RadioButtonReverseDecoy.IsChecked = task.SearchParameters.DecoyType == DecoyType.Reverse; RadioButtonSlideDecoy.IsChecked = task.SearchParameters.DecoyType == DecoyType.Slide; MissedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); - MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinPeptideLength.ToString(CultureInfo.InvariantCulture); - MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxPeptideLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxPeptideLength.ToString(CultureInfo.InvariantCulture); + MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinLength.ToString(CultureInfo.InvariantCulture); + MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxLength.ToString(CultureInfo.InvariantCulture); MaxFragmentMassTextBox.Text = task.SearchParameters.MaxFragmentSize.ToString(CultureInfo.InvariantCulture); //put after max peptide length to allow for override of auto maxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); - MaxModNumTextBox.Text = task.CommonParameters.DigestionParams.MaxModsForPeptide.ToString(CultureInfo.InvariantCulture); + MaxModNumTextBox.Text = task.CommonParameters.DigestionParams.MaxMods.ToString(CultureInfo.InvariantCulture); InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; DissociationTypeComboBox.SelectedItem = task.CommonParameters.DissociationType.ToString(); SeparationTypeComboBox.SelectedItem = task.CommonParameters.SeparationType.ToString(); diff --git a/MetaMorpheus/GUI/TaskWindows/XLSearchTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/XLSearchTaskWindow.xaml.cs index 477d53d2f..1d09c8469 100644 --- a/MetaMorpheus/GUI/TaskWindows/XLSearchTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/XLSearchTaskWindow.xaml.cs @@ -158,8 +158,8 @@ private void UpdateFieldsFromTask(XLSearchTask task) deconvolutePrecursors.IsChecked = task.CommonParameters.DoPrecursorDeconvolution; useProvidedPrecursor.IsChecked = task.CommonParameters.UseProvidedPrecursorInfo; missedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); - MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinPeptideLength.ToString(CultureInfo.InvariantCulture); - MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxPeptideLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxPeptideLength.ToString(CultureInfo.InvariantCulture); + MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinLength.ToString(CultureInfo.InvariantCulture); + MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxLength.ToString(CultureInfo.InvariantCulture); proteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; maxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); initiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; diff --git a/MetaMorpheus/GUI/Views/FileSpecificParametersWindow.xaml.cs b/MetaMorpheus/GUI/Views/FileSpecificParametersWindow.xaml.cs index 02494f1da..74bb899f5 100644 --- a/MetaMorpheus/GUI/Views/FileSpecificParametersWindow.xaml.cs +++ b/MetaMorpheus/GUI/Views/FileSpecificParametersWindow.xaml.cs @@ -208,10 +208,10 @@ private void PopulateChoices() // use default settings to populate var defaultParams = new CommonParameters(); Protease tempProtease = defaultParams.DigestionParams.Protease; - int tempMinPeptideLength = defaultParams.DigestionParams.MinPeptideLength; - int tempMaxPeptideLength = defaultParams.DigestionParams.MaxPeptideLength; + int tempMinPeptideLength = defaultParams.DigestionParams.MinLength; + int tempMaxPeptideLength = defaultParams.DigestionParams.MaxLength; int tempMaxMissedCleavages = defaultParams.DigestionParams.MaxMissedCleavages; - int tempMaxModsForPeptide = defaultParams.DigestionParams.MaxModsForPeptide; + int tempMaxModsForPeptide = defaultParams.DigestionParams.MaxMods; var tempPrecursorMassTolerance = defaultParams.PrecursorMassTolerance; var tempProductMassTolerance = defaultParams.ProductMassTolerance; DissociationType tempDissociationType = defaultParams.DissociationType; diff --git a/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs b/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs index 82b2762a1..1da9a9e70 100644 --- a/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs +++ b/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs @@ -45,14 +45,14 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; "); _ = ProseCreatedWhileRunning.Append("variable modifications = " + string.Join(", ", variableModifications.Select(m => m.IdWithMotif)) + "; "); - _ = ProseCreatedWhileRunning.Append("max mods per peptide = " + CommonParameters.DigestionParams.MaxModsForPeptide + "; "); + _ = ProseCreatedWhileRunning.Append("max mods per peptide = " + CommonParameters.DigestionParams.MaxMods + "; "); _ = ProseCreatedWhileRunning.Append("max modification isoforms = " + CommonParameters.DigestionParams.MaxModificationIsoforms + "; "); _ = ProseCreatedWhileRunning.Append("precursor mass tolerance = " + CommonParameters.PrecursorMassTolerance + "; "); _ = ProseCreatedWhileRunning.Append("product mass tolerance = " + CommonParameters.ProductMassTolerance + ". "); diff --git a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs index 5d04226cc..8f34924b4 100644 --- a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs +++ b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs @@ -46,10 +46,10 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; "); diff --git a/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoSearchTask.cs b/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoSearchTask.cs index 3d3e4ae0f..1c68667bf 100644 --- a/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoSearchTask.cs +++ b/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoSearchTask.cs @@ -61,10 +61,10 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; \n"); diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index 8aa93e245..5abf4eb60 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -397,10 +397,10 @@ public static CommonParameters SetAllFileSpecificCommonParams(CommonParameters c // set file-specific digestion parameters Protease protease = fileSpecificParams.Protease ?? commonParams.DigestionParams.SpecificProtease; //set to specific for nonspecific searches to update - int minPeptideLength = fileSpecificParams.MinPeptideLength ?? commonParams.DigestionParams.MinPeptideLength; - int maxPeptideLength = fileSpecificParams.MaxPeptideLength ?? commonParams.DigestionParams.MaxPeptideLength; + int minPeptideLength = fileSpecificParams.MinPeptideLength ?? commonParams.DigestionParams.MinLength; + int maxPeptideLength = fileSpecificParams.MaxPeptideLength ?? commonParams.DigestionParams.MaxLength; int maxMissedCleavages = fileSpecificParams.MaxMissedCleavages ?? commonParams.DigestionParams.MaxMissedCleavages; - int maxModsForPeptide = fileSpecificParams.MaxModsForPeptide ?? commonParams.DigestionParams.MaxModsForPeptide; + int maxModsForPeptide = fileSpecificParams.MaxModsForPeptide ?? commonParams.DigestionParams.MaxMods; DigestionParams fileSpecificDigestionParams = new DigestionParams( protease: protease.Name, maxMissedCleavages: maxMissedCleavages, diff --git a/MetaMorpheus/TaskLayer/PepXMLWriter.cs b/MetaMorpheus/TaskLayer/PepXMLWriter.cs index 3b30ab068..c66bd2eb2 100644 --- a/MetaMorpheus/TaskLayer/PepXMLWriter.cs +++ b/MetaMorpheus/TaskLayer/PepXMLWriter.cs @@ -43,8 +43,8 @@ public static void WritePepXml(List psms, List databas para.Add(new pepXML.Generated.nameValueType { name = "Protease", value = CommonParameters.DigestionParams.Protease.Name }); para.Add(new pepXML.Generated.nameValueType { name = "Initiator Methionine", value = CommonParameters.DigestionParams.InitiatorMethionineBehavior.ToString() }); para.Add(new pepXML.Generated.nameValueType { name = "Max Modification Isoforms", value = CommonParameters.DigestionParams.MaxModificationIsoforms.ToString() }); - para.Add(new pepXML.Generated.nameValueType { name = "Min Peptide Len", value = CommonParameters.DigestionParams.MinPeptideLength.ToString() }); - para.Add(new pepXML.Generated.nameValueType { name = "Max Peptide Len", value = CommonParameters.DigestionParams.MaxPeptideLength.ToString() }); + para.Add(new pepXML.Generated.nameValueType { name = "Min Peptide Len", value = CommonParameters.DigestionParams.MinLength.ToString() }); + para.Add(new pepXML.Generated.nameValueType { name = "Max Peptide Len", value = CommonParameters.DigestionParams.MaxLength.ToString() }); para.Add(new pepXML.Generated.nameValueType { name = "Product Mass Tolerance", value = CommonParameters.ProductMassTolerance.ToString() }); // TODO: check this para.Add(new pepXML.Generated.nameValueType { name = "Ions to search", value = string.Join(", ", DissociationTypeCollection.ProductsFromDissociationType[CommonParameters.DissociationType]) }); diff --git a/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs b/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs index 1d9245347..d1c220704 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs @@ -150,14 +150,14 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; "); ProseCreatedWhileRunning.Append("variable modifications = " + string.Join(", ", variableModifications.Select(m => m.IdWithMotif)) + "; "); - ProseCreatedWhileRunning.Append("max mods per peptide = " + CommonParameters.DigestionParams.MaxModsForPeptide + "; "); + ProseCreatedWhileRunning.Append("max mods per peptide = " + CommonParameters.DigestionParams.MaxMods + "; "); ProseCreatedWhileRunning.Append("max modification isoforms = " + CommonParameters.DigestionParams.MaxModificationIsoforms + "; "); ProseCreatedWhileRunning.Append("precursor mass tolerance = " + CommonParameters.PrecursorMassTolerance + "; "); ProseCreatedWhileRunning.Append("product mass tolerance = " + CommonParameters.ProductMassTolerance + "; "); diff --git a/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs b/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs index 32fadc5c1..c4c48a157 100644 --- a/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs +++ b/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs @@ -129,8 +129,8 @@ public static void WritePepXML_xl(List items, List Date: Mon, 22 Jan 2024 17:08:30 -0600 Subject: [PATCH 15/39] Implemented clone function in commonparams --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/CommonParameters.cs | 12 +----------- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 7 files changed, 7 insertions(+), 17 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index d0d281642..54b717e7a 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/CommonParameters.cs b/MetaMorpheus/EngineLayer/CommonParameters.cs index b7e4c33f4..194963fe3 100644 --- a/MetaMorpheus/EngineLayer/CommonParameters.cs +++ b/MetaMorpheus/EngineLayer/CommonParameters.cs @@ -212,17 +212,7 @@ public CommonParameters CloneWithNewTerminus(FragmentationTerminus? terminus = n PrecursorMassTolerance, DeconvolutionMassTolerance, MaxThreadsToUsePerFile, - new DigestionParams( - DigestionParams.Protease.Name, - DigestionParams.MaxMissedCleavages, - DigestionParams.MinLength, - DigestionParams.MaxLength, - DigestionParams.MaxModificationIsoforms, - DigestionParams.InitiatorMethionineBehavior, - DigestionParams.MaxMods, - DigestionParams.SearchModeType, - terminus.Value //possibly changed - ), + (DigestionParams)DigestionParams.Clone(terminus), ListOfModsVariable, ListOfModsFixed, AssumeOrphanPeaksAreZ1Fragments, diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 6740db347..1f29bcbfa 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 392593033..54798ddd5 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index c7472aefe..fef84664e 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 0279b1ba6..77a806acf 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 05e7eb14d..712489e0f 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From 5eb7cc42fb96c645658ab74f5fe14cc857851681 Mon Sep 17 00:00:00 2001 From: nbollis Date: Mon, 22 Jan 2024 19:49:38 -0600 Subject: [PATCH 16/39] Changed CommonParameters to use IDigestionParameters instead of DigestionParameters. Toml Properties changed to make this work, all tests pass --- MetaMorpheus/EngineLayer/CommonParameters.cs | 6 +- .../CrosslinkSearch/CrosslinkSearchEngine.cs | 21 +-- .../FdrAnalysis/FdrAnalysisEngine.cs | 4 +- .../FdrAnalysis/PEPValueAnalysisGeneric.cs | 2 +- .../GlycoSearch/GlycoSpectralMatch.cs | 2 +- .../EngineLayer/Indexing/IndexingEngine.cs | 16 +- .../NonSpecificEnzymeSearchEngine.cs | 2 +- .../EngineLayer/PeptideSpectralMatch.cs | 2 + .../ProteinParsimonyEngine.cs | 2 +- .../EngineLayer/Silac/SilacConversions.cs | 3 +- MetaMorpheus/EngineLayer/SpectralMatch.cs | 3 +- .../TaskWindows/CalibrateTaskWindow.xaml.cs | 7 +- .../GUI/TaskWindows/GPTMDTaskWindow.xaml.cs | 7 +- .../TaskWindows/GlycoSearchTaskWindow.xaml.cs | 7 +- .../GUI/TaskWindows/SearchTaskWindow.xaml.cs | 157 +++++++++--------- .../TaskWindows/XLSearchTaskWindow.xaml.cs | 8 +- .../FileSpecificParametersWindow.xaml.cs | 3 +- .../CalibrationTask/CalibrationTask.cs | 6 +- MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs | 8 +- .../GlycoSearchTask/GlycoSearchTask.cs | 8 +- .../MbrAnalysis/SpectralRecoveryRunner.cs | 2 +- MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 48 ++++-- MetaMorpheus/TaskLayer/PepXMLWriter.cs | 12 +- .../PostSearchAnalysisParameters.cs | 3 +- .../SearchTask/PostSearchAnalysisTask.cs | 13 +- .../TaskLayer/SearchTask/SearchTask.cs | 7 +- .../TaskLayer/XLSearchTask/WriteFile.cs | 13 +- .../TaskLayer/XLSearchTask/XLSearchTask.cs | 9 +- MetaMorpheus/Test/AnalysisEngineTest.cs | 15 +- MetaMorpheus/Test/BinGenerationTest.cs | 7 +- MetaMorpheus/Test/EventArgsTest.cs | 9 +- MetaMorpheus/Test/FdrTest.cs | 26 +-- MetaMorpheus/Test/GPTMDengineTest.cs | 9 +- MetaMorpheus/Test/LocalizationTest.cs | 9 +- .../Test/MultiProteaseParsimonyTest.cs | 17 +- MetaMorpheus/Test/MyTaskTest.cs | 27 +-- MetaMorpheus/Test/ParameterTest.cs | 4 +- MetaMorpheus/Test/RobTest.cs | 17 +- MetaMorpheus/Test/SearchEngineTests.cs | 15 +- .../SearchWithPeptidesAddedInParsimony.cs | 7 +- MetaMorpheus/Test/SilacTest.cs | 6 +- MetaMorpheus/Test/SpectralRecoveryTest.cs | 7 +- MetaMorpheus/Test/TestDataFile.cs | 7 +- MetaMorpheus/Test/TestPsm.cs | 24 +-- MetaMorpheus/Test/TestToml.cs | 32 ++-- MetaMorpheus/Test/VariantSearchTests.cs | 9 +- MetaMorpheus/Test/XLTest.cs | 3 +- MetaMorpheus/Test/gptmdPrunedBdTests.cs | 21 +-- 48 files changed, 372 insertions(+), 280 deletions(-) diff --git a/MetaMorpheus/EngineLayer/CommonParameters.cs b/MetaMorpheus/EngineLayer/CommonParameters.cs index 194963fe3..3f85332db 100644 --- a/MetaMorpheus/EngineLayer/CommonParameters.cs +++ b/MetaMorpheus/EngineLayer/CommonParameters.cs @@ -5,6 +5,8 @@ using System; using System.Collections.Generic; using System.Reflection; +using Nett; +using Omics.Digestion; using Omics.Fragmentation.Peptide; namespace EngineLayer @@ -46,7 +48,7 @@ public CommonParameters( Tolerance precursorMassTolerance = null, Tolerance deconvolutionMassTolerance = null, int maxThreadsToUsePerFile = -1, - DigestionParams digestionParams = null, + IDigestionParams digestionParams = null, IEnumerable<(string, string)> listOfModsVariable = null, IEnumerable<(string, string)> listOfModsFixed = null, bool assumeOrphanPeaksAreZ1Fragments = true, @@ -132,7 +134,7 @@ public CommonParameters( /// public double PepQValueThreshold { get; private set; } public double ScoreCutoff { get; private set; } - public DigestionParams DigestionParams { get; private set; } + public IDigestionParams DigestionParams { get; private set; } public bool ReportAllAmbiguity { get; private set; } public int? NumberOfPeaksToKeepPerWindow { get; private set; } public double? MinimumAllowedIntensityRatioToBasePeak { get; private set; } diff --git a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs index abfda1a6f..de7021200 100644 --- a/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/CrosslinkSearch/CrosslinkSearchEngine.cs @@ -323,9 +323,10 @@ private void FindCrosslinkedPeptide(Ms2ScanWithSpecificMass scan, List<(double, possibleMatches = new List(); } + var initiatorMethionine = ((DigestionParams)CommonParameters.DigestionParams).InitiatorMethionineBehavior; foreach (var id in idsOfPeptidesPossiblyObserved) { - List possibleCrosslinkLocations = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(AllCrosslinkerSites, PeptideIndex[id], CommonParameters.DigestionParams.InitiatorMethionineBehavior, CleaveAtCrosslinkSite); + List possibleCrosslinkLocations = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(AllCrosslinkerSites, PeptideIndex[id], initiatorMethionine, CleaveAtCrosslinkSite); foreach (var pre in precursors) @@ -422,14 +423,14 @@ private void FindCrosslinkedPeptide(Ms2ScanWithSpecificMass scan, List<(double, { seenPair.Add(key); - List possibleBetaCrosslinkSites = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(AllCrosslinkerSites, NextPeptideIndex[betaMassLowIndex], CommonParameters.DigestionParams.InitiatorMethionineBehavior, CleaveAtCrosslinkSite); + List possibleBetaCrosslinkSites = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(AllCrosslinkerSites, NextPeptideIndex[betaMassLowIndex], initiatorMethionine, CleaveAtCrosslinkSite); if (possibleBetaCrosslinkSites == null) { continue; } - CrosslinkSpectralMatch x = LocalizeCrosslinkSites(scan, id, betaMassLowIndex, Crosslinker, experimentFragmentMasses, intensityRanks); + CrosslinkSpectralMatch x = LocalizeCrosslinkSites(scan, id, betaMassLowIndex, Crosslinker, experimentFragmentMasses, intensityRanks, initiatorMethionine); if (x != null) { @@ -462,7 +463,7 @@ private void FindCrosslinkedPeptide(Ms2ScanWithSpecificMass scan, List<(double, /// /// Localizes the crosslink position on the alpha and beta peptides /// - private CrosslinkSpectralMatch LocalizeCrosslinkSites(Ms2ScanWithSpecificMass theScan, int alphaIndex, int betaIndex, Crosslinker crosslinker, double[] experimentFragmentMasses, int[] intensityRanks) + private CrosslinkSpectralMatch LocalizeCrosslinkSites(Ms2ScanWithSpecificMass theScan, int alphaIndex, int betaIndex, Crosslinker crosslinker, double[] experimentFragmentMasses, int[] intensityRanks, InitiatorMethionineBehavior initiatorMethionineBehavior) { CrosslinkSpectralMatch localizedCrosslinkedSpectralMatch = null; @@ -471,20 +472,20 @@ private CrosslinkSpectralMatch LocalizeCrosslinkSites(Ms2ScanWithSpecificMass th if (crosslinker.CrosslinkerModSites.Equals(crosslinker.CrosslinkerModSites2)) { - List possibleAlphaXlSites = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), PeptideIndex[alphaIndex], CommonParameters.DigestionParams.InitiatorMethionineBehavior, CleaveAtCrosslinkSite); - List possibleBetaXlSites = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), NextPeptideIndex[betaIndex], CommonParameters.DigestionParams.InitiatorMethionineBehavior, CleaveAtCrosslinkSite); + List possibleAlphaXlSites = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), PeptideIndex[alphaIndex], initiatorMethionineBehavior, CleaveAtCrosslinkSite); + List possibleBetaXlSites = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), NextPeptideIndex[betaIndex], initiatorMethionineBehavior, CleaveAtCrosslinkSite); pairs.Add(new Tuple, List>(possibleAlphaXlSites, possibleBetaXlSites)); } else { - List possibleAlphaXlSites =CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), PeptideIndex[alphaIndex], CommonParameters.DigestionParams.InitiatorMethionineBehavior, CleaveAtCrosslinkSite); - List possibleBetaXlSites = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites2.ToCharArray(), NextPeptideIndex[betaIndex], CommonParameters.DigestionParams.InitiatorMethionineBehavior, CleaveAtCrosslinkSite); + List possibleAlphaXlSites =CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), PeptideIndex[alphaIndex], initiatorMethionineBehavior, CleaveAtCrosslinkSite); + List possibleBetaXlSites = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites2.ToCharArray(), NextPeptideIndex[betaIndex], initiatorMethionineBehavior, CleaveAtCrosslinkSite); pairs.Add(new Tuple, List>(possibleAlphaXlSites, possibleBetaXlSites)); - List possibleAlphaXlSites2 = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites2.ToCharArray(), PeptideIndex[alphaIndex], CommonParameters.DigestionParams.InitiatorMethionineBehavior, CleaveAtCrosslinkSite); - List possibleBetaXlSites2 = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), NextPeptideIndex[betaIndex], CommonParameters.DigestionParams.InitiatorMethionineBehavior, CleaveAtCrosslinkSite); + List possibleAlphaXlSites2 = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites2.ToCharArray(), PeptideIndex[alphaIndex], initiatorMethionineBehavior, CleaveAtCrosslinkSite); + List possibleBetaXlSites2 = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), NextPeptideIndex[betaIndex], initiatorMethionineBehavior, CleaveAtCrosslinkSite); pairs.Add(new Tuple, List>(possibleAlphaXlSites2, possibleBetaXlSites2)); } diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs index 563d22cf0..777a22259 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs @@ -49,7 +49,7 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults) if (GlobalVariables.StopLoops) { return; } // calculate FDR on a per-protease basis (targets and decoys for a specific protease) - var psmsGroupedByProtease = AllPsms.GroupBy(p => p.DigestionParams.Protease); + var psmsGroupedByProtease = AllPsms.GroupBy(p => p.DigestionParams.DigestionAgent); foreach (var proteasePsms in psmsGroupedByProtease) { @@ -227,7 +227,7 @@ public void Compute_PEPValue(FdrAnalysisResults myAnalysisResults) if (AllPsms.Count > 100) { string searchType = "standard"; - if (AllPsms[0].DigestionParams.Protease.Name == "top-down") + if (AllPsms[0].DigestionParams.DigestionAgent.Name == "top-down") { searchType = "top-down"; } diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs index 9969e01ed..2bef96d11 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs @@ -788,7 +788,7 @@ public static PsmData CreateOnePsmDataEntry(string searchType, hasSpectralAngle = 1; } - if (psm.DigestionParams.Protease.Name != "top-down") + if (psm.DigestionParams.DigestionAgent.Name != "top-down") { missedCleavages = selectedPeptide.MissedCleavages; bool fileIsCzeSeparationType = fileSpecificParameters.Any(p => Path.GetFileName(p.fileName) == Path.GetFileName(psm.FullFilePath) && p.fileSpecificParameters.SeparationType == "CZE"); diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs index 9855026e1..3645a6c71 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/GlycoSpectralMatch.cs @@ -18,7 +18,7 @@ public enum LocalizationLevel Level3 } - public class GlycoSpectralMatch : SpectralMatch + public class GlycoSpectralMatch : PeptideSpectralMatch { public GlycoSpectralMatch(PeptideWithSetModifications theBestPeptide, int notch, double score, int scanIndex, Ms2ScanWithSpecificMass scan, CommonParameters commonParameters, List matchedFragmentIons) : base(theBestPeptide, notch, score, scanIndex, scan, commonParameters, matchedFragmentIons) diff --git a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs index 5c750f96f..ec51eda00 100644 --- a/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs +++ b/MetaMorpheus/EngineLayer/Indexing/IndexingEngine.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Omics; using Omics.Fragmentation.Peptide; using Omics.Modifications; using UsefulProteomicsDatabases; @@ -68,8 +69,9 @@ public override string ToString() sb.AppendLine("Dissociation Type: " + CommonParameters.DissociationType); sb.AppendLine("Contaminant Handling: " + TcAmbiguity); - sb.AppendLine("protease: " + CommonParameters.DigestionParams.Protease); - sb.AppendLine("initiatorMethionineBehavior: " + CommonParameters.DigestionParams.InitiatorMethionineBehavior); + sb.AppendLine("protease: " + CommonParameters.DigestionParams.DigestionAgent); + if (CommonParameters.DigestionParams is DigestionParams digestionParams) + sb.AppendLine("initiatorMethionineBehavior: " + digestionParams.InitiatorMethionineBehavior); sb.AppendLine("maximumMissedCleavages: " + CommonParameters.DigestionParams.MaxMissedCleavages); sb.AppendLine("minPeptideLength: " + CommonParameters.DigestionParams.MinLength); sb.AppendLine("maxPeptideLength: " + CommonParameters.DigestionParams.MaxLength); @@ -77,7 +79,8 @@ public override string ToString() sb.AppendLine("digestionTerminus: " + CommonParameters.DigestionParams.FragmentationTerminus); sb.AppendLine("maxModsForEachPeptide: " + CommonParameters.DigestionParams.MaxMods); sb.AppendLine("cleavageSpecificity: " + CommonParameters.DigestionParams.SearchModeType); - sb.AppendLine("specificProtease: " + CommonParameters.DigestionParams.SpecificProtease); + if (CommonParameters.DigestionParams is DigestionParams digestionParam) + sb.AppendLine("specificProtease: " + digestionParam.SpecificProtease); sb.AppendLine("maximumFragmentSize" + (int)Math.Round(MaxFragmentSize)); sb.Append("Localizeable mods: " + ProteinList.Select(b => b.OneBasedPossibleLocalizedModifications.Count).Sum()); @@ -92,6 +95,9 @@ protected override MetaMorpheusEngineResults RunSpecific() // digest database List peptides = new List(); + if (CommonParameters.DigestionParams is not DigestionParams digestionParams) + throw new MetaMorpheusException("Digestion parameters must be of type DigestionParams. Not yet implemented for Rna Digestion"); + int maxThreadsPerFile = CommonParameters.MaxThreadsToUsePerFile; int[] threads = Enumerable.Range(0, maxThreadsPerFile).ToArray(); Parallel.ForEach(threads, (i) => @@ -103,7 +109,7 @@ protected override MetaMorpheusEngineResults RunSpecific() // Stop loop if canceled if (GlobalVariables.StopLoops) { return; } - localPeptides.AddRange(ProteinList[i].Digest(CommonParameters.DigestionParams, FixedModifications, VariableModifications, SilacLabels, TurnoverLabels)); + localPeptides.AddRange(ProteinList[i].Digest(digestionParams, FixedModifications, VariableModifications, SilacLabels, TurnoverLabels)); progress++; var percentProgress = (int)((progress / ProteinList.Count) * 100); @@ -130,7 +136,7 @@ protected override MetaMorpheusEngineResults RunSpecific() { precursorIndex = CreateNewPrecursorIndex(peptides); } - bool addInteriorTerminalModsToPrecursorIndex = GeneratePrecursorIndex && CommonParameters.DigestionParams.Protease.Name.Contains("single"); + bool addInteriorTerminalModsToPrecursorIndex = GeneratePrecursorIndex && CommonParameters.DigestionParams.DigestionAgent.Name.Contains("single"); List terminalModifications = addInteriorTerminalModsToPrecursorIndex ? NonSpecificEnzymeSearchEngine.GetVariableTerminalMods(CommonParameters.DigestionParams.FragmentationTerminus, VariableModifications) : null; diff --git a/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs b/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs index a05a5c539..489add9c1 100644 --- a/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs +++ b/MetaMorpheus/EngineLayer/NonSpecificEnzymeSearch/NonSpecificEnzymeSearchEngine.cs @@ -598,7 +598,7 @@ public static List GetVariableTerminalMods(FragmentationTerminus f variableModifications.Where(x => x.LocationRestriction.Contains(terminalStringToFind)).ToList(); } - public static Dictionary> GetTerminalModPositions(PeptideWithSetModifications peptide, DigestionParams digestionParams, List variableMods) + public static Dictionary> GetTerminalModPositions(PeptideWithSetModifications peptide, IDigestionParams digestionParams, List variableMods) { Dictionary> annotatedTerminalModDictionary = new Dictionary>(); bool nTerminus = digestionParams.FragmentationTerminus == FragmentationTerminus.N; //is this the singleN or singleC search? diff --git a/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs b/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs index 89fd15e45..b34b02855 100644 --- a/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs @@ -21,6 +21,8 @@ public PeptideSpectralMatch(IBioPolymerWithSetMods peptide, int notch, double sc } + public new DigestionParams DigestionParams => base.DigestionParams as DigestionParams; + #region Silac /// diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs index d57cc666b..0f679258a 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ProteinParsimonyEngine.cs @@ -96,7 +96,7 @@ private List RunProteinParsimonyEngine() // that have unevenly-shared modifications if (!_treatModPeptidesAsDifferentPeptides) { - foreach (var protease in _fdrFilteredPsms.GroupBy(p => p.DigestionParams.Protease)) + foreach (var protease in _fdrFilteredPsms.GroupBy(p => p.DigestionParams.DigestionAgent)) { Dictionary> sequenceWithPsms = new Dictionary>(); diff --git a/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs b/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs index 42d8cff0d..878e6918c 100644 --- a/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs +++ b/MetaMorpheus/EngineLayer/Silac/SilacConversions.cs @@ -7,6 +7,7 @@ using System.Linq; using Omics.Modifications; using Omics; +using Omics.Digestion; namespace EngineLayer { @@ -303,7 +304,7 @@ public static SpectraFileInfo GetHeavyFileInfo(SpectraFileInfo originalFile, Sil //This light to heavy conversion needs to happen for the flashLFQ peptides here, but can't for the psm peptides, which are constrained to the protein //i.e. pwsms currently don't have sequences; they have start/end residues and a protein sequence. We have to change the output sequences when they're created. public static void SilacConversionsPostQuantification(List allSilacLabels, SilacLabel startLabel, SilacLabel endLabel, - List spectraFileInfo, List proteinGroups, HashSet listOfDigestionParams, FlashLfqResults flashLfqResults, + List spectraFileInfo, List proteinGroups, HashSet listOfDigestionParams, FlashLfqResults flashLfqResults, List allPsms, Dictionary modsToWriteSelection, bool quantifyUnlabeledPeptides) { //do protein quant if we had any results diff --git a/MetaMorpheus/EngineLayer/SpectralMatch.cs b/MetaMorpheus/EngineLayer/SpectralMatch.cs index 2341e12fc..ae6f5ce33 100644 --- a/MetaMorpheus/EngineLayer/SpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/SpectralMatch.cs @@ -11,6 +11,7 @@ using System.Runtime.CompilerServices; using Easy.Common.Extensions; using Omics; +using Omics.Digestion; using Omics.Modifications; using Proteomics.AminoAcidPolymer; using ThermoFisher.CommonCore.Data; @@ -93,7 +94,7 @@ protected SpectralMatch(IBioPolymerWithSetMods peptide, int notch, double score, #region Search - public DigestionParams DigestionParams { get; } + public IDigestionParams DigestionParams { get; } public Dictionary> BioPolymersWithSetModsToMatchingFragments { get; private set; } protected List<(int Notch, IBioPolymerWithSetMods Pwsm)> _BestMatchingBioPolymersWithSetMods; diff --git a/MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs index 5e3d87bad..b3bdb8da0 100644 --- a/MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/CalibrateTaskWindow.xaml.cs @@ -51,14 +51,17 @@ public CalibrateTaskWindow(CalibrationTask myCalibrateTask) private void UpdateFieldsFromTask(CalibrationTask task) { - ProteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; //protease needs to come first or recommended settings can overwrite the actual settings + if (task.CommonParameters.DigestionParams is DigestionParams digestionParams) + { + ProteaseComboBox.SelectedItem = digestionParams.Protease; //protease needs to come first or recommended settings can overwrite the actual settings + InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)digestionParams.InitiatorMethionineBehavior; + } MissedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinLength.ToString(CultureInfo.InvariantCulture); MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxLength.ToString(CultureInfo.InvariantCulture); MaxModsPerPeptideTextBox.Text = task.CommonParameters.DigestionParams.MaxMods.ToString(CultureInfo.InvariantCulture); MaxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); - InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; DissociationTypeComboBox.SelectedItem = task.CommonParameters.DissociationType.ToString(); MaxThreadsTextBox.Text = task.CommonParameters.MaxThreadsToUsePerFile.ToString(CultureInfo.InvariantCulture); MinVariantDepthTextBox.Text = task.CommonParameters.MinVariantDepth.ToString(CultureInfo.InvariantCulture); diff --git a/MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs index 62c42e428..729e27ddd 100644 --- a/MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/GPTMDTaskWindow.xaml.cs @@ -62,7 +62,11 @@ private void Row_DoubleClick(object sender, MouseButtonEventArgs e) private void UpdateFieldsFromTask(GptmdTask task) { - ProteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; //protease needs to come first or recommended settings can overwrite the actual settings + if (task.CommonParameters.DigestionParams is DigestionParams digestionParams) + { + ProteaseComboBox.SelectedItem = digestionParams.Protease; //protease needs to come first or recommended settings can overwrite the actual settings} + InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)digestionParams.InitiatorMethionineBehavior; + } UseProvidedPrecursor.IsChecked = task.CommonParameters.UseProvidedPrecursorInfo; DeconvolutePrecursors.IsChecked = task.CommonParameters.DoPrecursorDeconvolution; DeconvolutionMaxAssumedChargeStateTextBox.Text = task.CommonParameters.DeconvolutionMaxAssumedChargeState.ToString(); @@ -72,7 +76,6 @@ private void UpdateFieldsFromTask(GptmdTask task) MaxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); MaxModsPerPeptideTextBox.Text = task.CommonParameters.DigestionParams.MaxMods.ToString(CultureInfo.InvariantCulture); - InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; DissociationTypeComboBox.SelectedItem = task.CommonParameters.DissociationType.ToString(); ProductMassToleranceTextBox.Text = task.CommonParameters.ProductMassTolerance.Value.ToString(CultureInfo.InvariantCulture); ProductMassToleranceComboBox.SelectedIndex = task.CommonParameters.ProductMassTolerance is AbsoluteTolerance ? 0 : 1; diff --git a/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs index 2af1b19e9..d106e285e 100644 --- a/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/GlycoSearchTaskWindow.xaml.cs @@ -168,10 +168,13 @@ private void UpdateFieldsFromTask(GlycoSearchTask task) missedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinLength.ToString(CultureInfo.InvariantCulture); MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxLength.ToString(CultureInfo.InvariantCulture); - proteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; + if (task.CommonParameters.DigestionParams is DigestionParams digestionParams) + { + proteaseComboBox.SelectedItem = digestionParams.Protease; + initiatorMethionineBehaviorComboBox.SelectedIndex = (int)digestionParams.InitiatorMethionineBehavior; + } maxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); TxtBoxMaxModPerPep.Text = task.CommonParameters.DigestionParams.MaxMods.ToString(CultureInfo.InvariantCulture); - initiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; productMassToleranceTextBox.Text = task.CommonParameters.ProductMassTolerance.Value.ToString(CultureInfo.InvariantCulture); productMassToleranceComboBox.SelectedIndex = task.CommonParameters.ProductMassTolerance is AbsoluteTolerance ? 0 : 1; minScoreAllowed.Text = task.CommonParameters.ScoreCutoff.ToString(CultureInfo.InvariantCulture); diff --git a/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs index f9e292883..22f03fa59 100644 --- a/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/SearchTaskWindow.xaml.cs @@ -165,22 +165,92 @@ private void PopulateChoices() /// private void UpdateFieldsFromTask(SearchTask task) { - ProteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.SpecificProtease; //needs to be first, so nonspecific can override if necessary - ClassicSearchRadioButton.IsChecked = task.SearchParameters.SearchType == SearchType.Classic; - ModernSearchRadioButton.IsChecked = task.SearchParameters.SearchType == SearchType.Modern; - //do these in if statements so as not to trigger the change - if (task.SearchParameters.SearchType == SearchType.NonSpecific && task.CommonParameters.DigestionParams.SearchModeType == CleavageSpecificity.None) + if (task.CommonParameters.DigestionParams is DigestionParams digestionParams) { - NonSpecificSearchRadioButton.IsChecked = true; //when this is changed it overrides the protease - if (task.CommonParameters.DigestionParams.SpecificProtease.Name.Equals("singleC") || task.CommonParameters.DigestionParams.SpecificProtease.Name.Equals("singleN")) + ProteaseComboBox.SelectedItem = digestionParams.SpecificProtease; //needs to be first, so nonspecific can override if necessary + //do these in if statements so as not to trigger the change + if (task.SearchParameters.SearchType == SearchType.NonSpecific && digestionParams.SearchModeType == CleavageSpecificity.None) { - ProteaseComboBox.SelectedItem = ProteaseDictionary.Dictionary["non-specific"]; + NonSpecificSearchRadioButton.IsChecked = true; //when this is changed it overrides the protease + if (digestionParams.SpecificProtease.Name.Equals("singleC") || digestionParams.SpecificProtease.Name.Equals("singleN")) + { + ProteaseComboBox.SelectedItem = ProteaseDictionary.Dictionary["non-specific"]; + } + else + { + ProteaseComboBox.SelectedItem = digestionParams.SpecificProtease; + } } - else + + //If SILAC turnover + if (task.SearchParameters.StartTurnoverLabel != null || task.SearchParameters.EndTurnoverLabel != null) { - ProteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.SpecificProtease; + task.SearchParameters.SilacLabels = null; //reset if between runs + CheckBoxSILAC.IsChecked = true; + var startLabel = task.SearchParameters.StartTurnoverLabel; + if (startLabel != null) + { + SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(startLabel, SilacModificationWindow.ExperimentType.Start); + if (startLabel.AdditionalLabels != null) + { + foreach (SilacLabel additionalLabel in startLabel.AdditionalLabels) + { + infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.Start)); + } + } + StaticSilacLabelsObservableCollection.Add(infoToAdd); + } + else //it's unlabeled for the start condition + { + StaticSilacLabelsObservableCollection.Add(new SilacInfoForDataGrid(SilacModificationWindow.ExperimentType.Start)); + } + var endLabel = task.SearchParameters.EndTurnoverLabel; + if (endLabel != null) + { + SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(endLabel, SilacModificationWindow.ExperimentType.End); + if (endLabel.AdditionalLabels != null) + { + foreach (SilacLabel additionalLabel in endLabel.AdditionalLabels) + { + infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.End)); + } + } + StaticSilacLabelsObservableCollection.Add(infoToAdd); + } + else //it's unlabeled for the end condition + { + StaticSilacLabelsObservableCollection.Add(new SilacInfoForDataGrid(SilacModificationWindow.ExperimentType.End)); + } } + //else if SILAC multiplex + else if (task.SearchParameters.SilacLabels != null && task.SearchParameters.SilacLabels.Count != 0) + { + CheckBoxSILAC.IsChecked = true; + List labels = task.SearchParameters.SilacLabels; + foreach (SilacLabel label in labels) + { + SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(label, SilacModificationWindow.ExperimentType.Multiplex); + if (label.AdditionalLabels != null) + { + foreach (SilacLabel additionalLabel in label.AdditionalLabels) + { + infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.Multiplex)); + } + } + StaticSilacLabelsObservableCollection.Add(infoToAdd); + } + if (digestionParams.GeneratehUnlabeledProteinsForSilac) + { + StaticSilacLabelsObservableCollection.Add(new SilacInfoForDataGrid(SilacModificationWindow.ExperimentType.Multiplex)); + } + } + + CheckBoxQuantifyUnlabeledForSilac.IsChecked = digestionParams.GeneratehUnlabeledProteinsForSilac; + InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)digestionParams.InitiatorMethionineBehavior; } + ClassicSearchRadioButton.IsChecked = task.SearchParameters.SearchType == SearchType.Classic; + ModernSearchRadioButton.IsChecked = task.SearchParameters.SearchType == SearchType.Modern; + if (task.SearchParameters.SearchType == SearchType.NonSpecific && task.CommonParameters.DigestionParams.SearchModeType != CleavageSpecificity.None) { SemiSpecificSearchRadioButton.IsChecked = true; @@ -196,71 +266,7 @@ private void UpdateFieldsFromTask(SearchTask task) { CheckBoxLFQwSpectralRecovery.IsChecked = task.SearchParameters.DoSpectralRecovery; } - //If SILAC turnover - if (task.SearchParameters.StartTurnoverLabel != null || task.SearchParameters.EndTurnoverLabel != null) - { - task.SearchParameters.SilacLabels = null; //reset if between runs - CheckBoxSILAC.IsChecked = true; - var startLabel = task.SearchParameters.StartTurnoverLabel; - if (startLabel != null) - { - SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(startLabel, SilacModificationWindow.ExperimentType.Start); - if (startLabel.AdditionalLabels != null) - { - foreach (SilacLabel additionalLabel in startLabel.AdditionalLabels) - { - infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.Start)); - } - } - StaticSilacLabelsObservableCollection.Add(infoToAdd); - } - else //it's unlabeled for the start condition - { - StaticSilacLabelsObservableCollection.Add(new SilacInfoForDataGrid(SilacModificationWindow.ExperimentType.Start)); - } - var endLabel = task.SearchParameters.EndTurnoverLabel; - if (endLabel != null) - { - SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(endLabel, SilacModificationWindow.ExperimentType.End); - if (endLabel.AdditionalLabels != null) - { - foreach (SilacLabel additionalLabel in endLabel.AdditionalLabels) - { - infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.End)); - } - } - StaticSilacLabelsObservableCollection.Add(infoToAdd); - } - else //it's unlabeled for the end condition - { - StaticSilacLabelsObservableCollection.Add(new SilacInfoForDataGrid(SilacModificationWindow.ExperimentType.End)); - } - } - //else if SILAC multiplex - else if (task.SearchParameters.SilacLabels != null && task.SearchParameters.SilacLabels.Count != 0) - { - CheckBoxSILAC.IsChecked = true; - List labels = task.SearchParameters.SilacLabels; - foreach (SilacLabel label in labels) - { - SilacInfoForDataGrid infoToAdd = new SilacInfoForDataGrid(label, SilacModificationWindow.ExperimentType.Multiplex); - if (label.AdditionalLabels != null) - { - foreach (SilacLabel additionalLabel in label.AdditionalLabels) - { - infoToAdd.AddAdditionalLabel(new SilacInfoForDataGrid(additionalLabel, SilacModificationWindow.ExperimentType.Multiplex)); - } - } - StaticSilacLabelsObservableCollection.Add(infoToAdd); - } - if (task.CommonParameters.DigestionParams.GeneratehUnlabeledProteinsForSilac) - { - StaticSilacLabelsObservableCollection.Add(new SilacInfoForDataGrid(SilacModificationWindow.ExperimentType.Multiplex)); - } - } - - - CheckBoxQuantifyUnlabeledForSilac.IsChecked = task.CommonParameters.DigestionParams.GeneratehUnlabeledProteinsForSilac; + PeakFindingToleranceTextBox.Text = task.SearchParameters.QuantifyPpmTol.ToString(CultureInfo.InvariantCulture); CheckBoxMatchBetweenRuns.IsChecked = task.SearchParameters.MatchBetweenRuns; CheckBoxNormalize.IsChecked = task.SearchParameters.Normalize; @@ -277,7 +283,6 @@ private void UpdateFieldsFromTask(SearchTask task) MaxFragmentMassTextBox.Text = task.SearchParameters.MaxFragmentSize.ToString(CultureInfo.InvariantCulture); //put after max peptide length to allow for override of auto maxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); MaxModNumTextBox.Text = task.CommonParameters.DigestionParams.MaxMods.ToString(CultureInfo.InvariantCulture); - InitiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; DissociationTypeComboBox.SelectedItem = task.CommonParameters.DissociationType.ToString(); SeparationTypeComboBox.SelectedItem = task.CommonParameters.SeparationType.ToString(); NTerminalIons.IsChecked = task.CommonParameters.DigestionParams.FragmentationTerminus == FragmentationTerminus.Both || task.CommonParameters.DigestionParams.FragmentationTerminus == FragmentationTerminus.N; diff --git a/MetaMorpheus/GUI/TaskWindows/XLSearchTaskWindow.xaml.cs b/MetaMorpheus/GUI/TaskWindows/XLSearchTaskWindow.xaml.cs index 1d09c8469..f80ea607f 100644 --- a/MetaMorpheus/GUI/TaskWindows/XLSearchTaskWindow.xaml.cs +++ b/MetaMorpheus/GUI/TaskWindows/XLSearchTaskWindow.xaml.cs @@ -154,15 +154,19 @@ private void UpdateFieldsFromTask(XLSearchTask task) MS3ChildScanDissociationTypeComboBox.SelectedItem = task.CommonParameters.MS3ChildScanDissociationType.ToString(); } + if (task.CommonParameters.DigestionParams is DigestionParams digestionParams) + { + proteaseComboBox.SelectedItem = digestionParams.Protease; + initiatorMethionineBehaviorComboBox.SelectedIndex = (int)digestionParams.InitiatorMethionineBehavior; + } + checkBoxDecoy.IsChecked = task.XlSearchParameters.DecoyType != DecoyType.None; deconvolutePrecursors.IsChecked = task.CommonParameters.DoPrecursorDeconvolution; useProvidedPrecursor.IsChecked = task.CommonParameters.UseProvidedPrecursorInfo; missedCleavagesTextBox.Text = task.CommonParameters.DigestionParams.MaxMissedCleavages.ToString(CultureInfo.InvariantCulture); MinPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MinLength.ToString(CultureInfo.InvariantCulture); MaxPeptideLengthTextBox.Text = task.CommonParameters.DigestionParams.MaxLength == int.MaxValue ? "" : task.CommonParameters.DigestionParams.MaxLength.ToString(CultureInfo.InvariantCulture); - proteaseComboBox.SelectedItem = task.CommonParameters.DigestionParams.Protease; maxModificationIsoformsTextBox.Text = task.CommonParameters.DigestionParams.MaxModificationIsoforms.ToString(CultureInfo.InvariantCulture); - initiatorMethionineBehaviorComboBox.SelectedIndex = (int)task.CommonParameters.DigestionParams.InitiatorMethionineBehavior; productMassToleranceTextBox.Text = task.CommonParameters.ProductMassTolerance.Value.ToString(CultureInfo.InvariantCulture); productMassToleranceComboBox.SelectedIndex = task.CommonParameters.ProductMassTolerance is AbsoluteTolerance ? 0 : 1; minScoreAllowed.Text = task.CommonParameters.ScoreCutoff.ToString(CultureInfo.InvariantCulture); diff --git a/MetaMorpheus/GUI/Views/FileSpecificParametersWindow.xaml.cs b/MetaMorpheus/GUI/Views/FileSpecificParametersWindow.xaml.cs index 74bb899f5..9612caa7d 100644 --- a/MetaMorpheus/GUI/Views/FileSpecificParametersWindow.xaml.cs +++ b/MetaMorpheus/GUI/Views/FileSpecificParametersWindow.xaml.cs @@ -12,6 +12,7 @@ using System.Globalization; using System.Windows.Media; using MassSpectrometry; +using Omics.Digestion; namespace MetaMorpheusGUI { @@ -207,7 +208,7 @@ private void PopulateChoices() { // use default settings to populate var defaultParams = new CommonParameters(); - Protease tempProtease = defaultParams.DigestionParams.Protease; + DigestionAgent tempProtease = defaultParams.DigestionParams.DigestionAgent; int tempMinPeptideLength = defaultParams.DigestionParams.MinLength; int tempMaxPeptideLength = defaultParams.DigestionParams.MaxLength; int tempMaxMissedCleavages = defaultParams.DigestionParams.MaxMissedCleavages; diff --git a/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs b/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs index 1da9a9e70..0a33770be 100644 --- a/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs +++ b/MetaMorpheus/TaskLayer/CalibrationTask/CalibrationTask.cs @@ -15,6 +15,7 @@ using Omics.Modifications; using Readers; using UsefulProteomicsDatabases; +using Proteomics.ProteolyticDigestion; namespace TaskLayer { @@ -43,13 +44,14 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; "); _ = ProseCreatedWhileRunning.Append("variable modifications = " + string.Join(", ", variableModifications.Select(m => m.IdWithMotif)) + "; "); _ = ProseCreatedWhileRunning.Append("max mods per peptide = " + CommonParameters.DigestionParams.MaxMods + "; "); diff --git a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs index 8f34924b4..175a6ddac 100644 --- a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs +++ b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs @@ -12,6 +12,7 @@ using UsefulProteomicsDatabases; using Proteomics.ProteolyticDigestion; using System.Globalization; +using Omics.Digestion; using Omics.Modifications; namespace TaskLayer @@ -44,13 +45,14 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; "); ProseCreatedWhileRunning.Append("variable modifications = " + string.Join(", ", variableModifications.Select(m => m.IdWithMotif)) + "; "); @@ -71,7 +73,7 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List() }; var fileSpecificCommonParams = fileSettingsList.Select(b => SetAllFileSpecificCommonParams(CommonParameters, b)); - HashSet ListOfDigestionParams = new HashSet(fileSpecificCommonParams.Select(p => p.DigestionParams)); + var ListOfDigestionParams = new HashSet(fileSpecificCommonParams.Select(p => p.DigestionParams)); MyFileManager myFileManager = new MyFileManager(true); diff --git a/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoSearchTask.cs b/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoSearchTask.cs index 1c68667bf..dbd42a848 100644 --- a/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoSearchTask.cs +++ b/MetaMorpheus/TaskLayer/GlycoSearchTask/GlycoSearchTask.cs @@ -12,6 +12,7 @@ using EngineLayer.FdrAnalysis; using System; using FlashLFQ; +using Omics; using UsefulProteomicsDatabases; namespace TaskLayer @@ -59,13 +60,14 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; \n"); ProseCreatedWhileRunning.Append("variable modifications = " + string.Join(", ", variableModifications.Select(m => m.IdWithMotif)) + "; \n"); @@ -204,7 +206,7 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List(fileSpecificCommonParams.Select(p => p.DigestionParams)), + ListOfDigestionParams = new HashSet(fileSpecificCommonParams.Select(p => (DigestionParams)p.DigestionParams)), ProteinList = proteinList, VariableModifications = variableModifications, FixedModifications = fixedModifications, diff --git a/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryRunner.cs b/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryRunner.cs index d098271ae..0a8751885 100644 --- a/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryRunner.cs +++ b/MetaMorpheus/TaskLayer/MbrAnalysis/SpectralRecoveryRunner.cs @@ -226,7 +226,7 @@ private static void FDRAnalysisOfMbrPsms(ConcurrentDictionary[] PSMDataGroups = new IEnumerable[1]; string searchType = "standard"; - if (psms[0].DigestionParams.Protease.Name == "top-down") + if (psms[0].DigestionParams.DigestionAgent.Name == "top-down") { searchType = "top-down"; } diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index 5abf4eb60..a0386014b 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -18,6 +18,8 @@ using System.Reflection.Metadata.Ecma335; using System.Text; using System.Threading.Tasks; +using Omics; +using Omics.Digestion; using Omics.Fragmentation; using Omics.Fragmentation.Peptide; using Omics.Modifications; @@ -72,7 +74,13 @@ public abstract class MetaMorpheusTask .IgnoreProperty(p => p.MaxMods) .IgnoreProperty(p => p.MaxLength) .IgnoreProperty(p => p.MinLength)) + + .ConfigureType(type => type + .WithConversionFor(c => c + .FromToml(tmlTable => tmlTable.ContainsKey("Protease") ? tmlTable.Get() : throw new NotImplementedException("Placeholder for Rna Digestion Params")))) + ); + protected readonly StringBuilder ProseCreatedWhileRunning = new StringBuilder(); @@ -396,24 +404,36 @@ public static CommonParameters SetAllFileSpecificCommonParams(CommonParameters c } // set file-specific digestion parameters - Protease protease = fileSpecificParams.Protease ?? commonParams.DigestionParams.SpecificProtease; //set to specific for nonspecific searches to update int minPeptideLength = fileSpecificParams.MinPeptideLength ?? commonParams.DigestionParams.MinLength; int maxPeptideLength = fileSpecificParams.MaxPeptideLength ?? commonParams.DigestionParams.MaxLength; int maxMissedCleavages = fileSpecificParams.MaxMissedCleavages ?? commonParams.DigestionParams.MaxMissedCleavages; int maxModsForPeptide = fileSpecificParams.MaxModsForPeptide ?? commonParams.DigestionParams.MaxMods; - DigestionParams fileSpecificDigestionParams = new DigestionParams( - protease: protease.Name, - maxMissedCleavages: maxMissedCleavages, - minPeptideLength: minPeptideLength, - maxPeptideLength: maxPeptideLength, - maxModsForPeptides: maxModsForPeptide, - //NEED THESE OR THEY'LL BE OVERWRITTEN - maxModificationIsoforms: commonParams.DigestionParams.MaxModificationIsoforms, - initiatorMethionineBehavior: commonParams.DigestionParams.InitiatorMethionineBehavior, - fragmentationTerminus: commonParams.DigestionParams.FragmentationTerminus, - searchModeType: commonParams.DigestionParams.SearchModeType + IDigestionParams fileSpecificDigestionParams; + if (commonParams.DigestionParams is DigestionParams digestionParams) + { + DigestionAgent + protease = fileSpecificParams.Protease ?? + digestionParams.SpecificProtease; //set to specific for nonspecific searches to update + fileSpecificDigestionParams = new DigestionParams( + protease: protease.Name, + maxMissedCleavages: maxMissedCleavages, + minPeptideLength: minPeptideLength, + maxPeptideLength: maxPeptideLength, + maxModsForPeptides: maxModsForPeptide, + + //NEED THESE OR THEY'LL BE OVERWRITTEN + maxModificationIsoforms: digestionParams.MaxModificationIsoforms, + initiatorMethionineBehavior: digestionParams.InitiatorMethionineBehavior, + fragmentationTerminus: digestionParams.FragmentationTerminus, + searchModeType: digestionParams.SearchModeType ); + } + else // Placeholder for when we add RNA digestion + throw new NotImplementedException(); + + + // set the rest of the file-specific parameters Tolerance precursorMassTolerance = fileSpecificParams.PrecursorMassTolerance ?? commonParams.PrecursorMassTolerance; @@ -1077,8 +1097,8 @@ public static void DetermineAnalyteType(CommonParameters commonParameters) if (commonParameters != null && commonParameters.DigestionParams != null - && commonParameters.DigestionParams.Protease != null - && commonParameters.DigestionParams.Protease.Name == "top-down") + && commonParameters.DigestionParams is DigestionParams { Protease: not null } + && commonParameters.DigestionParams.DigestionAgent.Name == "top-down") { GlobalVariables.AnalyteType = "Proteoform"; } diff --git a/MetaMorpheus/TaskLayer/PepXMLWriter.cs b/MetaMorpheus/TaskLayer/PepXMLWriter.cs index c66bd2eb2..69a4ddba8 100644 --- a/MetaMorpheus/TaskLayer/PepXMLWriter.cs +++ b/MetaMorpheus/TaskLayer/PepXMLWriter.cs @@ -27,8 +27,8 @@ public static void WritePepXml(List psms, List databas _pepxml.date = DateTime.Now; _pepxml.summary_xml = psms[0].FullFilePath + ".pep.XML"; - string proteaseNC = string.Join(string.Empty, CommonParameters.DigestionParams.Protease.DigestionMotifs.Select(m => m.InducingCleavage)); - string proteaseC = string.Join(string.Empty, CommonParameters.DigestionParams.Protease.DigestionMotifs.Select(m => m.InducingCleavage)); + string proteaseNC = string.Join(string.Empty, CommonParameters.DigestionParams.DigestionAgent.DigestionMotifs.Select(m => m.InducingCleavage)); + string proteaseC = string.Join(string.Empty, CommonParameters.DigestionParams.DigestionAgent.DigestionMotifs.Select(m => m.InducingCleavage)); string fileNameNoExtension = Path.GetFileNameWithoutExtension(psms[0].FullFilePath); string filePathNoExtension = Path.ChangeExtension(psms[0].FullFilePath, null); @@ -40,8 +40,8 @@ public static void WritePepXml(List psms, List databas para.Add(new pepXML.Generated.nameValueType { name = "MS_data_file", value = psms[0].FullFilePath }); para.Add(new pepXML.Generated.nameValueType { name = "MaxMissed Cleavages", value = CommonParameters.DigestionParams.MaxMissedCleavages.ToString() }); - para.Add(new pepXML.Generated.nameValueType { name = "Protease", value = CommonParameters.DigestionParams.Protease.Name }); - para.Add(new pepXML.Generated.nameValueType { name = "Initiator Methionine", value = CommonParameters.DigestionParams.InitiatorMethionineBehavior.ToString() }); + para.Add(new pepXML.Generated.nameValueType { name = "Protease", value = CommonParameters.DigestionParams.DigestionAgent.Name }); + para.Add(new pepXML.Generated.nameValueType { name = "Initiator Methionine", value = ((DigestionParams)CommonParameters.DigestionParams).InitiatorMethionineBehavior.ToString() }); para.Add(new pepXML.Generated.nameValueType { name = "Max Modification Isoforms", value = CommonParameters.DigestionParams.MaxModificationIsoforms.ToString() }); para.Add(new pepXML.Generated.nameValueType { name = "Min Peptide Len", value = CommonParameters.DigestionParams.MinLength.ToString() }); para.Add(new pepXML.Generated.nameValueType { name = "Max Peptide Len", value = CommonParameters.DigestionParams.MaxLength.ToString() }); @@ -71,7 +71,7 @@ public static void WritePepXml(List psms, List databas raw_data = ".mzML", //TODO: use file format of spectra file used sample_enzyme = new pepXML.Generated.msms_pipeline_analysisMsms_run_summarySample_enzyme() { - name = CommonParameters.DigestionParams.Protease.Name, + name = CommonParameters.DigestionParams.DigestionAgent.Name, specificity = new pepXML.Generated.msms_pipeline_analysisMsms_run_summarySample_enzymeSpecificity[1] { new pepXML.Generated.msms_pipeline_analysisMsms_run_summarySample_enzymeSpecificity @@ -103,7 +103,7 @@ public static void WritePepXml(List psms, List databas }, enzymatic_search_constraint = new pepXML.Generated.msms_pipeline_analysisMsms_run_summarySearch_summaryEnzymatic_search_constraint { - enzyme = CommonParameters.DigestionParams.Protease.Name, + enzyme = CommonParameters.DigestionParams.DigestionAgent.Name, max_num_internal_cleavages = CommonParameters.DigestionParams.MaxMissedCleavages.ToString(), }, diff --git a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs index 58a0dafda..31fad5909 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisParameters.cs @@ -3,6 +3,7 @@ using Proteomics; using Proteomics.ProteolyticDigestion; using System.Collections.Generic; +using Omics.Digestion; using Omics.Modifications; namespace TaskLayer @@ -16,7 +17,7 @@ public class PostSearchAnalysisParameters public List VariableModifications { get; set; } public List FixedModifications { get; set; } public Modification MultiplexModification { get; set; } - public HashSet ListOfDigestionParams { get; set; } + public HashSet ListOfDigestionParams { get; set; } public List AllPsms { get; set; } public FlashLfqResults FlashLfqResults { get; set; } public int NumNotches { get; set; } diff --git a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs index 5c5fe3747..9c6717e8a 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/PostSearchAnalysisTask.cs @@ -22,6 +22,7 @@ using MzLibUtil; using Proteomics.AminoAcidPolymer; using System.Text.Json.Serialization; +using Omics.Digestion; using Omics.Modifications; namespace TaskLayer @@ -420,7 +421,7 @@ private void QuantificationAnalysis() List allSilacLabels = Parameters.SearchParameters.SilacLabels; SilacLabel startLabel = Parameters.SearchParameters.StartTurnoverLabel; SilacLabel endLabel = Parameters.SearchParameters.EndTurnoverLabel; - bool quantifyUnlabeledPeptides = Parameters.ListOfDigestionParams.Any(x => x.GeneratehUnlabeledProteinsForSilac); + bool quantifyUnlabeledPeptides = Parameters.ListOfDigestionParams.Any(x => x is DigestionParams { GeneratehUnlabeledProteinsForSilac: true }); if (Parameters.SearchParameters.SilacLabels != null) { bool turnoverWithMultipleLabels = startLabel != null && endLabel != null; //used to check multiple labels @@ -547,8 +548,8 @@ private void QuantificationAnalysis() // the peptides should still be quantified but not considered for protein quantification var undefinedPg = new FlashLFQ.ProteinGroup("UNDEFINED", "", ""); //sort the unambiguous psms by protease to make MBR compatible with multiple proteases - Dictionary> proteaseSortedPsms = new Dictionary>(); - Dictionary proteaseSortedFlashLFQResults = new Dictionary(); + Dictionary> proteaseSortedPsms = new Dictionary>(); + Dictionary proteaseSortedFlashLFQResults = new Dictionary(); foreach (DigestionParams dp in Parameters.ListOfDigestionParams) { @@ -564,7 +565,7 @@ private void QuantificationAnalysis() psmToProteinGroups.Add(psm, new List { undefinedPg }); } - proteaseSortedPsms[psm.DigestionParams.Protease].Add(psm); + proteaseSortedPsms[psm.DigestionParams.DigestionAgent].Add(psm); } // pass PSM info to FlashLFQ @@ -957,7 +958,7 @@ private void WriteProteinResults() Parameters.VariableModifications, Parameters.FixedModifications, Parameters.SearchParameters.SilacLabels, - new List { CommonParameters.DigestionParams.Protease }, + new List { ((DigestionParams)CommonParameters.DigestionParams).Protease }, CommonParameters.ProductMassTolerance, CommonParameters.PrecursorMassTolerance, CommonParameters.DigestionParams.MaxMissedCleavages, @@ -1849,7 +1850,7 @@ private static void WritePsmsForPercolator(List psmList, string w using (StreamWriter output = new StreamWriter(writtenFileForPercolator)) { string searchType; - if (psmList.Where(p => p != null).Any() && psmList[0].DigestionParams.Protease.Name != null && psmList[0].DigestionParams.Protease.Name == "top-down") + if (psmList.Where(p => p != null).Any() && psmList[0].DigestionParams.DigestionAgent.Name != null && psmList[0].DigestionParams.DigestionAgent.Name == "top-down") { searchType = "top-down"; } diff --git a/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs b/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs index d1c220704..e3e11b1ba 100644 --- a/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs +++ b/MetaMorpheus/TaskLayer/SearchTask/SearchTask.cs @@ -147,14 +147,15 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; "); ProseCreatedWhileRunning.Append("variable modifications = " + string.Join(", ", variableModifications.Select(m => m.IdWithMotif)) + "; "); ProseCreatedWhileRunning.Append("max mods per peptide = " + CommonParameters.DigestionParams.MaxMods + "; "); @@ -388,7 +389,7 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List(fileSpecificCommonParams.Select(p => p.DigestionParams)), + ListOfDigestionParams = new HashSet(fileSpecificCommonParams.Select(p => p.DigestionParams)), CurrentRawFileList = currentRawFileList, MyFileManager = myFileManager, NumNotches = numNotches, diff --git a/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs b/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs index c4c48a157..5e83ad6f8 100644 --- a/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs +++ b/MetaMorpheus/TaskLayer/XLSearchTask/WriteFile.cs @@ -12,6 +12,7 @@ using Easy.Common.Extensions; using Omics.Fragmentation.Peptide; using Omics.Modifications; +using Proteomics.ProteolyticDigestion; namespace TaskLayer { @@ -102,8 +103,8 @@ public static void WritePepXML_xl(List items, List m.InducingCleavage)) { proteaseC += x; } - foreach (var x in CommonParameters.DigestionParams.Protease.DigestionMotifs.Select(m => m.PreventingCleavage)) { proteaseNC += x; } + foreach (var x in CommonParameters.DigestionParams.DigestionAgent.DigestionMotifs.Select(m => m.InducingCleavage)) { proteaseC += x; } + foreach (var x in CommonParameters.DigestionParams.DigestionAgent.DigestionMotifs.Select(m => m.PreventingCleavage)) { proteaseNC += x; } Crosslinker crosslinker = XlSearchParameters.Crosslinker; @@ -126,8 +127,8 @@ public static void WritePepXML_xl(List items, List items, List items, List SetAllFileSpecificCommonParams(CommonParameters, b)); - HashSet ListOfDigestionParams = new HashSet(fileSpecificCommonParams.Select(p => p.DigestionParams)); + var ListOfDigestionParams = new HashSet(fileSpecificCommonParams.Select(p => p.DigestionParams)); int completedFiles = 0; object indexLock = new object(); @@ -66,13 +68,14 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List m.IdWithMotif)) + "; "); diff --git a/MetaMorpheus/Test/AnalysisEngineTest.cs b/MetaMorpheus/Test/AnalysisEngineTest.cs index 548cedb1e..109b7f763 100644 --- a/MetaMorpheus/Test/AnalysisEngineTest.cs +++ b/MetaMorpheus/Test/AnalysisEngineTest.cs @@ -13,6 +13,7 @@ using Omics.Digestion; using Omics.Modifications; using TaskLayer; +using Omics; namespace Test { @@ -57,19 +58,19 @@ public static void TestAnalysisEngineTests() var proteinList = new List { new Protein("MNNNKQQQ", "accession") }; var modPep = proteinList.First().Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).Last(); - HashSet value1 = new HashSet { modPep }; - PeptideWithSetModifications compactPeptide1 = value1.First(); + HashSet value1 = new HashSet { modPep }; + var compactPeptide1 = value1.First(); Assert.AreEqual("QQQ", value1.First().BaseSequence); var modPep2 = proteinList.First().Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).First(); - HashSet value2 = new HashSet { modPep2 }; - PeptideWithSetModifications compactPeptide2 = value2.First(); + HashSet value2 = new HashSet { modPep2 }; + var compactPeptide2 = value2.First(); Assert.AreEqual("MNNNK", value2.First().BaseSequence); var modPep3 = proteinList.First().Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[1]; - HashSet value3 = new HashSet { modPep3 }; - PeptideWithSetModifications compactPeptide3 = value3.First(); + HashSet value3 = new HashSet { modPep3 }; + var compactPeptide3 = value3.First(); Assert.AreEqual("NNNK", value3.First().BaseSequence); @@ -83,7 +84,7 @@ public static void TestAnalysisEngineTests() var newPsms = new List { matchA, matchB, matchC }; - MsDataFile myMsDataFile = new TestDataFile(new List { value1.First(), value2.First(), value3.First() }); + MsDataFile myMsDataFile = new TestDataFile(new List { value1.First(), value2.First(), value3.First() }); var searchMode = new SinglePpmAroundZeroSearchMode(5); Action, string, List> action2 = (List l, string s, List sdf) => {; }; diff --git a/MetaMorpheus/Test/BinGenerationTest.cs b/MetaMorpheus/Test/BinGenerationTest.cs index 47cde2c42..2a9992d8e 100644 --- a/MetaMorpheus/Test/BinGenerationTest.cs +++ b/MetaMorpheus/Test/BinGenerationTest.cs @@ -10,6 +10,7 @@ using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; +using Omics; namespace Test { @@ -53,7 +54,7 @@ public static void TestBinGeneration() Protein prot4 = new Protein("MNNDNNNN", "prot4"); var pep3_10 = prot4.Digest(st.CommonParameters.DigestionParams, new List(), new List { mod }).Last(); - List pepsWithSetMods = new List { pep1_0, pep1_10, pep2_0, pep2_10, pep3_10 }; + var pepsWithSetMods = new List { pep1_0, pep1_10, pep2_0, pep2_10, pep3_10 }; MsDataFile myMsDataFile = new TestDataFile(pepsWithSetMods); List proteinList = new List { prot1, prot2, prot3, prot4 }; @@ -114,8 +115,8 @@ public static void TestProteinSplitAcrossFiles() var pep1 = prot1.Digest(st.CommonParameters.DigestionParams, new List(), new List()).First(); var pep2 = prot1.Digest(st.CommonParameters.DigestionParams, new List(), new List()).Last(); - List listForFile1 = new List { pep1, pep2 }; - List listForFile2 = new List { pep2 }; + var listForFile1 = new List { pep1, pep2 }; + var listForFile2 = new List { pep2 }; MsDataFile myMsDataFile1 = new TestDataFile(listForFile1); MsDataFile myMsDataFile2 = new TestDataFile(listForFile2); diff --git a/MetaMorpheus/Test/EventArgsTest.cs b/MetaMorpheus/Test/EventArgsTest.cs index 9a489d430..16ef0261b 100644 --- a/MetaMorpheus/Test/EventArgsTest.cs +++ b/MetaMorpheus/Test/EventArgsTest.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Text; using Omics.Modifications; +using Omics; namespace Test { @@ -30,12 +31,12 @@ public static void SingleEventArgsTest() ModificationMotif.TryGetMotif("E", out ModificationMotif motif); List variableModifications = new List { new Modification(_originalId: "21", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943) }; - List allPeptidesWithSetModifications = parentProteinForMatch.Digest(commonParameters.DigestionParams, new List(), variableModifications).ToList(); + var allPeptidesWithSetModifications = parentProteinForMatch.Digest(commonParameters.DigestionParams, new List(), variableModifications).ToList(); Assert.AreEqual(4, allPeptidesWithSetModifications.Count()); - PeptideWithSetModifications ps = allPeptidesWithSetModifications.First(); + var ps = allPeptidesWithSetModifications.First(); - PeptideWithSetModifications pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1]; - MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetModsForSpectrum }); + var pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1]; + MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetModsForSpectrum }); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(myMsDataFile.GetAllScansList().Last(), pepWithSetModsForSpectrum.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); diff --git a/MetaMorpheus/Test/FdrTest.cs b/MetaMorpheus/Test/FdrTest.cs index 489cf247e..c8ec26d35 100644 --- a/MetaMorpheus/Test/FdrTest.cs +++ b/MetaMorpheus/Test/FdrTest.cs @@ -57,12 +57,12 @@ public static void FdrTestMethod() var digested = p.Digest(commonParameters.DigestionParams, new List(), new List()).ToList(); - PeptideWithSetModifications pep1 = digested[0]; - PeptideWithSetModifications pep2 = digested[1]; - PeptideWithSetModifications pep3 = digested[2]; - PeptideWithSetModifications pep4 = digested[3]; + var pep1 = digested[0]; + var pep2 = digested[1]; + var pep3 = digested[2]; + var pep4 = digested[3]; - TestDataFile t = new TestDataFile(new List { pep1, pep2, pep3 }); + TestDataFile t = new TestDataFile(new List { pep1, pep2, pep3 }); MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, pep1.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); @@ -117,12 +117,12 @@ public static void FdrAnalysisEngineFileSpecificParametersNotNull() var digested = p.Digest(commonParameters.DigestionParams, new List(), new List()).ToList(); - PeptideWithSetModifications pep1 = digested[0]; - PeptideWithSetModifications pep2 = digested[1]; - PeptideWithSetModifications pep3 = digested[2]; - PeptideWithSetModifications pep4 = digested[3]; + var pep1 = digested[0]; + var pep2 = digested[1]; + var pep3 = digested[2]; + var pep4 = digested[3]; - TestDataFile t = new TestDataFile(new List { pep1, pep2, pep3 }); + TestDataFile t = new TestDataFile(new List { pep1, pep2, pep3 }); MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, pep1.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); @@ -168,7 +168,7 @@ public static void TestDeltaValues() Protein TargetProteinLost = new Protein("PEPTIDEANTHE", "accession4"); Protein DecoyProteinFound = new Protein("PETPLEDQGTHE", "accessiond", isDecoy: true); - MsDataFile myMsDataFile = new TestDataFile(new List + MsDataFile myMsDataFile = new TestDataFile(new List { TargetProtein1.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein2.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], @@ -217,7 +217,7 @@ public static void TestDeltaValues() Protein DecoyProtein3 = new Protein("TLEDNIE", "accession3d", isDecoy: true); Protein DecoyProteinShiny = new Protein("GGGGGG", "accessionShinyd", isDecoy: true); - myMsDataFile = new TestDataFile(new List + myMsDataFile = new TestDataFile(new List { TargetProtein1.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein2.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], @@ -378,7 +378,7 @@ public static void TestComputePEPValue() var anMzSpectrum = new MzSpectrum(new double[] { 1, 1 }, new double[] { 2, 2 }, true); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(new MsDataScan(anMzSpectrum, 1, 1, true, Polarity.Negative, 2, null, "", MZAnalyzerType.Orbitrap, 2, null, null, null), 1, 1, "path", new CommonParameters()); Protein variantProtein = new Protein("MPEPPPTIDE", "protein3", sequenceVariations: new List { new SequenceVariation(4, 6, "PPP", "P", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }); - PeptideWithSetModifications varPep = variantProtein.GetVariantProteins().SelectMany(p => p.Digest(CommonParameters.DigestionParams, null, null)).FirstOrDefault(); + IBioPolymerWithSetMods varPep = variantProtein.GetVariantProteins().SelectMany(p => p.Digest(CommonParameters.DigestionParams, null, null)).FirstOrDefault(); Product prod = new Product(ProductType.b, FragmentationTerminus.N, 1, 1, 1, 0); List mfi = new List { new MatchedFragmentIon(prod, 1, 1.0, 1) }; diff --git a/MetaMorpheus/Test/GPTMDengineTest.cs b/MetaMorpheus/Test/GPTMDengineTest.cs index 622d1f25f..e019c6ba8 100644 --- a/MetaMorpheus/Test/GPTMDengineTest.cs +++ b/MetaMorpheus/Test/GPTMDengineTest.cs @@ -13,6 +13,7 @@ using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; +using Omics; namespace Test { @@ -49,7 +50,7 @@ public static void TestGptmdEngine(string proteinSequence, string accession, str //PsmParent newPsm = new TestParentSpectrumMatch(588.22520189093 + 21.981943); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null), (new Proteomics.AminoAcidPolymer.Peptide(modPep.BaseSequence).MonoisotopicMass + 21.981943).ToMz(1), 1, "filepath", new CommonParameters()); - var peptidesWithSetModifications = new List { modPep }; + var peptidesWithSetModifications = new List { modPep }; SpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, commonParameters, new List()); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); @@ -87,7 +88,7 @@ public static void TestCombos(string proteinSequence, string accession, string v MsDataScan dfd = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfd, (new Proteomics.AminoAcidPolymer.Peptide(modPep.BaseSequence).MonoisotopicMass + 21.981943 + 15.994915).ToMz(1), 1, "filepath", new CommonParameters()); - var peptidesWithSetModifications = new List { modPep }; + var peptidesWithSetModifications = new List { modPep }; SpectralMatch match = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, commonParameters, new List()); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); @@ -181,11 +182,11 @@ public static void TestSearchPtmVariantDatabase() Assert.AreEqual(4, digestedList.Count); //Set Peptide with 1 mod at position 3 - PeptideWithSetModifications pepWithSetMods1 = digestedList[1]; + var pepWithSetMods1 = digestedList[1]; //Finally Write MZML file Assert.AreEqual("PEK[type:acetyl on K]TID", pepWithSetMods1.FullSequence);//this might be base sequence - MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1 }); + MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1 }); string mzmlName = @"hello.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); diff --git a/MetaMorpheus/Test/LocalizationTest.cs b/MetaMorpheus/Test/LocalizationTest.cs index 4df8a6c79..efb79687b 100644 --- a/MetaMorpheus/Test/LocalizationTest.cs +++ b/MetaMorpheus/Test/LocalizationTest.cs @@ -9,6 +9,7 @@ using Proteomics.ProteolyticDigestion; using System.Collections.Generic; using System.Linq; +using Omics; using Omics.Modifications; namespace Test @@ -38,12 +39,12 @@ public static void TestLocalization() ModificationMotif.TryGetMotif("E", out ModificationMotif motif); List variableModifications = new List { new Modification(_originalId: "21", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943) }; - List allPeptidesWithSetModifications = parentProteinForMatch.Digest(commonParameters.DigestionParams, new List(), variableModifications).ToList(); + List allPeptidesWithSetModifications = parentProteinForMatch.Digest(commonParameters.DigestionParams, new List(), variableModifications).ToList(); Assert.AreEqual(4, allPeptidesWithSetModifications.Count()); - PeptideWithSetModifications ps = allPeptidesWithSetModifications.First(); + var ps = allPeptidesWithSetModifications.First(); - PeptideWithSetModifications pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1]; - MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetModsForSpectrum }); + var pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1]; + MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetModsForSpectrum }); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(myMsDataFile.GetAllScansList().Last(), pepWithSetModsForSpectrum.MonoisotopicMass.ToMz(1), 1, null, new CommonParameters()); diff --git a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs index 5865d0a67..d1a0fd1e3 100644 --- a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs +++ b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs @@ -12,6 +12,7 @@ using Omics.Digestion; using Omics.Modifications; using TaskLayer; +using Omics; namespace Test { @@ -63,7 +64,7 @@ public static void MultiProteaseTest() psms.ForEach(j => j.ResolveAllAmbiguities()); psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); - HashSet digestionParamsList = new HashSet(); + var digestionParamsList = new HashSet(); digestionParamsList.Add(commonParameters_Tryp.DigestionParams); digestionParamsList.Add(commonParameters_ArgC.DigestionParams); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); @@ -151,7 +152,7 @@ public static void MultiProteaseSamePeptideSameProteinsDifferentProteases() psms.ForEach(p => p.ResolveAllAmbiguities()); psms.ForEach(p => p.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); - HashSet digestionParamsList = new HashSet(); + var digestionParamsList = new HashSet(); digestionParamsList.Add(commonParameters1.DigestionParams); digestionParamsList.Add(commonParameters2.DigestionParams); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); @@ -229,7 +230,7 @@ public static void MultiProteaseParsimony_SharedSequenceCanBeUniquePeptide() psms.ForEach(p => p.ResolveAllAmbiguities()); psms.ForEach(p => p.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); - HashSet digestionParamsList = new HashSet(); + var digestionParamsList = new HashSet(); digestionParamsList.Add(commonParameters.DigestionParams); digestionParamsList.Add(commonParameters2.DigestionParams); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); @@ -541,7 +542,7 @@ public static void MultiProteaseParsimony_BaseSequenceCanBeSharedOrUniqueButOnly var protease2 = new Protease("test4", CleavageSpecificity.Full, null, null, motifs2); ProteaseDictionary.Dictionary.Add(protease2.Name, protease2); - var peptideList = new List(); + var peptideList = new List(); var p = new List(); List> gn = new List>(); for (int i = 0; i < sequences.Length; i++) @@ -613,7 +614,7 @@ public static void TestPSMFdrFiltering_Simulated() ProteaseDictionary.Dictionary.Add(protease1.Name, protease1); var protease2 = new Protease("testD", CleavageSpecificity.Full, null, null, motifs2); ProteaseDictionary.Dictionary.Add(protease2.Name, protease2); - var peptideList = new List(); + var peptideList = new List(); var p = new List(); List> gn = new List>(); @@ -822,7 +823,7 @@ public static void MultiProteaseParsimony_TestingSameBaseSequenceSharedandUnique psms.ForEach(j => j.ResolveAllAmbiguities()); psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); - HashSet digestionParamsList = new HashSet(); + var digestionParamsList = new HashSet(); digestionParamsList.Add(commonParameters.DigestionParams); digestionParamsList.Add(commonParameters2.DigestionParams); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); @@ -895,7 +896,7 @@ public static void MultiProteaseParsimony_TestingActuallyIndistinguisableProtein psms.ForEach(j => j.ResolveAllAmbiguities()); psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); - HashSet digestionParamsList = new HashSet(); + var digestionParamsList = new HashSet(); digestionParamsList.Add(commonParameters_tryp.DigestionParams); digestionParamsList.Add(commonParameters_LysC.DigestionParams); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); @@ -965,7 +966,7 @@ public static void MultiProteaseParsimony_TestingGreedyAlgorithm() psms.ForEach(j => j.ResolveAllAmbiguities()); psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); - HashSet digestionParamsList = new HashSet(); + var digestionParamsList = new HashSet(); digestionParamsList.Add(commonParameters.DigestionParams); digestionParamsList.Add(commonParameters2.DigestionParams); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); diff --git a/MetaMorpheus/Test/MyTaskTest.cs b/MetaMorpheus/Test/MyTaskTest.cs index be7cf4f8d..9b0e55b9c 100644 --- a/MetaMorpheus/Test/MyTaskTest.cs +++ b/MetaMorpheus/Test/MyTaskTest.cs @@ -11,6 +11,7 @@ using System.IO; using System.Linq; using System.Reflection; +using Omics; using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; @@ -80,9 +81,9 @@ public static void TestEverythingRunner() Assert.AreEqual(3, digestedList.Count); - PeptideWithSetModifications pepWithSetMods1 = digestedList[0]; + IBioPolymerWithSetMods pepWithSetMods1 = digestedList[0]; - PeptideWithSetModifications pepWithSetMods2 = digestedList[2]; + IBioPolymerWithSetMods pepWithSetMods2 = digestedList[2]; var dictHere = new Dictionary>(); ModificationMotif.TryGetMotif("E", out ModificationMotif motif); @@ -90,7 +91,7 @@ public static void TestEverythingRunner() Protein ParentProteinToNotInclude = new("MPEPTIDEK", "accession2", "organism", new List>(), dictHere); digestedList = ParentProteinToNotInclude.Digest(task1.CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); - MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1, pepWithSetMods2, digestedList[1] }); + MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1, pepWithSetMods2, digestedList[1] }); Protein proteinWithChain = new("MAACNNNCAA", "accession3", "organism", new List>(), new Dictionary>(), new List { new ProteolysisProduct(4, 8, "chain") }, "name2", "fullname2"); @@ -173,9 +174,9 @@ public static void TestMultipleFilesRunner() Assert.AreEqual(3, digestedList.Count); - PeptideWithSetModifications pepWithSetMods1 = digestedList[0]; + var pepWithSetMods1 = digestedList[0]; - PeptideWithSetModifications pepWithSetMods2 = digestedList[2]; + var pepWithSetMods2 = digestedList[2]; var dictHere = new Dictionary>(); ModificationMotif.TryGetMotif("E", out ModificationMotif motif); @@ -184,12 +185,12 @@ public static void TestMultipleFilesRunner() digestedList = ParentProteinToNotInclude.Digest(task1.CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); Assert.AreEqual(4, digestedList.Count); - MsDataFile myMsDataFile1 = new TestDataFile(new List { pepWithSetMods1, pepWithSetMods2, digestedList[1] }); + MsDataFile myMsDataFile1 = new TestDataFile(new List { pepWithSetMods1, pepWithSetMods2, digestedList[1] }); string mzmlName1 = @"ok1.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName1, false); - MsDataFile myMsDataFile2 = new TestDataFile(new List { pepWithSetMods1, pepWithSetMods2, digestedList[1] }); + MsDataFile myMsDataFile2 = new TestDataFile(new List { pepWithSetMods1, pepWithSetMods2, digestedList[1] }); string mzmlName2 = @"ok2.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile2, mzmlName2, false); @@ -244,9 +245,9 @@ public static void MakeSureFdrDoesntSkip() var targetDigested = theProteins[0].Digest(task.CommonParameters.DigestionParams, fixedModifications, GlobalVariables.AllModsKnown.OfType().ToList()).ToList(); - PeptideWithSetModifications targetGood = targetDigested.First(); + var targetGood = targetDigested.First(); - TestDataFile myMsDataFile = new(new List { targetGood }); + TestDataFile myMsDataFile = new(new List { targetGood }); var ii = myMsDataFile.GetOneBasedScan(1).MassSpectrum.YArray.ToList(); @@ -327,10 +328,10 @@ public static void MakeSureGptmdTaskMatchesExactMatches() var targetDigested = theProteins[0].Digest(task1.CommonParameters.DigestionParams, fixedModifications, GlobalVariables.AllModsKnown.OfType().Where(b => b.OriginalId.Equals("ok")).ToList()).ToList(); ModificationMotif.TryGetMotif("T", out ModificationMotif motif); - PeptideWithSetModifications targetGood = targetDigested[0]; + var targetGood = targetDigested[0]; - PeptideWithSetModifications targetWithUnknownMod = targetDigested[1]; - MsDataFile myMsDataFile = new TestDataFile(new List { targetGood, targetWithUnknownMod }); + var targetWithUnknownMod = targetDigested[1]; + MsDataFile myMsDataFile = new TestDataFile(new List { targetGood, targetWithUnknownMod }); Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); } @@ -410,7 +411,7 @@ public static void TestPeptideCount() Assert.AreEqual(4, setList1.Count); //Finally Write MZML file - MsDataFile myMsDataFile = new TestDataFile(new List { setList1[0], setList1[1], setList1[2], setList1[3], setList1[0], setList1[1] }); + MsDataFile myMsDataFile = new TestDataFile(new List { setList1[0], setList1[1], setList1[2], setList1[3], setList1[0], setList1[1] }); string mzmlName = @"singleProteinWithRepeatedMods.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); diff --git a/MetaMorpheus/Test/ParameterTest.cs b/MetaMorpheus/Test/ParameterTest.cs index b7a726020..6569b3634 100644 --- a/MetaMorpheus/Test/ParameterTest.cs +++ b/MetaMorpheus/Test/ParameterTest.cs @@ -150,7 +150,7 @@ public static void TestFileSpecifcParameterOverwrite() Assert.AreEqual(updatedParameters.DigestionParams.MaxMissedCleavages, basicFileSpecificParameters.MaxMissedCleavages); Assert.AreEqual(updatedParameters.DigestionParams.MinLength, basicFileSpecificParameters.MinPeptideLength); Assert.AreEqual(updatedParameters.DigestionParams.MaxLength, basicFileSpecificParameters.MaxPeptideLength); - Assert.AreEqual(updatedParameters.DigestionParams.Protease, basicFileSpecificParameters.Protease); + Assert.AreEqual(updatedParameters.DigestionParams.DigestionAgent, basicFileSpecificParameters.Protease); Assert.AreEqual(updatedParameters.CustomIons, basicFileSpecificParameters.CustomIons); Assert.AreEqual(updatedParameters.DoPrecursorDeconvolution, notDefaultParameters.DoPrecursorDeconvolution); @@ -168,7 +168,7 @@ public static void TestFileSpecifcParameterOverwrite() Assert.AreEqual(updatedParameters.UseDeltaScore, notDefaultParameters.UseDeltaScore); Assert.AreEqual(updatedParameters.DeconvolutionMassTolerance, notDefaultParameters.DeconvolutionMassTolerance); Assert.AreEqual(updatedParameters.MaxThreadsToUsePerFile, notDefaultParameters.MaxThreadsToUsePerFile); - Assert.AreEqual(updatedParameters.DigestionParams.InitiatorMethionineBehavior, notDefaultParameters.DigestionParams.InitiatorMethionineBehavior); + Assert.AreEqual(((DigestionParams)updatedParameters.DigestionParams).InitiatorMethionineBehavior, ((DigestionParams)notDefaultParameters.DigestionParams).InitiatorMethionineBehavior); Assert.AreEqual(updatedParameters.ListOfModsVariable, notDefaultParameters.ListOfModsVariable); Assert.AreEqual(updatedParameters.ListOfModsFixed, notDefaultParameters.ListOfModsFixed); diff --git a/MetaMorpheus/Test/RobTest.cs b/MetaMorpheus/Test/RobTest.cs index 1b87dcd13..25cfdbb17 100644 --- a/MetaMorpheus/Test/RobTest.cs +++ b/MetaMorpheus/Test/RobTest.cs @@ -11,6 +11,7 @@ using System.Linq; using Omics.Digestion; using Omics.Modifications; +using Omics; namespace Test { @@ -178,28 +179,28 @@ public static void TestPTMOutput() int idx = 0; - var pep1 = new HashSet { protDigest[idx++] }; + var pep1 = new HashSet { protDigest[idx++] }; Assert.AreEqual("MNNNSK", pep1.Single().FullSequence);//this might be base - var pep1mod = new HashSet { protDigest[idx++] }; + var pep1mod = new HashSet { protDigest[idx++] }; Assert.AreEqual("MNNNS[HaHa:resMod on S]K", pep1mod.Single().FullSequence);//this might be base - var pep3 = new HashSet { protDigest[idx++] }; + var pep3 = new HashSet { protDigest[idx++] }; Assert.AreEqual("NNNSK", pep3.Single().FullSequence);//this might be base - var pep3mod = new HashSet { protDigest[idx++] }; + var pep3mod = new HashSet { protDigest[idx++] }; Assert.AreEqual("NNNS[HaHa:resMod on S]K", pep3mod.Single().FullSequence);//this might be base - var pep4 = new HashSet { protDigest[idx++] }; + var pep4 = new HashSet { protDigest[idx++] }; Assert.AreEqual("QQQI", pep4.Single().FullSequence);//this might be base - var pep4mod1 = new HashSet { protDigest[idx++] }; + var pep4mod1 = new HashSet { protDigest[idx++] }; Assert.AreEqual("QQQI[HaHa:iModOne on I]", pep4mod1.Single().FullSequence);//this might be base - var pep4mod2 = new HashSet { protDigest[idx++] }; + var pep4mod2 = new HashSet { protDigest[idx++] }; Assert.AreEqual("QQQI[HaHa:iModTwo on I]", pep4mod2.Single().FullSequence);//this might be base - var peptideList = new HashSet(); + var peptideList = new HashSet(); foreach (var peptide in proteinList.SelectMany(protein => protein.Digest(commonParameters.DigestionParams, new List(), variableModifications))) { peptideList.Add(peptide); diff --git a/MetaMorpheus/Test/SearchEngineTests.cs b/MetaMorpheus/Test/SearchEngineTests.cs index 2721fe645..0cbb3e60b 100644 --- a/MetaMorpheus/Test/SearchEngineTests.cs +++ b/MetaMorpheus/Test/SearchEngineTests.cs @@ -16,6 +16,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Omics; using Omics.Digestion; using Omics.Modifications; using Readers; @@ -1461,7 +1462,7 @@ public static void TestSemiSpecificEnzymeEngineSingleN() scoreCutoff: 2, addCompIons: true); - HashSet digestParams = new HashSet { CommonParameters.DigestionParams }; + var digestParams = new HashSet { CommonParameters.DigestionParams }; var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.Reverse, CommonParameters, null, 100000, true, new List(), TargetContaminantAmbiguity.RemoveContaminant, new List()); var indexResults = (IndexingResults)indexEngine.Run(); @@ -1536,7 +1537,7 @@ public static void TestSemiSpecificEnzymeEngineSingleC() dissociationType: DissociationType.HCD, addCompIons: true); - HashSet digestParams = new HashSet { CommonParameters.DigestionParams }; + var digestParams = new HashSet { CommonParameters.DigestionParams }; var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.Reverse, CommonParameters, null, 30000, false, new List(), TargetContaminantAmbiguity.RemoveContaminant, new List()); var indexResults = (IndexingResults)indexEngine.Run(); @@ -1641,7 +1642,7 @@ public static void TestClassicSemiProtease() digestionParams: new DigestionParams(protease: protease2.Name, maxMissedCleavages: 5) ); - HashSet digestParams2 = new HashSet { CommonParameters2.DigestionParams }; + var digestParams2 = new HashSet { CommonParameters2.DigestionParams }; Tolerance DeconvolutionMassTolerance2 = new PpmTolerance(5); @@ -1791,7 +1792,7 @@ public static void TestFileSpecificUpdateMaintainsSpecificProteaseForNonSpecific CommonParameters commonParams = new CommonParameters(digestionParams: new DigestionParams(protease: "Arg-C", searchModeType: CleavageSpecificity.None)); FileSpecificParameters fileSpecificParams = new FileSpecificParameters(); CommonParameters updatedCommonParams = MetaMorpheusTask.SetAllFileSpecificCommonParams(commonParams, fileSpecificParams); - Assert.AreEqual(updatedCommonParams.DigestionParams.SpecificProtease, commonParams.DigestionParams.SpecificProtease); + Assert.AreEqual(((DigestionParams)updatedCommonParams.DigestionParams).SpecificProtease, ((DigestionParams)commonParams.DigestionParams).SpecificProtease); } [Test] @@ -1800,7 +1801,7 @@ public static void TestTerminalModificationsForSnes() //peptide and ms file prep PeptideWithSetModifications nTermModifiedPwsm = new PeptideWithSetModifications("[Uniprot:N-acetylalanine on A]AGIAAKLAKDREAAEGLGSHA", GlobalVariables.AllModsKnownDictionary); PeptideWithSetModifications cTermModifiedPwsm = new PeptideWithSetModifications("AGIAAKLAKDREAAEGLGSHA[Uniprot:Alanine amide on A]", GlobalVariables.AllModsKnownDictionary); - TestDataFile msFile = new TestDataFile(new List { nTermModifiedPwsm, cTermModifiedPwsm }); + TestDataFile msFile = new TestDataFile(new List { nTermModifiedPwsm, cTermModifiedPwsm }); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(msFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); //params for singleN and singleC @@ -1835,7 +1836,7 @@ public static void TestTerminalModificationsForSnes() List paramsToTest = new List { cCommonParameters, nCommonParameters, cCleaveParams, nCleaveParams }; foreach (CommonParameters commonParams in paramsToTest) { - HashSet digestParams = new HashSet { commonParams.DigestionParams }; + var digestParams = new HashSet { commonParams.DigestionParams }; var indexEngine = new IndexingEngine(termParams.proteinList, termParams.variableMods, empty, null, null, null, 1, DecoyType.None, commonParams, null, 100000, true, new List(), TargetContaminantAmbiguity.RemoveContaminant, new List()); var indexResults = (IndexingResults)indexEngine.Run(); @@ -1897,7 +1898,7 @@ public static void TestUndefinedProteinGroup() PeptideWithSetModifications peptide6 = new PeptideWithSetModifications("LNGEEPEPKSMTHERPEPSK", new Dictionary()); PeptideWithSetModifications peptide7 = new PeptideWithSetModifications("LNGEEPEPKASWELASKTHEPEPSK", new Dictionary()); - MsDataFile myMsDataFile1 = new TestDataFile(new List { peptide, peptide2, peptide3, peptide4, peptide5, peptide6, peptide7 }); + MsDataFile myMsDataFile1 = new TestDataFile(new List { peptide, peptide2, peptide3, peptide4, peptide5, peptide6, peptide7 }); string mzmlName = @"test.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); diff --git a/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs b/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs index e7c44fe94..969757d66 100644 --- a/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs +++ b/MetaMorpheus/Test/SearchWithPeptidesAddedInParsimony.cs @@ -10,6 +10,7 @@ using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; +using Omics; namespace Test { @@ -63,8 +64,8 @@ public static void SearchWithPeptidesAddedInParsimonyTest() }; Protein protein2 = new Protein("MG", "protein3", oneBasedModifications: oneBasedModifications2); - PeptideWithSetModifications pepMA = protein1.Digest(CommonParameters.DigestionParams, new List(), variableModifications).First(); - PeptideWithSetModifications pepMA111 = protein1.Digest(CommonParameters.DigestionParams, new List(), variableModifications).Last(); + var pepMA = protein1.Digest(CommonParameters.DigestionParams, new List(), variableModifications).First(); + var pepMA111 = protein1.Digest(CommonParameters.DigestionParams, new List(), variableModifications).Last(); var pepMG = protein2.Digest(CommonParameters.DigestionParams, new List(), variableModifications).First(); @@ -72,7 +73,7 @@ public static void SearchWithPeptidesAddedInParsimonyTest() string mzmlName = @"ajgdiu.mzML"; - MsDataFile myMsDataFile = new TestDataFile(new List { pepMA, pepMG, pepMA111 }); + MsDataFile myMsDataFile = new TestDataFile(new List { pepMA, pepMG, pepMA111 }); Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestSearchWithPeptidesAddedInParsimony"); diff --git a/MetaMorpheus/Test/SilacTest.cs b/MetaMorpheus/Test/SilacTest.cs index 74f86989a..386134c1e 100644 --- a/MetaMorpheus/Test/SilacTest.cs +++ b/MetaMorpheus/Test/SilacTest.cs @@ -10,6 +10,8 @@ using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; +using Omics; +using Omics.Digestion; namespace Test { @@ -555,7 +557,7 @@ public static void TestSilacTurnoverLabelSites() PeptideWithSetModifications onePeptide = new PeptideWithSetModifications("PEPTIDEK", new Dictionary()); PeptideWithSetModifications fivePeptide = new PeptideWithSetModifications("PaEKPKTaIK", new Dictionary()); PeptideWithSetModifications sixPeptide = new PeptideWithSetModifications("PKEaPaTKIKDa", new Dictionary()); - MsDataFile myMsDataFile1 = new TestDataFile(new List { zeroPeptide, onePeptide, sixPeptide, fivePeptide }); + MsDataFile myMsDataFile1 = new TestDataFile(new List { zeroPeptide, onePeptide, sixPeptide, fivePeptide }); string mzmlName = @"silac.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlName, false); @@ -661,7 +663,7 @@ public static void TestSilacHelperMethods() Assert.IsTrue(asdfff.Equals("ASDF[SomeSebuance]GHKASDF")); //Test no crash in weird situations - SilacConversions.SilacConversionsPostQuantification(null, null, null, new List(), null, new HashSet(), null, new List(), new Dictionary(), true); + SilacConversions.SilacConversionsPostQuantification(null, null, null, new List(), null, new HashSet(), null, new List(), new Dictionary(), true); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/SpectralRecoveryTest.cs b/MetaMorpheus/Test/SpectralRecoveryTest.cs index e46ca8994..358aef4ab 100644 --- a/MetaMorpheus/Test/SpectralRecoveryTest.cs +++ b/MetaMorpheus/Test/SpectralRecoveryTest.cs @@ -15,6 +15,7 @@ using TaskLayer; using TaskLayer.MbrAnalysis; using Omics; +using Omics.Digestion; namespace Test { @@ -103,7 +104,7 @@ public void SpectralRecoveryTestSetup() DatabaseFilenameList = databaseList, OutputFolder = outputFolder, NumMs2SpectraPerFile = numSpectraPerFile, - ListOfDigestionParams = new HashSet { new DigestionParams(generateUnlabeledProteinsForSilac: false) }, + ListOfDigestionParams = new HashSet { new DigestionParams(generateUnlabeledProteinsForSilac: false) }, SearchTaskResults = searchTaskResults, MyFileManager = myFileManager, IndividualResultsOutputFolder = Path.Combine(outputFolder, "individual"), @@ -272,7 +273,7 @@ public static void SpectralWriterTest() DatabaseFilenameList = databaseList, OutputFolder = outputFolder, NumMs2SpectraPerFile = numSpectraPerFile, - ListOfDigestionParams = new HashSet { new DigestionParams(generateUnlabeledProteinsForSilac: false) }, + ListOfDigestionParams = new HashSet { new DigestionParams(generateUnlabeledProteinsForSilac: false) }, SearchTaskResults = searchTaskResults, MyFileManager = myFileManager, IndividualResultsOutputFolder = Path.Combine(outputFolder, "Individual File Results"), @@ -318,7 +319,7 @@ public static void SpectralWriterTest() DatabaseFilenameList = databaseList, OutputFolder = outputFolder, NumMs2SpectraPerFile = numSpectraPerFile, - ListOfDigestionParams = new HashSet { new DigestionParams(generateUnlabeledProteinsForSilac: false) }, + ListOfDigestionParams = new HashSet { new DigestionParams(generateUnlabeledProteinsForSilac: false) }, SearchTaskResults = searchTaskResults, MyFileManager = myFileManager, IndividualResultsOutputFolder = Path.Combine(outputFolder, "Individual File Results"), diff --git a/MetaMorpheus/Test/TestDataFile.cs b/MetaMorpheus/Test/TestDataFile.cs index 4757672eb..ed2c25670 100644 --- a/MetaMorpheus/Test/TestDataFile.cs +++ b/MetaMorpheus/Test/TestDataFile.cs @@ -1,5 +1,6 @@ using Chemistry; using MassSpectrometry; +using Omics; using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; @@ -135,7 +136,7 @@ internal class TestDataFile : MsDataFile Scans = ScansHere.ToArray(); } - public TestDataFile(List pepWithSetModss) + public TestDataFile(List pepWithSetModss) : base(pepWithSetModss.Count * 2, new SourceFile(@"no nativeID format", "mzML format", null, "SHA-1", @"C:\fake.mzML", null)) { List ScansHere = new List(); @@ -283,7 +284,7 @@ public TestDataFile(List pwsms, List> Scans = ScansHere.ToArray(); } - public TestDataFile(PeptideWithSetModifications pepWithSetMods) + public TestDataFile(IBioPolymerWithSetMods pepWithSetMods) : base(2, new SourceFile(@"no nativeID format", "mzML format", null, "SHA-1", @"C:\fake.mzML", null)) { var mz1 = new double[] { pepWithSetMods.MonoisotopicMass.ToMz(2), (pepWithSetMods.MonoisotopicMass + Constants.C13MinusC12).ToMz(2), (pepWithSetMods.MonoisotopicMass + 2 * Constants.C13MinusC12).ToMz(2) }; @@ -312,7 +313,7 @@ public TestDataFile(PeptideWithSetModifications pepWithSetMods) Scans = ScansHere.ToArray(); } - public TestDataFile(PeptideWithSetModifications pepWithSetMods, string v) : base(2, new SourceFile(null, null, null, null, null)) + public TestDataFile(IBioPolymerWithSetMods pepWithSetMods, string v) : base(2, new SourceFile(null, null, null, null, null)) { if (v.Equals("quadratic")) { diff --git a/MetaMorpheus/Test/TestPsm.cs b/MetaMorpheus/Test/TestPsm.cs index f7cba663f..d60c8941a 100644 --- a/MetaMorpheus/Test/TestPsm.cs +++ b/MetaMorpheus/Test/TestPsm.cs @@ -29,7 +29,7 @@ public static class TestPsm public static void TestPsmHeader() { CommonParameters commonParameters = new CommonParameters(); - PeptideWithSetModifications pepWithSetMods = new Protein( + var pepWithSetMods = new Protein( "MQQQQQQQ", "accession1", "org", @@ -222,8 +222,8 @@ public static void TestPsmMatchingToTargetAndDecoyWithSameSequence() List mods = new List(); CommonParameters commonParameters = new CommonParameters(); - PeptideWithSetModifications target = new Protein("PEPTIDE", "TARGET").Digest(commonParameters.DigestionParams, mods, mods).First(); - PeptideWithSetModifications decoy = new Protein("PEPTIDE", "DECOY", isDecoy: true).Digest(commonParameters.DigestionParams, mods, mods).First(); + var target = new Protein("PEPTIDE", "TARGET").Digest(commonParameters.DigestionParams, mods, mods).First(); + var decoy = new Protein("PEPTIDE", "DECOY", isDecoy: true).Digest(commonParameters.DigestionParams, mods, mods).First(); MsDataFile msDataFile = new TestDataFile(target); MsDataScan msDataScan = msDataFile.GetOneBasedScan(2); @@ -248,8 +248,8 @@ public static void TestPsmMatchingToTargetAndDecoyWithDifferentSequences() CommonParameters commonParameters = new CommonParameters(); List mods = new List(); - PeptideWithSetModifications target = new Protein("PEPTIDE", "").Digest(commonParameters.DigestionParams, mods, mods).First(); - PeptideWithSetModifications decoy = new Protein("PEPTIDEL", "", isDecoy: true).Digest(commonParameters.DigestionParams, mods, mods).First(); + var target = new Protein("PEPTIDE", "").Digest(commonParameters.DigestionParams, mods, mods).First(); + var decoy = new Protein("PEPTIDEL", "", isDecoy: true).Digest(commonParameters.DigestionParams, mods, mods).First(); MsDataFile msDataFile = new TestDataFile(target); MsDataScan msDataScan = msDataFile.GetOneBasedScan(2); @@ -277,15 +277,15 @@ public static void TestPsmCount() { Protein p1 = new Protein("PEPTIDE", null); CommonParameters commonParameters = new CommonParameters(); - PeptideWithSetModifications pep1 = p1.Digest(commonParameters.DigestionParams, new List(), new List()).ToList().First(); + var pep1 = p1.Digest(commonParameters.DigestionParams, new List(), new List()).ToList().First(); Protein p2 = new Protein("PEPTIDE", null); - PeptideWithSetModifications pep2 = p2.Digest(commonParameters.DigestionParams, new List(), new List()).ToList().First(); + var pep2 = p2.Digest(commonParameters.DigestionParams, new List(), new List()).ToList().First(); Protein p3 = new Protein("PEPTIDE", null); - PeptideWithSetModifications pep3 = p3.Digest(commonParameters.DigestionParams, new List(), new List()).ToList().First(); + var pep3 = p3.Digest(commonParameters.DigestionParams, new List(), new List()).ToList().First(); - TestDataFile t = new TestDataFile(new List { pep1, pep2, pep3 }); + TestDataFile t = new TestDataFile(new List { pep1, pep2, pep3 }); MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, 0, 1, null, new CommonParameters()); @@ -464,12 +464,12 @@ public static void TestPSMFragmentCoverage() CommonParameters commonParameters = new CommonParameters(); Protein p1 = new Protein("PEPTIDEPEPTIDE", null); - PeptideWithSetModifications pep1 = p1.Digest(commonParameters.DigestionParams, new List(), new List()).ToList().First(); + var pep1 = p1.Digest(commonParameters.DigestionParams, new List(), new List()).ToList().First(); Protein p2 = new Protein("GGGGGGGGGGGGGGKPEPTIDEPEPTIDE", null); - PeptideWithSetModifications pep2 = p2.Digest(commonParameters.DigestionParams, new List(), new List()).ToList()[1]; + var pep2 = p2.Digest(commonParameters.DigestionParams, new List(), new List()).ToList()[1]; - TestDataFile t = new TestDataFile(new List { pep1, pep2}); + TestDataFile t = new TestDataFile(new List { pep1, pep2}); //psm 1 - test first and last amino acid positions, along with one internal Amino Acid position Product productC3 = new Product(ProductType.y, FragmentationTerminus.C, 0, 3, 12, 0); diff --git a/MetaMorpheus/Test/TestToml.cs b/MetaMorpheus/Test/TestToml.cs index 6233e6b12..1e0132d50 100644 --- a/MetaMorpheus/Test/TestToml.cs +++ b/MetaMorpheus/Test/TestToml.cs @@ -128,7 +128,7 @@ public static void TestTomlForSpecficFiles() CommonParameters c = MetaMorpheusTask.SetAllFileSpecificCommonParams(new CommonParameters(), f); - Assert.AreEqual("Asp-N", c.DigestionParams.Protease.Name); + Assert.AreEqual("Asp-N", c.DigestionParams.DigestionAgent.Name); Assert.AreEqual(DissociationType.ETD, c.DissociationType); Assert.AreEqual(2, c.DigestionParams.MaxMissedCleavages); } @@ -276,17 +276,22 @@ public static void TestDigestionParamsTomlReadingWriting() searchTask.CommonParameters = commonParams; // check that digestion params are correct in search task + var digestion = searchTask.CommonParameters.DigestionParams as DigestionParams; + if (digestion is null) + { + Assert.Fail("Digestion params are not of type DigestionParams"); + } Assert.That(searchTask.CommonParameters.DigestionParams.FragmentationTerminus, Is.EqualTo(digestionParams.FragmentationTerminus)); Assert.That(searchTask.CommonParameters.DigestionParams.SearchModeType, Is.EqualTo(digestionParams.SearchModeType)); - Assert.That(searchTask.CommonParameters.DigestionParams.InitiatorMethionineBehavior, Is.EqualTo(digestionParams.InitiatorMethionineBehavior)); + Assert.That(digestion.InitiatorMethionineBehavior, Is.EqualTo(digestionParams.InitiatorMethionineBehavior)); Assert.That(searchTask.CommonParameters.DigestionParams.MaxMissedCleavages, Is.EqualTo(digestionParams.MaxMissedCleavages)); Assert.That(searchTask.CommonParameters.DigestionParams.MaxModificationIsoforms, Is.EqualTo(digestionParams.MaxModificationIsoforms)); Assert.That(searchTask.CommonParameters.DigestionParams.MinLength, Is.EqualTo(digestionParams.MinLength)); Assert.That(searchTask.CommonParameters.DigestionParams.MaxLength, Is.EqualTo(digestionParams.MaxLength)); - Assert.That(searchTask.CommonParameters.DigestionParams.Protease.Name, Is.EqualTo(digestionParams.Protease.Name)); - Assert.That(searchTask.CommonParameters.DigestionParams.GeneratehUnlabeledProteinsForSilac, Is.EqualTo(digestionParams.GeneratehUnlabeledProteinsForSilac)); - Assert.That(searchTask.CommonParameters.DigestionParams.KeepNGlycopeptide, Is.EqualTo(digestionParams.KeepNGlycopeptide)); - Assert.That(searchTask.CommonParameters.DigestionParams.KeepOGlycopeptide, Is.EqualTo(digestionParams.KeepOGlycopeptide)); + Assert.That(searchTask.CommonParameters.DigestionParams.DigestionAgent.Name, Is.EqualTo(digestionParams.Protease.Name)); + Assert.That(digestion.GeneratehUnlabeledProteinsForSilac, Is.EqualTo(digestionParams.GeneratehUnlabeledProteinsForSilac)); + Assert.That(digestion.KeepNGlycopeptide, Is.EqualTo(digestionParams.KeepNGlycopeptide)); + Assert.That(digestion.KeepOGlycopeptide, Is.EqualTo(digestionParams.KeepOGlycopeptide)); // write and read file string filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "testDigestionParams.toml"); @@ -294,17 +299,22 @@ public static void TestDigestionParamsTomlReadingWriting() var searchTaskLoaded = Toml.ReadFile(filePath, MetaMorpheusTask.tomlConfig); // check that digestion params are correct in search task + digestion = searchTaskLoaded.CommonParameters.DigestionParams as DigestionParams; + if (digestion is null) + { + Assert.Fail("Digestion params are not of type DigestionParams"); + } Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.FragmentationTerminus, Is.EqualTo(digestionParams.FragmentationTerminus)); Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.SearchModeType, Is.EqualTo(digestionParams.SearchModeType)); - Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.InitiatorMethionineBehavior, Is.EqualTo(digestionParams.InitiatorMethionineBehavior)); + Assert.That(digestion.InitiatorMethionineBehavior, Is.EqualTo(digestionParams.InitiatorMethionineBehavior)); Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.MaxMissedCleavages, Is.EqualTo(digestionParams.MaxMissedCleavages)); Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.MaxModificationIsoforms, Is.EqualTo(digestionParams.MaxModificationIsoforms)); Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.MinLength, Is.EqualTo(digestionParams.MinLength)); Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.MaxLength, Is.EqualTo(digestionParams.MaxLength)); - Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.Protease.Name, Is.EqualTo(digestionParams.Protease.Name)); - Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.GeneratehUnlabeledProteinsForSilac, Is.EqualTo(digestionParams.GeneratehUnlabeledProteinsForSilac)); - Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.KeepNGlycopeptide, Is.EqualTo(digestionParams.KeepNGlycopeptide)); - Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.KeepOGlycopeptide, Is.EqualTo(digestionParams.KeepOGlycopeptide)); + Assert.That(searchTaskLoaded.CommonParameters.DigestionParams.DigestionAgent.Name, Is.EqualTo(digestionParams.Protease.Name)); + Assert.That(digestion.GeneratehUnlabeledProteinsForSilac, Is.EqualTo(digestionParams.GeneratehUnlabeledProteinsForSilac)); + Assert.That(digestion.KeepNGlycopeptide, Is.EqualTo(digestionParams.KeepNGlycopeptide)); + Assert.That(digestion.KeepOGlycopeptide, Is.EqualTo(digestionParams.KeepOGlycopeptide)); File.Delete(filePath); } diff --git a/MetaMorpheus/Test/VariantSearchTests.cs b/MetaMorpheus/Test/VariantSearchTests.cs index d13602de4..e769450eb 100644 --- a/MetaMorpheus/Test/VariantSearchTests.cs +++ b/MetaMorpheus/Test/VariantSearchTests.cs @@ -13,6 +13,7 @@ using UsefulProteomicsDatabases; using Nett; using Omics.Modifications; +using Omics; namespace Test { @@ -80,13 +81,13 @@ public static void SearchTests(int proteinIdx, int peptideIdx, bool containsVari new Protein("MPEPTIDE", "protein3", sequenceVariations: new List { new SequenceVariation(4, 4, "P", "PPP", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", new Dictionary> {{ 5, new[] { mp }.ToList() } }) }), new Protein("MPEPTIDEPEPTIDE", "protein3", sequenceVariations: new List { new SequenceVariation(4, 4, "PTIDEPEPTIDE", "PPP", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), }; - PeptideWithSetModifications pep = proteins[proteinIdx].GetVariantProteins().SelectMany(p => p.Digest(CommonParameters.DigestionParams, null, null)).ToList()[peptideIdx]; + var pep = proteins[proteinIdx].GetVariantProteins().SelectMany(p => p.Digest(CommonParameters.DigestionParams, null, null)).ToList()[peptideIdx]; string xmlName = $"andguiaheov{proteinIdx.ToString()}.xml"; ProteinDbWriter.WriteXmlDatabase(null, new List { proteins[proteinIdx] }, xmlName); string mzmlName = $"ajgdiv{proteinIdx.ToString()}.mzML"; - MsDataFile myMsDataFile = new TestDataFile(new List { pep }); + MsDataFile myMsDataFile = new TestDataFile(new List { pep }); Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, $"TestSearchWithVariants{proteinIdx.ToString()}"); @@ -113,10 +114,10 @@ public void MoreTests(string filename, DecoyType decoyType = DecoyType.None) string xmlName = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", filename); var proteins = ProteinDbLoader.LoadProteinXML(xmlName, decoyType == DecoyType.None, decoyType, null, false, null, out var un); var peps = proteins[1].Digest(CommonParameters.DigestionParams, null, null).ToList(); - PeptideWithSetModifications pep = peps[peps.Count - 2]; + var pep = peps[peps.Count - 2]; string mzmlName = $"ajgdiv{filename}{decoyType.ToString()}.mzML"; - MsDataFile myMsDataFile = new TestDataFile(new List { pep }); + MsDataFile myMsDataFile = new TestDataFile(new List { pep }); Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, $"TestSearchWithVariants{filename}{decoyType.ToString()}"); diff --git a/MetaMorpheus/Test/XLTest.cs b/MetaMorpheus/Test/XLTest.cs index b1b041f46..c2475ee50 100644 --- a/MetaMorpheus/Test/XLTest.cs +++ b/MetaMorpheus/Test/XLTest.cs @@ -22,6 +22,7 @@ using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; +using Omics; namespace Test { @@ -816,7 +817,7 @@ public static void XlTest_DiffCrosslinkSites() } //Generate digested peptide lists. - List digestedList = new List(); + var digestedList = new List(); foreach (var item in proteinList) { var digested = item.Digest(commonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); diff --git a/MetaMorpheus/Test/gptmdPrunedBdTests.cs b/MetaMorpheus/Test/gptmdPrunedBdTests.cs index a24149ba4..71497ff85 100644 --- a/MetaMorpheus/Test/gptmdPrunedBdTests.cs +++ b/MetaMorpheus/Test/gptmdPrunedBdTests.cs @@ -10,6 +10,7 @@ using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; +using Omics; namespace Test { @@ -155,11 +156,11 @@ public static void TestPrunedDatabase() Assert.AreEqual(4, digestedList.Count); //Set Peptide with 1 mod at position 3 - PeptideWithSetModifications pepWithSetMods1 = digestedList[1]; + var pepWithSetMods1 = digestedList[1]; //Finally Write MZML file Assert.AreEqual("PEP[ConnorModType:ConnorMod on P]TID", pepWithSetMods1.FullSequence);//this might be base sequence - MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1 }); + MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1 }); string mzmlName = @"hello.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); @@ -284,14 +285,14 @@ public static void TestUserModSelectionInPrunedDB() var digestedList = protein[0].Digest(task5.CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); //Set Peptide with 1 mod at position 3 - PeptideWithSetModifications pepWithSetMods1 = digestedList[0]; - PeptideWithSetModifications pepWithSetMods2 = digestedList[1]; - PeptideWithSetModifications pepWithSetMods3 = digestedList[2]; - PeptideWithSetModifications pepWithSetMods4 = digestedList[3]; - PeptideWithSetModifications pepWithSetMods5 = digestedList[4]; + var pepWithSetMods1 = digestedList[0]; + var pepWithSetMods2 = digestedList[1]; + var pepWithSetMods3 = digestedList[2]; + var pepWithSetMods4 = digestedList[3]; + var pepWithSetMods5 = digestedList[4]; //CUSTOM PEP - MsDataFile myMsDataFile = new TestDataFile(new List + MsDataFile myMsDataFile = new TestDataFile(new List { pepWithSetMods1, pepWithSetMods2, pepWithSetMods3, pepWithSetMods4, pepWithSetMods5 }); string mzmlName = @"newMzml.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); @@ -380,7 +381,7 @@ public static void TestProteinPrunedWithModSelection() numSpectraPerFile.Add("", stuffForSpectraFile); testPostTaskParameters.NumMs2SpectraPerFile = numSpectraPerFile; - MsDataFile myMsDataFile = new TestDataFile(new List + MsDataFile myMsDataFile = new TestDataFile(new List { peptideObserved}); string mzmlName = @"newMzml.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); @@ -485,7 +486,7 @@ public static void TestProteinPrunedWithModSelectionAndVariants() numSpectraPerFile.Add("", stuffForSpectraFile); testPostTaskParameters.NumMs2SpectraPerFile = numSpectraPerFile; - MsDataFile myMsDataFile = new TestDataFile(new List + MsDataFile myMsDataFile = new TestDataFile(new List { peptideObserved}); string mzmlName = @"newMzml.mzML"; Readers.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); From 25d4fd22eb9ad5210f2938d4f7cfe1c4d532b4b8 Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 23 Jan 2024 10:25:09 -0600 Subject: [PATCH 17/39] Formatted toml parameters --- MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index a0386014b..b8f57d089 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -74,11 +74,12 @@ public abstract class MetaMorpheusTask .IgnoreProperty(p => p.MaxMods) .IgnoreProperty(p => p.MaxLength) .IgnoreProperty(p => p.MinLength)) - .ConfigureType(type => type .WithConversionFor(c => c - .FromToml(tmlTable => tmlTable.ContainsKey("Protease") ? tmlTable.Get() : throw new NotImplementedException("Placeholder for Rna Digestion Params")))) - + .FromToml(tmlTable => + tmlTable.ContainsKey("Protease") + ? tmlTable.Get() + : throw new NotImplementedException("Placeholder for Rna Digestion Params")))) ); From 9096c5c6264294da20f6b12ad5341277934dbe21 Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 8 Feb 2024 18:00:43 -0600 Subject: [PATCH 18/39] Generalized Deconvolution in MzLIb --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/CommonParameters.cs | 19 +++++++++++++++++-- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- .../Localization/LocalizationEngine.cs | 2 +- .../EngineLayer/Ms2ScanWithSpecificMass.cs | 9 +++++---- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 8 +++----- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 10 files changed, 32 insertions(+), 18 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index ebe4a9739..de67b59c9 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/CommonParameters.cs b/MetaMorpheus/EngineLayer/CommonParameters.cs index f39ff3394..0407032aa 100644 --- a/MetaMorpheus/EngineLayer/CommonParameters.cs +++ b/MetaMorpheus/EngineLayer/CommonParameters.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using Nett; using Omics.Fragmentation.Peptide; namespace EngineLayer @@ -52,7 +53,8 @@ public CommonParameters( bool assumeOrphanPeaksAreZ1Fragments = true, int maxHeterozygousVariants = 4, int minVariantDepth = 1, - bool addTruncations = false) + bool addTruncations = false, + DeconvolutionParameters deconParams = null) { TaskDescriptor = taskDescriptor; @@ -95,7 +97,19 @@ public CommonParameters( MaxHeterozygousVariants = maxHeterozygousVariants; MinVariantDepth = minVariantDepth; - AddTruncations = addTruncations; + + AddTruncations = addTruncations; if (deconParams != null) + { + DeconvolutionParameters = deconParams; + } + else + { + DeconvolutionParameters = DeconvolutionMaxAssumedChargeState < 0 + ? new ClassicDeconvolutionParameters(deconvolutionMaxAssumedChargeState, -1, + DeconvolutionMassTolerance.Value, deconvolutionIntensityRatio, Polarity.Negative) + : new ClassicDeconvolutionParameters(1, deconvolutionMaxAssumedChargeState, + DeconvolutionMassTolerance.Value, deconvolutionIntensityRatio, Polarity.Positive); + } } // Notes: @@ -114,6 +128,7 @@ public CommonParameters( public bool UseProvidedPrecursorInfo { get; private set; } public double DeconvolutionIntensityRatio { get; private set; } public int DeconvolutionMaxAssumedChargeState { get; private set; } + [TomlIgnore] public DeconvolutionParameters DeconvolutionParameters { get; private set; } public Tolerance DeconvolutionMassTolerance { get; private set; } public int TotalPartitions { get; set; } public Tolerance ProductMassTolerance { get; set; } // public setter required for calibration task diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index f73bd152a..325d357ea 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs b/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs index ed0662d46..f4b03445c 100644 --- a/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs +++ b/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs @@ -58,7 +58,7 @@ protected override MetaMorpheusEngineResults RunSpecific() for (int r = 0; r < peptide.Length; r++) { // create new PeptideWithSetMods with unidentified mass difference at the given residue - PeptideWithSetModifications peptideWithLocalizedMassDiff = peptide.Localize(r, massDifference); + var peptideWithLocalizedMassDiff = peptide.Localize(r, massDifference); // this is the list of theoretical products for this peptide with mass-difference on this residue peptideWithLocalizedMassDiff.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus, productsWithLocalizedMassDiff); diff --git a/MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs b/MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs index 394118a1e..92ac89ccb 100644 --- a/MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs +++ b/MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs @@ -56,11 +56,11 @@ public Ms2ScanWithSpecificMass(MsDataScan mzLibScan, double precursorMonoisotopi public static IsotopicEnvelope[] GetNeutralExperimentalFragments(MsDataScan scan, CommonParameters commonParam) { - int minZ = 1; - int maxZ = 10; + int maxCharge = commonParam.DeconvolutionParameters.MaxAssumedChargeState; + commonParam.DeconvolutionParameters.MaxAssumedChargeState = 10; - var neutralExperimentalFragmentMasses = scan.MassSpectrum.Deconvolute(scan.MassSpectrum.Range, - minZ, maxZ, commonParam.DeconvolutionMassTolerance.Value, commonParam.DeconvolutionIntensityRatio).ToList(); + var neutralExperimentalFragmentMasses = + Deconvoluter.Deconvolute(scan, commonParam.DeconvolutionParameters, scan.MassSpectrum.Range).ToList(); if (commonParam.AssumeOrphanPeaksAreZ1Fragments) { @@ -81,6 +81,7 @@ public static IsotopicEnvelope[] GetNeutralExperimentalFragments(MsDataScan scan } } + commonParam.DeconvolutionParameters.MaxAssumedChargeState = maxCharge; return neutralExperimentalFragmentMasses.OrderBy(p => p.MonoisotopicMass).ToArray(); } diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 99be99737..683110e0c 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index fdb61d2d4..0495cc95e 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index 8dd270e14..ed25c943c 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -165,10 +165,7 @@ public static List[] _GetMs2Scans(MsDataFile myMSDataFi if (commonParameters.DoPrecursorDeconvolution) { foreach (IsotopicEnvelope envelope in ms2scan.GetIsolatedMassesAndCharges( - precursorSpectrum.MassSpectrum, 1, - commonParameters.DeconvolutionMaxAssumedChargeState, - commonParameters.DeconvolutionMassTolerance.Value, - commonParameters.DeconvolutionIntensityRatio)) + precursorSpectrum.MassSpectrum, commonParameters.DeconvolutionParameters)) { double monoPeakMz = envelope.MonoisotopicMass.ToMz(envelope.Charge); precursors.Add((monoPeakMz, envelope.Charge)); @@ -459,7 +456,8 @@ public static CommonParameters SetAllFileSpecificCommonParams(CommonParameters c assumeOrphanPeaksAreZ1Fragments: commonParams.AssumeOrphanPeaksAreZ1Fragments, maxHeterozygousVariants: commonParams.MaxHeterozygousVariants, minVariantDepth: commonParams.MinVariantDepth, - addTruncations: commonParams.AddTruncations); + addTruncations: commonParams.AddTruncations, + deconParams: commonParams.DeconvolutionParameters); return returnParams; } diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 889bb446a..acce65680 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index bedb648ad..8ec6193cf 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From 251e86eba473c898b0c25f8fd1bb7d5d83e93b96 Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 8 Feb 2024 18:07:15 -0600 Subject: [PATCH 19/39] Updated to mzlib after decon generalization --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index d0d281642..de67b59c9 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 6740db347..325d357ea 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 392593033..683110e0c 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index c7472aefe..0495cc95e 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 0279b1ba6..acce65680 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 05e7eb14d..8ec6193cf 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From 16a1a5a5ef7f846bf53f357b06d5596e0cc9ad87 Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 8 Feb 2024 18:14:45 -0600 Subject: [PATCH 20/39] fixed issue caused by merge --- MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs b/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs index c305ca04f..139670fe2 100644 --- a/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs +++ b/MetaMorpheus/EngineLayer/ProteinParsimony/ParsimonySequence.cs @@ -1,5 +1,5 @@ using Omics; -using Proteomics.ProteolyticDigestion; +using Omics.Digestion; namespace EngineLayer.ProteinParsimony { From f650731b97bf798875b641344a2b1bc5c80e0738 Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 8 Feb 2024 18:20:34 -0600 Subject: [PATCH 21/39] updated mzlib to decon --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index 54b717e7a..de67b59c9 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 1f29bcbfa..325d357ea 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 54798ddd5..683110e0c 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index fef84664e..0495cc95e 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 77a806acf..acce65680 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 712489e0f..8ec6193cf 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From c1c578ff86bee6b84bb25cbc83fd53105ee77346 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 14 Feb 2024 10:13:47 -0600 Subject: [PATCH 22/39] updated mzlib version --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index ebe4a9739..2570c57f1 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index f73bd152a..f1d1a4102 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs b/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs index ed0662d46..f4b03445c 100644 --- a/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs +++ b/MetaMorpheus/EngineLayer/Localization/LocalizationEngine.cs @@ -58,7 +58,7 @@ protected override MetaMorpheusEngineResults RunSpecific() for (int r = 0; r < peptide.Length; r++) { // create new PeptideWithSetMods with unidentified mass difference at the given residue - PeptideWithSetModifications peptideWithLocalizedMassDiff = peptide.Localize(r, massDifference); + var peptideWithLocalizedMassDiff = peptide.Localize(r, massDifference); // this is the list of theoretical products for this peptide with mass-difference on this residue peptideWithLocalizedMassDiff.Fragment(CommonParameters.DissociationType, CommonParameters.DigestionParams.FragmentationTerminus, productsWithLocalizedMassDiff); diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 99be99737..64bb7e0f7 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index fdb61d2d4..b32fb72cc 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index 889bb446a..57b70d433 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 6ac1c6373..0404d7fb6 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From 41128eb668f80bfdfed6e7411419dc5b3eb2c723 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 14 Feb 2024 10:15:18 -0600 Subject: [PATCH 23/39] Updated mzlib --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index de67b59c9..2570c57f1 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 325d357ea..f1d1a4102 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 683110e0c..64bb7e0f7 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index 0495cc95e..b32fb72cc 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index acce65680..57b70d433 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 8ec6193cf..bb9a3927e 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From e7d56b3106199441eec38ac3070ab593119ffd82 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 14 Feb 2024 11:49:35 -0600 Subject: [PATCH 24/39] Updated nuget --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index de67b59c9..2570c57f1 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 325d357ea..f1d1a4102 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 683110e0c..64bb7e0f7 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index 0495cc95e..b32fb72cc 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index acce65680..57b70d433 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 8ec6193cf..bb9a3927e 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From 8a6725683df039571e413fc09935d980ed073f24 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 14 Feb 2024 11:54:34 -0600 Subject: [PATCH 25/39] Resolved final conflicts --- MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs | 2 +- .../GlycoSearchTask/PostGlycoSearchAnalysisTask.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs index 4bdf9092f..0a006d5fb 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs @@ -49,7 +49,7 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults) { var psms = proteasePsms.ToList(); - psms = psms.OrderByDescending(b => b.Score).ThenBy(b => b.PeptideMonisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.PeptideMonisotopicMass.Value) : double.MaxValue).ToList(); + psms = psms.OrderByDescending(b => b.Score).ThenBy(b => b.BioPolymerWithSetModsMonoisotopicMass.HasValue ? Math.Abs(b.ScanPrecursorMass - b.BioPolymerWithSetModsMonoisotopicMass.Value) : double.MaxValue).ToList(); QValueTraditional(psms); if (psms.Count > 100) diff --git a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs index 4fb015eee..ca3ac11fc 100644 --- a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs @@ -89,7 +89,7 @@ public MyTaskResults Run(string OutputFolder, List dbFilenameList, Li SingleFDRAnalysis(allPsmsOgly, commonParameters, new List { taskId }); var writtenFileOGlyco = Path.Combine(OutputFolder + "\\oglyco" + ".psmtsv"); - var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsOgly.Where(p => p.ProteinAccession != null && p.OneBasedStartResidueInProtein.HasValue).ToList()); + var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsOgly.Where(p => p.Accession != null && p.OneBasedStartResidue.HasValue).ToList()); var seen_oglyco_localization_file = Path.Combine(OutputFolder + "\\seen_oglyco_localization" + ".tsv"); WriteGlycoFile.WriteSeenProteinGlycoLocalization(ProteinLevelLocalization, seen_oglyco_localization_file); @@ -106,7 +106,7 @@ public MyTaskResults Run(string OutputFolder, List dbFilenameList, Li var writtenFileNGlyco = Path.Combine(OutputFolder + "\\nglyco" + ".psmtsv"); - var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsNgly.Where(p => p.ProteinAccession != null && p.OneBasedStartResidueInProtein.HasValue).ToList()); + var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsNgly.Where(p => p.Accession != null && p.OneBasedStartResidue.HasValue).ToList()); var seen_nglyco_localization_file = Path.Combine(OutputFolder + "\\seen_nglyco_localization" + ".tsv"); WriteGlycoFile.WriteSeenProteinGlycoLocalization(ProteinLevelLocalization, seen_nglyco_localization_file); @@ -124,7 +124,7 @@ public MyTaskResults Run(string OutputFolder, List dbFilenameList, Li var writtenFileNOGlyco = Path.Combine(OutputFolder + "\\no_glyco" + ".psmtsv"); - var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsgly.Where(p => p.ProteinAccession != null && p.OneBasedStartResidueInProtein.HasValue).ToList()); + var ProteinLevelLocalization = GlycoProteinParsimony.ProteinLevelGlycoParsimony(allPsmsgly.Where(p => p.Accession != null && p.OneBasedStartResidue.HasValue).ToList()); var seen_no_glyco_localization_file = Path.Combine(OutputFolder + "\\seen_no_glyco_localization" + ".tsv"); WriteGlycoFile.WriteSeenProteinGlycoLocalization(ProteinLevelLocalization, seen_no_glyco_localization_file); From e340d5b22d7b4d8d0405a1478102500bcab73a67 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 14 Feb 2024 11:56:07 -0600 Subject: [PATCH 26/39] updated mzlib --- MetaMorpheus/CMD/CMD.csproj | 2 +- MetaMorpheus/EngineLayer/EngineLayer.csproj | 2 +- MetaMorpheus/GUI/GUI.csproj | 2 +- MetaMorpheus/GuiFunctions/GuiFunctions.csproj | 2 +- MetaMorpheus/TaskLayer/TaskLayer.csproj | 2 +- MetaMorpheus/Test/Test.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/CMD/CMD.csproj b/MetaMorpheus/CMD/CMD.csproj index de67b59c9..2570c57f1 100644 --- a/MetaMorpheus/CMD/CMD.csproj +++ b/MetaMorpheus/CMD/CMD.csproj @@ -24,7 +24,7 @@ - + diff --git a/MetaMorpheus/EngineLayer/EngineLayer.csproj b/MetaMorpheus/EngineLayer/EngineLayer.csproj index 325d357ea..f1d1a4102 100644 --- a/MetaMorpheus/EngineLayer/EngineLayer.csproj +++ b/MetaMorpheus/EngineLayer/EngineLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/GUI/GUI.csproj b/MetaMorpheus/GUI/GUI.csproj index 683110e0c..64bb7e0f7 100644 --- a/MetaMorpheus/GUI/GUI.csproj +++ b/MetaMorpheus/GUI/GUI.csproj @@ -55,7 +55,7 @@ - + diff --git a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj index 0495cc95e..b32fb72cc 100644 --- a/MetaMorpheus/GuiFunctions/GuiFunctions.csproj +++ b/MetaMorpheus/GuiFunctions/GuiFunctions.csproj @@ -14,7 +14,7 @@ - + diff --git a/MetaMorpheus/TaskLayer/TaskLayer.csproj b/MetaMorpheus/TaskLayer/TaskLayer.csproj index acce65680..57b70d433 100644 --- a/MetaMorpheus/TaskLayer/TaskLayer.csproj +++ b/MetaMorpheus/TaskLayer/TaskLayer.csproj @@ -21,7 +21,7 @@ - + diff --git a/MetaMorpheus/Test/Test.csproj b/MetaMorpheus/Test/Test.csproj index 8ec6193cf..bb9a3927e 100644 --- a/MetaMorpheus/Test/Test.csproj +++ b/MetaMorpheus/Test/Test.csproj @@ -23,7 +23,7 @@ - + From 4c23ce7003d657db84eb17b0b1f8448176e64ff3 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 21 Feb 2024 13:17:11 -0600 Subject: [PATCH 27/39] Removed decon tolerance and ratio from toml --- MetaMorpheus/EngineLayer/CommonParameters.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MetaMorpheus/EngineLayer/CommonParameters.cs b/MetaMorpheus/EngineLayer/CommonParameters.cs index ceba2d47d..426673c14 100644 --- a/MetaMorpheus/EngineLayer/CommonParameters.cs +++ b/MetaMorpheus/EngineLayer/CommonParameters.cs @@ -125,10 +125,10 @@ public CommonParameters( public IEnumerable<(string, string)> ListOfModsVariable { get; private set; } public bool DoPrecursorDeconvolution { get; private set; } public bool UseProvidedPrecursorInfo { get; private set; } - public double DeconvolutionIntensityRatio { get; private set; } + [TomlIgnore] public double DeconvolutionIntensityRatio { get; private set; } public int DeconvolutionMaxAssumedChargeState { get; private set; } [TomlIgnore] public DeconvolutionParameters DeconvolutionParameters { get; private set; } - public Tolerance DeconvolutionMassTolerance { get; private set; } + [TomlIgnore] public Tolerance DeconvolutionMassTolerance { get; private set; } public int TotalPartitions { get; set; } public Tolerance ProductMassTolerance { get; set; } // public setter required for calibration task public Tolerance PrecursorMassTolerance { get; set; } // public setter required for calibration task From 05ab191c7e311a50cf0a00db29f908f11c96b189 Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 27 Feb 2024 11:52:43 -0600 Subject: [PATCH 28/39] Updated classes after merge --- MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs | 1 - .../EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs | 1 + .../SpectralLibrarySearch/SpectralLibrarySearchFunction.cs | 1 + MetaMorpheus/TaskLayer/MetaMorpheusTask.cs | 3 ++- .../TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs b/MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs index 06501cdac..cae69a9bc 100644 --- a/MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs +++ b/MetaMorpheus/EngineLayer/Ms2ScanWithSpecificMass.cs @@ -78,7 +78,6 @@ public static IsotopicEnvelope[] GetNeutralExperimentalFragments(MsDataScan scan } } - commonParam.DeconvolutionParameters.MaxAssumedChargeState = maxCharge; return neutralExperimentalFragmentMasses.OrderBy(p => p.MonoisotopicMass).ToArray(); } diff --git a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs index ad060100a..c1eef796b 100644 --- a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs +++ b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrary.cs @@ -10,6 +10,7 @@ using System.Text.RegularExpressions; using Easy.Common.Extensions; using Omics.Fragmentation.Peptide; +using Omics.SpectrumMatch; using ThermoFisher.CommonCore.Data.Business; namespace EngineLayer diff --git a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrarySearchFunction.cs b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrarySearchFunction.cs index d35be53c6..10bf04fd6 100644 --- a/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrarySearchFunction.cs +++ b/MetaMorpheus/EngineLayer/SpectralLibrarySearch/SpectralLibrarySearchFunction.cs @@ -9,6 +9,7 @@ using Easy.Common.Extensions; using MassSpectrometry.MzSpectra; using Omics; +using Omics.SpectrumMatch; namespace EngineLayer { diff --git a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs index 2c6111dbf..611c062d2 100644 --- a/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs +++ b/MetaMorpheus/TaskLayer/MetaMorpheusTask.cs @@ -457,7 +457,8 @@ public static CommonParameters SetAllFileSpecificCommonParams(CommonParameters c maxHeterozygousVariants: commonParams.MaxHeterozygousVariants, minVariantDepth: commonParams.MinVariantDepth, addTruncations: commonParams.AddTruncations, - precursorDeconParams: commonParams.PrecursorDeconvolutionParameters); + precursorDeconParams: commonParams.PrecursorDeconvolutionParameters, + productDeconParams: commonParams.ProductDeconvolutionParameters ); return returnParams; } diff --git a/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs index 0c3eec775..547573773 100644 --- a/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/XLSearchTask/PostXLSearchAnalysisTask.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using Omics.Modifications; +using Omics.SpectrumMatch; namespace TaskLayer { From fe8ac9807ef2e55d1f8399400229bafab7eb58cb Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 27 Feb 2024 13:08:49 -0600 Subject: [PATCH 29/39] Made changes for code coverage --- .../EngineLayer/OligoSpectralMatch.cs | 26 +++++++++++++++++++ .../EngineLayer/PeptideSpectralMatch.cs | 16 ------------ 2 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 MetaMorpheus/EngineLayer/OligoSpectralMatch.cs diff --git a/MetaMorpheus/EngineLayer/OligoSpectralMatch.cs b/MetaMorpheus/EngineLayer/OligoSpectralMatch.cs new file mode 100644 index 000000000..d32130288 --- /dev/null +++ b/MetaMorpheus/EngineLayer/OligoSpectralMatch.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using Omics; +using Omics.Fragmentation; + +namespace EngineLayer; + +/// +/// Placeholder class for when RNA code gets fully incorporated +/// +[ExcludeFromCodeCoverage] +public class OligoSpectralMatch : SpectralMatch +{ + public OligoSpectralMatch(IBioPolymerWithSetMods peptide, int notch, double score, int scanIndex, + Ms2ScanWithSpecificMass scan, CommonParameters commonParameters, + List matchedFragmentIons, double xcorr = 0) : base(peptide, notch, score, scanIndex, + scan, commonParameters, matchedFragmentIons, xcorr) + { + + } + + protected OligoSpectralMatch(SpectralMatch psm, List<(int Notch, IBioPolymerWithSetMods Peptide)> bestMatchingPeptides) + : base(psm, bestMatchingPeptides) + { + } +} \ No newline at end of file diff --git a/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs b/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs index 89fd15e45..ea67808f1 100644 --- a/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs @@ -56,20 +56,4 @@ protected PeptideSpectralMatch(SpectralMatch psm, List<(int Notch, IBioPolymerWi #endregion } - - public class OligoSpectralMatch : SpectralMatch - { - public OligoSpectralMatch(IBioPolymerWithSetMods peptide, int notch, double score, int scanIndex, - Ms2ScanWithSpecificMass scan, CommonParameters commonParameters, - List matchedFragmentIons, double xcorr = 0) : base(peptide, notch, score, scanIndex, - scan, commonParameters, matchedFragmentIons, xcorr) - { - - } - - protected OligoSpectralMatch(SpectralMatch psm, List<(int Notch, IBioPolymerWithSetMods Peptide)> bestMatchingPeptides) - : base(psm, bestMatchingPeptides) - { - } - } } From 2a24fc23b77d75d1be6d871fca03654dc53dd22b Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 27 Feb 2024 14:08:16 -0600 Subject: [PATCH 30/39] Added test coverage to the bin class --- MetaMorpheus/Test/BinGenerationTest.cs | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/MetaMorpheus/Test/BinGenerationTest.cs b/MetaMorpheus/Test/BinGenerationTest.cs index 47cde2c42..703f9c9a7 100644 --- a/MetaMorpheus/Test/BinGenerationTest.cs +++ b/MetaMorpheus/Test/BinGenerationTest.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using EngineLayer.HistogramAnalysis; using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; @@ -139,5 +140,36 @@ public static void TestProteinSplitAcrossFiles() File.Delete(mzmlFilePath2); Directory.Delete(Path.Combine(TestContext.CurrentContext.TestDirectory, @"Task Settings"), true); } + + + [Test] + public static void TestBin_IdentifyAA() + { + var bin = new Bin(71); + bin.IdentifyAA(1); + Assert.AreEqual("Add Alanine", bin.AA); + + bin = new Bin(-56.1); + bin.IdentifyAA(1); + Assert.AreEqual("Remove Glycine", bin.AA); + + + bin = new Bin(114.102); + bin.IdentifyAA(1); + Assert.AreEqual("Add Aspartic Acid|Add (Glycine+Glycine)|Add Asparagine", bin.AA); + + bin = new Bin(-142.156); + bin.IdentifyAA(1); + Assert.AreEqual("Remove (Alanine+Alanine)", bin.AA); + } + + [Test] + public static void TestBin_IdentifyUnimodBins() + { + var bin = new Bin(77.987066); + bin.IdentifyUnimodBins(0.001); + Assert.AreEqual("Methylphosphonate on Y|Methylphosphonate on T|Methylphosphonate on S", bin.UnimodId); + Assert.AreEqual("CH3O2P", bin.UnimodFormulas); + } } } \ No newline at end of file From ab456b3c586ba7a7678e239c45328b161e1aefa7 Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 27 Feb 2024 15:37:41 -0600 Subject: [PATCH 31/39] Idk man its like 0.02% coverage --- MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs b/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs index ea119c94f..07b360557 100644 --- a/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs +++ b/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs @@ -158,15 +158,12 @@ public void IdentifyUnimodBins(double v) var ok = new HashSet(); var okformula = new HashSet(); var okDiff = new HashSet(); - foreach (var hm in GlobalVariables.UnimodDeserialized) + foreach (Modification theMod in GlobalVariables.UnimodDeserialized) { - var theMod = hm as Modification; - if (Math.Abs(theMod.MonoisotopicMass.Value - MassShift) <= v) - { - ok.Add(hm.IdWithMotif); - okformula.Add(theMod.ChemicalFormula.Formula); - okDiff.Add(theMod.MonoisotopicMass.Value - MassShift); - } + if (!(Math.Abs(theMod.MonoisotopicMass.Value - MassShift) <= v)) continue; + ok.Add(theMod.IdWithMotif); + okformula.Add(theMod.ChemicalFormula.Formula); + okDiff.Add(theMod.MonoisotopicMass.Value - MassShift); } UnimodId = string.Join("|", ok); UnimodFormulas = string.Join("|", okformula); From 04fd9bb48e017ec729ad2cbed51c2b6910391e3d Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 27 Feb 2024 16:07:48 -0600 Subject: [PATCH 32/39] helpme.jpg --- .../EngineLayer/HistogramAnalysis/Bin.cs | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs b/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs index 07b360557..24d601890 100644 --- a/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs +++ b/MetaMorpheus/EngineLayer/HistogramAnalysis/Bin.cs @@ -132,22 +132,18 @@ public void IdentifyAA(double v) var ok = new HashSet(); for (char c = 'A'; c <= 'Z'; c++) { - if (Residue.TryGetResidue(c, out Residue residue)) + if (!Residue.TryGetResidue(c, out Residue residue)) continue; + if (Math.Abs(residue.MonoisotopicMass - MassShift) <= v) + ok.Add("Add " + residue.Name); + if (Math.Abs(residue.MonoisotopicMass + MassShift) <= v) + ok.Add("Remove " + residue.Name); + for (char cc = 'A'; cc <= 'Z'; cc++) { - if (Math.Abs(residue.MonoisotopicMass - MassShift) <= v) - ok.Add("Add " + residue.Name); - if (Math.Abs(residue.MonoisotopicMass + MassShift) <= v) - ok.Add("Remove " + residue.Name); - for (char cc = 'A'; cc <= 'Z'; cc++) - { - if (Residue.TryGetResidue(cc, out Residue residueCC)) - { - if (Math.Abs(residueCC.MonoisotopicMass + residue.MonoisotopicMass - MassShift) <= v) - ok.Add("Add (" + residue.Name + "+" + residueCC.Name + ")"); - if (Math.Abs(residueCC.MonoisotopicMass + residue.MonoisotopicMass + MassShift) <= v) - ok.Add("Remove (" + residue.Name + "+" + residueCC.Name + ")"); - } - } + if (!Residue.TryGetResidue(cc, out Residue residueCC)) continue; + if (Math.Abs(residueCC.MonoisotopicMass + residue.MonoisotopicMass - MassShift) <= v) + ok.Add("Add (" + residue.Name + "+" + residueCC.Name + ")"); + if (Math.Abs(residueCC.MonoisotopicMass + residue.MonoisotopicMass + MassShift) <= v) + ok.Add("Remove (" + residue.Name + "+" + residueCC.Name + ")"); } } AA = string.Join("|", ok); From 2012fc3ce9d9622b05a6650f1117cc1a3095b5b8 Mon Sep 17 00:00:00 2001 From: nbollis Date: Thu, 7 Mar 2024 12:19:09 -0600 Subject: [PATCH 33/39] fixed errors in merge --- MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs | 2 +- .../EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs | 2 +- MetaMorpheus/EngineLayer/SpectralMatch.cs | 3 ++- .../GlycoSearchTask/PostGlycoSearchAnalysisTask.cs | 7 ++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs index 9290f2d52..3a92891ab 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs @@ -226,7 +226,7 @@ public static void Compute_PEPValue_Based_QValue(List psms) public void CountPsm() { - var psmsGroupedByProtease = AllPsms.GroupBy(p => p.DigestionParams.Protease); + var psmsGroupedByProtease = AllPsms.GroupBy(p => p.DigestionParams.DigestionAgent); foreach (var proteasePsms in psmsGroupedByProtease) { diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs index 15282674e..bdce120ba 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/PEPValueAnalysisGeneric.cs @@ -745,7 +745,7 @@ public static PsmData CreateOnePsmDataEntry(string searchType, List<(string file hasSpectralAngle = 1; } - if (psm.DigestionParams.Protease.Name != "top-down") + if (psm.DigestionParams.DigestionAgent.Name != "top-down") { missedCleavages = selectedPeptide.MissedCleavages; bool fileIsCzeSeparationType = fileSpecificParameters.Any(p => Path.GetFileName(p.fileName) == Path.GetFileName(psm.FullFilePath) && p.fileSpecificParameters.SeparationType == "CZE"); diff --git a/MetaMorpheus/EngineLayer/SpectralMatch.cs b/MetaMorpheus/EngineLayer/SpectralMatch.cs index dd28b3e84..9a3d2b68b 100644 --- a/MetaMorpheus/EngineLayer/SpectralMatch.cs +++ b/MetaMorpheus/EngineLayer/SpectralMatch.cs @@ -8,6 +8,7 @@ using System.Linq; using Omics; using System; +using Omics.Digestion; namespace EngineLayer { @@ -102,7 +103,7 @@ public List PrecursorMassErrorPpm } #region Search - public DigestionParams DigestionParams { get; } + public IDigestionParams DigestionParams { get; } public Dictionary> BioPolymersWithSetModsToMatchingFragments { get; private set; } protected List<(int Notch, IBioPolymerWithSetMods Pwsm)> _BestMatchingBioPolymersWithSetMods; diff --git a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs index 6578a1790..28b851e94 100644 --- a/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs +++ b/MetaMorpheus/TaskLayer/GlycoSearchTask/PostGlycoSearchAnalysisTask.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using FlashLFQ; +using Omics.Digestion; using Omics.Modifications; using Omics.SpectrumMatch; using pepXML.Generated; @@ -422,8 +423,8 @@ private void QuantificationAnalysis() // the peptides should still be quantified but not considered for protein quantification var undefinedPg = new FlashLFQ.ProteinGroup("UNDEFINED", "", ""); //sort the unambiguous psms by protease to make MBR compatible with multiple proteases - Dictionary> proteaseSortedPsms = new Dictionary>(); - Dictionary proteaseSortedFlashLFQResults = new Dictionary(); + Dictionary> proteaseSortedPsms = new Dictionary>(); + Dictionary proteaseSortedFlashLFQResults = new Dictionary(); foreach (DigestionParams dp in Parameters.ListOfDigestionParams) { @@ -439,7 +440,7 @@ private void QuantificationAnalysis() psmToProteinGroups.Add(psm, new List { undefinedPg }); } - proteaseSortedPsms[psm.DigestionParams.Protease].Add(psm); + proteaseSortedPsms[psm.DigestionParams.DigestionAgent].Add(psm); } // pass PSM info to FlashLFQ From cab9e105026ff6102187cffc5b2a65bbd852484c Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 9 Apr 2024 13:47:20 -0500 Subject: [PATCH 34/39] Merged in changes --- .../FdrAnalysis/FdrAnalysisEngine.cs | 93 +++++---------- .../EngineLayer/PsmTsv/PsmTsvWriter.cs | 3 +- .../Test/MultiProteaseParsimonyTest.cs | 9 +- MetaMorpheus/Test/PeptideSpectralMatchTest.cs | 102 +++++++++++++++++ .../Test/PostSearchAnalysisTaskTests.cs | 38 +++---- MetaMorpheus/Test/PsvTsvTest.cs | 106 +++++++++++++++++- MetaMorpheus/Test/SearchTaskTest.cs | 2 +- MetaMorpheus/Test/TestPsm.cs | 20 ++-- 8 files changed, 268 insertions(+), 105 deletions(-) create mode 100644 MetaMorpheus/Test/PeptideSpectralMatchTest.cs diff --git a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs index 3a92891ab..4e27dfe2a 100644 --- a/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs +++ b/MetaMorpheus/EngineLayer/FdrAnalysis/FdrAnalysisEngine.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; +using EngineLayer; +using EngineLayer.FdrAnalysis; namespace EngineLayer.FdrAnalysis { @@ -10,13 +12,13 @@ public class FdrAnalysisEngine : MetaMorpheusEngine private readonly int MassDiffAcceptorNumNotches; private readonly double ScoreCutoff; private readonly string AnalysisType; - private readonly string OutputFolder; // used for storing PEP training models + private readonly string OutputFolder; // used for storing PEP training models private readonly bool DoPEP; public FdrAnalysisEngine(List psms, int massDiffAcceptorNumNotches, CommonParameters commonParameters, List<(string fileName, CommonParameters fileSpecificParameters)> fileSpecificParameters, List nestedIds, string analysisType = "PSM", bool doPEP = true, string outputFolder = null) : base(commonParameters, fileSpecificParameters, nestedIds) { - AllPsms = psms.OrderByDescending(p=>p).ToList(); + AllPsms = psms.OrderByDescending(p => p).ToList(); MassDiffAcceptorNumNotches = massDiffAcceptorNumNotches; ScoreCutoff = commonParameters.ScoreCutoff; AnalysisType = analysisType; @@ -52,50 +54,14 @@ private void DoFalseDiscoveryRateAnalysis(FdrAnalysisResults myAnalysisResults) QValueTraditional(psms); if (psms.Count > 100) { - QValueInverted(psms); - } - - // set q-value thresholds such that a lower scoring PSM can't have - // a higher confidence than a higher scoring PSM - //Populate min qValues - double qValueThreshold = 1.0; - double[] qValueNotchThreshold = new double[MassDiffAcceptorNumNotches + 1]; - for (int i = 0; i < qValueNotchThreshold.Length; i++) - { - qValueNotchThreshold[i] = 1.0; - } - - for (int i = psms.Count - 1; i >= 0; i--) - { - SpectralMatch psm = psms[i]; - - // threshold q-values - if (psm.FdrInfo.QValue > qValueThreshold) + if (DoPEP) { - psm.FdrInfo.QValue = qValueThreshold; - } - else if (psm.FdrInfo.QValue < qValueThreshold) - { - qValueThreshold = psm.FdrInfo.QValue; - } - - // threshold notch q-values - int notch = psm.Notch ?? MassDiffAcceptorNumNotches; - if (psm.FdrInfo.QValueNotch > qValueNotchThreshold[notch]) - { - psm.FdrInfo.QValueNotch = qValueNotchThreshold[notch]; - } - else if (psm.FdrInfo.QValueNotch < qValueNotchThreshold[notch]) - { - qValueNotchThreshold[notch] = psm.FdrInfo.QValueNotch; + Compute_PEPValue(myAnalysisResults); } + QValueInverted(psms); } + CountPsm(psms); } - if (DoPEP) - { - Compute_PEPValue(myAnalysisResults); - } - CountPsm(); } private static void QValueInverted(List psms) @@ -194,7 +160,6 @@ public void Compute_PEPValue(FdrAnalysisResults myAnalysisResults) Compute_PEPValue_Based_QValue(AllPsms); } - CountPsm(); // recounting Psm's after PEP based disambiguation } if (AnalysisType == "Peptide") @@ -223,35 +188,31 @@ public static void Compute_PEPValue_Based_QValue(List psms) psms[psmsArrayIndicies[i]].FdrInfo.PEP_QValue = Math.Round(qValue, 6); } } - - public void CountPsm() + /// + /// This method gets the count of PSMs with the same full sequence (with q-value < 0.01) to include in the psmtsv output + /// + public void CountPsm(List proteasePsms) { - var psmsGroupedByProtease = AllPsms.GroupBy(p => p.DigestionParams.DigestionAgent); + // exclude ambiguous psms and has a fdr cutoff = 0.01 + var allUnambiguousPsms = proteasePsms.Where(psm => psm.FullSequence != null).ToList(); - foreach (var proteasePsms in psmsGroupedByProtease) - { - // exclude ambiguous psms and has a fdr cutoff = 0.01 - var allUnambiguousProteasePsms = proteasePsms.Where(p => p.FullSequence != null).ToList(); + var unambiguousPsmsLessThanOnePercentFdr = allUnambiguousPsms.Where(psm => + psm.FdrInfo.QValue <= 0.01 + && psm.FdrInfo.QValueNotch <= 0.01) + .GroupBy(p => p.FullSequence); - var fullSequenceGroups = allUnambiguousProteasePsms.Where(p => p.FdrInfo.QValue < 0.01 && p.FdrInfo.QValueNotch < 0.01) - .Select(p => p.FullSequence).GroupBy(s => s); + Dictionary sequenceToPsmCount = new Dictionary(); - Dictionary sequenceToPsmCount = new Dictionary(); - foreach (var fullSequence in fullSequenceGroups) - { - sequenceToPsmCount.Add(fullSequence.Key, fullSequence.Count()); - } + foreach (var sequenceGroup in unambiguousPsmsLessThanOnePercentFdr) + { + sequenceToPsmCount.TryAdd(sequenceGroup.First().FullSequence, sequenceGroup.Count()); + } - foreach (SpectralMatch psm in allUnambiguousProteasePsms) + foreach (SpectralMatch psm in allUnambiguousPsms) + { + if (sequenceToPsmCount.TryGetValue(psm.FullSequence, out int count)) { - if (sequenceToPsmCount.TryGetValue(psm.FullSequence, out int count)) - { - psm.PsmCount = count; - } - else - { - psm.PsmCount = 0; - } + psm.PsmCount = count; } } } diff --git a/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs b/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs index 07ec02dd0..0c304095f 100644 --- a/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs +++ b/MetaMorpheus/EngineLayer/PsmTsv/PsmTsvWriter.cs @@ -10,6 +10,7 @@ using Omics; using Omics.Modifications; + namespace EngineLayer { public static class PsmTsvWriter @@ -216,7 +217,7 @@ internal static void AddPeptideSequenceData(Dictionary s, Spectr .Where(d => Includes(b, d)) .Select(d => $"{d.OneBasedBeginPosition.ToString()}-{d.OneBasedEndPosition.ToString()}")))).ResolvedString; } - + s[PsmTsvHeader.Contaminant] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Parent.IsContaminant ? "Y" : "N")).ResolvedString; s[PsmTsvHeader.Decoy] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Parent.IsDecoy ? "Y" : "N")).ResolvedString; s[PsmTsvHeader.PeptideDesicription] = pepWithModsIsNull ? " " : Resolve(pepsWithMods.Select(b => b.Description)).ResolvedString; diff --git a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs index d1a0fd1e3..789b90f22 100644 --- a/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs +++ b/MetaMorpheus/Test/MultiProteaseParsimonyTest.cs @@ -991,7 +991,7 @@ public static void MultiProteaseParsimony_TestingGreedyAlgorithm() } /// - /// This test ensures that FDR for each psm is calculated accoriding to its protease + /// This test ensures that FDR for each psm is calculated according to its protease /// [Test] public static void MultiProteaseParsimony_TestingProteaseSpecificFDRCalculations() @@ -1033,16 +1033,15 @@ public static void MultiProteaseParsimony_TestingProteaseSpecificFDRCalculations new FdrAnalysisEngine(psms, 0, new CommonParameters(), fsp, new List()).Run(); psms = psms.OrderByDescending(p => p.Score).ToList(); - Assert.AreEqual(0.00, Math.Round(psms[0].FdrInfo.QValue, 2)); Assert.AreEqual(0.00, Math.Round(psms[1].FdrInfo.QValue, 2)); Assert.AreEqual(0.00, Math.Round(psms[2].FdrInfo.QValue, 2)); Assert.AreEqual(0.00, Math.Round(psms[3].FdrInfo.QValue, 2)); - Assert.AreEqual(0.33, Math.Round(psms[4].FdrInfo.QValue, 2)); + Assert.AreEqual(0.5, Math.Round(psms[4].FdrInfo.QValue, 2)); Assert.AreEqual(0.33, Math.Round(psms[5].FdrInfo.QValue, 2)); Assert.AreEqual(0.00, Math.Round(psms[6].FdrInfo.QValue, 2)); Assert.AreEqual(0.33, Math.Round(psms[7].FdrInfo.QValue, 2)); - Assert.AreEqual(0.50, Math.Round(psms[8].FdrInfo.QValue, 2)); - Assert.AreEqual(0.50, Math.Round(psms[9].FdrInfo.QValue, 2)); + Assert.AreEqual(0.67, Math.Round(psms[8].FdrInfo.QValue, 2)); + Assert.AreEqual(0.5, Math.Round(psms[9].FdrInfo.QValue, 2)); } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/PeptideSpectralMatchTest.cs b/MetaMorpheus/Test/PeptideSpectralMatchTest.cs new file mode 100644 index 000000000..6d3f3cd5e --- /dev/null +++ b/MetaMorpheus/Test/PeptideSpectralMatchTest.cs @@ -0,0 +1,102 @@ +using EngineLayer; +using MassSpectrometry; +using NUnit.Framework; +using Proteomics.ProteolyticDigestion; +using Proteomics; +using System; +using System.Collections.Generic; +using Omics.Digestion; +using Omics.Fragmentation; +using Omics.Modifications; + +namespace Test +{ + [TestFixture] + internal class PeptideSpectralMatchTest + { + [Test] + public static void GetAminoAcidCoverageTest() + { + CommonParameters commonParams = new CommonParameters(digestionParams: new DigestionParams(protease: "trypsin", minPeptideLength: 1)); + + MsDataScan scanNumberOne = new MsDataScan(new MzSpectrum(new double[] { 10 }, new double[] { 1 }, false), 1, 2, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", 10, 2, 100, double.NaN, null, DissociationType.AnyActivationType, 0, null); + + Ms2ScanWithSpecificMass ms2ScanOneMzTen = new Ms2ScanWithSpecificMass(scanNumberOne, 10, 2, "File", new CommonParameters()); + + string sequence = ""; + Dictionary allKnownMods = new(); + int numFixedMods = 0; + DigestionParams digestionParams = new DigestionParams(); + Protein myProtein = new Protein(sequence, "ACCESSION"); + int oneBasedStartResidueInProtein = 0; + int oneBasedEndResidueInProtein = Math.Max(sequence.Length, 0); + int missedCleavages = 0; + CleavageSpecificity cleavageSpecificity = CleavageSpecificity.Full; + string peptideDescription = null; + int? pairedTargetDecoyHash = null; + + PeptideWithSetModifications pwsmNoBaseSequence = new(sequence, allKnownMods, numFixedMods, digestionParams, myProtein, + oneBasedStartResidueInProtein, oneBasedEndResidueInProtein, missedCleavages, cleavageSpecificity, + peptideDescription, pairedTargetDecoyHash); + PeptideSpectralMatch psmNoBaseSequenceNoMFI = new(pwsmNoBaseSequence, 0, 10, 0, ms2ScanOneMzTen, commonParams, + new List()); + psmNoBaseSequenceNoMFI.ResolveAllAmbiguities(); + + //PSM has neither sequence nor matched fragment ions + var b = psmNoBaseSequenceNoMFI.BaseSequence; + Assert.AreEqual("", b); + var m = psmNoBaseSequenceNoMFI.MatchedFragmentIons; + Assert.AreEqual(0, m.Count); + psmNoBaseSequenceNoMFI.GetAminoAcidCoverage(); + + sequence = "PEPTIDE"; + oneBasedEndResidueInProtein = Math.Max(sequence.Length, 0); + myProtein = new Protein(sequence, "ACCESSION"); + PeptideWithSetModifications pwsmBaseSequence = new(sequence, allKnownMods, numFixedMods, digestionParams, myProtein, + oneBasedStartResidueInProtein, oneBasedEndResidueInProtein, missedCleavages, cleavageSpecificity, + peptideDescription, pairedTargetDecoyHash); + PeptideSpectralMatch psmBaseSequenceNoMFI = new(pwsmBaseSequence, 0, 10, 0, ms2ScanOneMzTen, commonParams, + new List()); + + //PSM has sequence but does not have matched fragment ions + psmBaseSequenceNoMFI.ResolveAllAmbiguities(); + b = psmBaseSequenceNoMFI.BaseSequence; + Assert.AreEqual(sequence, b); + m = psmBaseSequenceNoMFI.MatchedFragmentIons; + Assert.AreEqual(0, m.Count); + psmBaseSequenceNoMFI.GetAminoAcidCoverage(); + + //PSM has no sequence but does have matched fragment ions + Product ntProduct = new Product(ProductType.y, FragmentationTerminus.N, 1, 1, 1, 0); + MatchedFragmentIon mfi = new(ntProduct, 1, 1, 1); + List mfiList = new List() { mfi }; + PeptideSpectralMatch psmNoBaseSequenceMFI = new(pwsmNoBaseSequence, 0, 10, 0, ms2ScanOneMzTen, commonParams, + mfiList); + psmNoBaseSequenceMFI.ResolveAllAmbiguities(); + + b = psmNoBaseSequenceMFI.BaseSequence; + Assert.AreEqual("", b); + m = psmNoBaseSequenceMFI.MatchedFragmentIons; + Assert.AreEqual(1, m.Count); + psmNoBaseSequenceMFI.GetAminoAcidCoverage(); + + //PSM has sequence and matched fragment ions + PeptideSpectralMatch psmBaseSequenceMFI = new(pwsmBaseSequence, 0, 10, 0, ms2ScanOneMzTen, commonParams, + mfiList); + psmBaseSequenceMFI.ResolveAllAmbiguities(); + + b = psmBaseSequenceMFI.BaseSequence; + Assert.AreEqual("PEPTIDE", b); + m = psmBaseSequenceMFI.MatchedFragmentIons; + Assert.AreEqual(1, m.Count); + psmBaseSequenceMFI.GetAminoAcidCoverage(); + + List psms = new List() { psmNoBaseSequenceNoMFI, psmBaseSequenceNoMFI, psmNoBaseSequenceMFI, psmBaseSequenceMFI }; + + foreach (var psm in psms) + { + psm.ToString(); + } + } + } +} \ No newline at end of file diff --git a/MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs b/MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs index 7b20f2fe2..140903d0a 100644 --- a/MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs +++ b/MetaMorpheus/Test/PostSearchAnalysisTaskTests.cs @@ -34,7 +34,7 @@ public static void AllResultsAndResultsTxtTests() // identified across all files. int TaGe_SA_A549_3_snip_2ExpectedPsms = 214; int TaGe_SA_A549_3_snip_2ExpectedPeptides = 174; - + Assert.AreEqual("All target PSMs with q-value = 0.01: 428", allResults[12]); Assert.AreEqual("All target peptides with q-value = 0.01 : 174", allResults[13]); @@ -42,7 +42,7 @@ public static void AllResultsAndResultsTxtTests() Assert.AreEqual("TaGe_SA_A549_3_snip target PSMs with q-value = 0.01: 214", allResults[18]); Assert.AreEqual("Target protein groups within 1 % FDR in TaGe_SA_A549_3_snip: 165", allResults[24]); Assert.AreEqual("TaGe_SA_A549_3_snip Target peptides with q-value = 0.01 : 174", allResults[26]); - + Assert.AreEqual("TaGe_SA_A549_3_snip_2 target PSMs with q-value = 0.01: " + TaGe_SA_A549_3_snip_2ExpectedPsms, allResults[22]); Assert.AreEqual("TaGe_SA_A549_3_snip_2 Target peptides with q-value = 0.01 : " + TaGe_SA_A549_3_snip_2ExpectedPeptides, allResults[28]); Assert.AreEqual("Target protein groups within 1 % FDR in TaGe_SA_A549_3_snip_2: 165", allResults[25]); @@ -59,7 +59,7 @@ public static void AllResultsAndResultsTxtTests() Assert.AreEqual("TaGe_SA_A549_3_snip_2 target PSMs with q-value = 0.01: " + TaGe_SA_A549_3_snip_2ExpectedPsms, results[17]); Assert.AreEqual("TaGe_SA_A549_3_snip_2 Target peptides with q-value = 0.01 : " + TaGe_SA_A549_3_snip_2ExpectedPeptides, results[23]); - + Directory.Delete(outputFolder, true); @@ -71,9 +71,9 @@ public static void AllResultsAndResultsTxtTests() engineToml.Run(); string[] singleFileResults = File.ReadAllLines(resultsFile); - Assert.AreEqual("All target PSMs with q-value = 0.01: " + TaGe_SA_A549_3_snip_2ExpectedPsms, singleFileResults[7]); - Assert.AreEqual("All target peptides with q-value = 0.01 : " + TaGe_SA_A549_3_snip_2ExpectedPeptides, singleFileResults[8]); - Assert.AreEqual("All target protein groups with q-value = 0.01 (1% FDR): 165", singleFileResults[9]); + Assert.AreEqual("All target PSMs with q-value = 0.01: " + TaGe_SA_A549_3_snip_2ExpectedPsms, singleFileResults[7]); + Assert.AreEqual("All target peptides with q-value = 0.01 : " + TaGe_SA_A549_3_snip_2ExpectedPeptides, singleFileResults[8]); + Assert.AreEqual("All target protein groups with q-value = 0.01 (1% FDR): 165", singleFileResults[9]); //Second test that AllResults and Results display correct numbers of peptides and psms with PEP q-value filter on myTomlPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\Task2-SearchTaskconfig.toml"); @@ -83,30 +83,30 @@ public static void AllResultsAndResultsTxtTests() allResultsFile = Path.Combine(outputFolder, "allResults.txt"); allResults = File.ReadAllLines(allResultsFile); - Assert.AreEqual("All target PSMs with pep q-value = 0.01: 499", allResults[12]); - Assert.AreEqual("All target peptides with pep q-value = 0.01 : 179", allResults[13]); + Assert.AreEqual("All target PSMs with pep q-value = 0.01: 501", allResults[12]); + Assert.AreEqual("All target peptides with pep q-value = 0.01 : 182", allResults[13]); Assert.AreEqual("All target protein groups with q-value = 0.01 (1% FDR): 165", allResults[14]); - Assert.AreEqual("TaGe_SA_A549_3_snip target PSMs with pep q-value = 0.01: 230", allResults[18]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 target PSMs with pep q-value = 0.01: 230", allResults[22]); + Assert.AreEqual("TaGe_SA_A549_3_snip target PSMs with pep q-value = 0.01: 233", allResults[18]); + Assert.AreEqual("TaGe_SA_A549_3_snip_2 target PSMs with pep q-value = 0.01: 233", allResults[22]); Assert.AreEqual("Target protein groups within 1 % FDR in TaGe_SA_A549_3_snip: 165", allResults[24]); Assert.AreEqual("Target protein groups within 1 % FDR in TaGe_SA_A549_3_snip_2: 165", allResults[25]); - Assert.AreEqual("TaGe_SA_A549_3_snip Target peptides with pep q-value = 0.01 : 179", allResults[26]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 Target peptides with pep q-value = 0.01 : 179", allResults[28]); + Assert.AreEqual("TaGe_SA_A549_3_snip Target peptides with pep q-value = 0.01 : 182", allResults[26]); + Assert.AreEqual("TaGe_SA_A549_3_snip_2 Target peptides with pep q-value = 0.01 : 182", allResults[28]); resultsFile = Path.Combine(outputFolder, @"postSearchAnalysisTaskTestOutput\results.txt"); results = File.ReadAllLines(resultsFile); - Assert.AreEqual("All target PSMs with pep q-value = 0.01: 499", results[7]); - Assert.AreEqual("All target peptides with pep q-value = 0.01 : 179", results[8]); + Assert.AreEqual("All target PSMs with pep q-value = 0.01: 501", results[7]); + Assert.AreEqual("All target peptides with pep q-value = 0.01 : 182", results[8]); Assert.AreEqual("All target protein groups with q-value = 0.01 (1% FDR): 165", results[9]); - Assert.AreEqual("TaGe_SA_A549_3_snip target PSMs with pep q-value = 0.01: 230", results[13]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 target PSMs with pep q-value = 0.01: 230", results[17]); + Assert.AreEqual("TaGe_SA_A549_3_snip target PSMs with pep q-value = 0.01: 233", results[13]); + Assert.AreEqual("TaGe_SA_A549_3_snip_2 target PSMs with pep q-value = 0.01: 233", results[17]); Assert.AreEqual("Target protein groups within 1 % FDR in TaGe_SA_A549_3_snip: 165", results[19]); Assert.AreEqual("Target protein groups within 1 % FDR in TaGe_SA_A549_3_snip_2: 165", results[20]); - Assert.AreEqual("TaGe_SA_A549_3_snip Target peptides with pep q-value = 0.01 : 179", results[21]); - Assert.AreEqual("TaGe_SA_A549_3_snip_2 Target peptides with pep q-value = 0.01 : 179", results[23]); + Assert.AreEqual("TaGe_SA_A549_3_snip Target peptides with pep q-value = 0.01 : 182", results[21]); + Assert.AreEqual("TaGe_SA_A549_3_snip_2 Target peptides with pep q-value = 0.01 : 182", results[23]); Directory.Delete(outputFolder, true); } } -} +} \ No newline at end of file diff --git a/MetaMorpheus/Test/PsvTsvTest.cs b/MetaMorpheus/Test/PsvTsvTest.cs index 55fd5c5f0..8e9daac6c 100644 --- a/MetaMorpheus/Test/PsvTsvTest.cs +++ b/MetaMorpheus/Test/PsvTsvTest.cs @@ -1,7 +1,13 @@ using EngineLayer; using GuiFunctions; +using MassSpectrometry; using NUnit.Framework; +using Omics.Digestion; using Omics.Fragmentation; +using Omics.Modifications; +using Proteomics; +using Proteomics.ProteolyticDigestion; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -222,7 +228,7 @@ public static void TestToString() } [Test] - public static void TestSimpleToLibrarySpectrum() + public static void TestSimpleToLibrarySpectrum() { string psmTsvPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TopDownTestData\TDGPTMDSearchResults.psmtsv"); List warnings = new(); @@ -236,7 +242,7 @@ public static void TestSimpleToLibrarySpectrum() //not a great way to test equality but we are experiencing a great deal of 10th digit rounding differences Assert.AreEqual(Regex.Matches(expectedLibrarySpectrum, "ppm").Count, Regex.Matches(librarySpectrum, "ppm").Count); - + //the code below tests the addition and correct output for neutral loss fragments Product p = new Product(ProductType.bWaterLoss, FragmentationTerminus.N, 1, 1, 1, 18); MatchedFragmentIon matchedIon = new(p, 1, 1, 1); @@ -245,5 +251,101 @@ public static void TestSimpleToLibrarySpectrum() Assert.That(librarySpectrumWithNeutralLoss.Contains("WaterLoss")); } + [Test] + public static void TestPsmSortFunction() + { + string[] sequences = { + "ABCKPEPR", + "BRPEPR", + "ARPEPR", + "PEPPER", + "PEPTIDE", + "PRTIEN" + }; + + var p = new List(); + List> gn = new List>(); + for (int i = 0; i < sequences.Length; i++) + { + p.Add(new Protein(sequences[i], (i + 1).ToString(), null, gn, new Dictionary>())); + } + + CommonParameters commonParams = new CommonParameters(digestionParams: new DigestionParams(protease: "trypsin", minPeptideLength: 1)); + + PeptideWithSetModifications pepOne = new PeptideWithSetModifications(protein: p.ElementAt(0), digestionParams: commonParams.DigestionParams, oneBasedStartResidueInProtein: 5, oneBasedEndResidueInProtein: 8, cleavageSpecificity: CleavageSpecificity.Full, peptideDescription: "ABCKPEPR", missedCleavages: 0, allModsOneIsNterminus: new Dictionary(), numFixedMods: 0); + PeptideWithSetModifications pepTwo = new PeptideWithSetModifications(protein: p.ElementAt(1), digestionParams: commonParams.DigestionParams, oneBasedStartResidueInProtein: 3, oneBasedEndResidueInProtein: 6, cleavageSpecificity: CleavageSpecificity.Full, peptideDescription: "BRPEPR", missedCleavages: 0, allModsOneIsNterminus: new Dictionary(), numFixedMods: 0); + PeptideWithSetModifications pepThree = new PeptideWithSetModifications(protein: p.ElementAt(2), digestionParams: commonParams.DigestionParams, oneBasedStartResidueInProtein: 3, oneBasedEndResidueInProtein: 6, cleavageSpecificity: CleavageSpecificity.Full, peptideDescription: "ARPEPR", missedCleavages: 0, allModsOneIsNterminus: new Dictionary(), numFixedMods: 0); + PeptideWithSetModifications pepFour = new PeptideWithSetModifications(protein: p.ElementAt(3), digestionParams: commonParams.DigestionParams, oneBasedStartResidueInProtein: 1, oneBasedEndResidueInProtein: 3, cleavageSpecificity: CleavageSpecificity.Full, peptideDescription: "PEPPER", missedCleavages: 0, allModsOneIsNterminus: new Dictionary(), numFixedMods: 0); + PeptideWithSetModifications pepFive = new PeptideWithSetModifications(protein: p.ElementAt(4), digestionParams: commonParams.DigestionParams, oneBasedStartResidueInProtein: 3, oneBasedEndResidueInProtein: 6, cleavageSpecificity: CleavageSpecificity.Full, peptideDescription: "PEPTIDE", missedCleavages: 0, allModsOneIsNterminus: new Dictionary(), numFixedMods: 0); + PeptideWithSetModifications pepSix = new PeptideWithSetModifications(protein: p.ElementAt(5), digestionParams: commonParams.DigestionParams, oneBasedStartResidueInProtein: 3, oneBasedEndResidueInProtein: 6, cleavageSpecificity: CleavageSpecificity.Full, peptideDescription: "PRTIEN", missedCleavages: 0, allModsOneIsNterminus: new Dictionary(), numFixedMods: 0); + + MsDataScan scanNumberOne = new MsDataScan(new MzSpectrum(new double[] { 10 }, new double[] { 1 }, false), 1, 2, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", 10, 2, 100, double.NaN, null, DissociationType.AnyActivationType, 0, null); + MsDataScan scanNumberTwo = new MsDataScan(new MzSpectrum(new double[] { 20 }, new double[] { 1 }, false), 2, 2, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=2", 20, 2, 100, double.NaN, null, DissociationType.AnyActivationType, 0, null); + MsDataScan scanNumberThree = new MsDataScan(new MzSpectrum(new double[] { 20 }, new double[] { 1 }, false), 3, 2, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=3", 20, 2, 100, double.NaN, null, DissociationType.AnyActivationType, 0, null); + + Ms2ScanWithSpecificMass ms2ScanOneMzTen = new Ms2ScanWithSpecificMass(scanNumberOne, 10, 2, "File", new CommonParameters()); + Ms2ScanWithSpecificMass ms2ScanOneMzTwenty = new Ms2ScanWithSpecificMass(scanNumberTwo, 20, 2, "File", new CommonParameters()); + Ms2ScanWithSpecificMass ms2ScanTwoMzTwenty = new Ms2ScanWithSpecificMass(scanNumberTwo, 20, 2, "File", new CommonParameters()); + Ms2ScanWithSpecificMass ms2ScanThreeMzTwenty = new Ms2ScanWithSpecificMass(scanNumberThree, 20, 2, "File", new CommonParameters()); + + //highest score + PeptideSpectralMatch psmOne = new(pepOne, 0, 10, 0, ms2ScanOneMzTen, commonParams, + new List()); + + //second highest score 9. delta score 1 + PeptideSpectralMatch psmTwo = new(pepOne, 0, 8, 0, ms2ScanOneMzTen, commonParams, + new List()); + psmTwo.AddOrReplace(pepTwo, 9, 0, true, new List(), 0); + + //second highest score 9. delta score 0.1 + PeptideSpectralMatch psmThree = new(pepOne, 0, 8.90000000000000000000000000000, 0, ms2ScanOneMzTen, commonParams, + new List()); + psmThree.AddOrReplace(pepTwo, 9, 0, true, new List(), 0); + + //third highest score delta score 1. ppm error -888657.54 low + PeptideSpectralMatch psmFour = new(pepOne, 0, 7, 0, ms2ScanOneMzTwenty, commonParams, + new List()); + psmFour.AddOrReplace(pepFour, 8, 0, true, new List(), 0); + + //third highest score 8. delta score 1. ppm error -947281.29 high + PeptideSpectralMatch psmFive = new(pepOne, 0, 7, 0, ms2ScanOneMzTen, commonParams, + new List()); + psmFive.AddOrReplace(pepFour, 8, 0, true, new List(), 0); + + //fourth highest score 7. delta score 1. same ppm error + PeptideSpectralMatch psmSix = new(pepOne, 0, 6, 0, ms2ScanTwoMzTwenty, commonParams, + new List()); + psmSix.AddOrReplace(pepSix, 7, 0, true, new List(), 0); + + //fourth highest score 7. delta score 1. same ppm error + PeptideSpectralMatch psmSeven = new(pepOne, 0, 6, 0, ms2ScanThreeMzTwenty, commonParams, + new List()); + psmSeven.AddOrReplace(pepSix, 7, 0, true, new List(), 0); + + List psms = new List { psmFour, psmOne, psmThree, psmSeven, psmTwo, psmFive, psmSix }; + psms.ForEach(j => j.ResolveAllAmbiguities()); + psms.ForEach(j => j.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0)); + + List orderedPsms = psms.OrderByDescending(p => p).ToList(); + + Assert.AreEqual(10, orderedPsms[0].Score); + Assert.AreEqual(9, orderedPsms[1].Score); + Assert.AreEqual(9, orderedPsms[2].Score); + Assert.AreEqual(8, orderedPsms[3].Score); + Assert.AreEqual(8, orderedPsms[4].Score); + Assert.AreEqual(7, orderedPsms[5].Score); + Assert.AreEqual(7, orderedPsms[6].Score); + + Assert.AreEqual(5, orderedPsms[0].RunnerUpScore); + Assert.AreEqual(8.9, orderedPsms[1].RunnerUpScore); + Assert.AreEqual(8, orderedPsms[2].RunnerUpScore); + Assert.AreEqual(7, orderedPsms[3].RunnerUpScore); + Assert.AreEqual(7, orderedPsms[4].RunnerUpScore); + Assert.AreEqual(6, orderedPsms[5].RunnerUpScore); + Assert.AreEqual(6, orderedPsms[6].RunnerUpScore); + + Assert.IsTrue(Math.Abs(orderedPsms[3].PrecursorMassErrorPpm.First()) < Math.Abs(orderedPsms[4].PrecursorMassErrorPpm.First())); + Assert.IsTrue(orderedPsms[5].ScanNumber < orderedPsms[6].ScanNumber); + } } } \ No newline at end of file diff --git a/MetaMorpheus/Test/SearchTaskTest.cs b/MetaMorpheus/Test/SearchTaskTest.cs index cce514a40..9a88b00a9 100644 --- a/MetaMorpheus/Test/SearchTaskTest.cs +++ b/MetaMorpheus/Test/SearchTaskTest.cs @@ -386,7 +386,7 @@ public static void PeptideFDRTest() // test that the final q-value follows the (target / decoy) formula // intermediate q-values no longer always follow this formula, so I'm not testing them here - Assert.AreEqual(cumDecoys / (double)cumTargets, finalQValue, 0.0001); + Assert.That((double)cumDecoys / (double)cumTargets, Is.EqualTo(finalQValue).Within(.0005)); Directory.Delete(folderPath, true); } diff --git a/MetaMorpheus/Test/TestPsm.cs b/MetaMorpheus/Test/TestPsm.cs index 8ea7794a3..fb4207a00 100644 --- a/MetaMorpheus/Test/TestPsm.cs +++ b/MetaMorpheus/Test/TestPsm.cs @@ -6,19 +6,19 @@ using MzLibUtil; using NUnit.Framework; using Proteomics; -using Omics.Fragmentation; using Proteomics.ProteolyticDigestion; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using Omics.Digestion; -using Omics.Modifications; using TaskLayer; using UsefulProteomicsDatabases; using PsmFromTsv = EngineLayer.PsmFromTsv; using Omics; +using Omics.Digestion; +using Omics.Fragmentation; +using Omics.Modifications; namespace Test { @@ -126,7 +126,7 @@ public static void TestPpmAndDaMassErrors() CommonParameters, fsp, new List()).Run()); var nonNullPsms = allPsmsArray.Where(p => p != null).ToList(); - foreach (SpectralMatch psm in nonNullPsms) + foreach (PeptideSpectralMatch psm in nonNullPsms) { double daError = Math.Round(psm.ScanPrecursorMass - psm.BestMatchingBioPolymersWithSetMods.First().Peptide.MonoisotopicMass, 5); @@ -154,7 +154,7 @@ public static void TestLongestFragmentIonSequence() var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); SpectralMatch[] allPsmsArray = new SpectralMatch[listOfSortedms2Scans.Length]; bool writeSpetralLibrary = false; - new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, + new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, new CommonParameters(), null, null, new List(), writeSpetralLibrary).Run(); List longestSeriesObserved = new List(); @@ -346,7 +346,7 @@ public static void TestPsmCount() var fdrEngine = new FdrAnalysisEngine(allPsms, 0, new CommonParameters(), fsp, new List()); - fdrEngine.CountPsm(); + fdrEngine.CountPsm(allPsms); var psmGroups = allPsms.Where(psm => psm.FullSequence != null && psm.PsmCount > 0).GroupBy(p => p.FullSequence).ToList(); Assert.That(psmGroups.First().Count() == 2); Assert.That(psmGroups.First().First().PsmCount == 1); @@ -354,7 +354,7 @@ public static void TestPsmCount() psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0); psm3.ResolveAllAmbiguities(); - fdrEngine.CountPsm(); + fdrEngine.CountPsm(allPsms); psmGroups = allPsms.Where(psm => psm.FullSequence != null && psm.PsmCount > 0).GroupBy(p => p.FullSequence).ToList(); Assert.That(psmGroups.First().Count() == 3); } @@ -390,9 +390,7 @@ public static void TestPsmCount2() } var psmsFromTsv = PsmTsvReader.ReadTsv(Path.Combine(outputFolder, @"AllPSMs.psmtsv"), out var warnings); - var allUnambiguousPsms = psmsFromTsv.Where(psm => psm.FullSequence != null); - var unambiguousPsmsLessThanOnePercentFdr = allUnambiguousPsms.Where(psm => psm.QValue <= 0.01) .GroupBy(p => p.FullSequence).ToList(); @@ -514,7 +512,7 @@ public static void TestPSMFragmentCoverage() Protein p2 = new Protein("GGGGGGGGGGGGGGKPEPTIDEPEPTIDE", null); var pep2 = p2.Digest(commonParameters.DigestionParams, new List(), new List()).ToList()[1]; - TestDataFile t = new TestDataFile(new List { pep1, pep2}); + TestDataFile t = new TestDataFile(new List { pep1, pep2 }); //psm 1 - test first and last amino acid positions, along with one internal Amino Acid position Product productC3 = new Product(ProductType.y, FragmentationTerminus.C, 0, 3, 12, 0); @@ -535,7 +533,7 @@ public static void TestPSMFragmentCoverage() MatchedFragmentIon mfiN6 = new MatchedFragmentIon(productN6, 0, 0, 1); MatchedFragmentIon mfiN8 = new MatchedFragmentIon(productN8, 0, 0, 1); MatchedFragmentIon mfiN13 = new MatchedFragmentIon(productN13, 0, 0, 1); - List mfis1 = new List { mfiC3, mfiC4, mfiC7, mfiC13, mfiN3, mfiN4, mfiN6, mfiN8, mfiN13}; + List mfis1 = new List { mfiC3, mfiC4, mfiC7, mfiC13, mfiN3, mfiN4, mfiN6, mfiN8, mfiN13 }; MsDataScan mzLibScan1 = t.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, 0, 1, null, new CommonParameters()); SpectralMatch psm1 = new PeptideSpectralMatch(pep1, 0, 0, 0, scan1, commonParameters, mfis1); From aa6872cd797683e1538c06ed28b5a43892f5507f Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 9 Apr 2024 14:03:36 -0500 Subject: [PATCH 35/39] boosting code coverage elsewhere --- .../ViewModels/ModTypeForTreeViewModel.cs | 5 +---- .../MetaDraw/MetaDrawSettingsAndViewsTest.cs | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/MetaMorpheus/GuiFunctions/ViewModels/ModTypeForTreeViewModel.cs b/MetaMorpheus/GuiFunctions/ViewModels/ModTypeForTreeViewModel.cs index 9c88ba24f..56c908459 100644 --- a/MetaMorpheus/GuiFunctions/ViewModels/ModTypeForTreeViewModel.cs +++ b/MetaMorpheus/GuiFunctions/ViewModels/ModTypeForTreeViewModel.cs @@ -25,10 +25,7 @@ public MyEnumerator GetEnumerator() } public bool? Use { - get - { - return _isChecked; - } + get => _isChecked; set { _isChecked = value; diff --git a/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs b/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs index 5661074e2..064baffcf 100644 --- a/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs +++ b/MetaMorpheus/Test/MetaDraw/MetaDrawSettingsAndViewsTest.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Windows.Media; +using Easy.Common.Extensions; using EngineLayer; using GuiFunctions; using GuiFunctions.ViewModels.Legends; @@ -215,7 +216,7 @@ public static void TestCoverageTypeForTreeView() [Test] public static void TestModTypeForTreeView() { - var modGroups = GlobalVariables.AllModsKnown.GroupBy(b => b.ModificationType); + var modGroups = GlobalVariables.AllModsKnown.GroupBy(b => b.ModificationType).ToList(); var key = modGroups.First().Key; ModTypeForTreeViewModel modTypeForTreeView = new(key, false); Assert.That(!modTypeForTreeView.Expanded); @@ -227,6 +228,23 @@ public static void TestModTypeForTreeView() modTypeForTreeView = new(modGroups.First().Key, true); Assert.That(((SolidColorBrush)modTypeForTreeView.Background).Color == new SolidColorBrush(Colors.Red).Color); + + modGroups.First().Select(p => + new ModForTreeViewModel(p.ToString(), false, p.IdWithMotif, false, modTypeForTreeView)) + .ForEach(mod => modTypeForTreeView.Children.Add(mod)); + Assert.That(modTypeForTreeView.Children.Count == modGroups.First().Count()); + Assert.That(modTypeForTreeView.Children.All(p => p.Parent == modTypeForTreeView)); + Assert.That(modTypeForTreeView.Children.All(p => p.Use == false)); + modTypeForTreeView.VerifyCheckState(); + Assert.That(modTypeForTreeView.Use == false); + + modTypeForTreeView.Children.First().Use = true; + modTypeForTreeView.VerifyCheckState(); + Assert.That(modTypeForTreeView.Use == null); + + modTypeForTreeView.Children.ForEach(mod => mod.Use = true); + modTypeForTreeView.VerifyCheckState(); + Assert.That(modTypeForTreeView.Use == true); } [Test] From 3f4ede358672b9c2e5a1d17edd8e9ad3b180d9d6 Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 9 Apr 2024 14:06:46 -0500 Subject: [PATCH 36/39] removed unused node constructor --- MetaMorpheus/EngineLayer/GlycoSearch/Node.cs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/Node.cs b/MetaMorpheus/EngineLayer/GlycoSearch/Node.cs index 92f915a3b..3c8fc5666 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/Node.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/Node.cs @@ -4,15 +4,6 @@ namespace EngineLayer public class Node { - public Node(char v, Node l, Node r, Node m) - { - Value = v; - LeftChild = l; - RightChild = r; - MiddleChild = m; - Level = null; - } - public Node(char v) { Value = v; From 60b841dc9d50286b7bb8d237d507061f9603eda9 Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 9 Apr 2024 15:12:45 -0500 Subject: [PATCH 37/39] expanded gptmd test coverage --- MetaMorpheus/Test/gptmdPrunedBdTests.cs | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/MetaMorpheus/Test/gptmdPrunedBdTests.cs b/MetaMorpheus/Test/gptmdPrunedBdTests.cs index c29080062..798196503 100644 --- a/MetaMorpheus/Test/gptmdPrunedBdTests.cs +++ b/MetaMorpheus/Test/gptmdPrunedBdTests.cs @@ -11,6 +11,7 @@ using TaskLayer; using UsefulProteomicsDatabases; using Omics; +using Org.BouncyCastle.Asn1; namespace Test { @@ -532,5 +533,43 @@ public static void TestProteinPrunedWithModSelectionAndVariants() Assert.That(modPruned.ElementAt(0).OneBasedPossibleLocalizedModifications.Count().Equals(1)); Assert.That(modPruned.ElementAt(1).OneBasedPossibleLocalizedModifications.Count().Equals(1)); } + + + + + [Test] + public static void TestContaminantGPTMD() + { + //Create GPTMD Task + //Create Search Task + GptmdTask task1 = new GptmdTask + { + CommonParameters = new CommonParameters(), + GptmdParameters = new GptmdParameters + { + ListOfModsGptmd = GlobalVariables.AllModsKnown.Where(b => + b.ModificationType.Equals("Common Artifact") + || b.ModificationType.Equals("Common Biological") + || b.ModificationType.Equals("Metal") + || b.ModificationType.Equals("Less Common") + ).Select(b => (b.ModificationType, b.IdWithMotif)).ToList() + } + }; + + List<(string, MetaMorpheusTask)> taskList = new List<(string, MetaMorpheusTask)> { ("task1", task1) }; + string mzmlName = @"TestData\PrunedDbSpectra.mzml"; + string fastaName = @"TestData\DbForPrunedDb.fasta"; + string contaminantName = @"DatabaseTests\ProteaseModTest.fasta"; + string outputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestPrunedGeneration"); + var engine = new EverythingRunnerEngine(taskList, new List { mzmlName }, + new List { new DbForTask(fastaName, false), new DbForTask(contaminantName, true) }, + outputFolder); + engine.Run(); + string final = Path.Combine(MySetUpClass.outputFolder, "task1", "DbForPrunedDbGPTMD.xml"); + string contaminantFinal = Path.Combine(MySetUpClass.outputFolder, "task1", "ProteaseModTestGPTMD.xml"); + Assert.That(File.Exists(final)); + Assert.That(File.Exists(contaminantFinal)); + Directory.Delete(outputFolder, true); + } } } \ No newline at end of file From d438c5b709ba7b9376d1736e04fea299839ac3b6 Mon Sep 17 00:00:00 2001 From: nbollis Date: Tue, 9 Apr 2024 15:51:10 -0500 Subject: [PATCH 38/39] ugh --- MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs index 175a6ddac..8520272fb 100644 --- a/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs +++ b/MetaMorpheus/TaskLayer/GPTMDTask/GPTMDTask.cs @@ -180,11 +180,9 @@ protected override MyTaskResults RunSpecific(string OutputFolder, List !b.IsDecoy && b.IsContaminant).ToList(), outputXMLdbFullNameContaminants); FinishedWritingFile(outputXMLdbFullNameContaminants, new List { taskId }); - MyTaskResults.NewDatabases.Add(new DbForTask(outputXMLdbFullNameContaminants, true)); MyTaskResults.AddTaskSummaryText("Contaminant modifications added: " + newModsActuallyWritten.Select(b => b.Value).Sum()); MyTaskResults.AddTaskSummaryText("Mods types and counts:"); From d97d59009abf9c0716bc41b6e95087504425c449 Mon Sep 17 00:00:00 2001 From: nbollis Date: Wed, 10 Apr 2024 11:36:07 -0500 Subject: [PATCH 39/39] push to rerun appveyor --- MetaMorpheus/EngineLayer/GlycoSearch/Node.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/MetaMorpheus/EngineLayer/GlycoSearch/Node.cs b/MetaMorpheus/EngineLayer/GlycoSearch/Node.cs index 3c8fc5666..a69bc3fcf 100644 --- a/MetaMorpheus/EngineLayer/GlycoSearch/Node.cs +++ b/MetaMorpheus/EngineLayer/GlycoSearch/Node.cs @@ -1,7 +1,6 @@  namespace EngineLayer { - public class Node { public Node(char v)