Esempio n. 1
0
        private void TestPointsAcrossPeak()
        {
            RunUI(() =>
            {
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath("WormUnrefined.sky"));
                SkylineWindow.SetDisplayTypeChrom(DisplayTypeChrom.all);
                SkylineWindow.ArrangeGraphs(DisplayGraphsType.Tiled);
                SkylineWindow.ActivateReplicate("1");
            });
            WaitForDocumentLoaded();
            WaitForGraphs();

            var doc         = SkylineWindow.Document;
            var pathToGroup = doc.GetPathTo((int)SrmDocument.Level.TransitionGroups, 0);

            RunUI(() => SkylineWindow.SelectPath(pathToGroup));
            WaitForGraphs();

            var nodeGroup = (TransitionGroupDocNode)doc.FindNode(pathToGroup);

            VerifyGraphItemsCorrect(nodeGroup, pathToGroup, true);
            RunUI(() => SkylineWindow.ToggleRawTimesMenuItem());
            WaitForGraphs();
            VerifyGraphItemsCorrect(nodeGroup, pathToGroup, false);
        }
Esempio n. 2
0
        protected override void DoTest()
        {
            RunUI(() => SkylineWindow.SetUIMode(SrmDocument.DOCUMENT_TYPE.small_molecules));

            //   •	On the Settings menu, click Default.
            //   •	Click No on the form asking if you want to save the current settings.
            RunUI(() => SkylineWindow.ResetDefaultSettings());

            var doc = SkylineWindow.Document;

            //   •	On the Settings menu, click Transition Settings.
            //   •	Click the Filter tab.
            var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(() =>
                                                                         SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.Filter));

            //   •	This data was collected in negative ionization mode so [M+H] and[M +] can be removed from the Precursor Adducts and Fragment Adducts fields. However, they are harmless if left as is since the library we will use has only negative ion mode entries.
            //   •	In the Precursor Adducts field, enter “[M-H], [M+HCOO], [M+CH3COO]”.
            //   •	In the Fragment Adducts field, enter “[M-]”.
            RunUI(() =>
            {
                transitionSettingsUI.SmallMoleculePrecursorAdducts = "[M-H], [M+HCOO], [M+CH3COO]";
                transitionSettingsUI.SmallMoleculeFragmentAdducts  = "[M-]";
                transitionSettingsUI.SmallMoleculeFragmentTypes    = "f, p";
                transitionSettingsUI.Left = SkylineWindow.Right + 20;
            });
            //   •	The Transition Settings form should now look like this:
            PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings: Filter", 3);

            RunUI(() =>
            {
                //   •	Click the Full-Scan tab in the Transition Settings form.
                transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.FullScan;
                //   •	 In the MS1 filtering section, set the Isotope peaks included field to Count.
                transitionSettingsUI.PrecursorIsotopesCurrent = FullScanPrecursorIsotopes.Count;
                //   •	Set the Precursor mass analyzer field to TOF.
                transitionSettingsUI.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof;
                //   •	Enter “20,000” in the Resolving power field.
                transitionSettingsUI.PrecursorRes = 20000;
                //   •	In the MS/MS filtering section, set the Acquisition method field to DIA.
                transitionSettingsUI.AcquisitionMethod = FullScanAcquisitionMethod.DIA;
                //   •	Set the Isolation scheme field to All Ions.
                transitionSettingsUI.IsolationSchemeName = IsolationScheme.SpecialHandlingType.ALL_IONS;
                //   •	Enter “20,000” in the Resolving power field.
                transitionSettingsUI.ProductRes = 20000;
                //   •	Check Use high-selectivity extraction.
                transitionSettingsUI.UseSelectiveExtraction = true;
            });

            //   The Transition Settings form should look like this:
            PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Transition Settings - Full-Scan", 4);
            //   •	Click the OK button.
            OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            doc = WaitForDocumentChange(doc);

            //   Adding and Exploring a Spectral Library
            // Before you can explore the library, Skyline must be directed to its location by adding your library of interest to the global list of libraries for document editing.
            //   To get started with the small molecule library containing Drosophila lipids perform the following steps:
            //   •	From the Settings menu, click Molecule Settings.
            //   •	Click the Library tab.
            var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(() =>
                                                                   SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Library));
            //   •	Click the Edit List button.
            var libListDlg =
                ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(peptideSettingsUI.EditLibraryList);
            //   •	Click the Add button in the Edit Libraries form.
            var addLibDlg        = ShowDialog <EditLibraryDlg>(libListDlg.AddItem);
            var drosophilaLipids = "Drosophila Lipids";

            RunUI(() =>
            {
                //   •	Enter “Drosophila Lipids” in the Name field of the Edit Library form.
                addLibDlg.LibraryName = drosophilaLipids;
                //   •	Click the Browse button.
                //   •	Navigate to the SmallMoleculeLibraries folder created earlier.
                //   •	Select the “Drosophila_Lipids_Neg.blib” file.
                addLibDlg.LibraryPath = GetFullDataPath("Drosophila_Lipids_Neg.blib");
            });
            //   •	Click the Open button.
            //   •	Click the OK button in the Edit Library form.
            OkDialog(addLibDlg, addLibDlg.OkDialog);
            //   •	Click the OK button in the Edit Libraries form.
            OkDialog(libListDlg, libListDlg.OkDialog);

            //   The Libraries list in the Molecule Settings form should now contain the Drosophila Lipids library you just created.
            //   •	Check the Drosophila Lipids checkbox to tell Skyline to use this library in the current document.
            //   •	If you have any other libraries in this list checked, uncheck them now.
            RunUI(() =>
            {
                peptideSettingsUI.PickedLibraries = new[] { drosophilaLipids };
                peptideSettingsUI.Left            = SkylineWindow.Right + 20;
            });
            //   The Molecule Settings form should now look like:
            PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Molecule Settings - Library", 6);
            //   •	Click the OK button in the Molecule Settings form.
            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
            doc = WaitForDocumentChangeLoaded(doc);

            //   To open the library explorer and view the contents of the library you just added, do the following:
            //   •	From the View menu, click Spectral Libraries.
            var viewLibUI = ShowDialog <ViewLibraryDlg>(SkylineWindow.ViewSpectralLibraries);

            RunUI(() =>
            {
                viewLibUI.Left = SkylineWindow.Right + 20;
                viewLibUI.Top  = SkylineWindow.Top;
            });

            //   The library explorer should now resemble the image below:
            PauseForScreenShot("Library Explorer (probably need to resize wider)", 7);

            //  To add all the molecules in the library to your target list:
            //   •	Click the Add All button.
            //   •	A popup window will then notify you that you will add 34 molecules, 38 precursors, and 246 transitions to the document. Click Add All.
            var confirmAddDlg = ShowDialog <AlertDlg>(viewLibUI.AddAllPeptides);

            using (new CheckDocumentState(1, 34, 38, 246))
            {
                RunUI(confirmAddDlg.OkDialog);
                doc = WaitForDocumentChangeLoaded(doc);
            }

            //   •	Close the Spectral Library Explorer window.
            OkDialog(viewLibUI, viewLibUI.CancelDialog);

            //   Your Skyline window should now resemble:
            RunUI(() => SkylineWindow.Size = new Size(951, 607));
            PauseForScreenShot("Populated Skyline window", 8);

            //Importing Results Chromatogram.Data
            //    In this section, you will import the Drosophila data without utilizing IMS filtering. This is an initial look at the data to see the impact of interference among lipids and their shared fragments. To import the data, perform the following steps:
            //   •	On the File menu, click Save (Ctrl+S).
            //   •	Save this document in the tutorial folder you created.
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDirs[0].GetTestPath("Tutorial.sky")));

            //   •	From the File menu, choose Import and click Results.
            using (new WaitDocumentChange(null, true))
            {
                var importResultsDlg1 = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                //   •	Set the Files to import simultaneously field to Many.
                //   •	Check Show chromatograms during import.
                //   The Import Results form will appear as follows:
                RunUI(() =>
                {
                    importResultsDlg1.Top  = SkylineWindow.Top;
                    importResultsDlg1.Left = SkylineWindow.Right + 20;
                });
                PauseForScreenShot <ImportResultsDlg>("Import Results", 9);
                var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets =
                                                                                  importResultsDlg1.GetDataSourcePathsFile(null));
                //   •	Click the OK button.
                //   The Import Results Files form will now show the.d files you have extracted into the tutorial folder:
                //   •	Select both .d files.
                RunUI(() =>
                {
                    var path = Path.GetDirectoryName(GetFullDataPath(Flies_M));
                    openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(path);
                    openDataSourceDialog1.SelectAllFileType(ExtAgilentRaw);
                    openDataSourceDialog1.Left = importResultsDlg1.Left;
                    openDataSourceDialog1.Top  = importResultsDlg1.Bottom + 10;
                });
                PauseForScreenShot <OpenDataSourceDialog>("Import Results Files selection form", 10);
                OkDialog(openDataSourceDialog1, openDataSourceDialog1.Open);

                //   •	Click the Open button.
                //   •	The Import Results window will ask if you would like to remove the common prefix and suffix to shorten the file names used in Skyline.Click OK to accept the names “F_A_018” and “M_A_001”.
                //This should start the import and cause Skyline to show the Importing Results progress form:
                var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg1.OkDialog);
                OkDialog(importResultsNameDlg, importResultsNameDlg.OkDialog);
                var allChromatograms = WaitForOpenForm <AllChromatogramsGraph>();
                RunUI(() =>
                {
                    allChromatograms.Top  = SkylineWindow.Top;
                    allChromatograms.Left = SkylineWindow.Right + 20;
                });
                PauseForScreenShot <AllChromatogramsGraph>("Importing results form", 11);
            }

            WaitForGraphs();

            //Reviewing the Extracted Ion Chromatograms
            //    Once the files are imported, you can examine the chromatograms to evaluate interference from peaks with retention times and m/z values within the tolerance of your target list.
            RunUI(() =>
            {
                //   •	From the Edit menu, choose Expand All and click Molecules (Ctrl+D).
                SkylineWindow.ExpandPeptides();
                SkylineWindow.SetDisplayTypeChrom(DisplayTypeChrom.all);
                //   •	From the View menu, choose Arrange Graphs and click Tiled (Ctrl+T).
                SkylineWindow.ArrangeGraphs(DisplayGraphsType.Row); // With just two panes, Tiled may go either row or column, force row
                //   •	Right-click in a chromatogram graph and click Synchronize Zooming(leave if already checked).
                SkylineWindow.SynchronizeZooming(true);
                // •	Right-click in a chromatogram graph and click Legend to hide the legend.
                SkylineWindow.ShowChromatogramLegends(false);
                //   •	Right-click in a chromatogram graph, choose Transitions and click Split Graph (leave if already checked).
                SkylineWindow.ShowSplitChromatogramGraph(true);
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.Size = new Size(1487, 786);
            });
            RunDlg <ChromChartPropertyDlg>(SkylineWindow.ShowChromatogramProperties, propDlg =>
            {
                propDlg.IsPeakWidthRelative = false;
                propDlg.TimeRange           = 7; // minutes
                propDlg.OkDialog();
            });
            //  •	Select the molecule PC(16:0_18:1) and your spectra should appear as:
            FindNode("PC(16:0_18:1)");
            PauseForScreenShot("Chromatograms - prtsc-paste-edit", 12);

            RestoreViewOnScreen(13);
            var libraryMatchView = WaitForOpenForm <GraphSpectrum>();

            RunUI(() => libraryMatchView.ZoomXAxis(100, 400));
            PauseForScreenShot("Library Match", 13);

            //Since there are only 38 precursors in this document, you may want to review all 38 to get an overall feel for how the XIC look prior to IMS filtering.Before starting this review, do the following:
            //   •	On the View menu, choose Retention Times and click Replicate Comparison (F8).
            //   •	Attach the Retention Times view to the left of the Library Match view by clicking in the title bar and dragging until the mouse cursor is inside the left-side docking icon.
            RunUI(() =>
            {
                SkylineWindow.ShowGraphRetentionTime(true, GraphTypeSummary.replicate);
                //   •	Right-click in the Retention Times view and click Legend to hide the legend in this graph.
                SkylineWindow.ShowRTLegend(false);
            });

            //   •	From the View menu, choose Peak Areas and click Replicate Comparison (F7).
            RestoreViewOnScreen(14);

            //   •	Attach the Peak Areas view above the Retention Times view by clicking in the title bar and dragging until the mouse cursor is inside the up-side docking icon.
            //    You should end up with a similar layout to that below:
            RunUI(() =>
            {
                SkylineWindow.Size = new Size(1310, 786);
            });
            if (IsPauseForScreenShots)
            {
                // Change selected node away and back to adjust graphs
                TreeNode selectedNode = null;
                RunUI(() => selectedNode = SkylineWindow.SequenceTree.SelectedNode);
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.NextNode);
                WaitForGraphs();
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = selectedNode);
                WaitForGraphs();
                PauseForScreenShot("Main window", 14);
            }

            //Skyline often does a good job picking peaks and most integration boundaries do not need to be edited.However, there are a few isomer pairs that require some manual peak picking.
            //    The first two cases are the lysophospholipids (LPC and LPE), which are phospholipids with one fatty acyl chain cleaved off.These molecules chromatographically separate depending on the sn- position of the single fatty acyl chain.Here the library match ID retention time markers can be utilized to determine the elution order of the LPC(0:0/18:2)/LPC(18:2/0:0) and LPE(0:0/16:0)/LPE(16:0/0:0) pairs.Drag the integration boundaries with your mouse to integrate the correct peaks.Note that male and female fruit flies have vastly different lysophospholipid profiles, which was also observed across almost all lysophospholipids in a larger Drosophila study.
            //    The final isomer pair is near the bottom of the document. PG(16:0_18:3) and PG(16:1_18:2) have different fatty acyl compositions, but the same total number of carbons and double bonds, causing them to share the same precursor formula and m/z value.Again, use the library match ID retention time markers to determine the correct peak for each lipid. To integrate the correct peaks, either drag the integration boundaries with your mouse or click the retention time above the peak apex.The product XIC may not be useful until IMS filtering is utilized.
            //

            //Understanding and Utilizing the IMS Separation
            //To this point, we have ignored the IMS dimension in this data.To better understand the IMS separation, you need to look at the underlying spectra from which these chromatograms were extracted by doing the following:
            //   •	On the View menu, choose Auto-Zoom and click Best Peak (F11).
            //   •	Select the molecule PE(16:1_18:3).
            FindNode("PE(16:1_18:3)");
            WaitForGraphs();
            RunDlg <ChromChartPropertyDlg>(SkylineWindow.ShowChromatogramProperties, propDlg =>
            {
                propDlg.IsPeakWidthRelative = true;
                propDlg.TimeRange           = 3.4; // widths
                propDlg.OkDialog();
            });
            WaitForGraphs();
            PauseForScreenShot("Chromatogram", 15);

            //   •	Hover the mouse cursor over the precursor chromatogram peak apex until a blue circle appears that tracks the mouse movement, and click on it.
            ClickChromatogram(F_A_018, 14.81, 162.1E3, PaneKey.PRECURSORS);
            //   This should bring up the Full-Scan view showing a familiar two-dimensional spectrum in profile mode:
            RunUI(() => SkylineWindow.GraphFullScan.SetSpectrum(true));
            RunUI(() => SkylineWindow.GraphFullScan.ZoomToSelection(true));
            PauseForScreenShot("2D plot", 16);

            //   •	Click the Show 2D Spectrum button  to change the plot to a three-dimensional spectrum with drift time.
            RunUI(() => SkylineWindow.GraphFullScan.SetSpectrum(false));
            PauseForScreenShot("3D plot", 16);

            //   •	Click the Zoom to Selection button to see the entire 3D MS1 spectrum at the selected retention time.
            RunUI(() => SkylineWindow.GraphFullScan.ZoomToSelection(false));
            PauseForScreenShot("3D plot full range", 17);

            //    This is a fairly typical MS1 spectrum for IMS-MS lipidomics data.You can get a better sense of the data by zooming into multiple areas on this plot.You can also select other lipids and click on the blue circle at the apex of each precursor chromatogram peak to see how this plot can differ with retention time. An interesting example is PE(O-18:0/16:1), which has distinct ion distributions showing correlations between m/z and drift time for different lipid classes.
            //    To inspect a relevant MS/MS spectrum:
            //   •	Re-select the molecule PE(16:1_18:3) if you navigated away from it to view other MS1 spectra.
            FindNode("PE(16:1_18:3)");
            //   •	Click on the Zoom to Selection button to zoom back in.
            RunUI(() => SkylineWindow.GraphFullScan.ZoomToSelection(true));
            WaitForGraphs();
            //   •	Hover the mouse over the FA 18:3(+O) fragment chromatogram peak apex until a teal colored circle appears that tracks the mouse movement, and click on it.
            ClickChromatogram(F_A_018, 14.83, 120.5E3, PaneKey.PRODUCTS);
            //   The Full-Scan graph should change to:
            RunUI(() => SkylineWindow.GraphFullScan.ZoomToSelection(true));
            PauseForScreenShot("3D plot MSMS zoomed", 18);


            //You can see that at least three visible ions are contributing to the extracted intensities at 33, 37, and 44 ms.This goes back to the nature of lipid fragmentation as previously discussed, where most lipids with an 18:3 fatty acyl chain will share this fragment.The complexity is increased for fatty acyl chains fragments with fewer double bonds, such as 18:2 at m/z 279, which may have multiple ions as well as isotopic overlap from the abundant 18:3 fragment at m/z 277 contributing to the extracted intensity.A similar observation can be made with the FA 16:1(+O) fragment.
            //   •	Click the Zoom to Selection button again to see the entire 3D MS/MS spectrum.
            RunUI(() => SkylineWindow.GraphFullScan.ZoomToSelection(false));
            PauseForScreenShot("3D plot MSMS full range", 18);


            //    Reimporting Data with Drift Time Filtering

            // Prior to changing the settings and reimporting the data, you may want to save the current Skyline document and create a second file in order to compare the data before and after IMS filtering. To do so:
            //    •	On the File menu, click Save As...
            //    •	Save the file with a different name than your original Skyline document, such as “Drosophila_Lipids_Neg_IMS_Filtered”, in the tutorial folder you created.
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDirs[0].GetTestPath(@"Drosophila_Lipids_Neg_IMS_Filtered.sky")));
            RunUI(() => SkylineWindow.Width -= 300);

            //   •	From the Settings menu, click Transition Settings.
            //   •	Click the Ion Mobility tab.
            transitionSettingsUI = ShowDialog <TransitionSettingsUI>(() =>
                                                                     SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.IonMobility));

            //   •	Check Use spectral library ion mobility values when present.
            //   •	Set the Window Type field to Resolving power.
            //   •	In the Resolving power field, enter “50”.
            RunUI(() =>
            {
                // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                transitionSettingsUI.IonMobilityControl.IsUseSpectralLibraryIonMobilities = true;
                transitionSettingsUI.IonMobilityControl.IonMobilityFilterResolvingPower   = 50;
                transitionSettingsUI.IonMobilityControl.WindowWidthType =
                    IonMobilityWindowWidthCalculator.IonMobilityWindowWidthType.resolving_power;
                transitionSettingsUI.Left = SkylineWindow.Right + 20;
            });
            //   •	The Transition Settings form should now look like this:
            PauseForScreenShot <TransitionSettingsUI.IonMobilityTab>("Transition Settings: IonMobility", 20);            //The Transition Settings should now look like:


            //   •	Click the OK button.
            OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            WaitForDocumentChange(doc);

            //   The results must now be reimported with the newly applied IMS settings.
            //   •	From the Edit menu, click Manage Results.
            //   •	Click the Re-import button. “*” Should appear to the left of F_A_018.
            //   •	Select M_A_001 in the Manage Results view.
            //   •	Click the Re-import button. “*” Should appear to the left of M_A_001.
            //   •	Click the OK button.
            doc = SkylineWindow.Document;
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, manageDlg =>
            {
                manageDlg.SelectedChromatograms = SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.ToArray();
                manageDlg.ReimportResults();
                manageDlg.OkDialog();
            });
            //   This should start the re-import and cause Skyline to show the Importing Results progress form.
            WaitForDocumentChangeLoaded(doc);

            //   •	Click any other lipid in the Target list and re-select PE(16:1_18:3) to update the chromatograms.
            FindNode("PC(16:0_18:1)");
            WaitForGraphs();
            FindNode("PE(16:1_18:3)");
            WaitForGraphs();
            //   To explore the filtered data, perform the following:
            //   •	Click on the apex of the blue precursor chromatogram to show the Full-Scan graph.
            //   •	Click the Zoom to Selection button.
            RunUI(() => SkylineWindow.GraphFullScan.ZoomToSelection(true));
            //   The Full-Scan graph should now look something like this:
            ClickChromatogram(F_A_018, 14.807, 152.0E3, PaneKey.PRECURSORS);

            if (IsCoverShotMode)
            {
                RestoreCoverViewOnScreen();
                // Need to click again to get the full-scan graph populated after restoring view
                ClickChromatogram(F_A_018, 14.807, 152.0E3, PaneKey.PRECURSORS);
                TakeCoverShot();
                return;
            }

            PauseForScreenShot("Full scan graph with IM filtering", 21);

            // Note that if you were interested in lipids that are not present in the current spectral library, you can add to it manually or using LipidCreator. To access the LipidCreator plugin, do the following:
            //   •	From the Tools menu, click Tool Store.
            if (IsPauseForScreenShots)
            {
                RunUI(() =>
                {
                    SkylineWindow.GraphFullScan.Close();
                    SkylineWindow.Width -= 300;
                });
                var configureToolsDlg = ShowDialog <ConfigureToolsDlg>(SkylineWindow.ShowConfigureToolsDlg);
                //   •	Select LipidCreator.
                var pick = ShowDialog <ToolStoreDlg>(configureToolsDlg.AddFromWeb);
                RunUI(() =>
                {
                    pick.SelectTool("LipidCreator");
                    pick.Left = SkylineWindow.Right + 20;
                });
                PauseForScreenShot("LipidCreator in tool store", 22);
                RunUI(() => pick.CancelDialog());
                OkDialog(configureToolsDlg, configureToolsDlg.Cancel);
                //   •	Click the Install button.
            }

            //   The following steps can be taken to easily export an updated spectral library:
            //   •	From the File menu, choose Export and click Spectral Library.
            //   •	Enter a file name and click Save.
        }
