Ejemplo n.º 1
0
        private void DrawPsm(int oneBasedScanNumber, string fullSequence = null)
        {
            MsDataScan msDataScanToDraw        = MsDataFile.GetOneBasedScan(oneBasedScanNumber);
            IEnumerable <MetaDrawPsm> scanPsms = peptideSpectralMatches.Where(p => p.ScanNum == oneBasedScanNumber);

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

            MetaDrawPsm psmToDraw = scanPsms.FirstOrDefault();

            // draw annotated spectrum
            mainViewModel.DrawPeptideSpectralMatch(msDataScanToDraw, psmToDraw);

            // draw annotated base sequence
            DrawAnnotatedBaseSequence(psmToDraw);
        }
Ejemplo n.º 2
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));
            }
        }
Ejemplo n.º 3
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);
        }