public static void TestCompactPeptideMasses_internallyModifiedPeptide_NeutralLoss()
        {
            Protein p = new Protein("PET", "accession");

            ModificationMotif.TryGetMotif("E", out ModificationMotif motif);
            Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _target: motif, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1"), _neutralLosses: new Dictionary <DissociationType, List <double> > {
                { MassSpectrometry.DissociationType.HCD, new List <double> {
                      0, ChemicalFormula.ParseFormula("H3O4P1").MonoisotopicMass
                  } }
            });
            DigestionParams digestionParams = new DigestionParams(minPeptideLength: 2);
            var             aPeptideWithSetModifications = p.Digest(digestionParams, new List <Modification> {
                phosphorylation
            }, new List <Modification>()).First();

            var aCompactPeptide = aPeptideWithSetModifications.CompactPeptide(FragmentationTerminus.Both);

            var allFragmentNeutralMasses = aPeptideWithSetModifications.Fragment(DissociationType.HCD, FragmentationTerminus.Both);

            //evaluate N-terminal masses
            var           n = allFragmentNeutralMasses.Where(f => f.TerminusFragment.Terminus == FragmentationTerminus.N).ToList();
            HashSet <int> expectedNTerminalMasses = new HashSet <int> {
                97, 306, 208
            };

            Assert.That(expectedNTerminalMasses.SetEquals(n.Select(v => (int)Math.Round(v.NeutralMass, 1))));

            //evaluate C-terminal masses
            var           c = allFragmentNeutralMasses.Where(f => f.TerminusFragment.Terminus == FragmentationTerminus.C).ToList();
            HashSet <int> expectedCTerminalMasses = new HashSet <int> {
                119, 328, 230
            };

            Assert.That(expectedCTerminalMasses.SetEquals(c.Select(v => (int)Math.Round(v.NeutralMass, 1))));
        }
Beispiel #2
0
 public CommonParameters(
     string taskDescriptor                             = null,
     bool bIons                                        = true,
     bool yIons                                        = true,
     bool zDotIons                                     = false,
     bool cIons                                        = false,
     bool doPrecursorDeconvolution                     = true,
     bool useProvidedPrecursorInfo                     = true,
     double deconvolutionIntensityRatio                = 3,
     int deconvolutionMaxAssumedChargeState            = 12,
     bool reportAllAmbiguity                           = true,
     bool addCompIons                                  = false,
     int totalPartitions                               = 1,
     double scoreCutoff                                = 5,
     int topNpeaks                                     = 200,
     double minRatio                                   = 0.01,
     bool trimMs1Peaks                                 = false,
     bool trimMsMsPeaks                                = true,
     bool useDeltaScore                                = false,
     bool calculateEValue                              = false,
     Tolerance productMassTolerance                    = null,
     Tolerance precursorMassTolerance                  = null,
     Tolerance deconvolutionMassTolerance              = null,
     int maxThreadsToUsePerFile                        = -1,
     DigestionParams digestionParams                   = null,
     IEnumerable <(string, string)> listOfModsVariable = null,
Beispiel #3
0
        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 static void TestCompactPeptideMasses_nTerminalModifiedPeptide_NeutralLoss_DissociationTypes_CID_and_HCD()//there should be no added neutral losses in this case becuase the allowed dissociation type doesn't match the dissociation type used in the experiment
        {
            Protein p = new Protein("PET", "accession");

            ModificationMotif.TryGetMotif("P", out ModificationMotif motif);
            Modification phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _target: motif, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1"), _neutralLosses: new Dictionary <DissociationType, List <double> > {
                { MassSpectrometry.DissociationType.CID, new List <double> {
                      0, ChemicalFormula.ParseFormula("H3O4P1").MonoisotopicMass
                  } }
            });
            DigestionParams digestionParams = new DigestionParams(minPeptideLength: 2);
            var             aPeptideWithSetModifications = p.Digest(digestionParams, new List <Modification> {
                phosphorylation
            }, new List <Modification>()).First();

            var aCompactPeptide = aPeptideWithSetModifications.CompactPeptide(FragmentationTerminus.Both);

            //evaluate N-terminal masses
            var           nTerminalMasses         = aCompactPeptide.TerminalMasses.Where(v => v.Terminus == FragmentationTerminus.N);
            HashSet <int> expectedNTerminalMasses = new HashSet <int> {
                177, 306
            };

            Assert.That(expectedNTerminalMasses.SetEquals(nTerminalMasses.Select(v => (int)Math.Round(v.NeutralMass, 1))));

            //evaluate C-terminal masses
            var           cTerminalMasses         = aCompactPeptide.TerminalMasses.Where(v => v.Terminus == FragmentationTerminus.C);
            HashSet <int> expectedCTerminalMasses = new HashSet <int> {
                101, 230, 407
            };

            Assert.That(expectedCTerminalMasses.SetEquals(cTerminalMasses.Select(v => (int)Math.Round(v.NeutralMass, 1))));
        }
        public void Test_FragmentationModNeutralLoss()
        {
            // Now we'll check the mass of modified peptide with no neutral losses
            ModificationMotif.TryGetMotif("T", out ModificationMotif motif);
            Modification mod = new Modification(_originalId: "phospho", _modificationType: "testModType", _target: motif, _chemicalFormula: ChemicalFormula.ParseFormula("H1 O3 P1"), _neutralLosses: new Dictionary <DissociationType, List <double> > {
                { DissociationType.HCD, new List <double> {
                      ChemicalFormula.ParseFormula("H3 O4 P1").MonoisotopicMass
                  } }
            }, _locationRestriction: "Anywhere.");
            List <Modification> modlist = new List <Modification> {
                mod
            };
            DigestionParams digestionParams = new DigestionParams(
                protease: "trypsin",
                maxMissedCleavages: 0,
                minPeptideLength: 1,
                initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain);

            var prot = new Protein("PEPTIDE", null, oneBasedModifications: new Dictionary <int, List <Modification> > {
                { 4, modlist }
            });
            var ye = prot.Digest(digestionParams, new List <Modification>(), new List <Modification>()).ToList();

            var peptideWithNeutralMassMod = ye.Where(v => v.AllModsOneIsNterminus.Count > 0).First();

            var           myModFragments = peptideWithNeutralMassMod.Fragment(DissociationType.HCD, FragmentationTerminus.Both).ToList();
            HashSet <int> neutralMasses  = new HashSet <int>(myModFragments.Select(m => (int)m.NeutralMass.ToMz(1)).ToList());
            HashSet <int> expectedMasses = new HashSet <int> {
                98, 227, 324, 407, 520, 635, 505, 618, 733,  //b-ions with and without neutral loss
                148, 263, 376, 459, 556, 685, 557, 654, 783, //y-ions with and without neutral loss
                782
            };                                               //molecular ion with neutral loss

            Assert.That(neutralMasses.SetEquals(expectedMasses));
        }