Esempio n. 3
0
        protected override void DoTest()
        {
            string documentPath = TestFilesDir.GetTestPath("11-16-10mz_manual.sky");

            RunUI(() => SkylineWindow.OpenFile(documentPath));

            // Tests that elements show up in correct groups and order as type "tiled" in grouped window.
            RunGroupDlg(9, DisplayGraphsType.Tiled, GroupGraphsType.separated, GroupGraphsOrder.Acquired_Time);
            List <GraphChromatogram> graphChromatograms = SkylineWindow.GraphChromatograms.ToList();
            var beginningWidth  = 0;
            var beginningHeight = 0;

            RunUI(() =>
            {
                beginningWidth  = graphChromatograms.First().Parent.Parent.Parent.Width;
                beginningHeight = graphChromatograms.First().Parent.Parent.Parent.Height;
                // Need to set dimensions of panel containing chromatograms so dimensions get set the same each run.
                // Dimension are set to those I had in my settings when I build the test. (Yuval)
                graphChromatograms.First().Parent.Parent.Parent.Height = 443;
                graphChromatograms.First().Parent.Parent.Parent.Width  = 736;
            });
            Assert.IsTrue(graphChromatograms.Count == 27);
            var dictGraphPositions = GetDictionaryGraphChromatogram();

            foreach (KeyValuePair <Point, List <GraphChromatogram> > dictGraphGroup in dictGraphPositions)
            {
                Assert.IsTrue(dictGraphGroup.Value.Count == 3);
            }
            List <int> order = new List <int>();

            for (var i = 0; i < beginningWidth; i++)
            {
                if (dictGraphPositions.ContainsKey(new Point(i, 1)))
                {
                    foreach (GraphChromatogram graph in dictGraphPositions[new Point(i, 1)])
                    {
                        order.Add(int.Parse(graph.NameSet));
                    }
                }
            }
            for (var i = 0; i < beginningWidth; i++)
            {
                if (dictGraphPositions.ContainsKey(new Point(i, 128)))
                {
                    foreach (GraphChromatogram graph in dictGraphPositions[new Point(i, 128)])
                    {
                        order.Add(int.Parse(graph.NameSet));
                    }
                }
            }
            var sortedList = order;

            sortedList.Sort();
            Assert.IsTrue(sortedList == order);
            Assert.IsTrue(order.Count == 27);

            // Test distributed feature in grouped window.
            RunGroupDlg(9, DisplayGraphsType.Column, GroupGraphsType.distributed, GroupGraphsOrder.Acquired_Time);
            dictGraphPositions = GetDictionaryGraphChromatogram();
            var orderedByPosition = new Dictionary <Point, List <GraphChromatogram> >();

            for (int i = 0; i < beginningWidth; i++)
            {
                if (dictGraphPositions.ContainsKey(new Point(i, 1)))
                {
                    orderedByPosition.Add(new Point(i, 1), dictGraphPositions[new Point(i, 1)]);
                }
            }
            int val1 = 0;
            int val2 = 0;
            int val3 = 0;

            foreach (KeyValuePair <Point, List <GraphChromatogram> > dictGraphGroup in orderedByPosition)
            {
                var values = new List <int> {
                    int.Parse(dictGraphGroup.Value[0].NameSet), int.Parse(dictGraphGroup.Value[1].NameSet), int.Parse(dictGraphGroup.Value[2].NameSet)
                };
                values.Sort();
                if (val1 != 0)
                {
                    Assert.IsTrue(val1 < values[0]);
                    Assert.IsTrue(val2 < values[1]);
                    Assert.IsTrue(val3 < values[2]);
                }
                val1 = values[0];
                val2 = values[1];
                val3 = values[2];
            }

            // Test row functionality through grouped window.
            RunGroupDlg(9, DisplayGraphsType.Row, GroupGraphsType.separated, GroupGraphsOrder.Acquired_Time);
            dictGraphPositions = GetDictionaryGraphChromatogram();
            foreach (KeyValuePair <Point, List <GraphChromatogram> > dictGraphGroup in dictGraphPositions)
            {
                Assert.IsTrue(dictGraphGroup.Value.Count == 3);
                Assert.IsTrue(dictGraphGroup.Key.Y == 1);
            }

            // Tests column functionality through grouped window.
            RunGroupDlg(9, DisplayGraphsType.Column, GroupGraphsType.separated, GroupGraphsOrder.Acquired_Time);
            dictGraphPositions = GetDictionaryGraphChromatogram();
            foreach (KeyValuePair <Point, List <GraphChromatogram> > dictGraphGroup in dictGraphPositions)
            {
                Assert.IsTrue(dictGraphGroup.Value.Count == 3);
                Assert.IsTrue(dictGraphGroup.Key.X == 1);
            }

            // Test View > Arange Graphs > Row
            RunUI(() => SkylineWindow.ArrangeGraphs(DisplayGraphsType.Row));
            dictGraphPositions = GetDictionaryGraphChromatogram();
            foreach (KeyValuePair <Point, List <GraphChromatogram> > dictGraphGroup in dictGraphPositions)
            {
                Assert.IsTrue(dictGraphGroup.Value.Count == 1);
                Assert.IsTrue(dictGraphGroup.Key.Y == 1);
            }

            // Test View > Arange Graphs > Column
            RunUI(() => SkylineWindow.ArrangeGraphs(DisplayGraphsType.Column));
            dictGraphPositions = GetDictionaryGraphChromatogram();
            foreach (KeyValuePair <Point, List <GraphChromatogram> > dictGraphGroup in dictGraphPositions)
            {
                Assert.IsTrue(dictGraphGroup.Value.Count == 1);
                Assert.IsTrue(dictGraphGroup.Key.X == 1);
            }
            RunUI(() =>
            {
                // Sets dimesnions back to what they were at the beginning;
                graphChromatograms.First().Parent.Parent.Parent.Height = beginningHeight;
                graphChromatograms.First().Parent.Parent.Parent.Width  = beginningWidth;
            });
        }
