public static void TestVeryCloseExperimentalsModern() { IDictionary <int, List <Modification> > mods = new Dictionary <int, List <Modification> >(); ModificationMotif.TryGetMotif("M", out ModificationMotif motif); var prot = new Protein("MMMM", null, null, null, mods); DigestionParams digestionParams = new DigestionParams(minPeptideLength: 1); var thePep = prot.Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First(); var massArray = thePep.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> { ProductType.B, ProductType.Y }); Array.Sort(massArray); double[] intensities = new double[] { 1, 1, 1, 1 }; double[] mz = new double[] { 1, 2, massArray[4].ToMz(1), massArray[4].ToMz(1) + 1e-9 }; MzSpectrum massSpectrum = new MzSpectrum(mz, intensities, false); MsDataScan scan = new MsDataScan(massSpectrum, 1, 1, true, Polarity.Positive, 1, new MzRange(300, 2000), "", MZAnalyzerType.Unknown, massSpectrum.SumOfAllY, null, null, "scan=1", 0, null, null, 0, null, DissociationType.Unknown, 1, null); PeptideSpectralMatch[] globalPsms = new PeptideSpectralMatch[1]; Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans = { new Ms2ScanWithSpecificMass(scan, 600, 1, null) }; CommonParameters CommonParameters = new CommonParameters(productMassTolerance: new PpmTolerance(5), scoreCutoff: 1, digestionParams: new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, maxModificationIsoforms: int.MaxValue, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain)); var indexEngine = new IndexingEngine(new List <Protein> { prot }, new List <ModificationWithMass>(), new List <ModificationWithMass>(), new List <ProductType> { ProductType.B, ProductType.Y }, 1, DecoyType.Reverse, new List <DigestionParams> { CommonParameters.DigestionParams }, CommonParameters, 30000, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); var cse = new ModernSearchEngine(globalPsms, arrayOfSortedMS2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, new List <ProductType> { ProductType.B, ProductType.Y }, 0, CommonParameters, new OpenSearchMode(), 0, new List <string>()); cse.Run(); Assert.Less(globalPsms[0].Score, 2); Assert.Greater(globalPsms[0].Score, 1); }
public static void TestDeltaValues() { CommonParameters CommonParameters = new CommonParameters(scoreCutoff: 1, useDeltaScore: true, digestionParams: new DigestionParams(minPeptideLength: 5)); SearchParameters SearchParameters = new SearchParameters { MassDiffAcceptorType = MassDiffAcceptorType.Exact, }; List <Modification> variableModifications = GlobalVariables.AllModsKnown.OfType <Modification>().Where(b => CommonParameters.ListOfModsVariable.Contains((b.ModificationType, b.IdWithMotif))).ToList(); List <Modification> fixedModifications = GlobalVariables.AllModsKnown.OfType <Modification>().Where(b => CommonParameters.ListOfModsFixed.Contains((b.ModificationType, b.IdWithMotif))).ToList(); // Generate data for files Protein TargetProtein1 = new Protein("TIDEANTHE", "accession1"); Protein TargetProtein2 = new Protein("TIDELVE", "accession2"); Protein TargetProtein3 = new Protein("TIDENIE", "accession3"); Protein TargetProteinLost = new Protein("PEPTIDEANTHE", "accession4"); Protein DecoyProteinFound = new Protein("PETPLEDQGTHE", "accessiond", isDecoy: true); MsDataFile myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> { TargetProtein1.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein2.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein3.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], DecoyProteinFound.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0] }); var proteinList = new List <Protein> { TargetProtein1, TargetProtein2, TargetProtein3, TargetProteinLost, DecoyProteinFound }; var searchModes = new SinglePpmAroundZeroSearchMode(5); Tolerance DeconvolutionMassTolerance = new PpmTolerance(5); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); //check better when using delta PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, proteinList, searchModes, CommonParameters, new List <string>()).Run(); var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, 1, DecoyType.None, CommonParameters, 30000, false, new List <FileInfo>(), new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); PeptideSpectralMatch[] allPsmsArrayModern = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArrayModern, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, massDiffAcceptor, 0, new List <string>()).Run(); FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); FdrAnalysisResults fdrResultsModernDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArrayModern.ToList(), 1, CommonParameters, new List <string>()).Run()); Assert.IsTrue(fdrResultsClassicDelta.PsmsWithin1PercentFdr == 3); Assert.IsTrue(fdrResultsModernDelta.PsmsWithin1PercentFdr == 3); CommonParameters = new CommonParameters(digestionParams: new DigestionParams(minPeptideLength: 5)); //check worse when using score FdrAnalysisResults fdrResultsClassic = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); FdrAnalysisResults fdrResultsModern = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); Assert.IsTrue(fdrResultsClassic.PsmsWithin1PercentFdr == 0); Assert.IsTrue(fdrResultsModern.PsmsWithin1PercentFdr == 0); //check that when delta is bad, we used the score // Generate data for files Protein DecoyProtein1 = new Protein("TLEDAGGTHE", "accession1d", isDecoy: true); Protein DecoyProtein2 = new Protein("TLEDLVE", "accession2d", isDecoy: true); Protein DecoyProtein3 = new Protein("TLEDNIE", "accession3d", isDecoy: true); Protein DecoyProteinShiny = new Protein("GGGGGG", "accessionShinyd", isDecoy: true); myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> { TargetProtein1.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein2.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein3.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], DecoyProteinShiny.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], }); proteinList = new List <Protein> { TargetProtein1, DecoyProtein1, TargetProtein2, DecoyProtein2, TargetProtein3, DecoyProtein3, DecoyProteinShiny, }; listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); //check no change when using delta allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, proteinList, searchModes, CommonParameters, new List <string>()).Run(); CommonParameters = new CommonParameters(useDeltaScore: true, digestionParams: new DigestionParams(minPeptideLength: 5)); indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, 1, DecoyType.None, CommonParameters, 30000, false, new List <FileInfo>(), new List <string>()); indexResults = (IndexingResults)indexEngine.Run(); massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); allPsmsArrayModern = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArrayModern, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, massDiffAcceptor, 0, new List <string>()).Run(); fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); fdrResultsModernDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArrayModern.ToList(), 1, CommonParameters, new List <string>()).Run()); Assert.IsTrue(fdrResultsClassicDelta.PsmsWithin1PercentFdr == 3); Assert.IsTrue(fdrResultsModernDelta.PsmsWithin1PercentFdr == 3); CommonParameters = new CommonParameters(digestionParams: new DigestionParams(minPeptideLength: 5)); //check no change when using score fdrResultsClassic = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); fdrResultsModern = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArrayModern.ToList(), 1, CommonParameters, new List <string>()).Run()); Assert.IsTrue(fdrResultsClassic.PsmsWithin1PercentFdr == 3); Assert.IsTrue(fdrResultsModern.PsmsWithin1PercentFdr == 3); }
public static void TestCompIons_ModernSearch() { var myMsDataFile = new TestDataFile(); var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var localizeableModifications = new List <Modification>(); Dictionary <Modification, ushort> modsDictionary = new Dictionary <Modification, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int ii = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } var proteinList = new List <Protein> { new Protein("MNNNKQQQ", null) }; SearchParameters SearchParameters = new SearchParameters { MassDiffAcceptorType = MassDiffAcceptorType.Exact, SearchTarget = true, }; List <DigestionMotif> motifs = new List <DigestionMotif> { new DigestionMotif("K", null, 1, null) }; Protease protease = new Protease("singleN4", CleavageSpecificity.Full, null, null, motifs); ProteaseDictionary.Dictionary.Add(protease.Name, protease); CommonParameters CommonParameters = new CommonParameters(digestionParams: new DigestionParams(protease: protease.Name, minPeptideLength: 1), scoreCutoff: 1); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", CommonParameters)); CommonParameters withCompIons = new CommonParameters(digestionParams: new DigestionParams(protease: protease.Name, minPeptideLength: 1), scoreCutoff: 1, addCompIons: true); var fspComp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fspComp.Add(("", CommonParameters)); var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, null, null, 1, DecoyType.Reverse, CommonParameters, fsp, SearchParameters.MaxFragmentSize, false, new List <FileInfo>(), TargetContaminantAmbiguity.RemoveContaminant, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); Tolerance DeconvolutionMassTolerance = new PpmTolerance(5); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); // without complementary ions PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List <string>()).Run(); // with complementary ions PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, withCompIons, fspComp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List <string>()).Run(); // Single search mode Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); // Single ms2 scan Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); Assert.That(allPsmsArray[0] != null); Assert.That(allPsmsArray2[0] != null); Assert.IsTrue(allPsmsArray2[0].Score > 1); Assert.AreEqual(allPsmsArray[0].ScanNumber, allPsmsArray2[0].ScanNumber); Assert.IsTrue(allPsmsArray2[0].Score <= allPsmsArray[0].Score * 2 && allPsmsArray2[0].Score > allPsmsArray[0].Score + 3); }
public static void AddCompIonsCommonParams() { CommonParameters cp = new CommonParameters(null, DissociationType.HCD, DissociationType.Unknown, DissociationType.Unknown, null, true, true, 3, 12, true, true, 1, 5, 200, 0.01, null, null, false, false, true, false, null, null, null, -1, null, null, null, 1, true, 4, 1); var myMsDataFile = new TestDataFile(); var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var localizeableModifications = new List <Modification>(); Dictionary <Modification, ushort> modsDictionary = new Dictionary <Modification, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int ii = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } var proteinList = new List <Protein> { new Protein("MNNNKQQQ", null) }; SearchParameters SearchParameters = new SearchParameters { MassDiffAcceptorType = MassDiffAcceptorType.Exact, SearchTarget = true, }; List <DigestionMotif> motifs = new List <DigestionMotif> { new DigestionMotif("K", null, 1, null) }; Protease protease = new Protease("Test", CleavageSpecificity.Full, null, null, motifs); ProteaseDictionary.Dictionary.Add(protease.Name, protease); var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>(); fsp.Add(("", cp)); var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, new List <SilacLabel>(), null, null, 1, DecoyType.Reverse, cp, fsp, SearchParameters.MaxFragmentSize, false, new List <FileInfo>(), TargetContaminantAmbiguity.RemoveContaminant, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); Tolerance DeconvolutionMassTolerance = new PpmTolerance(5); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(cp.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); // without complementary ions PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; var mse = new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, cp, fsp, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List <string>()).Run(); }
public static void TestIndexEngine() { var proteinList = new List <Protein> { new Protein("MNNNKQQQ", null) }; var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var localizeableModifications = new List <Modification>(); Dictionary <Modification, ushort> modsDictionary = new Dictionary <Modification, 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++; } List <DigestionMotif> motifs = new List <DigestionMotif> { new DigestionMotif("K", null, 1, null) }; Protease p = new Protease("Custom Protease2", CleavageSpecificity.Full, null, null, motifs); ProteaseDictionary.Dictionary.Add(p.Name, p); CommonParameters CommonParameters = new CommonParameters(scoreCutoff: 1, digestionParams: new DigestionParams(protease: p.Name, minPeptideLength: 1)); var engine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, 1, DecoyType.None, CommonParameters, 30000, false, new List <FileInfo>(), new List <string>()); var results = (IndexingResults)engine.Run(); Assert.AreEqual(5, results.PeptideIndex.Count); var digestedList = proteinList[0].Digest(CommonParameters.DigestionParams, new List <Modification>(), variableModifications).ToList(); Assert.AreEqual(5, digestedList.Count); foreach (PeptideWithSetModifications peptide in digestedList) { Assert.Contains(peptide, results.PeptideIndex); var fragments = peptide.Fragment(CommonParameters.DissociationType, FragmentationTerminus.Both).ToList(); int positionInPeptideIndex = results.PeptideIndex.IndexOf(peptide); foreach (Product fragment in fragments) { // mass of the fragment double fragmentMass = fragment.NeutralMass; int integerMassRepresentation = (int)Math.Round(fragmentMass * 1000); // look up the peptides that have fragments with this mass // the result of the lookup is a list of peptide IDs that have this fragment mass List <int> fragmentBin = results.FragmentIndex[integerMassRepresentation]; // this list should contain this peptide! Assert.Contains(positionInPeptideIndex, fragmentBin); } } }
public static void TestIndexEngineLowRes() { var proteinList = ProteinDbLoader.LoadProteinFasta(Path.Combine(TestContext.CurrentContext.TestDirectory, @"indexEngineTestFasta.fasta"), true, DecoyType.Reverse, false, ProteinDbLoader.UniprotAccessionRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotGeneNameRegex, ProteinDbLoader.UniprotOrganismRegex, out var dbErrors, -1); var variableModifications = new List <Modification>(); var fixedModifications = new List <Modification>(); var localizeableModifications = new List <Modification>(); Dictionary <Modification, ushort> modsDictionary = new Dictionary <Modification, 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++; } CommonParameters CommonParameters = new CommonParameters(dissociationType: DissociationType.LowCID, maxThreadsToUsePerFile: 1, scoreCutoff: 1, digestionParams: new DigestionParams(protease: "trypsin", minPeptideLength: 1)); var engine = new IndexingEngine(proteinList, variableModifications, fixedModifications, null, 1, DecoyType.Reverse, CommonParameters, 30000, false, new List <FileInfo>(), new List <string>()); var results = (IndexingResults)engine.Run(); Assert.AreEqual(10, results.PeptideIndex.Count); var bubba = results.FragmentIndex; var tooBubba = results.PrecursorIndex; var digestedList = proteinList[0].Digest(CommonParameters.DigestionParams, new List <Modification>(), variableModifications).ToList(); digestedList.AddRange(proteinList[1].Digest(CommonParameters.DigestionParams, new List <Modification>(), variableModifications)); Assert.AreEqual(10, digestedList.Count); foreach (PeptideWithSetModifications peptide in digestedList) { Assert.Contains(peptide, results.PeptideIndex); var fragments = peptide.Fragment(CommonParameters.DissociationType, FragmentationTerminus.Both).ToList(); int positionInPeptideIndex = results.PeptideIndex.IndexOf(peptide); foreach (Product fragment in fragments.Where(f => f.ProductType == ProductType.b || f.ProductType == ProductType.y)) { // mass of the fragment double fragmentMass = Math.Round(fragment.NeutralMass / 1.0005079, 0) * 1.0005079; int integerMassRepresentation = (int)Math.Round(fragmentMass * 1000); // look up the peptides that have fragments with this mass // the result of the lookup is a list of peptide IDs that have this fragment mass List <int> fragmentBin = results.FragmentIndex[integerMassRepresentation]; // this list should contain this peptide! Assert.Contains(positionInPeptideIndex, fragmentBin); } } foreach (var fdfd in digestedList) { Assert.Contains(fdfd, results.PeptideIndex); } }
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 TestCompIons_ModernSearch() { var myMsDataFile = new TestDataFile(); var variableModifications = new List <ModificationWithMass>(); var fixedModifications = new List <ModificationWithMass>(); var localizeableModifications = new List <ModificationWithMass>(); Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>(); foreach (var mod in fixedModifications) { modsDictionary.Add(mod, 0); } int ii = 1; foreach (var mod in variableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } foreach (var mod in localizeableModifications) { modsDictionary.Add(mod, (ushort)ii); ii++; } var proteinList = new List <Protein> { new Protein("MNNNKQQQ", null) }; SearchParameters SearchParameters = new SearchParameters { MassDiffAcceptorType = MassDiffAcceptorType.Exact, SearchTarget = true, }; CommonParameters CommonParameters = new CommonParameters { PrecursorMassTolerance = new PpmTolerance(5), DigestionParams = new DigestionParams { Protease = new Protease("singleN", new List <string> { "K" }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null), MinPeptideLength = null, }, ConserveMemory = false, ScoreCutoff = 1, }; var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, new List <ProductType> { ProductType.B, ProductType.Y }, 1, DecoyType.Reverse, new List <IDigestionParams> { CommonParameters.DigestionParams }, CommonParameters, SearchParameters.MaxFragmentSize, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); bool DoPrecursorDeconvolution = true; bool UseProvidedPrecursorInfo = true; double DeconvolutionIntensityRatio = 4; int DeconvolutionMaxAssumedChargeState = 10; Tolerance DeconvolutionMassTolerance = new PpmTolerance(5); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, DoPrecursorDeconvolution, UseProvidedPrecursorInfo, DeconvolutionIntensityRatio, DeconvolutionMaxAssumedChargeState, DeconvolutionMassTolerance).OrderBy(b => b.PrecursorMass).ToArray(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArray, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, new List <ProductType> { ProductType.B, ProductType.Y }, 0, CommonParameters, SearchParameters.AddCompIons, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List <string>()).Run(); PeptideSpectralMatch[] allPsmsArray2 = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; SearchParameters.AddCompIons = true; new ModernSearchEngine(allPsmsArray2, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, new List <ProductType> { ProductType.B, ProductType.Y }, 0, CommonParameters, SearchParameters.AddCompIons, massDiffAcceptor, SearchParameters.MaximumMassThatFragmentIonScoreIsDoubled, new List <string>()).Run(); // Single search mode Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); // Single ms2 scan Assert.AreEqual(allPsmsArray.Length, allPsmsArray2.Length); Assert.That(allPsmsArray[0] != null); Assert.That(allPsmsArray2[0] != null); Assert.IsTrue(allPsmsArray2[0].Score > 1); Assert.AreEqual(allPsmsArray[0].ScanNumber, allPsmsArray2[0].ScanNumber); Assert.IsTrue(allPsmsArray2[0].Score <= allPsmsArray[0].Score * 2 && allPsmsArray2[0].Score > allPsmsArray[0].Score + 3); }
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"); }
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); }
public static void TestDeltaValues() { CommonParameters CommonParameters = new CommonParameters(scoreCutoff: 1, useDeltaScore: true, digestionParams: new DigestionParams(minPeptideLength: 5)); SearchParameters SearchParameters = new SearchParameters { MassDiffAcceptorType = MassDiffAcceptorType.Exact, }; List <ModificationWithMass> variableModifications = GlobalVariables.AllModsKnown.OfType <ModificationWithMass>().Where(b => CommonParameters.ListOfModsVariable.Contains((b.modificationType, b.id))).ToList(); List <ModificationWithMass> fixedModifications = GlobalVariables.AllModsKnown.OfType <ModificationWithMass>().Where(b => CommonParameters.ListOfModsFixed.Contains((b.modificationType, b.id))).ToList(); // Generate data for files Protein TargetProtein1 = new Protein("TIDEANTHE", "accession1"); Protein TargetProtein2 = new Protein("TIDELVE", "accession2"); Protein TargetProtein3 = new Protein("TIDENIE", "accession3"); Protein TargetProteinLost = new Protein("PEPTIDEANTHE", "accession4"); Protein DecoyProteinFound = new Protein("PETPLEDQGTHE", "accessiond", isDecoy: true); MsDataFile myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> { TargetProtein1.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein2.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein3.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], DecoyProteinFound.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0] }); var proteinList = new List <Protein> { TargetProtein1, TargetProtein2, TargetProtein3, TargetProteinLost, DecoyProteinFound }; var searchModes = new SinglePpmAroundZeroSearchMode(5); bool DoPrecursorDeconvolution = true; bool UseProvidedPrecursorInfo = true; double DeconvolutionIntensityRatio = 4; int DeconvolutionMaxAssumedChargeState = 10; Tolerance DeconvolutionMassTolerance = new PpmTolerance(5); var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, DoPrecursorDeconvolution, UseProvidedPrecursorInfo, DeconvolutionIntensityRatio, DeconvolutionMaxAssumedChargeState, DeconvolutionMassTolerance).OrderBy(b => b.PrecursorMass).ToArray(); //check better when using delta PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, proteinList, new List <ProductType> { ProductType.B, ProductType.Y }, searchModes, CommonParameters, new List <string>()).Run(); var indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, new List <ProductType> { ProductType.B, ProductType.Y }, 1, DecoyType.None, new List <DigestionParams> { CommonParameters.DigestionParams }, CommonParameters, 30000, new List <string>()); var indexResults = (IndexingResults)indexEngine.Run(); MassDiffAcceptor massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); PeptideSpectralMatch[] allPsmsArrayModern = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArrayModern, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, new List <ProductType> { ProductType.B, ProductType.Y }, 0, CommonParameters, massDiffAcceptor, 0, new List <string>()).Run(); Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > compactPeptideToProteinPeptideMatching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >(); if (proteinList.Any()) { SequencesToActualProteinPeptidesEngine sequencesToActualProteinPeptidesEngine = new SequencesToActualProteinPeptidesEngine(allPsmsArray.ToList(), proteinList, fixedModifications, variableModifications, new List <ProductType> { ProductType.B, ProductType.Y }, new List <DigestionParams> { CommonParameters.DigestionParams }, CommonParameters.ReportAllAmbiguity, CommonParameters, new List <string>()); var res = (SequencesToActualProteinPeptidesEngineResults)sequencesToActualProteinPeptidesEngine.Run(); compactPeptideToProteinPeptideMatching = res.CompactPeptideToProteinPeptideMatching; } foreach (var psm in allPsmsArray) { psm.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching); } foreach (var psm in allPsmsArrayModern) { psm.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching); } FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); FdrAnalysisResults fdrResultsModernDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArrayModern.ToList(), 1, CommonParameters, new List <string>()).Run()); Assert.IsTrue(fdrResultsClassicDelta.PsmsWithin1PercentFdr == 3); Assert.IsTrue(fdrResultsModernDelta.PsmsWithin1PercentFdr == 3); CommonParameters = new CommonParameters(digestionParams: new DigestionParams(minPeptideLength: 5)); //check worse when using score FdrAnalysisResults fdrResultsClassic = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); FdrAnalysisResults fdrResultsModern = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); Assert.IsTrue(fdrResultsClassic.PsmsWithin1PercentFdr == 0); Assert.IsTrue(fdrResultsModern.PsmsWithin1PercentFdr == 0); //check that when delta is bad, we used the score // Generate data for files Protein DecoyProtein1 = new Protein("TLEDAGGTHE", "accession1d", isDecoy: true); Protein DecoyProtein2 = new Protein("TLEDLVE", "accession2d", isDecoy: true); Protein DecoyProtein3 = new Protein("TLEDNIE", "accession3d", isDecoy: true); Protein DecoyProteinShiny = new Protein("GGGGGG", "accessionShinyd", isDecoy: true); myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> { TargetProtein1.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein2.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], TargetProtein3.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], DecoyProteinShiny.Digest(CommonParameters.DigestionParams, fixedModifications, variableModifications).ToList()[0], }); proteinList = new List <Protein> { TargetProtein1, DecoyProtein1, TargetProtein2, DecoyProtein2, TargetProtein3, DecoyProtein3, DecoyProteinShiny, }; listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, DoPrecursorDeconvolution, UseProvidedPrecursorInfo, DeconvolutionIntensityRatio, DeconvolutionMaxAssumedChargeState, DeconvolutionMassTolerance).OrderBy(b => b.PrecursorMass).ToArray(); //check no change when using delta allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, proteinList, new List <ProductType> { ProductType.B, ProductType.Y }, searchModes, CommonParameters, new List <string>()).Run(); CommonParameters = new CommonParameters(useDeltaScore: true, digestionParams: new DigestionParams(minPeptideLength: 5)); indexEngine = new IndexingEngine(proteinList, variableModifications, fixedModifications, new List <ProductType> { ProductType.B, ProductType.Y }, 1, DecoyType.None, new List <DigestionParams> { CommonParameters.DigestionParams }, CommonParameters, 30000, new List <string>()); indexResults = (IndexingResults)indexEngine.Run(); massDiffAcceptor = SearchTask.GetMassDiffAcceptor(CommonParameters.PrecursorMassTolerance, SearchParameters.MassDiffAcceptorType, SearchParameters.CustomMdac); allPsmsArrayModern = new PeptideSpectralMatch[listOfSortedms2Scans.Length]; new ModernSearchEngine(allPsmsArrayModern, listOfSortedms2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, new List <ProductType> { ProductType.B, ProductType.Y }, 0, CommonParameters, massDiffAcceptor, 0, new List <string>()).Run(); var compactPeptideToProteinPeptideMatching2 = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >(); if (proteinList.Any()) { SequencesToActualProteinPeptidesEngine sequencesToActualProteinPeptidesEngine2 = new SequencesToActualProteinPeptidesEngine(allPsmsArray.ToList(), proteinList, fixedModifications, variableModifications, new List <ProductType> { ProductType.B, ProductType.Y }, new List <DigestionParams> { CommonParameters.DigestionParams }, CommonParameters.ReportAllAmbiguity, CommonParameters, new List <string>()); var res = (SequencesToActualProteinPeptidesEngineResults)sequencesToActualProteinPeptidesEngine2.Run(); compactPeptideToProteinPeptideMatching2 = res.CompactPeptideToProteinPeptideMatching; } foreach (var psm in allPsmsArray) { psm.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching2); } foreach (var psm in allPsmsArrayModern) { psm.MatchToProteinLinkedPeptides(compactPeptideToProteinPeptideMatching2); } fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); fdrResultsModernDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArrayModern.ToList(), 1, CommonParameters, new List <string>()).Run()); Assert.IsTrue(fdrResultsClassicDelta.PsmsWithin1PercentFdr == 3); Assert.IsTrue(fdrResultsModernDelta.PsmsWithin1PercentFdr == 3); CommonParameters = new CommonParameters(digestionParams: new DigestionParams(minPeptideLength: 5)); //check no change when using score fdrResultsClassic = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.ToList(), 1, CommonParameters, new List <string>()).Run()); fdrResultsModern = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArrayModern.ToList(), 1, CommonParameters, new List <string>()).Run()); Assert.IsTrue(fdrResultsClassic.PsmsWithin1PercentFdr == 3); Assert.IsTrue(fdrResultsModern.PsmsWithin1PercentFdr == 3); }
private void GenerateIndexes(IndexingEngine indexEngine, List <DbForTask> dbFilenameList, ref List <CompactPeptide> peptideIndex, ref List <int>[] fragmentIndex, string taskId) { string pathToFolderWithIndices = GetExistingFolderWithIndices(indexEngine, dbFilenameList); if (pathToFolderWithIndices == null) { var output_folderForIndices = GenerateOutputFolderForIndices(dbFilenameList); Status("Writing params...", new List <string> { taskId }); var paramsFile = Path.Combine(output_folderForIndices, "indexEngine.params"); WriteIndexEngineParams(indexEngine, paramsFile); FinishedWritingFile(paramsFile, new List <string> { taskId }); Status("Running Index Engine...", new List <string> { taskId }); var indexResults = (IndexingResults)indexEngine.Run(); peptideIndex = indexResults.PeptideIndex; fragmentIndex = indexResults.FragmentIndex; Status("Writing peptide index...", new List <string> { taskId }); var peptideIndexFile = Path.Combine(output_folderForIndices, "peptideIndex.ind"); WritePeptideIndex(peptideIndex, peptideIndexFile); FinishedWritingFile(peptideIndexFile, new List <string> { taskId }); Status("Writing fragment index...", new List <string> { taskId }); var fragmentIndexFile = Path.Combine(output_folderForIndices, "fragmentIndex.ind"); WriteFragmentIndexNetSerializer(fragmentIndex, fragmentIndexFile); FinishedWritingFile(fragmentIndexFile, new List <string> { taskId }); } else { Status("Reading peptide index...", new List <string> { taskId }); var messageTypes = GetSubclassesAndItself(typeof(List <CompactPeptide>)); var ser = new NetSerializer.Serializer(messageTypes); using (var file = File.OpenRead(Path.Combine(pathToFolderWithIndices, "peptideIndex.ind"))) { peptideIndex = (List <CompactPeptide>)ser.Deserialize(file); } Status("Reading fragment index...", new List <string> { taskId }); messageTypes = GetSubclassesAndItself(typeof(List <int>[])); ser = new NetSerializer.Serializer(messageTypes); using (var file = File.OpenRead(Path.Combine(pathToFolderWithIndices, "fragmentIndex.ind"))) { fragmentIndex = (List <int>[])ser.Deserialize(file); } } }