private void OutputMassSpectrum(string outputFolder, XYData massSpectrumXYData, TargetBase target, SipperLcmsTargetedResult sipperLcmsTargetedResult)
        {
            var msGraphGenerator = new MSGraphControl();

            msGraphGenerator.SymbolType = SymbolType.None;

            if (massSpectrumXYData == null)
            {
                massSpectrumXYData         = new XYData();
                massSpectrumXYData.Xvalues = new double[] { 0, 1, 2, 3, 4, 5 };
                massSpectrumXYData.Yvalues = new double[] { 0, 1, 2, 3, 4, 5 };
            }


            msGraphGenerator.GenerateGraph(massSpectrumXYData.Xvalues, massSpectrumXYData.Yvalues, target.MZ - 2,
                                           target.MZ + 6);

            var annotation = "fractionC13= " + sipperLcmsTargetedResult.PercentCarbonsLabelled.ToString("0.000") + "\n" +
                             "populationFraction= " + sipperLcmsTargetedResult.PercentPeptideLabelled.ToString("0.000");


            msGraphGenerator.AddAnnotationRelativeAxis(annotation, 0.45, 0.05);

            var outputFilename = Path.Combine(outputFolder, target.ID + "_MS.png");

            msGraphGenerator.SaveGraph(outputFilename);
        }
            public MSGraphPane GetOrCreateGraphPane(MSGraphControl graphControl, PaneKey graphPaneKey)
            {
                var pane = GetGraphPane(graphControl, graphPaneKey);

                if (null != pane)
                {
                    return(pane);
                }
                if (GraphPaneKeys.Count == 0)
                {
                    GraphPaneKeys.Add(graphPaneKey);
                    pane = graphControl.GraphPane;
                    ApplySettingsToGraphPane(pane);
                    return(pane);
                }
                int index     = GraphPaneKeys.BinarySearch(graphPaneKey);
                int iInsert   = ~index;
                var graphPane = InsertMsGraphPane(graphControl, iInsert);

                GraphPaneKeys.Insert(iInsert, graphPaneKey);
                using (var graphics = graphControl.CreateGraphics())
                {
                    graphControl.MasterPane.SetLayout(graphics, PaneLayout.SingleColumn);
                }
                return(graphPane);
            }
        public static GraphHelper Attach(MSGraphControl msGraphControl)
        {
            GraphHelper graphHelper = new GraphHelper(msGraphControl);

            msGraphControl.MasterPane.Border.IsVisible = false;
            msGraphControl.GraphPane.Border.IsVisible  = false;
            msGraphControl.GraphPane.AllowCurveOverlap = true;
            return(graphHelper);
        }
Exemple #4
0
 public IsotopeDistributionForm(Workspace workspace) : base(workspace)
 {
     InitializeComponent();
     _msGraphControl = new MSGraphControlEx {
         Dock = DockStyle.Fill
     };
     _msGraphControl.GraphPane.XAxis.Title.Text = "M/Z";
     _msGraphControl.GraphPane.YAxis.Title.Text = "Intensity";
     colMass.DefaultCellStyle.Format            = "0.######";
     colIntensity.DefaultCellStyle.Format       = "0.######";
     splitContainer1.Panel2.Controls.Add(_msGraphControl);
 }
            public MSGraphPane GetGraphPane(MSGraphControl graphControl, PaneKey graphPaneKey)
            {
                if (!AllowSplitPanes)
                {
                    return(graphControl.GraphPane);
                }
                int index = GraphPaneKeys.BinarySearch(graphPaneKey);

                if (index >= 0)
                {
                    return((MSGraphPane)graphControl.MasterPane.PaneList[index]);
                }
                return(null);
            }
