//The oxoniumIonIntensities is related with Glycan.AllOxoniumIons. //Rules are coded in the function. public static bool OxoniumIonsAnalysis(double[] oxoniumIonsintensities, GlycanBox glycanBox) { //If a glycopeptide spectrum does not have 292.1027 or 274.0921, then remove all glycans that have sialic acids from the search. if (oxoniumIonsintensities[10] <= 0 && oxoniumIonsintensities[12] <= 0) { if (glycanBox.Kind[2] != 0 || glycanBox.Kind[3] != 0) { return(false); } } //If a spectrum has 366.1395, remove glycans that do not have HexNAc(1)Hex(1) or more. Here use the total glycan of glycanBox to calculate. if (oxoniumIonsintensities[14] > 0) { if (glycanBox.Kind[0] < 1 && glycanBox.Kind[1] < 1) { return(false); } } //Other rules: //A spectrum needs to have 204.0867 to be considered as a glycopeptide. //Ratio of 138.055 to 144.0655 can seperate O/N glycan. return(true); }
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 Setup() { GlycanBox.GlobalOGlycans = GlycanDatabase.LoadGlycan(GlobalVariables.OGlycanLocations.Where(p => p.Contains("OGlycan.gdb")).First(), true, true).ToArray(); GlycanBox.GlobalOGlycanModifications = GlycanBox.BuildGlobalOGlycanModifications(GlycanBox.GlobalOGlycans); OGlycanBoxes = GlycanBox.BuildOGlycanBoxes(3).OrderBy(p => p.Mass).ToArray(); }
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); }
public static PeptideWithSetModifications OGlyGetTheoreticalPeptide(int[] theModPositions, PeptideWithSetModifications peptide, GlycanBox glycanBox) { Modification[] modifications = new Modification[glycanBox.NumberOfMods]; for (int i = 0; i < glycanBox.NumberOfMods; i++) { modifications[i] = GlycanBox.GlobalOGlycanModifications[glycanBox.ModIds.ElementAt(i)]; } Dictionary <int, Modification> testMods = new Dictionary <int, Modification>(); foreach (var mod in peptide.AllModsOneIsNterminus) { testMods.Add(mod.Key, mod.Value); } for (int i = 0; i < theModPositions.Count(); i++) { testMods.Add(theModPositions.ElementAt(i), modifications[i]); } var testPeptide = new PeptideWithSetModifications(peptide.Protein, peptide.DigestionParams, peptide.OneBasedStartResidueInProtein, peptide.OneBasedEndResidueInProtein, peptide.CleavageSpecificityForFdrCategory, peptide.PeptideDescription, peptide.MissedCleavages, testMods, peptide.NumFixedMods); return(testPeptide); }