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 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)); }