Beispiel #6
0
        public static void TestPeptideWithSetModifications()
        {
            var                 prot                  = new Protein("M", null);
            DigestionParams     digestionParams       = new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, maxModsForPeptides: 3); // if you pass Custom Protease7 this test gets really flakey.
            List <Modification> variableModifications = new List <Modification>();

            ModificationMotif.TryGetMotif("M", out ModificationMotif motif);

            variableModifications.Add(new Modification(_originalId: "ProtNmod", _target: motif, _locationRestriction: "N-terminal.", _chemicalFormula: ChemicalFormula.ParseFormula("H"), _monoisotopicMass: GetElement(1).PrincipalIsotope.AtomicMass));
            variableModifications.Add(new Modification(_originalId: "pepNmod", _target: motif, _locationRestriction: "Peptide N-terminal.", _chemicalFormula: ChemicalFormula.ParseFormula("H"), _monoisotopicMass: GetElement(1).PrincipalIsotope.AtomicMass));
            variableModifications.Add(new Modification(_originalId: "resMod", _target: motif, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H"), _monoisotopicMass: GetElement(1).PrincipalIsotope.AtomicMass));
            variableModifications.Add(new Modification(_originalId: "PepCmod", _target: motif, _locationRestriction: "Peptide C-terminal.", _chemicalFormula: ChemicalFormula.ParseFormula("H"), _monoisotopicMass: GetElement(1).PrincipalIsotope.AtomicMass));
            variableModifications.Add(new Modification(_originalId: "ProtCmod", _target: motif, _locationRestriction: "C-terminal.", _chemicalFormula: ChemicalFormula.ParseFormula("H"), _monoisotopicMass: GetElement(1).PrincipalIsotope.AtomicMass));

            var ye = prot.Digest(digestionParams, new List <Modification>(), variableModifications).ToList();

            Assert.AreEqual(3 * 2 * 3, ye.Count);
            Assert.AreEqual("[H]M[H][H]", ye.Last().SequenceWithChemicalFormulas);

            double m1 = 5 * GetElement("H").PrincipalIsotope.AtomicMass + Residue.ResidueMonoisotopicMass['M'] + GetElement("O").PrincipalIsotope.AtomicMass;

            m1 = Math.Round(m1, 9, MidpointRounding.AwayFromZero);

            double m2 = ye.Last().MonoisotopicMass;
            double m3 = m1 - m2;

            Assert.IsTrue(m3 < 1e-9);
        }
Beispiel #7
0
        /// <summary>
        /// Gets peptides for digestion of a protein
        /// </summary>
        public IEnumerable <PeptideWithSetModifications> Digest(DigestionParams digestionParams, IEnumerable <Modification> allKnownFixedModifications,
                                                                List <Modification> variableModifications)
        {
            ProteinDigestion digestion = new ProteinDigestion(digestionParams, allKnownFixedModifications, variableModifications);

            return(digestionParams.SemiProteaseDigestion ? digestion.SemiSpecificDigestion(this) : digestion.Digestion(this));
        }
        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 <Modification>(), new List <Modification>()).First();

            var frags = new List <Product>();

            thePep.Fragment(DissociationType.HCD, FragmentationTerminus.Both, frags);
            var massArray = frags.Select(p => p.NeutralMass).ToArray();

            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, new CommonParameters()) };
            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 <Modification>(), new List <Modification>(), null, null, null, 1, DecoyType.Reverse,
                                                 CommonParameters, null, 30000, false, new List <FileInfo>(), TargetContaminantAmbiguity.RemoveContaminant, new List <string>());
            var indexResults = (IndexingResults)indexEngine.Run();
            var cse          = new ModernSearchEngine(globalPsms, arrayOfSortedMS2Scans, indexResults.PeptideIndex, indexResults.FragmentIndex, 0, CommonParameters, null, new OpenSearchMode(), 0, new List <string>());

            cse.Run();
            Assert.Less(globalPsms[0].Score, 2);
            Assert.Greater(globalPsms[0].Score, 1);
        }
