示例#1
0
        public static void TestCombos()
        {
            List <PeptideSpectralMatch> allIdentifications = null;

            ModificationMotif.TryGetMotif("N", out ModificationMotif motifN);
            ModificationMotif.TryGetMotif("P", out ModificationMotif motifP);
            var gptmdModifications = new List <ModificationWithMass> {
                new ModificationWithMass("21", "mt", motifN, TerminusLocalization.Any, 21.981943, null),
                new ModificationWithMass("16", "mt", motifP, TerminusLocalization.Any, 15.994915, null)
            };
            IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> > {
                new Tuple <double, double>(21.981943, 15.994915)
            };
            Tolerance precursorMassTolerance = new PpmTolerance(10);

            MsDataScan dfd = 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(dfd, (651.297638557 + 21.981943 + 15.994915).ToMz(1), 1, "filepath");

            var                         parentProtein         = new Protein("NNNPPP", "accession");
            DigestionParams             digestionParams       = new DigestionParams(minPeptideLength: 5);
            List <ModificationWithMass> variableModifications = new List <ModificationWithMass>();
            var                         modPep = parentProtein.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).First();

            var peptidesWithSetModifications = new List <PeptideWithSetModifications> {
                modPep
            };
            PeptideSpectralMatch match  = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan, digestionParams);
            PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan, digestionParams);
            Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>();
            Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >
            {
                { peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> {
                      peptidesWithSetModifications.First()
                  } }
            };

            List <ProductType> lp = new List <ProductType> {
                ProductType.B, ProductType.Y
            };

            Tolerance fragmentTolerance = new AbsoluteTolerance(0.01);

            match.MatchToProteinLinkedPeptides(matching);

            match.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0, 0, false);
            allIdentifications = new List <PeptideSpectralMatch> {
                match
            };

            var engine = new GptmdEngine(allIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> {
                { "filepath", precursorMassTolerance }
            }, new CommonParameters(), new List <string>());
            var res = (GptmdResults)engine.Run();

            Assert.AreEqual(1, res.Mods.Count);
            Assert.AreEqual(6, res.Mods["accession"].Count);
            Assert.AreEqual(3, res.Mods["accession"].Where(b => b.Item2.id.Equals("21")).Count());
            Assert.AreEqual(3, res.Mods["accession"].Where(b => b.Item2.id.Equals("16")).Count());
        }
示例#2
0
        public static void TestGptmdEngine()
        {
            List <PeptideSpectralMatch> allResultingIdentifications = null;

            ModificationMotif.TryGetMotif("N", out ModificationMotif motifN);
            var gptmdModifications = new List <ModificationWithMass> {
                new ModificationWithMass("21", "mt", motifN, TerminusLocalization.Any, 21.981943)
            };
            IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> >();
            Tolerance precursorMassTolerance             = new PpmTolerance(10);

            allResultingIdentifications = new List <PeptideSpectralMatch>();
            var engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, precursorMassTolerance, new List <string>());
            var res    = (GptmdResults)engine.Run();

            Assert.AreEqual(0, res.Mods.Count);

            //PsmParent newPsm = new TestParentSpectrumMatch(588.22520189093 + 21.981943);
            Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(new MzmlScanWithPrecursor(0, new MzmlMzSpectrum(new double[] { 1 }, new double[] { 1 }, false), 1, true, Polarity.Positive, double.NaN, null, null, MZAnalyzerType.Orbitrap, double.NaN, double.NaN, null, null, double.NaN, null, DissociationType.AnyActivationType, 0, null, null, "scan=1"), (588.22520189093 + 21.981943).ToMz(1), 1, null);

            var parentProtein = new Protein("NNNNN", "accession");
            var protease      = new Protease("Custom Protease", new List <string> {
                "K"
            }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null);

            DigestionParams             digestionParams       = new DigestionParams();
            List <ModificationWithMass> variableModifications = new List <ModificationWithMass>();
            var modPep = parentProtein.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).First();

            var peptidesWithSetModifications = new List <PeptideWithSetModifications> {
                modPep
            };
            PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), 0, 0, 0, scan);

            Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>();
            Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >
            {
                { peptidesWithSetModifications.First().CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> {
                      peptidesWithSetModifications.First()
                  } }
            };
            List <ProductType> lp = new List <ProductType> {
                ProductType.B, ProductType.Y
            };
            Tolerance fragmentTolerance = new AbsoluteTolerance(0.01);

            newPsm.MatchToProteinLinkedPeptides(matching);

            newPsm.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0, 0, false);
            allResultingIdentifications.Add(newPsm);

            engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, precursorMassTolerance, new List <string>());
            res    = (GptmdResults)engine.Run();
            Assert.AreEqual(1, res.Mods.Count);
            Assert.AreEqual(5, res.Mods["accession"].Count);
        }