Esempio n. 4
0
 public void ArrangeGraphs(DisplayGraphsType displayGraphsType)
 {
     SkylineWindow.ArrangeGraphs(displayGraphsType);
 }
        protected override void DoTest()
        {
            // Clean-up before running the test
            RunUI(() => SkylineWindow.ModifyDocument("Set default settings",
                                                     d => d.ChangeSettings(SrmSettingsList.GetDefault())));

            SrmDocument doc = SkylineWindow.Document;

            const string documentBaseName = "Ms1FilterTutorial";
            string       documentFile     = GetTestPath(documentBaseName + SrmDocument.EXT);

            RunUI(() => SkylineWindow.SaveDocument(documentFile));

            // Launch the wizard
            var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg);

            // We're on the "Build Spectral Library" page of the wizard.
            // Add the test xml file to the search files list and try to
            // build the document library.
            string[] searchFiles =
            {
                GetTestPath("100803_0001_MCF7_TiB_L.group.xml"),      // Not L10N
                GetTestPath("100803_0005b_MCF7_TiTip3.group.xml")     // Not L10N
            };
            foreach (var searchFile in searchFiles)
            {
                Assert.IsTrue(File.Exists(searchFile), string.Format("File {0} does not exist.", searchFile));
            }

            PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library empty page", 3);

            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page);
                importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles);

                // Sanity check here, because of failure getting both files for results import below
                var searchNames = importPeptideSearchDlg.BuildPepSearchLibControl.SearchFilenames;
                Assert.AreEqual(searchFiles.Length, searchNames.Length,
                                PathsMessage("Unexpected search files found.", searchNames));
                var builder = importPeptideSearchDlg.BuildPepSearchLibControl.ImportPeptideSearch.GetLibBuilder(
                    SkylineWindow.DocumentUI, SkylineWindow.DocumentFilePath, false);
                Assert.IsTrue(ArrayUtil.EqualsDeep(searchFiles, builder.InputFiles),
                              PathsMessage("Unexpected BlibBuild input files.", builder.InputFiles));
                importPeptideSearchDlg.BuildPepSearchLibControl.DebugMode = true;
            });
            PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library populated page", 4);

            WaitForConditionUI(() => importPeptideSearchDlg.IsNextButtonEnabled);
            var ambiguousDlg = ShowDialog <MessageDlg>(() => importPeptideSearchDlg.ClickNextButton());

            RunUI(() => AssertEx.Contains(ambiguousDlg.Message,
                                          Resources.BiblioSpecLiteBuilder_AmbiguousMatches_The_library_built_successfully__Spectra_matching_the_following_peptides_had_multiple_ambiguous_peptide_matches_and_were_excluded_));
            OkDialog(ambiguousDlg, ambiguousDlg.OkDialog);

            // Verify document library was built
            string docLibPath          = BiblioSpecLiteSpec.GetLibraryFileName(documentFile);
            string redundantDocLibPath = BiblioSpecLiteSpec.GetRedundantName(docLibPath);

            Assert.IsTrue(File.Exists(docLibPath) && File.Exists(redundantDocLibPath));
            var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries;

            Assert.IsTrue(librarySettings.HasDocumentLibrary);
            // Verify input paths sent to BlibBuild
            string buildArgs   = importPeptideSearchDlg.BuildPepSearchLibControl.LastBuildCommandArgs;
            string buildOutput = importPeptideSearchDlg.BuildPepSearchLibControl.LastBuildOutput;
            var    argLines    = buildArgs.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            var    dirCommon   = PathEx.GetCommonRoot(searchFiles);
            var    searchLines = searchFiles.Select(f => PathEx.RemovePrefix(f, dirCommon)).ToArray();

            Assert.IsTrue(ArrayUtil.EqualsDeep(searchLines, argLines.Skip(1).ToArray()), buildArgs);

            // Verify resulting .blib file contains the expected files
            var docLib                   = librarySettings.Libraries[0];
            int expectedFileCount        = searchFiles.Length;
            int expectedRedundantSpectra = 813; // 446 with TiTip only
            int expectedSpectra          = 552; // 428 with TiTip3 only

            if (expectedFileCount != docLib.FileCount)
            {
                var searchFileNames = searchFiles.Select(Path.GetFileName).ToArray();
                using (var blibDbRedundant = BlibDb.OpenBlibDb(redundantDocLibPath))
                {
                    VerifyLib(searchFileNames, expectedRedundantSpectra, blibDbRedundant.GetIdFilePaths(), blibDbRedundant.GetSpectraCount(),
                              "redundant library", buildArgs, buildOutput);
                }
                using (var blibDb = BlibDb.OpenBlibDb(docLibPath))
                {
                    VerifyLib(searchFileNames, expectedSpectra, blibDb.GetIdFilePaths(), blibDb.GetSpectraCount(),
                              "SQLite library", buildArgs, buildOutput);
                }
                VerifyLib(searchFileNames, expectedSpectra, docLib.LibraryDetails.DataFiles.Select(d => d.IdFilePath).ToArray(), docLib.SpectrumCount,
                          "in memory", buildArgs, buildOutput);
            }

            // We're on the "Extract Chromatograms" page of the wizard.
            // All the test results files are in the same directory as the
            // document file, so all the files should be found, and we should
            // just be able to move to the next page.
            WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page &&
                               importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles.Count > 0 &&
                               importPeptideSearchDlg.IsNextButtonEnabled);

            // Wait for extra for both source files in the list
            TryWaitForConditionUI(10 * 1000, () => importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles.Count == searchFiles.Length);

            RunUI(() =>
            {
                // Check for missing files
                var missingFiles = importPeptideSearchDlg.ImportResultsControl.MissingResultsFiles.ToArray();
                Assert.AreEqual(0, missingFiles.Length,
                                PathsMessage("Unexpected missing file found.", missingFiles));
                // Check for expected results files
                var resultsNames = importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles.Select(f => f.Name).ToArray();
                Assert.AreEqual(searchFiles.Length, importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles.Count,
                                PathsMessage("Unexpected results files found.", resultsNames));
                // Check for expected common prefix
                var commonPrefix = ImportResultsDlg.GetCommonPrefix(resultsNames);
                Assert.IsFalse(string.IsNullOrEmpty(commonPrefix),
                               PathsMessage("File names do not have a common prefix.", resultsNames));
                Assert.AreEqual("100803_000", commonPrefix);
            });
            PauseForScreenShot <ImportPeptideSearchDlg.ChromatogramsPage>("Import Peptide Search - Extract Chromatograms page", 6);

            var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(() => importPeptideSearchDlg.ClickNextButton());

            PauseForScreenShot <ImportResultsNameDlg>("Import Results - Common prefix form", 7);

            OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog);

            // Wait for the "Add Modifications" page of the wizard.
            WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.match_modifications_page);

            List <string> modsToCheck = new List <string> {
                "Phospho (ST)", "Phospho (Y)", "Oxidation (M)"
            };                                                                                              // Not L10N

            RunUI(() =>
            {
                importPeptideSearchDlg.MatchModificationsControl.CheckedModifications = modsToCheck;
            });
            PauseForScreenShot <ImportPeptideSearchDlg.MatchModsPage>("Import Peptide Search - Add Modifications page", 8);
            RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton()));

            // We're on the "Configure MS1 Full-Scan Settings" page of the wizard.
            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.full_scan_settings_page);
                importPeptideSearchDlg.FullScanSettingsControl.PrecursorCharges      = new[] { 2, 3, 4 };
                importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof;
                importPeptideSearchDlg.FullScanSettingsControl.PrecursorRes          = 10 * 1000;

                Assert.AreEqual(importPeptideSearchDlg.FullScanSettingsControl.PrecursorIsotopesCurrent, FullScanPrecursorIsotopes.Count);
                Assert.AreEqual(FullScanMassAnalyzerType.tof, importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer);
                Assert.AreEqual(10 * 1000, importPeptideSearchDlg.FullScanSettingsControl.PrecursorRes);
                Assert.AreEqual(3, importPeptideSearchDlg.FullScanSettingsControl.Peaks);
                Assert.AreEqual(RetentionTimeFilterType.ms2_ids, importPeptideSearchDlg.FullScanSettingsControl.RetentionTimeFilterType);
                Assert.AreEqual(5, importPeptideSearchDlg.FullScanSettingsControl.TimeAroundMs2Ids);
            });
            PauseForScreenShot <ImportPeptideSearchDlg.Ms1FullScanPage>("Import Peptide Search - Configure MS1 Full-Scan Settings page", 9);

            RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton()));

            // Last page of wizard - Import Fasta.
            string fastaPath = GetTestPath("12_proteins.062011.fasta");

            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.import_fasta_page);
                Assert.AreEqual("Trypsin [KR | P]", importPeptideSearchDlg.ImportFastaControl.Enzyme.GetKey());
                importPeptideSearchDlg.ImportFastaControl.MaxMissedCleavages = 2;
                importPeptideSearchDlg.ImportFastaControl.SetFastaContent(fastaPath);
                Assert.IsFalse(importPeptideSearchDlg.ImportFastaControl.DecoyGenerationEnabled);
            });
            PauseForScreenShot <ImportPeptideSearchDlg.FastaPage>("Import Peptide Search - Import FASTA page", 12);

            var peptidesPerProteinDlg = ShowDialog <PeptidesPerProteinDlg>(() => importPeptideSearchDlg.ClickNextButton());

            WaitForCondition(() => peptidesPerProteinDlg.DocumentFinalCalculated);
            RunUI(() =>
            {
                int proteinCount, peptideCount, precursorCount, transitionCount;
                peptidesPerProteinDlg.NewTargetsAll(out proteinCount, out peptideCount, out precursorCount, out transitionCount);
                Assert.AreEqual(11, proteinCount);
                Assert.AreEqual(51, peptideCount);
                Assert.AreEqual(52, precursorCount);
                Assert.AreEqual(156, transitionCount);
                peptidesPerProteinDlg.NewTargetsFinal(out proteinCount, out peptideCount, out precursorCount, out transitionCount);
                Assert.AreEqual(11, proteinCount);
                Assert.AreEqual(51, peptideCount);
                Assert.AreEqual(52, precursorCount);
                Assert.AreEqual(156, transitionCount);
            });
            OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog);

            var allChromGraph = WaitForOpenForm <AllChromatogramsGraph>();

            RunUI(() =>
            {
                allChromGraph.Left = SkylineWindow.Right + 20;
                allChromGraph.Activate();
            });

            PauseForScreenShot <AllChromatogramsGraph>("Loading chromatograms window", 13);
            WaitForDocumentChangeLoaded(doc, 8 * 60 * 1000); // 10 minutes

            var libraryExplorer   = ShowDialog <ViewLibraryDlg>(() => SkylineWindow.OpenLibraryExplorer(documentBaseName));
            var matchedPepModsDlg = WaitForOpenForm <AddModificationsDlg>();

            PauseForScreenShot <AddModificationsDlg>("Add mods alert", 14);
            RunUI(() =>
            {
                Assert.AreEqual(13, matchedPepModsDlg.NumMatched);
                Assert.AreEqual(0, matchedPepModsDlg.NumUnmatched);
                matchedPepModsDlg.CancelDialog();
            });
            RunUI(() =>
            {
                libraryExplorer.GraphSettings.ShowBIons        = true;
                libraryExplorer.GraphSettings.ShowYIons        = true;
                libraryExplorer.GraphSettings.ShowCharge1      = true;
                libraryExplorer.GraphSettings.ShowCharge2      = true;
                libraryExplorer.GraphSettings.ShowPrecursorIon = true;
            });

            PauseForScreenShot <ViewLibraryDlg>("Spectral Library Explorer", 15);
            RunUI(() =>
            {
                const string sourceFirst = "100803_0005b_MCF7_TiTip3.wiff";
                const double timeFirst   = 35.2128;
                Assert.AreEqual(sourceFirst, libraryExplorer.SourceFile);
                Assert.AreEqual(timeFirst, libraryExplorer.RetentionTime, 0.01);
                libraryExplorer.SelectedIndex++;
                Assert.AreNotEqual(sourceFirst, libraryExplorer.SourceFile);
                Assert.AreNotEqual(timeFirst, libraryExplorer.RetentionTime, 0.01);
            });
            OkDialog(libraryExplorer, libraryExplorer.CancelDialog);

            const int TIB_L = 0; // index for Tib_L
            const int TIP3  = 1; // index for Tip3

            AssertEx.IsDocumentState(SkylineWindow.Document, null, 11, 51, 52, 156);
            AssertResult.IsDocumentResultsState(SkylineWindow.Document, GetFileNameWithoutExtension(searchFiles[TIB_L]), 51, 52, 0, 156, 0);
            AssertResult.IsDocumentResultsState(SkylineWindow.Document, GetFileNameWithoutExtension(searchFiles[TIP3]), 51, 52, 0, 156, 0);
            string Tib_LFilename = searchFiles[TIB_L].Replace(".group.xml", PreferedExtAbWiff);
            string Tip3Filename  = searchFiles[TIP3].Replace(".group.xml", PreferedExtAbWiff);

            // Select the first transition group.
            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedPath =
                    SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0);
                SkylineWindow.GraphSpectrumSettings.ShowAIons        = true;
                SkylineWindow.GraphSpectrumSettings.ShowBIons        = true;
                SkylineWindow.GraphSpectrumSettings.ShowYIons        = true;
                SkylineWindow.GraphSpectrumSettings.ShowPrecursorIon = true;
                SkylineWindow.ExpandPrecursors();
                SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
            });
            RunDlg <SpectrumChartPropertyDlg>(SkylineWindow.ShowSpectrumProperties, dlg =>
            {
                dlg.FontSize = GraphFontSize.NORMAL;
                dlg.OkDialog();
            });
            RunDlg <ChromChartPropertyDlg>(SkylineWindow.ShowChromatogramProperties, dlg =>
            {
                dlg.FontSize = GraphFontSize.NORMAL;
                dlg.OkDialog();
            });
            const int skylineWindowWidth  = 1160;
            const int skylineWindowHeight = 792;

            RunUI(() =>
            {
                // Make window screenshot size
                if (IsPauseForScreenShots && SkylineWindow.WindowState != FormWindowState.Maximized)
                {
                    SkylineWindow.Width  = skylineWindowWidth;
                    SkylineWindow.Height = skylineWindowHeight;
                }
            });
            RestoreViewOnScreen(13);
            PauseForScreenShot("Main window with imported data", 16);