Beispiel #9
0
        public static void TestPeptideWithFixedModifications()
        {
            var prot     = new Protein("M", null);
            var protease = new Protease("Custom Protease", new List <string> {
                "K"
            }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null);
            List <ModificationWithMass> fixedMods = new List <ModificationWithMass>();

            ModificationMotif.TryGetMotif("M", out ModificationMotif motif);
            fixedMods.Add(new ModificationWithMassAndCf("ProtNmod", null, motif, TerminusLocalization.NProt, Chemistry.ChemicalFormula.ParseFormula("H"), GetElement(1).PrincipalIsotope.AtomicMass));
            fixedMods.Add(new ModificationWithMassAndCf("PepNmod", null, motif, TerminusLocalization.NPep, Chemistry.ChemicalFormula.ParseFormula("H"), GetElement(1).PrincipalIsotope.AtomicMass));
            fixedMods.Add(new ModificationWithMassAndCf("resMod", null, motif, TerminusLocalization.Any, Chemistry.ChemicalFormula.ParseFormula("H"), GetElement(1).PrincipalIsotope.AtomicMass));
            fixedMods.Add(new ModificationWithMassAndCf("PepCmod", null, motif, TerminusLocalization.PepC, Chemistry.ChemicalFormula.ParseFormula("H"), GetElement(1).PrincipalIsotope.AtomicMass));
            fixedMods.Add(new ModificationWithMassAndCf("ProtCmod", null, motif, TerminusLocalization.ProtC, Chemistry.ChemicalFormula.ParseFormula("H"), GetElement(1).PrincipalIsotope.AtomicMass));

            DigestionParams digestionParams = new DigestionParams
            {
                MinPeptideLength = 1,
            };
            var ok = prot.Digest(digestionParams, fixedMods, new List <ModificationWithMass>()).ToList();

            Assert.AreEqual(1, ok.Count);

            Assert.AreEqual("[:PepNmod]M[:resMod][:ProtCmod]", ok.Last().Sequence);
            Assert.AreEqual("[H]M[H][H]", ok.Last().SequenceWithChemicalFormulas);
            Assert.AreEqual(5 * GetElement("H").PrincipalIsotope.AtomicMass + Residue.ResidueMonoisotopicMass['M'] + GetElement("O").PrincipalIsotope.AtomicMass, ok.Last().MonoisotopicMass, 1e-9);
        }
        public static void TestAllNaN()
        {
            IDictionary <int, List <Modification> > mods = new Dictionary <int, List <Modification> >();
            var             prot            = new Protein("XMMM", null, null, null, mods);
            DigestionParams digestionParams = new DigestionParams(minPeptideLength: 1);
            var             thePep          = prot.Digest(digestionParams, new List <Modification>(), new List <Modification>()).First();

            var frags = new List <Product>();

            thePep.Fragment(DissociationType.HCD, FragmentationTerminus.Both, frags);
            var massArray = frags.Select(p => p.NeutralMass).ToArray();

            Array.Sort(massArray);
            double[]   intensities  = new double[] { 1, 1, 1, 1 };
            double[]   mz           = new double[] { 1, 2, 3, 4 };
            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, 0, 0, null, new CommonParameters()) };
            CommonParameters          CommonParameters      = new CommonParameters(productMassTolerance: new PpmTolerance(5), scoreCutoff: 1, digestionParams: new DigestionParams(maxMissedCleavages: 0, minPeptideLength: 1, maxModificationIsoforms: int.MaxValue, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain));

            ClassicSearchEngine cse = new ClassicSearchEngine(globalPsms, arrayOfSortedMS2Scans, new List <Modification>(), new List <Modification>(), null, null, null, new List <Protein> {
                prot
            }, new OpenSearchMode(), CommonParameters, null, new List <string>());

            cse.Run();
            Assert.IsNull(globalPsms[0]);
        }
Beispiel #11
0
        public static void TestDigestIndices()
        {
            ModificationMotif.TryGetMotif("N", out ModificationMotif motifN);
            ModificationMotif.TryGetMotif("R", out ModificationMotif motifR);
            Modification modN = new Modification("myMod", null, "myModType", null, motifN, "Anywhere.", null, 10, null, null, null, null, null, null);
            Modification modR = new Modification("myMod", null, "myModType", null, motifR, "Anywhere.", null, 10, null, null, null, null, null, null);
            IDictionary <int, List <Modification> > modDict = new Dictionary <int, List <Modification> >
            {
                { 2, new List <Modification> {
                      modN
                  } },
                { 8, new List <Modification> {
                      modR
                  } }
            };
            var prot = new Protein("MNNNNKRRRRR", null, null, null, modDict, isDecoy: true);

            DigestionParams digestionParams = new DigestionParams(minPeptideLength: 5, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain);

            var digestedList = prot.Digest(digestionParams, new List <Modification>(), new List <Modification>()).ToList();
            var ok1          = digestedList[1];
            var ok2          = digestedList[3];

            Assert.AreEqual(1, ok1.NumMods);
            Assert.IsTrue(ok1.AllModsOneIsNterminus.ContainsKey(3));
            Assert.AreEqual(1, ok2.NumMods);
            Assert.IsTrue(ok2.AllModsOneIsNterminus.ContainsKey(3));
        }
