public static void AnnotateModifications(PsmFromTsv spectrumMatch, Canvas sequenceDrawingCanvas, string fullSequence, int yLoc, double?spacer = null, int xShift = 12) { var peptide = new PeptideWithSetModifications(fullSequence, GlobalVariables.AllModsKnownDictionary); // read glycans if applicable List <Tuple <int, string, double> > localGlycans = null; if (spectrumMatch.GlycanLocalizationLevel != null) { localGlycans = PsmFromTsv.ReadLocalizedGlycan(spectrumMatch.LocalizedGlycan); } // annotate mods foreach (var mod in peptide.AllModsOneIsNterminus) { double xLocation = (mod.Key - 1) * (spacer ?? MetaDrawSettings.AnnotatedSequenceTextSpacing) - xShift; double yLocation = yLoc + 2; if (mod.Value.ModificationType == "O-Glycosylation") { if (localGlycans.Where(p => p.Item1 + 1 == mod.Key).Count() > 0) { DrawCircle(sequenceDrawingCanvas, new Point(xLocation, yLocation), MetaDrawSettings.ModificationAnnotationColor); } else { DrawCircle(sequenceDrawingCanvas, new Point(xLocation, yLocation), Brushes.Gray); } } else { DrawCircle(sequenceDrawingCanvas, new Point(xLocation, yLocation), MetaDrawSettings.ModificationAnnotationColor); } } }
private void DrawAnnotatedBaseSequence(Canvas canvas, PsmFromTsv psm, bool ToAnnotateChildScan = false) { double spacing = 22; BaseDraw.clearCanvas(canvas); // don't draw ambiguous sequences if (psm.FullSequence.Contains("|")) { return; } // draw base sequence for (int r = 0; r < psm.BaseSeq.Length; r++) { BaseDraw.txtDrawing(canvas, new Point(r * spacing + 10, 10), psm.BaseSeq[r].ToString(), Brushes.Black); } var matchIons = psm.MatchedIons; if (ToAnnotateChildScan) { matchIons = new List <MatchedFragmentIon>(); foreach (var x in psm.ChildScanMatchedIons) { matchIons.AddRange(x.Value); } } // draw the fragment ion annotations on the base sequence foreach (var ion in matchIons) { int residue = ion.NeutralTheoreticalProduct.AminoAcidPosition; string annotation = ion.NeutralTheoreticalProduct.ProductType + "" + ion.NeutralTheoreticalProduct.FragmentNumber; Color color = psm.VariantCrossingIons.Contains(ion) ? variantCrossColor : productTypeToColor[ion.NeutralTheoreticalProduct.ProductType]; if (ion.NeutralTheoreticalProduct.NeutralLoss != 0) { annotation += "-" + ion.NeutralTheoreticalProduct.NeutralLoss; } if (ion.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.C) { BaseDraw.topSplittingDrawing(canvas, new Point(residue * spacing + 8, productTypeToYOffset[ion.NeutralTheoreticalProduct.ProductType]), color, annotation); } else if (ion.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.N) { BaseDraw.botSplittingDrawing(canvas, new Point(residue * spacing + 8, productTypeToYOffset[ion.NeutralTheoreticalProduct.ProductType]), color, annotation); } // don't draw diagnostic ions, precursor ions, etc } // draw modifications var peptide = new PeptideWithSetModifications(psm.FullSequence, GlobalVariables.AllModsKnownDictionary); if (psm.GlycanLocalizationLevel != null) { var localGlycans = PsmFromTsv.ReadLocalizedGlycan(psm.LocalizedGlycan); foreach (var mod in peptide.AllModsOneIsNterminus) { if (mod.Value.ModificationType == "O-Glycosylation") { if (localGlycans.Where(p => p.Item1 + 1 == mod.Key).Count() > 0) { BaseDraw.circledTxtDraw(canvas, new Point((mod.Key - 1) * spacing - 17, 12), modificationAnnotationColor); } else { BaseDraw.circledTxtDraw(canvas, new Point((mod.Key - 1) * spacing - 17, 12), Brushes.Gray); } } } } else { foreach (var mod in peptide.AllModsOneIsNterminus) { BaseDraw.circledTxtDraw(canvas, new Point((mod.Key - 1) * spacing - 17, 12), modificationAnnotationColor); } } if (psm.BetaPeptideBaseSequence != null) { for (int r = 0; r < psm.BetaPeptideBaseSequence.Length; r++) { BaseDraw.txtDrawing(canvas, new Point(r * spacing + 10, 100), psm.BetaPeptideBaseSequence[r].ToString(), Brushes.Black); } foreach (var ion in psm.BetaPeptideMatchedIons) { int residue = ion.NeutralTheoreticalProduct.AminoAcidPosition; string annotation = ion.NeutralTheoreticalProduct.ProductType + "" + ion.NeutralTheoreticalProduct.FragmentNumber; if (ion.NeutralTheoreticalProduct.NeutralLoss != 0) { annotation += "-" + ion.NeutralTheoreticalProduct.NeutralLoss; } if (ion.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.C) { BaseDraw.topSplittingDrawing(canvas, new Point(residue * spacing + 8, productTypeToYOffset[ion.NeutralTheoreticalProduct.ProductType] + 90), productTypeToColor[ion.NeutralTheoreticalProduct.ProductType], annotation); } else if (ion.NeutralTheoreticalProduct.Terminus == FragmentationTerminus.N) { BaseDraw.botSplittingDrawing(canvas, new Point(residue * spacing + 8, productTypeToYOffset[ion.NeutralTheoreticalProduct.ProductType] + 90), productTypeToColor[ion.NeutralTheoreticalProduct.ProductType], annotation); } // don't draw diagnostic ions, precursor ions, etc } var betaPeptide = new PeptideWithSetModifications(psm.BetaPeptideFullSequence, GlobalVariables.AllModsKnownDictionary); foreach (var mod in betaPeptide.AllModsOneIsNterminus) { BaseDraw.circledTxtDraw(canvas, new Point((mod.Key - 1) * spacing - 17, 12 + 90), modificationAnnotationColor); } int alphaSite = Int32.Parse(Regex.Match(psm.FullSequence, @"\d+").Value); int betaSite = Int32.Parse(Regex.Match(psm.BetaPeptideFullSequence, @"\d+").Value); BaseDraw.DrawCrosslinker(canvas, new Point(alphaSite * spacing, 50), new Point(betaSite * spacing, 90), Colors.Black); } }