public static void TestCombos() { List <PeptideSpectralMatch> allIdentifications = null; ModificationMotif.TryGetMotif("N", out ModificationMotif motifN); ModificationMotif.TryGetMotif("P", out ModificationMotif motifP); var gptmdModifications = new List <ModificationWithMass> { new ModificationWithMass("21", "mt", motifN, TerminusLocalization.Any, 21.981943, null), new ModificationWithMass("16", "mt", motifP, TerminusLocalization.Any, 15.994915, null) }; IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> > { new Tuple <double, double>(21.981943, 15.994915) }; Tolerance precursorMassTolerance = new PpmTolerance(10); MsDataScan dfd = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfd, (651.297638557 + 21.981943 + 15.994915).ToMz(1), 1, "filepath"); var parentProtein = new Protein("NNNPPP", "accession"); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 5); List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); var modPep = parentProtein.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).First(); var peptidesWithSetModifications = new List <PeptideWithSetModifications> { modPep }; PeptideSpectralMatch match = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan, digestionParams); PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan, digestionParams); Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { peptidesWithSetModifications.First() } } }; List <ProductType> lp = new List <ProductType> { ProductType.B, ProductType.Y }; Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); match.MatchToProteinLinkedPeptides(matching); match.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0, 0, false); allIdentifications = new List <PeptideSpectralMatch> { match }; var engine = new GptmdEngine(allIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> { { "filepath", precursorMassTolerance } }, new CommonParameters(), new List <string>()); var res = (GptmdResults)engine.Run(); Assert.AreEqual(1, res.Mods.Count); Assert.AreEqual(6, res.Mods["accession"].Count); Assert.AreEqual(3, res.Mods["accession"].Where(b => b.Item2.id.Equals("21")).Count()); Assert.AreEqual(3, res.Mods["accession"].Where(b => b.Item2.id.Equals("16")).Count()); }
public static void TestLocalization() { var protease = new Protease("Custom Protease", new List <string> { "K" }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null); Protein parentProteinForMatch = new Protein("MEK", null); DigestionParams digestionParams = new DigestionParams { MinPeptideLength = 1, }; ModificationMotif.TryGetMotif("E", out ModificationMotif motif); List <ModificationWithMass> variableModifications = new List <ModificationWithMass> { new ModificationWithMass("21", null, motif, TerminusLocalization.Any, 21.981943) }; List <PeptideWithSetModifications> allPeptidesWithSetModifications = parentProteinForMatch.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList(); Assert.AreEqual(4, allPeptidesWithSetModifications.Count()); PeptideWithSetModifications ps = allPeptidesWithSetModifications.First(); List <ProductType> lp = new List <ProductType> { ProductType.BnoB1ions, ProductType.Y }; PeptideWithSetModifications pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1]; IMsDataFile <IMsDataScan <IMzSpectrum <IMzPeak> > > myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> { pepWithSetModsForSpectrum }); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(myMsDataFile.Last() as IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> >, pepWithSetModsForSpectrum.MonoisotopicMass.ToMz(1), 1, null); PeptideSpectralMatch newPsm = new PeptideSpectralMatch(ps.CompactPeptide(TerminusType.None), 0, 0, 2, scan); Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { ps.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { ps } } }; newPsm.MatchToProteinLinkedPeptides(matching); LocalizationEngine f = new LocalizationEngine(new List <PeptideSpectralMatch> { newPsm }, lp, myMsDataFile, fragmentTolerance, new List <string>(), false); f.Run(); // Was single peak!!! Assert.AreEqual(0, newPsm.MatchedIonDictOnlyMatches[ProductType.BnoB1ions].Count(b => b > 0)); Assert.AreEqual(1, newPsm.MatchedIonDictOnlyMatches[ProductType.Y].Count(b => b > 0)); // If localizing, three match!!! Assert.IsTrue(newPsm.LocalizedScores[1] > 3 && newPsm.LocalizedScores[1] < 4); }
public static void TestPsmHeader() { DigestionParams digestionParams = new DigestionParams(); PeptideWithSetModifications pepWithSetMods = new Protein( "MQQQQQQQ", "accession1", "org", new List <Tuple <string, string> > { new Tuple <string, string>("geneNameType", "geneName") }, new Dictionary <int, List <Modification> > { { 2, new List <Modification> { new Modification("mod", "mod") } } }, name: "name", full_name: "fullName", sequenceVariations: new List <SequenceVariation> { new SequenceVariation(2, "P", "Q", "changed this sequence") }) .Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First(); MsDataFile myMsDataFile = new TestDataFile(pepWithSetMods, "quadratic"); MsDataScan scann = myMsDataFile.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(scann, 4, 1, null); PeptideSpectralMatch psm = new PeptideSpectralMatch(pepWithSetMods.CompactPeptide(TerminusType.None), 1, 2, 3, scan, digestionParams); var t = psm.ToString(); var tabsepheader = PeptideSpectralMatch.GetTabSeparatedHeader(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { pepWithSetMods.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { pepWithSetMods } } }; psm.MatchToProteinLinkedPeptides(matching); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Tolerance fragmentTolerance = new PpmTolerance(10); List <ProductType> lp = new List <ProductType> { ProductType.B }; new LocalizationEngine(new List <PeptideSpectralMatch> { psm }, lp, myMsDataFile, new CommonParameters(productMassTolerance: fragmentTolerance), new List <string>()).Run(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); psm.SetFdrValues(6, 6, 6, 6, 6, 6, 0, 0, 0, true); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); }
public static void TestGptmdEngine() { List <PeptideSpectralMatch> allResultingIdentifications = null; ModificationMotif.TryGetMotif("N", out ModificationMotif motifN); var gptmdModifications = new List <ModificationWithMass> { new ModificationWithMass("21", "mt", motifN, TerminusLocalization.Any, 21.981943) }; IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> >(); Tolerance precursorMassTolerance = new PpmTolerance(10); allResultingIdentifications = new List <PeptideSpectralMatch>(); var engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, precursorMassTolerance, new List <string>()); var res = (GptmdResults)engine.Run(); Assert.AreEqual(0, res.Mods.Count); //PsmParent newPsm = new TestParentSpectrumMatch(588.22520189093 + 21.981943); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(new MzmlScanWithPrecursor(0, new MzmlMzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null, null, "scan=1"), (588.22520189093 + 21.981943).ToMz(1), 1, null); var parentProtein = new Protein("NNNNN", "accession"); var protease = new Protease("Custom Protease", new List <string> { "K" }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null); DigestionParams digestionParams = new DigestionParams(); List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); var modPep = parentProtein.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).First(); var peptidesWithSetModifications = new List <PeptideWithSetModifications> { modPep }; PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan); Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { peptidesWithSetModifications.First() } } }; List <ProductType> lp = new List <ProductType> { ProductType.B, ProductType.Y }; Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); newPsm.MatchToProteinLinkedPeptides(matching); newPsm.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0, 0, false); allResultingIdentifications.Add(newPsm); engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, precursorMassTolerance, new List <string>()); res = (GptmdResults)engine.Run(); Assert.AreEqual(1, res.Mods.Count); Assert.AreEqual(5, res.Mods["accession"].Count); }
public static void TestLocalization() { Protein parentProteinForMatch = new Protein("MEK", null); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 1); ModificationMotif.TryGetMotif("E", out ModificationMotif motif); List <ModificationWithMass> variableModifications = new List <ModificationWithMass> { new ModificationWithMass("21", null, motif, TerminusLocalization.Any, 21.981943) }; List <PeptideWithSetModifications> allPeptidesWithSetModifications = parentProteinForMatch.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList(); Assert.AreEqual(4, allPeptidesWithSetModifications.Count()); PeptideWithSetModifications ps = allPeptidesWithSetModifications.First(); List <ProductType> lp = new List <ProductType> { ProductType.BnoB1ions, ProductType.Y }; PeptideWithSetModifications pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1]; MsDataFile myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> { pepWithSetModsForSpectrum }); Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(myMsDataFile.GetAllScansList().Last(), pepWithSetModsForSpectrum.MonoisotopicMass.ToMz(1), 1, null); PeptideSpectralMatch newPsm = new PeptideSpectralMatch(ps.CompactPeptide(TerminusType.None), 0, 0, 2, scan, digestionParams); Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { ps.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { ps } } }; newPsm.MatchToProteinLinkedPeptides(matching); CommonParameters commonParameters = new CommonParameters(productMassTolerance: fragmentTolerance); LocalizationEngine f = new LocalizationEngine(new List <PeptideSpectralMatch> { newPsm }, lp, myMsDataFile, commonParameters, new List <string>()); f.Run(); // Was single peak!!! Assert.AreEqual(0, newPsm.MatchedIonMassToChargeRatioDict[ProductType.BnoB1ions].Count(b => b > 0)); Assert.AreEqual(1, newPsm.MatchedIonMassToChargeRatioDict[ProductType.Y].Count(b => b > 0)); Assert.AreEqual(0, newPsm.MatchedIonIntensitiesDict[ProductType.BnoB1ions].Count(b => b > 0)); Assert.AreEqual(1, newPsm.MatchedIonIntensitiesDict[ProductType.Y].Count(b => b > 0)); // If localizing, three match!!! Assert.IsTrue(newPsm.LocalizedScores[1] > 3 && newPsm.LocalizedScores[1] < 4); }
public static void TestPsmHeader() { DigestionParams digestionParams = new DigestionParams(); PeptideWithSetModifications pepWithSetMods = new Protein("MQQQQQQQ", "accession1").Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First(); IMsDataFile <IMsDataScan <IMzSpectrum <IMzPeak> > > myMsDataFile = new TestDataFile(pepWithSetMods, "quadratic"); IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> > scann = myMsDataFile.GetOneBasedScan(2) as IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> >; Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(scann, 4, 1, null); PeptideSpectralMatch psm = new PeptideSpectralMatch(pepWithSetMods.CompactPeptide(TerminusType.None), 1, 2, 3, scan); var t = psm.ToString(); var tabsepheader = PeptideSpectralMatch.GetTabSeparatedHeader(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { pepWithSetMods.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { pepWithSetMods } } }; psm.MatchToProteinLinkedPeptides(matching); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); Tolerance fragmentTolerance = new PpmTolerance(10); List <ProductType> lp = new List <ProductType> { ProductType.B }; new LocalizationEngine(new List <PeptideSpectralMatch> { psm }, lp, myMsDataFile, fragmentTolerance, new List <string>(), false).Run(); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); psm.SetFdrValues(6, 6, 6, 6, 6, 6, 0, 0, 0, false); Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t')); }
private static Tuple <List <PeptideSpectralMatch>, Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >, MassDiffAcceptor, bool, CompactPeptideBase, CompactPeptideBase> GetInfo(bool localizeable) { CommonParameters CommonParameters = new CommonParameters(digestionParams: new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, maxModificationIsoforms: 2, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain, maxModsForPeptides: 1), scoreCutoff: 1); // Alanine = Glycine + CH2 Protein protein1 = new Protein("MA", "protein1"); Protein protein2 = new Protein("MG", "protein2"); Protein protein3; double monoisotopicMass = Chemistry.ChemicalFormula.ParseFormula("CH2").MonoisotopicMass; ModificationMotif.TryGetMotif("G", out ModificationMotif motif1); ModificationMotif.TryGetMotif("A", out ModificationMotif motif2); TerminusLocalization modificationSites = TerminusLocalization.Any; List <ModificationWithMass> allKnownFixedModifications = new List <ModificationWithMass> { new ModificationWithMass("CH2 on Glycine", null, motif1, modificationSites, monoisotopicMass) }; List <ModificationWithMass> variableModifications; ModificationWithMass alanineMod = new ModificationWithMass("CH2 on Alanine", null, motif2, modificationSites, monoisotopicMass); if (localizeable) { variableModifications = new List <ModificationWithMass>(); IDictionary <int, List <Modification> > oneBasedModifications = new Dictionary <int, List <Modification> > { { 2, new List <Modification> { alanineMod } } }; protein3 = new Protein("MA", "protein3", oneBasedModifications: oneBasedModifications); } else { variableModifications = new List <ModificationWithMass>(); variableModifications = new List <ModificationWithMass> { alanineMod }; protein3 = new Protein("MA", "protein3"); } var pepWithSetModifications1 = protein1.Digest(CommonParameters.DigestionParams, allKnownFixedModifications, variableModifications).First(); var pepWithSetModifications2 = protein2.Digest(CommonParameters.DigestionParams, allKnownFixedModifications, variableModifications).First(); var pepWithSetModifications3 = protein3.Digest(CommonParameters.DigestionParams, allKnownFixedModifications, variableModifications).Last(); CompactPeptide compactPeptide1 = new CompactPeptide(pepWithSetModifications1, TerminusType.None); CompactPeptide compactPeptideDuplicate = new CompactPeptide(pepWithSetModifications2, TerminusType.None); Assert.AreEqual(compactPeptide1, compactPeptideDuplicate); CompactPeptide compactPeptide2 = new CompactPeptide(pepWithSetModifications3, TerminusType.None); string fullFilePath = null; int precursorCharge = 0; TestDataFile testDataFile = new TestDataFile(); MsDataScan mzLibScan = testDataFile.GetOneBasedScan(2); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(mzLibScan, 0, precursorCharge, fullFilePath); int scanIndex = 0; double score = 0; int notch = 0; PeptideSpectralMatch psm1 = new PeptideSpectralMatch(compactPeptide1, notch, score, scanIndex, scan, CommonParameters.DigestionParams); psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); PeptideSpectralMatch psm2 = new PeptideSpectralMatch(compactPeptide1, notch, score, scanIndex, scan, CommonParameters.DigestionParams); psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); PeptideSpectralMatch psm3 = new PeptideSpectralMatch(compactPeptide2, notch, score, scanIndex, scan, CommonParameters.DigestionParams); psm3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); var newPsms = new List <PeptideSpectralMatch> { psm1, psm2, psm3 }; MassDiffAcceptor massDiffAcceptors = new SinglePpmAroundZeroSearchMode(5); SequencesToActualProteinPeptidesEngine stappe = new SequencesToActualProteinPeptidesEngine(newPsms, new List <Protein> { protein1, protein2, protein3 }, allKnownFixedModifications, variableModifications, new List <ProductType> { ProductType.B, ProductType.Y }, new List <DigestionParams> { CommonParameters.DigestionParams }, CommonParameters.ReportAllAmbiguity, CommonParameters, new List <string>()); var haha = (SequencesToActualProteinPeptidesEngineResults)stappe.Run(); var compactPeptideToProteinPeptideMatching = haha.CompactPeptideToProteinPeptideMatching; Assert.AreEqual(2, compactPeptideToProteinPeptideMatching.Count); psm1.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching); bool noOneHitWonders = false; return(new Tuple <List <PeptideSpectralMatch>, Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >, MassDiffAcceptor, bool, CompactPeptideBase, CompactPeptideBase> ( newPsms, compactPeptideToProteinPeptideMatching, massDiffAcceptors, noOneHitWonders, compactPeptide1, compactPeptide2 )); }
public static void TryFailSequenceCoverage() { var prot1 = new Protein("MMKMMK", "prot1"); ModificationMotif.TryGetMotif("M", out ModificationMotif motifM); ModificationWithMass mod1 = new ModificationWithMass("mod1", "mt", motifM, TerminusLocalization.NProt, 10); ModificationWithMass mod2 = new ModificationWithMass("mod2", "mt", motifM, TerminusLocalization.NPep, 10); ModificationWithMass mod3 = new ModificationWithMass("mod3", "mt", motifM, TerminusLocalization.Any, 10); ModificationMotif.TryGetMotif("K", out ModificationMotif motifK); ModificationWithMass mod4 = new ModificationWithMass("mod4", "mt", motifK, TerminusLocalization.PepC, 10); ModificationWithMass mod5 = new ModificationWithMass("mod5", "mt", motifK, TerminusLocalization.ProtC, 10); Dictionary <int, ModificationWithMass> modsFor1 = new Dictionary <int, ModificationWithMass> { { 1, mod1 }, { 3, mod3 }, { 5, mod4 }, }; Dictionary <int, ModificationWithMass> modsFor2 = new Dictionary <int, ModificationWithMass> { { 1, mod2 }, { 5, mod5 }, }; Dictionary <int, ModificationWithMass> modsFor3 = new Dictionary <int, ModificationWithMass> { { 1, mod1 }, { 5, mod3 }, { 8, mod5 } }; DigestionParams digestionParams = new DigestionParams(); var pwsm1 = new PeptideWithSetModifications(protein: prot1, digestionParams: digestionParams, oneBasedStartResidueInProtein: 1, oneBasedEndResidueInProtein: 3, peptideDescription: "", missedCleavages: 0, allModsOneIsNterminus: modsFor1, numFixedMods: 0); var pwsm2 = new PeptideWithSetModifications(protein: prot1, digestionParams: digestionParams, oneBasedStartResidueInProtein: 4, oneBasedEndResidueInProtein: 6, peptideDescription: "", missedCleavages: 0, allModsOneIsNterminus: modsFor2, numFixedMods: 0); var pwsm3 = new PeptideWithSetModifications(protein: prot1, digestionParams: digestionParams, oneBasedStartResidueInProtein: 1, oneBasedEndResidueInProtein: 6, peptideDescription: "", missedCleavages: 0, allModsOneIsNterminus: modsFor3, numFixedMods: 0); HashSet <PeptideWithSetModifications> peptides = new HashSet <PeptideWithSetModifications> { pwsm1, pwsm2, pwsm3, }; Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { pwsm1.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { pwsm1 } }, { pwsm2.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { pwsm2 } }, { pwsm3.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> { pwsm3 } }, }; IScan scan = new ThisTestScan(); var psm1 = new PeptideSpectralMatch(pwsm1.CompactPeptide(TerminusType.None), 0, 1, 0, scan, digestionParams); psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); psm1.MatchToProteinLinkedPeptides(matching); var psm2 = new PeptideSpectralMatch(pwsm2.CompactPeptide(TerminusType.None), 0, 1, 0, scan, digestionParams); psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); psm2.MatchToProteinLinkedPeptides(matching); var psm3 = new PeptideSpectralMatch(pwsm3.CompactPeptide(TerminusType.None), 0, 1, 0, scan, digestionParams); psm3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); psm3.MatchToProteinLinkedPeptides(matching); List <PeptideSpectralMatch> newPsms = new List <PeptideSpectralMatch> { psm1, psm2, psm3, }; ProteinParsimonyEngine ppe = new ProteinParsimonyEngine(matching, true, new CommonParameters(), new List <string>()); ProteinParsimonyResults fjkd = (ProteinParsimonyResults)ppe.Run(); ProteinScoringAndFdrEngine psafe = new ProteinScoringAndFdrEngine(fjkd.ProteinGroups, newPsms, true, true, true, new CommonParameters(), new List <string>()); psafe.Run(); fjkd.ProteinGroups.First().CalculateSequenceCoverage(); var firstSequenceCoverageDisplayList = fjkd.ProteinGroups.First().SequenceCoverageDisplayList.First(); Assert.AreEqual("MMKMMK", firstSequenceCoverageDisplayList); var firstSequenceCoverageDisplayListWithMods = fjkd.ProteinGroups.First().SequenceCoverageDisplayListWithMods.First(); Assert.AreEqual("[mod1]-MM[mod3]KM[mod3]MK-[mod5]", firstSequenceCoverageDisplayListWithMods); var firstModInfo = fjkd.ProteinGroups.First().ModsInfo.First(); Assert.IsTrue(firstModInfo.Contains(@"#aa1[mod1,info:occupancy=1.00(2/2)]")); Assert.IsTrue(firstModInfo.Contains(@"#aa2[mod3,info:occupancy=0.50(1/2)]")); Assert.IsFalse(firstModInfo.Contains(@"#aa3")); Assert.IsTrue(firstModInfo.Contains(@"#aa4[mod3,info:occupancy=0.50(1/2)]")); Assert.IsFalse(firstModInfo.Contains(@"#aa5")); Assert.IsTrue(firstModInfo.Contains(@"#aa6[mod5,info:occupancy=1.00(2/2)]")); }
public static void TestPTMOutput() { List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); List <ModificationWithMass> fixedModifications = new List <ModificationWithMass>(); ModificationMotif.TryGetMotif("S", out ModificationMotif motif); variableModifications.Add(new ModificationWithMassAndCf("resMod", "HaHa", motif, TerminusLocalization.Any, ChemicalFormula.ParseFormula("H"))); var proteinList = new List <Protein> { new Protein("MNNNSKQQQ", "accession") }; var protease = new Protease("CustomProtease", new List <Tuple <string, TerminusType> > { new Tuple <string, TerminusType>("K", TerminusType.C) }, new List <Tuple <string, TerminusType> >(), CleavageSpecificity.Full, null, null, null); ProteaseDictionary.Dictionary.Add(protease.Name, protease); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > compactPeptideToProteinPeptideMatching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >(); Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort> { { variableModifications.Last(), 1 } }; DigestionParams digestionParams = new DigestionParams(protease: protease.Name, maxMissedCleavages: 0, minPeptideLength: 1); var modPep = proteinList.First().Digest(digestionParams, fixedModifications, variableModifications).Last(); HashSet <PeptideWithSetModifications> value = new HashSet <PeptideWithSetModifications> { modPep }; CompactPeptide compactPeptide1 = new CompactPeptide(value.First(), TerminusType.None); Assert.AreEqual("QQQ", value.First().Sequence); var firstProtDigest = proteinList.First().Digest(digestionParams, fixedModifications, variableModifications).ToList(); HashSet <PeptideWithSetModifications> value2 = new HashSet <PeptideWithSetModifications> { firstProtDigest[0] }; CompactPeptide compactPeptide2 = new CompactPeptide(value2.First(), TerminusType.None); Assert.AreEqual("MNNNSK", value2.First().Sequence); HashSet <PeptideWithSetModifications> value2mod = new HashSet <PeptideWithSetModifications> { firstProtDigest[1] }; CompactPeptide compactPeptide2mod = new CompactPeptide(value2mod.Last(), TerminusType.None); Assert.AreEqual("MNNNS[HaHa:resMod]K", value2mod.Last().Sequence); HashSet <PeptideWithSetModifications> value3 = new HashSet <PeptideWithSetModifications> { firstProtDigest[2] }; CompactPeptide compactPeptide3 = new CompactPeptide(value3.First(), TerminusType.None); Assert.AreEqual("NNNSK", value3.First().Sequence); HashSet <PeptideWithSetModifications> value3mod = new HashSet <PeptideWithSetModifications> { firstProtDigest[3] }; CompactPeptide compactPeptide3mod = new CompactPeptide(value3mod.Last(), TerminusType.None); Assert.AreEqual("NNNS[HaHa:resMod]K", value3mod.Last().Sequence); var peptideList = new HashSet <PeptideWithSetModifications>(); foreach (var protein in proteinList) { foreach (var peptide in protein.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications)) { peptideList.Add(peptide); } } compactPeptideToProteinPeptideMatching.Add(compactPeptide1, value); compactPeptideToProteinPeptideMatching.Add(compactPeptide2, value2); compactPeptideToProteinPeptideMatching.Add(compactPeptide3, value3); compactPeptideToProteinPeptideMatching.Add(compactPeptide2mod, value2mod); compactPeptideToProteinPeptideMatching.Add(compactPeptide3mod, value3mod); ProteinParsimonyEngine engine = new ProteinParsimonyEngine(compactPeptideToProteinPeptideMatching, true, new CommonParameters(), new List <string> { "ff" }); var cool = (ProteinParsimonyResults)engine.Run(); var proteinGroups = cool.ProteinGroups; MsDataScan jdfk = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass ms2scan = new Ms2ScanWithSpecificMass(jdfk, 2, 0, "File"); List <ProductType> lp = new List <ProductType> { ProductType.B, ProductType.Y }; Tolerance fragmentTolerance = new AbsoluteTolerance(0.01); var match1 = new PeptideSpectralMatch(peptideList.ElementAt(0).CompactPeptide(TerminusType.None), 0, 10, 0, ms2scan, digestionParams) { }; match1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); var match2 = new PeptideSpectralMatch(peptideList.ElementAt(1).CompactPeptide(TerminusType.None), 0, 10, 0, ms2scan, digestionParams) { }; match2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); var match3 = new PeptideSpectralMatch(peptideList.ElementAt(1).CompactPeptide(TerminusType.None), 0, 10, 0, ms2scan, digestionParams) { }; match3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); match1.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching); match2.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching); match3.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching); List <PeptideSpectralMatch> psms = new List <PeptideSpectralMatch> { match1, match2, match3 }; ProteinScoringAndFdrEngine f = new ProteinScoringAndFdrEngine(proteinGroups, psms, false, false, true, new CommonParameters(), new List <string>()); f.Run(); Assert.AreEqual("#aa5[resMod,info:occupancy=0.67(2/3)];", proteinGroups.First().ModsInfo[0]); }
public static void FdrTestMethod() { MassDiffAcceptor searchModes = new DotMassDiffAcceptor(null, new List <double> { 0, 1.0029 }, new PpmTolerance(5)); List <string> nestedIds = new List <string>(); Protein p = new Protein("MNKNNKNNNKNNNNK", null); DigestionParams digestionParams = new DigestionParams(); var digested = p.Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).ToList(); PeptideWithSetModifications pep1 = digested[0]; PeptideWithSetModifications pep2 = digested[1]; PeptideWithSetModifications pep3 = digested[2]; PeptideWithSetModifications pep4 = digested[3]; TestDataFile t = new TestDataFile(new List <PeptideWithSetModifications> { pep1, pep2, pep3 }); CompactPeptide peptide1 = new CompactPeptide(pep1, TerminusType.None); IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> > mzLibScan1 = t.GetOneBasedScan(2) as IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> >; Ms2ScanWithSpecificMass scan1 = new Ms2ScanWithSpecificMass(mzLibScan1, peptide1.MonoisotopicMassIncludingFixedMods.ToMz(1), 1, null); PeptideSpectralMatch psm1 = new PeptideSpectralMatch(peptide1, 0, 3, 0, scan1); CompactPeptide peptide2 = new CompactPeptide(pep2, TerminusType.None); IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> > mzLibScan2 = t.GetOneBasedScan(4) as IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> >; Ms2ScanWithSpecificMass scan2 = new Ms2ScanWithSpecificMass(mzLibScan2, peptide2.MonoisotopicMassIncludingFixedMods.ToMz(1), 1, null); PeptideSpectralMatch psm2 = new PeptideSpectralMatch(peptide2, 1, 2, 1, scan2); CompactPeptide peptide3 = new CompactPeptide(pep3, TerminusType.None); IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> > mzLibScan3 = t.GetOneBasedScan(6) as IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> >; Ms2ScanWithSpecificMass scan3 = new Ms2ScanWithSpecificMass(mzLibScan3, peptide3.MonoisotopicMassIncludingFixedMods.ToMz(1), 1, null); PeptideSpectralMatch psm3 = new PeptideSpectralMatch(peptide3, 0, 1, 2, scan3); CompactPeptide peptide4 = new CompactPeptide(pep4, TerminusType.None); psm3.AddOrReplace(peptide4, 1, 1, true); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > { { peptide1, new HashSet <PeptideWithSetModifications> { pep1 } }, { peptide2, new HashSet <PeptideWithSetModifications> { pep2 } }, { peptide3, new HashSet <PeptideWithSetModifications> { pep3 } }, { peptide4, new HashSet <PeptideWithSetModifications> { pep4 } }, }; psm1.MatchToProteinLinkedPeptides(matching); psm2.MatchToProteinLinkedPeptides(matching); psm3.MatchToProteinLinkedPeptides(matching); var newPsms = new List <PeptideSpectralMatch> { psm1, psm2, psm3 }; FdrAnalysisEngine fdr = new FdrAnalysisEngine(newPsms, searchModes.NumNotches, true, nestedIds); fdr.Run(); Assert.AreEqual(2, searchModes.NumNotches); Assert.AreEqual(0, newPsms[0].FdrInfo.CumulativeDecoyNotch); Assert.AreEqual(1, newPsms[0].FdrInfo.CumulativeTargetNotch); Assert.AreEqual(0, newPsms[1].FdrInfo.CumulativeDecoyNotch); Assert.AreEqual(1, newPsms[1].FdrInfo.CumulativeTargetNotch); Assert.AreEqual(0, newPsms[2].FdrInfo.CumulativeDecoyNotch); Assert.AreEqual(1, newPsms[2].FdrInfo.CumulativeTargetNotch); Assert.AreEqual(0, newPsms[0].FdrInfo.CumulativeDecoy); Assert.AreEqual(1, newPsms[0].FdrInfo.CumulativeTarget); Assert.AreEqual(0, newPsms[1].FdrInfo.CumulativeDecoy); Assert.AreEqual(2, newPsms[1].FdrInfo.CumulativeTarget); Assert.AreEqual(0, newPsms[2].FdrInfo.CumulativeDecoy); Assert.AreEqual(3, newPsms[2].FdrInfo.CumulativeTarget); }