Beispiel #12
0
        public static void testingTMTonBigScan()
        {
            Dictionary <string, MsDataFile> MyMsDataFiles = new Dictionary <string, MsDataFile>();
            var             origDataFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\tmt18test.mzML");
            FilteringParams filter       = new FilteringParams();

            MyMsDataFiles[origDataFile] = Mzml.LoadAllStaticData(origDataFile, filter, 1);
            var scans2       = MyMsDataFiles[origDataFile].GetAllScansList();
            var trimmedScans = scans2.Where(m => m.MsnOrder == 3).ToList();

            Protein             p = new Protein("LAALNPESNTAGLDIFAK", "accession");
            List <Modification> fixedModifications = new List <Modification>();

            fixedModifications.AddRange(GlobalVariables.AllModsKnown);
            List <Modification> tmt18Mods       = fixedModifications.Where(m => m.ModificationType == "Multiplex Label" && m.IdWithMotif.Contains("TMT18")).ToList();
            DigestionParams     digestionParams = new DigestionParams(minPeptideLength: 1);
            var aPeptideWithSetModifications    = p.Digest(digestionParams, tmt18Mods, new List <Modification>()).First();
            var theseTheoreticalFragments       = new List <Product>();

            aPeptideWithSetModifications.Fragment(DissociationType.HCD, FragmentationTerminus.Both, theseTheoreticalFragments);
            theseTheoreticalFragments = theseTheoreticalFragments.Where(n => n.ProductType == ProductType.D).ToList();
            double ppmTolerance = 20;
            int    roundTo      = 5;

            List <double> diagnosticIons = new List <double>();

            for (int k = 0; k < theseTheoreticalFragments.Count(); k++)
            {
                diagnosticIons.Add(Math.Round(theseTheoreticalFragments[k].NeutralMass, roundTo));
            }

            int i = 460;

            do
            {
                if (i == trimmedScans.Count())
                {
                    break;
                }
                var massList = trimmedScans[i].MassSpectrum.XArray.ToList();
                for (int j = 0; j < massList.Count(); j++)
                {
                    massList[j] = Math.Round(massList[j], roundTo);
                }

                for (int l = 0; l < massList.Count(); l++)
                {
                    for (int m = 0; m < diagnosticIons.Count(); m++)
                    {
                        double toleranceValue = ppmTolerance / Math.Pow(10, 6) * massList[l];
                        if ((massList[l] < diagnosticIons[m] + toleranceValue) & (massList[l] > diagnosticIons[m] - toleranceValue))
                        {
                            diagnosticIons.Remove(diagnosticIons[m]);
                        }
                    }
                }
                i++;
            } while (diagnosticIons.Count() > 0);
            Assert.AreEqual(0, diagnosticIons.Count());
        }
Beispiel #13
0
        public static void TestCompactPeptideMasses_cTerminalModifiedPeptide()
        {
            Protein p = new Protein("PET", "accession");

            ModificationMotif.TryGetMotif("T", out ModificationMotif motif);
            Modification    phosphorylation = new Modification(_originalId: "phospho", _modificationType: "CommonBiological", _target: motif, _locationRestriction: "Anywhere.", _chemicalFormula: ChemicalFormula.ParseFormula("H1O3P1"));
            DigestionParams digestionParams = new DigestionParams(minPeptideLength: 2);
            var             aPeptideWithSetModifications = p.Digest(digestionParams, new List <Modification> {
                phosphorylation
            }, new List <Modification>()).First();

            var aCompactPeptide = aPeptideWithSetModifications.CompactPeptide(FragmentationTerminus.Both);

            //evaluate N-terminal masses
            var           nTerminalMasses         = aCompactPeptide.TerminalMasses.Where(v => v.Terminus == FragmentationTerminus.N);
            HashSet <int> expectedNTerminalMasses = new HashSet <int> {
                97, 226
            };

            Assert.That(expectedNTerminalMasses.SetEquals(nTerminalMasses.Select(v => (int)Math.Round(v.NeutralMass, 1))));

            //evaluate C-terminal masses
            var           cTerminalMasses         = aCompactPeptide.TerminalMasses.Where(v => v.Terminus == FragmentationTerminus.C);
            HashSet <int> expectedCTerminalMasses = new HashSet <int> {
                181, 310, 407
            };

            Assert.That(expectedCTerminalMasses.SetEquals(cTerminalMasses.Select(v => (int)Math.Round(v.NeutralMass, 1))));
        }