示例#3
0
        public static void TestGptmdEngine(string proteinSequence, string accession, string sequenceVariantDescription, int numModifiedResidues)
        {
            List <PeptideSpectralMatch> allResultingIdentifications = null;

            ModificationMotif.TryGetMotif("N", out ModificationMotif motifN);
            var gptmdModifications = new List <Modification> {
                new Modification(_originalId: "21", _modificationType: "mt", _target: motifN, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943)
            };
            IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> >();
            Tolerance precursorMassTolerance             = new PpmTolerance(10);

            allResultingIdentifications = new List <PeptideSpectralMatch>();

            var fsp = new List <(string fileName, CommonParameters fileSpecificParameters)>();

            fsp.Add(("", new CommonParameters()));

            var engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> {
                { "filepath", precursorMassTolerance }
            }, new CommonParameters(), fsp, new List <string>());
            var res = (GptmdResults)engine.Run();

            Assert.AreEqual(0, res.Mods.Count);

            var parentProtein = new Protein(proteinSequence, accession, sequenceVariations: new List <SequenceVariation> {
                new SequenceVariation(1, "N", "A", sequenceVariantDescription)
            });
            var variantProteins = parentProtein.GetVariantProteins();
            CommonParameters commonParameters = new CommonParameters(digestionParams: new DigestionParams(minPeptideLength: 5));

            List <Modification> variableModifications = new List <Modification>();
            var modPep = variantProteins.SelectMany(p => p.Digest(commonParameters.DigestionParams, new List <Modification>(), variableModifications)).First();

            //PsmParent newPsm = new TestParentSpectrumMatch(588.22520189093 + 21.981943);
            Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(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), (new Proteomics.AminoAcidPolymer.Peptide(modPep.BaseSequence).MonoisotopicMass + 21.981943).ToMz(1), 1, "filepath", new CommonParameters());

            var peptidesWithSetModifications = new List <PeptideWithSetModifications> {
                modPep
            };
            PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, commonParameters, new List <MatchedFragmentIon>());

            Tolerance fragmentTolerance = new AbsoluteTolerance(0.01);

            newPsm.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0);
            allResultingIdentifications.Add(newPsm);

            engine = new GptmdEngine(allResultingIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> {
                { "filepath", precursorMassTolerance }
            }, new CommonParameters(), null, new List <string>());
            res = (GptmdResults)engine.Run();
            Assert.AreEqual(1, res.Mods.Count);
            Assert.AreEqual(numModifiedResidues, res.Mods["accession"].Count);
        }
        public static void TestCombos(string proteinSequence, string accession, string variantAA, string sequenceVariantDescription, int numModHashes, int numModifiedResidues, int numModifiedResiduesN, int numModifiedResiduesP, int numModifiedResiduesNP)
        {
            List <PeptideSpectralMatch> allIdentifications = null;

            ModificationMotif.TryGetMotif("N", out ModificationMotif motifN);
            ModificationMotif.TryGetMotif("P", out ModificationMotif motifP);
            var gptmdModifications = new List <Modification> {
                new Modification(_originalId: "21", _modificationType: "mt", _target: motifN, _locationRestriction: "Anywhere.", _monoisotopicMass: 21.981943),
                new Modification(_originalId: "16", _modificationType: "mt", _target: motifP, _locationRestriction: "Anywhere.", _monoisotopicMass: 15.994915)
            };
            IEnumerable <Tuple <double, double> > combos = new List <Tuple <double, double> > {
                new Tuple <double, double>(21.981943, 15.994915)
            };
            Tolerance precursorMassTolerance = new PpmTolerance(10);

            var parentProtein = new Protein(proteinSequence, accession, sequenceVariations: new List <SequenceVariation> {
                new SequenceVariation(1, "N", variantAA, sequenceVariantDescription)
            });
            var variantProteins = parentProtein.GetVariantProteins();

            DigestionParams     digestionParams       = new DigestionParams(minPeptideLength: 5);
            List <Modification> variableModifications = new List <Modification>();
            var modPep = variantProteins.SelectMany(p => p.Digest(digestionParams, new List <Modification>(), variableModifications)).First();

            MsDataScan dfd = 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(dfd, (new Proteomics.AminoAcidPolymer.Peptide(modPep.BaseSequence).MonoisotopicMass + 21.981943 + 15.994915).ToMz(1), 1, "filepath", new CommonParameters());

            var peptidesWithSetModifications = new List <PeptideWithSetModifications> {
                modPep
            };
            PeptideSpectralMatch match  = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, digestionParams, new List <MatchedFragmentIon>());
            PeptideSpectralMatch newPsm = new PeptideSpectralMatch(peptidesWithSetModifications.First(), 0, 0, 0, scan, digestionParams, new List <MatchedFragmentIon>());

            Tolerance fragmentTolerance = new AbsoluteTolerance(0.01);

            match.SetFdrValues(1, 0, 0, 1, 0, 0, 0, 0);
            allIdentifications = new List <PeptideSpectralMatch> {
                match
            };

            var engine = new GptmdEngine(allIdentifications, gptmdModifications, combos, new Dictionary <string, Tolerance> {
                { "filepath", precursorMassTolerance }
            }, new CommonParameters(), new List <string>());
            var res = (GptmdResults)engine.Run();

            Assert.AreEqual(numModHashes, res.Mods.Count);
            Assert.AreEqual(numModifiedResidues, res.Mods["accession"].Count);
            Assert.AreEqual(numModifiedResiduesN, res.Mods["accession"].Where(b => b.Item2.OriginalId.Equals("21")).Count());
            Assert.AreEqual(numModifiedResiduesP, res.Mods["accession"].Where(b => b.Item2.OriginalId.Equals("16")).Count());
            res.Mods.TryGetValue("accession_N1P", out var hash);
            Assert.AreEqual(numModifiedResiduesNP, (hash ?? new HashSet <Tuple <int, Modification> >()).Count);
        }