From 4653e031c13a18cf94ade524f4a9a3585422e85e Mon Sep 17 00:00:00 2001 From: Edwin Date: Wed, 27 Sep 2023 12:52:45 -0500 Subject: [PATCH 1/2] Tests Passing --- .../PeptideWithSetModifications.cs | 12 ++++++- mzLib/Test/TestPeptideWithSetMods.cs | 32 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs index 4f391729d..537e44e47 100644 --- a/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs +++ b/mzLib/Proteomics/ProteolyticDigestion/PeptideWithSetModifications.cs @@ -5,7 +5,8 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; + using System.Reflection; + using System.Text; namespace Proteomics.ProteolyticDigestion { @@ -76,6 +77,15 @@ public PeptideWithSetModifications(string sequence, Dictionary allModsOneIsNterminus) + { + _allModsOneIsNterminus = allModsOneIsNterminus; + _monoisotopicMass = null; + _mostAbundantMonoisotopicMass = null; + _hasChemicalFormulas = null; + + } + public DigestionParams DigestionParams { get { return _digestionParams; } diff --git a/mzLib/Test/TestPeptideWithSetMods.cs b/mzLib/Test/TestPeptideWithSetMods.cs index 1829f7820..45d8f2b2a 100644 --- a/mzLib/Test/TestPeptideWithSetMods.cs +++ b/mzLib/Test/TestPeptideWithSetMods.cs @@ -1,4 +1,5 @@ using Chemistry; +using Easy.Common.Extensions; using NUnit.Framework; using Proteomics; using Proteomics.Fragmentation; @@ -1085,5 +1086,36 @@ public static void CheckMostAbundantMonoisotopicMass() double large_pep_most_abundant_mass_prospector = 4709.12020 - 1.0079; Assert.That(large_pep.MostAbundantMonoisotopicMass, Is.EqualTo(large_pep_most_abundant_mass_prospector).Within(0.01)); } + + [Test] + public static void TestReplaceAllModsOneIsNterminus() + { + PeptideWithSetModifications peptide = new PeptideWithSetModifications(new Protein("PEPTIDES", "ACCESSION"), + new DigestionParams(protease: "trypsin"), 1, 8, + CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + + Assert.That(peptide.AllModsOneIsNterminus.Count == 0); + Assert.That(peptide.MonoisotopicMass, Is.EqualTo(peptide.MonoisotopicMass).Within(0.01)); + Assert.That(peptide.MostAbundantMonoisotopicMass, Is.EqualTo(peptide.MonoisotopicMass).Within(0.01)); + Assert.That(peptide.NumMods == 0); + Assert.That(peptide.NumVariableMods == 0); + Assert.That(peptide.SequenceWithChemicalFormulas == "PEPTIDES"); + + var noModPeptideMonoisotopicMass = peptide.MonoisotopicMass; + var noModPeptideMostAbundantMonoisotopicMass = peptide.MostAbundantMonoisotopicMass; + + //Makes phospho mod and a dictionary that contains the mod in the last residue + Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); + var phosphoDict = new Dictionary(); + phosphoDict.Add(8, phosphorylation); + peptide.ReplaceAllModsOneIsNterminus(phosphoDict); + + Assert.That(peptide.AllModsOneIsNterminus.Count != 0); + Assert.That(peptide.MonoisotopicMass, Is.EqualTo(noModPeptideMonoisotopicMass + phosphorylation.MonoisotopicMass).Within(0.01)); + Assert.That(peptide.MostAbundantMonoisotopicMass, Is.EqualTo(noModPeptideMostAbundantMonoisotopicMass + phosphorylation.MonoisotopicMass).Within(0.01)); + Assert.That(peptide.NumMods == 1); + Assert.That(peptide.NumVariableMods == 1); + Assert.That(peptide.SequenceWithChemicalFormulas == "PEPTIDE[HO3P]S"); + } } } \ No newline at end of file From 4026d954424d9f1bc34be26dcf0050a7be4592e8 Mon Sep 17 00:00:00 2001 From: Edwin Date: Wed, 27 Sep 2023 13:12:30 -0500 Subject: [PATCH 2/2] Update TestPeptideWithSetMods.cs --- mzLib/Test/TestPeptideWithSetMods.cs | 960 +++++++++++++++++++-------- 1 file changed, 697 insertions(+), 263 deletions(-) diff --git a/mzLib/Test/TestPeptideWithSetMods.cs b/mzLib/Test/TestPeptideWithSetMods.cs index de493c49c..9064c0ad3 100644 --- a/mzLib/Test/TestPeptideWithSetMods.cs +++ b/mzLib/Test/TestPeptideWithSetMods.cs @@ -1,5 +1,4 @@ using Chemistry; -using Easy.Common.Extensions; using NUnit.Framework; using Proteomics; using Proteomics.Fragmentation; @@ -29,7 +28,8 @@ public static void Setuppp() [TearDown] public static void TearDown() { - Console.WriteLine($"Analysis time: {Stopwatch.Elapsed.Hours}h {Stopwatch.Elapsed.Minutes}m {Stopwatch.Elapsed.Seconds}s"); + Console.WriteLine( + $"Analysis time: {Stopwatch.Elapsed.Hours}h {Stopwatch.Elapsed.Minutes}m {Stopwatch.Elapsed.Seconds}s"); } /// @@ -41,11 +41,15 @@ public static void TestDifferentProteaseEquals() { Protein myProtein = new Protein("SEQUENCEK", "accession"); - DigestionParams digest1 = new DigestionParams(protease: "trypsin", maxMissedCleavages: 0, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); - DigestionParams digest2 = new DigestionParams(protease: "Lys-C (cleave before proline)", maxMissedCleavages: 0, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); + DigestionParams digest1 = new DigestionParams(protease: "trypsin", maxMissedCleavages: 0, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); + DigestionParams digest2 = new DigestionParams(protease: "Lys-C (cleave before proline)", + maxMissedCleavages: 0, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); - PeptideWithSetModifications pep1 = myProtein.Digest(digest1, new List(), new List()).First(); - PeptideWithSetModifications pep2 = myProtein.Digest(digest2, new List(), new List()).First(); + PeptideWithSetModifications pep1 = + myProtein.Digest(digest1, new List(), new List()).First(); + PeptideWithSetModifications pep2 = + myProtein.Digest(digest2, new List(), new List()).First(); Assert.That(pep1.FullSequence.Equals(pep2.FullSequence)); Assert.That(pep1.Protein.Equals(pep2.Protein)); @@ -57,15 +61,22 @@ public static void TestDifferentProteaseEquals() [Test] public static void TestSemiFewCleavages() { - Protein protein = new("MQLLRCFSIFSVIASVLAQELTTICEQIPSPTLESTPYSLSTTTILANGKAMQGVFEYYKSVTFVSNCGSHPSTTSKGSPINTQYVF", "P32781"); - DigestionParams nParams = new("trypsin", 2, 7, 50, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.N); - DigestionParams cParams = new("trypsin", 2, 7, 50, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.C); + Protein protein = + new("MQLLRCFSIFSVIASVLAQELTTICEQIPSPTLESTPYSLSTTTILANGKAMQGVFEYYKSVTFVSNCGSHPSTTSKGSPINTQYVF", + "P32781"); + DigestionParams nParams = new("trypsin", 2, 7, 50, searchModeType: CleavageSpecificity.Semi, + fragmentationTerminus: FragmentationTerminus.N); + DigestionParams cParams = new("trypsin", 2, 7, 50, searchModeType: CleavageSpecificity.Semi, + fragmentationTerminus: FragmentationTerminus.C); //Unit test is not crashing protein.Digest(nParams, null, null).ToList(); protein.Digest(cParams, null, null).ToList(); - Protein protein2 = new Protein("MQFSTVASVAFVALANFVAAESAAAISQITDGQIQATTTATTEATTTAAPSSTVETVSPSSTETISQQTENGAAKAAVGMGAGALAAAAMLL", "P43497"); + Protein protein2 = + new Protein( + "MQFSTVASVAFVALANFVAAESAAAISQITDGQIQATTTATTEATTTAAPSSTVETVSPSSTETISQQTENGAAKAAVGMGAGALAAAAMLL", + "P43497"); protein2.Digest(nParams, null, null).ToList(); protein2.Digest(cParams, null, null).ToList(); @@ -75,10 +86,15 @@ public static void TestSemiFewCleavages() }; //speedy - Protein protein3 = new Protein("MQFSTVASVAFVALANFVAAESAAAISQITDGQIQATTTATTEATTTAAPSSTVETVSPSSTETISQQTENGAAKAAVGMGAGALAAAAMLL", "P43497", proteolysisProducts: proteolysisProducts); + Protein protein3 = + new Protein( + "MQFSTVASVAFVALANFVAAESAAAISQITDGQIQATTTATTEATTTAAPSSTVETVSPSSTETISQQTENGAAKAAVGMGAGALAAAAMLL", + "P43497", proteolysisProducts: proteolysisProducts); protein3.Digest(nParams, null, null).ToList(); protein3.Digest(cParams, null, null).ToList(); - cParams = new DigestionParams("trypsin", 0, 7, 9, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.C, initiatorMethionineBehavior: InitiatorMethionineBehavior.Cleave); + cParams = new DigestionParams("trypsin", 0, 7, 9, searchModeType: CleavageSpecificity.Semi, + fragmentationTerminus: FragmentationTerminus.C, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Cleave); protein3.Digest(cParams, null, null).ToList(); //classic @@ -90,19 +106,21 @@ public static void TestSemiFewCleavages() public static void TestSpeedyNonAndSemiSpecificMaxLength() { Protein Q07065 = new Protein("MPSAKQRGSKGGHGAASPSEKGAHPSGGADDV" + - "AKKPPPAPQQPPPPPAPHPQQHPQQHPQNQAHGKGGHRGGGGGGGKSSSSSSASAAAAAA" + - "AASSSASCSRRLGRALNFLFYLALVAAAAFSGWCVHHVLEEVQQVRRSHQDFSRQREELGQ" + - "GLQGVEQKVQSLQATFGTFESILRSSQHKQDLTEKAVKQGESEVSRISEVLQKLQNEILKDL" + - "SDGIHVVKDARERDFTSLENTVEERLTELTKSINDNIAIFTEVQKRSQKEINDMKAKVASLEE" + - "SEGNKQDLKALKEAVKEIQTSAKSREWDMEALRSTLQTMESDIYTEVRELVSLKQEQQAFKEA" + - "ADTERLALQALTEKLLRSEESVSRLPEEIRRLEEELRQLKSDSHGPKEDGGFRHSEAFEALQQK" + - "SQGLDSRLQHVEDGVLSMQVASARQTESLESLLSKSQEHEQRLAALQGRLEGLGSSEADQDGLAST" + - "VRSLGETQLVLYGDVEELKRSVGELPSTVESLQKVQEQVHTLLSQDQAQAARLPPQDFLDRLSSLD" + - "NLKASVSQVEADLKMLRTAVDSLVAYSVKIETNENNLESAKGLLDDLRNDLDRLFVKVEKIHEKV", "Q07065"); + "AKKPPPAPQQPPPPPAPHPQQHPQQHPQNQAHGKGGHRGGGGGGGKSSSSSSASAAAAAA" + + "AASSSASCSRRLGRALNFLFYLALVAAAAFSGWCVHHVLEEVQQVRRSHQDFSRQREELGQ" + + "GLQGVEQKVQSLQATFGTFESILRSSQHKQDLTEKAVKQGESEVSRISEVLQKLQNEILKDL" + + "SDGIHVVKDARERDFTSLENTVEERLTELTKSINDNIAIFTEVQKRSQKEINDMKAKVASLEE" + + "SEGNKQDLKALKEAVKEIQTSAKSREWDMEALRSTLQTMESDIYTEVRELVSLKQEQQAFKEA" + + "ADTERLALQALTEKLLRSEESVSRLPEEIRRLEEELRQLKSDSHGPKEDGGFRHSEAFEALQQK" + + "SQGLDSRLQHVEDGVLSMQVASARQTESLESLLSKSQEHEQRLAALQGRLEGLGSSEADQDGLAST" + + "VRSLGETQLVLYGDVEELKRSVGELPSTVESLQKVQEQVHTLLSQDQAQAARLPPQDFLDRLSSLD" + + "NLKASVSQVEADLKMLRTAVDSLVAYSVKIETNENNLESAKGLLDDLRNDLDRLFVKVEKIHEKV", "Q07065"); //Semi - DigestionParams semiNParams = new DigestionParams("Asp-N", 3, 7, 50, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.N); - DigestionParams semiCParams = new DigestionParams("Asp-N", 3, 7, 50, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.C); + DigestionParams semiNParams = new DigestionParams("Asp-N", 3, 7, 50, + searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.N); + DigestionParams semiCParams = new DigestionParams("Asp-N", 3, 7, 50, + searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.C); List nPwsms = Q07065.Digest(semiNParams, null, null).ToList(); List cPwsms = Q07065.Digest(semiCParams, null, null).ToList(); Assert.IsFalse(nPwsms.Any(x => x.Length > semiNParams.MaxPeptideLength)); @@ -111,8 +129,11 @@ public static void TestSpeedyNonAndSemiSpecificMaxLength() Assert.IsTrue(cPwsms.Any(x => x.Length == semiCParams.MaxPeptideLength)); //Non - DigestionParams nonNParams = new DigestionParams("Asp-N", 20, 7, 50, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N); //more missed cleavages here so we can test the end - DigestionParams nonCParams = new DigestionParams("Asp-N", 3, 7, 50, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); + DigestionParams nonNParams = new DigestionParams("Asp-N", 20, 7, 50, + searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.N); //more missed cleavages here so we can test the end + DigestionParams nonCParams = new DigestionParams("Asp-N", 3, 7, 50, + searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); nPwsms = Q07065.Digest(nonNParams, null, null).ToList(); cPwsms = Q07065.Digest(nonCParams, null, null).ToList(); Assert.IsFalse(nPwsms.Any(x => x.Length > nonNParams.MaxPeptideLength)); @@ -127,21 +148,27 @@ public static void TestSpeedyNonAndSemiSpecificMaxLength() public static void TestNonAndSemiSpecificDigests() { Protein fiveCleavages = new Protein("MAAKCCKDDKEEKFFKGG", "fiveCleavages"); //protein with 5 K's - List> trypticSequencesInducingClevage = new List> - { - new Tuple("K",FragmentationTerminus.C ) //cleave at C terminus of K - }; - List> trypticSequencesPreventingClevage = new List>(); + List> trypticSequencesInducingClevage = + new List> + { + new Tuple("K", FragmentationTerminus.C) //cleave at C terminus of K + }; + List> trypticSequencesPreventingClevage = + new List>(); //make two identical proteases, but one is fully specific and one is semi specific var motifList = DigestionMotif.ParseDigestionMotifsFromString("K|"); - Protease trypsinForTestNonAndSemiSpecificDigests = new Protease("trypsinForTestNonAndSemiSpecificDigests", CleavageSpecificity.Full, "asdf", "asdf", motifList); - Protease semiTrypsinForTestNonAndSemiSpecificDigests = new Protease("semitrypsinForTestNonAndSemiSpecificDigests", CleavageSpecificity.Semi, "asdf", "asdf", motifList); + Protease trypsinForTestNonAndSemiSpecificDigests = new Protease("trypsinForTestNonAndSemiSpecificDigests", + CleavageSpecificity.Full, "asdf", "asdf", motifList); + Protease semiTrypsinForTestNonAndSemiSpecificDigests = new Protease( + "semitrypsinForTestNonAndSemiSpecificDigests", CleavageSpecificity.Semi, "asdf", "asdf", motifList); //add these made up proteases to the dictionary - ProteaseDictionary.Dictionary.Add(trypsinForTestNonAndSemiSpecificDigests.Name, trypsinForTestNonAndSemiSpecificDigests); - ProteaseDictionary.Dictionary.Add(semiTrypsinForTestNonAndSemiSpecificDigests.Name, semiTrypsinForTestNonAndSemiSpecificDigests); + ProteaseDictionary.Dictionary.Add(trypsinForTestNonAndSemiSpecificDigests.Name, + trypsinForTestNonAndSemiSpecificDigests); + ProteaseDictionary.Dictionary.Add(semiTrypsinForTestNonAndSemiSpecificDigests.Name, + semiTrypsinForTestNonAndSemiSpecificDigests); //Digest with the full DigestionParams fullyDigestParams = new DigestionParams(trypsinForTestNonAndSemiSpecificDigests.Name, 3, 2); @@ -149,7 +176,8 @@ public static void TestNonAndSemiSpecificDigests() Assert.AreEqual(22, fiveCleavageProductsTrypsin.Count); //digests with the semi (variable methionine) - DigestionParams semiDigestionParams = new DigestionParams(semiTrypsinForTestNonAndSemiSpecificDigests.Name, 3, 2); + DigestionParams semiDigestionParams = + new DigestionParams(semiTrypsinForTestNonAndSemiSpecificDigests.Name, 3, 2); var fiveCleavageProductsSemiTrypsin = fiveCleavages.Digest(semiDigestionParams, null, null).ToList(); //This is a partial list of the full peptides. From this, we can GENERATE every possible semi that we would expect to see @@ -172,12 +200,16 @@ public static void TestNonAndSemiSpecificDigests() for (int i = 0; i < s.Length - semiDigestionParams.MinPeptideLength; i++) //cleave it to be semi { string sToFind = s.Substring(i); //get a peptide from this precursor (fixed C) - var peps = fiveCleavageProductsSemiTrypsin.Where(x => x.BaseSequence.Equals(sToFind)).ToArray(); //find the peptide in the digested list - Assert.IsTrue(peps.Length == 1); //There should be exactly one! More than that means there are duplicates, fewer means we didn't generate it! + var peps = fiveCleavageProductsSemiTrypsin.Where(x => x.BaseSequence.Equals(sToFind)) + .ToArray(); //find the peptide in the digested list + Assert.IsTrue(peps.Length == + 1); //There should be exactly one! More than that means there are duplicates, fewer means we didn't generate it! var pep = peps[0]; //get that single peptide //if it's a full sequence (cleaved at both indexes (including termini)) - if ((pep.BaseSequence[0] == pep.BaseSequence[1] || pep.BaseSequence[0] == 'M') && (pep.BaseSequence[pep.BaseSequence.Length - 1] == 'K' - || (pep.BaseSequence[pep.BaseSequence.Length - 1] == 'G' && pep.BaseSequence[pep.BaseSequence.Length - 2] == 'G'))) + if ((pep.BaseSequence[0] == pep.BaseSequence[1] || pep.BaseSequence[0] == 'M') && + (pep.BaseSequence[pep.BaseSequence.Length - 1] == 'K' + || (pep.BaseSequence[pep.BaseSequence.Length - 1] == 'G' && + pep.BaseSequence[pep.BaseSequence.Length - 2] == 'G'))) { Assert.IsTrue(pep.CleavageSpecificityForFdrCategory == CleavageSpecificity.Full); } @@ -185,17 +217,25 @@ public static void TestNonAndSemiSpecificDigests() { Assert.IsTrue(pep.CleavageSpecificityForFdrCategory == CleavageSpecificity.Semi); } + //try to remake the pwsm with unknown specificity... was it assigned the correct specificity? - PeptideWithSetModifications pwsmRemake = new PeptideWithSetModifications(fiveCleavages, semiDigestionParams, pep.OneBasedStartResidueInProtein, pep.OneBasedEndResidueInProtein, CleavageSpecificity.Unknown, "", 3, pep.AllModsOneIsNterminus, 0); - Assert.IsTrue(pwsmRemake.CleavageSpecificityForFdrCategory == pep.CleavageSpecificityForFdrCategory); + PeptideWithSetModifications pwsmRemake = new PeptideWithSetModifications(fiveCleavages, + semiDigestionParams, pep.OneBasedStartResidueInProtein, pep.OneBasedEndResidueInProtein, + CleavageSpecificity.Unknown, "", 3, pep.AllModsOneIsNterminus, 0); + Assert.IsTrue(pwsmRemake.CleavageSpecificityForFdrCategory == + pep.CleavageSpecificityForFdrCategory); //Repeat the above going from the other direction (fixed N) - sToFind = s.Substring(0, semiDigestionParams.MinPeptideLength + i); //get a peptide from this precursor (fixed N) - peps = fiveCleavageProductsSemiTrypsin.Where(x => x.BaseSequence.Equals(sToFind)).ToArray();//find the peptide in the digested list - Assert.IsTrue(peps.Length == 1);//There should be exactly one! More than that means there are duplicates, fewer means we didn't generate it! - pep = peps[0];//get that single peptide + sToFind = s.Substring(0, + semiDigestionParams.MinPeptideLength + i); //get a peptide from this precursor (fixed N) + peps = fiveCleavageProductsSemiTrypsin.Where(x => x.BaseSequence.Equals(sToFind)) + .ToArray(); //find the peptide in the digested list + Assert.IsTrue(peps.Length == + 1); //There should be exactly one! More than that means there are duplicates, fewer means we didn't generate it! + pep = peps[0]; //get that single peptide //if it's a full sequence (cleaved at both indexes (including termini)) - if ((pep.BaseSequence[0] == pep.BaseSequence[1] || pep.BaseSequence[0] == 'M') && pep.BaseSequence.Last() == 'K') + if ((pep.BaseSequence[0] == pep.BaseSequence[1] || pep.BaseSequence[0] == 'M') && + pep.BaseSequence.Last() == 'K') { Assert.IsTrue(pep.CleavageSpecificityForFdrCategory == CleavageSpecificity.Full); } @@ -203,42 +243,75 @@ public static void TestNonAndSemiSpecificDigests() { Assert.IsTrue(pep.CleavageSpecificityForFdrCategory == CleavageSpecificity.Semi); } + //try to remake the pwsm with unknown specificity... was it assigned the correct specificity? - pwsmRemake = new PeptideWithSetModifications(fiveCleavages, semiDigestionParams, pep.OneBasedStartResidueInProtein, pep.OneBasedEndResidueInProtein, CleavageSpecificity.Unknown, "", 3, pep.AllModsOneIsNterminus, 0); - Assert.IsTrue(pwsmRemake.CleavageSpecificityForFdrCategory == pep.CleavageSpecificityForFdrCategory); + pwsmRemake = new PeptideWithSetModifications(fiveCleavages, semiDigestionParams, + pep.OneBasedStartResidueInProtein, pep.OneBasedEndResidueInProtein, CleavageSpecificity.Unknown, + "", 3, pep.AllModsOneIsNterminus, 0); + Assert.IsTrue(pwsmRemake.CleavageSpecificityForFdrCategory == + pep.CleavageSpecificityForFdrCategory); } } + //confirm there were 85 peptides generated by the semi Assert.AreEqual(85, fiveCleavageProductsSemiTrypsin.Count); //The rest of the tests are less intense //check semi when methionine is cleaved - DigestionParams semiCleaveDigestionParams = new DigestionParams(semiTrypsinForTestNonAndSemiSpecificDigests.Name, 3, 2, initiatorMethionineBehavior: InitiatorMethionineBehavior.Cleave); - var fiveCleavageProductsSemiTrypsinCleave = fiveCleavages.Digest(semiCleaveDigestionParams, null, null).ToList(); - int numVariableWithMet = fiveCleavageProductsSemiTrypsin.Where(x => x.BaseSequence[0] == 'M').Count(); //how many had methionine in the variable digestion? - Assert.AreEqual(fiveCleavageProductsSemiTrypsin.Count, fiveCleavageProductsSemiTrypsinCleave.Count + numVariableWithMet); //there should be the same number of sequences as before, minus the amount of methionine peptides + DigestionParams semiCleaveDigestionParams = new DigestionParams( + semiTrypsinForTestNonAndSemiSpecificDigests.Name, 3, 2, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Cleave); + var fiveCleavageProductsSemiTrypsinCleave = + fiveCleavages.Digest(semiCleaveDigestionParams, null, null).ToList(); + int numVariableWithMet = + fiveCleavageProductsSemiTrypsin.Where(x => x.BaseSequence[0] == 'M') + .Count(); //how many had methionine in the variable digestion? + Assert.AreEqual(fiveCleavageProductsSemiTrypsin.Count, + fiveCleavageProductsSemiTrypsinCleave.Count + + numVariableWithMet); //there should be the same number of sequences as before, minus the amount of methionine peptides //check semi when methionine is retained - DigestionParams semiRetainDigestionParams = new DigestionParams(semiTrypsinForTestNonAndSemiSpecificDigests.Name, 3, 2, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); - var fiveCleavageProductsSemiTrypsinRetain = fiveCleavages.Digest(semiRetainDigestionParams, null, null).ToList(); - int numNotRetained = fiveCleavageProductsSemiTrypsin.Where(x => x.BaseSequence[0] == 'A' && x.BaseSequence[1] == 'A' //how many had Met cleaved in the variable digestion? - && (x.BaseSequence[x.BaseSequence.Length - 1] != 'K' && !(x.BaseSequence[x.BaseSequence.Length - 1] == 'G' && x.BaseSequence[x.BaseSequence.Length - 2] == 'G'))).Count(); - Assert.AreEqual(fiveCleavageProductsSemiTrypsinRetain.Count + numNotRetained, fiveCleavageProductsSemiTrypsin.Count); //there should be the same number of sequences as before, minus the amount of cleaved peptides + DigestionParams semiRetainDigestionParams = new DigestionParams( + semiTrypsinForTestNonAndSemiSpecificDigests.Name, 3, 2, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); + var fiveCleavageProductsSemiTrypsinRetain = + fiveCleavages.Digest(semiRetainDigestionParams, null, null).ToList(); + int numNotRetained = fiveCleavageProductsSemiTrypsin.Where(x => x.BaseSequence[0] == 'A' && + x.BaseSequence[1] == + 'A' //how many had Met cleaved in the variable digestion? + && (x.BaseSequence[ + x.BaseSequence.Length - 1] != 'K' && + !(x.BaseSequence + [x.BaseSequence.Length - 1] == + 'G' && + x.BaseSequence[ + x.BaseSequence.Length - 2] == + 'G'))).Count(); + Assert.AreEqual(fiveCleavageProductsSemiTrypsinRetain.Count + numNotRetained, + fiveCleavageProductsSemiTrypsin + .Count); //there should be the same number of sequences as before, minus the amount of cleaved peptides //Check the speedy semi-specific search (the previous ones were the slow classic) //Fixed N - DigestionParams modernSemiDigestionParamsN = new DigestionParams(trypsinForTestNonAndSemiSpecificDigests.Name, 3, 2, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.N); - var fiveCleavageProductsModernSemiTrypsinN = fiveCleavages.Digest(modernSemiDigestionParamsN, null, null).ToList(); + DigestionParams modernSemiDigestionParamsN = new DigestionParams( + trypsinForTestNonAndSemiSpecificDigests.Name, 3, 2, searchModeType: CleavageSpecificity.Semi, + fragmentationTerminus: FragmentationTerminus.N); + var fiveCleavageProductsModernSemiTrypsinN = + fiveCleavages.Digest(modernSemiDigestionParamsN, null, null).ToList(); Assert.AreEqual(7, fiveCleavageProductsModernSemiTrypsinN.Count); //Fixed C - DigestionParams modernSemiDigestionParamsC = new DigestionParams(trypsinForTestNonAndSemiSpecificDigests.Name, 3, 2, searchModeType: CleavageSpecificity.Semi, fragmentationTerminus: FragmentationTerminus.C); - var fiveCleavageProductsModernSemiTrypsinC = fiveCleavages.Digest(modernSemiDigestionParamsC, null, null).ToList(); + DigestionParams modernSemiDigestionParamsC = new DigestionParams( + trypsinForTestNonAndSemiSpecificDigests.Name, 3, 2, searchModeType: CleavageSpecificity.Semi, + fragmentationTerminus: FragmentationTerminus.C); + var fiveCleavageProductsModernSemiTrypsinC = + fiveCleavages.Digest(modernSemiDigestionParamsC, null, null).ToList(); Assert.AreEqual(6, fiveCleavageProductsModernSemiTrypsinC.Count); //test the maxPeptideLength for both singleN and SingleC (variable methionine) //Single N max peptide length - var modernNonSpecificN = new DigestionParams("singleN", 4, 2, 4, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N); + var modernNonSpecificN = new DigestionParams("singleN", 4, 2, 4, searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.N); var fiveCleavageProductsModernNonSpecificN = fiveCleavages.Digest(modernNonSpecificN, null, null).ToList(); Assert.AreEqual(17, fiveCleavageProductsModernNonSpecificN.Count); foreach (var pep in fiveCleavageProductsModernNonSpecificN) @@ -247,7 +320,8 @@ public static void TestNonAndSemiSpecificDigests() } //Single C max peptide length - var modernNonSpecificC = new DigestionParams("singleC", 4, 2, 4, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); + var modernNonSpecificC = new DigestionParams("singleC", 4, 2, 4, searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.C); var fiveCleavageProductsModernNonSpecificC = fiveCleavages.Digest(modernNonSpecificC, null, null).ToList(); Assert.AreEqual(17, fiveCleavageProductsModernNonSpecificC.Count); foreach (var pep in fiveCleavageProductsModernNonSpecificC) @@ -269,14 +343,19 @@ public static void TestNonAndSemiSpecificDigests() //test classic nonspecific DigestionParams classicNonspecificDigest = new DigestionParams("non-specific", 50); - List classicNonspecificPeptides = fiveCleavages.Digest(classicNonspecificDigest, null, null).ToList(); + List classicNonspecificPeptides = + fiveCleavages.Digest(classicNonspecificDigest, null, null).ToList(); Assert.IsTrue(classicNonspecificPeptides.Count == 78); } - private static void TestSingleProteases(Protein protein, InitiatorMethionineBehavior initiatorMethionineBehavior, FragmentationTerminus fragmentationTerminus, int numSequencesExpected) + private static void TestSingleProteases(Protein protein, + InitiatorMethionineBehavior initiatorMethionineBehavior, FragmentationTerminus fragmentationTerminus, + int numSequencesExpected) { string protease = FragmentationTerminus.N == fragmentationTerminus ? "singleN" : "singleC"; - DigestionParams digestionParams = new DigestionParams(protease, 50, 2, searchModeType: CleavageSpecificity.None, initiatorMethionineBehavior: initiatorMethionineBehavior, fragmentationTerminus: fragmentationTerminus); + DigestionParams digestionParams = new DigestionParams(protease, 50, 2, + searchModeType: CleavageSpecificity.None, initiatorMethionineBehavior: initiatorMethionineBehavior, + fragmentationTerminus: fragmentationTerminus); var products = protein.Digest(digestionParams, null, null).ToList(); Assert.AreEqual(numSequencesExpected, products.Count); } @@ -287,18 +366,24 @@ public static void TestSingleProteasesWithTerminalMods() //we actually don't want C-terminal mods on SingleN or N-terminal mods on SingleC, because they don't influence the fragment ion series and just create a redundant peptide //the modified peptides are found using precursor mass matching after scoring, but that happens downstream in MetaMorpheus ModificationMotif.TryGetMotif("A", out ModificationMotif motif); - Modification nTermMod = new Modification(_originalId: "acetylation", _modificationType: "testModType", _target: motif, _chemicalFormula: ChemicalFormula.ParseFormula("C2H2O1"), _locationRestriction: "N-terminal."); - Modification cTermMod = new Modification(_originalId: "amide", _modificationType: "testModType", _target: motif, _chemicalFormula: ChemicalFormula.ParseFormula("C2H2O1"), _locationRestriction: "C-terminal."); + Modification nTermMod = new Modification(_originalId: "acetylation", _modificationType: "testModType", + _target: motif, _chemicalFormula: ChemicalFormula.ParseFormula("C2H2O1"), + _locationRestriction: "N-terminal."); + Modification cTermMod = new Modification(_originalId: "amide", _modificationType: "testModType", + _target: motif, _chemicalFormula: ChemicalFormula.ParseFormula("C2H2O1"), + _locationRestriction: "C-terminal."); Protein proteinWithMods = new Protein("MAGIAAKLAKDREAAEGLGSHA", "testProtein", oneBasedModifications: new Dictionary> { - { 2, new List{nTermMod } }, - { 22, new List{cTermMod } } + { 2, new List { nTermMod } }, + { 22, new List { cTermMod } } }); - DigestionParams singleN = new DigestionParams(protease: "singleN", searchModeType: CleavageSpecificity.SingleN, fragmentationTerminus: FragmentationTerminus.N); - DigestionParams singleC = new DigestionParams(protease: "singleC", searchModeType: CleavageSpecificity.SingleC, fragmentationTerminus: FragmentationTerminus.C); + DigestionParams singleN = new DigestionParams(protease: "singleN", + searchModeType: CleavageSpecificity.SingleN, fragmentationTerminus: FragmentationTerminus.N); + DigestionParams singleC = new DigestionParams(protease: "singleC", + searchModeType: CleavageSpecificity.SingleC, fragmentationTerminus: FragmentationTerminus.C); List empty = new List(); List allMods = new List { nTermMod, cTermMod }; @@ -324,16 +409,22 @@ public static void TestSingleProteasesWithTerminalMods() Assert.IsTrue(cPeps.Count == 16); //Test single proteases with specific protease - DigestionParams specificNonN = new DigestionParams(protease: "Asp-N", searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N); - DigestionParams specificNonC = new DigestionParams(protease: "Asp-N", searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); - List nSpecificPeps = proteinWithMods.Digest(specificNonN, empty, empty).ToList(); - List cSpecificPeps = proteinWithMods.Digest(specificNonC, empty, empty).ToList(); + DigestionParams specificNonN = new DigestionParams(protease: "Asp-N", + searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N); + DigestionParams specificNonC = new DigestionParams(protease: "Asp-N", + searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); + List nSpecificPeps = + proteinWithMods.Digest(specificNonN, empty, empty).ToList(); + List cSpecificPeps = + proteinWithMods.Digest(specificNonC, empty, empty).ToList(); Assert.IsTrue(nSpecificPeps.Count == cSpecificPeps.Count); Assert.IsTrue(cSpecificPeps.Count == 17); //try again with no missed cleavages - specificNonN = new DigestionParams(protease: "Asp-N", maxMissedCleavages: 0, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N); - specificNonC = new DigestionParams(protease: "Asp-N", maxMissedCleavages: 0, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); + specificNonN = new DigestionParams(protease: "Asp-N", maxMissedCleavages: 0, + searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N); + specificNonC = new DigestionParams(protease: "Asp-N", maxMissedCleavages: 0, + searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); nSpecificPeps = proteinWithMods.Digest(specificNonN, empty, empty).ToList(); cSpecificPeps = proteinWithMods.Digest(specificNonC, empty, empty).ToList(); Assert.IsTrue(nSpecificPeps.Count == 11); @@ -345,10 +436,13 @@ public static void TestSingleProteasesWithSpecificProteases() { Protein tinyProteinWithCleavages = new Protein("ACDREFGHIKLMNPQRST", "tiny"); Protein tinyProteinWithoutCleavages = new Protein("ACDEFGHILMNPQST", "tinier"); - Protein bigProteinWithStretchOfNoCleavages = new Protein("ACDREFGHIKLMNPQRSTGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGACDREFGHIKLMNPQRST", "big"); + Protein bigProteinWithStretchOfNoCleavages = + new Protein("ACDREFGHIKLMNPQRSTGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGACDREFGHIKLMNPQRST", "big"); - DigestionParams dpN = new DigestionParams("trypsin", 1, 5, 20, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N); - DigestionParams dpC = new DigestionParams("trypsin", 1, 5, 20, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); + DigestionParams dpN = new DigestionParams("trypsin", 1, 5, 20, searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.N); + DigestionParams dpC = new DigestionParams("trypsin", 1, 5, 20, searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.C); List empty = new List(); //SingleN tests @@ -370,8 +464,12 @@ public static void TestSingleProteasesWithSpecificProteases() //Methionine cleavage fringe test Protein methionineProtein = new Protein("MDBCEFGDHIKLMNODPQRST", "tiny"); - dpN = new DigestionParams("Asp-N", 2, 5, 20, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N, initiatorMethionineBehavior: InitiatorMethionineBehavior.Cleave); - dpC = new DigestionParams("Asp-N", 2, 5, 20, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C, initiatorMethionineBehavior: InitiatorMethionineBehavior.Cleave); + dpN = new DigestionParams("Asp-N", 2, 5, 20, searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.N, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Cleave); + dpC = new DigestionParams("Asp-N", 2, 5, 20, searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.C, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Cleave); peptides = methionineProtein.Digest(dpN, empty, empty).ToList(); Assert.IsTrue(peptides.Count == 16); peptides = methionineProtein.Digest(dpC, empty, empty).ToList(); @@ -388,7 +486,8 @@ public static void TestHardToParseModifiedSequence() Modification mod = new Modification(_originalId: "Cation:Fe[III]", _modificationType: "Metal", _monoisotopicMass: 1, _locationRestriction: "Anywhere.", _target: motif); - Dictionary mods = new Dictionary { { "Cation:Fe[III] on X", mod } }; + Dictionary mods = new Dictionary + { { "Cation:Fe[III] on X", mod } }; PeptideWithSetModifications pep = new PeptideWithSetModifications(fullSequence, mods); @@ -433,7 +532,8 @@ public static void TestCTermAndLastSideChainModParsing() [Test] public static void TestPeptideWithSetMod_GetHashCode() { - PeptideWithSetModifications pep1 = new PeptideWithSetModifications("SEQUENCEK", new Dictionary()); + PeptideWithSetModifications pep1 = + new PeptideWithSetModifications("SEQUENCEK", new Dictionary()); int oneHashCode = pep1.GetHashCode(); //if digestion params is not defined, the peptidewithsetmods should still return a hashcode. @@ -441,9 +541,11 @@ public static void TestPeptideWithSetMod_GetHashCode() Protein myProtein = new Protein("SEQUENCEK", "accession"); - DigestionParams digest1 = new DigestionParams(protease: "trypsin", maxMissedCleavages: 0, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); + DigestionParams digest1 = new DigestionParams(protease: "trypsin", maxMissedCleavages: 0, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); - PeptideWithSetModifications pep2 = myProtein.Digest(digest1, new List(), new List()).First(); + PeptideWithSetModifications pep2 = + myProtein.Digest(digest1, new List(), new List()).First(); int twoHashCode = pep2.GetHashCode(); @@ -458,7 +560,8 @@ public static void TestTopDownDigestion() { new ProteolysisProduct(5, 20, "asdf") }; - Protein protein = new Protein("MACDEFGHIKLMNOPQRSTVWYMACDEFGHIKLMNOPQRSTVWYMACDEFGHIKLMNOPQRSTVWY", "testProtein", "Mus", proteolysisProducts: proteolysisProducts); + Protein protein = new Protein("MACDEFGHIKLMNOPQRSTVWYMACDEFGHIKLMNOPQRSTVWYMACDEFGHIKLMNOPQRSTVWY", + "testProtein", "Mus", proteolysisProducts: proteolysisProducts); DigestionParams topdownParams = new DigestionParams("top-down"); List peptides = protein.Digest(topdownParams, null, null).ToList(); Assert.IsTrue(peptides.Count == 3); @@ -469,32 +572,47 @@ public static void TestUpdateCleavageSpecificity() { Protein protein = new Protein("MACDEFGHIKLMNPQRST", "test"); DigestionParams dpVariable = new DigestionParams(); - DigestionParams dpRetain = new DigestionParams(initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); + DigestionParams dpRetain = + new DigestionParams(initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); Dictionary empty = new Dictionary(); //Test with varying Methionine - PeptideWithSetModifications fullCleavageVariableMet = new PeptideWithSetModifications(protein, dpVariable, 2, 10, CleavageSpecificity.Unknown, "", 0, empty, 0); + PeptideWithSetModifications fullCleavageVariableMet = + new PeptideWithSetModifications(protein, dpVariable, 2, 10, CleavageSpecificity.Unknown, "", 0, empty, + 0); Assert.IsTrue(fullCleavageVariableMet.CleavageSpecificityForFdrCategory == CleavageSpecificity.Full); - PeptideWithSetModifications fullCleavageRetainMet = new PeptideWithSetModifications(protein, dpRetain, 2, 10, CleavageSpecificity.Unknown, "", 0, empty, 0); + PeptideWithSetModifications fullCleavageRetainMet = + new PeptideWithSetModifications(protein, dpRetain, 2, 10, CleavageSpecificity.Unknown, "", 0, empty, 0); Assert.IsTrue(fullCleavageRetainMet.CleavageSpecificityForFdrCategory == CleavageSpecificity.Semi); - PeptideWithSetModifications semiCleavageVariableMet = new PeptideWithSetModifications(protein, dpVariable, 2, 9, CleavageSpecificity.Unknown, "", 0, empty, 0); + PeptideWithSetModifications semiCleavageVariableMet = + new PeptideWithSetModifications(protein, dpVariable, 2, 9, CleavageSpecificity.Unknown, "", 0, empty, + 0); Assert.IsTrue(semiCleavageVariableMet.CleavageSpecificityForFdrCategory == CleavageSpecificity.Semi); - PeptideWithSetModifications semiCleavageRetainMet = new PeptideWithSetModifications(protein, dpRetain, 2, 9, CleavageSpecificity.Unknown, "", 0, empty, 0); + PeptideWithSetModifications semiCleavageRetainMet = + new PeptideWithSetModifications(protein, dpRetain, 2, 9, CleavageSpecificity.Unknown, "", 0, empty, 0); Assert.IsTrue(semiCleavageRetainMet.CleavageSpecificityForFdrCategory == CleavageSpecificity.None); - PeptideWithSetModifications noneCleavageVariableMet = new PeptideWithSetModifications(protein, dpVariable, 3, 9, CleavageSpecificity.Unknown, "", 0, empty, 0); + PeptideWithSetModifications noneCleavageVariableMet = + new PeptideWithSetModifications(protein, dpVariable, 3, 9, CleavageSpecificity.Unknown, "", 0, empty, + 0); Assert.IsTrue(noneCleavageVariableMet.CleavageSpecificityForFdrCategory == CleavageSpecificity.None); - PeptideWithSetModifications noneCleavageRetainMet = new PeptideWithSetModifications(protein, dpRetain, 3, 9, CleavageSpecificity.Unknown, "", 0, empty, 0); + PeptideWithSetModifications noneCleavageRetainMet = + new PeptideWithSetModifications(protein, dpRetain, 3, 9, CleavageSpecificity.Unknown, "", 0, empty, 0); Assert.IsTrue(noneCleavageRetainMet.CleavageSpecificityForFdrCategory == CleavageSpecificity.None); //Test with proteolytic cleavages - protein = new Protein("MACDEFGHIKLMNPQRST", "test", proteolysisProducts: new List { new ProteolysisProduct(3, 9, "chain") }); - PeptideWithSetModifications fullProteolytic = new PeptideWithSetModifications(protein, dpVariable, 3, 9, CleavageSpecificity.Unknown, "", 0, empty, 0); + protein = new Protein("MACDEFGHIKLMNPQRST", "test", + proteolysisProducts: new List { new ProteolysisProduct(3, 9, "chain") }); + PeptideWithSetModifications fullProteolytic = new PeptideWithSetModifications(protein, dpVariable, 3, 9, + CleavageSpecificity.Unknown, "", 0, empty, 0); Assert.IsTrue(fullProteolytic.CleavageSpecificityForFdrCategory == CleavageSpecificity.Full); - fullProteolytic = new PeptideWithSetModifications(protein, dpVariable, 3, 10, CleavageSpecificity.Unknown, "", 0, empty, 0); + fullProteolytic = new PeptideWithSetModifications(protein, dpVariable, 3, 10, CleavageSpecificity.Unknown, + "", 0, empty, 0); Assert.IsTrue(fullProteolytic.CleavageSpecificityForFdrCategory == CleavageSpecificity.Full); - PeptideWithSetModifications semiProteolytic = new PeptideWithSetModifications(protein, dpVariable, 3, 6, CleavageSpecificity.Unknown, "", 0, empty, 0); + PeptideWithSetModifications semiProteolytic = new PeptideWithSetModifications(protein, dpVariable, 3, 6, + CleavageSpecificity.Unknown, "", 0, empty, 0); Assert.IsTrue(semiProteolytic.CleavageSpecificityForFdrCategory == CleavageSpecificity.Semi); - semiProteolytic = new PeptideWithSetModifications(protein, dpVariable, 5, 9, CleavageSpecificity.Unknown, "", 0, empty, 0); + semiProteolytic = new PeptideWithSetModifications(protein, dpVariable, 5, 9, CleavageSpecificity.Unknown, + "", 0, empty, 0); Assert.IsTrue(semiProteolytic.CleavageSpecificityForFdrCategory == CleavageSpecificity.Semi); } @@ -502,8 +620,12 @@ public static void TestUpdateCleavageSpecificity() public static void TestSingleProteasesTinyProtein() { Protein P56381 = new Protein("MVAYWRQAGLSYIRYSQICAKAVRDALKTEFKANAEKTSGSNVKIVKVKKE", "P56381"); - DigestionParams singleN = new DigestionParams(protease: "Asp-N", maxMissedCleavages: 3, minPeptideLength: 7, maxPeptideLength: 50, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.N); - DigestionParams singleC = new DigestionParams(protease: "Asp-N", maxMissedCleavages: 3, minPeptideLength: 7, maxPeptideLength: 50, searchModeType: CleavageSpecificity.None, fragmentationTerminus: FragmentationTerminus.C); + DigestionParams singleN = new DigestionParams(protease: "Asp-N", maxMissedCleavages: 3, minPeptideLength: 7, + maxPeptideLength: 50, searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.N); + DigestionParams singleC = new DigestionParams(protease: "Asp-N", maxMissedCleavages: 3, minPeptideLength: 7, + maxPeptideLength: 50, searchModeType: CleavageSpecificity.None, + fragmentationTerminus: FragmentationTerminus.C); List nPwsms = P56381.Digest(singleN, null, null).ToList(); List cPwsms = P56381.Digest(singleC, null, null).ToList(); Assert.IsTrue(nPwsms.Count == cPwsms.Count); @@ -514,7 +636,8 @@ public static void TestSingleProteasesTinyProtein() public static void TestIncludeSpliceSiteRanges() { Protein protein = new Protein("MACDEFGHIKLMNPQRST", "test"); - PeptideWithSetModifications pepe = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 10, CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); + PeptideWithSetModifications pepe = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 10, + CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); SpliceSite ss1Before = new SpliceSite(1, 1, ""); SpliceSite ss2BeginningBefore = new SpliceSite(1, 2, ""); SpliceSite ss3 = new SpliceSite(2, 3, ""); @@ -535,18 +658,28 @@ public static void TestIncludeSpliceSiteRanges() public static void TestIntersectsSequenceVariations() { Protein protein = new Protein("MACDEFGHIK", "test"); - PeptideWithSetModifications pepe = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 10, CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); + PeptideWithSetModifications pepe = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 10, + CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); // The weird thing here is that IntersectsWithVariation takes in applied variations, // so these are constructed as if already applied SequenceVariation sv1Before = new SequenceVariation(1, 1, "A", "M", ""); // before peptide (not identified) - SequenceVariation sv2Synonymous = new SequenceVariation(2, 2, "A", "A", ""); // no change (intersects because peptide crosses entire variant but is not truly "identified") + SequenceVariation + sv2Synonymous = + new SequenceVariation(2, 2, "A", "A", + ""); // no change (intersects because peptide crosses entire variant but is not truly "identified") SequenceVariation sv4MissenseBeginning = new SequenceVariation(2, 2, "V", "A", ""); // missense at beginning - SequenceVariation sv5InsertionAtEnd = new SequenceVariation(7, 9, "GHI", "GHIK", ""); // insertion or stop loss + SequenceVariation + sv5InsertionAtEnd = new SequenceVariation(7, 9, "GHI", "GHIK", ""); // insertion or stop loss SequenceVariation sv6Deletion = new SequenceVariation(2, 3, "AC", "A", ""); // deletion - SequenceVariation sv66Truncation = new SequenceVariation(10, 20, "KAAAAAAAAAA", "K", ""); // truncation or stop gain (identified because peptide crosses entire variant) + SequenceVariation + sv66Truncation = + new SequenceVariation(10, 20, "KAAAAAAAAAA", "K", + ""); // truncation or stop gain (identified because peptide crosses entire variant) SequenceVariation sv7MNP = new SequenceVariation(2, 3, "AA", "AC", ""); // mnp - SequenceVariation sv77MNP = new SequenceVariation(2, 3, "AC", "AC", ""); // synonymous mnp (identified because peptide crosses entire variant) + SequenceVariation + sv77MNP = new SequenceVariation(2, 3, "AC", "AC", + ""); // synonymous mnp (identified because peptide crosses entire variant) SequenceVariation sv9MissenseInRange = new SequenceVariation(3, 3, "C", "V", ""); // missense in range SequenceVariation sv10MissenseRangeEdge = new SequenceVariation(10, 10, "K", "R", ""); // missense at end SequenceVariation sv11After = new SequenceVariation(11, 11, "L", "V", ""); // after peptide (not identified) @@ -575,18 +708,27 @@ public static void TestIntersectsSequenceVariations() Assert.IsTrue(pepe.IntersectsAndIdentifiesVariation(sv10MissenseRangeEdge).identifies); Assert.IsFalse(pepe.IntersectsAndIdentifiesVariation(sv11After).identifies); - PeptideWithSetModifications pepe2 = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 9, CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); - Assert.IsTrue(pepe2.IntersectsAndIdentifiesVariation(sv5InsertionAtEnd).intersects); // this only intersects GHI, which is the same in GHI -> GHIK + PeptideWithSetModifications pepe2 = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 9, + CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); + Assert.IsTrue(pepe2.IntersectsAndIdentifiesVariation(sv5InsertionAtEnd) + .intersects); // this only intersects GHI, which is the same in GHI -> GHIK Assert.IsFalse(pepe2.IntersectsAndIdentifiesVariation(sv5InsertionAtEnd).identifies); } [Test] public static void TestIsVariantPeptide() { - Protein protein = new Protein("MPEPTIDENEWPEPTIDE", "protein0", appliedSequenceVariations: new List { new SequenceVariation(4, 4, "P", "V", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }); + Protein protein = new Protein("MPEPTIDENEWPEPTIDE", "protein0", + appliedSequenceVariations: new List + { + new SequenceVariation(4, 4, "P", "V", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }); - PeptideWithSetModifications pepe = new PeptideWithSetModifications(protein, new DigestionParams(), 1, 8, CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); - PeptideWithSetModifications notPepe = new PeptideWithSetModifications(protein, new DigestionParams(), 9, 18, CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); + PeptideWithSetModifications pepe = new PeptideWithSetModifications(protein, new DigestionParams(), 1, 8, + CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); + PeptideWithSetModifications notPepe = new PeptideWithSetModifications(protein, new DigestionParams(), 9, 18, + CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); Assert.IsTrue(pepe.IsVariantPeptide()); Assert.IsFalse(notPepe.IsVariantPeptide()); @@ -598,25 +740,33 @@ public static void TestSeqVarString() Protein protein = new Protein("MACDEFGHIK", "test"); // mod on N-terminus - PeptideWithSetModifications pepe = new PeptideWithSetModifications(protein, new DigestionParams(), 1, 10, CleavageSpecificity.Unknown, "", 0, new Dictionary { { 1, new Modification("mod on M", "mod", "mod", "mod") } }, 0); - SequenceVariation sv1Before = new SequenceVariation(1, 1, "A", "M", ""); // n-terminal mod goes before the sequence + PeptideWithSetModifications pepe = new PeptideWithSetModifications(protein, new DigestionParams(), 1, 10, + CleavageSpecificity.Unknown, "", 0, + new Dictionary { { 1, new Modification("mod on M", "mod", "mod", "mod") } }, 0); + SequenceVariation + sv1Before = new SequenceVariation(1, 1, "A", "M", ""); // n-terminal mod goes before the sequence Assert.AreEqual("A1[mod:mod on M]M", pepe.SequenceVariantString(sv1Before, true)); // mod in middle - PeptideWithSetModifications pepe2 = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 10, CleavageSpecificity.Unknown, "", 0, new Dictionary { { 2, new Modification("mod on A", "mod", "mod", "mod") } }, 0); + PeptideWithSetModifications pepe2 = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 10, + CleavageSpecificity.Unknown, "", 0, + new Dictionary { { 2, new Modification("mod on A", "mod", "mod", "mod") } }, 0); SequenceVariation sv4MissenseBeginning = new SequenceVariation(2, 2, "V", "A", ""); // missense at beginning Assert.AreEqual("V2A[mod:mod on A]", pepe2.SequenceVariantString(sv4MissenseBeginning, true)); // truncated seqvar doesn't truncate in string report (using applied variation correctly) - PeptideWithSetModifications pepe3 = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 9, CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); + PeptideWithSetModifications pepe3 = new PeptideWithSetModifications(protein, new DigestionParams(), 2, 9, + CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); SequenceVariation svvvv = new SequenceVariation(7, 10, "GHM", "GHIK", ""); // insertion Assert.AreEqual("GHM7GHIK", pepe3.SequenceVariantString(svvvv, true)); Protein protein2 = new Protein("WACDEFGHIK", "test"); //variant starts at protein start but peptide does not - PeptideWithSetModifications pepe4 = new PeptideWithSetModifications(protein2, new DigestionParams(), 4, 8, CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); - SequenceVariation variant = new SequenceVariation(1, 10, "MABCDEFGHIJKLMNOP", "WACDEFGHIK", ""); // frameshift + PeptideWithSetModifications pepe4 = new PeptideWithSetModifications(protein2, new DigestionParams(), 4, 8, + CleavageSpecificity.Unknown, "", 0, new Dictionary(), 0); + SequenceVariation + variant = new SequenceVariation(1, 10, "MABCDEFGHIJKLMNOP", "WACDEFGHIK", ""); // frameshift Assert.AreEqual("MABCDEFGHIJKLMNOP1WACDEFGHIK", pepe4.SequenceVariantString(variant, true)); } @@ -624,9 +774,11 @@ public static void TestSeqVarString() public static void TestIdentifyandStringMethods() { ModificationMotif.TryGetMotif("V", out ModificationMotif motifV); - Modification mv = new Modification("mod", null, "type", null, motifV, "Anywhere.", null, 42.01, new Dictionary>(), null, null, null, null, null); + Modification mv = new Modification("mod", null, "type", null, motifV, "Anywhere.", null, 42.01, + new Dictionary>(), null, null, null, null, null); ModificationMotif.TryGetMotif("P", out ModificationMotif motifP); - Modification mp = new Modification("mod", null, "type", null, motifP, "Anywhere.", null, 42.01, new Dictionary>(), null, null, null, null, null); + Modification mp = new Modification("mod", null, "type", null, motifP, "Anywhere.", null, 42.01, + new Dictionary>(), null, null, null, null, null); Dictionary modV = new Dictionary(); modV.Add(4, mv); Dictionary modP = new Dictionary(); @@ -637,22 +789,104 @@ public static void TestIdentifyandStringMethods() List proteins = new List { - new Protein("MPEPTIDE", "protein0", sequenceVariations: new List { new SequenceVariation(4, 4, "P", "V", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), - new Protein("MPEPTIDE", "protein1", sequenceVariations: new List { new SequenceVariation(4, 5, "PT", "KT", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), - new Protein("MPEPTIDE", "protein2", 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", null) }), - 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) }), - new Protein("MPEPKPKTIDE", "protein4", sequenceVariations: new List { new SequenceVariation(4, 7, "PKPK", "PK", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), - new Protein("MPEPTAIDE", "protein5",sequenceVariations: new List { new SequenceVariation(4, 6, "PTA", "KT", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), - new Protein("MPEKKAIDE", "protein6", sequenceVariations: new List { new SequenceVariation(4, 6, "KKA", "K", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), - new Protein("MPEPTIDE", "protein7", sequenceVariations: new List { new SequenceVariation(4, 4, "P", "V", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", new Dictionary> {{ 4, new[] { mv }.ToList() } }) }), - new Protein("MPEPTIDE", "protein8",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", "protein9", sequenceVariations: new List { new SequenceVariation(4, 15, "PTIDEPEPTIDE", "PPP", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), - new Protein("MPEPTIDE", "protein10", oneBasedModifications: proteinPMods ,sequenceVariations: new List { new SequenceVariation(4, 4, "P", "V", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), - new Protein("MPEPTIDE", "protein11", sequenceVariations: new List { new SequenceVariation(5, 5, "T", "*", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), //stop-gain (can identify) - new Protein("MPEKTIDE", "protein12", sequenceVariations: new List { new SequenceVariation(5, 5, "T", "*", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), //stop-gain (can't identify) - new Protein("MPEPTIPEPEPTIPE", "protein13", sequenceVariations: new List { new SequenceVariation(7, 7, "P", "D", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), - new Protein("MPEPTIDE", "protein14", sequenceVariations: new List { new SequenceVariation(8, 9, "E", "EK", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), //peptide becomes longer, and cleavage site is created but cannot be identified - new Protein("MPEPTIDE", "protein15", sequenceVariations: new List { new SequenceVariation(9, 13, "*", "KMPEP", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) }), // stop loss at end of original protein that cannot be identified + new Protein("MPEPTIDE", "protein0", + sequenceVariations: new List + { + new SequenceVariation(4, 4, "P", "V", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), + new Protein("MPEPTIDE", "protein1", + sequenceVariations: new List + { + new SequenceVariation(4, 5, "PT", "KT", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), + new Protein("MPEPTIDE", "protein2", + 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", null) + }), + 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) + }), + new Protein("MPEPKPKTIDE", "protein4", + sequenceVariations: new List + { + new SequenceVariation(4, 7, "PKPK", "PK", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), + new Protein("MPEPTAIDE", "protein5", + sequenceVariations: new List + { + new SequenceVariation(4, 6, "PTA", "KT", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), + new Protein("MPEKKAIDE", "protein6", + sequenceVariations: new List + { + new SequenceVariation(4, 6, "KKA", "K", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), + new Protein("MPEPTIDE", "protein7", + sequenceVariations: new List + { + new SequenceVariation(4, 4, "P", "V", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", + new Dictionary> { { 4, new[] { mv }.ToList() } }) + }), + new Protein("MPEPTIDE", "protein8", + 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", "protein9", + sequenceVariations: new List + { + new SequenceVariation(4, 15, "PTIDEPEPTIDE", "PPP", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), + new Protein("MPEPTIDE", "protein10", oneBasedModifications: proteinPMods, + sequenceVariations: new List + { + new SequenceVariation(4, 4, "P", "V", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), + new Protein("MPEPTIDE", "protein11", + sequenceVariations: new List + { + new SequenceVariation(5, 5, "T", "*", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), //stop-gain (can identify) + new Protein("MPEKTIDE", "protein12", + sequenceVariations: new List + { + new SequenceVariation(5, 5, "T", "*", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), //stop-gain (can't identify) + new Protein("MPEPTIPEPEPTIPE", "protein13", + sequenceVariations: new List + { + new SequenceVariation(7, 7, "P", "D", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), + new Protein("MPEPTIDE", "protein14", + sequenceVariations: new List + { + new SequenceVariation(8, 9, "E", "EK", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), //peptide becomes longer, and cleavage site is created but cannot be identified + new Protein("MPEPTIDE", "protein15", + sequenceVariations: new List + { + new SequenceVariation(9, 13, "*", "KMPEP", + @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null) + }), // stop loss at end of original protein that cannot be identified }; DigestionParams dp = new DigestionParams(minPeptideLength: 2); @@ -697,76 +931,145 @@ public static void TestIdentifyandStringMethods() var protein14_peptide = protein14_variant.Digest(dp3, digestMods, digestMods).ElementAt(0); var protein15_peptide = protein15_variant.Digest(dp3, digestMods, digestMods).ElementAt(0); - Assert.AreEqual((true, true), protein0_peptide.IntersectsAndIdentifiesVariation(protein0_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein0_peptide2.IntersectsAndIdentifiesVariation(protein0_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein1_peptide.IntersectsAndIdentifiesVariation(protein1_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein2_peptide.IntersectsAndIdentifiesVariation(protein2_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein3_peptide.IntersectsAndIdentifiesVariation(protein3_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((false, false), protein4_peptide.IntersectsAndIdentifiesVariation(protein4_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein5_peptide.IntersectsAndIdentifiesVariation(protein5_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((false, true), protein6_peptide.IntersectsAndIdentifiesVariation(protein6_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein7_peptide.IntersectsAndIdentifiesVariation(protein7_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein8_peptide.IntersectsAndIdentifiesVariation(protein8_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein9_peptide.IntersectsAndIdentifiesVariation(protein9_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, true), protein10_peptide.IntersectsAndIdentifiesVariation(protein10_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((false, true), protein11_peptide.IntersectsAndIdentifiesVariation(protein11_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((false, true), protein11_peptide2.IntersectsAndIdentifiesVariation(protein11_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((false, false), protein12_peptide.IntersectsAndIdentifiesVariation(protein12_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((false, true), protein13_peptide.IntersectsAndIdentifiesVariation(protein13_variant.AppliedSequenceVariations.ElementAt(0))); - Assert.AreEqual((true, false), protein14_peptide.IntersectsAndIdentifiesVariation(protein14_variant.AppliedSequenceVariations.ElementAt(0)));// the peptide crosses the variant but the newly genrated cleavage site makes the same peptide as without the variant - Assert.AreEqual((false, false), protein15_peptide.IntersectsAndIdentifiesVariation(protein15_variant.AppliedSequenceVariations.ElementAt(0)));// the peptide does not cross the variant, and the stop loss adds addition amino acids, but it creates the same peptide as without the variant - - Assert.AreEqual("P4V", protein0_peptide.SequenceVariantString(protein0_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("P4V", protein0_peptide2.SequenceVariantString(protein0_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("PT4KT", protein1_peptide.SequenceVariantString(protein1_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("P4PPP", protein2_peptide.SequenceVariantString(protein2_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("PPP4P", protein3_peptide.SequenceVariantString(protein3_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("PTA4KT", protein5_peptide.SequenceVariantString(protein5_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("KKA4K", protein6_peptide.SequenceVariantString(protein6_variant.AppliedSequenceVariations.ElementAt(0), false)); - Assert.AreEqual("P4V[type:mod on V]", protein7_peptide.SequenceVariantString(protein7_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("P4PP[type:mod on P]P", protein8_peptide.SequenceVariantString(protein8_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("PTIDEPEPTIDE4PPP", protein9_peptide.SequenceVariantString(protein9_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("P4V", protein10_peptide.SequenceVariantString(protein10_variant.AppliedSequenceVariations.ElementAt(0), true)); - Assert.AreEqual("T5*", protein11_peptide.SequenceVariantString(protein11_variant.AppliedSequenceVariations.ElementAt(0), false)); - Assert.AreEqual("T5*", protein11_peptide2.SequenceVariantString(protein11_variant.AppliedSequenceVariations.ElementAt(0), false)); - Assert.AreEqual("P7D", protein13_peptide.SequenceVariantString(protein13_variant.AppliedSequenceVariations.ElementAt(0), false)); + Assert.AreEqual((true, true), + protein0_peptide.IntersectsAndIdentifiesVariation( + protein0_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein0_peptide2.IntersectsAndIdentifiesVariation( + protein0_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein1_peptide.IntersectsAndIdentifiesVariation( + protein1_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein2_peptide.IntersectsAndIdentifiesVariation( + protein2_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein3_peptide.IntersectsAndIdentifiesVariation( + protein3_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((false, false), + protein4_peptide.IntersectsAndIdentifiesVariation( + protein4_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein5_peptide.IntersectsAndIdentifiesVariation( + protein5_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((false, true), + protein6_peptide.IntersectsAndIdentifiesVariation( + protein6_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein7_peptide.IntersectsAndIdentifiesVariation( + protein7_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein8_peptide.IntersectsAndIdentifiesVariation( + protein8_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein9_peptide.IntersectsAndIdentifiesVariation( + protein9_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, true), + protein10_peptide.IntersectsAndIdentifiesVariation( + protein10_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((false, true), + protein11_peptide.IntersectsAndIdentifiesVariation( + protein11_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((false, true), + protein11_peptide2.IntersectsAndIdentifiesVariation(protein11_variant.AppliedSequenceVariations + .ElementAt(0))); + Assert.AreEqual((false, false), + protein12_peptide.IntersectsAndIdentifiesVariation( + protein12_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((false, true), + protein13_peptide.IntersectsAndIdentifiesVariation( + protein13_variant.AppliedSequenceVariations.ElementAt(0))); + Assert.AreEqual((true, false), + protein14_peptide.IntersectsAndIdentifiesVariation( + protein14_variant.AppliedSequenceVariations + .ElementAt(0))); // the peptide crosses the variant but the newly genrated cleavage site makes the same peptide as without the variant + Assert.AreEqual((false, false), + protein15_peptide.IntersectsAndIdentifiesVariation( + protein15_variant.AppliedSequenceVariations + .ElementAt(0))); // the peptide does not cross the variant, and the stop loss adds addition amino acids, but it creates the same peptide as without the variant + + Assert.AreEqual("P4V", + protein0_peptide.SequenceVariantString(protein0_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("P4V", + protein0_peptide2.SequenceVariantString(protein0_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("PT4KT", + protein1_peptide.SequenceVariantString(protein1_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("P4PPP", + protein2_peptide.SequenceVariantString(protein2_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("PPP4P", + protein3_peptide.SequenceVariantString(protein3_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("PTA4KT", + protein5_peptide.SequenceVariantString(protein5_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("KKA4K", + protein6_peptide.SequenceVariantString(protein6_variant.AppliedSequenceVariations.ElementAt(0), false)); + Assert.AreEqual("P4V[type:mod on V]", + protein7_peptide.SequenceVariantString(protein7_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("P4PP[type:mod on P]P", + protein8_peptide.SequenceVariantString(protein8_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("PTIDEPEPTIDE4PPP", + protein9_peptide.SequenceVariantString(protein9_variant.AppliedSequenceVariations.ElementAt(0), true)); + Assert.AreEqual("P4V", + protein10_peptide.SequenceVariantString(protein10_variant.AppliedSequenceVariations.ElementAt(0), + true)); + Assert.AreEqual("T5*", + protein11_peptide.SequenceVariantString(protein11_variant.AppliedSequenceVariations.ElementAt(0), + false)); + Assert.AreEqual("T5*", + protein11_peptide2.SequenceVariantString(protein11_variant.AppliedSequenceVariations.ElementAt(0), + false)); + Assert.AreEqual("P7D", + protein13_peptide.SequenceVariantString(protein13_variant.AppliedSequenceVariations.ElementAt(0), + false)); } [Test] public static void BreakDeserializationMethod() { - Assert.Throws(() => new PeptideWithSetModifications("|", new Dictionary())); // ambiguous - Assert.Throws(() => new PeptideWithSetModifications("[]", new Dictionary())); // bad mod - Assert.Throws(() => new PeptideWithSetModifications("A[:mod]", new Dictionary())); // nonexistent mod + Assert.Throws(() => + new PeptideWithSetModifications("|", new Dictionary())); // ambiguous + Assert.Throws(() => + new PeptideWithSetModifications("[]", new Dictionary())); // bad mod + Assert.Throws(() => + new PeptideWithSetModifications("A[:mod]", new Dictionary())); // nonexistent mod } [Test] public static void TestReverseDecoyFromTarget() { ModificationMotif.TryGetMotif("P", out ModificationMotif motif_p); - Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _target: motif_p, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); + Modification phosphorylation = new Modification(_originalId: "phospho", + _modificationType: "CommonBiological", _target: motif_p, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); ModificationMotif.TryGetMotif("K", out ModificationMotif motif_k); - Modification acetylation = new Modification(_originalId: "acetyl", _modificationType: "CommonBiological", _target: motif_k, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); + Modification acetylation = new Modification(_originalId: "acetyl", _modificationType: "CommonBiological", + _target: motif_k, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); - Modification nTermAcet = new Modification(_originalId: "n-acetyl", _modificationType: "CommonBiological", _target: null, _locationRestriction: "N-terminal.", _chemicalFormula: ChemicalFormula.ParseFormula("H")); + Modification nTermAcet = new Modification(_originalId: "n-acetyl", _modificationType: "CommonBiological", + _target: null, _locationRestriction: "N-terminal.", + _chemicalFormula: ChemicalFormula.ParseFormula("H")); - Dictionary allmodsoneisnterminus = new Dictionary { { 1, nTermAcet }, { 6, phosphorylation }, { 9, acetylation } }; + Dictionary allmodsoneisnterminus = new Dictionary + { { 1, nTermAcet }, { 6, phosphorylation }, { 9, acetylation } }; - PeptideWithSetModifications p = new PeptideWithSetModifications(new Protein("PEPTIDEK", "ACCESSIION"), new DigestionParams(), 1, 8, CleavageSpecificity.Full, null, 0, allmodsoneisnterminus, 0, null); + PeptideWithSetModifications p = new PeptideWithSetModifications(new Protein("PEPTIDEK", "ACCESSIION"), + new DigestionParams(), 1, 8, CleavageSpecificity.Full, null, 0, allmodsoneisnterminus, 0, null); int[] newAminoAcidPositions = new int["PEPTIDEK".Length]; PeptideWithSetModifications reverse = p.GetReverseDecoyFromTarget(newAminoAcidPositions); // Hash code corresponding to the target sequence, should be PairedTargetDecoyHash for reverse int testTargetHash = p.GetHashCode(); // Hash code corresponding to the decoy sequence, should be PairedTargetDecoyHash for target - int testDecoyHash = reverse.GetHashCode(); + int testDecoyHash = reverse.GetHashCode(); Assert.AreEqual(reverse.PairedTargetDecoyHash, testTargetHash); Assert.AreEqual(p.PairedTargetDecoyHash, testDecoyHash); Assert.AreEqual("EDITPEPK", reverse.BaseSequence); Assert.AreEqual(new int[] { 6, 5, 4, 3, 2, 1, 0, 7 }, newAminoAcidPositions); Assert.IsTrue(reverse.Protein.IsDecoy); - Assert.AreEqual(p.Protein.BaseSequence.Length, reverse.Protein.BaseSequence.Length);//we replaced the original with the new so the protein should have the same length + Assert.AreEqual(p.Protein.BaseSequence.Length, + reverse.Protein.BaseSequence + .Length); //we replaced the original with the new so the protein should have the same length Assert.AreEqual(reverse.PeptideDescription, p.FullSequence); List decoyProducts = new List(); @@ -776,7 +1079,9 @@ public static void TestReverseDecoyFromTarget() // Arg-C -- Cleave after R newAminoAcidPositions = new int["RPEPTIREK".Length]; - PeptideWithSetModifications p_argC = new PeptideWithSetModifications(new Protein("RPEPTIREK", "DECOY_ARGC"), new DigestionParams(protease: "Arg-C"), 1, 9, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications p_argC = new PeptideWithSetModifications(new Protein("RPEPTIREK", "DECOY_ARGC"), + new DigestionParams(protease: "Arg-C"), 1, 9, CleavageSpecificity.Full, null, 0, + new Dictionary(), 0, null); PeptideWithSetModifications p_argC_reverse = p_argC.GetReverseDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual("RKEITPREP", p_argC_reverse.BaseSequence); Assert.AreEqual(new int[] { 0, 8, 7, 5, 4, 3, 6, 2, 1 }, newAminoAcidPositions); @@ -784,54 +1089,74 @@ public static void TestReverseDecoyFromTarget() // Asp-N -- Cleave before D newAminoAcidPositions = new int["DPEPTIDEK".Length]; - PeptideWithSetModifications p_aspN = new PeptideWithSetModifications(new Protein("DPEPTIDEK", "DECOY_ASPN"), new DigestionParams(protease: "Asp-N"), 1, 9, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications p_aspN = new PeptideWithSetModifications(new Protein("DPEPTIDEK", "DECOY_ASPN"), + new DigestionParams(protease: "Asp-N"), 1, 9, CleavageSpecificity.Full, null, 0, + new Dictionary(), 0, null); PeptideWithSetModifications p_aspN_reverse = p_aspN.GetReverseDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual("DKEITPDEP", p_aspN_reverse.BaseSequence); Assert.AreEqual(p_aspN.FullSequence, p_aspN_reverse.PeptideDescription); // chymotrypsin (don't cleave before proline) newAminoAcidPositions = new int["FKFPRWAWPSYGYPG".Length]; - PeptideWithSetModifications p_chymoP = new PeptideWithSetModifications(new Protein("FKFPRWAWPSYGYPG", "DECOY_CHYMOP"), new DigestionParams(protease: "chymotrypsin (don't cleave before proline)", maxMissedCleavages: 10), 1, 15, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications p_chymoP = new PeptideWithSetModifications( + new Protein("FKFPRWAWPSYGYPG", "DECOY_CHYMOP"), + new DigestionParams(protease: "chymotrypsin (don't cleave before proline)", maxMissedCleavages: 10), 1, + 15, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); PeptideWithSetModifications p_chymoP_reverse = p_chymoP.GetReverseDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual("FGPYGWSPWAYRPFK", p_chymoP_reverse.BaseSequence); Assert.AreEqual(p_chymoP.FullSequence, p_chymoP_reverse.PeptideDescription); // chymotrypsin (don't cleave before proline) newAminoAcidPositions = new int["FKFPRWAWPSYGYPG".Length]; - PeptideWithSetModifications p_chymo = new PeptideWithSetModifications(new Protein("FKFPRWAWPSYGYPG", "DECOY_CHYMO"), new DigestionParams(protease: "chymotrypsin (cleave before proline)", maxMissedCleavages: 10), 1, 15, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications p_chymo = new PeptideWithSetModifications( + new Protein("FKFPRWAWPSYGYPG", "DECOY_CHYMO"), + new DigestionParams(protease: "chymotrypsin (cleave before proline)", maxMissedCleavages: 10), 1, 15, + CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); PeptideWithSetModifications p_chymo_reverse = p_chymo.GetReverseDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual("FGFPGWSWPAYRYPK", p_chymo_reverse.BaseSequence); Assert.AreEqual(p_chymo.FullSequence, p_chymo_reverse.PeptideDescription); // CNBr cleave after M newAminoAcidPositions = new int["MPEPTIMEK".Length]; - PeptideWithSetModifications p_cnbr = new PeptideWithSetModifications(new Protein("MPEPTIMEK", "DECOY_CNBR"), new DigestionParams(protease: "CNBr"), 1, 9, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications p_cnbr = new PeptideWithSetModifications(new Protein("MPEPTIMEK", "DECOY_CNBR"), + new DigestionParams(protease: "CNBr"), 1, 9, CleavageSpecificity.Full, null, 0, + new Dictionary(), 0, null); PeptideWithSetModifications p_cnbr_reverse = p_cnbr.GetReverseDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual("MKEITPMEP", p_cnbr_reverse.BaseSequence); Assert.AreEqual(p_cnbr.FullSequence, p_cnbr_reverse.PeptideDescription); // elastase cleave after A, V, S, G, L, I, newAminoAcidPositions = new int["KAYVPSRGHLDIN".Length]; - PeptideWithSetModifications p_elastase = new PeptideWithSetModifications(new Protein("KAYVPSRGHLDIN", "DECOY_ELASTASE"), new DigestionParams(protease: "elastase"), 1, 13, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); - PeptideWithSetModifications p_elastase_reverse = p_elastase.GetReverseDecoyFromTarget(newAminoAcidPositions); + PeptideWithSetModifications p_elastase = new PeptideWithSetModifications( + new Protein("KAYVPSRGHLDIN", "DECOY_ELASTASE"), new DigestionParams(protease: "elastase"), 1, 13, + CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications p_elastase_reverse = + p_elastase.GetReverseDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual("NADVHSRGPLYIK", p_elastase_reverse.BaseSequence); // top-down newAminoAcidPositions = new int["RPEPTIREK".Length]; - PeptideWithSetModifications p_topdown = new PeptideWithSetModifications(new Protein("RPEPTIREK", "DECOY_TD"), new DigestionParams(protease: "top-down"), 1, 9, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications p_topdown = new PeptideWithSetModifications( + new Protein("RPEPTIREK", "DECOY_TD"), new DigestionParams(protease: "top-down"), 1, 9, + CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); PeptideWithSetModifications p_topdown_reverse = p_topdown.GetReverseDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual("KERITPEPR", p_topdown_reverse.BaseSequence); // Arg-C -- Cleave after R newAminoAcidPositions = new int["PEPTGPYGPYIDE".Length]; - PeptideWithSetModifications p_coll = new PeptideWithSetModifications(new Protein("PEPTGPYGPYIDE", "DECOY_COL"), new DigestionParams(protease: "collagenase"), 1, 13, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications p_coll = new PeptideWithSetModifications( + new Protein("PEPTGPYGPYIDE", "DECOY_COL"), new DigestionParams(protease: "collagenase"), 1, 13, + CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); PeptideWithSetModifications p_coll_reverse = p_coll.GetReverseDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual("EDITGPYGPYPEP", p_coll_reverse.BaseSequence); // Tyrpsin -- Reverse Decoy is identical so get mirror - Dictionary VTIRTVR_modsDictionary = new Dictionary { { 1, nTermAcet }, { 3, phosphorylation } }; + Dictionary VTIRTVR_modsDictionary = new Dictionary + { { 1, nTermAcet }, { 3, phosphorylation } }; newAminoAcidPositions = new int["VTIRTVR".Length]; - PeptideWithSetModifications p_tryp = new PeptideWithSetModifications(new Protein("VTIRTVR", "DECOY_TRYP"), new DigestionParams(protease: "trypsin"), 1, 7, CleavageSpecificity.Full, null, 0, VTIRTVR_modsDictionary, 0, null); + PeptideWithSetModifications p_tryp = new PeptideWithSetModifications(new Protein("VTIRTVR", "DECOY_TRYP"), + new DigestionParams(protease: "trypsin"), 1, 7, CleavageSpecificity.Full, null, 0, + VTIRTVR_modsDictionary, 0, null); PeptideWithSetModifications p_tryp_reverse = p_tryp.GetReverseDecoyFromTarget(newAminoAcidPositions); // Hash code corresponding to the target sequence, should be PairedTargetDecoyHash for reverse int testMirrorTargetHash = p_tryp.GetHashCode(); @@ -841,26 +1166,35 @@ public static void TestReverseDecoyFromTarget() Assert.AreEqual(testMirrorDecoyHash, p_tryp.PairedTargetDecoyHash); Assert.AreEqual("RVTRITV", p_tryp_reverse.BaseSequence); Assert.AreEqual(new int[] { 6, 5, 4, 3, 2, 1, 0 }, newAminoAcidPositions); - Assert.IsTrue(p_tryp_reverse.AllModsOneIsNterminus.ContainsKey(1));//n-term acetyl - Assert.IsTrue(p_tryp_reverse.AllModsOneIsNterminus.ContainsKey(7));//moved T-phospho from 3 to 7 + Assert.IsTrue(p_tryp_reverse.AllModsOneIsNterminus.ContainsKey(1)); //n-term acetyl + Assert.IsTrue(p_tryp_reverse.AllModsOneIsNterminus.ContainsKey(7)); //moved T-phospho from 3 to 7 Assert.IsTrue(p_tryp_reverse.Protein.IsDecoy); Assert.AreEqual(p_tryp.FullSequence, p_tryp_reverse.PeptideDescription); } + [Test] public static void TestScrambledDecoyFromTarget() { ModificationMotif.TryGetMotif("P", out ModificationMotif motif_p); - Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _target: motif_p, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); + Modification phosphorylation = new Modification(_originalId: "phospho", + _modificationType: "CommonBiological", _target: motif_p, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); ModificationMotif.TryGetMotif("K", out ModificationMotif motif_k); - Modification acetylation = new Modification(_originalId: "acetyl", _modificationType: "CommonBiological", _target: motif_k, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); + Modification acetylation = new Modification(_originalId: "acetyl", _modificationType: "CommonBiological", + _target: motif_k, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); - Modification nTermAcet = new Modification(_originalId: "n-acetyl", _modificationType: "CommonBiological", _target: null, _locationRestriction: "N-terminal.", _chemicalFormula: ChemicalFormula.ParseFormula("H")); + Modification nTermAcet = new Modification(_originalId: "n-acetyl", _modificationType: "CommonBiological", + _target: null, _locationRestriction: "N-terminal.", + _chemicalFormula: ChemicalFormula.ParseFormula("H")); - Dictionary allmodsoneisnterminus = new Dictionary { { 1, nTermAcet }, { 5, phosphorylation }, { 9, acetylation } }; + Dictionary allmodsoneisnterminus = new Dictionary + { { 1, nTermAcet }, { 5, phosphorylation }, { 9, acetylation } }; - PeptideWithSetModifications p = new PeptideWithSetModifications(new Protein("PEPTIDEK", "ACCESSIION"), new DigestionParams(), 1, 8, CleavageSpecificity.Full, null, 0, allmodsoneisnterminus, 0, null); + PeptideWithSetModifications p = new PeptideWithSetModifications(new Protein("PEPTIDEK", "ACCESSIION"), + new DigestionParams(), 1, 8, CleavageSpecificity.Full, null, 0, allmodsoneisnterminus, 0, null); int[] newAminoAcidPositions = new int["PEPTIDEK".Length]; PeptideWithSetModifications testScrambled = p.GetScrambledDecoyFromTarget(newAminoAcidPositions); // Hash code corresponding to the target sequence, should be PairedTargetDecoyHash for reverse @@ -872,7 +1206,7 @@ public static void TestScrambledDecoyFromTarget() Assert.AreEqual("IDEETPPK", testScrambled.BaseSequence); Assert.AreEqual(new int[] { 4, 5, 6, 1, 3, 0, 2, 7 }, newAminoAcidPositions); // Check n-term acetyl - Assert.AreEqual(p.AllModsOneIsNterminus[1], testScrambled.AllModsOneIsNterminus[1]); + Assert.AreEqual(p.AllModsOneIsNterminus[1], testScrambled.AllModsOneIsNterminus[1]); // Check phosphorylated Thr originally at position 5 Assert.AreEqual(p.AllModsOneIsNterminus[5], testScrambled.AllModsOneIsNterminus[6]); Assert.IsTrue(testScrambled.Protein.IsDecoy); @@ -881,62 +1215,85 @@ public static void TestScrambledDecoyFromTarget() Assert.AreEqual(testScrambled.PeptideDescription, p.FullSequence); // Test for complex cleavage motif patterns - Dictionary complexTrypticMods = new Dictionary { { 1, nTermAcet }, { 89, acetylation } }; + Dictionary complexTrypticMods = new Dictionary + { { 1, nTermAcet }, { 89, acetylation } }; Loaders.LoadElements(); - string insulinFile = Path.Combine(TestContext.CurrentContext.TestDirectory, "DataFiles", "humanInsulin.fasta"); - string insulinSeq = ProteinDbLoader.LoadProteinFasta(insulinFile, true, DecoyType.None, false, out var dbError)[0].BaseSequence; - PeptideWithSetModifications insulinTryptic = new PeptideWithSetModifications(new Protein(insulinSeq, "COMPLEX_TRYP"), new DigestionParams(), 1, 110, CleavageSpecificity.Full, null, 0, complexTrypticMods, 0, null); + string insulinFile = + Path.Combine(TestContext.CurrentContext.TestDirectory, "DataFiles", "humanInsulin.fasta"); + string insulinSeq = + ProteinDbLoader.LoadProteinFasta(insulinFile, true, DecoyType.None, false, out var dbError)[0] + .BaseSequence; + PeptideWithSetModifications insulinTryptic = new PeptideWithSetModifications( + new Protein(insulinSeq, "COMPLEX_TRYP"), new DigestionParams(), 1, 110, CleavageSpecificity.Full, null, + 0, complexTrypticMods, 0, null); int[] insulinScrambledOrder = new int[insulinSeq.Length]; - PeptideWithSetModifications insulinScrambled = insulinTryptic.GetScrambledDecoyFromTarget(insulinScrambledOrder); + PeptideWithSetModifications insulinScrambled = + insulinTryptic.GetScrambledDecoyFromTarget(insulinScrambledOrder); // Check that cleavage motif positions are preserved in the more complex case Assert.AreEqual(insulinTryptic.BaseSequence[5], insulinScrambled[5]); - Assert.AreEqual(insulinScrambled.BaseSequence[55], insulinTryptic.BaseSequence[55]); + Assert.AreEqual(insulinScrambled.BaseSequence[55], insulinTryptic.BaseSequence[55]); // Check that modified cleavage motif residues are preserved Assert.AreEqual(insulinScrambled.AllModsOneIsNterminus[89], insulinTryptic.AllModsOneIsNterminus[89]); // Test with Arg-C as the protease newAminoAcidPositions = new int["RPEPTIREAVLKK".Length]; - PeptideWithSetModifications testArgC = new PeptideWithSetModifications(new Protein("RPEPTIREAVLKK", "DECOY_ARGC"), new DigestionParams(protease: "Arg-C"), 1, 13, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications testArgC = new PeptideWithSetModifications( + new Protein("RPEPTIREAVLKK", "DECOY_ARGC"), new DigestionParams(protease: "Arg-C"), 1, 13, + CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); PeptideWithSetModifications scrambledArgC = testArgC.GetScrambledDecoyFromTarget(newAminoAcidPositions); // Check for preserved cleavage motif positions Assert.AreEqual(testArgC.BaseSequence[6], scrambledArgC.BaseSequence[6]); // Tests that peptide is mirrored when the maximum number of scramble attempts is reached newAminoAcidPositions = new int["AVLRRRKKRDEF".Length]; - PeptideWithSetModifications forceMirror = new PeptideWithSetModifications(new Protein("AVLRRRKKRDEF", "ACCESSIION"), new DigestionParams(), 1, 12, CleavageSpecificity.Full, null, 0, allmodsoneisnterminus, 0, null); + PeptideWithSetModifications forceMirror = new PeptideWithSetModifications( + new Protein("AVLRRRKKRDEF", "ACCESSIION"), new DigestionParams(), 1, 12, CleavageSpecificity.Full, null, + 0, allmodsoneisnterminus, 0, null); PeptideWithSetModifications mirroredTarget = forceMirror.GetScrambledDecoyFromTarget(newAminoAcidPositions); Assert.AreEqual(new int[] { 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, newAminoAcidPositions); } + [Test] public static void TestReverseDecoyFromPeptideFromProteinXML() { //Just making sure there are no snafus when creating decoy peptides from an xml,which will have mods in various places, etc. //sequence variants, modifications Dictionary un = new Dictionary(); - var psiModDeserialized = Loaders.LoadPsiMod(Path.Combine(TestContext.CurrentContext.TestDirectory, "PSI-MOD.obo2.xml")); + var psiModDeserialized = + Loaders.LoadPsiMod(Path.Combine(TestContext.CurrentContext.TestDirectory, "PSI-MOD.obo2.xml")); Dictionary formalChargesDictionary = Loaders.GetFormalChargesDictionary(psiModDeserialized); - List UniProtPtms = Loaders.LoadUniprot(Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist2.txt"), formalChargesDictionary).ToList(); - List proteins = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "cRAP_databaseGPTMD.xml"), true, DecoyType.None, UniProtPtms, false, new string[] { "exclude_me" }, out un); + List UniProtPtms = Loaders + .LoadUniprot(Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist2.txt"), + formalChargesDictionary).ToList(); + List proteins = ProteinDbLoader.LoadProteinXML( + Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "cRAP_databaseGPTMD.xml"), true, + DecoyType.None, UniProtPtms, false, new string[] { "exclude_me" }, out un); List fixedMods = new List(); List variableMods = new List(); ModificationMotif.TryGetMotif("C", out ModificationMotif motif_C); ModificationMotif.TryGetMotif("M", out ModificationMotif motif_M); - fixedMods.Add(new Modification(_originalId: "resMod_C", _target: motif_C, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H"), _monoisotopicMass: PeriodicTable.GetElement(1).PrincipalIsotope.AtomicMass)); - fixedMods.Add(new Modification(_originalId: "resMod_M", _target: motif_C, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("O"), _monoisotopicMass: PeriodicTable.GetElement(8).PrincipalIsotope.AtomicMass)); + fixedMods.Add(new Modification(_originalId: "resMod_C", _target: motif_C, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("H"), + _monoisotopicMass: PeriodicTable.GetElement(1).PrincipalIsotope.AtomicMass)); + fixedMods.Add(new Modification(_originalId: "resMod_M", _target: motif_C, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("O"), + _monoisotopicMass: PeriodicTable.GetElement(8).PrincipalIsotope.AtomicMass)); int unchangedPeptides = 0; int totalPeptides = 0; foreach (Protein p in proteins) { - List targetPeptides = p.Digest(new DigestionParams(), fixedMods, variableMods, null, null).ToList(); + List targetPeptides = + p.Digest(new DigestionParams(), fixedMods, variableMods, null, null).ToList(); foreach (PeptideWithSetModifications targetPeptide in targetPeptides) { totalPeptides++; int[] newAminoAcidPositions = new int[targetPeptide.BaseSequence.Length]; - PeptideWithSetModifications decoyPeptide = targetPeptide.GetReverseDecoyFromTarget(newAminoAcidPositions); + PeptideWithSetModifications decoyPeptide = + targetPeptide.GetReverseDecoyFromTarget(newAminoAcidPositions); if (decoyPeptide.BaseSequence == targetPeptide.BaseSequence) { @@ -952,24 +1309,34 @@ public static void TestReverseDecoyFromPeptideFromProteinXML() public static void CountTargetsWithMatchingDecoys() { Dictionary un = new Dictionary(); - var psiModDeserialized = Loaders.LoadPsiMod(Path.Combine(TestContext.CurrentContext.TestDirectory, "PSI-MOD.obo2.xml")); + var psiModDeserialized = + Loaders.LoadPsiMod(Path.Combine(TestContext.CurrentContext.TestDirectory, "PSI-MOD.obo2.xml")); Dictionary formalChargesDictionary = Loaders.GetFormalChargesDictionary(psiModDeserialized); - List UniProtPtms = Loaders.LoadUniprot(Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist2.txt"), formalChargesDictionary).ToList(); - List proteins = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "cRAP_databaseGPTMD.xml"), true, DecoyType.None, UniProtPtms, false, new string[] { "exclude_me" }, out un); + List UniProtPtms = Loaders + .LoadUniprot(Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist2.txt"), + formalChargesDictionary).ToList(); + List proteins = ProteinDbLoader.LoadProteinXML( + Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "cRAP_databaseGPTMD.xml"), true, + DecoyType.None, UniProtPtms, false, new string[] { "exclude_me" }, out un); List fixedMods = new List(); List variableMods = new List(); ModificationMotif.TryGetMotif("C", out ModificationMotif motif_C); ModificationMotif.TryGetMotif("M", out ModificationMotif motif_M); - fixedMods.Add(new Modification(_originalId: "resMod_C", _target: motif_C, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H"), _monoisotopicMass: PeriodicTable.GetElement(1).PrincipalIsotope.AtomicMass)); - fixedMods.Add(new Modification(_originalId: "resMod_M", _target: motif_C, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("O"), _monoisotopicMass: PeriodicTable.GetElement(8).PrincipalIsotope.AtomicMass)); + fixedMods.Add(new Modification(_originalId: "resMod_C", _target: motif_C, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("H"), + _monoisotopicMass: PeriodicTable.GetElement(1).PrincipalIsotope.AtomicMass)); + fixedMods.Add(new Modification(_originalId: "resMod_M", _target: motif_C, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("O"), + _monoisotopicMass: PeriodicTable.GetElement(8).PrincipalIsotope.AtomicMass)); Dictionary targets = new Dictionary(); foreach (Protein p in proteins) { - List targetPeptides = p.Digest(new DigestionParams(), fixedMods, variableMods, null, null).ToList(); + List targetPeptides = + p.Digest(new DigestionParams(), fixedMods, variableMods, null, null).ToList(); foreach (PeptideWithSetModifications targetPeptide in targetPeptides) { @@ -987,7 +1354,8 @@ public static void CountTargetsWithMatchingDecoys() int matchingDecoys = 0; foreach (Protein p in proteins) { - List targetPeptides = p.Digest(new DigestionParams(), fixedMods, variableMods, null, null).ToList(); + List targetPeptides = + p.Digest(new DigestionParams(), fixedMods, variableMods, null, null).ToList(); foreach (PeptideWithSetModifications target in targetPeptides) { @@ -1005,58 +1373,80 @@ public static void CountTargetsWithMatchingDecoys() [Test] public static void TestPeptideWithSetModsReturnsTruncationsInTopDown() { - string xmlDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, "DataFiles", "humanInsulin.xml"); + string xmlDatabase = + Path.Combine(TestContext.CurrentContext.TestDirectory, "DataFiles", "humanInsulin.xml"); Protein insulin = ProteinDbLoader.LoadProteinXML(xmlDatabase, true, DecoyType.None, null, false, null, out var unknownModifications, addTruncations: true)[0]; - Protease protease = new Protease("top-down", CleavageSpecificity.None, "", "", new List(), null); - List insulinTruncations = insulin.Digest(new DigestionParams(protease: protease.Name), new List(), new List(), topDownTruncationSearch: true).ToList(); + Protease protease = new Protease("top-down", CleavageSpecificity.None, "", "", new List(), + null); + List insulinTruncations = insulin + .Digest(new DigestionParams(protease: protease.Name), new List(), + new List(), topDownTruncationSearch: true).ToList(); Assert.AreEqual(68, insulinTruncations.Count); } [Test] public static void TestPeptideWithSetModsReturnsDecoyTruncationsInTopDown() { - string xmlDatabase = Path.Combine(TestContext.CurrentContext.TestDirectory, "DataFiles", "humanInsulin.xml"); + string xmlDatabase = + Path.Combine(TestContext.CurrentContext.TestDirectory, "DataFiles", "humanInsulin.xml"); List insulinProteins = ProteinDbLoader.LoadProteinXML(xmlDatabase, true, DecoyType.Reverse, null, false, null, out var unknownModifications, addTruncations: true); - Protease protease = new Protease("top-down", CleavageSpecificity.None, "", "", new List(), null); - List insulintTargetTruncations = insulinProteins.Where(p=>!p.IsDecoy).First().Digest(new DigestionParams(protease: protease.Name), new List(), new List(), topDownTruncationSearch: true).ToList(); + Protease protease = new Protease("top-down", CleavageSpecificity.None, "", "", new List(), + null); + List insulintTargetTruncations = insulinProteins.Where(p => !p.IsDecoy).First() + .Digest(new DigestionParams(protease: protease.Name), new List(), + new List(), topDownTruncationSearch: true).ToList(); Assert.AreEqual(68, insulintTargetTruncations.Count); - List insulintDecoyTruncations = insulinProteins.Where(p => p.IsDecoy).First().Digest(new DigestionParams(protease: protease.Name), new List(), new List(), topDownTruncationSearch: true).ToList(); + List insulintDecoyTruncations = insulinProteins.Where(p => p.IsDecoy).First() + .Digest(new DigestionParams(protease: protease.Name), new List(), + new List(), topDownTruncationSearch: true).ToList(); Assert.AreEqual(68, insulintDecoyTruncations.Count); } [Test] public static void CheckFullChemicalFormula() { - PeptideWithSetModifications small_pep = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, 7, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications small_pep = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION"), + new DigestionParams(protease: "trypsin"), 1, 7, CleavageSpecificity.Full, null, 0, + new Dictionary(), 0, null); ChemicalFormula small_pep_cf = ChemicalFormula.ParseFormula("C34H53N7O15"); Assert.AreEqual(small_pep.FullChemicalFormula, small_pep_cf); - PeptideWithSetModifications large_pep = new PeptideWithSetModifications(new Protein("PEPTIDEKRNSPEPTIDEKECUEIRQUV", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, 28, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications large_pep = new PeptideWithSetModifications( + new Protein("PEPTIDEKRNSPEPTIDEKECUEIRQUV", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, + 28, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); ChemicalFormula large_pep_cf = ChemicalFormula.ParseFormula("C134H220N38O50S1Se2"); Assert.AreEqual(large_pep.FullChemicalFormula, large_pep_cf); ModificationMotif.TryGetMotif("S", out ModificationMotif motif_s); - Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _target: motif_s, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); + Modification phosphorylation = new Modification(_originalId: "phospho", + _modificationType: "CommonBiological", _target: motif_s, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); Dictionary modDict_small = new Dictionary(); modDict_small.Add(4, phosphorylation); - PeptideWithSetModifications small_pep_mod = new PeptideWithSetModifications(new Protein("PEPSIDE", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, 7, CleavageSpecificity.Full, null, 0, modDict_small, 0, null); + PeptideWithSetModifications small_pep_mod = new PeptideWithSetModifications( + new Protein("PEPSIDE", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, 7, + CleavageSpecificity.Full, null, 0, modDict_small, 0, null); ChemicalFormula small_pep_mod_cf = ChemicalFormula.ParseFormula("C33H52N7O18P1"); Assert.AreEqual(small_pep_mod.FullChemicalFormula, small_pep_mod_cf); ModificationMotif.TryGetMotif("K", out ModificationMotif motif_k); - Modification acetylation = new Modification(_originalId: "acetyl", _modificationType: "CommonBiological", _target: motif_k, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("C2H3O")); + Modification acetylation = new Modification(_originalId: "acetyl", _modificationType: "CommonBiological", + _target: motif_k, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("C2H3O")); Dictionary modDict_large = new Dictionary(); modDict_large.Add(4, phosphorylation); modDict_large.Add(11, phosphorylation); modDict_large.Add(8, acetylation); - PeptideWithSetModifications large_pep_mod = new PeptideWithSetModifications(new Protein("PEPSIDEKRNSPEPTIDEKECUEIRQUV", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, 28, CleavageSpecificity.Full, null, 0, modDict_large, 0, null); + PeptideWithSetModifications large_pep_mod = new PeptideWithSetModifications( + new Protein("PEPSIDEKRNSPEPTIDEKECUEIRQUV", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, + 28, CleavageSpecificity.Full, null, 0, modDict_large, 0, null); ChemicalFormula large_pep_mod_cf = ChemicalFormula.ParseFormula("C135H223N38O57P2S1Se2"); Assert.AreEqual(large_pep_mod.FullChemicalFormula, large_pep_mod_cf); @@ -1065,12 +1455,21 @@ public static void CheckFullChemicalFormula() Dictionary modDict = new() { - { "Carbamidomethyl on C", new Modification(_originalId: "Carbamidomethyl", _modificationType: "Common Fixed", - _target: motif_c, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("C2H3ON")) }, - { "BS on G" , new Modification(_originalId: "BS on G", _modificationType: "BS", _target: motif_g, _monoisotopicMass: 96.0875)} + { + "Carbamidomethyl on C", new Modification(_originalId: "Carbamidomethyl", + _modificationType: "Common Fixed", + _target: motif_c, _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("C2H3ON")) + }, + { + "BS on G", + new Modification(_originalId: "BS on G", _modificationType: "BS", _target: motif_g, + _monoisotopicMass: 96.0875) + } }; PeptideWithSetModifications pwsmWithMissingCfMods = new PeptideWithSetModifications( - "ENQGDETQG[Speculative:BS on G]C[Common Fixed:Carbamidomethyl on C]PPQR", modDict, p: new Protein("ENQGDETQGCPPQR", "FakeProtein"), digestionParams: new DigestionParams(), + "ENQGDETQG[Speculative:BS on G]C[Common Fixed:Carbamidomethyl on C]PPQR", modDict, + p: new Protein("ENQGDETQGCPPQR", "FakeProtein"), digestionParams: new DigestionParams(), oneBasedStartResidueInProtein: 1, oneBasedEndResidueInProtein: 14); Assert.Null(pwsmWithMissingCfMods.FullChemicalFormula); } @@ -1078,27 +1477,44 @@ public static void CheckFullChemicalFormula() [Test] public static void CheckMostAbundantMonoisotopicMass() { - PeptideWithSetModifications small_pep = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, 7, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications small_pep = new PeptideWithSetModifications(new Protein("PEPTIDE", "ACCESSION"), + new DigestionParams(protease: "trypsin"), 1, 7, CleavageSpecificity.Full, null, 0, + new Dictionary(), 0, null); double small_pep_most_abundant_mass_prospector = 800.36724 - 1.0079; - Assert.That(small_pep.MostAbundantMonoisotopicMass, Is.EqualTo(small_pep_most_abundant_mass_prospector).Within(0.01)); + Assert.That(small_pep.MostAbundantMonoisotopicMass, + Is.EqualTo(small_pep_most_abundant_mass_prospector).Within(0.01)); - PeptideWithSetModifications large_pep = new PeptideWithSetModifications(new Protein("PEPTIDEPEPTIDEPEPTIDEPEPTIDEPEPTIDEPEPTIDE", "ACCESSION"), new DigestionParams(protease: "trypsin"), 1, 42, CleavageSpecificity.Full, null, 0, new Dictionary(), 0, null); + PeptideWithSetModifications large_pep = new PeptideWithSetModifications( + new Protein("PEPTIDEPEPTIDEPEPTIDEPEPTIDEPEPTIDEPEPTIDE", "ACCESSION"), + new DigestionParams(protease: "trypsin"), 1, 42, CleavageSpecificity.Full, null, 0, + new Dictionary(), 0, null); double large_pep_most_abundant_mass_prospector = 4709.12020 - 1.0079; - Assert.That(large_pep.MostAbundantMonoisotopicMass, Is.EqualTo(large_pep_most_abundant_mass_prospector).Within(0.01)); + Assert.That(large_pep.MostAbundantMonoisotopicMass, + Is.EqualTo(large_pep_most_abundant_mass_prospector).Within(0.01)); } - public static void TestPeptideWithSetModsEssentialSequence() + + public static void TestPeptideWithSetModsEssentialSequence() { - var psiModDeserialized = Loaders.LoadPsiMod(Path.Combine(TestContext.CurrentContext.TestDirectory, "PSI-MOD.obo2.xml")); + var psiModDeserialized = + Loaders.LoadPsiMod(Path.Combine(TestContext.CurrentContext.TestDirectory, "PSI-MOD.obo2.xml")); Dictionary formalChargesDictionary = Loaders.GetFormalChargesDictionary(psiModDeserialized); - List UniProtPtms = Loaders.LoadUniprot(Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist2.txt"), formalChargesDictionary).ToList(); + List UniProtPtms = Loaders + .LoadUniprot(Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist2.txt"), + formalChargesDictionary).ToList(); Dictionary modsToWrite = new Dictionary(); - modsToWrite.Add("UniProt",0); + modsToWrite.Add("UniProt", 0); - var proteinXml = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "humanGAPDH.xml"), true, DecoyType.None, UniProtPtms, false, null, out var unknownMod); + var proteinXml = ProteinDbLoader.LoadProteinXML( + Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "humanGAPDH.xml"), true, + DecoyType.None, UniProtPtms, false, null, out var unknownMod); var gapdh = proteinXml[0]; - var gapdhPeptides = gapdh.Digest(new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, initiatorMethionineBehavior: InitiatorMethionineBehavior.Variable), UniProtPtms, new List()); + var gapdhPeptides = + gapdh.Digest( + new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Variable), UniProtPtms, + new List()); List allSequences = new List(); foreach (var peptide in gapdhPeptides) @@ -1106,30 +1522,42 @@ public static void TestPeptideWithSetModsEssentialSequence() allSequences.Add(peptide.EssentialSequence(modsToWrite)); } - var expectedFullStrings = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "essentialSequences.txt")); + var expectedFullStrings = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, + "DatabaseTests", "essentialSequences.txt")); CollectionAssert.AreEquivalent(expectedFullStrings, allSequences.ToArray()); } - + [Test] public static void TestPeptideWithSetModsFullSequence() { - var psiModDeserialized = Loaders.LoadPsiMod(Path.Combine(TestContext.CurrentContext.TestDirectory, "PSI-MOD.obo2.xml")); - Dictionary formalChargesDictionary = Loaders.GetFormalChargesDictionary(psiModDeserialized); - List UniProtPtms = Loaders.LoadUniprot(Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist2.txt"), formalChargesDictionary).ToList(); - var proteinXml = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "humanGAPDH.xml"), true, DecoyType.None, UniProtPtms, false, null, out var unknownMod); + var psiModDeserialized = + Loaders.LoadPsiMod(Path.Combine(TestContext.CurrentContext.TestDirectory, "PSI-MOD.obo2.xml")); + Dictionary formalChargesDictionary = + Loaders.GetFormalChargesDictionary(psiModDeserialized); + List UniProtPtms = Loaders + .LoadUniprot(Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist2.txt"), + formalChargesDictionary).ToList(); + var proteinXml = ProteinDbLoader.LoadProteinXML( + Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "humanGAPDH.xml"), true, + DecoyType.None, UniProtPtms, false, null, out var unknownMod); var gapdh = proteinXml[0]; - var gapdhPeptides = gapdh.Digest(new DigestionParams(maxMissedCleavages:0, minPeptideLength:1, initiatorMethionineBehavior:InitiatorMethionineBehavior.Variable),UniProtPtms,new List()); - + var gapdhPeptides = + gapdh.Digest( + new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, + initiatorMethionineBehavior: InitiatorMethionineBehavior.Variable), UniProtPtms, + new List()); + List allSequences = new List(); foreach (var peptide in gapdhPeptides) { allSequences.Add(peptide.FullSequence); } - var expectedFullStrings = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "fullSequences.txt")); - CollectionAssert.AreEquivalent(expectedFullStrings,allSequences.ToArray()); + var expectedFullStrings = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, + "DatabaseTests", "fullSequences.txt")); + CollectionAssert.AreEquivalent(expectedFullStrings, allSequences.ToArray()); allSequences.Clear(); foreach (var peptide in gapdhPeptides) @@ -1137,9 +1565,11 @@ public static void TestPeptideWithSetModsFullSequence() allSequences.Add(peptide.FullSequenceWithMassShift()); } - var expectedFullStringsWithMassShifts = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, "DatabaseTests", "fullSequencesWithMassShift.txt")); + var expectedFullStringsWithMassShifts = File.ReadAllLines(Path.Combine( + TestContext.CurrentContext.TestDirectory, "DatabaseTests", "fullSequencesWithMassShift.txt")); CollectionAssert.AreEquivalent(expectedFullStringsWithMassShifts, allSequences.ToArray()); - + } + [Test] public static void TestReplaceAllModsOneIsNterminus() { @@ -1158,14 +1588,18 @@ public static void TestReplaceAllModsOneIsNterminus() var noModPeptideMostAbundantMonoisotopicMass = peptide.MostAbundantMonoisotopicMass; //Makes phospho mod and a dictionary that contains the mod in the last residue - Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); + Modification phosphorylation = new Modification(_originalId: "phospho", + _modificationType: "CommonBiological", _locationRestriction: "Anywhere.", + _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1")); var phosphoDict = new Dictionary(); phosphoDict.Add(8, phosphorylation); peptide.ReplaceAllModsOneIsNterminus(phosphoDict); Assert.That(peptide.AllModsOneIsNterminus.Count != 0); - Assert.That(peptide.MonoisotopicMass, Is.EqualTo(noModPeptideMonoisotopicMass + phosphorylation.MonoisotopicMass).Within(0.01)); - Assert.That(peptide.MostAbundantMonoisotopicMass, Is.EqualTo(noModPeptideMostAbundantMonoisotopicMass + phosphorylation.MonoisotopicMass).Within(0.01)); + Assert.That(peptide.MonoisotopicMass, + Is.EqualTo(noModPeptideMonoisotopicMass + phosphorylation.MonoisotopicMass).Within(0.01)); + Assert.That(peptide.MostAbundantMonoisotopicMass, + Is.EqualTo(noModPeptideMostAbundantMonoisotopicMass + phosphorylation.MonoisotopicMass).Within(0.01)); Assert.That(peptide.NumMods == 1); Assert.That(peptide.NumVariableMods == 1); Assert.That(peptide.SequenceWithChemicalFormulas == "PEPTIDE[HO3P]S");