public static void TestCombos() { List <PeptideSpectralMatch> allIdentifications = null; ModificationMotif.TryGetMotif("N", out ModificationMotif motifN); ModificationMotif.TryGetMotif("P", out ModificationMotif motifP); var gptmdModifications = new List <ModificationWithMass> { new ModificationWithMass("21", "mt", motifN, TerminusLocalization.Any, 21.981943, null), new ModificationWithMass("16", "mt", motifP, TerminusLocalization.Any, 15.994915, null) }; IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> > { new Tuple <double, double>(21.981943, 15.994915) }; Tolerance precursorMassTolerance = new PpmTolerance(10); 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, (651.297638557 + 21.981943 + 15.994915).ToMz(1), 1, "filepath"); var parentProtein = new Protein("NNNPPP", "accession"); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 5); List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); var modPep = parentProtein.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).First(); var peptidesWithSetModifications = new List <PeptideWithSetModifications> { modPep }; PeptideSpectralMatch match = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan, digestionParams); PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan, digestionParams); Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { peptidesWithSetModifications.First() } } }; List <ProductType> lp = new List <ProductType> { ProductType.B, ProductType.Y }; Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); match.MatchToProteinLinkedPeptides(matching); match.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0, 0, false); allIdentifications = new List <PeptideSpectralMatch> { match }; var engine = new GptmdEngine(allIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> { { "filepath", precursorMassTolerance } }, new CommonParameters(), new List <string>()); var res = (GptmdResults)engine.Run(); Assert.AreEqual(1, res.Mods.Count); Assert.AreEqual(6, res.Mods["accession"].Count); Assert.AreEqual(3, res.Mods["accession"].Where(b => b.Item2.id.Equals("21")).Count()); Assert.AreEqual(3, res.Mods["accession"].Where(b => b.Item2.id.Equals("16")).Count()); }
public static void TestGptmdEngine() { List <PeptideSpectralMatch> allResultingIdentifications = null; ModificationMotif.TryGetMotif("N", out ModificationMotif motifN); var gptmdModifications = new List <ModificationWithMass> { new ModificationWithMass("21", "mt", motifN, TerminusLocalization.Any, 21.981943) }; IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> >(); Tolerance precursorMassTolerance = new PpmTolerance(10); allResultingIdentifications = new List <PeptideSpectralMatch>(); var engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, precursorMassTolerance, new List <string>()); var res = (GptmdResults)engine.Run(); Assert.AreEqual(0, res.Mods.Count); //PsmParent newPsm = new TestParentSpectrumMatch(588.22520189093 + 21.981943); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(new MzmlScanWithPrecursor(0, new MzmlMzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null, null, "scan=1"), (588.22520189093 + 21.981943).ToMz(1), 1, null); var parentProtein = new Protein("NNNNN", "accession"); var protease = new Protease("Custom Protease", new List <string> { "K" }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null); DigestionParams digestionParams = new DigestionParams(); List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); var modPep = parentProtein.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).First(); var peptidesWithSetModifications = new List <PeptideWithSetModifications> { modPep }; PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan); Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { peptidesWithSetModifications.First() } } }; List <ProductType> lp = new List <ProductType> { ProductType.B, ProductType.Y }; Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); newPsm.MatchToProteinLinkedPeptides(matching); newPsm.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0, 0, false); allResultingIdentifications.Add(newPsm); engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, precursorMassTolerance, new List <string>()); res = (GptmdResults)engine.Run(); Assert.AreEqual(1, res.Mods.Count); Assert.AreEqual(5, res.Mods["accession"].Count); }
public static void TestModFits() { ModificationMotif.TryGetMotif("X", out ModificationMotif motif); ModificationWithMass attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Protein protein = new Protein("M", null); int peptideOneBasedIndex = 1; int peptideLength = 1; int proteinOneBasedIndex = 1; Assert.IsTrue(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("M", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsTrue(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("N", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("Mx", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("Mr", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("xM", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("Nxs", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); protein = new Protein("MNRS", null); peptideOneBasedIndex = 1; peptideLength = 1; proteinOneBasedIndex = 1; Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("Nxs", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); protein = new Protein("MNRS", null); peptideOneBasedIndex = 1; peptideLength = 1; proteinOneBasedIndex = 1; Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); peptideOneBasedIndex = 2; peptideLength = 1; proteinOneBasedIndex = 2; Assert.IsTrue(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); protein = new Protein("MNRN", null); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); }
public static void TestUniProtGptmdConflict() { // this unit test checks to make sure GPTMD does not annotate mods at residues on // proteins where the equivalent uniprot mod already exists Modification uniProtPhospho = GlobalVariables.AllModsKnown.First(p => p.ModificationType == "UniProt" && p.IdWithMotif.Contains("Phosphoserine")); Modification mmPhospho = GlobalVariables.AllModsKnown.First(p => p.ModificationType == "Common Biological" && p.IdWithMotif.Contains("Phosphorylation on S")); Protein protein = new Protein("PEPTIDESK", "test", oneBasedModifications: new Dictionary <int, List <Modification> >() { { 8, new List <Modification> { uniProtPhospho } } }); PeptideWithSetModifications pep = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First(p => p.AllModsOneIsNterminus.Count == 0); // 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); Assert.That(!modFits); } // the following code is just a control to make sure the phosphorylation actually does fit // at the given residue if the UniProt phosphorylation is not already present var someOtherSMod = GlobalVariables.AllModsKnown.Where(p => p.ModificationType == "Common Biological" && p.IdWithMotif.Contains("HexNAc on S")).First(); protein = new Protein("PEPTIDESK", "test", oneBasedModifications: new Dictionary <int, List <Modification> >() { { 8, new List <Modification> { someOtherSMod } } }); pep = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First(p => p.AllModsOneIsNterminus.Count == 0); // 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); if (i + 1 == 8) { Assert.That(modFits); } else { Assert.That(!modFits); } } }
public static void TestGptmdEngine(string proteinSequence, string accession, string sequenceVariantDescription, int numModifiedResidues) { List <PeptideSpectralMatch> allResultingIdentifications = null; ModificationMotif.TryGetMotif("N", out ModificationMotif motifN); var gptmdModifications = new List <Modification> { new Modification(_originalId: "21", _modificationType: "mt", _target: motifN, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943) }; IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> >(); Tolerance precursorMassTolerance = new PpmTolerance(10); allResultingIdentifications = new List <PeptideSpectralMatch>(); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", new CommonParameters())); var engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> { { "filepath", precursorMassTolerance } }, new CommonParameters(), fsp, new List <string>()); var res = (GptmdResults)engine.Run(); Assert.AreEqual(0, res.Mods.Count); var parentProtein = new Protein(proteinSequence, accession, sequenceVariations: new List <SequenceVariation> { new SequenceVariation(1, "N", "A", sequenceVariantDescription) }); var variantProteins = parentProtein.GetVariantProteins(); CommonParameters commonParameters = new CommonParameters(digestionParams: new DigestionParams(minPeptideLength: 5)); List <Modification> variableModifications = new List <Modification>(); var modPep = variantProteins.SelectMany(p => p.Digest(commonParameters.DigestionParams, new List <Modification>(), variableModifications)).First(); //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 <PeptideWithSetModifications> { modPep }; PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, commonParameters, new List <MatchedFragmentIon>()); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); newPsm.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0); allResultingIdentifications.Add(newPsm); engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> { { "filepath", precursorMassTolerance } }, new CommonParameters(), null, new List <string>()); res = (GptmdResults)engine.Run(); Assert.AreEqual(1, res.Mods.Count); Assert.AreEqual(numModifiedResidues, res.Mods["accession"].Count); }
public static void TestCombos(string proteinSequence, string accession, string variantAA, string sequenceVariantDescription, int numModHashes, int numModifiedResidues, int numModifiedResiduesN, int numModifiedResiduesP, int numModifiedResiduesNP) { List <PeptideSpectralMatch> allIdentifications = null; ModificationMotif.TryGetMotif("N", out ModificationMotif motifN); ModificationMotif.TryGetMotif("P", out ModificationMotif motifP); var gptmdModifications = new List <Modification> { new Modification(_originalId: "21", _modificationType: "mt", _target: motifN, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943), new Modification(_originalId: "16", _modificationType: "mt", _target: motifP, _locationRestriction: "Anywhere.", _monoisotopicMass: 15.994915) }; IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> > { new Tuple <double, double>(21.981943, 15.994915) }; Tolerance precursorMassTolerance = new PpmTolerance(10); var parentProtein = new Protein(proteinSequence, accession, sequenceVariations: new List <SequenceVariation> { new SequenceVariation(1, "N", variantAA, sequenceVariantDescription) }); var variantProteins = parentProtein.GetVariantProteins(); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 5); List <Modification> variableModifications = new List <Modification>(); var modPep = variantProteins.SelectMany(p => p.Digest(digestionParams, new List <Modification>(), variableModifications)).First(); 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 <PeptideWithSetModifications> { modPep }; PeptideSpectralMatch match = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, digestionParams, new List <MatchedFragmentIon>()); PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, digestionParams, new List <MatchedFragmentIon>()); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); match.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0); allIdentifications = new List <PeptideSpectralMatch> { match }; var engine = new GptmdEngine(allIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> { { "filepath", precursorMassTolerance } }, new CommonParameters(), new List <string>()); var res = (GptmdResults)engine.Run(); Assert.AreEqual(numModHashes, res.Mods.Count); Assert.AreEqual(numModifiedResidues, res.Mods["accession"].Count); Assert.AreEqual(numModifiedResiduesN, res.Mods["accession"].Where(b => b.Item2.OriginalId.Equals("21")).Count()); Assert.AreEqual(numModifiedResiduesP, res.Mods["accession"].Where(b => b.Item2.OriginalId.Equals("16")).Count()); res.Mods.TryGetValue("accession_N1P", out var hash); Assert.AreEqual(numModifiedResiduesNP, (hash ?? new HashSet <Tuple <int, Modification> >()).Count); }
public static void Test_GptmdEngineModFits(string targetAminoAcid, string proteinSequence, string locationRestriction, int peptideOneBasedIndex, int peptideLength, int proteinOneBasedIndex, bool result) { ModificationMotif.TryGetMotif(targetAminoAcid, out ModificationMotif motif); Modification attemptToLocalize = new Modification(null, null, null, null, _target: motif, _locationRestriction: locationRestriction, _chemicalFormula: null, _monoisotopicMass: 1, _databaseReference: null, _taxonomicRange: null, _keywords: null, _neutralLosses: null, _diagnosticIons: null, _fileOrigin: null); Dictionary <int, List <Modification> > oneBasedModifications = new Dictionary <int, List <Modification> >(); oneBasedModifications.Add(proteinOneBasedIndex, new List <Modification>() { attemptToLocalize }); Protein protein = new Protein(proteinSequence, null, null, null, oneBasedModifications, null, null, null, false, false, null, null, null, null, null, null, ""); Assert.AreEqual(result, GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); }