//            RunUIWithDocumentWait(() =>
//            {
//                SkylineWindow.ToggleIntegrateAll(); // TODO: No longer necessary.  Change in tutorial
//            });
            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(true);
                SkylineWindow.ShowPeakAreaReplicateComparison();
                SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.NONE);
                Settings.Default.ShowDotProductPeakArea = true;
                Settings.Default.ShowLibraryPeakArea    = true;
            });
            RunUI(() =>
            {
                SkylineWindow.Width    = 500;
                var peakAreas          = SkylineWindow.GraphPeakArea;
                var peakAreasFloating  = peakAreas.Parent.Parent;
                peakAreasFloating.Left = SkylineWindow.Right + 20;
                peakAreasFloating.Top  = SkylineWindow.Top;
                peakAreasFloating.Size = new Size(504, 643);
            });

            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas view (show context menu)", 18);

            RunUI(() => SkylineWindow.Width = skylineWindowWidth);
            RestoreViewOnScreen(15);
            RunUI(() =>
            {
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.ShowChromatogramLegends(false);
            });
            PauseForScreenShot("Main window layout", 19);

            int atest = 0;

            CheckAnnotations(TIB_L, 0, atest++);
            int pepIndex = 3;

            RunUI(() => SkylineWindow.CollapsePeptides());
            RunUI(() => SkylineWindow.ShowAlignedPeptideIDTimes(true));
            ChangePeakBounds(TIB_L, pepIndex, 38.79, 39.385);
            PauseForScreenShot("Chromatogram graphs clipped from main window", 21);
            CheckAnnotations(TIB_L, pepIndex, atest++);

            var       alignmentForm            = ShowDialog <AlignmentForm>(() => SkylineWindow.ShowRetentionTimeAlignmentForm());
            const int skylineWindowNarrowWidth = 788;

            RunUI(() =>
            {
                SkylineWindow.Width  = skylineWindowNarrowWidth;
                alignmentForm.Width  = 660;
                alignmentForm.Height = 561;
                alignmentForm.Left   = SkylineWindow.Right + 20;
                alignmentForm.Splitter.SplitterDistance       = 75;
                alignmentForm.ComboAlignAgainst.SelectedIndex = 0;     // to match what's in the tutorial doc
            });
            PauseForScreenShot <AlignmentForm>("Retention time alignment form", 22);

            OkDialog(alignmentForm, alignmentForm.Close);
            PauseForScreenShot("Status bar clipped from main window - 4/51 pep 4/52 prec 10/156 tran", 23);

            const string TIP_NAME = "5b_MCF7_TiTip3";

            if (IsCoverShotMode)
            {
                RestoreCoverViewOnScreen();
                ClickChromatogram(TIP_NAME, 34.5, 366);
                TreeNode selectedNode = null;
                RunUI(() => selectedNode = SkylineWindow.SequenceTree.SelectedNode);
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0]);
                WaitForGraphs();
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = selectedNode);
                TakeCoverShot();
                return;
            }

            pepIndex = JumpToPeptide("SSKASLGSLEGEAEAEASSPK");
            RunUI(() => SkylineWindow.ShowChromatogramLegends(true));
            Assert.IsTrue(8 == pepIndex);
            PauseForScreenShot("Chromatogram graph metafiles for 9th peptide", 24);
            CheckAnnotations(TIB_L, pepIndex, atest++);

            ZoomSingle(TIP3, 31.8, 42.2, 280); // simulate the wheel scroll described in tutorial
            PauseForScreenShot("Chromatogram graph metafile showing all peaks for 1_MCF_TiB_L", 24);
            CheckAnnotations(TIB_L, pepIndex, atest++);

            // current TIB_L peak should have idotp .87 and ppm -6.9
            Assert.AreEqual(0.87, GetTransitionGroupChromInfo(TIB_L, pepIndex).IsotopeDotProduct ?? -1, .005);
            Assert.AreEqual(-10.8, GetTransitionChromInfo(TIB_L, pepIndex, 0).MassError ?? -1, .05);

            ChangePeakBounds(TIB_L, pepIndex, 36.5, 38.0);

            // now current TIB_L peak should have idotp .9 and ppm -6.5
            Assert.AreEqual(0.9, GetTransitionGroupChromInfo(TIB_L, pepIndex).IsotopeDotProduct ?? -1, .005);
            Assert.AreEqual(-9.4, GetTransitionChromInfo(TIB_L, pepIndex, 0).MassError ?? -1, .05);
            CheckAnnotations(TIB_L, pepIndex, atest++);

            var undoIndex = SkylineWindow.Document.RevisionIndex; // preserve for simulating ctrl-z

            RunUI(() => SkylineWindow.Width = skylineWindowWidth);
            PickPeakBoth(pepIndex, 40.471035, 40.8134); // select peak for both chromatograms at these respective retention times
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 25);

            int[] m1Thru4 = { 1, 2, 3, 4, 5 };
            PickTransitions(pepIndex, m1Thru4, "Transition pick list filtered", 26, "Transition pick list unfiltered", 26); // turn on chromatograms
            PickPeakBoth(pepIndex, 36.992836, 37.3896027);                                                                  // select peak for both chromatograms at these respective retention times
            ZoomSingle(TIP3, 32.4, 42.2, 520);                                                                              // set the view for screenshot
            RunUI(() =>
            {
                SkylineWindow.Height = 550;
                SkylineWindow.ArrangeGraphsTabbed();
            });
            ActivateReplicate(TIP_NAME);
            PauseForScreenShot("Chromatogram graph metafile comparing 33 and 37 minute peaks", 27);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

            RevertDoc(undoIndex); // undo changes

            ActivateReplicate(TIP_NAME);
            ClickChromatogram(TIP_NAME, 37.3, 142);
            PauseForScreenShot("MS1 spectrum graph 37.32 minutes", 28);
            ClickChromatogram(TIP_NAME, 33.2, 328.1);
            PauseForScreenShot("MS1 spectrum graph 33.19 minutes", 29);
            RunUI(() => SkylineWindow.HideFullScanGraph());

            RunUI(() =>
            {
                SkylineWindow.Width  = skylineWindowNarrowWidth;
                SkylineWindow.Height = skylineWindowHeight;
                SkylineWindow.ArrangeGraphs(DisplayGraphsType.Column);
            });
            pepIndex = JumpToPeptide("ASLGSLEGEAEAEASSPKGK"); // Not L10N
            Assert.IsTrue(10 == pepIndex);
            PauseForScreenShot("Chromatogram graph meta files for peptide ASLGSLEGEAEAEASSPKGK", 30);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

            PickTransitions(pepIndex, m1Thru4);  // turn on M+3 and M+4
            ChangePeakBounds(TIP3, pepIndex, 37.35, 38.08);
            ZoomSingle(TIP3, 36.65, 39.11, 300); // simulate the wheel scroll described in tutorial
            PauseForScreenShot("upper - Chromatogram graph metafile for peptide ASLGSLEGEAEAEASSPKGK with adjusted integration", 31);
            CheckAnnotations(TIP3, pepIndex, atest++);

            RevertDoc(undoIndex);                              // undo changes
            pepIndex = JumpToPeptide("AEGEWEDQEALDYFSDKESGK"); // Not L10N
            PauseForScreenShot("lower - Chromatogram graph metafiles for peptide AEGEWEDQEALDYFSDKESGK", 31);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

            int[] m1Thru5 = { 1, 2, 3, 4, 5, 6 };
            PickTransitions(pepIndex, m1Thru5); // turn on M+3 M+4 and M+5
            PauseForScreenShot("Chromatogram graph metafiles with M+3, M+4 and M+5 added", 32);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

            JumpToPeptide("ALVEFESNPEETREPGSPPSVQR"); // Not L10N
            PauseForScreenShot("Chromatogram graph metafiles for peptide ALVEFESNPEETREPGSPPSVQR", 33);

            pepIndex = JumpToPeptide("YGPADVEDTTGSGATDSKDDDDIDLFGSDDEEESEEAKR"); // Not L10N
            if (IsPauseForScreenShots)
            {
                RestoreViewOnScreen(34);
                PauseForScreenShot("upper - Peak Areas graph metafile for peptide YGPADVEDTTGSGATDSKDDDDIDLFGSDDEEESEEAKR", 34);
            }

            int[] m1Thru7 = { 1, 2, 3, 4, 5, 6, 7, 8 };
            PickTransitions(pepIndex, m1Thru7); // enable [M+3] [M+4] [M+5] [M+6] [M+7]
            PauseForScreenShot("lower - Peak Areas graph metafile with M+3 through M+7 added", 34);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

            RunUI(() => SkylineWindow.ShowGraphPeakArea(false));

            // page 36 zooming setup
            RunUI(() =>
            {
                SkylineWindow.SynchronizeZooming(true);
                SkylineWindow.LockYChrom(false);
                SkylineWindow.AlignToFile = GetGraphChromatogram(TIP3).GetChromFileInfoId(); // align to Tip3
            });
            ZoomBoth(36.5, 39.5, 1600);                                                      // simulate the wheel scroll described in tutorial
            RunUI(() =>
            {
                SkylineWindow.ShowChromatogramLegends(false);
                SkylineWindow.Width  = skylineWindowWidth;
                SkylineWindow.Height = 720;
            });
            PauseForScreenShot("Chromatogram graphs clipped from main window with synchronized zooming", 35);

            ClickChromatogram(TIP_NAME, 37.5, 1107.3);
            PauseForScreenShot("MS1 spectrum graph 37.50 minutes", 36);
            RunUI(() => SkylineWindow.HideFullScanGraph());

            RunUI(() =>
            {
                SkylineWindow.ShowChromatogramLegends(true);
                SkylineWindow.Width  = skylineWindowNarrowWidth;
                SkylineWindow.Height = skylineWindowHeight;
            });
            RestoreViewOnScreen(36);                                                                                                      // float the Library Match window
            RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(MsDataFileUri.Parse(Tip3Filename), 37.6076f))); // set the Library Match view
            PauseForScreenShot <GraphSpectrum>("Library Match graph metafile - 5b_MCF7_TiTip3 (37.61 Min)", 37);

            RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(MsDataFileUri.Parse(Tib_LFilename), 37.0335f))); // set the Library Match view
            PauseForScreenShot <GraphSpectrum>("Library Match graph metafile - 1_MCF_TiB_L (37.03 min)", 37);

            RestoreViewOnScreen(37);                       // back to normal view
            /* pepIndex = */ JumpToPeptide("DQVANSAFVER"); // Not L10N
            PauseForScreenShot("Chromatogram graph metafiles for peptide DQVANSAFVER", 38);

