private void resetFilesButton_Click(object sender, RoutedEventArgs e) { // clear spectra file path if ((sender as Button).Name.Equals(resetSpectraFileButton.Name)) { spectraFilePath = null; spectraFileNameLabel.Text = "None Selected"; spectraFileNameLabel.ToolTip = null; resetSpectraFileButton.IsEnabled = false; } // clear psm file path, psm data, and stat plot else { tsvResultsFilePath = null; psmFileNameLabel.Text = "None Selected"; psmFileNameLabel.ToolTip = null; psmFileNameLabelStat.Text = "None Selected"; psmFileNameLabelStat.ToolTip = null; resetPsmFileButton.IsEnabled = false; resetPsmFileButtonStat.IsEnabled = false; allPsms.Clear(); filteredListOfPsms.Clear(); psmsBySourceFile.Clear(); sourceFilesList.Clear(); plotViewStat.DataContext = null; } // clear main plot, base sequence, and properties table mainViewModel.Model = null; BaseDraw.clearCanvas(canvas); propertyView.Clear(); MsDataFile = null; }
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); } }
private void DrawAnnotatedBaseSequence(PsmFromTsv psm) { 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); } // draw the fragment ion annotations on the base sequence foreach (var ion in psm.MatchedIons) { int residue = ion.NeutralTheoreticalProduct.TerminusFragment.AminoAcidPosition; string annotation = ion.NeutralTheoreticalProduct.ProductType + "" + ion.NeutralTheoreticalProduct.TerminusFragment.FragmentNumber; if (ion.NeutralTheoreticalProduct.NeutralLoss != 0) { annotation += "-" + ion.NeutralTheoreticalProduct.NeutralLoss; } if (ion.NeutralTheoreticalProduct.TerminusFragment.Terminus == FragmentationTerminus.C) { BaseDraw.topSplittingDrawing(canvas, new Point(residue * spacing + 8, productTypeToYOffset[ion.NeutralTheoreticalProduct.ProductType]), productTypeToColor[ion.NeutralTheoreticalProduct.ProductType], annotation); } else if (ion.NeutralTheoreticalProduct.TerminusFragment.Terminus == FragmentationTerminus.N) { BaseDraw.botSplittingDrawing(canvas, new Point(residue * spacing + 8, productTypeToYOffset[ion.NeutralTheoreticalProduct.ProductType]), productTypeToColor[ion.NeutralTheoreticalProduct.ProductType], annotation); } // don't draw diagnostic ions, precursor ions, etc } // draw modifications var peptide = new PeptideWithSetModifications(psm.FullSequence, GlobalVariables.AllModsKnownDictionary); 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.TerminusFragment.AminoAcidPosition; string annotation = ion.NeutralTheoreticalProduct.ProductType + "" + ion.NeutralTheoreticalProduct.TerminusFragment.FragmentNumber; if (ion.NeutralTheoreticalProduct.NeutralLoss != 0) { annotation += "-" + ion.NeutralTheoreticalProduct.NeutralLoss; } if (ion.NeutralTheoreticalProduct.TerminusFragment.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.TerminusFragment.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); } }
private void DrawAnnotatedBaseSequence(MetaDrawPsm psm) { double spacing = 22; BaseDraw.clearCanvas(canvas); // draw base sequence for (int r = 0; r < psm.BaseSequence.Length; r++) { BaseDraw.txtDrawing(canvas, new Point(r * spacing + 10, 10), psm.BaseSequence[r].ToString(), Brushes.Black); } // draw b ions foreach (var bIon in psm.FragmentIons.Where(p => p.ProductType == ProductType.B)) { int residue = bIon.IonNumber; BaseDraw.botSplittingDrawing(canvas, new Point(residue * spacing + 8, 50), Colors.Blue, bIon.ProductType.ToString().ToLower() + bIon.IonNumber); } // draw c ions foreach (var cIon in psm.FragmentIons.Where(p => p.ProductType == ProductType.C)) { int residue = psm.BaseSequence.Length - cIon.IonNumber; BaseDraw.botSplittingDrawing(canvas, new Point(residue * spacing + 8, 50), Colors.Gold, cIon.ProductType.ToString().ToLower() + cIon.IonNumber); } // draw y ions foreach (var yIon in psm.FragmentIons.Where(p => p.ProductType == ProductType.Y)) { int residue = psm.BaseSequence.Length - yIon.IonNumber; BaseDraw.topSplittingDrawing(canvas, new Point(residue * spacing + 8, 0), Colors.Purple, yIon.ProductType.ToString().ToLower() + yIon.IonNumber); } // draw zdot ions foreach (var zDotIon in psm.FragmentIons.Where(p => p.ProductType == ProductType.Zdot)) { int residue = zDotIon.IonNumber; BaseDraw.topSplittingDrawing(canvas, new Point(residue * spacing + 8, 0), Colors.Orange, zDotIon.ProductType.ToString().ToLower() + zDotIon.IonNumber); } // draw modifications int aa = 0; bool currentlyReadingMod = false; for (int c = 0; c < psm.FullSequence.Length; c++) { switch (psm.FullSequence[c]) { case '[': currentlyReadingMod = true; BaseDraw.circledTxtDraw(canvas, new Point(aa * spacing - 17, 12), Brushes.Yellow); break; case ']': currentlyReadingMod = false; break; default: if (!currentlyReadingMod) { aa++; } break; } } }
private void DrawSequenceCoverageMap(ProteinForTreeView protein) //string accession, Dictionary<string, PeptideForTreeView> uniquePeptides, Dictionary<string, PeptideForTreeView> sharedPeptides) { string protease = "trypsin"; // only works for single protease for now string seqCoverage = proteinGroups[protein.Accession]; mapViewer.Visibility = Visibility.Visible; BaseDraw.clearCanvas(map); mainViewModel.Model = null; // clear plot BaseDraw.clearCanvas(canvas); double spacing = 22; int height = 10; int totalHeight = 0; int accumIndex = 0; foreach (string seq in seqCoverage.Split('|')) { var splitSeq = Split(seq, spacing); var allPeptides = new List <string>(protein.AllPeptides.Keys); foreach (var line in splitSeq) { List <int> indices = new List <int>(); // draw sequence for (int r = 0; r < line.Length; r++) { SequenceCoverageMap.txtDrawing(map, new Point(r * spacing + 10, height), line[r].ToString().ToUpper(), Brushes.Black); } // highlight partial peptide sequences (broken off into multiple lines) if (partialPeptideMatches.Count > 0) { var temp = new Dictionary <string, int>(partialPeptideMatches); partialPeptideMatches.Clear(); foreach (var peptide in temp) { if (MatchPeptideSequence(peptide.Key, line, 0, peptide.Value, accumIndex - peptide.Value == seq.IndexOf(peptide.Key))) { int start = 0; int end = Math.Min(start + peptide.Key.Length - peptide.Value - 1, line.Length - 1); SequenceCoverageMap.Highlight(start, end, map, indices, height, proteaseByColor[protease], protein.UniquePeptides.Keys.Any(u => u.Contains(peptide.Key))); // draw line for peptide sequence } } } // highlight full peptide sequences for (int i = 0; i < line.Length; ++i) { var temp = new List <string>(allPeptides); foreach (string peptide in temp) { if (MatchPeptideSequence(peptide, line, i, 0, accumIndex + i == seq.IndexOf(peptide))) { int start = i; int end = Math.Min(start + peptide.Length - 1, line.Length - 1); SequenceCoverageMap.Highlight(start, end, map, indices, height, proteaseByColor[protease], protein.UniquePeptides.Keys.Any(u => u.Contains(peptide))); allPeptides.Remove(peptide); } } } height += 50; accumIndex += line.Length; } totalHeight += splitSeq.Count() * 50; height += 50; } mapGrid.Height = totalHeight + 50 * seqCoverage.Split('|').Count(); SequenceCoverageMap.drawLegend(legend, proteaseByColor, proteases, legendGrid); }