Beispiel #14
0
        public static void Test_ProteinDigest()
        {
            DigestionParams d = new DigestionParams(
                maxMissedCleavages: 0,
                minPeptideLength: 5,
                initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain);

            ModificationMotif.TryGetMotif("D", out ModificationMotif motif);
            Modification mod = new Modification(_originalId: "mod1", _modificationType: "mt", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 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(d, new List <Modification>(), new List <Modification>()).First();
            var pep2 = prot1.Digest(d, new List <Modification>(), new List <Modification>()).Last();

            Assert.AreEqual("MEDEEK", pep1.FullSequence);
            Assert.AreEqual("MED[mt:mod1 on D]EEK", pep2.FullSequence);
        }
Beispiel #15
0
        public static void TestFragments()
        {
            // creates some test proteins, digest, and fragment
            string[] sequences = { "GLSDGEWQQVLNVWGK" }; // just one peptide

            var protease = new Protease("tryp", new List <string> {
                "K"
            }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null);
            var peptides = new HashSet <PeptideWithSetModifications>();

            var p = new List <Protein>();

            for (int i = 0; i < sequences.Length; i++)
            {
                p.Add(new Protein(sequences[i], (i + 1).ToString()));
            }

            DigestionParams digestionParams = new DigestionParams();

            foreach (var protein in p)
            {
                foreach (var peptide in protein.Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()))
                {
                    peptides.Add(peptide);
                }
            }

            var CfragmentMasses    = new Dictionary <PeptideWithSetModifications, double[]>();
            var ZdotfragmentMasses = new Dictionary <PeptideWithSetModifications, double[]>();
            var BfragmentMasses    = new Dictionary <PeptideWithSetModifications, double[]>();
            var YfragmentMasses    = new Dictionary <PeptideWithSetModifications, double[]>();
            var BYfragmentMasses   = new Dictionary <PeptideWithSetModifications, double[]>();

            foreach (var peptide in peptides)
            {
                CfragmentMasses.Add(peptide, peptide.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                    ProductType.C
                }));
                ZdotfragmentMasses.Add(peptide, peptide.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                    ProductType.Zdot
                }));
                BfragmentMasses.Add(peptide, peptide.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                    ProductType.B
                }));
                YfragmentMasses.Add(peptide, peptide.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                    ProductType.Y
                }));
                BYfragmentMasses.Add(peptide, peptide.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                    ProductType.B, ProductType.Y
                }));
            }
            Assert.That(BfragmentMasses.TryGetValue(peptides.First(), out double[] testB));

            Assert.That(YfragmentMasses.TryGetValue(peptides.First(), out double[] testY));

            Assert.That(CfragmentMasses.TryGetValue(peptides.First(), out double[] testC));

            Assert.That(ZdotfragmentMasses.TryGetValue(peptides.First(), out double[] testZ));
        }
        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());
        }
        public static void TestNonSpecific()
        {
            Protease p    = ProteaseDictionary.Dictionary["non-specific"];
            Protein  prot = new Protein("MABCDEFGH", null);

            DigestionParams digestionParams = new DigestionParams(protease: p.Name, maxMissedCleavages: 8, minPeptideLength: 1, maxPeptideLength: 9, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain);

            Assert.AreEqual(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8, prot.Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).Count());
        }
Beispiel #18
0
        private readonly string ProteinAccession; // used to get protein object after deserialization

        public InSilicoPeptide(Protein protein, DigestionParams digestionParams, int oneBasedStartResidueInProtein, int oneBasedEndResidueInProtein, CleavageSpecificity cleavageSpecificity,
                               string peptideDescription, int missedCleavages, Dictionary <int, Modification> allModsOneIsNterminus, int numFixedMods, string baseSeqeunce, bool isPeptideUnique) : base(protein, digestionParams, oneBasedStartResidueInProtein, oneBasedEndResidueInProtein,
                                                                                                                                                                                                         cleavageSpecificity, peptideDescription, missedCleavages, allModsOneIsNterminus, numFixedMods, baseSeqeunce)
        {
            _allModsOneIsNterminus = allModsOneIsNterminus;
            _digestionParams       = digestionParams;
            ProteinAccession       = protein.Accession;
            UniquePeptide          = isPeptideUnique;
        }
        public void Test_FragmentationTwoModNeutralLossTwoFragTypes()
        {
            // Now we'll check the mass of modified peptide with no neutral losses
            ModificationMotif.TryGetMotif("T", out ModificationMotif motif);

            Dictionary <DissociationType, List <double> > myNeutralLosses = new Dictionary <DissociationType, List <double> >()
            {
                { DissociationType.HCD, new List <double> {
                      ChemicalFormula.ParseFormula("H3 O4 P1").MonoisotopicMass
                  } },
                { DissociationType.ETD, new List <double>()
                  {
                      ChemicalFormula.ParseFormula("H3 N1").MonoisotopicMass
                  } }                                                                                                   // this makes no sense in real life, it's just for a unit test
            };

            Modification        mod     = new Modification(_originalId: "phospho", _modificationType: "testModType", _target: motif, _chemicalFormula: ChemicalFormula.ParseFormula("H1 O3 P1"), _neutralLosses: myNeutralLosses, _locationRestriction: "Anywhere.");
            List <Modification> modlist = new List <Modification> {
                mod
            };
            DigestionParams digestionParams = new DigestionParams(
                protease: "trypsin",
                maxMissedCleavages: 0,
                minPeptideLength: 1,
                initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain);

            var prot = new Protein("PEPTIDE", null, oneBasedModifications: new Dictionary <int, List <Modification> > {
                { 4, modlist }
            });
            var ye = prot.Digest(digestionParams, new List <Modification>(), new List <Modification>()).ToList();

            var peptideWithNeutralMassMod = ye.Where(v => v.AllModsOneIsNterminus.Count == 1).First();

            var myModFragmentsHCD = peptideWithNeutralMassMod.Fragment(DissociationType.HCD, FragmentationTerminus.Both);

            var neutralMassesHCD  = myModFragmentsHCD.Select(m => (int)m.NeutralMass.ToMz(1));
            var expectedMassesHCD = new HashSet <int> {
                98, 227, 324, 407, 520, 635, 505, 618, 733,  // b-ions with and without neutral loss
                148, 263, 376, 459, 556, 685, 557, 654, 783, //y-ions with and without neutral loss
                782
            };                                               // molecular ion with neutral loss

            Assert.That(expectedMassesHCD.SetEquals(neutralMassesHCD));

            //Now try the other half
            var myModFragmentsETD = peptideWithNeutralMassMod.Fragment(DissociationType.ETD, FragmentationTerminus.Both);

            var neutralMassesETD  = myModFragmentsETD.Select(m => (int)m.NeutralMass.ToMz(1));
            var expectedMassesETD = new HashSet <int> {
                115, 244, 341, 505, 618, 733, 522, 635, 750, // c-ions and c-17 ions
                148, 263, 376, 540, 637, 766, 557, 654, 783, // y and y-17 ions
                133, 248, 361, 525, 622, 751, 542, 639, 768, // z+1 and z+1-17 ions
                863
            };                                               //Molecular ions minus ammonia

            Assert.That(expectedMassesHCD.SetEquals(neutralMassesHCD));
        }