//            int[] m1 = {2};
//            PickTransitions(pepIndex, m1); // enable [M+1] only
//            // Measured times in TIB_L are different from displayed times, because of alignment
//            ChangePeakBounds(TIB_L, pepIndex, 23.99, 25.29);
//            ChangePeakBounds(TIP3, pepIndex, 23.81, 25.21);
//            // First transition selected for screenshot
//            RunUI(() =>
//            {
//                var pathPep = SkylineWindow.SelectedPath;
//                var nodePep = ((PeptideTreeNode)SkylineWindow.SelectedNode).DocNode;
//                var nodeGroup = nodePep.TransitionGroups.First();
//                var nodeTran = nodeGroup.Transitions.First();
//                SkylineWindow.SelectedPath = new IdentityPath(
//                    new IdentityPath(pathPep, nodeGroup.TransitionGroup), nodeTran.Transition);
//            });
//            PauseForScreenShot("page 36 - M+1 only, with adjusted integration");
//            CheckAnnotations(TIB_L, pepIndex, atest++);
//            CheckAnnotations(TIP3, pepIndex, EXPECTED_ANNOTATIONS[atest]);

            var docAfter = WaitForProteinMetadataBackgroundLoaderCompletedUI();

            // Minimizing a chromatogram cache file.
            RunUI(SkylineWindow.CollapsePeptides);
            for (int i = 0; i < 5; i++) // just do the first 5
            {
                int iPeptide = i;
                var path     = docAfter.GetPathTo((int)SrmDocument.Level.Molecules, iPeptide);
                RunUI(() =>
                {
                    SkylineWindow.SelectedPath = path;
                });
                WaitForGraphs();
            }

            // Eliminate extraneous chromatogram data.
            doc = WaitForProteinMetadataBackgroundLoaderCompletedUI();
            var minimizedFile = GetTestPath("Ms1FilteringTutorial-2min.sky"); // Not L10N
            var cacheFile     = Path.ChangeExtension(minimizedFile, ChromatogramCache.EXT);

            {
                // TODO: Figure out why the minimize fails to unlock the .skyd file, if not minimized to current file
                RunUI(() => SkylineWindow.SaveDocument(minimizedFile));

                var manageResultsDlg   = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
                var minimizeResultsDlg = ShowDialog <MinimizeResultsDlg>(manageResultsDlg.MinimizeResults);
                RunUI(() =>
                {
                    minimizeResultsDlg.LimitNoiseTime = true;
                    minimizeResultsDlg.NoiseTimeRange = 2;                                                        // Not L10N
                });
                PauseForScreenShot <MinimizeResultsDlg>("Minimize Results form (percentages vary slightly)", 39); // old p. 23

                OkDialog(minimizeResultsDlg, () => minimizeResultsDlg.MinimizeToFile(minimizedFile));
                WaitForCondition(() => File.Exists(cacheFile));
                WaitForClosedForm(manageResultsDlg);
            }
            WaitForDocumentChange(doc);

            // Inclusion list method export for MS1 filtering
            doc = SkylineWindow.Document;
            RunDlg <PeptideSettingsUI>(() => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction), dlg =>
            {
                dlg.IsUseMeasuredRT = true;
                dlg.TimeWindow      = 10;
                dlg.OkDialog();
            });
            doc = WaitForDocumentChangeLoaded(doc);

            // Now deviating from the tutorial script for a moment to make sure we can choose a Scheduled export method.
            // CONSIDER: This refinement seems to be a no-op. Not sure why it is here.
            RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, dlg =>
            {
                dlg.MinPeptides = 1;                                // This would get rid of proteins with no peptides (none exist)
                const double minPeakFoundRatio = 0.1;
                dlg.MinPeakFoundRatio          = minPeakFoundRatio; // This would get rid of undetected transitions (none exist)
                dlg.OkDialog();                                     // Will not change the document or add an Undo entry
            });
            // Nothing should have changed on the UI thread
            RunUI(() => Assert.AreSame(doc, SkylineWindow.DocumentUI));

            // Ready to export, although we will just cancel out of the dialog.
            var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method));

            RunUI(() =>
            {
                exportMethodDlg.InstrumentType = ExportInstrumentType.ABI_TOF; // Not L10N
                exportMethodDlg.MethodType     = ExportMethodType.Scheduled;
                exportMethodDlg.CancelButton.PerformClick();
            });
            WaitForClosedForm(exportMethodDlg);

            // Because this was showing up in the nightly test failures
            WaitForConditionUI(() => exportMethodDlg.IsDisposed);

            RunUI(() => SkylineWindow.SaveDocument());
            RunUI(SkylineWindow.NewDocument);
        }