Пример #1
0
        private void OnSelectionChanged()
        {
            if (dataGridScanNums.SelectedItem == null)
            {
                return;
            }

            // draw the selected PSM
            propertyView.Clear();
            PsmFromTsv row = (PsmFromTsv)dataGridScanNums.SelectedItem;
            System.Reflection.PropertyInfo[] temp = row.GetType().GetProperties();

            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].Name == nameof(row.MatchedIons))
                {
                    propertyView.Rows.Add(temp[i].Name, string.Join(", ", row.MatchedIons.Select(p => p.Annotation)));
                }
                else
                {
                    propertyView.Rows.Add(temp[i].Name, temp[i].GetValue(row, null));
                }
            }
            dataGridProperties.Items.Refresh();
            itemsControlSampleViewModel.Data.Clear();
            DrawPsm(row.Ms2ScanNumber, row.FullSequence);
        }
Пример #2
0
        /// <summary>
        /// Event triggers when a different cell is selected in the PSM data grid
        /// </summary>
        private void dataGridScanNums_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            if (dataGridScanNums.SelectedItem == null)
            {
                return;
            }

            PsmFromTsv psm = (PsmFromTsv)dataGridScanNums.SelectedItem;

            // draw the annotated spectrum
            MetaDrawLogic.DisplaySpectrumMatch(plotView, canvas, psm, itemsControlSampleViewModel, out var errors);

            //draw the sequence coverage if not crosslinked
            if (psm.ChildScanMatchedIons == null)
            {
                MetaDrawLogic.DrawSequenceCoverageMap(psm, sequenceText, map); //TODO: figure out how to show coverage on crosslinked peptides
                ParentChildScanView.Visibility            = Visibility.Collapsed;
                SequenceCoverageAnnotationView.Visibility = Visibility.Visible;
            }
            else
            {
                ParentChildScanView.Visibility            = Visibility.Visible;
                SequenceCoverageAnnotationView.Visibility = Visibility.Collapsed;
            }

            mapViewer.Width = map.Width;

            if (errors != null && errors.Any())
            {
                MessageBox.Show(errors.First());
                return;
            }

            // display PSM properties
            propertyView.Clear();
            System.Reflection.PropertyInfo[] temp = psm.GetType().GetProperties();

            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].Name == nameof(psm.MatchedIons))
                {
                    propertyView.Rows.Add(temp[i].Name, string.Join(", ", psm.MatchedIons.Select(p => p.Annotation)));
                }
                else if (temp[i].Name == nameof(psm.VariantCrossingIons))
                {
                    propertyView.Rows.Add(temp[i].Name, string.Join(", ", psm.VariantCrossingIons.Select(p => p.Annotation)));
                }
                else
                {
                    propertyView.Rows.Add(temp[i].Name, temp[i].GetValue(psm, null));
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Event triggers when a different cell is selected in the PSM data grid
        /// </summary>
        private void dataGridScanNums_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            if (dataGridScanNums.SelectedItem == null)
            {
                return;
            }

            PsmFromTsv psm = (PsmFromTsv)dataGridScanNums.SelectedItem;

            // draw the PSM
            MetaDrawLogic.DisplaySpectrumMatch(plotView, canvas, psm, itemsControlSampleViewModel, out var errors);

            if (psm.ChildScanMatchedIons != null)
            {
                ParentChildScanView.Visibility = Visibility.Visible;
                ParentScanView.Visibility      = Visibility.Visible;
            }
            else
            {
                ParentChildScanView.Visibility = Visibility.Collapsed;
                ParentScanView.Visibility      = Visibility.Collapsed;
            }

            if (errors != null && errors.Any())
            {
                MessageBox.Show(errors.First());
                return;
            }

            // display PSM properties
            propertyView.Clear();
            System.Reflection.PropertyInfo[] temp = psm.GetType().GetProperties();

            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].Name == nameof(psm.MatchedIons))
                {
                    propertyView.Rows.Add(temp[i].Name, string.Join(", ", psm.MatchedIons.Select(p => p.Annotation)));
                }
                else if (temp[i].Name == nameof(psm.VariantCrossingIons))
                {
                    propertyView.Rows.Add(temp[i].Name, string.Join(", ", psm.VariantCrossingIons.Select(p => p.Annotation)));
                }
                else
                {
                    propertyView.Rows.Add(temp[i].Name, temp[i].GetValue(psm, null));
                }
            }
        }
Пример #4
0
        // displays psm spectrum annotation
        private void displayPsm(PsmForTreeView selection)
        {
            PsmFromTsv row = selection.Psm;

            System.Reflection.PropertyInfo[] temp = row.GetType().GetProperties();

            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i].Name == nameof(row.MatchedIons))
                {
                    propertyView.Rows.Add(temp[i].Name, string.Join(", ", row.MatchedIons.Select(p => p.Annotation)));
                }
                else
                {
                    propertyView.Rows.Add(temp[i].Name, temp[i].GetValue(row, null));
                }
            }
            dataGridProperties.Items.Refresh();
            itemsControlSampleViewModel.Data.Clear();
            DrawPsm(row.Ms2ScanNumber, row.FullSequence);
        }
        public void DrawPeptideSpectralMatchPdf(MsDataScan msDataScan, PsmFromTsv psm, string fileName, bool redraw)
        {
            var properties = psm.GetType().GetProperties();
            var pdfModel   = DrawPdf(msDataScan, properties, psm, redraw);

            string tempPath        = Path.Combine(Path.GetDirectoryName(fileName), "sequence.pdf");
            string baseSeqTempPath = Path.Combine(Path.GetDirectoryName(fileName), "annotation.png");

            // exports plot to pdf
            using (var stream = File.Create(tempPath))
            {
                PdfExporter pdf = new PdfExporter {
                    Width = 800, Height = 500
                };
                pdf.Export(pdfModel, stream);
            }

            // adds base seq annotation to pdf
            using (Stream inputPdfStream = new FileStream(tempPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                using (Stream inputImageStream = new FileStream(baseSeqTempPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (Stream outputPdfStream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
                    {
                        var reader         = new PdfReader(inputPdfStream);
                        var stamper        = new PdfStamper(reader, outputPdfStream);
                        var pdfContentByte = stamper.GetOverContent(1);

                        var image = iTextSharp.text.Image.GetInstance(inputImageStream);
                        image.ScaleAbsoluteHeight(500);
                        image.ScaleAbsoluteWidth(500);
                        image.SetAbsolutePosition(95, 190);
                        pdfContentByte.AddImage(image);
                        stamper.Close();
                    }

            File.Delete(tempPath);
            File.Delete(baseSeqTempPath);
        }