Beispiel #20
0
        public static void TestLocalization()
        {
            var protease = new Protease("Custom Protease", new List <string> {
                "K"
            }, new List <string>(), TerminusType.C, CleavageSpecificity.Full, null, null, null);

            Protein         parentProteinForMatch = new Protein("MEK", null);
            DigestionParams digestionParams       = new DigestionParams
            {
                MinPeptideLength = 1,
            };

            ModificationMotif.TryGetMotif("E", out ModificationMotif motif);
            List <ModificationWithMass> variableModifications = new List <ModificationWithMass> {
                new ModificationWithMass("21", null, motif, TerminusLocalization.Any, 21.981943)
            };

            List <PeptideWithSetModifications> allPeptidesWithSetModifications = parentProteinForMatch.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList();

            Assert.AreEqual(4, allPeptidesWithSetModifications.Count());
            PeptideWithSetModifications ps = allPeptidesWithSetModifications.First();

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

            PeptideWithSetModifications pepWithSetModsForSpectrum            = allPeptidesWithSetModifications[1];
            IMsDataFile <IMsDataScan <IMzSpectrum <IMzPeak> > > myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> {
                pepWithSetModsForSpectrum
            });
            Tolerance fragmentTolerance = new AbsoluteTolerance(0.01);

            Ms2ScanWithSpecificMass scan   = new Ms2ScanWithSpecificMass(myMsDataFile.Last() as IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> >, pepWithSetModsForSpectrum.MonoisotopicMass.ToMz(1), 1, null);
            PeptideSpectralMatch    newPsm = new PeptideSpectralMatch(ps.CompactPeptide(TerminusType.None), 0, 0, 2, scan);

            Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>();
            Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >
            {
                { ps.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> {
                      ps
                  } }
            };

            newPsm.MatchToProteinLinkedPeptides(matching);

            LocalizationEngine f = new LocalizationEngine(new List <PeptideSpectralMatch> {
                newPsm
            }, lp, myMsDataFile, fragmentTolerance, new List <string>(), false);

            f.Run();

            // Was single peak!!!
            Assert.AreEqual(0, newPsm.MatchedIonDictOnlyMatches[ProductType.BnoB1ions].Count(b => b > 0));
            Assert.AreEqual(1, newPsm.MatchedIonDictOnlyMatches[ProductType.Y].Count(b => b > 0));
            // If localizing, three match!!!
            Assert.IsTrue(newPsm.LocalizedScores[1] > 3 && newPsm.LocalizedScores[1] < 4);
        }
