Пример #1
0
        public MetaDraw()
        {
            UsefulProteomicsDatabases.Loaders.LoadElements();

            InitializeComponent();

            itemsControlSampleViewModel = new ItemsControlSampleViewModel();
            DataContext = itemsControlSampleViewModel;
            mainViewModel = new PsmAnnotationViewModel();
            plotView.DataContext = mainViewModel;
            allPsms = new ObservableCollection<PsmFromTsv>();
            filteredListOfPsms = new ObservableCollection<PsmFromTsv>();
            propertyView = new DataTable();
            propertyView.Columns.Add("Name", typeof(string));
            propertyView.Columns.Add("Value", typeof(string));
            peptideSpectralMatchesView = CollectionViewSource.GetDefaultView(filteredListOfPsms);
            dataGridScanNums.DataContext = peptideSpectralMatchesView;
            dataGridProperties.DataContext = propertyView.DefaultView;
            Title = "MetaDraw: version " + GlobalVariables.MetaMorpheusVersion;
            spectraFileManager = new MyFileManager(true);
            SetUpDictionaries();
            modificationAnnotationColor = Brushes.Yellow;
            metaDrawGraphicalSettings = new MetaDrawGraphicalSettings();
            metaDrawFilterSettings = new MetaDrawFilterSettings();
            base.Closing += this.OnClosing;

            ParentChildScanView.Visibility = Visibility.Collapsed;
            ParentScanView.Visibility = Visibility.Collapsed;

            plotTypes = new ObservableCollection<string>();
            SetUpPlots();
            //plotsListBox.ItemsSource = plotTypes;
        }
Пример #2
0
 public void AddNewRow(PsmAnnotationViewModel psmAnnotationViewModel, string annotation)
 {
     Data.Add(new ItemsControlSampleData()
     {
         PsmAnnotationViewModel = psmAnnotationViewModel, SpectrumLabel = annotation
     });
 }
Пример #3
0
        public MetaDraw()
        {
            InitializeComponent();

            mainViewModel          = new PsmAnnotationViewModel();
            plotView.DataContext   = mainViewModel;
            peptideSpectralMatches = new ObservableCollection <MetaDrawPsm>();
            propertyView           = new DataTable();
            propertyView.Columns.Add("Name", typeof(string));
            propertyView.Columns.Add("Value", typeof(string));
            peptideSpectralMatchesView     = CollectionViewSource.GetDefaultView(peptideSpectralMatches);
            dataGridScanNums.DataContext   = peptideSpectralMatchesView;
            dataGridProperties.DataContext = propertyView.DefaultView;
            Title = "MetaDraw: version " + GlobalVariables.MetaMorpheusVersion;
            spectraFileManager = new MyFileManager(true);
        }
Пример #4
0
        public MetaDraw()
        {
            UsefulProteomicsDatabases.Loaders.LoadElements();

            InitializeComponent();

            itemsControlSampleViewModel = new ItemsControlSampleViewModel();
            DataContext          = itemsControlSampleViewModel;
            mainViewModel        = new PsmAnnotationViewModel();
            plotView.DataContext = mainViewModel;
            allPsms            = new ObservableCollection <PsmFromTsv>();
            filteredListOfPsms = new ObservableCollection <PsmFromTsv>();
            proteinTree        = new ObservableCollection <ProteinForTreeView>();
            filteredTree       = new ObservableCollection <ProteinForTreeView>();
            propertyView       = new DataTable();
            propertyView.Columns.Add("Name", typeof(string));
            propertyView.Columns.Add("Value", typeof(string));
            psmsWithMatch = new List <PsmFromTsv>();
            proteinTreeView.DataContext    = proteinTree;
            dataGridProperties.DataContext = propertyView.DefaultView;
            Title = "MetaDraw: version " + GlobalVariables.MetaMorpheusVersion;
            spectraFileManager = new MyFileManager(true);
            SetUpDictionaries();
            variantCrossColor               = Colors.Green;
            modificationAnnotationColor     = Brushes.Orange;
            metaDrawGraphicalSettings       = new MetaDrawGraphicalSettings();
            metaDrawFilterSettings          = new MetaDrawFilterSettings();
            SearchModifications.Timer.Tick += new EventHandler(searchBox_TextChangedHandler);
            base.Closing += this.OnClosing;

            ParentChildScanView.Visibility = Visibility.Collapsed;
            ParentScanView.Visibility      = Visibility.Collapsed;
            mapViewer.Visibility           = Visibility.Collapsed;
            legend.Visibility = Visibility.Collapsed;

            plotTypes = new ObservableCollection <string>();
            proteases = new string[1] {
                "trypsin"
            };

            SetUpPlots();
            //plotsListBox.ItemsSource = plotTypes;
            ChangeMapScrollViewSize();
        }
