コード例 #1
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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public static void TestCompactPeptideSerialization()
        {
            // purpose of this test is to serialize/deserialize a CompactPeptide and make sure the deserialized peptide
            // has the same properties as before it was serialized. This peptide is unmodified
            string sequence = "PEPTIDE";
            PeptideWithSetModifications p = new PeptideWithSetModifications(sequence, new Dictionary <string, Modification>(), 0, null, null, 0, 7, 0, null);
            CompactPeptide cp             = p.CompactPeptide(FragmentationTerminus.Both);
            CompactPeptide deserializedCp = null;

            string dir = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, "TestCompactPeptideSerialization");

            System.IO.Directory.CreateDirectory(dir);
            string path = System.IO.Path.Combine(dir, "myCompactPeptideIndex.ind");

            var messageTypes = typeof(CompactPeptide);
            var ser          = new NetSerializer.Serializer(new List <Type> {
                messageTypes
            });

            using (var file = System.IO.File.Create(path))
            {
                ser.Serialize(file, cp);
            }

            using (var file = System.IO.File.OpenRead(path))
            {
                deserializedCp = (CompactPeptide)ser.Deserialize(file);
            }

            Assert.That(cp.Equals(deserializedCp));
        }
コード例 #4
0
        public TestDataFile(PeptideWithSetModifications pepWithSetMods, int charge, double intensity, double rt) : base(2, new SourceFile(null, null, null, null, null))
        {
            var mz1           = new double[] { pepWithSetMods.MonoisotopicMass.ToMz(charge), (pepWithSetMods.MonoisotopicMass + 1.003).ToMz(charge), (pepWithSetMods.MonoisotopicMass + 2.005).ToMz(charge) };
            var intensities1  = new double[] { intensity, intensity * 10, intensity / 10 };
            var MassSpectrum1 = new MzSpectrum(mz1, intensities1, false);

            var ScansHere = new List <MsDataScan> {
                new MsDataScan(MassSpectrum1, 1, 1, true, Polarity.Positive, rt, new MzLibUtil.MzRange(0, 10000), "ff", MZAnalyzerType.Unknown, 1000, 1, null, "scan=1")
            };

            List <double> mz2          = new List <double>();
            List <double> intensities2 = new List <double>();

            foreach (var aok in pepWithSetMods.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                ProductType.B, ProductType.Y
            }))
            {
                mz2.Add(aok.ToMz(1));
                mz2.Add((aok + 1.003).ToMz(1));
                intensities2.Add(intensity);
                intensities2.Add(intensity);
            }
            var MassSpectrum2 = new MzSpectrum(mz2.OrderBy(b => b).ToArray(), intensities2.ToArray(), false);
            var scan2         = new MsDataScan(MassSpectrum2, 2, 2, true, Polarity.Positive, rt + 0.01, new MzLibUtil.MzRange(0, 10000), "df", MZAnalyzerType.Orbitrap, 234734, 1, null, "scan=2", pepWithSetMods.MonoisotopicMass.ToMz(2), 2, 1, pepWithSetMods.MonoisotopicMass.ToMz(2), 2, DissociationType.HCD, 1, pepWithSetMods.MonoisotopicMass.ToMz(2));

            scan2.ComputeSelectedPeakIntensity(MassSpectrum1);
            scan2.ComputeMonoisotopicPeakIntensity(MassSpectrum1);
            ScansHere.Add(scan2);
            Scans = ScansHere.ToArray();
        }
