public static void OGlycoTest_FragmentIons2() { //Get glycanBox var glycanBox = OGlycanBoxes[24]; Protein protein = new Protein("TVYLGASK", ""); var peptide = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First(); List <int> modPos = new List <int> { 2, 8 }; var peptideWithMod = GlycoPeptides.OGlyGetTheoreticalPeptide(modPos.ToArray(), peptide, OGlycanBoxes[24]); Assert.That(peptideWithMod.FullSequence == "T[O-Glycosylation:H1N1 on X]VYLGAS[O-Glycosylation:H1N1A1 on X]K"); var fragments_etd = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.ETD, peptide, peptideWithMod); Assert.That(fragments_etd.Count == 22); Assert.That(fragments_etd.Last().Annotation == "zDot8"); Assert.That(fragments_etd.Last().NeutralMass > 1824); var fragments_hcd = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.HCD, peptide, peptideWithMod); Assert.That(fragments_hcd.Where(p => p.ProductType == ProductType.M).Count() == 5); var fragments_ethcd = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.EThcD, peptide, peptideWithMod); Assert.That(fragments_ethcd.Where(p => p.ProductType == ProductType.M).Count() == 5); }
public static void OGlycoTest_FragmentIonsHash() { //Get glycanBox var glycanBox = OGlycanBoxes[8]; Protein protein = new Protein("PTLFKNVSLYK", ""); var peptide = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First(); List <int> modPos = GlycoSpectralMatch.GetPossibleModSites(peptide, new string[] { "S", "T" }); var peptideWithMod = GlycoPeptides.OGlyGetTheoreticalPeptide(modPos.ToArray(), peptide, glycanBox); Assert.That(peptideWithMod.FullSequence == "PT[O-Glycosylation:N1A1 on X]LFKNVS[O-Glycosylation:N1 on X]LYK"); //The following code prove that the default Fragment method doesn't work for O-glycopeptide due to neutral losses. var fragments_hcd = new List <Product>(); peptide.Fragment(DissociationType.HCD, FragmentationTerminus.Both, fragments_hcd); var fragmentsMod_hcd = new List <Product>(); peptideWithMod.Fragment(DissociationType.HCD, FragmentationTerminus.Both, fragmentsMod_hcd); Assert.That(fragments_hcd.Count() == 20); Assert.That(fragmentsMod_hcd.Count() == 61); //The Fragments also contain neutral loss ions. var frag_ments_etd = new List <Product>(); peptide.Fragment(DissociationType.ETD, FragmentationTerminus.Both, frag_ments_etd); var fragmentsMod_etd = new List <Product>(); peptideWithMod.Fragment(DissociationType.ETD, FragmentationTerminus.Both, fragmentsMod_etd); //Tuple<int, int[]> keyValuePair represents: <glycanBoxId, glycanModPositions> Tuple <int, int[]> keyValuePairs = new Tuple <int, int[]>(8, modPos.ToArray()); var fragments_etd_origin = GlycoPeptides.GetFragmentHash(frag_ments_etd, new Tuple <int, int[]>(0, null), OGlycanBoxes, 1000); var fragmentsHash_etd = GlycoPeptides.GetFragmentHash(frag_ments_etd, keyValuePairs, OGlycanBoxes, 1000); var fragmentsMod_etd_origin = GlycoPeptides.GetFragmentHash(fragmentsMod_etd, new Tuple <int, int[]>(0, null), OGlycanBoxes, 1000); var overlap = fragmentsHash_etd.Intersect(fragments_etd_origin).Count(); Assert.That(overlap == 14); var overlap2 = fragmentsHash_etd.Intersect(fragmentsMod_etd_origin).Count(); //ETD didn't change y ions. Assert.That(overlap2 == 23); }
public static void OGlycoTest_FragmentIons() { //This test is to test ETD on proline. As proline didn't have proline related product ions. //Get glycanBox var glycanBox = OGlycanBoxes[8]; Protein protein = new Protein("PTLFKNVSLYK", ""); var peptide = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First(); List <int> modPos = GlycoSpectralMatch.GetPossibleModSites(peptide, new string[] { "S", "T" }); var peptideWithMod = GlycoPeptides.OGlyGetTheoreticalPeptide(modPos.ToArray(), peptide, OGlycanBoxes[8]); Assert.That(peptideWithMod.FullSequence == "PT[O-Glycosylation:N1A1 on X]LFKNVS[O-Glycosylation:N1 on X]LYK"); var fragments_hcd = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.HCD, peptide, peptideWithMod); var fragments_ethcd = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.EThcD, peptide, peptideWithMod); }
public static void OGlycoTest_Localization2() { //There may have a bug that MM cannot identify Peptide modified with (HexNAc), This is to test and find the bug. //Get glycanBox var glycanBox = OGlycanBoxes[0]; //Get unmodified peptide, products, allPossible modPos and all boxes. Protein protein = new Protein("AATVGSLAGQPLQER", "P16150"); var peptide = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First(); List <Product> products = new List <Product>(); peptide.Fragment(DissociationType.ETD, FragmentationTerminus.Both, products); int[] modPos = GlycoSpectralMatch.GetPossibleModSites(peptide, new string[] { "S", "T" }).OrderBy(p => p).ToArray(); var boxes = GlycanBox.BuildChildOGlycanBoxes(glycanBox.NumberOfMods, glycanBox.ModIds).ToArray(); //Load scan. CommonParameters commonParameters = new CommonParameters(dissociationType: DissociationType.ETD, trimMsMsPeaks: false); string spectraFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"GlycoTestData\181217_Fusion_(LC2)_NewObj_Serum_deSA_Jacalin_HRM_4h_ETD_HCD_DDA_mz(400_1200)_21707.mgf"); var file = new MyFileManager(true).LoadFile(spectraFile, commonParameters); var scans = MetaMorpheusTask.GetMs2Scans(file, spectraFile, commonParameters).ToArray(); //Known peptideWithMod match. var peptideWithMod = GlycoPeptides.OGlyGetTheoreticalPeptide(new int[1] { 4 }, peptide, glycanBox); Assert.That(peptideWithMod.FullSequence == "AAT[O-Glycosylation:N1 on X]VGSLAGQPLQER"); //List<Product> knownProducts = peptideWithMod.Fragment(DissociationType.EThcD, FragmentationTerminus.Both).ToList(); List <Product> knownProducts = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.ETD, peptide, peptideWithMod); var matchedKnownFragmentIons = MetaMorpheusEngine.MatchFragmentIons(scans.First(), knownProducts, commonParameters); //Get hashset int int obsPreviousFragmentCeilingMz = 0; List <int> binsToSearch = new List <int>(); foreach (var envelope in scans.First().ExperimentalFragments) { // assume charge state 1 to calculate mass tolerance double experimentalFragmentMass = envelope.MonoisotopicMass; // get theoretical fragment bins within mass tolerance int obsFragmentFloorMass = (int)Math.Floor((commonParameters.ProductMassTolerance.GetMinimumValue(experimentalFragmentMass)) * 1000); int obsFragmentCeilingMass = (int)Math.Ceiling((commonParameters.ProductMassTolerance.GetMaximumValue(experimentalFragmentMass)) * 1000); // prevents double-counting peaks close in m/z and lower-bound out of range exceptions if (obsFragmentFloorMass < obsPreviousFragmentCeilingMz) { obsFragmentFloorMass = obsPreviousFragmentCeilingMz; } obsPreviousFragmentCeilingMz = obsFragmentCeilingMass + 1; // search mass bins within a tolerance for (int fragmentBin = obsFragmentFloorMass; fragmentBin <= obsFragmentCeilingMass; fragmentBin++) { binsToSearch.Add(fragmentBin); } } HashSet <int> allPeaks = new HashSet <int>(binsToSearch); //Graph Localization LocalizationGraph localizationGraph = new LocalizationGraph(modPos, glycanBox, boxes, -1); LocalizationGraph.LocalizeOGlycan(localizationGraph, scans.First(), commonParameters.ProductMassTolerance, products); var allPaths = LocalizationGraph.GetAllHighestScorePaths(localizationGraph.array, localizationGraph.ChildModBoxes); var knowPath = new int[2] { 1, 1 }; Assert.That(Enumerable.SequenceEqual(knowPath, allPaths[0])); var local = LocalizationGraph.GetLocalizedPath(localizationGraph, allPaths.First()); Assert.That(Enumerable.SequenceEqual(local.Mods.Select(p => p.Item1), new List <int> { 4 })); Assert.That(Enumerable.SequenceEqual(local.Mods.Select(p => p.Item2), new List <int> { 0 })); }
public static void OGlycoTest_Localization() { //Get glycanBox var glycanBox = OGlycanBoxes[19]; //Get unmodified peptide, products, allPossible modPos and all boxes. Protein protein = new Protein("TTGSLEPSSGASGPQVSSVK", "P16150"); var peptide = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First(); List <Product> products = new List <Product>(); peptide.Fragment(DissociationType.ETD, FragmentationTerminus.Both, products); int[] modPos = GlycoSpectralMatch.GetPossibleModSites(peptide, new string[] { "S", "T" }).OrderBy(v => v).ToArray(); var boxes = GlycanBox.BuildChildOGlycanBoxes(3, glycanBox.ModIds).ToArray(); Assert.That(boxes.Count() == 6); //Get Unlocal Fragment var unlocalCost = GlycoPeptides.GetUnlocalFragment(products, modPos, glycanBox); Assert.That(unlocalCost.Count == 4); //Basicly, the unlocal are c/z ions that don't localize glycosylation. //Get scan CommonParameters commonParameters = new CommonParameters(dissociationType: DissociationType.EThcD, trimMsMsPeaks: false); string spectraFile = Path.Combine(TestContext.CurrentContext.TestDirectory, @"GlycoTestData\2019_09_16_StcEmix_35trig_EThcD25_rep1_4565.mgf"); var file = new MyFileManager(true).LoadFile(spectraFile, commonParameters); var scans = MetaMorpheusTask.GetMs2Scans(file, spectraFile, commonParameters).ToArray(); //Known peptideWithMod match. var peptideWithMod = GlycoPeptides.OGlyGetTheoreticalPeptide(new int[3] { 10, 2, 3 }, peptide, glycanBox); Assert.That(peptideWithMod.FullSequence == "T[O-Glycosylation:H1N1 on X]T[O-Glycosylation:H1N1 on X]GSLEPSS[O-Glycosylation:N1 on X]GASGPQVSSVK"); List <Product> knownProducts = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.EThcD, peptide, peptideWithMod); var matchedKnownFragmentIons = MetaMorpheusEngine.MatchFragmentIons(scans.First(), knownProducts, commonParameters); //Graph Localization LocalizationGraph localizationGraph = new LocalizationGraph(modPos, glycanBox, boxes, -1); LocalizationGraph.LocalizeOGlycan(localizationGraph, scans.First(), commonParameters.ProductMassTolerance, products); var allPaths = LocalizationGraph.GetAllHighestScorePaths(localizationGraph.array, localizationGraph.ChildModBoxes); var knowPath = new int[8] { 2, 4, 4, 4, 5, 5, 5, 5 }; Assert.That(Enumerable.SequenceEqual(knowPath, allPaths[0])); //Get localized Route var local = LocalizationGraph.GetLocalizedPath(localizationGraph, allPaths.First()); Assert.That(Enumerable.SequenceEqual(local.Mods.Select(v => v.Item1), new List <int> { 2, 3, 10 })); Assert.That(Enumerable.SequenceEqual(local.Mods.Select(v => v.Item2), new List <int> { 1, 1, 0 })); //Get all paths, calculate PScore and calculate position probability. var p = scans.First().TheScan.MassSpectrum.Size *commonParameters.ProductMassTolerance.GetRange(1000).Width / scans.First().TheScan.MassSpectrum.Range.Width; var n = knownProducts.Where(v => v.ProductType == ProductType.c || v.ProductType == ProductType.zDot).Count(); var allPathWithWeights = LocalizationGraph.GetAllPaths_CalP(localizationGraph, p, n); Assert.That(allPathWithWeights.Count == 168); //Calculate Site Specific Localization Probability var y = LocalizationGraph.CalSiteSpecificLocalizationProbability(allPathWithWeights, localizationGraph.ModPos); Assert.That(y.Count == 8); Assert.That(y.First().Value[1].Item2 > 0.99); }