public static void XlTestXlPosCal() { var prot = new Protein("MNNNKQQQQ", null); Protease protease = new Protease("New Custom 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); DigestionParams digestionParams = new DigestionParams(protease: protease.Name, minPeptideLength: 1, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain); List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); var ye = prot.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList(); var pep = ye[0]; Assert.AreEqual(pep.BaseSequence, "MNNNK"); CrosslinkerTypeClass crosslinker = new CrosslinkerTypeClass(); crosslinker.SelectCrosslinker(CrosslinkerType.DSS); Assert.AreEqual(crosslinker.CrosslinkerModSites, "K"); Assert.AreEqual(Residue.GetResidue(crosslinker.CrosslinkerModSites).MonoisotopicMass, 128.09496301518999, 1e-9); var n = pep.CompactPeptide(TerminusType.None).NTerminalMasses; var c = pep.CompactPeptide(TerminusType.None).CTerminalMasses; Assert.AreEqual(n.Count(), 4); Assert.AreEqual(c.Count(), 4); Assert.AreEqual(c[0], 128.09496301518999, 1e-6); var x = PsmCross.XlPosCal(pep.CompactPeptide(TerminusType.None), crosslinker.CrosslinkerModSites).ToArray(); Assert.AreEqual(x[0], 4); var pep2 = ye[2]; Assert.AreEqual("MNNNKQQQQ", pep2.BaseSequence); var n2 = pep2.CompactPeptide(TerminusType.None).NTerminalMasses; var c2 = pep2.CompactPeptide(TerminusType.None).CTerminalMasses; Assert.AreEqual(n2.Count(), 8); Assert.AreEqual(c2.Count(), 8); Assert.AreEqual(n2[4] - n2[3], 128.09496301518999, 1e-6); var x2 = PsmCross.XlPosCal(pep2.CompactPeptide(TerminusType.None), crosslinker.CrosslinkerModSites).ToArray(); Assert.AreEqual(x2[0], 4); //Test crosslinker with multiple types of mod var protSTC = new Protein("GASTACK", null); var peps = protSTC.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList(); var pepSTC = peps[0]; Assert.AreEqual(pepSTC.BaseSequence, "GASTACK"); CrosslinkerTypeClass crosslinker2 = new CrosslinkerTypeClass("ST", "C", "crosslinkerSTC", false, -18.01056, 0, 0, 0, 0, 0, 0); string crosslinkerModSitesAll = new string((crosslinker2.CrosslinkerModSites + crosslinker2.CrosslinkerModSites2).ToCharArray().Distinct().ToArray()); Assert.AreEqual(crosslinkerModSitesAll, "STC"); }
public static void XlTestXlPosCal() { var prot = new Protein("MNNNKQQQQ", null); var protease = new Protease("Custom Protease", new List <string> { "K" }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null); DigestionParams digestionParams = new DigestionParams { InitiatorMethionineBehavior = InitiatorMethionineBehavior.Retain, MaxMissedCleavages = 2, Protease = protease, MinPeptideLength = 1 }; List <ModificationWithMass> variableModifications = new List <ModificationWithMass>(); var ye = prot.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList(); var pep = ye[0]; Assert.AreEqual(pep.BaseSequence, "MNNNK"); CrosslinkerTypeClass crosslinker = new CrosslinkerTypeClass(); crosslinker.SelectCrosslinker(CrosslinkerType.DSS); Assert.AreEqual(crosslinker.CrosslinkerModSite, 'K'); Assert.AreEqual(Residue.GetResidue(crosslinker.CrosslinkerModSite).MonoisotopicMass, 128.09496301518999, 1e-9); var n = pep.CompactPeptide(TerminusType.None).NTerminalMasses; var c = pep.CompactPeptide(TerminusType.None).CTerminalMasses; Assert.AreEqual(n.Count(), 4); Assert.AreEqual(c.Count(), 4); Assert.AreEqual(c[0], 128.09496301518999, 1e-6); var x = PsmCross.XlPosCal(pep.CompactPeptide(TerminusType.None), crosslinker).ToArray(); Assert.AreEqual(x[0], 4); var pep2 = ye[2]; Assert.AreEqual("MNNNKQQQQ", pep2.BaseSequence); var n2 = pep2.CompactPeptide(TerminusType.None).NTerminalMasses; var c2 = pep2.CompactPeptide(TerminusType.None).CTerminalMasses; Assert.AreEqual(n2.Count(), 8); Assert.AreEqual(c2.Count(), 8); Assert.AreEqual(n2[4] - n2[3], 128.09496301518999, 1e-6); var x2 = PsmCross.XlPosCal(pep2.CompactPeptide(TerminusType.None), crosslinker).ToArray(); Assert.AreEqual(x2[0], 4); }
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 XlTestLocalization() { var CommonParameters = new CommonParameters(); var proteinList = new List <Protein> { new Protein("CASIQKFGERLCVLHEKTPVSEK", null) }; 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 }; 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++; } var engine = new IndexingEngine(proteinList, variableModifications, fixedModifications, lp, 1, DecoyType.Reverse, new List <IDigestionParams> { CommonParameters.DigestionParams }, CommonParameters, 30000, new List <string>()); var results = (IndexingResults)engine.Run(); var digestedList = proteinList[0].Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList(); foreach (var fdfd in digestedList) { fdfd.CompactPeptide(TerminusType.None); //Assert.Contains(fdfd.CompactPeptide(TerminusType.None), results.PeptideIndex); } var productMasses = digestedList[3].CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> { ProductType.B, ProductType.Y }); CrosslinkerTypeClass crosslinker = new CrosslinkerTypeClass(); crosslinker.SelectCrosslinker(CrosslinkerType.DSS); var x = PsmCross.XlPosCal(digestedList[3].CompactPeptide(TerminusType.None), crosslinker).ToArray(); Assert.AreEqual(x[0], 5); 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(); var psmCrossAlpha = new PsmCross(digestedList[3].CompactPeptide(TerminusType.None), 0, 0, i, listOfSortedms2Scans[0]); var psmCrossBeta = new PsmCross(digestedList[5].CompactPeptide(TerminusType.None), 0, 0, i, listOfSortedms2Scans[0]); var modMassAlpha1 = psmCrossBeta.compactPeptide.MonoisotopicMassIncludingFixedMods + crosslinker.TotalMass; //Another method to calculate modification mass of cross-linked peptides //var modMassAlpha2 = listOfSortedms2Scans[0].PrecursorMass - psmCrossAlpha.compactPeptide.MonoisotopicMassIncludingFixedMods; var linkPos = PsmCross.XlPosCal(psmCrossAlpha.compactPeptide, crosslinker); var productMassesAlphaList = PsmCross.XlCalculateTotalProductMasses(psmCrossAlpha, modMassAlpha1, crosslinker, lp, true, false, linkPos); Assert.AreEqual(productMassesAlphaList[0].ProductMz.Length, 35); Assert.AreEqual(productMassesAlphaList[0].ProductMz[26], 2312.21985342336); }