Exemple #6
0
        public SpectrumViewer(string filename, object index, string interpretation)
        {
            // Prepare the annotation
            annotation = new PeptideFragmentationAnnotation(interpretation, 1, 2, false, true, false, false, true, false, false, true, false, true);
            annotation.OptionsPanel.Dock = DockStyle.None;
            annotation.OptionsPanel.Dock = DockStyle.Fill;

            // Get the mass spectrum
            spectrum = SpectrumCache.GetMassSpectrum(filename, index);
            if (spectrum == null)
            {
                return;
            }

            // Add annotation to the mass spectrum and get a new graph control
            spectrum.AnnotationList.Clear();
            spectrum.AnnotationList.Add((IAnnotation)annotation);
            graph = new MSGraphControl();
            graph.AddGraphItem(graph.GraphPane, spectrum);
            graph.Dock = DockStyle.Fill;


            // Create new panels and add the graph and annotations
            spectrumPanel = new Panel();
            spectrumPanel.Controls.Add(graph);
            spectrumPanel.Dock = DockStyle.None;
            spectrumPanel.Dock = DockStyle.Fill;
            annotationPanel    = new Panel();
            annotationPanel.Controls.Add(annotation.OptionsPanel);
            annotationPanel.Dock = DockStyle.None;
            annotationPanel.Dock = DockStyle.Fill;
            fragmentationPanel   = new Panel();
            annotation.FragmentInfoGridView.Location    = new Point(0, 0);
            annotation.FragmentInfoGridView.ScrollBars  = ScrollBars.Both;
            annotation.FragmentInfoGridView.Dock        = DockStyle.None;
            annotation.FragmentInfoGridView.Dock        = DockStyle.Fill;
            annotation.FragmentInfoGridView.BorderStyle = BorderStyle.FixedSingle;
            fragmentationPanel.Controls.Add(annotation.FragmentInfoGridView);
            fragmentationPanel.Dock = DockStyle.None;
            fragmentationPanel.Dock = DockStyle.Fill;

            // Add the call back for refreshing
            annotation.OptionsChanged += new EventHandler(OnOptionsChanged);
        }
            private MSGraphPane InsertMsGraphPane(MSGraphControl graphControl, int iInsert)
            {
                var pane = new MSGraphPane
                {
                    Border            = { IsVisible = false },
                    AllowCurveOverlap = true,
                };

                ApplySettingsToGraphPane(pane);
                var primaryPane = graphControl.GraphPane;

                pane.CurrentItemType = primaryPane.CurrentItemType;
                pane.ZoomStack.AddRange(primaryPane.ZoomStack);
                var zoomState = new ZoomState(primaryPane, ZoomState.StateType.Zoom);

                zoomState.ApplyState(pane);
                pane.YAxis.Title.Text = primaryPane.YAxis.Title.Text;
                pane.XAxis.Title.Text = primaryPane.XAxis.Title.Text;
                graphControl.MasterPane.PaneList.Insert(iInsert, pane);
                return(pane);
            }