Beispiel #21
0
        public static void TestPsmHeader()
        {
            DigestionParams             digestionParams = new DigestionParams();
            PeptideWithSetModifications pepWithSetMods  = new Protein(
                "MQQQQQQQ",
                "accession1",
                "org",
                new List <Tuple <string, string> > {
                new Tuple <string, string>("geneNameType", "geneName")
            },
                new Dictionary <int, List <Modification> > {
                { 2, new List <Modification> {
                      new Modification("mod", "mod")
                  } }
            },
                name: "name",
                full_name: "fullName",
                sequenceVariations: new List <SequenceVariation> {
                new SequenceVariation(2, "P", "Q", "changed this sequence")
            })
                                                          .Digest(digestionParams, new List <ModificationWithMass>(), new List <ModificationWithMass>()).First();
            MsDataFile myMsDataFile      = new TestDataFile(pepWithSetMods, "quadratic");
            MsDataScan scann             = myMsDataFile.GetOneBasedScan(2);
            Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(scann, 4, 1, null);
            PeptideSpectralMatch    psm  = new PeptideSpectralMatch(pepWithSetMods.CompactPeptide(TerminusType.None), 1, 2, 3, scan, digestionParams);

            var t            = psm.ToString();
            var tabsepheader = PeptideSpectralMatch.GetTabSeparatedHeader();

            Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t'));

            Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >
            {
                { pepWithSetMods.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> {
                      pepWithSetMods
                  } }
            };

            psm.MatchToProteinLinkedPeptides(matching);

            Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t'));

            Tolerance          fragmentTolerance = new PpmTolerance(10);
            List <ProductType> lp = new List <ProductType> {
                ProductType.B
            };

            new LocalizationEngine(new List <PeptideSpectralMatch> {
                psm
            }, lp, myMsDataFile, new CommonParameters(productMassTolerance: fragmentTolerance), new List <string>()).Run();

            Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t'));

            psm.SetFdrValues(6, 6, 6, 6, 6, 6, 0, 0, 0, true);

            Assert.AreEqual(psm.ToString().Count(f => f == '\t'), PeptideSpectralMatch.GetTabSeparatedHeader().Count(f => f == '\t'));
        }
Beispiel #22
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);
        }
Beispiel #23
0
        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");
        }
Beispiel #24
0
        public static void XlTestXlPosCal()
        {
            var prot = new Protein("MNNNKQQQQ", null);
            List <DigestionMotif> motifs = new List <DigestionMotif> {
                new DigestionMotif("K", null, 1, null)
            };
            Protease protease = new Protease("New Custom Protease", CleavageSpecificity.Full, null, null, motifs);

            ProteaseDictionary.Dictionary.Add(protease.Name, protease);
            DigestionParams     digestionParams       = new DigestionParams(protease: protease.Name, minPeptideLength: 1, initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain);
            List <Modification> variableModifications = new List <Modification>();

            var ye = prot.Digest(digestionParams, new List <Modification>(), variableModifications).ToList();

            var pep = ye[0];

            Assert.AreEqual(pep.BaseSequence, "MNNNK");
            Crosslinker crosslinker = GlobalVariables.Crosslinkers.Where(p => p.CrosslinkerName == "DSS").First();

            Assert.AreEqual(crosslinker.CrosslinkerModSites, "K");
            Assert.AreEqual(Residue.GetResidue(crosslinker.CrosslinkerModSites).MonoisotopicMass, 128.09496301518999, 1e-9);
            var n = pep.Fragment(DissociationType.HCD, FragmentationTerminus.N);
            var c = pep.Fragment(DissociationType.HCD, FragmentationTerminus.C);

            Assert.AreEqual(n.Count(), 4);
            Assert.AreEqual(c.Count(), 4);
            Assert.AreEqual(c.First().NeutralMass, 146.10552769899999, 1e-6);
            var x = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), pep).ToArray();

            Assert.AreEqual(x[0], 5);

            var pep2 = ye[2];

            Assert.AreEqual("MNNNKQQQQ", pep2.BaseSequence);
            var n2 = pep2.Fragment(DissociationType.HCD, FragmentationTerminus.N);
            var c2 = pep2.Fragment(DissociationType.HCD, FragmentationTerminus.C);

            Assert.AreEqual(n2.Count(), 8);
            Assert.AreEqual(c2.Count(), 8);
            var x2 = CrosslinkSpectralMatch.GetPossibleCrosslinkerModSites(crosslinker.CrosslinkerModSites.ToCharArray(), pep2).ToArray();

            Assert.AreEqual(x2[0], 5);

            //Test crosslinker with multiple types of mod
            var protSTC = new Protein("GASTACK", null);
            var peps    = protSTC.Digest(digestionParams, new List <Modification>(), variableModifications).ToList();
            var pepSTC  = peps[0];

            Assert.AreEqual(pepSTC.BaseSequence, "GASTACK");
            Crosslinker crosslinker2           = new Crosslinker("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");
        }
Beispiel #25
0
        public static void TestNoCleavage()
        {
            List <Modification> fixedModifications = new List <Modification>();
            var prot = new Protein("MNNNKQQQQ", null, null, null, new Dictionary <int, List <Modification> >(), new List <ProteolysisProduct> {
                new ProteolysisProduct(5, 6, "lala")
            });
            DigestionParams digestionParams = new DigestionParams(minPeptideLength: 5);
            var             ye = prot.Digest(digestionParams, fixedModifications, new List <Modification>()).ToList();

            Assert.AreEqual(3, ye.Count);
        }