コード例 #5
0
        public TestDataFile(PeptideWithSetModifications pepWithSetMods, string v) : base(2, new SourceFile(null, null, null, null, null))
        {
            if (v.Equals("quadratic"))
            {
                // Add three ms1 peaks with charge 2, exact
                var MassSpectrum1 = new MzSpectrum(new double[] { pepWithSetMods.MonoisotopicMass.ToMz(2), (pepWithSetMods.MonoisotopicMass + 1.003).ToMz(2), (pepWithSetMods.MonoisotopicMass + 2.005).ToMz(2) }, new double[] { 1, 1, 1 }, false);

                List <double> mz2          = new List <double>();
                List <double> intensities2 = new List <double>();
                foreach (var aok in pepWithSetMods.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                    ProductType.B, ProductType.Y
                }))
                {
                    var t1 = aok.ToMz(1);
                    var c  = 0.0000001;
                    mz2.Add(t1 + c * Math.Pow(t1, 2));
                    var t2 = (aok + 1.003).ToMz(1);
                    mz2.Add(t2 + c * Math.Pow(t2, 2));
                    intensities2.Add(1);
                    intensities2.Add(1);
                }
                var MassSpectrum2 = new MzSpectrum(mz2.OrderBy(b => b).ToArray(), intensities2.ToArray(), false);

                var scan2 = new MsDataScan(MassSpectrum2, 2, 2, true, Polarity.Positive, 2, new MzLibUtil.MzRange(0, 10000), "df", MZAnalyzerType.Orbitrap, 234734, 1, null, "scan=2", pepWithSetMods.MonoisotopicMass.ToMz(2), 2, 1, pepWithSetMods.MonoisotopicMass.ToMz(2), 2, DissociationType.HCD, 1, pepWithSetMods.MonoisotopicMass.ToMz(2));
                scan2.ComputeSelectedPeakIntensity(MassSpectrum1);
                scan2.ComputeMonoisotopicPeakIntensity(MassSpectrum1);
                var ScansHere = new List <MsDataScan>  {
                    new MsDataScan(MassSpectrum1, 1, 1, true, Polarity.Positive, 1, new MzLibUtil.MzRange(0, 10000), "ff", MZAnalyzerType.Unknown, 1000, 1, null, "scan=1"),
                    scan2
                };
                Scans = ScansHere.ToArray();
            }
        }
コード例 #6
0
        public TestDataFile(PeptideWithSetModifications pepWithSetMods) : base(2, new SourceFile(@"no nativeID format", "mzML format", null, "SHA-1", @"C:\fake.mzML", null))
        {
            var mz1           = new double[] { pepWithSetMods.MonoisotopicMass.ToMz(2), (pepWithSetMods.MonoisotopicMass + 1.003).ToMz(2), (pepWithSetMods.MonoisotopicMass + 2.005).ToMz(2) };
            var intensities1  = new double[] { 1, 1, 1 };
            var MassSpectrum1 = new MzmlMzSpectrum(mz1, intensities1, false);

            var ScansHere = new List <IMzmlScan> {
                new MzmlScan(1, MassSpectrum1, 1, true, Polarity.Positive, 1, new MzLibUtil.MzRange(0, 10000), "ff", MZAnalyzerType.Unknown, 1000, 1, "scan=1")
            };

            List <double> mz2          = new List <double>();
            List <double> intensities2 = new List <double>();

            foreach (var aok in pepWithSetMods.CompactPeptide(TerminusType.None).ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                ProductType.B, ProductType.Y
            }))
            {
                mz2.Add(aok.ToMz(1));
                mz2.Add((aok + 1.003).ToMz(1));
                intensities2.Add(1);
                intensities2.Add(1);
            }
            var MassSpectrum2 = new MzmlMzSpectrum(mz2.OrderBy(b => b).ToArray(), intensities2.ToArray(), false);
            var scan2         = new MzmlScanWithPrecursor(2, MassSpectrum2, 2, true, Polarity.Positive, 2, new MzLibUtil.MzRange(0, 10000), "df", MZAnalyzerType.Orbitrap, 234734, pepWithSetMods.MonoisotopicMass.ToMz(2), 2, 1, pepWithSetMods.MonoisotopicMass.ToMz(2), 2, DissociationType.HCD, 1, pepWithSetMods.MonoisotopicMass.ToMz(2), 1, "scan=2");

            scan2.ComputeSelectedPeakIntensity(MassSpectrum1);
            scan2.ComputeMonoisotopicPeakIntensity(MassSpectrum1);
            ScansHere.Add(scan2);
            Scans = ScansHere.ToArray();
        }