Exemple #8
0
        public OpenDataSourceDialog()
        {
            InitializeComponent();

            listViewColumnSorter        = new ListViewColumnSorter();
            listView.ListViewItemSorter = listViewColumnSorter;

            DialogResult = DialogResult.Cancel;

            string[] sourceTypes = new string[]
            {
                "Any spectra format",
                "mzML",
                //"mzData",
                "mzXML",
                "mz5",
                "Thermo RAW",
                "Waters RAW",
                "ABSciex WIFF",
                //"Bruker/Agilent YEP",
                //"Bruker BAF",
                //"Bruker FID",
                "Bruker Analysis",
                "Agilent MassHunter",
                "Mascot Generic",
                "Bruker Data Exchange",
                //"Sequest DTA"
            };

            sourceTypeComboBox.Items.AddRange(sourceTypes);
            sourceTypeComboBox.SelectedIndex = 0;

            ImageList smallImageList = new ImageList();

            smallImageList.ColorDepth = ColorDepth.Depth32Bit;
            smallImageList.Images.Add(Properties.Resources.folder);
            smallImageList.Images.Add(Properties.Resources.file);
            smallImageList.Images.Add(Properties.Resources.DataProcessing);
            listView.SmallImageList = smallImageList;

            TreeView tv = new TreeView();

            tv.Indent = 8;
            TreeNode lookInNode = tv.Nodes.Add("My Recent Documents", "My Recent Documents", 0, 0);

            lookInNode.Tag = lookInNode.Text;
            lookInComboBox.Items.Add(lookInNode);
            TreeNode desktopNode = tv.Nodes.Add("Desktop", "Desktop", 1, 1);

            desktopNode.Tag = desktopNode.Text;
            lookInComboBox.Items.Add(desktopNode);
            lookInNode     = desktopNode.Nodes.Add("My Documents", "My Documents", 2, 2);
            lookInNode.Tag = lookInNode.Text;
            lookInComboBox.Items.Add(lookInNode);
            TreeNode myComputerNode = desktopNode.Nodes.Add("My Computer", "My Computer", 3, 3);

            myComputerNode.Tag = myComputerNode.Text;
            lookInComboBox.Items.Add(myComputerNode);
            lookInComboBox.SelectedIndex  = 1;
            lookInComboBox.IntegralHeight = false;
            lookInComboBox.DropDownHeight = lookInComboBox.Items.Count * lookInComboBox.ItemHeight + 2;

            ticGraphControl = new MSGraphControl()
            {
                Dock = DockStyle.Fill,
            };
            ticGraphControl.GraphPane.Legend.IsVisible = false;
            ticGraphControl.Visible = false;
            splitContainer1.Panel2.Controls.Add(ticGraphControl);
            splitContainer1.Panel2Collapsed = false;
        }
        public OpenDataSourceDialog()
        {
            InitializeComponent();

            listViewColumnSorter        = new ListViewColumnSorter();
            listView.ListViewItemSorter = listViewColumnSorter;

            DialogResult = DialogResult.Cancel;

            var sourceTypes = new List <string>();

            foreach (var typeExtsPair in ReaderList.FullReaderList.getFileExtensionsByType())
            {
                if (typeExtsPair.Value.Count > 0) // e.g. exclude UNIFI
                {
                    sourceTypes.Add(typeExtsPair.Key);
                }
            }
            sourceTypes.Sort();
            sourceTypes.Insert(0, "Any spectra format");

            sourceTypeComboBox.Items.AddRange(sourceTypes.ToArray());
            sourceTypeComboBox.SelectedIndex = 0;

            ImageList smallImageList = new ImageList();

            smallImageList.ColorDepth = ColorDepth.Depth32Bit;
            smallImageList.Images.Add(Properties.Resources.folder);
            smallImageList.Images.Add(Properties.Resources.file);
            smallImageList.Images.Add(Properties.Resources.DataProcessing);
            listView.SmallImageList = smallImageList;

            TreeView tv = new TreeView();

            tv.Indent = 8;
            TreeNode lookInNode = tv.Nodes.Add("My Recent Documents", "My Recent Documents", 0, 0);

            lookInNode.Tag = lookInNode.Text;
            lookInComboBox.Items.Add(lookInNode);
            TreeNode desktopNode = tv.Nodes.Add("Desktop", "Desktop", 1, 1);

            desktopNode.Tag = desktopNode.Text;
            lookInComboBox.Items.Add(desktopNode);
            lookInNode     = desktopNode.Nodes.Add("My Documents", "My Documents", 2, 2);
            lookInNode.Tag = lookInNode.Text;
            lookInComboBox.Items.Add(lookInNode);
            TreeNode myComputerNode = desktopNode.Nodes.Add("My Computer", "My Computer", 3, 3);

            myComputerNode.Tag = myComputerNode.Text;
            lookInComboBox.Items.Add(myComputerNode);
            lookInComboBox.SelectedIndex  = 1;
            lookInComboBox.IntegralHeight = false;
            lookInComboBox.DropDownHeight = lookInComboBox.Items.Count * lookInComboBox.ItemHeight + 2;

            ticGraphControl = new MSGraphControl()
            {
                Dock = DockStyle.Fill,
            };
            ticGraphControl.GraphPane.Legend.IsVisible = false;
            ticGraphControl.Visible = false;
            splitContainer1.Panel2.Controls.Add(ticGraphControl);
            splitContainer1.Panel2Collapsed = false;
        }