Пример #5
0
        private void PDFButton_Click(object sender, RoutedEventArgs e)
        {
            PsmFromTsv tempPsm = null;

            if (dataGridScanNums.SelectedCells.Count == 0)
            {
                MessageBox.Show("Please select at least one scan to export");
            }
            else
            {
                int numberOfScansToExport = dataGridScanNums.SelectedItems.Count;

                foreach (object selectedItem in dataGridScanNums.SelectedItems)
                {
                    PsmFromTsv psm = (PsmFromTsv)selectedItem;

                    if (tempPsm == null)
                    {
                        tempPsm = psm;
                    }

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

                    string myString = illegalInFileName.Replace(psm.FullSequence, "");

                    if (myString.Length > 30)
                    {
                        myString = myString.Substring(0, 30);
                    }

                    string filePath = Path.Combine(Path.GetDirectoryName(tsvResultsFilePath), "MetaDrawExport", psm.Ms2ScanNumber + "_" + myString + ".pdf");
                    string dir      = Path.GetDirectoryName(filePath);

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

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

                    // if this spectrum has child scans, draw them in the "advanced" tab
                    if ((psm.ChildScanMatchedIons != null && psm.ChildScanMatchedIons.Count > 0) ||
                        (psm.BetaPeptideChildScanMatchedIons != null && psm.BetaPeptideChildScanMatchedIons.Count > 0))
                    {
                        // draw child scans
                        HashSet <int> scansDrawn = new HashSet <int>();
                        var           allChildScanMatchedIons = psm.ChildScanMatchedIons;
                        if (psm.BetaPeptideChildScanMatchedIons != null)
                        {
                            allChildScanMatchedIons = allChildScanMatchedIons.Concat(psm.BetaPeptideChildScanMatchedIons).ToDictionary(p => p.Key, q => q.Value);
                        }
                        foreach (var childScanMatchedIons in allChildScanMatchedIons)
                        {
                            int scanNumber = childScanMatchedIons.Key;

                            if (scansDrawn.Contains(scanNumber))
                            {
                                continue;
                            }
                            scansDrawn.Add(scanNumber);

                            List <MatchedFragmentIon> matchedIons = childScanMatchedIons.Value;

                            var        childPsmModel = new PsmAnnotationViewModel();
                            MsDataScan childScan     = MsDataFile.GetOneBasedScan(scanNumber);

                            childPsmModel.DrawPeptideSpectralMatch(childScan, psm, metaDrawGraphicalSettings.ShowMzValues,
                                                                   metaDrawGraphicalSettings.ShowAnnotationCharges, metaDrawGraphicalSettings.AnnotatedFontSize, metaDrawGraphicalSettings.BoldText);

                            string childfilePath = Path.Combine(Path.GetDirectoryName(tsvResultsFilePath), "MetaDrawExport", childScan.OneBasedScanNumber + "_" + myString + ".pdf");

                            DrawPdfAnnotatedBaseSequence(psm, canvas, childfilePath); // captures the annotation for the pdf
                            childPsmModel.DrawPeptideSpectralMatchPdf(childScan, psm, childfilePath, false);
                        }
                    }
                }

                dataGridScanNums.SelectedItem = dataGridScanNums.SelectedItem;

                itemsControlSampleViewModel.Data.Clear();
                DrawPsm(tempPsm.Ms2ScanNumber, tempPsm.FullSequence);

                MessageBox.Show(string.Format("{0} PDFs exported", numberOfScansToExport));
            }
        }
