Exemplo n.º 1
0
        private void OnSelectionChanged()
        {
            // can select protein or peptide only at a time (not both)
            if (proteinTreeView.SelectedItem == null)
            {
                return;
            }

            // draw the selected PSM
            propertyView.Clear();

            // differentiate item click protein VS psm
            var            selection    = proteinTreeView.SelectedItem.GetType().Name;
            PsmForTreeView psmToDisplay = null;

            switch (selection)
            {
            case "ProteinForTreeView":
            {
                ProteinForTreeView selectedItem = (ProteinForTreeView)proteinTreeView.SelectedItem;
                itemsControlSampleViewModel.Data.Clear();

                if (proteinGroups[selectedItem.Accession] != null)
                {
                    DrawSequenceCoverageMap(selectedItem);
                    ChangeMapScrollViewVisibility();
                }
            }
            break;

            case "PeptideForTreeView":
            {
                // find psm with best score
                PeptideForTreeView selectedItem = (PeptideForTreeView)proteinTreeView.SelectedItem;
                psmToDisplay = selectedItem.Children.OrderByDescending(psm => psm.Psm.Score).First();
                goto case "display";
            }

            case "PsmForTreeView":
            {
                psmToDisplay = (PsmForTreeView)proteinTreeView.SelectedItem;
                goto case "display";
            }

            case "display":
            {
                mapViewer.Visibility = Visibility.Collapsed;
                legend.Visibility    = Visibility.Collapsed;
                displayPsm(psmToDisplay);
            }
            break;
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        // redraw display based on first selection
        private void RestoreDefault(object defaultSelection)
        {
            mapGrid.Width = 485;
            var selection = defaultSelection.GetType().Name;

            switch (selection)
            {
            case "ProteinForTreeView":
            {
                ProteinForTreeView protein = (ProteinForTreeView)defaultSelection;
                DrawSequenceCoverageMap(protein);
            }
            break;

            case "PsmForTreeView":
            {
                PsmForTreeView psm = (PsmForTreeView)defaultSelection;
                DrawPsm(psm.Psm.Ms2ScanNumber, psm.Psm.FullSequence);
            }
            break;
            }
        }
Exemplo n.º 4
0
        private void PDFButton_Click(object sender, RoutedEventArgs e)
        {
            object temp       = null;
            var    selections = new List <object>();

            // select best scoring psm for any peptide selections
            foreach (object selectedItem in proteinTreeView.SelectedItems)
            {
                if (selectedItem.GetType().Name.Equals("PeptideForTreeView"))
                {
                    PeptideForTreeView peptide        = (PeptideForTreeView)selectedItem;
                    PsmForTreeView     bestScoringPsm = peptide.Children.OrderByDescending(psm => psm.Psm.Score).First();
                    selections.Add(bestScoringPsm);
                    continue;
                }

                selections.Add(selectedItem);
            }

            if (proteinTreeView.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select at least one scan or coverage map to export");
            }
            else
            {
                int numberOfScansToExport = selections.Distinct().Count();

                foreach (object selectedItem in selections.Distinct())
                {
                    if (temp == null)
                    {
                        temp = selectedItem;
                    }

                    var selection = selectedItem.GetType().Name;
                    switch (selection)
                    {
                    case "ProteinForTreeView":
                    {
                        ProteinForTreeView protein  = (ProteinForTreeView)selectedItem;
                        string             myString = illegalInFileName.Replace(protein.DisplayName, "");
                        myString = myString.Length > 30 ? myString.Substring(0, 30) : myString;

                        string filePath = Path.Combine(Path.GetDirectoryName(psmFilePath), "MetaDrawExport", myString.Trim(), myString + ".pdf");
                        string dir      = Path.GetDirectoryName(filePath);

                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }

                        DrawPdfCoverageMap(protein, mapGrid, filePath);
                    }
                    break;

                    case "PsmForTreeView":
                    {
                        PsmForTreeView psm           = (PsmForTreeView)selectedItem;
                        var            proteinFolder = illegalInFileName.Replace(psm.Parent.Parent.DisplayName, "");
                        proteinFolder = proteinFolder.Length > 30 ? proteinFolder.Substring(0, 30) : proteinFolder;

                        string peptideFolder = illegalInFileName.Replace(psm.Parent.DisplayName, "");
                        peptideFolder = peptideFolder.Length > 30 ? peptideFolder.Substring(0, 30) : peptideFolder;

                        string filePath = Path.Combine(Path.GetDirectoryName(psmFilePath), "MetaDrawExport", proteinFolder.Trim(), peptideFolder.Trim(), psm.ScanNo + ".pdf");
                        string dir      = Path.GetDirectoryName(filePath);

                        MsDataScan msDataScanToDraw = MsDataFile.GetOneBasedScan(psm.ScanNo);

                        if (!Directory.Exists(dir))
                        {
                            Directory.CreateDirectory(dir);
                        }

                        DrawPdfAnnotatedBaseSequence(psm.Psm, canvas, filePath);         // captures the annotation for the pdf
                        mainViewModel.DrawPeptideSpectralMatchPdf(msDataScanToDraw, psm.Psm, filePath, numberOfScansToExport > 1);
                    }
                    break;
                    }
                }

                RestoreDefault(temp);
                MessageBox.Show(string.Format("{0} PDFs exported", numberOfScansToExport));
            }
        }