コード例 #7
0
        protected override MetaMorpheusEngineResults RunSpecific()
        {
            TerminusType terminusType = ProductTypeMethod.IdentifyTerminusType(lp);

            foreach (var ok in allResultingIdentifications)
            {
                ok.MatchedIonDictOnlyMatches = new Dictionary <ProductType, double[]>();
                ok.ProductMassErrorDa        = new Dictionary <ProductType, double[]>();
                ok.ProductMassErrorPpm       = new Dictionary <ProductType, double[]>();
                var    theScan          = myMsDataFile.GetOneBasedScan(ok.ScanNumber);
                double thePrecursorMass = ok.ScanPrecursorMass;
                foreach (var huh in lp)
                {
                    var ionMasses = ok.CompactPeptides.First().Key.ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                        huh
                    });
                    Array.Sort(ionMasses);
                    List <double> matchedIonMassesList    = new List <double>();
                    List <double> productMassErrorDaList  = new List <double>();
                    List <double> productMassErrorPpmList = new List <double>();
                    MatchIons(theScan, fragmentTolerance, ionMasses, matchedIonMassesList, productMassErrorDaList, productMassErrorPpmList, thePrecursorMass, dissociationTypes, addCompIons);
                    double[] matchedIonMassesOnlyMatches = matchedIonMassesList.ToArray();
                    ok.MatchedIonDictOnlyMatches.Add(huh, matchedIonMassesOnlyMatches);
                    ok.ProductMassErrorDa.Add(huh, productMassErrorDaList.ToArray());
                    ok.ProductMassErrorPpm.Add(huh, productMassErrorPpmList.ToArray());
                }
            }

            foreach (var ok in allResultingIdentifications.Where(b => b.NumDifferentCompactPeptides == 1))
            {
                var    theScan          = myMsDataFile.GetOneBasedScan(ok.ScanNumber);
                double thePrecursorMass = ok.ScanPrecursorMass;

                if (ok.FullSequence == null)
                {
                    continue;
                }

                var representative = ok.CompactPeptides.First().Value.Item2.First();

                var localizedScores = new List <double>();
                for (int indexToLocalize = 0; indexToLocalize < representative.Length; indexToLocalize++)
                {
                    PeptideWithSetModifications localizedPeptide = representative.Localize(indexToLocalize, ok.ScanPrecursorMass - representative.MonoisotopicMass);

                    var gg = localizedPeptide.CompactPeptide(terminusType).ProductMassesMightHaveDuplicatesAndNaNs(lp);
                    Array.Sort(gg);
                    var score = CalculatePeptideScore(theScan, fragmentTolerance, gg, thePrecursorMass, dissociationTypes, addCompIons, 0);
                    localizedScores.Add(score);
                }

                ok.LocalizedScores = localizedScores;
            }
            return(new LocalizationEngineResults(this));
        }
コード例 #8
0
        public static void TestLastPeaks()
        {
            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);
            PeptideWithSetModifications 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 };
            double[]   mz           = new double[] { 1, 2, massArray[4].ToMz(1) };
            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) };
            CommonParameters          CommonParameters      = new CommonParameters(
                scoreCutoff: 1,
                productMassTolerance: new PpmTolerance(5),
                digestionParams: new DigestionParams(
                    maxMissedCleavages: 0,
                    minPeptideLength: 1,
                    maxModificationIsoforms: int.MaxValue,
                    initiatorMethionineBehavior: InitiatorMethionineBehavior.Retain));
            ClassicSearchEngine cse = new ClassicSearchEngine(globalPsms, arrayOfSortedMS2Scans, new List <ModificationWithMass>(), new List <ModificationWithMass>(), new List <Protein> {
                prot
            }, new List <ProductType> {
                ProductType.B, ProductType.Y
            }, new OpenSearchMode(), CommonParameters, new List <string>());

            cse.Run();
            Assert.Less(globalPsms[0].Score, 2);
            Assert.Greater(globalPsms[0].Score, 1);
        }