Beispiel #26
0
        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 };
            MzmlMzSpectrum massSpectrum = new MzmlMzSpectrum(mz, intensities, false);
            IMsDataScanWithPrecursor <IMzSpectrum <IMzPeak> > scan = new MzmlScanWithPrecursor(1, massSpectrum, 1, true, Polarity.Positive, 1, new MzRange(300, 2000), "", MZAnalyzerType.Unknown, massSpectrum.SumOfAllY, 0, null, null, 0, null, DissociationType.Unknown, 1, null, null, "scan=1");

            PeptideSpectralMatch[]    globalPsms            = new PeptideSpectralMatch[1];
            Ms2ScanWithSpecificMass[] arrayOfSortedMS2Scans = { new Ms2ScanWithSpecificMass(scan, 600, 1, null) };
            CommonParameters          CommonParameters      = new CommonParameters
            {
                ProductMassTolerance = new PpmTolerance(5),
                DigestionParams      = new DigestionParams
                {
                    MaxMissedCleavages          = 0,
                    MinPeptideLength            = null,
                    MaxModificationIsoforms     = int.MaxValue,
                    InitiatorMethionineBehavior = InitiatorMethionineBehavior.Retain,
                },
                ConserveMemory = false,
                ScoreCutoff    = 1
            };
            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 <IDigestionParams> {
                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, false, new OpenSearchMode(), 0, new List <string>());

            cse.Run();
            Assert.Less(globalPsms[0].Score, 2);
            Assert.Greater(globalPsms[0].Score, 1);
        }
        public static void TestLocalization()
        {
            Protein         parentProteinForMatch = new Protein("MEK", null);
            DigestionParams digestionParams       = new DigestionParams(minPeptideLength: 1);

            ModificationMotif.TryGetMotif("E", out ModificationMotif motif);
            List <ModificationWithMass> variableModifications = new List <ModificationWithMass> {
                new ModificationWithMass("21", null, motif, TerminusLocalization.Any, 21.981943)
            };

            List <PeptideWithSetModifications> allPeptidesWithSetModifications = parentProteinForMatch.Digest(digestionParams, new List <ModificationWithMass>(), variableModifications).ToList();

            Assert.AreEqual(4, allPeptidesWithSetModifications.Count());
            PeptideWithSetModifications ps = allPeptidesWithSetModifications.First();

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

            PeptideWithSetModifications pepWithSetModsForSpectrum = allPeptidesWithSetModifications[1];
            MsDataFile myMsDataFile = new TestDataFile(new List <PeptideWithSetModifications> {
                pepWithSetModsForSpectrum
            });
            Tolerance fragmentTolerance = new AbsoluteTolerance(0.01);

            Ms2ScanWithSpecificMass scan   = new Ms2ScanWithSpecificMass(myMsDataFile.GetAllScansList().Last(), pepWithSetModsForSpectrum.MonoisotopicMass.ToMz(1), 1, null);
            PeptideSpectralMatch    newPsm = new PeptideSpectralMatch(ps.CompactPeptide(TerminusType.None), 0, 0, 2, scan, digestionParams);

            Dictionary <ModificationWithMass, ushort> modsDictionary = new Dictionary <ModificationWithMass, ushort>();
            Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> > matching = new Dictionary <CompactPeptideBase, HashSet <PeptideWithSetModifications> >
            {
                { ps.CompactPeptide(TerminusType.None), new HashSet <PeptideWithSetModifications> {
                      ps
                  } }
            };

            newPsm.MatchToProteinLinkedPeptides(matching);

            CommonParameters   commonParameters = new CommonParameters(productMassTolerance: fragmentTolerance);
            LocalizationEngine f = new LocalizationEngine(new List <PeptideSpectralMatch> {
                newPsm
            }, lp, myMsDataFile, commonParameters, new List <string>());

            f.Run();

            // Was single peak!!!
            Assert.AreEqual(0, newPsm.MatchedIonMassToChargeRatioDict[ProductType.BnoB1ions].Count(b => b > 0));
            Assert.AreEqual(1, newPsm.MatchedIonMassToChargeRatioDict[ProductType.Y].Count(b => b > 0));
            Assert.AreEqual(0, newPsm.MatchedIonIntensitiesDict[ProductType.BnoB1ions].Count(b => b > 0));
            Assert.AreEqual(1, newPsm.MatchedIonIntensitiesDict[ProductType.Y].Count(b => b > 0));
            // If localizing, three match!!!
            Assert.IsTrue(newPsm.LocalizedScores[1] > 3 && newPsm.LocalizedScores[1] < 4);
        }
        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);
        }
Beispiel #29
0
        public static void TestNoCleavage()
        {
            List <ModificationWithMass> fixedModifications = new List <ModificationWithMass>();
            var prot = new Protein("MNNNKQQQQ", null, null, null, new Dictionary <int, List <Modification> >(), new List <ProteolysisProduct> {
                new ProteolysisProduct(5, 6, "lala")
            });
            var protease = new Protease("Custom Protease", null, null, TerminusType.None, CleavageSpecificity.None, null, null, null);

            DigestionParams digestionParams = new DigestionParams();
            var             ye = prot.Digest(digestionParams, fixedModifications, new List <ModificationWithMass>()).ToList();

            Assert.AreEqual(3, ye.Count);
        }
Beispiel #30
0
        public static void TestNonSpecificProtease()
        {
            var             empty             = new List <Modification>();
            DigestionParams myDigestionParams = new DigestionParams("non-specific", minPeptideLength: 1, maxMissedCleavages: 0);

            // create a protein
            Protein myProtein = new Protein("PRO", "myAccession");

            // digest it into peptides
            var myPeptides = myProtein.Digest(myDigestionParams, empty, empty).ToList();

            Assert.AreEqual(myPeptides.Count(), 3);
        }