Exemple #10
0
        public const string scientificNotationFormatString = "0.0#####e0"; // Not L10N

        public GraphHelper(MSGraphControl msGraphControl)
        {
            GraphControl  = msGraphControl;
            _displayState = new ErrorDisplayState();
        }
Exemple #11
0
        /// <summary>
        /// Selects a peptide and then changes chromatogram "Transform" and "Transition" settings.
        /// </summary>
        private void TestPeptide(PeptideGroupDocNode peptideGroup, PeptideDocNode peptide)
        {
            RunUI(() => SkylineWindow.SelectedPath  = new IdentityPath(peptideGroup.Id, peptide.Id));
            Settings.Default.SplitChromatogramGraph = false;
            RunUI(() => SkylineWindow.SetDisplayTypeChrom(DisplayTypeChrom.all));
            WaitForGraphs();

            var            graphChrom   = FindOpenForm <GraphChromatogram>();
            MSGraphControl graphControl = (MSGraphControl)graphChrom.Controls.Find("graphControl", true).First();

            if (peptide.TransitionGroupCount <= 1)
            {
                // When a peptide with one transition group is seleted, then all transitions should be displayed
                Assert.AreEqual(peptide.TransitionCount, GetChromatogramCount(graphControl.GraphPane));
            }
            else
            {
                // If the peptide has more than one transition group, then only transition groups are displayed
                // when the peptide is selected.
                Assert.AreEqual(peptide.TransitionGroupCount, GetChromatogramCount(graphControl.GraphPane));
            }

            // When Display Type is set to "total", there is one curve per transition group.
            RunUI(() => SkylineWindow.SetDisplayTypeChrom(DisplayTypeChrom.total));
            WaitForGraphs();
            Assert.AreEqual(peptide.TransitionGroupCount, GetChromatogramCount(graphControl.GraphPane));

            foreach (var transitionGroup in peptide.TransitionGroups)
            {
                string message             = peptide.ModifiedTarget.ToString() + ' ' + transitionGroup.PrecursorMz + ' ' + Settings.Default.TransformTypeChromatogram;
                var    transitionGroupPath = new IdentityPath(peptideGroup.Id, peptide.Id, transitionGroup.Id);
                RunUI(() => SkylineWindow.SelectedPath = transitionGroupPath);

                // Verify that "Split Graph" produces the correct number of panes.
                Settings.Default.SplitChromatogramGraph = true;
                RunUI(() => SkylineWindow.SetDisplayTypeChrom(DisplayTypeChrom.all));
                WaitForGraphs();
                if (transitionGroup.GetMsTransitions(true).Any() && transitionGroup.GetMsMsTransitions(true).Any())
                {
                    Assert.AreEqual(2, graphControl.MasterPane.PaneList.Count, message);
                }
                else
                {
                    Assert.AreEqual(1, graphControl.MasterPane.PaneList.Count, message);
                }

                int countTrans = 0;
                foreach (var transition in transitionGroup.Transitions)
                {
                    if (++countTrans >= 5)  // Selecting absolutely everything makes this a pretty long test (this cuts time in half)
                    {
                        break;
                    }

                    var transitionPath = new IdentityPath(transitionGroupPath, transition.Id);
                    RunUI(() => SkylineWindow.SelectedPath = transitionPath);
                    RunUI(() => SkylineWindow.SetDisplayTypeChrom(DisplayTypeChrom.single));
                    WaitForGraphs();
                    Assert.AreEqual(1, graphControl.MasterPane.PaneList.Count);
                    if (1 != GetChromatogramCount(graphControl.GraphPane))
                    {
                        Assert.AreEqual(1, GetChromatogramCount(graphControl.GraphPane));
                    }
                    RunUI(() => SkylineWindow.SetDisplayTypeChrom(DisplayTypeChrom.total));
                }
            }
        }