コード例 #9
0
        public static void TryFailSequenceCoverage()
        {
            var prot1 = new Protein("MMKMMK", "prot1");

            ModificationMotif.TryGetMotif("M", out ModificationMotif motifM);
            ModificationWithMass mod1 = new ModificationWithMass("mod1", "mt", motifM, TerminusLocalization.NProt, 10);
            ModificationWithMass mod2 = new ModificationWithMass("mod2", "mt", motifM, TerminusLocalization.NPep, 10);
            ModificationWithMass mod3 = new ModificationWithMass("mod3", "mt", motifM, TerminusLocalization.Any, 10);

            ModificationMotif.TryGetMotif("K", out ModificationMotif motifK);
            ModificationWithMass mod4 = new ModificationWithMass("mod4", "mt", motifK, TerminusLocalization.PepC, 10);
            ModificationWithMass mod5 = new ModificationWithMass("mod5", "mt", motifK, TerminusLocalization.ProtC, 10);

            Dictionary <int, ModificationWithMass> modsFor1 = new Dictionary <int, ModificationWithMass>
            {
                { 1, mod1 },
                { 3, mod3 },
                { 5, mod4 },
            };
            Dictionary <int, ModificationWithMass> modsFor2 = new Dictionary <int, ModificationWithMass>
            {
                { 1, mod2 },
                { 5, mod5 },
            };
            Dictionary <int, ModificationWithMass> modsFor3 = new Dictionary <int, ModificationWithMass>
            {
                { 1, mod1 },
                { 5, mod3 },
                { 8, mod5 }
            };

            DigestionParams digestionParams = new DigestionParams();
            var             pwsm1           = new PeptideWithSetModifications(protein: prot1, digestionParams: digestionParams, oneBasedStartResidueInProtein: 1, oneBasedEndResidueInProtein: 3, peptideDescription: "", missedCleavages: 0, allModsOneIsNterminus: modsFor1, numFixedMods: 0);
            var             pwsm2           = new PeptideWithSetModifications(protein: prot1, digestionParams: digestionParams, oneBasedStartResidueInProtein: 4, oneBasedEndResidueInProtein: 6, peptideDescription: "", missedCleavages: 0, allModsOneIsNterminus: modsFor2, numFixedMods: 0);
            var             pwsm3           = new PeptideWithSetModifications(protein: prot1, digestionParams: digestionParams, oneBasedStartResidueInProtein: 1, oneBasedEndResidueInProtein: 6, peptideDescription: "", missedCleavages: 0, allModsOneIsNterminus: modsFor3, numFixedMods: 0);

            HashSet <PeptideWithSetModifications> peptides = new HashSet <PeptideWithSetModifications>
            {
                pwsm1,
                pwsm2,
                pwsm3,
            };

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

            IScan scan = new ThisTestScan();
            var   psm1 = new PeptideSpectralMatch(pwsm1.CompactPeptide(TerminusType.None), 0, 1, 0, scan, digestionParams);

            psm1.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false);
            psm1.MatchToProteinLinkedPeptides(matching);
            var psm2 = new PeptideSpectralMatch(pwsm2.CompactPeptide(TerminusType.None), 0, 1, 0, scan, digestionParams);

            psm2.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false);
            psm2.MatchToProteinLinkedPeptides(matching);
            var psm3 = new PeptideSpectralMatch(pwsm3.CompactPeptide(TerminusType.None), 0, 1, 0, scan, digestionParams);

            psm3.SetFdrValues(0, 0, 0, 0, 0, 0, 0, 0, 0, false);
            psm3.MatchToProteinLinkedPeptides(matching);

            List <PeptideSpectralMatch> newPsms = new List <PeptideSpectralMatch>
            {
                psm1,
                psm2,
                psm3,
            };

            ProteinParsimonyEngine  ppe  = new ProteinParsimonyEngine(matching, true, new CommonParameters(), new List <string>());
            ProteinParsimonyResults fjkd = (ProteinParsimonyResults)ppe.Run();

            ProteinScoringAndFdrEngine psafe = new ProteinScoringAndFdrEngine(fjkd.ProteinGroups, newPsms, true, true, true, new CommonParameters(), new List <string>());

            psafe.Run();

            fjkd.ProteinGroups.First().CalculateSequenceCoverage();

            var firstSequenceCoverageDisplayList = fjkd.ProteinGroups.First().SequenceCoverageDisplayList.First();

            Assert.AreEqual("MMKMMK", firstSequenceCoverageDisplayList);
            var firstSequenceCoverageDisplayListWithMods = fjkd.ProteinGroups.First().SequenceCoverageDisplayListWithMods.First();

            Assert.AreEqual("[mod1]-MM[mod3]KM[mod3]MK-[mod5]", firstSequenceCoverageDisplayListWithMods);

            var firstModInfo = fjkd.ProteinGroups.First().ModsInfo.First();

            Assert.IsTrue(firstModInfo.Contains(@"#aa1[mod1,info:occupancy=1.00(2/2)]"));
            Assert.IsTrue(firstModInfo.Contains(@"#aa2[mod3,info:occupancy=0.50(1/2)]"));
            Assert.IsFalse(firstModInfo.Contains(@"#aa3"));
            Assert.IsTrue(firstModInfo.Contains(@"#aa4[mod3,info:occupancy=0.50(1/2)]"));
            Assert.IsFalse(firstModInfo.Contains(@"#aa5"));
            Assert.IsTrue(firstModInfo.Contains(@"#aa6[mod5,info:occupancy=1.00(2/2)]"));
        }
