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 XlTest_BSA_DSSO() { //Generate parameters var commonParameters = new CommonParameters(doPrecursorDeconvolution: false, dissociationType: DissociationType.EThcD, scoreCutoff: 1, digestionParams: new DigestionParams(minPeptideLength: 5), precursorMassTolerance: new PpmTolerance(10)); var xlSearchParameters = new XlSearchParameters(); //Create databases contain two protein. var proteinList = new List <Protein> { new Protein("EKVLTSSAR", "Fake01"), new Protein("LSQKFPK", "Fake02") }; ModificationMotif.TryGetMotif("M", out ModificationMotif motif1); Modification mod1 = new Modification(_originalId: "Oxidation of M", _modificationType: "Common Variable", _target: motif1, _locationRestriction: "Anywhere.", _monoisotopicMass: 15.99491461957); ModificationMotif.TryGetMotif("C", out ModificationMotif motif2); Modification mod2 = new Modification(_originalId: "Carbamidomethyl of C", _modificationType: "Common Fixed", _target: motif2, _locationRestriction: "Anywhere.", _monoisotopicMass: 57.02146372068994); var variableModifications = new List <Modification>() { mod1 }; var fixedModifications = new List <Modification>() { mod2 }; var localizeableModifications = new List <Modification>(); //Run index engine var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, 1, DecoyType.Reverse, commonParameters, 30000, false, new List <FileInfo>(), new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); var indexedFragments = indexResults.FragmentIndex.Where(p => p != null).SelectMany(v => v).ToList(); Assert.AreEqual(82, indexedFragments.Count); Assert.AreEqual(3, indexResults.PeptideIndex.Count); //Get MS2 scans. var myMsDataFile = new XLTestDataFile(); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); //Generate crosslinker, which is DSSO here. Crosslinker crosslinker = GlobalVariables.Crosslinkers.Where(p => p.CrosslinkerName == "DSSO").First(); CrosslinkSpectralMatch[] possiblePsms = new CrosslinkSpectralMatch[listOfSortedms2Scans.Length]; new CrosslinkSearchEngine(possiblePsms, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, commonParameters, crosslinker, xlSearchParameters.RestrictToTopNHits, xlSearchParameters.CrosslinkSearchTopNum, xlSearchParameters.XlQuench_H2O, xlSearchParameters.XlQuench_NH2, xlSearchParameters.XlQuench_Tris, new List <string> { }).Run(); var newPsms = possiblePsms.Where(p => p != null).ToList(); foreach (var item in newPsms) { item.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false); } //Test newPsms Assert.AreEqual(3, newPsms.Count); //Test Output var task = new XLSearchTask(); task.WritePepXML_xl(newPsms, proteinList, null, variableModifications, fixedModifications, null, TestContext.CurrentContext.TestDirectory, "pep.XML", new List <string> { }); //Test PsmCross.XlCalculateTotalProductMasses //var psmCrossAlpha = new CrosslinkSpectralMatch(digestedList[1], 0, 0, 0, listOfSortedms2Scans[0], commonParameters.DigestionParams, new List<MatchedFragmentIon>()); //var psmCrossBeta = new CrosslinkSpectralMatch(digestedList[2], 0, 0, 0, listOfSortedms2Scans[0], commonParameters.DigestionParams, new List<MatchedFragmentIon>()); //var linkPos = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), digestedList[1]); //var productMassesAlphaList = CrosslinkedPeptide.XlGetTheoreticalFragments(DissociationType.EThcD, false, crosslinker, linkPos, digestedList[2].MonoisotopicMass, digestedList[1]); //Assert.AreEqual(productMassesAlphaList.First().Value.Count, 50); //TO DO: The number here should be manually verified. File.Delete(@"singlePsms.tsv"); File.Delete(@"pep.XML.pep.xml"); File.Delete(@"allPsms.tsv"); }