Пример #6
0
        private void DrawPsm(int oneBasedScanNumber, string fullSequence = null, string fileName = null)
        {
            MsDataScan msDataScanToDraw       = MsDataFile.GetOneBasedScan(oneBasedScanNumber);
            IEnumerable <PsmFromTsv> scanPsms = filteredListOfPsms.Where(p => p.Ms2ScanNumber == oneBasedScanNumber);

            if (fullSequence != null)
            {
                scanPsms = scanPsms.Where(p => p.FullSequence == fullSequence);
            }

            PsmFromTsv psmToDraw = scanPsms.FirstOrDefault();

            // if this spectrum has child scans, draw them in the "advanced" tab
            if ((psmToDraw.ChildScanMatchedIons != null && psmToDraw.ChildScanMatchedIons.Count > 0) ||
                (psmToDraw.BetaPeptideChildScanMatchedIons != null && psmToDraw.BetaPeptideChildScanMatchedIons.Count > 0))
            {
                ParentChildScanView.Visibility = Visibility.Visible;
                ParentScanView.Visibility      = Visibility.Visible;

                // draw parent scans
                var        parentPsmModel = new PsmAnnotationViewModel();
                MsDataScan parentScan     = MsDataFile.GetOneBasedScan(psmToDraw.Ms2ScanNumber);

                parentPsmModel.DrawPeptideSpectralMatch(parentScan, psmToDraw, metaDrawGraphicalSettings.ShowMzValues,
                                                        metaDrawGraphicalSettings.ShowAnnotationCharges, metaDrawGraphicalSettings.AnnotatedFontSize, metaDrawGraphicalSettings.BoldText);

                string parentAnnotation = "Scan: " + parentScan.OneBasedScanNumber.ToString()
                                          + " Dissociation Type: " + parentScan.DissociationType.ToString()
                                          + " MsOrder: " + parentScan.MsnOrder.ToString()
                                          + " Selected Mz: " + parentScan.SelectedIonMZ.Value.ToString("0.##")
                                          + " Retention Time: " + parentScan.RetentionTime.ToString("0.##");

                itemsControlSampleViewModel.AddNewRow(parentPsmModel, parentAnnotation, null);

                // draw child scans
                HashSet <int> scansDrawn = new HashSet <int>();
                var           allChildScanMatchedIons = psmToDraw.ChildScanMatchedIons;
                if (psmToDraw.BetaPeptideChildScanMatchedIons != null)
                {
                    allChildScanMatchedIons = allChildScanMatchedIons.Concat(psmToDraw.BetaPeptideChildScanMatchedIons).ToDictionary(p => p.Key, q => q.Value);
                }
                foreach (var childScanMatchedIons in allChildScanMatchedIons)
                {
                    int scanNumber = childScanMatchedIons.Key;

                    if (scansDrawn.Contains(scanNumber))
                    {
                        continue;
                    }
                    scansDrawn.Add(scanNumber);

                    List <MatchedFragmentIon> matchedIons = childScanMatchedIons.Value;

                    var        childPsmModel = new PsmAnnotationViewModel();
                    MsDataScan childScan     = MsDataFile.GetOneBasedScan(scanNumber);

                    childPsmModel.DrawPeptideSpectralMatch(childScan, psmToDraw, metaDrawGraphicalSettings.ShowMzValues,
                                                           metaDrawGraphicalSettings.ShowAnnotationCharges, metaDrawGraphicalSettings.AnnotatedFontSize, metaDrawGraphicalSettings.BoldText);

                    string childAnnotation = "Scan: " + scanNumber.ToString()
                                             + " Dissociation Type: " + childScan.DissociationType.ToString()
                                             + " MsOrder: " + childScan.MsnOrder.ToString()
                                             + " Selected Mz: " + childScan.SelectedIonMZ.Value.ToString("0.##")
                                             + " RetentionTime: " + childScan.RetentionTime.ToString("0.##");

                    Canvas aCanvas = new Canvas {
                        Height = 60
                    };
                    DrawAnnotatedBaseSequence(aCanvas, psmToDraw, true);

                    itemsControlSampleViewModel.AddNewRow(childPsmModel, childAnnotation, aCanvas);
                }
            }
            else
            {
                ParentChildScanView.Visibility = Visibility.Collapsed;
                ParentScanView.Visibility      = Visibility.Collapsed;
            }

            // if this is a crosslink spectrum match, there are two base sequence annotations to draw
            // this makes the canvas taller to fit both of these peptide sequences
            if (psmToDraw.BetaPeptideBaseSequence != null)
            {
                int height = 150;

                canvas.Height = height;
                PsmAnnotationGrid.RowDefinitions[1].Height = new GridLength(height);
            }
            else
            {
                int height = 60;

                canvas.Height = height;
                PsmAnnotationGrid.RowDefinitions[1].Height = new GridLength(height);
            }

            // draw annotated spectrum
            mainViewModel.DrawPeptideSpectralMatch(msDataScanToDraw, psmToDraw, metaDrawGraphicalSettings.ShowMzValues,
                                                   metaDrawGraphicalSettings.ShowAnnotationCharges, metaDrawGraphicalSettings.AnnotatedFontSize, metaDrawGraphicalSettings.BoldText);

            // draw annotated base sequence
            DrawAnnotatedBaseSequence(canvas, psmToDraw);
        }
Пример #7
0
 public void AddNewRow(PsmAnnotationViewModel psmAnnotationViewModel, string annotation, Canvas canvas)
 {
     Data.Add(new ItemsControlSampleData {
         PsmAnnotationViewModel = psmAnnotationViewModel, SpectrumLabel = annotation, TheCanvas = canvas
     });
 }