public void Test_modification3_hash_set() { ModificationMotif.TryGetMotif("K", out ModificationMotif motif); ModificationWithMass m1 = new ModificationWithMass("id1", "modificationType", motif, TerminusLocalization.Any, 1.11111d, new Dictionary <string, IList <string> >(), neutralLosses: new List <double> { 2.222222 }, diagnosticIons: new List <double> { 1.2233 }); ModificationWithMass m2 = new ModificationWithMass("id1", "modificationType", motif, TerminusLocalization.Any, 1.11111d - 1e-10, new Dictionary <string, IList <string> >(), neutralLosses: new List <double> { 2.222222 + 1e-10 }, diagnosticIons: new List <double> { 1.2233 }); m1.linksToOtherDbs.Add("key", new List <string> { "value" }); m2.linksToOtherDbs.Add("key", new List <string> { "value" }); HashSet <Modification> mods = new HashSet <Modification>(new Modification[] { m1, m2 }); Assert.AreEqual(1, mods.Count); Assert.True(m1.Equals(m2)); }
public static TheoreticalProteoform make_a_theoretical(string a, string d, double mass, ProteinWithGoTerms p, Dictionary <InputFile, Protein[]> dict) { ModificationMotif motif; ModificationMotif.TryGetMotif("K", out motif); string mod_title = "oxidation"; ModificationWithMass m = new ModificationWithMass(mod_title, new Tuple <string, string>("", mod_title), motif, ModificationSites.K, 1, new Dictionary <string, IList <string> >(), new List <double>(), new List <double>(), ""); ProteinWithGoTerms p1 = new ProteinWithGoTerms("MSSSSSSSSSSS", "T1", new List <Tuple <string, string> > { new Tuple <string, string>("ordered locus", "GENE") }, new Dictionary <int, List <Modification> > { { 1, new List <Modification> { m } } }, new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, "T2", "T3", true, false, new List <DatabaseReference> { new DatabaseReference("GO", ":", new List <Tuple <string, string> > { new Tuple <string, string>("term", "P:") }) }, new List <GoTerm> { new GoTerm(new DatabaseReference("GO", ":", new List <Tuple <string, string> > { new Tuple <string, string>("term", "P:") })) }); PtmSet set = new PtmSet(new List <Ptm> { new Ptm(0, m) }); return(new TheoreticalProteoform(a, d, new List <ProteinWithGoTerms> { p }, mass, 0, set, true, false, dict)); }
public static void TestDigestIndices() { ModificationMotif.TryGetMotif("X", out ModificationMotif motif); Modification mod = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); IDictionary <int, List <Modification> > modDict = new Dictionary <int, List <Modification> > { { 2, new List <Modification> { mod } }, { 8, new List <Modification> { mod } } }; var prot = new Protein("MNNNNKRRRRR", null, null, null, modDict); var protease = new Protease("Custom Protease", new List <string> { "K" }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null); DigestionParams digestionParams = new DigestionParams { Protease = protease, InitiatorMethionineBehavior = InitiatorMethionineBehavior.Retain, MaxMissedCleavages = 0, }; var digestList = prot.Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).ToList(); var ok1 = digestList[1]; var ok2 = digestList[3]; Assert.AreEqual(1, ok1.NumMods); Assert.IsTrue(ok1.allModsOneIsNterminus.ContainsKey(3)); Assert.AreEqual(1, ok2.NumMods); Assert.IsTrue(ok2.allModsOneIsNterminus.ContainsKey(3)); }
public void Test_write_with_custom_mods() { var nice = new List <Modification> { new ModificationWithLocation("fayk", null, null, ModificationSites.A, null, null) }; ModificationMotif.TryGetMotif("K", out ModificationMotif motif); ModificationWithMass m = new ModificationWithMass("mod", new Tuple <string, string>("", ""), motif, ModificationSites.Any, 1, new Dictionary <string, IList <string> >(), new List <double> { -1 }, new List <double>(), ""); Dictionary <string, HashSet <Tuple <int, ModificationWithMass> > > new_mods = new Dictionary <string, HashSet <Tuple <int, ModificationWithMass> > > { { "P53863", new HashSet <Tuple <int, ModificationWithMass> > { new Tuple <int, ModificationWithMass>(2, m) } } }; List <Protein> ok = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, @"xml2.xml"), false, nice, false, null, out Dictionary <string, Modification> un); var newModResEntries = ProteinDbWriter.WriteXmlDatabase(new_mods, ok, Path.Combine(TestContext.CurrentContext.TestDirectory, @"rewrite_xml2.xml")); Assert.AreEqual(1, newModResEntries.Count); List <Protein> ok2 = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, @"rewrite_xml2.xml"), false, nice, false, null, out un); Assert.AreEqual(ok.Count, ok2.Count); Assert.True(Enumerable.Range(0, ok.Count).All(i => ok[i].BaseSequence == ok2[i].BaseSequence)); Assert.AreEqual(2, ok[0].OneBasedPossibleLocalizedModifications.Count); Assert.AreEqual(3, ok2[0].OneBasedPossibleLocalizedModifications.Count); }
public void Test_modification3_hash_set() { ModificationMotif.TryGetMotif("K", out ModificationMotif motif); ModificationWithMass m1 = new ModificationWithMass(null, new Tuple <string, string>("item1", "item2"), motif, ModificationSites.K, 1.11111d, new Dictionary <string, IList <string> >(), new List <double> { 2.222222 }, new List <double> { 1.2233 }, "modificationType"); ModificationWithMass m2 = new ModificationWithMass(null, new Tuple <string, string>("item1", "item2"), motif, ModificationSites.K, 1.11111d, new Dictionary <string, IList <string> >(), new List <double> { 2.222222 }, new List <double> { 1.2233 }, "modificationType"); m1.linksToOtherDbs.Add("key", new List <string> { "value" }); m2.linksToOtherDbs.Add("key", new List <string> { "value" }); HashSet <Modification> mods = new HashSet <Modification>(new Modification[] { m1, m2 }); Assert.AreEqual(1, mods.Count); Assert.True(m1.Equals(m2)); }
public void DoNotWriteSameModTwiceButWriteInHeaderSinceDifferent() { Loaders.LoadElements(Path.Combine(TestContext.CurrentContext.TestDirectory, "elements2.dat")); var sampleModList = PtmListLoader.ReadModsFromFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "z.txt")).ToList(); Protein protein = new Protein("MCSSSSSSSSSS", "accession", "organism", new List <Tuple <string, string> >(), new Dictionary <int, List <Modification> > { { 2, sampleModList.OfType <Modification>().ToList() } }, null, "name", "full_name", false, false, new List <DatabaseReference>(), new List <SequenceVariation>(), new List <DisulfideBond>()); Assert.AreEqual(1, protein.OneBasedPossibleLocalizedModifications[2].OfType <ModificationWithMass>().Count()); Dictionary <string, HashSet <Tuple <int, Modification> > > dictWithThisMod = new Dictionary <string, HashSet <Tuple <int, Modification> > >(); HashSet <Tuple <int, Modification> > value = new HashSet <Tuple <int, Modification> >(); ModificationMotif.TryGetMotif("C", out ModificationMotif motif); ModificationWithMass newMod = new ModificationWithMass("Palmitoylation of C", "mt", motif, TerminusLocalization.Any, double.NaN, null, null); Assert.AreNotEqual(newMod, sampleModList.First()); value.Add(new Tuple <int, Modification>(2, newMod)); dictWithThisMod.Add("accession", value); var newModResEntries = ProteinDbWriter.WriteXmlDatabase(dictWithThisMod, new List <Protein> { protein }, Path.Combine(TestContext.CurrentContext.TestDirectory, "test_modifications_with_proteins2.xml")); Assert.AreEqual(0, newModResEntries.Count); List <Protein> new_proteins = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, "test_modifications_with_proteins2.xml"), true, DecoyType.None, new List <Modification>(), false, new List <string>(), out Dictionary <string, Modification> um); Assert.AreEqual(1, new_proteins.Count); Assert.AreEqual(1, new_proteins[0].OneBasedPossibleLocalizedModifications.Count); Assert.AreEqual(2, new_proteins[0].OneBasedPossibleLocalizedModifications.SelectMany(kv => kv.Value).Count()); }
public static void prepare_for_et(List <double> delta_masses) { SaveState.lollipop.theoretical_database.all_mods_with_mass = new List <ModificationWithMass>(); SaveState.lollipop.theoretical_database.all_possible_ptmsets = new List <PtmSet>(); SaveState.lollipop.modification_ranks = new Dictionary <double, int>(); //Prepare for making ET relation foreach (double delta_m in new HashSet <double>(delta_masses)) { ModificationWithMass m = ConstructorsForTesting.get_modWithMass("fake" + delta_m.ToString(), delta_m); SaveState.lollipop.theoretical_database.all_mods_with_mass.Add(m); SaveState.lollipop.theoretical_database.all_possible_ptmsets.Add(new PtmSet(new List <Ptm> { new Ptm(-1, m) })); SaveState.lollipop.modification_ranks.Add(delta_m, 2); } SaveState.lollipop.theoretical_database.possible_ptmset_dictionary = SaveState.lollipop.theoretical_database.make_ptmset_dictionary(); if (!SaveState.lollipop.modification_ranks.TryGetValue(0, out int a)) { SaveState.lollipop.modification_ranks.Add(0, 1); } SaveState.lollipop.mod_rank_sum_threshold = 2; }
public static void ParsimonyLocalizeableTreatAsUnique() { bool modPeptidesAreUnique = true; // set up mods var modDictionary = new Dictionary <int, List <Modification> >(); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); var mod = new ModificationWithMass("Oxidation of M", "Common Variable", motif1, TerminusLocalization.Any, 15.99491461957); TerminusType terminusType = ProductTypeMethod.IdentifyTerminusType(new List <ProductType> { ProductType.B, ProductType.Y }); var protease = new Protease("kprotease", new List <string> { "K" }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null); // modified version of protein var protein1 = new Protein("PEPTIDEM", "accession1"); // unmodified version of protein var protein2 = new Protein("YYYKPEPTIDEM", "accession2"); var pep1 = protein1.Digest(new DigestionParams { MinPeptideLength = null, Protease = protease }, new List <ModificationWithMass> { mod }, new List <ModificationWithMass>()).First(); var pep2 = protein2.Digest(new DigestionParams { MinPeptideLength = null, Protease = protease }, new List <ModificationWithMass>(), new List <ModificationWithMass>()).ToList()[1]; // check to make sure mod is present Assert.That(pep1.Sequence != pep2.Sequence); Assert.That(pep1.NumMods == 1); Assert.That(pep2.NumMods == 0); // build the dictionary for input to parsimony var compactPeptideToProteinPeptideMatching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >(); compactPeptideToProteinPeptideMatching.Add(pep1.CompactPeptide(terminusType), new HashSet <PeptideWithSetModifications> { pep1 }); compactPeptideToProteinPeptideMatching.Add(pep2.CompactPeptide(terminusType), new HashSet <PeptideWithSetModifications> { pep2 }); // apply parsimony ProteinParsimonyEngine pae = new ProteinParsimonyEngine(compactPeptideToProteinPeptideMatching, modPeptidesAreUnique, new List <string>()); pae.Run(); // check to make sure both peptides are NOT associated with both proteins Assert.That(compactPeptideToProteinPeptideMatching.Count == 2); foreach (var kvp in compactPeptideToProteinPeptideMatching) { Assert.That(kvp.Value.Count == 1); } }
//MODIFICATION public static ModificationWithMass get_modWithMass(string id, double mass) { ModificationMotif motif; ModificationMotif.TryGetMotif("K", out motif); ModificationWithMass m = new ModificationWithMass(id, new Tuple <string, string>("", ""), motif, ModificationSites.K, mass, new Dictionary <string, IList <string> >(), new List <double>(), new List <double>(), ""); return(m); }
public static void TestModFits() { ModificationMotif.TryGetMotif("X", out ModificationMotif motif); ModificationWithMass attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Protein protein = new Protein("M", null); int peptideOneBasedIndex = 1; int peptideLength = 1; int proteinOneBasedIndex = 1; Assert.IsTrue(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("M", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsTrue(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("N", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("Mx", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("Mr", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("xM", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("Nxs", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); protein = new Protein("MNRS", null); peptideOneBasedIndex = 1; peptideLength = 1; proteinOneBasedIndex = 1; Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); ModificationMotif.TryGetMotif("Nxs", out motif); attemptToLocalize = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, double.NaN); protein = new Protein("MNRS", null); peptideOneBasedIndex = 1; peptideLength = 1; proteinOneBasedIndex = 1; Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); peptideOneBasedIndex = 2; peptideLength = 1; proteinOneBasedIndex = 2; Assert.IsTrue(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); protein = new Protein("MNRN", null); Assert.IsFalse(GptmdEngine.ModFits(attemptToLocalize, protein, peptideOneBasedIndex, peptideLength, proteinOneBasedIndex)); }
public static void Test_modificationsHashCode() { ModificationMotif.TryGetMotif("M", out ModificationMotif motif); var mod1 = new ModificationWithMass("mod", "type", motif, TerminusLocalization.Any, 1, null, null, null); var mod2 = new ModificationWithMass("mod2", "type", motif, TerminusLocalization.Any, 10, null, null, null); Assert.AreNotEqual(mod1.GetHashCode(), mod2.GetHashCode()); Assert.AreNotEqual(mod1, mod2); HashSet <Modification> myHashSet = new HashSet <Modification> { mod1, mod2 }; Assert.AreEqual(2, myHashSet.Count); }
protected static IEnumerable <double> ComputeFollowingFragmentMassesByPepCom(PepWithSetModForCompactPep yyy, double prevMass, int oneBasedIndexToLookAt, int direction) { ModificationWithMass currentModification = null; do { if (oneBasedIndexToLookAt != 0 && oneBasedIndexToLookAt != yyy.Length + 1) { prevMass += Residue.ResidueMonoisotopicMass[yyy.BaseSequence[oneBasedIndexToLookAt - 1]]; } // If modification exists if (yyy.allModsOneIsNterminus.TryGetValue(oneBasedIndexToLookAt + 1, out currentModification)) { if (currentModification.neutralLosses.Count == 1 && oneBasedIndexToLookAt != 0 && oneBasedIndexToLookAt != yyy.Length + 1) { prevMass += currentModification.monoisotopicMass - currentModification.neutralLosses.First(); yield return(Math.Round(prevMass, digitsForRoundingMasses)); } else { foreach (double nl in currentModification.neutralLosses) { var theMass = prevMass + currentModification.monoisotopicMass - nl; if (oneBasedIndexToLookAt != 0 && oneBasedIndexToLookAt != yyy.Length + 1) { yield return(Math.Round(theMass, digitsForRoundingMasses)); } if ((direction == 1 && oneBasedIndexToLookAt + direction < yyy.Length) || (direction == -1 && oneBasedIndexToLookAt + direction > 1)) { foreach (var nextMass in ComputeFollowingFragmentMassesByPepCom(yyy, theMass, oneBasedIndexToLookAt + direction, direction)) { yield return(Math.Round(nextMass, digitsForRoundingMasses)); } } } break; } } else if (oneBasedIndexToLookAt != 0 && oneBasedIndexToLookAt != yyy.Length + 1) // No modification exists { yield return(Math.Round(prevMass, digitsForRoundingMasses)); } oneBasedIndexToLookAt += direction; } while ((oneBasedIndexToLookAt > 1 && direction == -1) || (oneBasedIndexToLookAt < yyy.Length && direction == 1)); }
private int ComputePeptideIndexes(PeptideWithSetModifications yyy, double[] prevMass, int oneBasedIndexToLookAt, int direction, double precursorMass, MassDiffAcceptor massDiffAcceptor) { ModificationWithMass residue_variable_mod = null; do { prevMass[0] += Residue.ResidueMonoisotopicMass[yyy[oneBasedIndexToLookAt - 1]]; yyy.allModsOneIsNterminus.TryGetValue(oneBasedIndexToLookAt + 1, out residue_variable_mod); if (residue_variable_mod == null) { if (massDiffAcceptor.Accepts(precursorMass, prevMass[0]) >= 0) { return(oneBasedIndexToLookAt); } } else if (residue_variable_mod.neutralLosses.Count == 1) { prevMass[0] += residue_variable_mod.monoisotopicMass - residue_variable_mod.neutralLosses.First(); if (massDiffAcceptor.Accepts(precursorMass, prevMass[0]) >= 0) { return(oneBasedIndexToLookAt); } } else { foreach (double nl in residue_variable_mod.neutralLosses) { prevMass[0] = prevMass[0] + residue_variable_mod.monoisotopicMass - nl; if (massDiffAcceptor.Accepts(precursorMass, prevMass[0]) >= 0) { return(oneBasedIndexToLookAt); } if ((direction == 1 && oneBasedIndexToLookAt + direction < yyy.Length) || (direction == -1 && oneBasedIndexToLookAt + direction > 1)) { return(ComputePeptideIndexes(yyy, prevMass, oneBasedIndexToLookAt + direction, direction, precursorMass, massDiffAcceptor)); } } break; } oneBasedIndexToLookAt += direction; } while ((oneBasedIndexToLookAt >= 1 && direction == -1) || (oneBasedIndexToLookAt <= yyy.Length && direction == 1)); return(-1); }
public UnlocalizedModification(ModificationWithMass m) { original_modification = m; mass = m.monoisotopicMass; id = m.id; ptm_count = 1; ptm_rank = SaveState.lollipop.modification_ranks[m.monoisotopicMass]; require_proteoform_without_mod = false; if (m.modificationType == "FattyAcid" || m.modificationType == "Unlocalized") { ptm_rank = SaveState.lollipop.mod_rank_first_quartile / 2; } else if (m.modificationType == "Deconvolution Error") { ptm_rank = SaveState.lollipop.mod_rank_third_quartile; } }
public static void TestNeutralLossFragments() { Protein p = new Protein("PR", "ac"); ModificationMotif.TryGetMotif("X", out ModificationMotif motif); ModificationWithMass nTermAmmoniaLoss = new ModificationWithMass("ntermammonialoss", "mt", motif, TerminusLocalization.NPep, 0, neutralLosses: new List <double> { 0, -17 }); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 2); var cool = p.Digest(digestionParams, new List <ModificationWithMass> { nTermAmmoniaLoss }, new List <ModificationWithMass>()).First(); var nice = cool.CompactPeptide(TerminusType.None); Assert.AreEqual(2, nice.NTerminalMasses.Length); Assert.AreEqual(1, nice.CTerminalMasses.Length); }
public void TestMods() { PsmCross PSM = new PsmCross(); PSM.BaseSequence = "DMHGDSEYNIMFGPDICGPGTK"; PSM.FullSequence = "DM[Common Variable:Oxidation of M]HGDSEYNIM[Common Variable:Oxidation of M]FGPDIC[Common Fixed:Carbamidomethyl of C]GPGTK"; PSM.PeptideMonisotopicMass = 2472.0032; var mods = TsvResultReader.GetMods(PSM); Dictionary <int, ModificationWithMass> allModsOneIsNterminus = new Dictionary <int, ModificationWithMass>(); foreach (var item in mods) { ModificationMotif.TryGetMotif(item.Value, out ModificationMotif modificationMotif); ModificationWithMass mod = new ModificationWithMass("mod", null, modificationMotif, TerminusLocalization.Any, 10); allModsOneIsNterminus.Add(item.Key, mod); } PepWithSetModForCompactPep pepWithSetModForCompactPep = new PepWithSetModForCompactPep(); pepWithSetModForCompactPep.allModsOneIsNterminus = allModsOneIsNterminus; pepWithSetModForCompactPep.BaseSequence = PSM.BaseSequence; pepWithSetModForCompactPep.Length = PSM.BaseSequence.Length; pepWithSetModForCompactPep.MonoisotopicMass = (double)PSM.PeptideMonisotopicMass; var compactPeptide = new CompactPeptide(pepWithSetModForCompactPep, TerminusType.None); PSM.CompactPeptide = compactPeptide; var lp = new List <ProductType> { ProductType.BnoB1ions, ProductType.Y }; Tolerance productMassTolerance = new PpmTolerance(10); var pmm = PsmCross.XlCalculateTotalProductMassesForSingle(PSM, lp, false); var matchedIonMassesListPositiveIsMatch = new MatchedIonInfo(pmm.ProductMz.Length); //double pmmScore = PsmCross.XlMatchIons(theScan.TheScan, productMassTolerance, pmm.ProductMz, pmm.ProductName, matchedIonMassesListPositiveIsMatch); }
public void nodes_table_gives_meaningful_modified_theoreticals2() { ModificationMotif motif; ModificationMotif.TryGetMotif("K", out motif); ModificationWithMass m = new ModificationWithMass("oxidation", new Tuple <string, string>("", ""), motif, ModificationSites.K, 1, new Dictionary <string, IList <string> >(), new List <double>(), new List <double>(), ""); Proteoform p = ConstructorsForTesting.make_a_theoretical(); ProteoformFamily f = new ProteoformFamily(p); f.construct_family(); string node_table = CytoscapeScript.get_cytoscape_nodes_tsv(new List <ProteoformFamily> { f }, false, CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], Lollipop.node_positioning[0], 2, f.theoretical_proteoforms, false, Lollipop.gene_name_labels[1]); Assert.True(node_table.Contains(CytoscapeScript.modified_theoretical_label)); Assert.AreNotEqual(f.theoretical_proteoforms[0].accession, CytoscapeScript.get_proteoform_shared_name(p, Lollipop.node_labels[0], 2)); }
private static mzIdentML110.Generated.CVParamType GetUnimodCvParam(ModificationWithMass mod) { if (mod.linksToOtherDbs.ContainsKey("Unimod")) { return(new mzIdentML110.Generated.CVParamType() { accession = "UNIMOD:" + mod.linksToOtherDbs["Unimod"].First(), name = mod.id, cvRef = "PSI-MS", }); } else { return new mzIdentML110.Generated.CVParamType() { accession = "MS:1001460", name = "unknown modification", cvRef = "UNIMOD", value = mod.id, } }; } }
public void Test_write_with_custom_mods() { ModificationMotif.TryGetMotif("S", out ModificationMotif m1); ModificationMotif.TryGetMotif("T", out ModificationMotif m2); ModificationMotif.TryGetMotif("X", out ModificationMotif motiff); var nice = new List <Modification> { new ModificationWithLocation("fayk", "mt", motiff, TerminusLocalization.Any, null), new ModificationWithLocation("Phosphoserine", "mt", m1, TerminusLocalization.Any, null), new ModificationWithLocation("Phosphothreonine", "mt", m2, TerminusLocalization.Any, null) }; ModificationMotif.TryGetMotif("K", out ModificationMotif motif); ModificationWithMass m = new ModificationWithMass("mod", "mt", motif, TerminusLocalization.Any, 1, neutralLosses: new List <double> { -1 }); Dictionary <string, HashSet <Tuple <int, Modification> > > new_mods = new Dictionary <string, HashSet <Tuple <int, Modification> > > { { "P53863", new HashSet <Tuple <int, Modification> > { new Tuple <int, Modification>(2, m) } } }; List <Protein> ok = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, @"xml2.xml"), true, DecoyType.None, nice, false, new List <string>(), out Dictionary <string, Modification> un); var newModResEntries = ProteinDbWriter.WriteXmlDatabase(new_mods, ok, Path.Combine(TestContext.CurrentContext.TestDirectory, @"rewrite_xml2.xml")); Assert.AreEqual(1, newModResEntries.Count); List <Protein> ok2 = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, @"rewrite_xml2.xml"), true, DecoyType.None, nice, false, new List <string>(), out un); Assert.AreEqual(ok.Count, ok2.Count); Assert.True(Enumerable.Range(0, ok.Count).All(i => ok[i].BaseSequence == ok2[i].BaseSequence)); Assert.AreEqual(2, ok[0].OneBasedPossibleLocalizedModifications.Count); Assert.AreEqual(3, ok2[0].OneBasedPossibleLocalizedModifications.Count); }
public static bool ModFits(ModificationWithMass attemptToLocalize, Protein protein, int peptideOneBasedIndex, int peptideLength, int proteinOneBasedIndex) { var motif = attemptToLocalize.motif; // First find the capital letter... var hehe = motif.ToString().IndexOf(motif.ToString().First(b => char.IsUpper(b))); var proteinToMotifOffset = proteinOneBasedIndex - hehe - 1; var indexUp = 0; // Look up starting at and including the capital letter while (indexUp < motif.ToString().Length) { if (indexUp + proteinToMotifOffset < 0 || indexUp + proteinToMotifOffset >= protein.Length || (!char.ToUpper(motif.ToString()[indexUp]).Equals('X') && !char.ToUpper(motif.ToString()[indexUp]).Equals(protein.BaseSequence[indexUp + proteinToMotifOffset]))) { return(false); } indexUp++; } if (attemptToLocalize.terminusLocalization == TerminusLocalization.NProt && (proteinOneBasedIndex > 2)) { return(false); } if (attemptToLocalize.terminusLocalization == TerminusLocalization.NPep && peptideOneBasedIndex > 1) { return(false); } if (attemptToLocalize.terminusLocalization == TerminusLocalization.PepC && peptideOneBasedIndex < peptideLength) { return(false); } if (attemptToLocalize.terminusLocalization == TerminusLocalization.ProtC && proteinOneBasedIndex < protein.Length) { return(false); } return(true); }
public static TheoreticalProteoform make_a_theoretical(string a, double mass, int lysine_count) { ModificationWithMass unmodification = new ModificationWithMass("Unmodified", new Tuple <string, string>("N/A", "Unmodified"), null, ModificationSites.Any, 0, null, null, null, null); ProteinWithGoTerms p1 = new ProteinWithGoTerms("MSSSSSSSSSSS", "T1", new List <Tuple <string, string> > { new Tuple <string, string>("", "") }, new Dictionary <int, List <Modification> > { { 0, new List <Modification> { unmodification } } }, new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, "T2", "T3", true, false, new List <DatabaseReference> { new DatabaseReference("GO", ":", new List <Tuple <string, string> > { new Tuple <string, string>("term", "P:") }) }, new List <GoTerm> { new GoTerm(new DatabaseReference("GO", ":", new List <Tuple <string, string> > { new Tuple <string, string>("term", "P:") })) }); PtmSet set = new PtmSet(new List <Ptm>()); return(new TheoreticalProteoform(a, "", new List <ProteinWithGoTerms> { p1 }, mass, lysine_count, set, true, false, new Dictionary <InputFile, Protein[]>())); }
public static void MultiProteaseIndistiguishableTest() { string[] sequences = { "ABCEFG", "EFGABC", }; List <Tuple <string, TerminusType> > sequencesInducingCleavage = new List <Tuple <string, TerminusType> > { new Tuple <string, TerminusType>("C", TerminusType.C) }; List <Tuple <string, TerminusType> > sequencesInducingCleavage2 = new List <Tuple <string, TerminusType> > { new Tuple <string, TerminusType>("G", TerminusType.C) }; var protease = new Protease("testA", sequencesInducingCleavage, new List <Tuple <string, TerminusType> >(), CleavageSpecificity.Full, null, null, null); ProteaseDictionary.Dictionary.Add(protease.Name, protease); var protease2 = new Protease("testB", sequencesInducingCleavage2, new List <Tuple <string, TerminusType> >(), CleavageSpecificity.Full, null, null, null); ProteaseDictionary.Dictionary.Add(protease2.Name, protease2); var peptideList = new HashSet <PeptideWithSetModifications>(); var p = new List <Protein>(); List <Tuple <string, string> > gn = new List <Tuple <string, string> >(); for (int i = 0; i < sequences.Length; i++) { p.Add(new Protein(sequences[i], (i + 1).ToString(), null, gn, new Dictionary <int, List <Modification> >())); } DigestionParams digestionParams = new DigestionParams(protease: protease.Name, minPeptideLength: 1); DigestionParams digestionParams2 = new DigestionParams(protease: protease2.Name, minPeptideLength: 1); foreach (var protein in p) { foreach (var peptide in protein.Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>())) { switch (peptide.BaseSequence) { case "ABC": peptideList.Add(peptide); break; case "EFG": peptideList.Add(peptide); break; } } foreach (var peptide in protein.Digest(digestionParams2, new List <ModificationWithMass>(), new List <ModificationWithMass>())) { switch (peptide.BaseSequence) { case "ABC": peptideList.Add(peptide); break; case "EFG": peptideList.Add(peptide); break; } } } // creates the initial dictionary of "peptide" and "virtual peptide" matches var dictionary = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >(); CompactPeptide[] peptides = new CompactPeptide[peptideList.Count]; PeptideWithSetModifications[] PWSM = new PeptideWithSetModifications[peptideList.Count]; // creates peptide list for (int i = 0; i < peptideList.Count; i++) { peptides[i] = new CompactPeptide(peptideList.ElementAt(i), TerminusType.None); PWSM[i] = peptideList.ElementAt(i); } dictionary.Add(peptides[0], new HashSet <PeptideWithSetModifications> { PWSM[0], PWSM[3] }); dictionary.Add(peptides[1], new HashSet <PeptideWithSetModifications> { PWSM[1], PWSM[2] }); // builds psm list to match to peptides List <PeptideSpectralMatch> psms = new List <PeptideSpectralMatch>(); 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"); foreach (var kvp in dictionary) { foreach (var peptide in kvp.Value) { switch (peptide.BaseSequence) { case "ABC": if (peptide.DigestionParams == digestionParams) { psms.Add(new PeptideSpectralMatch(peptide.CompactPeptide(TerminusType.None), 0, 10, 0, scan, digestionParams)); break; } if (peptide.DigestionParams == digestionParams2) { psms.Add(new PeptideSpectralMatch(peptide.CompactPeptide(TerminusType.None), 0, 10, 0, scan, digestionParams2)); break; } else { break; } case "EFG": if (peptide.DigestionParams == digestionParams) { psms.Add(new PeptideSpectralMatch(peptide.CompactPeptide(TerminusType.None), 0, 10, 0, scan, digestionParams)); break; } if (peptide.DigestionParams == digestionParams2) { psms.Add(new PeptideSpectralMatch(peptide.CompactPeptide(TerminusType.None), 0, 10, 0, scan, digestionParams2)); break; } else { break; } } } } List <ProductType> IonTypes = new List <ProductType>(); ProductType BnoB1ions = ProductType.BnoB1ions; ProductType Yions = ProductType.Y; IonTypes.Add(BnoB1ions); IonTypes.Add(Yions); HashSet <DigestionParams> digestionParamsList = new HashSet <DigestionParams>(); digestionParamsList.Add(digestionParams); digestionParamsList.Add(digestionParams2); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); ModificationWithMass mod = new ModificationWithMass("Oxidation of M", "Common Variable", motif1, TerminusLocalization.Any, 15.99491461957); List <ModificationWithMass> modVarList = new List <ModificationWithMass> { mod }; ModificationMotif.TryGetMotif("M", out ModificationMotif motif2); List <ModificationWithMass> modFixedList = new List <ModificationWithMass> { mod }; SequencesToActualProteinPeptidesEngine sequencesToActualProteinPeptidesEngine = new SequencesToActualProteinPeptidesEngine(psms, p, modFixedList, modVarList, IonTypes, digestionParamsList, true, new CommonParameters(), null); var results = (SequencesToActualProteinPeptidesEngineResults)sequencesToActualProteinPeptidesEngine.Run(); var CompactPeptidesToProteinPeptidesMatching = results.CompactPeptideToProteinPeptideMatching; Assert.AreEqual(2, CompactPeptidesToProteinPeptidesMatching.Count); Assert.AreEqual(2, CompactPeptidesToProteinPeptidesMatching.ElementAt(0).Value.Count); Assert.AreEqual("ABC", CompactPeptidesToProteinPeptidesMatching.ElementAt(0).Value.ElementAt(0).BaseSequence); Assert.AreEqual("ABC", CompactPeptidesToProteinPeptidesMatching.ElementAt(0).Value.ElementAt(1).BaseSequence); Assert.AreEqual(2, CompactPeptidesToProteinPeptidesMatching.ElementAt(1).Value.Count); Assert.AreEqual("EFG", CompactPeptidesToProteinPeptidesMatching.ElementAt(1).Value.ElementAt(0).BaseSequence); Assert.AreEqual("EFG", CompactPeptidesToProteinPeptidesMatching.ElementAt(1).Value.ElementAt(1).BaseSequence); ProteinParsimonyEngine ppe = new ProteinParsimonyEngine(CompactPeptidesToProteinPeptidesMatching, false, new CommonParameters(), null); var proteinAnalysisResults = (ProteinParsimonyResults)ppe.Run(); List <ProteinGroup> proteinGroups = proteinAnalysisResults.ProteinGroups; Assert.AreEqual(2, proteinGroups.Count); Assert.AreEqual(2, proteinGroups.ElementAt(0).AllPeptides.Count); Assert.AreEqual(2, proteinGroups.ElementAt(0).UniquePeptides.Count); Assert.AreEqual("ABC", proteinGroups.ElementAt(0).AllPeptides.ElementAt(0).BaseSequence); Assert.AreEqual("testA", proteinGroups.ElementAt(0).AllPeptides.ElementAt(0).DigestionParams.Protease.Name); Assert.AreEqual("EFG", proteinGroups.ElementAt(0).AllPeptides.ElementAt(1).BaseSequence); Assert.AreEqual("testA", proteinGroups.ElementAt(0).AllPeptides.ElementAt(1).DigestionParams.Protease.Name); Assert.AreEqual("ABC", proteinGroups.ElementAt(0).UniquePeptides.ElementAt(0).BaseSequence); Assert.AreEqual("EFG", proteinGroups.ElementAt(0).UniquePeptides.ElementAt(1).BaseSequence); Assert.AreEqual(2, proteinGroups.ElementAt(1).AllPeptides.Count); Assert.AreEqual(2, proteinGroups.ElementAt(1).UniquePeptides.Count); Assert.AreEqual("ABC", proteinGroups.ElementAt(1).AllPeptides.ElementAt(0).BaseSequence); Assert.AreEqual("testB", proteinGroups.ElementAt(1).AllPeptides.ElementAt(0).DigestionParams.Protease.Name); Assert.AreEqual("EFG", proteinGroups.ElementAt(1).AllPeptides.ElementAt(1).BaseSequence); Assert.AreEqual("testB", proteinGroups.ElementAt(1).AllPeptides.ElementAt(1).DigestionParams.Protease.Name); Assert.AreEqual("ABC", proteinGroups.ElementAt(1).UniquePeptides.ElementAt(0).BaseSequence); Assert.AreEqual("EFG", proteinGroups.ElementAt(1).UniquePeptides.ElementAt(1).BaseSequence); }
public static void XlTest_BSA_DSSO() { //Generate parameters var commonParameters = new CommonParameters(doPrecursorDeconvolution: false, cIons: true, zDotIons: true, scoreCutoff: 2, digestionParams: new DigestionParams(minPeptideLength: 5)); var xlSearchParameters = new XlSearchParameters { XlCharge_2_3_PrimeFragment = true }; //Create databases contain two protein. var proteinList = new List <Protein> { new Protein("EKVLTSSAR", "Fake01"), new Protein("LSQKFPK", "Fake02") }; ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); ModificationWithMass mod1 = new ModificationWithMass("Oxidation of M", "Common Variable", motif1, TerminusLocalization.Any, 15.99491461957); ModificationMotif.TryGetMotif("C", out ModificationMotif motif2); ModificationWithMass mod2 = new ModificationWithMass("Carbamidomethyl of C", "Common Fixed", motif2, TerminusLocalization.Any, 57.02146372068994); var variableModifications = new List <ModificationWithMass>() { mod1 }; var fixedModifications = new List <ModificationWithMass>() { mod2 }; var localizeableModifications = new List <ModificationWithMass>(); var lp = new List <ProductType> { ProductType.BnoB1ions, ProductType.Y, ProductType.C, ProductType.Zdot }; Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int i = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)i); i++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)i); i++; } //Generate digested peptide lists. List <PeptideWithSetModifications> digestedList = new List <PeptideWithSetModifications>(); foreach (var item in proteinList) { var digested = item.Digest(commonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); digestedList.AddRange(digested); } foreach (var fdfd in digestedList) { fdfd.CompactPeptide(TerminusType.None); } //Run index engine var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, lp, 1, DecoyType.Reverse, new List <DigestionParams> { commonParameters.DigestionParams }, commonParameters, 30000, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); var fragmentIndexCount = indexResults.FragmentIndex.Count(p => p != null); var fragmentIndexAll = indexResults.FragmentIndex.Select((s, j) => new { j, s }).Where(p => p.s != null).Select(t => t.j).ToList(); Assert.IsTrue(fragmentIndexAll.Count() > 0); //Get MS2 scans. var myMsDataFile = new XLTestDataFile(); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, commonParameters.DoPrecursorDeconvolution, commonParameters.UseProvidedPrecursorInfo, commonParameters.DeconvolutionIntensityRatio, commonParameters.DeconvolutionMaxAssumedChargeState, commonParameters.DeconvolutionMassTolerance).OrderBy(b => b.PrecursorMass).ToArray(); //Generate crosslinker, which is DSSO here. CrosslinkerTypeClass crosslinker = new CrosslinkerTypeClass(); crosslinker.SelectCrosslinker(xlSearchParameters.CrosslinkerType); //TwoPassCrosslinkSearchEngine.Run(). List <PsmCross> newPsms = new List <PsmCross>(); new TwoPassCrosslinkSearchEngine(newPsms, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, lp, 0, commonParameters, false, xlSearchParameters.XlPrecusorMsTl, crosslinker, xlSearchParameters.CrosslinkSearchTop, xlSearchParameters.CrosslinkSearchTopNum, xlSearchParameters.XlQuench_H2O, xlSearchParameters.XlQuench_NH2, xlSearchParameters.XlQuench_Tris, xlSearchParameters.XlCharge_2_3, xlSearchParameters.XlCharge_2_3_PrimeFragment, new List <string> { }).Run(); var compactPeptideToProteinPeptideMatch = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >(); new CrosslinkAnalysisEngine(newPsms, compactPeptideToProteinPeptideMatch, proteinList, variableModifications, fixedModifications, lp, null, crosslinker, TerminusType.None, commonParameters, new List <string> { }).Run(); foreach (var item in newPsms) { item.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); } //Test newPsms Assert.AreEqual(newPsms.Count(), 3); //Test Output var task = new XLSearchTask(); task.WriteAllToTsv(newPsms, TestContext.CurrentContext.TestDirectory, "allPsms", new List <string> { }); task.WritePepXML_xl(newPsms, proteinList, null, variableModifications, fixedModifications, null, TestContext.CurrentContext.TestDirectory, "pep.XML", new List <string> { }); task.WriteSingleToTsv(newPsms.Where(p => p.CrossType == PsmCrossType.Singe).ToList(), TestContext.CurrentContext.TestDirectory, "singlePsms", new List <string> { }); //Test PsmCross.XlCalculateTotalProductMasses. var psmCrossAlpha = new PsmCross(digestedList[1].CompactPeptide(TerminusType.None), 0, 0, i, listOfSortedms2Scans[0], commonParameters.DigestionParams); var psmCrossBeta = new PsmCross(digestedList[2].CompactPeptide(TerminusType.None), 0, 0, i, listOfSortedms2Scans[0], commonParameters.DigestionParams); var linkPos = PsmCross.XlPosCal(psmCrossAlpha.compactPeptide, crosslinker.CrosslinkerModSites); var productMassesAlphaList = PsmCross.XlCalculateTotalProductMasses(psmCrossAlpha, psmCrossBeta.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.TotalMass, crosslinker, lp, true, false, linkPos); Assert.AreEqual(productMassesAlphaList[0].ProductMz.Length, 99); }
public static void TestProteinSplitAcrossFiles() { SearchTask st = new SearchTask() { CommonParameters = new CommonParameters( scoreCutoff: 1, digestionParams: new DigestionParams( maxMissedCleavages: 0, minPeptideLength: 5, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain)), SearchParameters = new SearchParameters { DoHistogramAnalysis = true, MassDiffAcceptorType = MassDiffAcceptorType.Open, MatchBetweenRuns = true, DoQuantification = true }, }; string proteinDbFilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestProteinSplitAcrossFiles.xml"); string mzmlFilePath1 = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestProteinSplitAcrossFiles1.mzML"); string mzmlFilePath2 = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestProteinSplitAcrossFiles2.mzML"); ModificationMotif.TryGetMotif("D", out ModificationMotif motif); ModificationWithMass mod = new ModificationWithMass("mod1", "mt", motif, TerminusLocalization.Any, 10); IDictionary <int, List <Modification> > oneBasedModification = new Dictionary <int, List <Modification> > { { 3, new List <Modification> { mod } } }; Protein prot1 = new Protein("MEDEEK", "prot1", oneBasedModifications: oneBasedModification); var pep1 = prot1.Digest(st.CommonParameters.DigestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First(); var pep2 = prot1.Digest(st.CommonParameters.DigestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).Last(); List <PeptideWithSetModifications> listForFile1 = new List <PeptideWithSetModifications> { pep1, pep2 }; List <PeptideWithSetModifications> listForFile2 = new List <PeptideWithSetModifications> { pep2 }; MsDataFile myMsDataFile1 = new TestDataFile(listForFile1); MsDataFile myMsDataFile2 = new TestDataFile(listForFile2); List <Protein> proteinList = new List <Protein> { prot1 }; IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile1, mzmlFilePath1, false); IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile2, mzmlFilePath2, false); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), proteinList, proteinDbFilePath); string output_folder = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestProteinSplitAcrossFiles"); Directory.CreateDirectory(output_folder); st.RunTask( output_folder, new List <DbForTask> { new DbForTask(proteinDbFilePath, false) }, new List <string> { mzmlFilePath1, mzmlFilePath2, }, null); }
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 SearchWithPeptidesAddedInParsimonyTest() { // Make sure can run the complete search task when multiple compact peptides may correspond to a single PWSM SearchTask st = new SearchTask { SearchParameters = new SearchParameters { DoParsimony = true, DecoyType = DecoyType.None, ModPeptidesAreDifferent = false }, CommonParameters = new CommonParameters { ScoreCutoff = 1, DigestionParams = new DigestionParams { MinPeptideLength = 2 } } }; string xmlName = "andguiaheow.xml"; #region Generate protein and write to file CommonParameters CommonParameters = new CommonParameters { DigestionParams = new DigestionParams { MaxMissedCleavages = 0, MinPeptideLength = null, InitiatorMethionineBehavior = InitiatorMethionineBehavior.Retain, MaxModsForPeptide = 1, MaxModificationIsoforms = 2 }, ScoreCutoff = 1 }; ModificationMotif.TryGetMotif("A", out ModificationMotif motifA); ModificationWithMass alanineMod = new ModificationWithMass("111", "mt", motifA, TerminusLocalization.Any, 111); var variableModifications = new List <ModificationWithMass>(); IDictionary <int, List <Modification> > oneBasedModifications1 = new Dictionary <int, List <Modification> > { { 2, new List <Modification> { alanineMod } } }; Protein protein1 = new Protein("MA", "protein1", oneBasedModifications: oneBasedModifications1); // Alanine = Glycine + CH2 ModificationMotif.TryGetMotif("G", out ModificationMotif motif1); ModificationWithMass glycineMod = new ModificationWithMass("CH2 on Glycine", "mt", motif1, TerminusLocalization.Any, Chemistry.ChemicalFormula.ParseFormula("CH2").MonoisotopicMass); IDictionary <int, List <Modification> > oneBasedModifications2 = new Dictionary <int, List <Modification> > { { 2, new List <Modification> { glycineMod } } }; Protein protein2 = new Protein("MG", "protein3", oneBasedModifications: oneBasedModifications2); PeptideWithSetModifications pepMA = protein1.Digest(CommonParameters.DigestionParams, new List <ModificationWithMass>(), variableModifications).First(); PeptideWithSetModifications pepMA111 = protein1.Digest(CommonParameters.DigestionParams, new List <ModificationWithMass>(), variableModifications).Last(); var pepMG = protein2.Digest(CommonParameters.DigestionParams, new List <ModificationWithMass>(), variableModifications).First(); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), new List <Protein> { protein1, protein2 }, xmlName); #endregion Generate protein and write to file string mzmlName = @"ajgdiu.mzML"; #region Generate and write the mzml { IMsDataFile <IMsDataScan <IMzSpectrum <IMzPeak> > > myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> { pepMA, pepMG, pepMA111 }, true); IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlName, false); } #endregion Generate and write the mzml st.RunTask("", new List <DbForTask> { new DbForTask(xmlName, false) }, new List <string> { mzmlName }, ""); }
public void TestFullProteinReadWrite() { Modification mod = new Modification("mod1", "modType1"); ModificationMotif.TryGetMotif("E", out ModificationMotif motif); ModificationWithLocation mod2 = new ModificationWithLocation("mod2", "modType1", motif, TerminusLocalization.Any, null); ModificationMotif.TryGetMotif("N", out ModificationMotif motif3); ModificationWithMass mod3 = new ModificationWithMass("mod3", "modType1", motif3, TerminusLocalization.Any, 10, null, null, null); List <Tuple <string, string> > gene_names = new List <Tuple <string, string> > { new Tuple <string, string>("a", "b") }; IDictionary <int, List <Modification> > oneBasedModifications = new Dictionary <int, List <Modification> > { { 3, new List <Modification> { mod } }, { 4, new List <Modification> { mod2 } }, { 5, new List <Modification> { mod3 } } }; List <ProteolysisProduct> proteolysisProducts = new List <ProteolysisProduct> { new ProteolysisProduct(1, 2, "propeptide") }; string name = "testName"; string full_name = "testFullName"; List <DatabaseReference> databaseReferences = new List <DatabaseReference> { new DatabaseReference("type1", "id1", new List <Tuple <string, string> > { new Tuple <string, string>("e1", "e2") }) }; List <SequenceVariation> sequenceVariations = new List <SequenceVariation> { new SequenceVariation(3, "Q", "N", "replace Q by N"), new SequenceVariation(3, 4, "QE", "NN", "replace QE by NN") }; List <DisulfideBond> disulfideBonds = new List <DisulfideBond> { new DisulfideBond(1, "ds1"), new DisulfideBond(2, 3, "ds2") }; Protein p1 = new Protein("SEQENCE", "a1", gene_names: gene_names, oneBasedModifications: oneBasedModifications, proteolysisProducts: proteolysisProducts, name: name, full_name: full_name, isDecoy: false, isContaminant: true, databaseReferences: databaseReferences, sequenceVariations: sequenceVariations, disulfideBonds: disulfideBonds, databaseFilePath: Path.Combine(TestContext.CurrentContext.TestDirectory, @"bnueiwhf.xml")); // Generate data for files ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), new List <Protein> { p1 }, Path.Combine(TestContext.CurrentContext.TestDirectory, @"bnueiwhf.xml")); IEnumerable <string> modTypesToExclude = new List <string>(); IEnumerable <Modification> allKnownModifications = new List <Modification>(); List <Protein> ok = ProteinDbLoader.LoadProteinXML(Path.Combine(TestContext.CurrentContext.TestDirectory, @"bnueiwhf.xml"), true, DecoyType.None, allKnownModifications, true, modTypesToExclude, out Dictionary <string, Modification> unknownModifications); Assert.AreEqual(p1.Accession, ok[0].Accession); Assert.AreEqual(p1.BaseSequence, ok[0].BaseSequence); Assert.AreEqual(p1.DatabaseReferences.First().Id, ok[0].DatabaseReferences.First().Id); Assert.AreEqual(p1.DatabaseReferences.First().Properties.First().Item1, ok[0].DatabaseReferences.First().Properties.First().Item1); Assert.AreEqual(p1.DatabaseReferences.First().Properties.First().Item2, ok[0].DatabaseReferences.First().Properties.First().Item2); Assert.AreEqual(p1.DatabaseReferences.First().Type, ok[0].DatabaseReferences.First().Type); Assert.AreEqual(p1.DisulfideBonds.First().Description, ok[0].DisulfideBonds.First().Description); Assert.AreEqual(p1.DisulfideBonds.First().OneBasedBeginPosition, ok[0].DisulfideBonds.First().OneBasedBeginPosition); Assert.AreEqual(p1.DisulfideBonds.First().OneBasedEndPosition, ok[0].DisulfideBonds.First().OneBasedEndPosition); Assert.AreEqual(p1.DisulfideBonds.Last().Description, ok[0].DisulfideBonds.Last().Description); Assert.AreEqual(p1.DisulfideBonds.Last().OneBasedBeginPosition, ok[0].DisulfideBonds.Last().OneBasedBeginPosition); Assert.AreEqual(p1.DisulfideBonds.Last().OneBasedEndPosition, ok[0].DisulfideBonds.Last().OneBasedEndPosition); Assert.AreEqual(p1.FullDescription, ok[0].FullDescription); Assert.AreEqual(p1.FullName, ok[0].FullName); Assert.AreEqual(p1.GeneNames, ok[0].GeneNames); Assert.AreEqual(p1.IsContaminant, ok[0].IsContaminant); Assert.AreEqual(p1.IsDecoy, ok[0].IsDecoy); Assert.AreEqual(p1.Length, ok[0].Length); Assert.AreEqual(p1.Name, ok[0].Name); Assert.AreEqual(p1.DatabaseFilePath, ok[0].DatabaseFilePath); Assert.AreEqual(p1.OneBasedPossibleLocalizedModifications[3][0], ok[0].OneBasedPossibleLocalizedModifications[3][0]); Assert.AreEqual(p1.OneBasedPossibleLocalizedModifications[3][0].id, ok[0].OneBasedPossibleLocalizedModifications[3][0].id); Assert.AreEqual(p1.OneBasedPossibleLocalizedModifications[3][0].modificationType, ok[0].OneBasedPossibleLocalizedModifications[3][0].modificationType); Assert.AreEqual(p1.OneBasedPossibleLocalizedModifications[4][0].id, ok[0].OneBasedPossibleLocalizedModifications[4][0].id); Assert.AreEqual(p1.OneBasedPossibleLocalizedModifications[4][0].modificationType, ok[0].OneBasedPossibleLocalizedModifications[4][0].modificationType); Assert.AreEqual((p1.OneBasedPossibleLocalizedModifications[4][0] as ModificationWithLocation).linksToOtherDbs, (ok[0].OneBasedPossibleLocalizedModifications[4][0] as ModificationWithLocation).linksToOtherDbs); Assert.AreEqual((p1.OneBasedPossibleLocalizedModifications[4][0] as ModificationWithLocation).motif, (ok[0].OneBasedPossibleLocalizedModifications[4][0] as ModificationWithLocation).motif); Assert.AreEqual((p1.OneBasedPossibleLocalizedModifications[4][0] as ModificationWithLocation).terminusLocalization, (ok[0].OneBasedPossibleLocalizedModifications[4][0] as ModificationWithLocation).terminusLocalization); Assert.AreEqual((p1.OneBasedPossibleLocalizedModifications[5][0] as ModificationWithMass).diagnosticIons, (ok[0].OneBasedPossibleLocalizedModifications[5][0] as ModificationWithMass).diagnosticIons); Assert.AreEqual((p1.OneBasedPossibleLocalizedModifications[5][0] as ModificationWithMass).neutralLosses, (ok[0].OneBasedPossibleLocalizedModifications[5][0] as ModificationWithMass).neutralLosses); Assert.AreEqual((p1.OneBasedPossibleLocalizedModifications[5][0] as ModificationWithMass).monoisotopicMass, (ok[0].OneBasedPossibleLocalizedModifications[5][0] as ModificationWithMass).monoisotopicMass); Assert.AreEqual(p1.ProteolysisProducts.First().OneBasedBeginPosition, ok[0].ProteolysisProducts.First().OneBasedBeginPosition); Assert.AreEqual(p1.ProteolysisProducts.First().OneBasedEndPosition, ok[0].ProteolysisProducts.First().OneBasedEndPosition); Assert.AreEqual(p1.ProteolysisProducts.First().Type, ok[0].ProteolysisProducts.First().Type); Assert.AreEqual(p1.SequenceVariations.First().Description, ok[0].SequenceVariations.First().Description); Assert.AreEqual(p1.SequenceVariations.First().OneBasedBeginPosition, ok[0].SequenceVariations.First().OneBasedBeginPosition); Assert.AreEqual(p1.SequenceVariations.First().OneBasedEndPosition, ok[0].SequenceVariations.First().OneBasedEndPosition); Assert.AreEqual(p1.SequenceVariations.First().OriginalSequence, ok[0].SequenceVariations.First().OriginalSequence); Assert.AreEqual(p1.SequenceVariations.First().VariantSequence, ok[0].SequenceVariations.First().VariantSequence); Assert.AreEqual(p1.SequenceVariations.Last().Description, ok[0].SequenceVariations.Last().Description); Assert.AreEqual(p1.SequenceVariations.Last().OneBasedBeginPosition, ok[0].SequenceVariations.Last().OneBasedBeginPosition); Assert.AreEqual(p1.SequenceVariations.Last().OneBasedEndPosition, ok[0].SequenceVariations.Last().OneBasedEndPosition); Assert.AreEqual(p1.SequenceVariations.Last().OriginalSequence, ok[0].SequenceVariations.Last().OriginalSequence); Assert.AreEqual(p1.SequenceVariations.Last().VariantSequence, ok[0].SequenceVariations.Last().VariantSequence); }
public static void ParsimonyVariableDontTreatAsUnique() { bool modPeptidesAreUnique = false; // set up mods var modDictionary = new Dictionary <int, List <Modification> >(); ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); var mod = new ModificationWithMass("Oxidation of M", "Common Variable", motif1, TerminusLocalization.Any, 15.99491461957); Protease protease = new Protease("k Protease", 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); TerminusType terminusType = ProductTypeMethods.IdentifyTerminusType(new List <ProductType> { ProductType.B, ProductType.Y }); // modified version of protein var protein1 = new Protein("PEPTIDEM", "accession1"); // unmodified version of protein var protein2 = new Protein("YYYKPEPTIDEM", "accession2"); var pep1 = protein1.Digest(new DigestionParams(protease: "k Protease", minPeptideLength: 1), new List <ModificationWithMass> { mod }, new List <ModificationWithMass>()).First(); var pep2 = protein2.Digest(new DigestionParams(protease: "k Protease", minPeptideLength: 1), new List <ModificationWithMass> { mod }, new List <ModificationWithMass>()).ToList()[1]; // check to make sure mod is present Assert.That(pep1.Sequence.Equals(pep2.Sequence)); Assert.That(pep1.NumMods == 1); Assert.That(pep2.NumMods == 1); // build the dictionary for input to parsimony var compactPeptideToProteinPeptideMatching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >(); var cp1 = pep1.CompactPeptide(terminusType); var cp2 = pep2.CompactPeptide(terminusType); Assert.That(cp1.Equals(cp2)); compactPeptideToProteinPeptideMatching.Add(pep1.CompactPeptide(terminusType), new HashSet <PeptideWithSetModifications> { pep1 }); Assert.That(compactPeptideToProteinPeptideMatching.ContainsKey(cp2)); compactPeptideToProteinPeptideMatching[cp2].Add(pep2); // apply parsimony ProteinParsimonyEngine pae = new ProteinParsimonyEngine(compactPeptideToProteinPeptideMatching, modPeptidesAreUnique, new CommonParameters(), new List <string>()); pae.Run(); // check to make sure both peptides are associated with both proteins Assert.That(compactPeptideToProteinPeptideMatching.Count == 1); Assert.That(compactPeptideToProteinPeptideMatching.First().Value.Count == 2); var seq = compactPeptideToProteinPeptideMatching.First().Value.First().Sequence; foreach (var sequence in compactPeptideToProteinPeptideMatching.First().Value) { Assert.That(sequence.Sequence.Equals(seq)); } }
public static void TestBinGeneration() { SearchTask st = new SearchTask { CommonParameters = new CommonParameters(scoreCutoff: 1, digestionParams: new DigestionParams(minPeptideLength: 5, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain)), SearchParameters = new SearchParameters { DoHistogramAnalysis = true, MassDiffAcceptorType = MassDiffAcceptorType.Open, DecoyType = DecoyType.None, DoParsimony = true, DoQuantification = true }, }; string proteinDbFilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "BinGenerationTest.xml"); string mzmlFilePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "BinGenerationTest.mzML"); Protein prot1 = new Protein("MEDEEK", "prot1"); Protein prot2 = new Protein("MENEEK", "prot2"); ModificationMotif.TryGetMotif("D", out ModificationMotif motif); ModificationWithMass mod = new ModificationWithMass(null, null, motif, TerminusLocalization.Any, 10); var pep1_0 = prot1.Digest(st.CommonParameters.DigestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First(); var pep1_10 = prot1.Digest(st.CommonParameters.DigestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).Last(); Protein prot3 = new Protein("MAAADAAAAAAAAAAAAAAA", "prot3"); var pep2_0 = prot3.Digest(st.CommonParameters.DigestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First(); var pep2_10 = prot3.Digest(st.CommonParameters.DigestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass> { mod }).Last(); Protein prot4 = new Protein("MNNDNNNN", "prot4"); var pep3_10 = prot4.Digest(st.CommonParameters.DigestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass> { mod }).Last(); List <PeptideWithSetModifications> pepsWithSetMods = new List <PeptideWithSetModifications> { pep1_0, pep1_10, pep2_0, pep2_10, pep3_10 }; MsDataFile myMsDataFile = new TestDataFile(pepsWithSetMods); List <Protein> proteinList = new List <Protein> { prot1, prot2, prot3, prot4 }; IO.MzML.MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(myMsDataFile, mzmlFilePath, false); ProteinDbWriter.WriteXmlDatabase(new Dictionary <string, HashSet <Tuple <int, Modification> > >(), proteinList, proteinDbFilePath); string output_folder = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestBinGeneration"); Directory.CreateDirectory(output_folder); st.RunTask( output_folder, new List <DbForTask> { new DbForTask(proteinDbFilePath, false) }, new List <string> { mzmlFilePath }, null); Assert.AreEqual(3, File.ReadLines(Path.Combine(output_folder, @"MassDifferenceHistogram.tsv")).Count()); }