コード例 #10
0
        protected override MetaMorpheusEngineResults RunSpecific()
        {
            TerminusType terminusType = ProductTypeMethods.IdentifyTerminusType(ProductTypes);

            foreach (PeptideSpectralMatch psm in AllResultingIdentifications)
            {
                // Stop loop if canceled
                if (GlobalVariables.StopLoops)
                {
                    break;
                }

                psm.MatchedIonSeriesDict            = new Dictionary <ProductType, int[]>();
                psm.MatchedIonMassToChargeRatioDict = new Dictionary <ProductType, double[]>();
                psm.ProductMassErrorDa        = new Dictionary <ProductType, double[]>();
                psm.ProductMassErrorPpm       = new Dictionary <ProductType, double[]>();
                psm.MatchedIonIntensitiesDict = new Dictionary <ProductType, double[]>();
                var    theScan          = MyMsDataFile.GetOneBasedScan(psm.ScanNumber);
                double thePrecursorMass = psm.ScanPrecursorMass;
                foreach (ProductType productType in ProductTypes)
                {
                    var sortedTheoreticalProductMasses = psm.CompactPeptides.First().Key.ProductMassesMightHaveDuplicatesAndNaNs(new List <ProductType> {
                        productType
                    });
                    Array.Sort(sortedTheoreticalProductMasses);
                    List <int>    matchedIonSeriesList            = new List <int>();
                    List <double> matchedIonMassToChargeRatioList = new List <double>();
                    List <double> productMassErrorDaList          = new List <double>();
                    List <double> productMassErrorPpmList         = new List <double>();
                    List <double> matchedIonIntensityList         = new List <double>();

                    //populate the above lists
                    MatchIonsOld(theScan, commonParameters.ProductMassTolerance, sortedTheoreticalProductMasses, matchedIonSeriesList, matchedIonMassToChargeRatioList, productMassErrorDaList, productMassErrorPpmList, matchedIonIntensityList, thePrecursorMass, productType, commonParameters.AddCompIons);

                    psm.MatchedIonSeriesDict.Add(productType, matchedIonSeriesList.ToArray());
                    psm.MatchedIonMassToChargeRatioDict.Add(productType, matchedIonMassToChargeRatioList.ToArray());
                    psm.ProductMassErrorDa.Add(productType, productMassErrorDaList.ToArray());
                    psm.ProductMassErrorPpm.Add(productType, productMassErrorPpmList.ToArray());
                    psm.MatchedIonIntensitiesDict.Add(productType, matchedIonIntensityList.ToArray());
                }
            }

            foreach (PeptideSpectralMatch psm in AllResultingIdentifications.Where(b => b.NumDifferentCompactPeptides == 1))
            {
                // Stop loop if canceled
                if (GlobalVariables.StopLoops)
                {
                    break;
                }

                var    theScan          = MyMsDataFile.GetOneBasedScan(psm.ScanNumber);
                double thePrecursorMass = psm.ScanPrecursorMass;

                if (psm.FullSequence == null)
                {
                    continue;
                }

                PeptideWithSetModifications representative = psm.CompactPeptides.First().Value.Item2.First();

                var localizedScores = new List <double>();
                for (int indexToLocalize = 0; indexToLocalize < representative.Length; indexToLocalize++)
                {
                    PeptideWithSetModifications localizedPeptide = representative.Localize(indexToLocalize, psm.ScanPrecursorMass - representative.MonoisotopicMass);

                    var gg = localizedPeptide.CompactPeptide(terminusType).ProductMassesMightHaveDuplicatesAndNaNs(ProductTypes);
                    Array.Sort(gg);
                    var score = CalculatePeptideScoreOld(theScan, commonParameters.ProductMassTolerance, gg, thePrecursorMass, DissociationTypes, commonParameters.AddCompIons, 0);
                    localizedScores.Add(score);
                }

                psm.LocalizedScores = localizedScores;
            }
            return(new LocalizationEngineResults(this));
        }