public static void TopPickedFdrTest() { //Test that the decoy beats out the target for FDR, but that the target still gets written. Protein fillerProtein = new Protein("FILLR", "filler"); Protein targetProtein = new Protein("KFDSA", "protein"); Protein decoyProtein = new Protein("ASDFK", "DECOY_protein", isDecoy: true); IEnumerable <Modification> allKnownFixedModifications = new List <Modification>(); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 5); List <Modification> variableModifications = new List <Modification>(); PeptideWithSetModifications fillerPep = fillerProtein.Digest(digestionParams, allKnownFixedModifications, variableModifications).First(); PeptideWithSetModifications targetPep = targetProtein.Digest(digestionParams, allKnownFixedModifications, variableModifications).First(); PeptideWithSetModifications decoyPep = decoyProtein.Digest(digestionParams, allKnownFixedModifications, variableModifications).First(); // build the dictionary for input to parsimony MsDataScan dfb = new MsDataScan(new MzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 0, 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, null, null, "scan=1", double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null); Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(dfb, 2, 0, "File", new CommonParameters()); List <PeptideSpectralMatch> psms = new List <PeptideSpectralMatch> { new PeptideSpectralMatch(fillerPep, 0, 30, 0, scan, new DigestionParams(), new List <MatchedFragmentIon>()), new PeptideSpectralMatch(decoyPep, 0, 15.11, 0, scan, new DigestionParams(), new List <MatchedFragmentIon>()), new PeptideSpectralMatch(targetPep, 0, 15.1, 0, scan, new DigestionParams(), new List <MatchedFragmentIon>()) }; psms.ForEach(p => p.ResolveAllAmbiguities()); psms.ForEach(p => p.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0)); // apply parsimony ProteinParsimonyEngine pae = new ProteinParsimonyEngine(psms, false, new CommonParameters(), new List <string>()); ProteinParsimonyResults proteinParsimonyResult = (ProteinParsimonyResults)pae.Run(); ProteinScoringAndFdrEngine proteinScoringEngine = new ProteinScoringAndFdrEngine(proteinParsimonyResult.ProteinGroups, psms, false, true, true, new CommonParameters(), new List <string>()); ProteinScoringAndFdrResults results = (ProteinScoringAndFdrResults)proteinScoringEngine.Run(); Assert.IsTrue(results.SortedAndScoredProteinGroups.Count == 3); Assert.IsTrue(results.SortedAndScoredProteinGroups[1].QValue == 0.5); }
public static void TryFailSequenceCoverage() { var prot1 = new Protein("MMKMMK", "prot1"); ModificationMotif.TryGetMotif("M", out ModificationMotif motifM); Modification mod1 = new Modification(_originalId: "mod1", _modificationType: "mt", _target: motifM, _locationRestriction: "N-terminal.", _monoisotopicMass: 10); Modification mod2 = new Modification(_originalId: "mod2", _modificationType: "mt", _target: motifM, _locationRestriction: "Peptide N-terminal.", _monoisotopicMass: 10); Modification mod3 = new Modification(_originalId: "mod3", _modificationType: "mt", _target: motifM, _locationRestriction: "Anywhere.", _monoisotopicMass: 10); ModificationMotif.TryGetMotif("K", out ModificationMotif motifK); Modification mod4 = new Modification(_originalId: "mod4", _modificationType: "mt", _target: motifK, _locationRestriction: "Peptide C-terminal.", _monoisotopicMass: 10); Modification mod5 = new Modification(_originalId: "mod5", _modificationType: "mt", _target: motifK, _locationRestriction: "C-terminal.", _monoisotopicMass: 10); Dictionary <int, Modification> modsFor1 = new Dictionary <int, Modification> { { 1, mod1 }, { 3, mod3 }, { 5, mod4 }, }; Dictionary <int, Modification> modsFor2 = new Dictionary <int, Modification> { { 1, mod2 }, { 5, mod5 }, }; Dictionary <int, Modification> modsFor3 = new Dictionary <int, Modification> { { 1, mod1 }, { 5, mod3 }, { 8, mod5 } }; DigestionParams digestionParams = new DigestionParams(); var pwsm1 = new PeptideWithSetModifications(prot1, digestionParams, 1, 3, CleavageSpecificity.Unknown, "", 0, modsFor1, 0); var pwsm2 = new PeptideWithSetModifications(prot1, digestionParams, 4, 6, CleavageSpecificity.Unknown, "", 0, modsFor2, 0); var pwsm3 = new PeptideWithSetModifications(prot1, digestionParams, 1, 6, CleavageSpecificity.Unknown, "", 0, modsFor3, 0); HashSet <PeptideWithSetModifications> peptides = new HashSet <PeptideWithSetModifications> { pwsm1, pwsm2, pwsm3, }; IScan scan = new ThisTestScan(); var psm1 = new PeptideSpectralMatch(pwsm1, 0, 1, 0, scan, digestionParams, new List <MatchedFragmentIon>()); psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); var psm2 = new PeptideSpectralMatch(pwsm2, 0, 1, 0, scan, digestionParams, new List <MatchedFragmentIon>()); psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); var psm3 = new PeptideSpectralMatch(pwsm3, 0, 1, 0, scan, digestionParams, new List <MatchedFragmentIon>()); psm3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); List <PeptideSpectralMatch> newPsms = new List <PeptideSpectralMatch> { psm1, psm2, psm3, }; newPsms.ForEach(p => p.ResolveAllAmbiguities()); ProteinParsimonyEngine ppe = new ProteinParsimonyEngine(newPsms, 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 on M]-MM[mod3 on M]KM[mod3 on M]MK-[mod5 on K]", firstSequenceCoverageDisplayListWithMods); var firstModInfo = fjkd.ProteinGroups.First().ModsInfo.First(); Assert.IsTrue(firstModInfo.Contains(@"#aa1[mod1 on M,info:occupancy=1.00(2/2)]")); Assert.IsTrue(firstModInfo.Contains(@"#aa2[mod3 on M,info:occupancy=0.50(1/2)]")); Assert.IsFalse(firstModInfo.Contains(@"#aa3")); Assert.IsTrue(firstModInfo.Contains(@"#aa4[mod3 on M,info:occupancy=0.50(1/2)]")); Assert.IsFalse(firstModInfo.Contains(@"#aa5")); Assert.IsTrue(firstModInfo.Contains(@"#aa6[mod5 on K,info:occupancy=1.00(2/2)]")); }
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)]")); }