Exemple #1
0
        protected override void DoTest()
        {
            // Check backward compatibility with 19.1.9.338 and 350 when combined IMS got written to MsDataFilePath
            string legacyFile_19_1_9 = TestFilesDirs[1].GetTestPath(@"BSA-Training.sky");

            RunUI(() => SkylineWindow.OpenFile(legacyFile_19_1_9));
            VerifyCombinedIonMobility(WaitForDocumentLoaded());
            RunUI(() =>
            {
                SkylineWindow.SaveDocument();
                SkylineWindow.NewDocument();
                SkylineWindow.OpenFile(legacyFile_19_1_9);
            });
            VerifyCombinedIonMobility(WaitForDocumentLoaded());
            var    oldDoc  = SkylineWindow.Document;
            string skyFile = TestFilesDirs[0].GetTestPath(@"IMSFiltering\BSA-Training.sky");

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

            var document = WaitForDocumentChangeLoaded(oldDoc, 240 * 1000); // 4 minutes

            RunUI(() => SkylineWindow.Size = new Size(880, 560));
            RestoreViewOnScreen(2);
            PauseForScreenShot("Document open - full window", 2);
            AssertEx.IsDocumentState(document, null, 1, 34, 38, 404);

            {
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(() =>
                                                                             SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.FullScan));

                PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Full-scan settings", 3);

                RunUI(() =>
                {
                    Assert.AreEqual(FullScanPrecursorIsotopes.Count, transitionSettingsUI.PrecursorIsotopesCurrent);
                    Assert.AreEqual(20 * 1000, transitionSettingsUI.PrecursorRes);
                    Assert.AreEqual(FullScanMassAnalyzerType.tof, transitionSettingsUI.PrecursorMassAnalyzer);
                    Assert.AreEqual(IsolationScheme.SpecialHandlingType.ALL_IONS, transitionSettingsUI.IsolationSchemeName);
                    Assert.AreEqual(20 * 1000, transitionSettingsUI.ProductRes);
                    Assert.AreEqual(FullScanMassAnalyzerType.tof, transitionSettingsUI.ProductMassAnalyzer);
                });

                OkDialog(transitionSettingsUI, transitionSettingsUI.CancelDialog);
            }

            {
                var importResults = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                RunUI(() => importResults.ImportSimultaneousIndex = 2);

                PauseForScreenShot <ImportResultsDlg>("Import results form", 4);

                // Importing raw data from a sample which is a mixture of yeast and BSA

                var openDataSourceDialog = ShowDialog <OpenDataSourceDialog>(importResults.OkDialog);

                RunUI(() =>
                {
                    openDataSourceDialog.CurrentDirectory = new MsDataFilePath(DataPath);
                    openDataSourceDialog.SelectAllFileType(".d");
                });
                PauseForScreenShot <OpenDataSourceDialog>("Import results files", 5);

                OkDialog(openDataSourceDialog, openDataSourceDialog.Open);
            }

            string yeastReplicateName = Path.GetFileNameWithoutExtension(Yeast_BSA);

            PauseForScreenShot <AllChromatogramsGraph>("Importing results form", 6);

            WaitForDocumentChangeLoaded(document, 1000 * 60 * 60 * 10); // 10 minutes

            // Arrange graphs tiled
            RunUI(() =>
            {
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.ShowSplitChromatogramGraph(true);
            });
            FindNode("R.FKDLGEEHFK.G");

            RunUI(() => SkylineWindow.Size = new Size(1075, 799));
            RestoreViewOnScreen(7);
            PauseForScreenShot("Zoomed split graph panes only", 7);

            RunUI(() => SkylineWindow.AutoZoomNone());
            PauseForScreenShot("Unzoomed split graph panes only", 8);

            const int wideWidth = 1547;

            RunUI(() =>
            {
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.ShowRTReplicateGraph();
                SkylineWindow.ShowGraphPeakArea(true);
                SkylineWindow.ShowChromatogramLegends(false);
                SkylineWindow.ShowPeakAreaLegend(false);
                SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.TOTAL);
                SkylineWindow.SynchronizeZooming(true);
                SkylineWindow.Size = new Size(wideWidth, 855);
            });
            RestoreViewOnScreen(9);
            PauseForScreenShot("Full window", 9);

            FindNode("TCVADESHAGCEK");
            var noteDlg = ShowDialog <EditNoteDlg>(SkylineWindow.EditNote);

            RunUI(() => noteDlg.NoteText = "Lost in yeast samples");

            PauseForScreenShot("Peptide note", 10);
            OkDialog(noteDlg, noteDlg.OkDialog);

            FindNode("NECFLSHKDDSPDLPK");
            RestoreViewOnScreen(11);
            const int narrowWidth = 1350;

            RunUI(() => SkylineWindow.Width = narrowWidth);
            PauseForScreenShot("Yeast chromatograms and RT only - prtsc-paste-edit", 11);
            PauseForScreenShot("Hover over BSA in water chromatogram - prtsc-paste-edit", 12);
            RunUI(() => SkylineWindow.Width = wideWidth);
            RestoreViewOnScreen(13);
            {
                const double clickTime1 = 41.06;
                ClickChromatogram(clickTime1, 1.62E+6, PaneKey.PRECURSORS);
                PauseForScreenShot("Full scan 2D MS1 graph", 13);
                var fullScanGraph = FindOpenForm <GraphFullScan>();
                RunUI(() => fullScanGraph.SetSpectrum(false));
                PauseForScreenShot("Full scan 3D MS1 graph", 13);
                ValidateClickTime(fullScanGraph, clickTime1);

                RunUI(() => fullScanGraph.SetZoom(false));
                PauseForScreenShot("Full scan unzoomed 3D MS1 graph", 14);

                const double clickTime2 = 41.02;
                RunUI(() => fullScanGraph.SetZoom(true));
                ClickChromatogram(clickTime2, 5.8E+4, PaneKey.PRODUCTS);
                PauseForScreenShot("Full scan 3D MS/MS graph", 15);
                ValidateClickTime(fullScanGraph, clickTime2);

                RunUI(() => fullScanGraph.SetZoom(false));
                PauseForScreenShot("Full scan unzoomed 3D MS/MS graph", 15);

                if (IsCoverShotMode)
                {
                    RunUI(() =>
                    {
                        Settings.Default.ChromatogramFontSize = 14;
                        Settings.Default.AreaFontSize         = 14;
                        SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    });

                    RestoreCoverViewOnScreen();

                    ClickChromatogram(clickTime2, 5.8E+4, PaneKey.PRODUCTS);

                    var manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
                    RenameReplicate(manageResultsDlg, 0, "BSA");
                    RenameReplicate(manageResultsDlg, 1, "Yeast_BSA");
                    OkDialog(manageResultsDlg, manageResultsDlg.OkDialog);

                    RunUI(SkylineWindow.FocusDocument);

                    TakeCoverShot();
                    return;
                }

                const double clickTime3 = 41.48;
                ClickChromatogram(yeastReplicateName, clickTime3, 3.14E+4, PaneKey.PRODUCTS);
                PauseForScreenShot("Interference full scan unzoomed 3D MS/MS graph", 16);
                ValidateClickTime(fullScanGraph, clickTime3);

                RunUI(SkylineWindow.HideFullScanGraph);
            }

            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg =>
            {
                dlg.SelectedChromatograms = SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Skip(1);
                dlg.RemoveReplicates();
                dlg.OkDialog();
            });
            RunUI(() => SkylineWindow.SaveDocument());

            {
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.IonMobility;
                    transitionSettingsUI.IonMobilityControl.WindowWidthType = IonMobilityWindowWidthCalculator
                                                                              .IonMobilityWindowWidthType.resolving_power;
                    transitionSettingsUI.IonMobilityControl.IonMobilityFilterResolvingPower = 50;
                });
                PauseForScreenShot("Setting ion mobility filter width calculation values", 17);


                var          editIonMobilityLibraryDlg = ShowDialog <EditIonMobilityLibraryDlg>(transitionSettingsUI.IonMobilityControl.AddIonMobilityLibrary);
                const string libraryName  = "BSA";
                var          databasePath = TestFilesDirs[1].GetTestPath(libraryName + IonMobilityDb.EXT);

                RunUI(() =>
                {
                    editIonMobilityLibraryDlg.LibraryName = libraryName;
                    editIonMobilityLibraryDlg.CreateDatabaseFile(databasePath); // Simulate user click on Create button
                    editIonMobilityLibraryDlg.SetOffsetHighEnergySpectraCheckbox(true);
                    editIonMobilityLibraryDlg.GetIonMobilitiesFromResults();
                });
                PauseForScreenShot("Edit ion mobility library form", 18);

                // Check that a new value was calculated for all precursors
                RunUI(() => Assert.AreEqual(SkylineWindow.Document.MoleculeTransitionGroupCount, editIonMobilityLibraryDlg.LibraryMobilitiesFlatCount));

                OkDialog(editIonMobilityLibraryDlg, () => editIonMobilityLibraryDlg.OkDialog());

                PauseForScreenShot <TransitionSettingsUI.IonMobilityTab>("Transition Settings - Ion Mobility", 19);

                RunUI(() =>
                {
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.FullScan;
                    transitionSettingsUI.SetRetentionTimeFilter(RetentionTimeFilterType.scheduling_windows, 3);
                });

                PauseForScreenShot("Transition Settings - Full-Scan", 20);

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                RunUI(() => peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Prediction);
                PauseForScreenShot("Peptide Settings - Prediction", 21);
                RunUI(() =>
                {
                    Assert.IsTrue(peptideSettingsUI.IsUseMeasuredRT);
                    Assert.AreEqual(6, peptideSettingsUI.TimeWindow);
                });

                OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
            }

            using (new WaitDocumentChange(1, true, 1000 * 60 * 60 * 5))
            {
                var choosePredictionReplicates = ShowDialog <ChooseSchedulingReplicatesDlg>(SkylineWindow.ImportResults);
                PauseForScreenShot("Choose Replicates form", 22);

                RunUI(() => choosePredictionReplicates.SelectOrDeselectAll(true));
                var importResults = ShowDialog <ImportResultsDlg>(choosePredictionReplicates.OkDialog);
                RunDlg <OpenDataSourceDialog>(importResults.OkDialog, openDataSourceDialog =>
                {
                    openDataSourceDialog.CurrentDirectory = new MsDataFilePath(DataPath);
                    openDataSourceDialog.SelectAllFileType(Yeast_BSA);
                    openDataSourceDialog.Open();
                });
            }
            WaitForGraphs();

            // Test to ensure the filtering happened
            if (!IsPauseForScreenShots) // Don't bring up unexpected UI in a screenshot run
            {
                TestReports();
            }

            RestoreViewOnScreen(11);
            RunUI(() => SkylineWindow.Width = narrowWidth);
            PauseForScreenShot("Yeast chromatogram and RTs - prtsc-paste-edit", 23);
            RunUI(() => SkylineWindow.Width = wideWidth);
            RestoreViewOnScreen(13);
            {
                const double clickTime = 42.20;
                ClickChromatogram(yeastReplicateName, clickTime, 2.904E+4, PaneKey.PRODUCTS);
                var fullScanGraph = FindOpenForm <GraphFullScan>();
                RunUI(() => fullScanGraph.SetZoom(true));
                RunUI(() => fullScanGraph.Parent.Parent.Size = new Size(671, 332));
                PauseForScreenShot("Full-scan graph zoomed", 24);
                RunUI(() => Assert.IsTrue(fullScanGraph.TitleText.Contains(clickTime.ToString(CultureInfo.CurrentCulture))));
                RunUI(SkylineWindow.HideFullScanGraph);
            }

            FindNode("FKDLGEEHFK");

            RunUI(() =>
            {
                SkylineWindow.Size = new Size(1547, 689);
                SkylineWindow.ShowProductTransitions();
                SkylineWindow.ShowPeakAreaLegend(true);
            });
            RestoreViewOnScreen(25);
            PauseForScreenShot("Chromatograms and Peak Areas - prtsc-paste-edit", 25);

            var docFiltered = SkylineWindow.Document;

            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, manageDlg =>
            {
                manageDlg.SelectedChromatograms = SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Take(1);
                manageDlg.ReimportResults();
                manageDlg.OkDialog();
            });

            WaitForDocumentChangeLoaded(docFiltered, 1000 * 60 * 60 * 5); // 5 minutes

            // TODO: Check peak ranks before and after

            AssertEx.IsFalse(IsRecordMode); // Make sure we turn this off before commit!
        }
        protected override void DoTest()
        {
            RunUI(() => SkylineWindow.SetUIMode(SrmDocument.DOCUMENT_TYPE.small_molecules));

            // Inserting a Transition List, p. 5
            {
                var doc = SkylineWindow.Document;

                SetCsvFileClipboardText(GetTestPath("Energy_TransitionList.csv"));
                RunUI(() =>
                {
                    SkylineWindow.Paste();
                    AdjustSequenceTreePanelWidth();
                });

                PauseForScreenShot <SkylineWindow>("Main window after paste from csv", 5);

                var docTargets = WaitForDocumentChange(doc);

                AssertEx.IsDocumentState(docTargets, null, 3, 18, 36, 36);
                Assert.IsFalse(docTargets.MoleculeTransitions.Any(t => t.Transition.IsPrecursor()));

                {
                    var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                    RunUI(() =>
                    {
                        // Predicition Settings
                        transitionSettingsUI.SelectedTab      = TransitionSettingsUI.TABS.Prediction;
                        transitionSettingsUI.RegressionCEName = "Waters Xevo"; // Collision Energy
                    });
                    PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings - Prediction tab", 6);


                    RunUI(() =>
                    {
                        // Filter Settings
                        transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Filter;
                        transitionSettingsUI.SmallMoleculePrecursorAdducts = Adduct.M_MINUS.AdductFormula;
                        transitionSettingsUI.SmallMoleculeFragmentAdducts  = Adduct.M_MINUS.AdductFormula;
                        transitionSettingsUI.SmallMoleculeFragmentTypes    = TransitionFilter.SMALL_MOLECULE_FRAGMENT_CHAR;
                    });
                    PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings -Filter tab", 7);

                    OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                    WaitForDocumentChange(docTargets);
                }

                RunUI(() => SkylineWindow.SaveDocument(GetTestPath("EnergyMet.sky")));


                // Export method - 2 minutes
                {
                    var exportMethodDlg2 = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method));
                    RunUI(() =>
                    {
                        exportMethodDlg2.InstrumentType = ExportInstrumentType.WATERS_XEVO_TQ;
                        exportMethodDlg2.MethodType     = ExportMethodType.Standard;
                        exportMethodDlg2.RunLength      = 2;
                        exportMethodDlg2.SetTemplateFile("VerifyETemplate.exp");
                    });
                    PauseForScreenShot <ExportMethodDlg>("Exporting 2 minute method", 9);
                    OkDialog(exportMethodDlg2, exportMethodDlg2.CancelDialog);
                }

                // Export transition list
                {
                    var exportTransitionList = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                    RunUI(() =>
                    {
                        exportTransitionList.InstrumentType = ExportInstrumentType.WATERS_XEVO_TQ;
                        exportTransitionList.MethodType     = ExportMethodType.Standard;
                        exportTransitionList.RunLength      = 2;
                    });
                    PauseForScreenShot <ExportMethodDlg>("Exporting transition list", 10);
                    OkDialog(exportTransitionList, exportTransitionList.CancelDialog);
                }

                using (new WaitDocumentChange(1, true))
                {
                    var importResultsDlg1     = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                    var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets =
                                                                                      importResultsDlg1.GetDataSourcePathsFile(null));
                    RunUI(() =>
                    {
                        openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(GetTestPath("Unscheduled"));
                        openDataSourceDialog1.SelectAllFileType(ExtWatersRaw);
                    });
                    PauseForScreenShot <OpenDataSourceDialog>("Import Results Files form", 11);
                    OkDialog(openDataSourceDialog1, openDataSourceDialog1.Open);

                    var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg1.OkDialog);
                    PauseForScreenShot <ImportResultsNameDlg>("Import Results common name form", 12);
                    OkDialog(importResultsNameDlg, importResultsNameDlg.OkDialog);
                    OkDialog(importResultsDlg1, importResultsDlg1.OkDialog);
                }

                SelectNode(SrmDocument.Level.Molecules, 0);
                SelectNode(SrmDocument.Level.MoleculeGroups, 0);

                PauseForScreenShot <SkylineWindow>("Skyline window multi-target graph", 13);

                // Renaming replicates
                {
                    var      manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
                    string[] repNames         = new[] { "2 min", "5 min" };
                    RunUI(() => manageResultsDlg.Left = SkylineWindow.Right + 50);
                    for (var i = 0; i < 2; i++)
                    {
                        doc = SkylineWindow.Document;
                        var chromatograms = doc.Settings.MeasuredResults.Chromatograms;
                        var chrom         = chromatograms[i];
                        RunUI(() =>
                        {
                            manageResultsDlg.SelectedChromatograms = new[] { chrom };
                        });

                        var renameDlg = ShowDialog <RenameResultDlg>(manageResultsDlg.RenameResult);
                        RunUI(() => renameDlg.ReplicateName = repNames[i]);
                        if (i == 0)
                        {
                            PauseForScreenShot <SkylineWindow>("Manage Results and Rename Replicate (PrtScn and select in Paint)", 14);
                        }
                        OkDialog(renameDlg, renameDlg.OkDialog);
                    }
                    OkDialog(manageResultsDlg, manageResultsDlg.OkDialog);
                }

                PauseForScreenShot <SkylineWindow>("Skyline window (renamed)", 15);

                var docResults = SkylineWindow.Document;

                var msg = "";
                foreach (var chromatogramSet in docResults.Settings.MeasuredResults.Chromatograms)
                {
                    try
                    {
                        AssertResult.IsDocumentResultsState(docResults, chromatogramSet.Name, 18, 18, 18, 18, 18);
                    }
                    catch (Exception x)
                    {
                        msg += TextUtil.LineSeparate(x.Message);
                    }
                }
                if (!string.IsNullOrEmpty(msg))
                {
                    Assert.IsTrue(string.IsNullOrEmpty(msg), msg);
                }
                RunUI(() =>
                {
                    SkylineWindow.ShowPeakAreaReplicateComparison();
                    SkylineWindow.ShowRTReplicateGraph();
                    SkylineWindow.ArrangeGraphsTiled();
                });
                RestoreViewOnScreen(16);
                SelectNode(SrmDocument.Level.MoleculeGroups, 0);
                WaitForGraphs();
                RunUI(() =>
                {
                    SkylineWindow.Size = new Size(1054, 587);
                    AdjustSequenceTreePanelWidth(true);
                });

                PauseForScreenShot <SkylineWindow>("Skyline window multi-replicate layout", 16);

                // Set zoom to show better peak separation in 5 minute run
                for (var i = 0; i < 2; i++)
                {
                    WaitForGraphs();
                    RunUI(() => SkylineWindow.GraphChromatograms.ToArray()[i].ZoomTo(.8, 1.8, 1.39e+8));
                    WaitForGraphs();
                }
                PauseForScreenShot <SkylineWindow>("Skyline window showing relative peak separation", 17);

                // Set time window
                {
                    var peptideSettingsDlg = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                    RunUI(() =>
                    {
                        // ReSharper disable once RedundantCast
                        peptideSettingsDlg.SelectedTab = (PeptideSettingsUI.TABS) 0; //regular enum does not work because of the hidden tabs in the Small Molecule mode.
                        peptideSettingsDlg.TimeWindow  = 1;
                    });
                    PauseForScreenShot <PeptideSettingsUI>("Setting scheduled transition list time window", 18);
                    OkDialog(peptideSettingsDlg, peptideSettingsDlg.OkDialog);
                }

                // Export transition list
                {
                    var exportTransitionList = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                    RunUI(() =>
                    {
                        exportTransitionList.InstrumentType = ExportInstrumentType.WATERS_XEVO_TQ;
                        exportTransitionList.MethodType     = ExportMethodType.Scheduled;
                        exportTransitionList.OptimizeType   = ExportOptimize.NONE;
                    });
                    PauseForScreenShot <ExportMethodDlg>("Exporting scheduled transition list", 19);

                    var schedulingOptionsDlg = ShowDialog <SchedulingOptionsDlg>(() => exportTransitionList.OkDialog(GetTestPath("EnergyMet_5minutes_scheduled.csv")));
                    RunUI(() =>
                    {
                        schedulingOptionsDlg.Algorithm    = ExportSchedulingAlgorithm.Single;
                        schedulingOptionsDlg.ReplicateNum = 1;  // 5 min
                    });
                    PauseForScreenShot <SchedulingOptionsDlg>("Exporting scheduled transition list - choose replicate", 19);
                    OkDialog(schedulingOptionsDlg, schedulingOptionsDlg.OkDialog);
                    WaitForClosedForm(exportTransitionList);
                }

                using (new WaitDocumentChange(1, true))
                {
                    var importResultsDlg1     = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                    var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets =
                                                                                      importResultsDlg1.GetDataSourcePathsFile(null));
                    RunUI(() =>
                    {
                        openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(GetTestPath("Scheduled"));
                        openDataSourceDialog1.SelectAllFileType(ExtWatersRaw);
                    });
                    OkDialog(openDataSourceDialog1, openDataSourceDialog1.Open);

                    var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg1.OkDialog);
                    RunUI(() => importResultsNameDlg.IsRemove = false);
                    PauseForScreenShot <ImportResultsNameDlg>("Import Results common name form, not changing names", 20);
                    OkDialog(importResultsNameDlg, importResultsNameDlg.OkDialog);
                }

                // Remove 2 minute gradient
                // Renaming replicates
                string[] newNames = { "1:1_1", "1:1_2", "2:1_2", "1:2_2" };
                {
                    var manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
                    SelectReplicate(manageResultsDlg, 0);

                    PauseForScreenShot <SkylineWindow>("Manage Results removing 2 min", 21);

                    RunUI(manageResultsDlg.RemoveReplicates);

                    for (var i = 0; i < newNames.Length; i++)
                    {
                        SelectReplicate(manageResultsDlg, i + 1);
                        RunDlg <RenameResultDlg>(manageResultsDlg.RenameResult, renameDlg =>
                        {
                            renameDlg.ReplicateName = newNames[i];
                            renameDlg.OkDialog();
                        });
                    }

                    PauseForScreenShot <SkylineWindow>("Manage Results replicate renamed", 22);
                    OkDialog(manageResultsDlg, manageResultsDlg.OkDialog);
                }

                SelectNode(SrmDocument.Level.Molecules, 0);
                RunUI(() =>
                {
                    var molNode = SkylineWindow.SelectedNode;
                    molNode.Expand();
                    Assert.AreEqual(2, molNode.Nodes.Count);
                    molNode.Nodes[0].Expand();
                    molNode.Nodes[1].Expand();
                    SkylineWindow.ArrangeGraphsTabbed();
                });
                PauseForScreenShot <SkylineWindow>("Skyline window with calibration data", 23);

                // Linearity
                var documentGrid = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));
                RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates));

                double[] concentrations      = { 1, 1, 2, 0.5 };
                var      namedConcentrations = newNames.Select((n, i) => new Tuple <string, double?>(n, concentrations[i]));
                SetDocumentGridSampleTypesAndConcentrations(namedConcentrations.ToDictionary(t => t.Item1,
                                                                                             t => new Tuple <SampleType, double?>(SampleType.STANDARD, t.Item2)));
                RunUI(() =>
                {
                    var gridFloatingWindow  = documentGrid.Parent.Parent;
                    gridFloatingWindow.Size = new Size(370, 230);
                    gridFloatingWindow.Top  = SkylineWindow.Top;
                    gridFloatingWindow.Left = SkylineWindow.Right + 20;
                });
                PauseForScreenShot <DocumentGridForm>("Document Grid - sample types and concentrations ", 23);
                RunUI(() => SkylineWindow.ShowDocumentGrid(false));

                using (new WaitDocumentChange(1, true))
                {
                    // Quant settings
                    var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

                    RunUI(() =>
                    {
                        // ReSharper disable once RedundantCast
                        peptideSettingsUI.SelectedTab              = (PeptideSettingsUI.TABS) 3;
                        peptideSettingsUI.QuantRegressionFit       = RegressionFit.LINEAR;
                        peptideSettingsUI.QuantNormalizationMethod =
                            new NormalizationMethod.RatioToLabel(IsotopeLabelType.heavy);
                        peptideSettingsUI.QuantUnits = "ratio to heavy";
                    });

                    PauseForScreenShot <PeptideSettingsUI.QuantificationTab>("Peptide Settings - Quantitation", 24);
                    OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
                }

                var calibrationForm = ShowDialog <CalibrationForm>(() => SkylineWindow.ShowCalibrationForm());
                RunUI(() =>
                {
                    var calibrationFloatingWindow   = calibrationForm.Parent.Parent;
                    calibrationFloatingWindow.Width = 565;
                    calibrationFloatingWindow.Top   = SkylineWindow.Top;
                    calibrationFloatingWindow.Left  = SkylineWindow.Right + 20;
                });
                PauseForScreenShot <CalibrationForm>("Calibration Curve ", 25);
                OkDialog(calibrationForm, calibrationForm.Close); // Hide the calibration window

                {
                    var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                    RunUI(() => transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Prediction);
                    var editCurrentCE = ShowDialog <EditCEDlg>(transitionSettingsUI.EditCECurrent);
                    RunUI(() =>
                    {
                        editCurrentCE.StepSize  = 2;
                        editCurrentCE.StepCount = 5;
                    });
                    PauseForScreenShot <EditCEDlg>("Edit Collision Energy Equation form", 26);

                    RunUI(() =>
                    {
                        editCurrentCE.OkDialog();
                        transitionSettingsUI.UseOptimized = true;
                        transitionSettingsUI.OptimizeType = OptimizedMethodType.Transition.GetLocalizedString();
                    });
                    PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings - Prediction tab", 27);
                    OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                }

                // Export transition lists
                {
                    var exportTransitionList = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                    RunUI(() =>
                    {
                        exportTransitionList.ExportStrategy = ExportStrategy.Buckets;
                        exportTransitionList.IgnoreProteins = true;
                        exportTransitionList.MaxTransitions = 100;
                        exportTransitionList.InstrumentType = ExportInstrumentType.WATERS_XEVO_TQ;
                        exportTransitionList.MethodType     = ExportMethodType.Scheduled;
                        exportTransitionList.OptimizeType   = ExportOptimize.CE;
                    });
                    PauseForScreenShot <ExportMethodDlg>("Exporting scheduled transition list", 28);

                    var scheduleDlg = ShowDialog <SchedulingOptionsDlg>(() => exportTransitionList.OkDialog(GetTestPath("EnergyMet_5minutes_ceopt.csv")));
                    PauseForScreenShot <SchedulingOptionsDlg>("Scheduling", 29);
                    OkDialog(scheduleDlg, scheduleDlg.OkDialog);
                }

                // Import CE optimization runs
                using (new WaitDocumentChange(1, true))
                {
                    var importResultsDlg1 = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                    RunUI(() =>
                    {
                        importResultsDlg1.RadioCreateMultipleChecked = true;
                        importResultsDlg1.OptimizationName           = ExportOptimize.CE;
                        importResultsDlg1.ReplicateName = "CE Optimization";
                    });
                    PauseForScreenShot <ImportResultsDlg>("Setting new replicate name to CE Optimization", 30);
                    var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.OkDialog());
                    RunUI(() =>
                    {
                        openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(GetTestPath("CE Optimization"));
                        openDataSourceDialog1.SelectAllFileType(ExtWatersRaw);
                    });
                    PauseForScreenShot <OpenDataSourceDialog>("Import Results Files form", 31);
                    OkDialog(openDataSourceDialog1, openDataSourceDialog1.Open);
                }

                PauseForScreenShot <SkylineWindow>("Skyline shows new replicate \"CE Optimization\"", 32);
                RunUI(() =>
                {
                    SkylineWindow.Size = new Size(1600, 960);
                    SkylineWindow.ShowGraphRetentionTime(false, GraphTypeSummary.replicate);
                    SkylineWindow.AutoZoomBestPeak();
                    AdjustSequenceTreePanelWidth();
                    SkylineWindow.ShowSingleTransition();
                    SkylineWindow.ShowSplitChromatogramGraph(true);
                });
                PauseForScreenShot <SkylineWindow>("Split graph", 33);

                RunUI(() =>
                {
                    SkylineWindow.ShowPeakAreaLegend(false);
                });
                PauseForScreenShot <SkylineWindow>("No legend", 34);

                // Show Pentose-P
                SelectNode(SrmDocument.Level.Molecules, 6);
                PauseForScreenShot <SkylineWindow>("Pentose-P", 35);

                if (IsCoverShotMode)
                {
                    RunUI(() =>
                    {
                        Settings.Default.ChromatogramFontSize = 14;
                        Settings.Default.AreaFontSize         = 14;
                        SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                        SkylineWindow.ShowChromatogramLegends(false);
                    });

                    RestoreCoverViewOnScreen();
                    TakeCoverShot();
                    return;
                }

                // Export final transition list
                {
                    var exportTransitionList = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                    RunUI(() =>
                    {
                        exportTransitionList.ExportStrategy = ExportStrategy.Single;
                        exportTransitionList.IgnoreProteins = true;
                        exportTransitionList.MaxTransitions = 100;
                        exportTransitionList.InstrumentType = ExportInstrumentType.WATERS_XEVO_TQ;
                        exportTransitionList.MethodType     = ExportMethodType.Scheduled;
                    });
                    PauseForScreenShot <ExportMethodDlg>("Exporting final optimized transition list", 36);

                    var scheduleDlg = ShowDialog <SchedulingOptionsDlg>(() => exportTransitionList.OkDialog(GetTestPath("EnergyMet_5minutes_optimal.csv")));
                    PauseForScreenShot <SchedulingOptionsDlg>("Final Scheduling", 37);
                    OkDialog(scheduleDlg, scheduleDlg.OkDialog);
                }
            }
        }
        protected override void DoTest()
        {
            // Inserting a Transition List, p. 2
            {
                var doc = SkylineWindow.Document;

                var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);
                RunUI(() =>
                {
                    pasteDlg.IsMolecule = false;  // Default peptide view
                    pasteDlg.Size       = new Size(800, 275);
                });
                PauseForScreenShot <PasteDlg>("Paste Dialog in peptide mode", 2);

                RunUI(() =>
                {
                    pasteDlg.IsMolecule = true;
                    pasteDlg.SetSmallMoleculeColumns(null);  // Default columns
                });
                PauseForScreenShot <PasteDlg>("Paste Dialog in small molecule mode, default columns - show Columns checklist", 3);


                var columnsOrdered = new[]
                {
                    // Prepare transition list insert window to match tutorial
                    SmallMoleculeTransitionListColumnHeaders.moleculeGroup,
                    SmallMoleculeTransitionListColumnHeaders.namePrecursor,
                    SmallMoleculeTransitionListColumnHeaders.labelType,
                    SmallMoleculeTransitionListColumnHeaders.mzPrecursor,
                    SmallMoleculeTransitionListColumnHeaders.chargePrecursor,
                    SmallMoleculeTransitionListColumnHeaders.mzProduct,
                    SmallMoleculeTransitionListColumnHeaders.chargeProduct,
                    SmallMoleculeTransitionListColumnHeaders.coneVoltage,
                    SmallMoleculeTransitionListColumnHeaders.cePrecursor,
                    SmallMoleculeTransitionListColumnHeaders.rtPrecursor,
                }.ToList();
                RunUI(() => { pasteDlg.SetSmallMoleculeColumns(columnsOrdered); });
                WaitForConditionUI(() => pasteDlg.GetUsableColumnCount() == columnsOrdered.Count);
                PauseForScreenShot <PasteDlg>("Paste Dialog with selected and ordered columns", 4);

                var text = "DrugX,Drug,light,283.04,1,129.96,1,26,16,2.7\r\nDrugX,Drug,heavy,286.04,1,133.00,1,26,16,2.7\r\n";
                text = text.Replace(',', TextUtil.CsvSeparator).Replace(".", LocalizationHelper.CurrentCulture.NumberFormat.NumberDecimalSeparator);
                SetClipboardText(text);
                RunUI(pasteDlg.PasteTransitions);
                RunUI(pasteDlg.ValidateCells);
                PauseForScreenShot <PasteDlg>("Paste Dialog with validated contents", 5);

                OkDialog(pasteDlg, pasteDlg.OkDialog);
                var docTargets = WaitForDocumentChange(doc);

                AssertEx.IsDocumentState(docTargets, null, 1, 1, 2, 2);
                Assert.IsFalse(docTargets.MoleculeTransitions.Any(t => t.Transition.IsPrecursor()));

                RunUI(() =>
                {
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.Size = new Size(957, 654);
                });
                SelectNode(SrmDocument.Level.Transitions, 0);
                SelectNode(SrmDocument.Level.Transitions, 1);
                SelectNode(SrmDocument.Level.Molecules, 0);
                PauseForScreenShot <SkylineWindow>("Skyline with small molecule targets", 5);

                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    // Predicition Settings
                    transitionSettingsUI.SelectedTab             = TransitionSettingsUI.TABS.Prediction;
                    transitionSettingsUI.PrecursorMassType       = MassType.Monoisotopic;
                    transitionSettingsUI.FragmentMassType        = MassType.Monoisotopic;
                    transitionSettingsUI.RegressionCEName        = "Waters Xevo";                            // Collision Energy
                    transitionSettingsUI.RegressionDPName        = Resources.SettingsList_ELEMENT_NONE_None; // Declustering Potential
                    transitionSettingsUI.OptimizationLibraryName = Resources.SettingsList_ELEMENT_NONE_None; // Optimization Library
                    transitionSettingsUI.RegressionCOVName       = Resources.SettingsList_ELEMENT_NONE_None; // Compensation Voltage

                    transitionSettingsUI.UseOptimized = true;
                    transitionSettingsUI.OptimizeType = OptimizedMethodType.Transition.GetLocalizedString();
                });
                PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings - Prediction tab", 4);


                RunUI(() =>
                {
                    // Filter Settings
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.SelectedPeptidesSmallMolsSubTab = 1;
                    transitionSettingsUI.SmallMoleculePrecursorAdducts   = Adduct.M_PLUS_H.AdductFormula;
                    transitionSettingsUI.SmallMoleculeFragmentAdducts    = Adduct.M_PLUS.AdductFormula;
                    transitionSettingsUI.SmallMoleculeFragmentTypes      = TransitionFilter.SMALL_MOLECULE_FRAGMENT_CHAR;
                    transitionSettingsUI.FragmentMassType = MassType.Monoisotopic;
                    transitionSettingsUI.SetAutoSelect    = true;
                });
                PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings -Filter tab", 4);


                RunUI(() =>
                {
                    // Instrument Settings
                    transitionSettingsUI.SelectedTab      = TransitionSettingsUI.TABS.Instrument;
                    transitionSettingsUI.MinMz            = 50;
                    transitionSettingsUI.MaxMz            = 1500;
                    transitionSettingsUI.MZMatchTolerance = .02;
                    transitionSettingsUI.MinTime          = null;
                    transitionSettingsUI.MaxTime          = null;
                });
                PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings -Instrument tab", 4);

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                WaitForDocumentChange(docTargets);

                RunUI(() => SkylineWindow.SaveDocument(GetTestPath("SMQuant_v1.sky")));

                ImportReplicates(true);

                SelectNode(SrmDocument.Level.Transitions, 1);
                SelectNode(SrmDocument.Level.Molecules, 0);

                PauseForScreenShot <SkylineWindow>("Skyline window multi-precursor graph", 8);

                var docResults = SkylineWindow.Document;

                var expectedTransCount = new Dictionary <string, int[]>
                {
                    // peptide count, transition groups, heavy transition groups, tranistions, heavy transitions
                    { "Blank_01", new[] { 1, 0, 1, 0, 1 } },
                    { "DoubleBlank1", new[] { 1, 0, 1, 0, 1 } },
                    { "DoubleBlank2", new[] { 1, 0, 1, 0, 1 } },
                    { "DoubleBlank3", new[] { 1, 0, 1, 0, 1 } },
                    { "47_0_1_1_00_1021523591", new[] { 1, 0, 1, 0, 1 } },
                };
                var msg = "";
                foreach (var chromatogramSet in docResults.Settings.MeasuredResults.Chromatograms)
                {
                    int[] transitions;
                    if (!expectedTransCount.TryGetValue(chromatogramSet.Name, out transitions))
                    {
                        transitions = new[] { 1, 1, 1, 1, 1 }
                    }
                    ;                                        // Most have this value
                    try
                    {
                        AssertResult.IsDocumentResultsState(docResults, chromatogramSet.Name, transitions[0],
                                                            transitions[1], transitions[2], transitions[3], transitions[4]);
                    }
                    catch (Exception x)
                    {
                        msg += TextUtil.LineSeparate(x.Message);
                    }
                }
                if (!string.IsNullOrEmpty(msg))
                {
                    Assert.IsTrue(string.IsNullOrEmpty(msg), msg);
                }

                RestoreViewOnScreen(9);
                SelectNode(SrmDocument.Level.Transitions, 0);
                SelectNode(SrmDocument.Level.Transitions, 1);
                SelectNode(SrmDocument.Level.Molecules, 0);
                PauseForScreenShot <SkylineWindow>("Skyline window multi-replicate layout", 9);

                // Peak integration correction
                ActivateReplicate("DoubleBlank1"); // First with mismatched RT
                PauseForScreenShot <SkylineWindow>("Selected replicate with unexpected RT", 10);
                ChangePeakBounds("DoubleBlank2", 26.5, 27.5);
                ChangePeakBounds("DoubleBlank3", 26.5, 27.5);
                ChangePeakBounds("DoubleBlank1", 26.5, 27.5);
                PauseForScreenShot <SkylineWindow>("Adjusted peak boundaries", 13);

                using (new WaitDocumentChange(1, true))
                {
                    // Quant settings
                    var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

                    RunUI(() =>
                    {
                        peptideSettingsUI.SelectedTab              = PeptideSettingsUI.TABS.Quantification;
                        peptideSettingsUI.QuantRegressionFit       = RegressionFit.LINEAR;
                        peptideSettingsUI.QuantNormalizationMethod =
                            new NormalizationMethod.RatioToLabel(IsotopeLabelType.heavy);
                        peptideSettingsUI.QuantRegressionWeighting = RegressionWeighting.ONE_OVER_X_SQUARED;
                        peptideSettingsUI.QuantMsLevel             = null; // All
                        peptideSettingsUI.QuantUnits = "uM";
                    });

                    PauseForScreenShot <PeptideSettingsUI.QuantificationTab>("Peptide Settings - Quantitation", 14);
                    OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
                }

                // Setting sample types
                WaitForClosedForm <DocumentGridForm>();
                var documentGrid = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));
                RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates));
                PauseForScreenShot <DocumentGridForm>("Document Grid - replicates", 15);

                /*IDictionary<string, Tuple<SampleType, double?>> sampleTypes =
                 *  new Dictionary<string, Tuple<SampleType, double?>> {
                 *  {"Blank_01", new Tuple<SampleType, double?>(SampleType.BLANK,null)},
                 *  {"Blank_02", new Tuple<SampleType, double?>(SampleType.BLANK,null)},
                 *  {"Blank_03", new Tuple<SampleType, double?>(SampleType.BLANK,null)},
                 *  {"Cal_1_01", new Tuple<SampleType, double?>(SampleType.STANDARD,10)},
                 *  {"Cal_1_02", new Tuple<SampleType, double?>(SampleType.STANDARD,10)},
                 *  {"Cal_2_01", new Tuple<SampleType, double?>(SampleType.STANDARD,20)},
                 *  {"Cal_2_02", new Tuple<SampleType, double?>(SampleType.STANDARD,20)},
                 *  {"Cal_3_01", new Tuple<SampleType, double?>(SampleType.STANDARD,100)},
                 *  {"Cal_3_02", new Tuple<SampleType, double?>(SampleType.STANDARD,100)},
                 *  {"Cal_4_01", new Tuple<SampleType, double?>(SampleType.STANDARD,200)},
                 *  {"Cal_4_02", new Tuple<SampleType, double?>(SampleType.STANDARD,200)},
                 *  {"Cal_5_01", new Tuple<SampleType, double?>(SampleType.STANDARD,400)},
                 *  {"Cal_5_02", new Tuple<SampleType, double?>(SampleType.STANDARD,400)},
                 *  {"Cal_6_01", new Tuple<SampleType, double?>(SampleType.STANDARD,600)},
                 *  {"Cal_6_02", new Tuple<SampleType, double?>(SampleType.STANDARD,600)},
                 *  {"Cal_7_01", new Tuple<SampleType, double?>(SampleType.STANDARD,800)},
                 *  {"Cal_7_02", new Tuple<SampleType, double?>(SampleType.STANDARD,800)},
                 *  {"DoubleBlank1", new Tuple<SampleType, double?>(SampleType.DOUBLE_BLANK,null)},
                 *  {"DoubleBlank2", new Tuple<SampleType, double?>(SampleType.DOUBLE_BLANK,null)},
                 *  {"DoubleBlank3", new Tuple<SampleType, double?>(SampleType.DOUBLE_BLANK,null)},
                 *  {"QC_High_01", new Tuple<SampleType, double?>(SampleType.QC,589)},
                 *  {"QC_High_02", new Tuple<SampleType, double?>(SampleType.QC,589)},
                 *  {"QC_High_03", new Tuple<SampleType, double?>(SampleType.QC,589)},
                 *  {"QC_Low_01", new Tuple<SampleType, double?>(SampleType.QC,121)},
                 *  {"QC_Low_02", new Tuple<SampleType, double?>(SampleType.QC,121)},
                 *  {"QC_Low_03", new Tuple<SampleType, double?>(SampleType.QC,121)},
                 *  {"QC_Mid_01", new Tuple<SampleType, double?>(SampleType.QC,346)},
                 *  {"QC_Mid_02", new Tuple<SampleType, double?>(SampleType.QC,346)},
                 *  {"QC_Mid_03", new Tuple<SampleType, double?>(SampleType.QC,346)}
                 * };*/

                SetExcelFileClipboardText(GetTestPath("Concentrations.xlsx"), "Sheet1", 3, false);
                RunUI(() =>
                {
                    // Find and select Blank_01 cell
                    var replicateColumnIndex = documentGrid.FindColumn(PropertyPath.Root).Index;
                    documentGrid.DataGridView.CurrentCell = documentGrid.DataGridView.Rows.Cast <DataGridViewRow>()
                                                            .Select(row => row.Cells[replicateColumnIndex])
                                                            .FirstOrDefault(cell => ((Replicate)cell.Value).Name == "Blank_01");

                    documentGrid.DataGridView.SendPaste();
                });
                //SetDocumentGridSampleTypesAndConcentrations(sampleTypes);
                PauseForScreenShot <DocumentGridForm>("Document Grid - sample types - enlarge for screenshot so all rows can be seen ", 16);

                RunUI(() => SkylineWindow.ShowCalibrationForm());
                PauseForScreenShot <CalibrationForm>("Calibration Curve ", 18);

                EnableDocumentGridColumns(documentGrid, Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates, 47,
                                          new[]
                {
                    "Proteins!*.Peptides!*.Results!*.Value.Quantification.Accuracy",
                    "Proteins!*.Peptides!*.Results!*.Value.ExcludeFromCalibration"
                },
                                          "Replicates_custom_quant");
                PauseForScreenShot <DocumentGridForm>("Custom document grid - resize so all rows are visible before screenshot", 19);

                SetDocumentGridExcludeFromCalibration();
                PauseForScreenShot <CalibrationForm>("Calibration Curve - outliers disabled", 20);

                ImportReplicates(false); // Import the rest of the replicates
                PauseForScreenShot <CalibrationForm>("Calibration Curve - all replicates loaded", 21);

                RunUI(() => documentGrid.ChooseView(Resources.ReportSpecList_GetDefaults_Peptide_Ratio_Results));
                WaitForConditionUI(() => documentGrid.ColumnCount > 6);
                RunUI(() => {
                    var colReplicate = documentGrid.FindColumn(PropertyPath.Parse("Results!*.Value.ResultFile.Replicate"));
                    documentGrid.DataGridView.Sort(colReplicate, ListSortDirection.Ascending);
                });

                PauseForScreenShot <DocumentGridForm>("Document Grid - Peptide Ratio Results", 15);
            }
        }
        protected override void DoTest()
        {
            TestSmallMolecules = false; // The presence of the extra test node without any results is incompatible with what's being tested here.

            // 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));

            // show the empty Transition Setting dialog
            var transitionSettingsDlg = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);

            RunUI(() => transitionSettingsDlg.SelectedTab = TransitionSettingsUI.TABS.FullScan);
            PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Transition Settings - Full-Scan tab nothing set", 2);
            OkDialog(transitionSettingsDlg, transitionSettingsDlg.OkDialog);

            // 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
            };
            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);
            });
            PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library populated page", 4);

            var ambiguousDlg = ShowDialog <MessageDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck);

            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);

            // 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);
            PauseForScreenShot <ImportPeptideSearchDlg.ChromatogramsPage>("Import Peptide Search - Extract Chromatograms page", 5);

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

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

            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", 7);
            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", 8);

            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", 10);

            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);
            PauseForScreenShot <AllChromatogramsGraph>("Loading chromatograms window", 11);
            WaitForDocumentChangeLoaded(doc, 8 * 60 * 1000); // 10 minutes

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

            PauseForScreenShot <MultiButtonMsgDlg>("Add mods alert", 12);
            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", 13);
            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.0001);
                libraryExplorer.SelectedIndex++;
                Assert.AreNotEqual(sourceFirst, libraryExplorer.SourceFile);
                Assert.AreNotEqual(timeFirst, libraryExplorer.RetentionTime, 0.0001);
            });
            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();
            });
            RunUI(() =>
            {
                // Make window screenshot size
                if (IsPauseForScreenShots && SkylineWindow.WindowState != FormWindowState.Maximized)
                {
                    SkylineWindow.Width  = 1160;
                    SkylineWindow.Height = 792;
                }
            });
            RestoreViewOnScreen(13);
            PauseForScreenShot("Main window with imported data", 14);

//            RunUIWithDocumentWait(() =>
//            {
//                SkylineWindow.ToggleIntegrateAll(); // TODO: No longer necessary.  Change in tutorial
//            });
            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(true);
                SkylineWindow.ShowPeakAreaReplicateComparison();
                SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.none);
                Settings.Default.ShowDotProductPeakArea = true;
                Settings.Default.ShowLibraryPeakArea    = true;
            });
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas view (show context menu)", 16);

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

            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", 19);
            CheckAnnotations(TIB_L, pepIndex, atest++);

            var alignmentForm = ShowDialog <AlignmentForm>(() => SkylineWindow.ShowRetentionTimeAlignmentForm());

            RunUI(() =>
            {
                alignmentForm.Width  = 711;
                alignmentForm.Height = 561;
                alignmentForm.ComboAlignAgainst.SelectedIndex = 0;     // to match what's in the tutorial doc
            });
            PauseForScreenShot <AlignmentForm>("Retention time alignment form", 20);

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

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

            ZoomSingle(TIP3, 32.6, 41.4); // simulate the wheel scroll described in tutorial
            PauseForScreenShot("Chromatogram graph metafile showing all peaks for 1_MCF_TiB_L", 22);
            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

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

            int[] m1Thru4 = { 1, 2, 3, 4, 5 };
            PickTransitions(pepIndex, m1Thru4, "Transition pick list filtered", 24, "Transition pick list unfiltered", 24); // turn on chromatograms
            PickPeakBoth(pepIndex, 36.992836, 37.3896027);                                                                  // select peak for both chromatograms at these respective retention times
            ZoomSingle(TIP3, 32.4, 39.6);                                                                                   // set the view for screenshot
            PauseForScreenShot("Chromatogram graph metafile comparing 33 and 37 minute peaks", 25);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

            RevertDoc(undoIndex);                             // undo changes
            pepIndex = JumpToPeptide("ASLGSLEGEAEAEASSPKGK"); // Not L10N
            Assert.IsTrue(10 == pepIndex);
            PauseForScreenShot("Chhromatogram graph meta files for peptide ASLGSLEGEAEAEASSPKGK", 26);
            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);     // simulate the wheel scroll described in tutorial
            PauseForScreenShot("upper - Chromatogram graph metafile for peptide ASLGSLEGEAEAEASSPKGK with adjusted integration", 27);
            CheckAnnotations(TIP3, pepIndex, atest++);

            RevertDoc(undoIndex);                              // undo changes
            pepIndex = JumpToPeptide("AEGEWEDQEALDYFSDKESGK"); // Not L10N
            PauseForScreenShot("lower - Chromatogram graph metafiles for peptide AEGEWEDQEALDYFSDKESGK", 27);
            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", 28);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

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

            pepIndex = JumpToPeptide("YGPADVEDTTGSGATDSKDDDDIDLFGSDDEEESEEAKR"); // Not L10N
            PauseForScreenShot("upper - Peak Areas graph metafile for peptide YGPADVEDTTGSGATDSKDDDDIDLFGSDDEEESEEAKR", 30);

            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", 30);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

            // page 32 zooming setup
            RunUI(() =>
            {
                SkylineWindow.SynchronizeZooming(true);
                SkylineWindow.LockYChrom(false);
                SkylineWindow.AlignToFile = SkylineWindow.GraphChromatograms.ToArray()[TIP3].GetChromFileInfoId(); // align to Tip3
            });
            ZoomBoth(36.5, 39.5, 1600);                                                                            // simulate the wheel scroll described in tutorial
            RunUI(() => SkylineWindow.ShowChromatogramLegends(false));
            PauseForScreenShot("Chromatogram graphs clipped from main window with synchronized zooming", 32);

            RestoreViewOnScreen(33);                                                                                                      // float the  Library Match window TODO this causes a crash at next call to ChangePeakBounds, in pwiz.Skyline.Controls.Graphs.GraphChromatogram.ChromGroupInfos.get() Line 492 , why?
            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)", 33);

            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)", 33);

            RestoreViewOnScreen(34);                    // back to normal view

            pepIndex = JumpToPeptide("GVVDSEDLPLNISR"); // Not L10N
            RunUI(() => SkylineWindow.ShowChromatogramLegends(true));
            PauseForScreenShot("upper - Chromatogram graph metafiles for peptide GVVDSEDLPLNISR", 34);

            ZoomBoth(35.05, 36.9, 480);
            PauseForScreenShot("lower - Chromatogram graph metafile - effect of zoom ", 34);
            ChangePeakBounds(TIP3, pepIndex, 35.7, 36.5);  // adjust integration per tutorial
            CheckAnnotations(TIP3, pepIndex, atest++);     // check the new idotp values

            /* pepIndex = */ JumpToPeptide("DQVANSAFVER"); // Not L10N
            PauseForScreenShot("Chromatogram graph metafiles for peptide DQVANSAFVER", 35);

//            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)", 36); // 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();
            });
            WaitForDocumentChangeLoaded(doc);

            // Now deviating from the tutorial script for a moment to make sure we can choose a Scheduled export method.
            RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, dlg =>
            {
                dlg.MinPeptides = 1; // Not L10N
                const double minPeakFoundRatio = 0.1;
                dlg.MinPeakFoundRatio          = minPeakFoundRatio;
                dlg.OkDialog();
            });

            // 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);

            RunUI(() => SkylineWindow.SaveDocument());
            RunUI(SkylineWindow.NewDocument);
        }
Exemple #5
0
        protected override void DoTest()
        {
            // Setting the UI mode, p 2
            var startPage = WaitForOpenForm <StartPage>();

            RunUI(() => startPage.SetUIMode(SrmDocument.DOCUMENT_TYPE.proteomic));
            PauseForScreenShot <StartPage>("Start Window proteomic", 2);
            RunUI(() => startPage.SetUIMode(SrmDocument.DOCUMENT_TYPE.small_molecules));
            PauseForScreenShot <StartPage>("Start Window small molecule", 3);
            RunUI(() => startPage.DoAction(skylineWindow => true));
            WaitForOpenForm <SkylineWindow>();

            // Inserting a Transition List, p. 2
            {
                var doc = SkylineWindow.Document;

                for (var retry = 0; retry < 2; retry++)
                {
                    var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);

                    RunUI(() =>
                    {
                        pasteDlg.SetSmallMoleculeColumns(null);  // Default columns
                    });
                    if (retry == 0)
                    {
                        PauseForScreenShot <PasteDlg>("Paste Dialog in small molecule mode, default columns - show Columns checklist", 3);
                    }


                    var columnsOrdered = new[]
                    {
                        // Prepare transition list insert window to match tutorial
                        // Molecule List Name,Precursor Name,Precursor Formula,Precursor Adduct,Label Type,Precursor m/z,Precursor Charge,Explicit Retention Time
                        SmallMoleculeTransitionListColumnHeaders.moleculeGroup,
                        SmallMoleculeTransitionListColumnHeaders.namePrecursor,
                        SmallMoleculeTransitionListColumnHeaders.formulaPrecursor,
                        SmallMoleculeTransitionListColumnHeaders.adductPrecursor,
                        SmallMoleculeTransitionListColumnHeaders.labelType,
                        SmallMoleculeTransitionListColumnHeaders.mzPrecursor,
                        SmallMoleculeTransitionListColumnHeaders.chargePrecursor,
                        SmallMoleculeTransitionListColumnHeaders.rtPrecursor,
                    }.ToList();
                    RunUI(() => { pasteDlg.SetSmallMoleculeColumns(columnsOrdered); });
                    WaitForConditionUI(() => pasteDlg.GetUsableColumnCount() == columnsOrdered.Count);
                    if (retry == 0)
                    {
                        PauseForScreenShot <PasteDlg>("Paste Dialog with selected and ordered columns", 4);
                    }

                    var text = GetCsvFileText(GetTestPath("PUFA_TransitionList.csv"), true);
                    if (retry > 0)
                    {
                        // Fix bad charge declaration
                        var z    = string.Format("{0}1{0}", TextUtil.CsvSeparator);
                        var zneg = string.Format("{0}-1{0}", TextUtil.CsvSeparator);
                        text = text.Replace(z, zneg);
                    }
                    SetClipboardText(text);
                    RunUI(pasteDlg.PasteTransitions);
                    RunUI(pasteDlg.ValidateCells);
                    if (retry == 0)
                    {
                        PauseForScreenShot <PasteDlg>("Paste Dialog with validated contents showing charge problem", 5);
                        OkDialog(pasteDlg, pasteDlg.CancelDialog);
                    }
                    else
                    {
                        PauseForScreenShot <PasteDlg>("Paste Dialog with validated contents", 5);
                        OkDialog(pasteDlg, pasteDlg.OkDialog);
                    }
                }
                var docTargets = WaitForDocumentChange(doc);

                AssertEx.IsDocumentState(docTargets, null, 1, 4, 7, 7);
                Assert.IsFalse(docTargets.MoleculeTransitions.Any(t => !t.Transition.IsPrecursor()));

                RunUI(() =>
                {
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.Size = new Size(957, 654);
                    SkylineWindow.ExpandPeptides();
                });
                RestoreViewOnScreen(5);
                PauseForScreenShot <SkylineWindow>("Skyline with small molecule targets - show the right-click menu for setting DHA to be a surrogate standard", 5);

                // Set the standard type of the surrogate standards to StandardType.SURROGATE_STANDARD
                RunUI(() =>
                {
                    List <IdentityPath> pathsToSelect = SkylineWindow.SequenceTree.Nodes.OfType <PeptideGroupTreeNode>()
                                                        .SelectMany(peptideGroup => peptideGroup.Nodes.OfType <PeptideTreeNode>())
                                                        .Where(peptideTreeNode => peptideTreeNode.DocNode.RawTextId.Contains("(DHA)"))
                                                        .Select(treeNode => treeNode.Path)
                                                        .ToList();
                    SkylineWindow.SequenceTree.SelectedPaths = pathsToSelect;
                    SkylineWindow.SetStandardType(StandardType.SURROGATE_STANDARD);
                });


                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);

                RunUI(() =>
                {
                    // Filter Settings
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.SelectedPeptidesSmallMolsSubTab = 1;
                    transitionSettingsUI.SmallMoleculePrecursorAdducts   = Adduct.M_PLUS_H.AdductFormula;
                    transitionSettingsUI.SmallMoleculeFragmentAdducts    = Adduct.M_PLUS.AdductFormula;
                    transitionSettingsUI.SmallMoleculeFragmentTypes      =
                        TransitionFilter.SMALL_MOLECULE_FRAGMENT_CHAR + "," + TransitionFilter.PRECURSOR_ION_CHAR;
                    transitionSettingsUI.FragmentMassType = MassType.Monoisotopic;
                    transitionSettingsUI.SetAutoSelect    = true;
                });
                PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings -Filter tab", 4);


                RunUI(() =>
                {
                    // Full Scan Settings
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.FullScan;
                    transitionSettingsUI.PrecursorIsotopesCurrent = FullScanPrecursorIsotopes.Count;
                    transitionSettingsUI.Peaks = 2;
                    transitionSettingsUI.PrecursorMassAnalyzer   = FullScanMassAnalyzerType.orbitrap;
                    transitionSettingsUI.PrecursorRes            = 70000;
                    transitionSettingsUI.PrecursorResMz          = 200;
                    transitionSettingsUI.RetentionTimeFilterType = RetentionTimeFilterType.none;
                });
                PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings -Full Scan tab", 4);

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                WaitForDocumentChange(docTargets);

                RunUI(() => SkylineWindow.SaveDocument(GetTestPath("FattyAcids_demo.sky")));

                using (new WaitDocumentChange(1, true))
                {
                    var importResultsDlg1     = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                    var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets =
                                                                                      importResultsDlg1.GetDataSourcePathsFile(null));
                    RunUI(() =>
                    {
                        openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(Path.Combine(TestFilesDirs.First().PersistentFilesDir, GetDataFolder()));
                        openDataSourceDialog1.SelectAllFileType(ExtWatersRaw);
                    });
                    PauseForScreenShot <ImportResultsSamplesDlg>("Import Results Files form", 6);
                    OkDialog(openDataSourceDialog1, openDataSourceDialog1.Open);

                    OkDialog(importResultsDlg1, importResultsDlg1.OkDialog);
                }

                SelectNode(SrmDocument.Level.Molecules, 0);
                SelectNode(SrmDocument.Level.MoleculeGroups, 0);

                PauseForScreenShot <SkylineWindow>("Skyline window multi-target graph", 8);

                var docResults = SkylineWindow.Document;

                var expectedTransCount = new Dictionary <string, int[]>
                {
                    // peptides, transition groups, heavy transition groups, tranistions, heavy transitions
                    { "default", new[] { 4, 4, 3, 8, 6 } }, // Most have these values
                    { "ID31609_01_E749_4745_091517", new[] { 4, 4, 3, 7, 6 } },
                };
                var msg = "";
                foreach (var chromatogramSet in docResults.Settings.MeasuredResults.Chromatograms)
                {
                    int[] transitions;
                    if (!expectedTransCount.TryGetValue(chromatogramSet.Name, out transitions))
                    {
                        transitions = expectedTransCount["default"];
                    }
                    try
                    {
                        AssertResult.IsDocumentResultsState(docResults, chromatogramSet.Name, transitions[0], transitions[1], transitions[2], transitions[3], transitions[4]);
                    }
                    catch (Exception x)
                    {
                        msg += TextUtil.LineSeparate(x.Message);
                    }
                }
                if (!string.IsNullOrEmpty(msg))
                {
                    Assert.IsTrue(string.IsNullOrEmpty(msg), msg);
                }
                RestoreViewOnScreen(9);
                var documentGrid = FindOpenForm <DocumentGridForm>();
                if (documentGrid == null)
                {
                    // When running offscreen, can't depend on RestoreViewOnScreen to open document grid
                    RunUI(() => SkylineWindow.ShowDocumentGrid(true));
                    documentGrid = FindOpenForm <DocumentGridForm>();
                }
                RunUI(() => documentGrid.ChooseView(Resources.Resources_ReportSpecList_GetDefaults_Peptide_Quantification));
                PauseForScreenShot <SkylineWindow>("Skyline window multi-replicate layout", 9);

                using (new WaitDocumentChange(1, true))
                {
                    // Quant settings
                    var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

                    RunUI(() =>
                    {
                        peptideSettingsUI.SelectedTab              = PeptideSettingsUI.TABS.Quantification;
                        peptideSettingsUI.QuantRegressionFit       = RegressionFit.LINEAR_THROUGH_ZERO;
                        peptideSettingsUI.QuantNormalizationMethod =
                            new NormalizationMethod.RatioToLabel(IsotopeLabelType.heavy);
                        peptideSettingsUI.QuantRegressionWeighting = RegressionWeighting.NONE;
                        peptideSettingsUI.QuantMsLevel             = null; // All
                        peptideSettingsUI.QuantUnits = "uM";
                    });

                    PauseForScreenShot <PeptideSettingsUI.QuantificationTab>("Peptide Settings - Quantitation", 10);
                    OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
                }

                var documentGrid2 = FindOpenForm <DocumentGridForm>();
                RunUI(() =>
                {
                    documentGrid2.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates);
                });
                WaitForConditionUI(() => (documentGrid2.RowCount == 16)); // Let it initialize

                RunUI(() =>
                {
                    var gridView = documentGrid2.DataGridView;
                    for (var index = 0; index < gridView.Rows.Count; index++)
                    {
                        var row = gridView.Rows[index];
                        if (row.Cells[0].Value.ToString().StartsWith("NIST"))
                        {
                            row.Cells[1].Value = SampleType.STANDARD;
                            row.Cells[2].Value = 1.0;
                        }
                        else if (row.Cells[0].Value.ToString().StartsWith("GW"))
                        {
                            row.Cells[1].Value = SampleType.QC;
                        }
                    }
                });
                // Make sure the edits have flowed to the document
                WaitForConditionUI(() => SkylineWindow.DocumentUI.Settings.MeasuredResults.Chromatograms.Where(c => c.Name.StartsWith("GW")).All(c => c.SampleType.Equals(SampleType.QC)));
                PauseForScreenShot <DocumentGridForm>("Document Grid - replicates", 11);

                // Finish setting up quant
                var documentGrid3 = FindOpenForm <DocumentGridForm>();
                RunUI(() =>
                {
                    documentGrid3.ChooseView(Resources.Resources_ReportSpecList_GetDefaults_Peptide_Quantification);
                });
                WaitForConditionUI(() => (documentGrid3.RowCount > 0 &&
                                          documentGrid3.ColumnCount > 6)); // Let it initialize

                RunUI(() =>
                {
                    var gridView = documentGrid3.DataGridView;
                    var methods  = ((DataGridViewComboBoxCell)gridView.Rows[0].Cells[6]).Items;
                    var ratioToSurrogateHeavyDHA    = ((Tuple <String, NormalizationMethod>)methods[6]).Item2;
                    gridView.Rows[0].Cells[5].Value = 2838.0;
                    gridView.Rows[1].Cells[5].Value = 54.0;
                    gridView.Rows[1].Cells[6].Value = ratioToSurrogateHeavyDHA;
                    gridView.Rows[2].Cells[5].Value = 984.0;
                    gridView.Rows[3].Cells[5].Value = 118.0;
                });

                PauseForScreenShot <DocumentGridForm>("Document Grid - peptide quant again", 11);

                RunUI(() => SkylineWindow.ShowCalibrationForm());
                SelectNode(SrmDocument.Level.Molecules, 0);
                PauseForScreenShot <DocumentGridForm>("Calibration curve", 12);
            }
        }
Exemple #6
0
        protected override void DoTest()
        {
            // iRT Retention Time Prediction
            string standardDocumentFile = GetTestPath("iRT-C18 Standard.sky"); // Not L10N

            RunUI(() => SkylineWindow.OpenFile(standardDocumentFile));
            WaitForDocumentLoaded();                                                       // might have some updating to do for protein metadata
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath("iRT-C18 Calibrate.sky"))); // Not L10N

            // Load raw files for iRT calculator calibration p. 2
            const string unschedHuman1Fileroot = "A_D110907_SiRT_HELA_11_nsMRM_150selected_1_30min-5-35"; // Not L10N
            string       unschedHuman1Name     = unschedHuman1Fileroot.Substring(41, 7);
            const string unschedHuman2Fileroot = "A_D110907_SiRT_HELA_11_nsMRM_150selected_2_30min-5-35"; // Not L10N
            string       unschedHuman2Name     = unschedHuman2Fileroot.Substring(41, 7);

            ImportNewResults(new[] { unschedHuman1Fileroot, unschedHuman2Fileroot }, 5, false, true, "Names form", 3);
            var       docCalibrate = WaitForProteinMetadataBackgroundLoaderCompletedUI();
            const int pepCount = 11, tranCount = 33;

            AssertEx.IsDocumentState(docCalibrate, null, 1, pepCount, pepCount, tranCount);
            AssertResult.IsDocumentResultsState(docCalibrate, unschedHuman1Name, pepCount, pepCount, 0, tranCount, 0);
            AssertResult.IsDocumentResultsState(docCalibrate, unschedHuman2Name, pepCount, pepCount, 0, tranCount, 0);

            RunUI(() =>
            {
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.ShowRTPeptideGraph();
                using (var enumLabels = SkylineWindow.RTGraphController.GraphSummary.Categories.GetEnumerator())
                {
                    foreach (var nodePep in docCalibrate.Peptides)
                    {
                        Assert.IsTrue(enumLabels.MoveNext() && enumLabels.Current != null);
                        Assert.IsTrue(nodePep.Peptide.Sequence.StartsWith(enumLabels.Current.Substring(0, 3)));
                    }
                }
            });

            // Page 3.
            PauseForScreenShot <GraphSummary.RTGraphView>("RT graph metafile", 3);   // Peptide RT graph

            RunUI(() =>
            {
                SkylineWindow.ShowRTReplicateGraph();
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.SelectedPath = docCalibrate.GetPathTo((int)SrmDocument.Level.Molecules, 0);
                SkylineWindow.Size         = new Size(914, 560);
            });
            // Ensure graphs look like p. 5
            WaitForGraphs();

            RestoreViewOnScreen(5);
            PauseForScreenShot("Main window showing chromatograms and RT graph", 5);   // Skyline window with docked RT replicate comparison graph

            RunUI(() =>
            {
                Assert.AreEqual(3, SkylineWindow.RTGraphController.GraphSummary.CurveCount);
                Assert.AreEqual(2, SkylineWindow.RTGraphController.GraphSummary.Categories.Count());
                var chromGraphs = SkylineWindow.GraphChromatograms.ToArray();
                Assert.AreEqual(2, chromGraphs.Length);
                Assert.AreEqual(11.3, chromGraphs[0].GraphItems.First().BestPeakTime, 0.05);
                Assert.AreEqual(11.2, chromGraphs[1].GraphItems.First().BestPeakTime, 0.05);
            });

            var listTimes = new List <double>();

            for (int i = 0; i < docCalibrate.PeptideCount; i++)
            {
                int iPeptide = i;
                RunUI(() =>
                {
                    SkylineWindow.SelectedPath = docCalibrate.GetPathTo((int)SrmDocument.Level.Molecules, iPeptide);
                });
                WaitForGraphs();
                RunUI(() =>
                {
                    var chromGraphs = SkylineWindow.GraphChromatograms.ToArray();
                    double time1    = chromGraphs[0].GraphItems.First(g => g.BestPeakTime > 0).BestPeakTime;
                    double time2    = chromGraphs[1].GraphItems.First(g => g.BestPeakTime > 0).BestPeakTime;
                    listTimes.Add((time1 + time2) / 2);
                    Assert.AreEqual(time1, time2, 0.2);
                });
            }

            // Calibrate a calculator p. 7
            const string irtCalcName           = "iRT-C18";
            string       irtCalcPath           = GetTestPath(irtCalcName + IrtDb.EXT);
            const string irtCalcPathScreenShot = @"C:\Users\Brendan\Documents\iRT\iRT-C18.irtdb";
            var          peptideSettingsUI1    = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var          editIrtCalc1          = ShowDialog <EditIrtCalcDlg>(peptideSettingsUI1.AddCalculator);

            RunUI(() =>
            {
                editIrtCalc1.CalcName = irtCalcName;
                editIrtCalc1.CreateDatabase(irtCalcPath);           // Not L10N
            });
            {
                var calibrateDlg = ShowDialog <CalibrateIrtDlg>(editIrtCalc1.Calibrate);
                RunUI(() =>
                {
                    calibrateDlg.StandardName = "Biognosys (30 min cal)";
                    calibrateDlg.UseResults();
                    Assert.AreEqual(11, calibrateDlg.StandardPeptideCount);
                    calibrateDlg.SetFixedPoints(1, 10);
                    for (int i = 0; i < calibrateDlg.StandardPeptideCount; i++)
                    {
                        Assert.AreEqual(listTimes[i], calibrateDlg.StandardPeptideList[i].RetentionTime, 0.2);
                    }
                });

                PauseForScreenShot <CalibrateIrtDlg>("Calibrate iRT Calculator form", 6);   // Calibrate iRT Calculator form

                RunDlg <GraphRegression>(calibrateDlg.GraphRegression, dlg => dlg.CloseDialog());
                RunDlg <GraphRegression>(calibrateDlg.GraphIrts, dlg => dlg.CloseDialog());

                RunUI(calibrateDlg.OkDialog);
            }
            Assert.IsTrue(WaitForConditionUI(() => editIrtCalc1.StandardPeptideCount == 11));

            if (IsPauseForScreenShots)
            {
                RunUI(() => editIrtCalc1.CalcPath = irtCalcPathScreenShot);
                PauseForScreenShot <EditIrtCalcDlg>("Edit iRT Calculator form", 7);   // Edit iRT Calculator form
                RunUI(() => editIrtCalc1.CalcPath = irtCalcPath);
            }

            // Check iRT values and update to defined values p. 7-8
            var    irtDefinitionPath = GetTestPath("iRT definition.xlsx");                      // Not L10N
            string irtDefText        = GetExcelFileText(irtDefinitionPath, "iRT-C18", 2, true); // Not L10N

            RunUI(() =>
            {
                var standardPeptidesArray = editIrtCalc1.StandardPeptides.ToArray();
                Assert.AreEqual(11, standardPeptidesArray.Length);
                Assert.AreEqual(0, standardPeptidesArray[1].Irt, 0.00001);
                Assert.AreEqual(100, standardPeptidesArray[10].Irt, 0.00001);
                CheckIrtStandardPeptides(standardPeptidesArray, irtDefText, 6);

                SetClipboardText(irtDefText);
                editIrtCalc1.DoPasteStandard();

                standardPeptidesArray = editIrtCalc1.StandardPeptides.ToArray();
                Assert.AreEqual(11, standardPeptidesArray.Length);
                Assert.AreEqual(0, standardPeptidesArray[1].Irt, 0.001);
                Assert.AreEqual(100, standardPeptidesArray[10].Irt, 0.005);
                CheckIrtStandardPeptides(standardPeptidesArray, irtDefText, 0.00001);
            });
            OkDialog(editIrtCalc1, editIrtCalc1.OkDialog);
            OkDialog(peptideSettingsUI1, peptideSettingsUI1.OkDialog);

            // Inspect RT regression graph p. 9
            RunUI(SkylineWindow.ShowRTRegressionGraphScoreToRun);
            WaitForRegression();

            RestoreViewOnScreen(9);
            PauseForScreenShot <GraphSummary.RTGraphView>("Retention Times Regression graph metafile", 9);   // RT Regression graph

            RunUI(() =>
            {
                VerifyRTRegression(0.15, 15.09, 0.9991);

                SkylineWindow.ShowSingleReplicate();
                SkylineWindow.SequenceTree.Focus();             // If the focus is left on the results tab, then the next line does nothing
                SkylineWindow.SelectedResultsIndex = 0;
            });

            WaitForRegression();

            RunUI(() =>
            {
                VerifyRTRegression(0.15, 15.15, 0.9991);

                SkylineWindow.SelectedResultsIndex = 1;
            });

            WaitForRegression();

            RunUI(() => VerifyRTRegression(0.15, 15.04, 0.9991));
            RunUI(() => SkylineWindow.ShowAverageReplicates());
            RunUI(() => SkylineWindow.SaveDocument());

            // Create a document containing human and standard peptides, p. 10
            RunUI(() => SkylineWindow.OpenFile(GetTestPath("iRT Human.sky")));
            WaitForProteinMetadataBackgroundLoaderCompletedUI(); // let peptide metadata background loader do its work
            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0];
                SkylineWindow.ImportFiles(standardDocumentFile);
            });
            WaitForProteinMetadataBackgroundLoaderCompletedUI(); // let peptide metadata background loader do its work

            RestoreViewOnScreen(10);
            PauseForScreenShot("Targets tree clipped out of main window", 10);   // Target tree

            RunUI(() =>
            {
                Assert.AreEqual("iRT-C18 Standard Peptides", SkylineWindow.SelectedNode.Text);           // Not L10N
                Assert.AreEqual(1231, SkylineWindow.DocumentUI.PeptideTransitionCount);

                SkylineWindow.SaveDocument(GetTestPath("iRT Human+Standard.sky"));           // Not L10N
                SkylineWindow.SaveDocument(GetTestPath("iRT Human+Standard Calibrate.sky")); // Not L10N
            });

            // Remove heavy precursors, p. 11
            var docHumanAndStandard = SkylineWindow.Document;

            RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, refineDlg =>
            {
                refineDlg.RefineLabelType = IsotopeLabelType.heavy;
                refineDlg.OkDialog();
            });
            var docLightOnly = WaitForDocumentChange(docHumanAndStandard);

            Assert.AreEqual(632, docLightOnly.PeptideTransitionCount);

            // Create auto-calculate regression RT predictor, p. 11
            const string irtPredictorName = "iRT-C18"; // Not L10N

            {
                var docPre             = SkylineWindow.Document;
                var peptideSettingsUI2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                RunUI(() => peptideSettingsUI2.ChooseRegression(irtPredictorName));
                var regressionDlg = ShowDialog <EditRTDlg>(peptideSettingsUI2.EditRegression);
                RunUI(() =>
                {
                    Assert.AreEqual(irtPredictorName, regressionDlg.Regression.Name);
                    Assert.AreEqual(irtCalcName, regressionDlg.Regression.Calculator.Name);
                    regressionDlg.SetAutoCalcRegression(true);
                    regressionDlg.SetTimeWindow(5);
                });

                PauseForScreenShot("Edit Retention Time Predictor form", 11);   // Edit retention time predictor form

                OkDialog(regressionDlg, regressionDlg.OkDialog);
                OkDialog(peptideSettingsUI1, peptideSettingsUI2.OkDialog);
                // Make sure iRT calculator is loaded
                WaitForDocumentChangeLoaded(docPre);
            }

            // Export unscheduled transition list, p. 12
            {
                const string calibrateBasename = "iRT Human+Standard Calibrate"; // Not L10N
                var          exportMethodDlg   = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() =>
                {
                    exportMethodDlg.ExportStrategy = ExportStrategy.Buckets;
                    exportMethodDlg.IgnoreProteins = true;
                    exportMethodDlg.MaxTransitions = 335;
                });

                PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 12);

                RunUI(() => exportMethodDlg.OkDialog(GetTestPath(calibrateBasename + TextUtil.EXT_CSV)));
                WaitForClosedForm(exportMethodDlg);

                Assert.AreEqual(332, File.ReadAllLines(GetTestPath(calibrateBasename + "_0001.csv")).Length); // Not L10N
                Assert.AreEqual(333, File.ReadAllLines(GetTestPath(calibrateBasename + "_0002.csv")).Length); // Not L10N
            }

            // Import human peptide calibration results p. 13
            ImportNewResults(new[] { unschedHuman1Fileroot, unschedHuman2Fileroot }, -1, true);

            // Review iRT-C18 graph p. 13-14
            RunUI(() => SkylineWindow.ChooseCalculator(irtCalcName));
            RunUI(SkylineWindow.ShowRTRegressionGraphScoreToRun);
            WaitForRegression();

            PauseForScreenShot <GraphSummary.RTGraphView>("RT Regression graph metafile", 14);

            RunUI(() =>
            {
                VerifyRTRegression(0.15, 15.09, 0.9991);
                Assert.AreEqual(11, SkylineWindow.DocumentUI.PeptideCount -
                                SkylineWindow.RTGraphController.Outliers.Length);
            });

            // Find all unintegrated transitions, p. 14-15
            {
                var findDlg = ShowDialog <FindNodeDlg>(SkylineWindow.ShowFindNodeDlg);
                RunUI(() =>
                {
                    findDlg.FindOptions = new FindOptions().ChangeText(string.Empty)
                                          .ChangeCustomFinders(Finders.ListAllFinders().Where(f => f is UnintegratedTransitionFinder));
                });

                PauseForScreenShot <FindNodeDlg>("Find form", 15);

                RestoreViewOnScreen(15);

                RunUI(() =>
                {
                    findDlg.FindAll();
                    findDlg.Close();
                });
                WaitForClosedForm(findDlg);
            }

            PauseForScreenShot <FindResultsForm>("Find Results pane", 15);

            var findAllForm = WaitForOpenForm <FindResultsForm>();

            Assert.IsNotNull(findAllForm);
            const int expectedItems = 6;

            RunUI(() =>
            {
                Assert.AreEqual(expectedItems, findAllForm.ItemCount);

                SkylineWindow.ShowAllTransitions();
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.Size = new Size(657, 632);
            });

            // Review peaks with missing transitions, p. 16
            for (int i = 0; i < expectedItems; i++)
            {
                int iItem = i;
                RunUI(() => findAllForm.ActivateItem(iItem));
                WaitForGraphs();
                RunUI(() => Assert.AreEqual((int)SequenceTree.StateImageId.no_peak,
                                            SkylineWindow.SelectedNode.StateImageIndex));

                if (i == 1)
                {
                    PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile (1 of 2)", 16);   // Chromatogram graph
                }
                if (i == 2)
                {
                    PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile (2 of 2)", 16);
                }
                if (i == 3)
                {
                    RunUI(() =>
                    {
                        var document  = SkylineWindow.DocumentUI;
                        var nodeGroup = document.FindNode(SkylineWindow.SelectedPath.Parent) as TransitionGroupDocNode;
                        Assert.IsNotNull(nodeGroup);
                        var nodeTran = document.FindNode(SkylineWindow.SelectedPath) as TransitionDocNode;
                        Assert.IsNotNull(nodeTran);
                        var graph = SkylineWindow.GetGraphChrom(Resources.ImportResultsDlg_DefaultNewName_Default_Name);
                        // New peak picking picks correct peak
                        Assert.AreEqual(19.8, graph.BestPeakTime.Value, 0.05);
//                        TransitionGroupDocNode nodeGroupGraph;
//                        TransitionDocNode nodeTranGraph;
//                        var scaledRT = graph.FindAnnotatedPeakRetentionTime(19.8, out nodeGroupGraph, out nodeTranGraph);
//                        Assert.AreSame(nodeGroup, nodeGroupGraph);
//                        Assert.AreNotSame(nodeTran, nodeTranGraph);
//                        Assert.AreEqual(7, nodeTranGraph.Transition.Ordinal);   // y7
//                        graph.FirePickedPeak(nodeGroupGraph, nodeTranGraph, scaledRT);
                    });
                }
            }

            // New peak picking picks correct peak
//            RunUI(() => findAllForm.ActivateItem(3));
//            PauseForScreenShot<GraphChromatogram>("Chromatogram graph metafile (3 of 3)", 15);

            RunUI(SkylineWindow.ToggleIntegrateAll);
            RunUI(findAllForm.Close);
            WaitForClosedForm(findAllForm);

            RunUI(SkylineWindow.ShowRTRegressionGraphScoreToRun);

            // Calculate new iRT values for human peptides, p. 18
            {
                WaitForConditionUI(() =>
                                   SkylineWindow.IsGraphRetentionTimeShown(GraphTypeSummary.score_to_run_regression) &&
                                   SkylineWindow.RTGraphController.RegressionRefined != null);

                var editIrtCalc2 = ShowDialog <EditIrtCalcDlg>(SkylineWindow.ShowEditCalculatorDlg);
                RunUI(() => Assert.AreEqual(0, editIrtCalc2.LibraryPeptideCount));
                var addPeptidesDlg = ShowDialog <AddIrtPeptidesDlg>(editIrtCalc2.AddResults);

                PauseForScreenShot <AddIrtPeptidesDlg>("Add Peptides form", 17);

                RunUI(() =>
                {
                    Assert.AreEqual(148, addPeptidesDlg.PeptidesCount);
                    Assert.AreEqual(2, addPeptidesDlg.RunsConvertedCount);
                    Assert.AreEqual(0, addPeptidesDlg.RunsFailedCount);
                });
                var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg.OkDialog);
                OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click);

                if (IsPauseForScreenShots)
                {
                    RunUI(() => editIrtCalc2.CalcPath = irtCalcPathScreenShot);
                    PauseForScreenShot <EditIrtCalcDlg>("Edit iRT Calculator form", 18);   // Edit iRT Calculator form
                    RunUI(() => editIrtCalc2.CalcPath = irtCalcPath);
                }

                RunUI(() => Assert.AreEqual(148, editIrtCalc2.LibraryPeptideCount));

                CommitIrtCalcChange(editIrtCalc2);
            }

            // Check the RT regression, p. 19
            WaitForRegression();

            PauseForScreenShot <GraphSummary.RTGraphView>("RT Regression graph metafile", 19);

            RunUI(() =>
            {
                VerifyRTRegression(0.15, 15.09, 0.99985);
                Assert.AreEqual(0, SkylineWindow.RTGraphController.Outliers.Length);

                SkylineWindow.SaveDocument();
                SkylineWindow.HideFindResults();
            });

            // Recalibrate method to 90-minute gradient, p. 20
            RunUI(() => SkylineWindow.OpenFile(GetTestPath("iRT Human+Standard.sky"))); // Not L10N
            RunDlg <FindNodeDlg>(SkylineWindow.ShowFindNodeDlg, findDlg =>
            {
                findDlg.FindOptions = new FindOptions().ChangeText("NSAQ");         // Not L10N
                findDlg.FindNext();
                findDlg.Close();
            });
            RunUI(SkylineWindow.EditDelete);

            {
                var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                RunUI(() =>
                {
                    peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Prediction;
                    peptideSettingsUI.ChooseRegression(irtPredictorName);
                    peptideSettingsUI.IsUseMeasuredRT = true;
                    peptideSettingsUI.TimeWindow      = 5;
                });

                PauseForScreenShot <PeptideSettingsUI.PredictionTab>("Peptide Settings - Prediction tab", 21);

                RunUI(peptideSettingsUI.OkDialog);
                WaitForClosedForm(peptideSettingsUI);
            }

            // Import 90-minute standard mix run, p. 19
            const string unsched90MinFileroot = "A_D110913_SiRT_HELA_11_nsMRM_150selected_90min-5-40_TRID2215_01"; // Not L10N

            ImportNewResults(new[] { unsched90MinFileroot }, -1, false);
            WaitForGraphs();

            // Verify regression graph, p. 19
            RunUI(SkylineWindow.ShowRTRegressionGraphScoreToRun);
            WaitForRegression();
            PauseForScreenShot <GraphSummary.RTGraphView>("RT Regression graph metafile", 22);
            RunUI(() =>
            {
                VerifyRTRegression(0.40, 24.77, 0.9998);
                Assert.AreEqual(147, SkylineWindow.RTGraphController.Outliers.Length);
            });

            // Check scheduling graph, p. 20
            RunUI(SkylineWindow.ShowRTSchedulingGraph);
            RunDlg <SchedulingGraphPropertyDlg>(() => SkylineWindow.ShowRTPropertyDlg(SkylineWindow.GraphRetentionTime), propertyDlg =>
            {
                propertyDlg.TimeWindows = new[] { 2.0, 5.0, 10.0 };
                propertyDlg.OkDialog();
            });
            WaitForGraphs();

            PauseForScreenShot <GraphSummary.RTGraphView>("RT Scheduling graph metafile", 23);

            // Export new 90-minute scheduled transition list, p. 22
            const string scheduledBasename = "iRT Human+Standard"; // Not L10N

            {
                var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() =>
                {
                    exportMethodDlg.ExportStrategy = ExportStrategy.Buckets;
                    exportMethodDlg.MaxTransitions = 265;
                    exportMethodDlg.MethodType     = ExportMethodType.Scheduled;
                });

                PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 24);

                RunUI(() => exportMethodDlg.OkDialog(GetTestPath(scheduledBasename + TextUtil.EXT_CSV)));
                WaitForClosedForm(exportMethodDlg);
            }

            Assert.AreEqual(1223, File.ReadAllLines(GetTestPath(scheduledBasename + "_0001.csv")).Length); // Not L10N
            Assert.IsFalse(File.Exists(GetTestPath("iRT Human+Standard_0002.csv")));                       // Not L10N

            // Import scheduled data, p. 23
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, manageResultsDlg =>
            {
                manageResultsDlg.RemoveAllReplicates();
                manageResultsDlg.OkDialog();
            });

            RunUI(() => SkylineWindow.SaveDocument());
            const string sched90MinFileroot = "A_D110913_SiRT_HELA_11_sMRM_150selected_90min-5-40_SIMPLE"; // Not L10N

            ImportNewResults(new[] { sched90MinFileroot }, -1, false);

            RunUI(SkylineWindow.ShowRTRegressionGraphScoreToRun);
            WaitForRegression();

            PauseForScreenShot <GraphSummary.RTGraphView>("RT Regression graph metafile", 26);

            // Review regression and outliers, p. 24
            RunUI(() =>
            {
                VerifyRTRegression(0.358, 25.920, 0.91606);
                Assert.AreEqual(0, SkylineWindow.RTGraphController.Outliers.Length);
            });

            RunDlg <RegressionRTThresholdDlg>(SkylineWindow.ShowRegressionRTThresholdDlg, thresholdDlg =>
            {
                thresholdDlg.Threshold = 0.998;
                thresholdDlg.OkDialog();
            });

            PauseForScreenShot <GraphSummary.RTGraphView>("RT Regression graph metafile", 27);

            // Verify 2 outliers highlighted and removed, p. 25
            WaitForConditionUI(() => SkylineWindow.RTGraphController.Outliers.Length == 2);
            RunUI(() =>
            {
                VerifyRTRegression(0.393, 24.85, 0.9989);

                SkylineWindow.RemoveRTOutliers();
                SkylineWindow.ShowPlotType(PlotTypeRT.residuals);
            });
            WaitForRegression();

            PauseForScreenShot <GraphSummary.RTGraphView>("RT Regression graph metafile", 28);

            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    Settings.Default.ChromatogramFontSize = 14;
                    Settings.Default.AreaFontSize         = 14;
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                });

                RestoreCoverViewOnScreen();

                var manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
                RenameReplicate(manageResultsDlg, 0, "HELA_11_sMRM_150selected_90min");
                OkDialog(manageResultsDlg, manageResultsDlg.OkDialog);

                var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                RunUI(() =>
                {
                    peptideSettingsUI.Top  = SkylineWindow.Top;
                    peptideSettingsUI.Left = SkylineWindow.Left - peptideSettingsUI.Width - 20;
                });
                var irtEditor = ShowDialog <EditIrtCalcDlg>(peptideSettingsUI.EditCalculator);
                RunUI(() =>
                {
                    irtEditor.Height = SkylineWindow.DockPanel.Height + 10;
                    irtEditor.Width += 25;
                    irtEditor.Top    = SkylineWindow.Bottom - irtEditor.Height - SkylineWindow.StatusBarHeight - 5;
                    irtEditor.Left   = SkylineWindow.Right - irtEditor.Width - 5;
                });
                TakeCoverShot();
                OkDialog(irtEditor, irtEditor.CancelDialog);
                OkDialog(peptideSettingsUI, peptideSettingsUI.CancelDialog);
                return;
            }

            // Check outlier removal, p. 25
            RunUI(() =>
            {
                VerifyRTRegression(0.393, 24.85, 0.9989);
                Assert.AreEqual(0, SkylineWindow.RTGraphController.Outliers.Length);
            });

            RunUI(() =>
            {
                SkylineWindow.ShowPlotType(PlotTypeRT.correlation);
                SkylineWindow.ShowGraphRetentionTime(false, GraphTypeSummary.score_to_run_regression);
                SkylineWindow.ShowGraphRetentionTime(false, GraphTypeSummary.schedule);
            });

            // Review a peak and its predicted retention time, p. 26
            RunDlg <FindNodeDlg>(SkylineWindow.ShowFindNodeDlg, findDlg =>
            {
                findDlg.FindOptions = new FindOptions().ChangeText("DATNVG");         // Not L10N
                findDlg.FindNext();
                findDlg.Close();
            });
            WaitForGraphs();

            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile", 29);   // Chromatogram graph

            RunUI(() =>
            {
                var graphChrom = SkylineWindow.GetGraphChrom(sched90MinFileroot);
                Assert.IsTrue(graphChrom.BestPeakTime.HasValue);
                Assert.AreEqual(47.3, graphChrom.BestPeakTime.Value, 0.05);
                Assert.IsTrue(graphChrom.PredictedRT.HasValue);
                Assert.AreEqual(47.6, graphChrom.PredictedRT.Value, 0.05);
            });

            RunUI(SkylineWindow.ShowRTRegressionGraphScoreToRun);

            // Import retention times from a spectral library, p. 31
            {
                WaitForConditionUI(() =>
                                   SkylineWindow.IsGraphRetentionTimeShown(GraphTypeSummary.score_to_run_regression) &&
                                   SkylineWindow.RTGraphController.RegressionRefined != null);

                var editIrtCalc   = ShowDialog <EditIrtCalcDlg>(SkylineWindow.ShowEditCalculatorDlg);
                var addLibraryDlg = ShowDialog <AddIrtSpectralLibrary>(editIrtCalc.AddLibrary);
                RunUI(() =>
                {
                    addLibraryDlg.Source   = SpectralLibrarySource.file;
                    addLibraryDlg.FilePath = GetTestPath(Path.Combine("Yeast+Standard",               // Not L10N
                                                                      "Yeast_iRT_C18_0_00001.blib")); // Not L10N
                    addLibraryDlg.FilePathFocus();
                });

                PauseForScreenShot <AddIrtSpectralLibrary>("Add Spectral Library form", 31);

                // Verify converted peptide iRT values and OK dialogs, p. 31
                var addPeptidesDlg = ShowDialog <AddIrtPeptidesDlg>(addLibraryDlg.OkDialog);
                RunUI(() =>
                {
                    Assert.AreEqual(558, addPeptidesDlg.PeptidesCount);
                    Assert.AreEqual(1, addPeptidesDlg.RunsConvertedCount);  // Libraries now convert through internal alignment to single RT scale
                    Assert.AreEqual(3, addPeptidesDlg.KeepPeptidesCount);
                });

                PauseForScreenShot <AddIrtPeptidesDlg>("Add Peptides form", 31);

                var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg.OkDialog);
                OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click);

                Assert.IsTrue(WaitForConditionUI(() => editIrtCalc.LibraryPeptideCount == 706));

                CommitIrtCalcChange(editIrtCalc);
            }

            // Inspect MS1 filtered Skyline file created from library DDA data, p. 32
            RunUI(() => SkylineWindow.OpenFile(GetTestPath(Path.Combine("Yeast+Standard", // Not L10N
                                                                        "Yeast+Standard (refined) - 2min.sky"))));
            WaitForDocumentLoaded();
            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0));
            WaitForRegression();

            // Verify numbers that show up in the screenshot
            RunUI(() =>
            {
                // If the cache gets rebuilt, then because the chromatograms
                // were minimized, the peak picking is not exactly the same
                // using the minimized chromatograms.
                VerifyRTRegression(0.3, 19.37, 0.9998);
                var graphChrom = SkylineWindow.GetGraphChrom("Velos_2011_1110_RJ_16");           // Not L10N
                Assert.AreEqual(37.6, graphChrom.RetentionMsMs[0], 0.05);
                Assert.IsTrue(graphChrom.BestPeakTime.HasValue);
                Assert.AreEqual(37.6, graphChrom.BestPeakTime.Value, 0.05);
                graphChrom = SkylineWindow.GetGraphChrom("Velos_2011_1110_RJ_14");           // Not L10N
                Assert.AreEqual(37.3, graphChrom.RetentionMsMs[0], 0.05);
                Assert.AreEqual(37.6, graphChrom.RetentionMsMs[1], 0.05);
                Assert.IsTrue(graphChrom.BestPeakTime.HasValue);
                Assert.AreEqual(37.4, graphChrom.BestPeakTime.Value, 0.05);

                SkylineWindow.Size = new Size(1250, 660);
            });

            PauseForScreenShot("Main window", 33);

            // Add results and verify add dialog counts, p. 33
            {
                RunUI(() => SkylineWindow.Width = 500); // Make room for the form below

                var editIrtCalc    = ShowDialog <EditIrtCalcDlg>(SkylineWindow.ShowEditCalculatorDlg);
                var addPeptidesDlg = ShowDialog <AddIrtPeptidesDlg>(editIrtCalc.AddResults);
                RunUI(() =>
                {
                    Assert.AreEqual(0, addPeptidesDlg.PeptidesCount);
                    Assert.AreEqual(2, addPeptidesDlg.RunsConvertedCount);
                    Assert.AreEqual(558, addPeptidesDlg.OverwritePeptidesCount);
                    Assert.AreEqual(3, addPeptidesDlg.ExistingPeptidesCount);

                    addPeptidesDlg.Left = SkylineWindow.Right + 20;
                });

                PauseForScreenShot <AddIrtPeptidesDlg>("Add Peptides form", 34);

                var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg.OkDialog);
                OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click);
                RunUI(editIrtCalc.OkDialog);
                WaitForClosedForm(editIrtCalc);
            }

            RunUI(() => SkylineWindow.SaveDocument());
            RunUI(SkylineWindow.NewDocument);
        }
        protected override void DoTest()
        {
            // Skyline Collision Energy Optimization
            RunUI(() => SkylineWindow.OpenFile(GetTestPath("CE_Vantage_15mTorr.sky"))); // Not L10N

            if (AsSmallMolecules)
            {
                ConvertDocumentToSmallMolecules();
            }

            // Deriving a New Linear Equation, p. 2
            var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
            var editList             =
                ShowDialog <EditListDlg <SettingsListBase <CollisionEnergyRegression>, CollisionEnergyRegression> >
                    (transitionSettingsUI.EditCEList);

            RunUI(() => editList.SelectItem("Thermo")); // Not L10N
            EditCEDlg editItem = ShowDialog <EditCEDlg>(editList.EditItem);

            PauseForScreenShot <EditCEDlg>("Edit Collision Energy Equation form", 3);

            ChargeRegressionLine regressionLine2 = new ChargeRegressionLine(2, 0.034, 3.314);
            ChargeRegressionLine regressionLine3 = new ChargeRegressionLine(3, 0.044, 3.314);

            CheckRegressionLines(new[] { regressionLine2, regressionLine3 }, editItem.Regression.Conversions);

            RunUI(() =>
            {
                editItem.DialogResult             = DialogResult.OK;
                editList.DialogResult             = DialogResult.Cancel;
                transitionSettingsUI.DialogResult = DialogResult.Cancel;
            });
            WaitForClosedForm(transitionSettingsUI);

            // Measuring Retention Times for Method Scheduling, p. 3
            {
                var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.THERMO;
                    exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlg.OptimizeType   = ExportOptimize.NONE;
                    exportMethodDlg.MethodType     = ExportMethodType.Standard;
                });

                PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 4);

                RunUI(() => exportMethodDlg.OkDialog(GetTestPath("CE_Vantage_15mTorr_unscheduled.csv"))); // Not L10N
                WaitForClosedForm(exportMethodDlg);
            }

            string filePathTemplate = GetTestPath("CE_Vantage_15mTorr_unscheduled.csv"); // Not L10N

            CheckTransitionList(filePathTemplate, new [] { 120 }, 6);

            const string unscheduledName = "Unscheduled"; // Not L10N

            RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg =>
            {
                importResultsDlg.RadioAddNewChecked = true;
                var path =
                    new[] { new KeyValuePair <string, MsDataFileUri[]>(unscheduledName,
                                                                                                                                                                       // This is not actually a valid file path (missing OptimizeCE)
                                                                                                                                                                       // but Skyline should correctly find the file in the same folder
                                                                                                                                                                       // as the document.
                                                                       new[] { MsDataFileUri.Parse(GetTestPath("CE_Vantage_15mTorr_unscheduled" + ExtThermoRaw)) }) }; // Not L10N
                importResultsDlg.NamedPathSets = path;
                importResultsDlg.OkDialog();
            });
            WaitForCondition(5 * 60 * 1000, () => SkylineWindow.Document.Settings.HasResults &&
                             SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 5 minutes
            AssertEx.IsDocumentState(SkylineWindow.Document, null, 7, 27, 30, 120);
            var docUnsched = SkylineWindow.Document;

            AssertResult.IsDocumentResultsState(SkylineWindow.Document,
                                                unscheduledName,
                                                docUnsched.MoleculeCount,
                                                docUnsched.MoleculeTransitionGroupCount, 0,
                                                docUnsched.MoleculeTransitionCount, 0);

            RunUI(() =>
            {
                SkylineWindow.ExpandProteins();
                SkylineWindow.ExpandPeptides();
            });

            RestoreViewOnScreen(5);
            PauseForScreenShot("Main Skyline window", 5);

            // Creating Optimization Methods, p. 5
            {
                var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.THERMO;
                    exportMethodDlg.ExportStrategy = ExportStrategy.Buckets;
                    exportMethodDlg.MaxTransitions = 110;
                    exportMethodDlg.IgnoreProteins = true;
                    exportMethodDlg.OptimizeType   = ExportOptimize.CE;
                    exportMethodDlg.MethodType     = ExportMethodType.Scheduled;
                });

                PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 6);

                RunUI(() => exportMethodDlg.OkDialog(GetTestPath("CE_Vantage_15mTorr.csv"))); // Not L10N
                WaitForClosedForm(exportMethodDlg);
            }

            string filePathTemplate1 = GetTestPath("CE_Vantage_15mTorr_000{0}.csv"); // Not L10N

            CheckTransitionList(filePathTemplate1, new[] { 220, 220, 264, 308, 308 }, 9);

            var filePath = GetTestPath("CE_Vantage_15mTorr_0001.csv"); // Not L10N

            CheckCEValues(filePath, 11);

            // Analyze Optimization Data, p. 7
            RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg =>
            {
                importResultsDlg.RadioAddNewChecked = true;
                importResultsDlg.OptimizationName   = ExportOptimize.CE;
                importResultsDlg.NamedPathSets      = DataSourceUtil.GetDataSourcesInSubdirs(TestFilesDirs[0].FullPath).ToArray();
                importResultsDlg.NamedPathSets[0]   =
                    new KeyValuePair <string, MsDataFileUri[]>("Optimize CE", importResultsDlg.NamedPathSets[0].Value.Take(5).ToArray()); // Not L10N
                importResultsDlg.OkDialog();
            });
            RunUI(() =>
            {
                SkylineWindow.ShowSingleTransition();
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.ShowPeakAreaReplicateComparison();
            });

            WaitForDocumentLoaded(15 * 60 * 1000); // 10 minutes
            string decorator = AsSmallMolecules
                ? RefinementSettings.TestingConvertedFromProteomicPeptideNameDecorator
                : string.Empty;

            FindNode(decorator + "IHGFDLAAINLQR");
            RestoreViewOnScreen(8);
            RunUI(() => SkylineWindow.Size = new Size(984, 553));
            PauseForScreenShot("Main Skyline window", 8);

            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    Settings.Default.ChromatogramFontSize = 14;
                    Settings.Default.AreaFontSize         = 14;
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.ShowPeakAreaLegend(false);
                });

                RestoreCoverViewOnScreen();

                RunUI(SkylineWindow.FocusDocument);

                TakeCoverShot();
                return;
            }

            // p. 8
            // Not L10N
            RemoveTargetByDisplayName(decorator + "EGIHAQQK");

            FindNode(decorator + "IDALNENK");

            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.TOTAL));

            PauseForScreenShot("Main Skyline window", 9);

            RunUI(SkylineWindow.EditDelete);

            RemoveTargetByDisplayName(AsSmallMolecules ? decorator + "LIC[+57.0]DNTHITK" : "LICDNTHITK");

            // Creating a New Equation for CE, p. 9
            var transitionSettingsUI1 = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
            var editCEDlg1            = ShowDialog <EditListDlg <SettingsListBase <CollisionEnergyRegression>, CollisionEnergyRegression> >(transitionSettingsUI1.EditCEList);
            var addItem = ShowDialog <EditCEDlg>(editCEDlg1.AddItem);

            RunUI(() =>
            {
                addItem.RegressionName = "Thermo Vantage Tutorial"; // Not L10N
                addItem.UseCurrentData();
            });

            var graphRegression = ShowDialog <GraphRegression>(addItem.ShowGraph);

            PauseForScreenShot <GraphRegression>("Collision Energy Regression graphs", 10);

            var graphDatas = graphRegression.RegressionGraphDatas.ToArray();

            Assert.AreEqual(2, graphDatas.Length);

            ChargeRegressionLine regressionLine21 = new ChargeRegressionLine(2, 0.0305, 2.5061);
            ChargeRegressionLine regressionLine31 = new ChargeRegressionLine(3, 0.0397, 1.4217);
            var expectedRegressions = new[] { regressionLine21, regressionLine31 };

            CheckRegressionLines(expectedRegressions, new[]
            {
                new ChargeRegressionLine(2,
                                         Math.Round(graphDatas[0].RegressionLine.Slope, 4),
                                         Math.Round(graphDatas[0].RegressionLine.Intercept, 4)),
                new ChargeRegressionLine(3,
                                         Math.Round(graphDatas[1].RegressionLine.Slope, 4),
                                         Math.Round(graphDatas[1].RegressionLine.Intercept, 4)),
            });

            RunUI(graphRegression.CloseDialog);
            WaitForClosedForm(graphRegression);
            RunUI(addItem.OkDialog);
            WaitForClosedForm(addItem);
            RunUI(editCEDlg1.OkDialog);
            WaitForClosedForm(editCEDlg1);
            RunUI(transitionSettingsUI1.OkDialog);
            WaitForClosedForm(transitionSettingsUI1);

            // Optimizing Each Transition, p. 10
            RunDlg <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI, transitionSettingsUI2 =>
            {
                transitionSettingsUI2.UseOptimized = true;
                transitionSettingsUI2.OptimizeType = OptimizedMethodType.Transition.GetLocalizedString();
                transitionSettingsUI2.OkDialog();
            });
            RunDlg <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List), exportMethodDlg =>
            {
                exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                exportMethodDlg.OkDialog(GetTestPath("CE_Vantage_15mTorr_optimized.csv")); // Not L10N
            });

            var filePathTemplate2 = GetTestPath("CE_Vantage_15mTorr_optimized.csv"); // Not L10N

            CheckTransitionList(filePathTemplate2, new[] { 108 }, 9);

            RunUI(() => SkylineWindow.SaveDocument());
            WaitForConditionUI(() => !SkylineWindow.Dirty);
        }
        protected override void DoTest()
        {
            var folderAbsoluteQuant = UseRawFiles ? "AbsoluteQuant" : "AbsoluteQuantMzml";
            // Generating a Transition List, p. 5, 6
            {
                var doc = SkylineWindow.Document;
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    // Prediction Settings
                    transitionSettingsUI.SelectedTab       = TransitionSettingsUI.TABS.Prediction;
                    transitionSettingsUI.PrecursorMassType = MassType.Monoisotopic;
                    transitionSettingsUI.FragmentMassType  = MassType.Monoisotopic;
                    transitionSettingsUI.RegressionCEName  = "Thermo TSQ Vantage";
                    transitionSettingsUI.RegressionDPName  = Resources.SettingsList_ELEMENT_NONE_None;
                });
                PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings - Prediction tab", 5);

                RunUI(() =>
                {
                    // Filter Settings
                    transitionSettingsUI.SelectedTab      = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.PrecursorCharges = "2";
                    transitionSettingsUI.ProductCharges   = "1";
                    transitionSettingsUI.FragmentTypes    = "y";
                    transitionSettingsUI.RangeFrom        = Resources.TransitionFilter_FragmentStartFinders_ion_3;
                    transitionSettingsUI.RangeTo          = Resources.TransitionFilter_FragmentEndFinders_last_ion_minus_1;
                    transitionSettingsUI.SpecialIons      = new string[0];
                });
                PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 6);

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                WaitForDocumentChange(doc);
            }

            // Configuring Peptide settings p. 7, 8
            PeptideSettingsUI peptideSettingsUi = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() => peptideSettingsUi.SelectedTab = PeptideSettingsUI.TABS.Modifications);

            var modHeavyK = new StaticMod("Label:13C(6)15N(2) (C-term K)", "K", ModTerminus.C, false, null,
                                          LabelAtoms.C13 | LabelAtoms.N15, RelativeRT.Matching, null, null, null);

            AddHeavyMod(modHeavyK, peptideSettingsUi, "Edit Isotope Modification over Transition Settings", 7);
            RunUI(() => peptideSettingsUi.PickedHeavyMods = new[] { modHeavyK.Name });
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modification tab with mod added", 8);

            OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);

            // Inserting a peptide sequence p. 9
            using (new CheckDocumentState(1, 1, 2, 10))
            {
                RunUI(() => SetClipboardText("IEAIPQIDK\tGST-tag"));
                var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);
                RunUI(pasteDlg.PastePeptides);
                WaitForProteinMetadataBackgroundLoaderCompletedUI();
                RunUI(() => pasteDlg.Size = new Size(700, 210));
                PauseForScreenShot <PasteDlg.PeptideListTab>("Insert Peptide List", 9);

                OkDialog(pasteDlg, pasteDlg.OkDialog);
            }

            RunUI(SkylineWindow.ExpandPrecursors);
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            WaitForCondition(() => File.Exists(GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            RunUI(() => SkylineWindow.Size = new Size(840, 410));

            PauseForScreenShot("Main window with Targets view", 9);

            // Exporting a transition list p. 10
            {
                var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.THERMO;
                    exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlg.OptimizeType   = ExportOptimize.NONE;
                    exportMethodDlg.MethodType     = ExportMethodType.Standard;
                });
                PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List", 10);

                OkDialog(exportMethodDlg, () =>
                         exportMethodDlg.OkDialog(GetTestPath("Quant_Abs_Thermo_TSQ_Vantage.csv")));
            }

            // Importing RAW files into Skyline p. 11, 12
            var importResultsDlg = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);

            PauseForScreenShot <ImportResultsDlg>("Import Results - click OK to get shot of Import Results Files and then cancel", 11);

            RunUI(() =>
            {
                var rawFiles      = DataSourceUtil.GetDataSources(TestFilesDirs[0].FullPath).First().Value.Skip(1);
                var namedPathSets = from rawFile in rawFiles
                                    select new KeyValuePair <string, MsDataFileUri[]>(
                    rawFile.GetFileNameWithoutExtension(), new[] { rawFile });
                importResultsDlg.NamedPathSets = namedPathSets.ToArray();
            });
            RunDlg <ImportResultsNameDlg>(importResultsDlg.OkDialog,
                                          importResultsNameDlg => importResultsNameDlg.NoDialog());

            WaitForGraphs();

            RunUI(() =>
            {
                SkylineWindow.SelectedPath             = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0);
                Settings.Default.ArrangeGraphsOrder    = GroupGraphsOrder.Document.ToString();
                Settings.Default.ArrangeGraphsReversed = false;
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.AutoZoomBestPeak();
            });
            WaitForCondition(() => Equals(8, SkylineWindow.GraphChromatograms.Count(graphChrom => !graphChrom.IsHidden)),
                             "unexpected visible graphChromatogram count");

            RunUI(() =>
            {               //resize the window and activate the first standard chromatogram pane.
                RunUI(() => SkylineWindow.Size = new Size(1330, 720));
                var chrom = SkylineWindow.GraphChromatograms.First();
                chrom.Select();
            });

            WaitForCondition(10 * 60 * 1000,    // ten minutes
                             () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);
            PauseForScreenShot("Main window with imported data", 13);

            // Analyzing SRM Data from FOXN1-GST Sample p. 14
            RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults,
                                      importResultsDlg1 =>
            {
                var rawFiles      = DataSourceUtil.GetDataSources(TestFilesDirs[0].FullPath).First().Value.Take(1);
                var namedPathSets = from rawFile in rawFiles
                                    select new KeyValuePair <string, MsDataFileUri[]>(
                    rawFile.GetFileNameWithoutExtension(), new[] { rawFile });
                importResultsDlg1.NamedPathSets = namedPathSets.ToArray();
                importResultsDlg1.OkDialog();
            });
            WaitForGraphs();
            CheckReportCompatibility.CheckAll(SkylineWindow.Document);
            WaitForCondition(5 * 60 * 1000, // five minutes
                             () =>
                             SkylineWindow.Document.Settings.HasResults &&
                             SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);

            RunUI(() =>
            {
                SkylineWindow.ToggleIntegrateAll();
                SkylineWindow.ArrangeGraphsTabbed();
                SkylineWindow.ShowRTReplicateGraph();
                SkylineWindow.ShowPeakAreaReplicateComparison();
                // Total normalization
                SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.TOTAL);
            });

            RunUI(() => SkylineWindow.ActivateReplicate("FOXN1-GST"));
            WaitForGraphs();
            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.TransitionGroups, 0));
            WaitForGraphs();
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SelectedResultsIndex, SkylineWindow.GraphPeakArea.ResultsIndex);
                Assert.AreEqual(SkylineWindow.SelectedResultsIndex, SkylineWindow.GraphRetentionTime.ResultsIndex);
            });

            RunUI(() =>
            {
                int transitionCount = SkylineWindow.DocumentUI.PeptideTransitionGroups.First().TransitionCount;
                CheckGstGraphs(transitionCount, transitionCount);
            });
            RunUI(() => SkylineWindow.Size = new Size(1470, 656));
            RestoreViewOnScreen(14);
            PauseForScreenShot("Main window with Peak Areas, Retention Times and FOXN1-GST for light", 14);

            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.TransitionGroups, 1));
            WaitForGraphs();

            RunUI(() =>
            {
                int transitionCount = SkylineWindow.DocumentUI.PeptideTransitionGroups.ToArray()[1].TransitionCount;
                CheckGstGraphs(transitionCount, transitionCount);
            });
            PauseForScreenShot("Main window with Peak Areas, Retention Times and FOXN1-GST for heavy", 14);

            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0));
            WaitForGraphs();
            // Heavy normalization
            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.FromIsotopeLabelType(IsotopeLabelType.heavy)));
            WaitForGraphs();
            RunUI(() =>
            {
                int transitionGroupCount = SkylineWindow.DocumentUI.Peptides.First().TransitionGroupCount;
                CheckGstGraphs(transitionGroupCount, transitionGroupCount - 1);
            });
            PauseForScreenShot("Main window with totals graphs for light and heavy and FOXN1-GST", 15);

            // Peptide Quantitification Settings p. 16
            peptideSettingsUi = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            RunUI(() => peptideSettingsUi.SelectedTab = (PeptideSettingsUI.TABS) 5);
            const string quantUnits = "fmol/ul";

            RunUI(() =>
            {
                peptideSettingsUi.QuantRegressionFit       = RegressionFit.LINEAR;
                peptideSettingsUi.QuantNormalizationMethod = new NormalizationMethod.RatioToLabel(IsotopeLabelType.heavy);
                peptideSettingsUi.QuantUnits = quantUnits;
            });
            PauseForScreenShot("Peptide Settings Quantification Tab", 16);
            OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);

            // Specify analyte concentrations of external standards
            var documentGridForm = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));

            RunUI(() =>
            {
                documentGridForm.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates);
            });
            WaitForConditionUI(() => documentGridForm.IsComplete);
            var concentrations = new[] { 40, 12.5, 5, 2.5, 1, .5, .25, .1 };

            for (int iRow = 0; iRow < concentrations.Length; iRow++)
            {
                // ReSharper disable AccessToModifiedClosure
                RunUI(() =>
                {
                    var colSampleType = documentGridForm.FindColumn(PropertyPath.Root.Property("SampleType"));
                    documentGridForm.DataGridView.Rows[iRow].Cells[colSampleType.Index].Value = SampleType.STANDARD;
                });
                WaitForConditionUI(() => documentGridForm.IsComplete);
                RunUI(() =>
                {
                    var colAnalyteConcentration =
                        documentGridForm.FindColumn(PropertyPath.Root.Property("AnalyteConcentration"));
                    var cell = documentGridForm.DataGridView.Rows[iRow].Cells[colAnalyteConcentration.Index];
                    documentGridForm.DataGridView.CurrentCell = cell;
                    cell.Value = concentrations[iRow];
                });
                // ReSharper restore AccessToModifiedClosure
                WaitForConditionUI(() => documentGridForm.IsComplete);
            }

            if (IsPauseForScreenShots)
            {
                RunUI(() =>
                {
                    SkylineWindow.Width     = 500;
                    var gridFloatingWindow  = documentGridForm.Parent.Parent;
                    gridFloatingWindow.Size = new Size(370, 315);
                    gridFloatingWindow.Top  = SkylineWindow.Top;
                    gridFloatingWindow.Left = SkylineWindow.Right + 20;
                });
                PauseForScreenShot("Document grid with concentrations filled in", 17);
            }

            // View the calibration curve p. 18
            RunUI(() => SkylineWindow.ShowDocumentGrid(false));

            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    Settings.Default.ChromatogramFontSize = 14;
                    Settings.Default.AreaFontSize         = 14;
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.ShowPeakAreaLegend(false);
                    SkylineWindow.ShowRTLegend(false);
                });
                RestoreCoverViewOnScreen();
                RunUI(() =>
                {
                    var calibrationOpenForm        = WaitForOpenForm <CalibrationForm>();
                    var calibrationFloatingWindow  = calibrationOpenForm.Parent.Parent;
                    calibrationFloatingWindow.Top  = SkylineWindow.Bottom - calibrationFloatingWindow.Height - 35;
                    calibrationFloatingWindow.Left = SkylineWindow.Left + 15;
                });
                TakeCoverShot();
                return;
            }

            var calibrationForm = ShowDialog <CalibrationForm>(() => SkylineWindow.ShowCalibrationForm());

            if (IsPauseForScreenShots)
            {
                RunUI(() =>
                {
                    var calibrationFloatingWindow   = calibrationForm.Parent.Parent;
                    calibrationFloatingWindow.Width = 565;
                    calibrationFloatingWindow.Top   = SkylineWindow.Top;
                    calibrationFloatingWindow.Left  = SkylineWindow.Right + 20;
                });
                PauseForScreenShot("View calibration curve", 18);
            }

            Assert.AreEqual(CalibrationCurveFitter.AppendUnits(QuantificationStrings.Analyte_Concentration, quantUnits), calibrationForm.ZedGraphControl.GraphPane.XAxis.Title.Text);
            Assert.AreEqual(string.Format(QuantificationStrings.CalibrationCurveFitter_PeakAreaRatioText__0___1__Peak_Area_Ratio, IsotopeLabelType.light.Title, IsotopeLabelType.heavy.Title),
                            calibrationForm.ZedGraphControl.GraphPane.YAxis.Title.Text);
        }
Exemple #9
0
        private void DoStudy7Test()
        {
            // Preparing a Document to Accept the Study 7 Transition List, p. 18
            RunUI(() => SkylineWindow.NewDocument());
            var peptideSettingsUI1 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            if (IsCoverShotMode)
            {
                var modHeavyK = new StaticMod(HEAVY_K, "K", ModTerminus.C, false, null, LabelAtoms.C13 | LabelAtoms.N15, // Not L10N
                                              RelativeRT.Matching, null, null, null);
                AddHeavyMod(modHeavyK, peptideSettingsUI1, "Edit Isotope Modification form", 6);
            }
            var mod13Cr = new StaticMod("Label:13C(6) (C-term R)", "R", ModTerminus.C, false, null, LabelAtoms.C13,
                                        RelativeRT.Matching, null, null, null);

            AddHeavyMod(mod13Cr, peptideSettingsUI1, "Edit Isotope Modification form", 18);
            RunUI(() =>
            {
                peptideSettingsUI1.PickedHeavyMods            = new[] { "Label:13C(6) (C-term R)", HEAVY_K };
                peptideSettingsUI1.PickedLibraries            = new string[0];
                peptideSettingsUI1.SelectedBackgroundProteome = Resources.SettingsList_ELEMENT_NONE_None;
                peptideSettingsUI1.OkDialog();
            });

            // Pasting a Transition List into the Document, p. 19.
            string clipboardSaveText = string.Empty;

            RunUI(() =>
            {
                var filePath = GetTestPath(@"Study 7\Study7 transition list.xls");
                SetExcelFileClipboardText(filePath, "Simple", 6, false);
                clipboardSaveText = ClipboardEx.GetText();
            });
            // We expect this to fail due to instrument settings rather than format issues eg "The product m/z 1519.78 is out of range for the instrument settings, in the peptide sequence YEVQGEVFTKPQLWP. Check the Instrument tab in the Transition Settings."
            {
                var transitionSelectdgl = ShowDialog <ImportTransitionListColumnSelectDlg>(SkylineWindow.Paste);
                var messageDlg          = ShowDialog <ImportTransitionListErrorDlg>(transitionSelectdgl.AcceptButton.PerformClick);
                AssertEx.AreComparableStrings(TextUtil.SpaceSeparate(Resources.MassListRowReader_CalcTransitionExplanations_The_product_m_z__0__is_out_of_range_for_the_instrument_settings__in_the_peptide_sequence__1_,
                                                                     Resources.MassListRowReader_CalcPrecursorExplanations_Check_the_Instrument_tab_in_the_Transition_Settings),
                                              messageDlg.ErrorList[0].ErrorMessage,
                                              2);
                RunUI(() => messageDlg.Size = new Size(838, 192));
                PauseForScreenShot <ImportTransitionListErrorDlg>("Error message form (expected)", 19);
                OkDialog(messageDlg, messageDlg.CancelButton.PerformClick);          // Acknowledge the error but decline to proceed with import
                RunUI(() => transitionSelectdgl.DialogResult = DialogResult.Cancel); // Cancel the import

                // Restore the clipboard text after pausing
                ClipboardEx.SetText(clipboardSaveText);
            }

            RunDlg <TransitionSettingsUI>(() => SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.Instrument), transitionSettingsUI =>
            {
                transitionSettingsUI.InstrumentMaxMz = 1800;
                transitionSettingsUI.OkDialog();
            });
            PasteTransitionListSkipColumnSelect();
            RunUI(SkylineWindow.CollapsePeptides);
            PauseForScreenShot("Targets tree (selected from main window)", 20);

            // Adjusting Modifications Manually, p. 19.
            AdjustModifications("AGLCQTFVYGGCR", true, 'V', 747.348);
            PauseForScreenShot("Target tree clipped from main window", 22);

            AdjustModifications("IVGGWECEK", true, 'V', 541.763);
            AdjustModifications("YEVQGEVFTKPQLWP", false, 'L', 913.974);
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath(@"Study 7\Study7.sky")));

            // Importing Data from a Multiple Sample WIFF file, p. 23.
            var importResultsDlg1     = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
            var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets =
                                                                              importResultsDlg1.GetDataSourcePathsFile(null));

            RunUI(() =>
            {
                openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(GetTestPath("Study 7"));
                openDataSourceDialog1.SelectAllFileType(UseRawFilesOrFullData ? ".wiff" : ".mzML"); // Force true wiff for FullData
            });
            if (UseRawFilesOrFullData)
            {
                var importResultsSamplesDlg = ShowDialog <ImportResultsSamplesDlg>(openDataSourceDialog1.Open);
                PauseForScreenShot <ImportResultsSamplesDlg>("Choose Samples form", 24);

                RunUI(() =>
                {
                    if (IsFullData)
                    {
                        importResultsSamplesDlg.CheckAll(true);
                        importResultsSamplesDlg.ExcludeSample(0);           // Blank
                        importResultsSamplesDlg.ExcludeSample(25);          // QC
                        importResultsSamplesDlg.ExcludeSample(26);
                        importResultsSamplesDlg.ExcludeSample(27);
                        importResultsSamplesDlg.ExcludeSample(28);
                        importResultsSamplesDlg.ExcludeSample(45);           // A2
                        importResultsSamplesDlg.ExcludeSample(46);
                        importResultsSamplesDlg.ExcludeSample(47);
                        importResultsSamplesDlg.ExcludeSample(48);
                        importResultsSamplesDlg.ExcludeSample(49);           // gradientwash
                        importResultsSamplesDlg.ExcludeSample(50);
                        importResultsSamplesDlg.ExcludeSample(51);
                        importResultsSamplesDlg.ExcludeSample(52);
                        importResultsSamplesDlg.ExcludeSample(53);           // A3
                        importResultsSamplesDlg.ExcludeSample(54);
                        importResultsSamplesDlg.ExcludeSample(55);
                        importResultsSamplesDlg.ExcludeSample(56);
                    }
                    else
                    {
                        importResultsSamplesDlg.CheckAll(false);
                        importResultsSamplesDlg.IncludeSample(1);
                        importResultsSamplesDlg.IncludeSample(2);
                        importResultsSamplesDlg.IncludeSample(11);
                        importResultsSamplesDlg.IncludeSample(12);
                    }
                });
                OkDialog(importResultsSamplesDlg, importResultsSamplesDlg.OkDialog);
            }
            else
            {
                RunUI(openDataSourceDialog1.Open);
            }

            {
                var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg1.OkDialog);
                PauseForScreenShot <ImportResultsNameDlg>("Import Results Common prefix form", 25);

                OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog);
            }
            WaitForCondition(() =>
                             SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);
            RestoreViewOnScreen(26);

            // Inspecting and Adjusting Peak Integration, p. 24.
            RunUI(() =>
            {
                SkylineWindow.ShowPeakAreaReplicateComparison();
                SkylineWindow.ShowGraphRetentionTime(true);
                SkylineWindow.Size = new Size(1029, 659);
            });

            if (!IsPauseForScreenShots && !IsFullData)
            {
                TestApplyToAll();
            }

            PauseForScreenShot <GraphSummary.RTGraphView>("Main window with peaks and retention times showing", 26);
            CheckReportCompatibility.CheckAll(SkylineWindow.Document);
            RunUI(SkylineWindow.EditDelete);
            FindNode("IVGGWECEK"); // Not L10N

            TransitionGroupTreeNode selNodeGroup = null;

            RunUI(() =>
            {
                selNodeGroup = (TransitionGroupTreeNode)SkylineWindow.SequenceTree.SelectedNode.Nodes[1];
                Assert.AreEqual(selNodeGroup.StateImageIndex, (int)SequenceTree.StateImageId.peak_blank);
            });
            RunDlg <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI, transitionSettingsUI =>
            {
                transitionSettingsUI.MZMatchTolerance = 0.065;
                transitionSettingsUI.OkDialog();
            });
            RunUI(() =>
            {
                Assert.AreEqual((int)SequenceTree.StateImageId.peak, selNodeGroup.StateImageIndex);
                SkylineWindow.ToggleIntegrateAll();
            });
            RunUI(() =>
            {
                foreach (PeptideDocNode nodePep in SkylineWindow.Document.Molecules)
                {
                    string sequence = nodePep.Peptide.Sequence;
                    int imageIndex  = PeptideTreeNode.GetPeakImageIndex(nodePep, SkylineWindow.SequenceTree);
                    if ((sequence != null) && (sequence.StartsWith("YLA") || sequence.StartsWith("YEV"))) // Not L10N
                    {
                        Assert.AreEqual((int)SequenceTree.StateImageId.keep, imageIndex,
                                        string.Format("Expected keep icon for the peptide {0}, found {1}", sequence, imageIndex));
                    }
                    else if (sequence != null)
                    {
                        Assert.AreEqual((int)SequenceTree.StateImageId.peak, imageIndex,
                                        string.Format("Expected peak icon for the peptide {0}, found {1}", sequence, imageIndex));
                    }
                    else // Custom Ion
                    {
                        Assert.AreEqual((int)SequenceTree.StateImageId.peak_blank, imageIndex,
                                        string.Format("Expected peak_blank icon for the custom ion {0}, found {1}", nodePep.ModifiedTarget, imageIndex));
                    }
                }
            });
            PauseForScreenShot("Main window", 27);

            // Data Inspection with Peak Areas View, p. 29.
            RestoreViewOnScreen(28);
            FindNode("SSDLVALSGGHTFGK"); // Not L10N
            RunUI(NormalizeGraphToHeavy);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 29);

            FindNode((564.7746).ToString(LocalizationHelper.CurrentCulture) + "++"); // ESDTSYVSLK - Not L10N
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 30);

            RunUI(SkylineWindow.ExpandPeptides);
            string hgflprLight = (363.7059).ToString(LocalizationHelper.CurrentCulture) + "++";  // HGFLPR - Not L10N

            FindNode(hgflprLight);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph metafile", 31);

            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.TOTAL));
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph normalized metafile", 32);

            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(false);
                SkylineWindow.ActivateReplicate("E_03");
                SkylineWindow.Size = new Size(757, 655);
            });
            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile with interference", 32);

            RunUI(() => SkylineWindow.ShowGraphPeakArea(true));
            RunUI(() =>
            {
                SkylineWindow.ShowPeakAreaPeptideGraph();
                SkylineWindow.ShowTotalTransitions();
                SkylineWindow.ShowCVValues(true);
                SkylineWindow.ShowPeptideOrder(SummaryPeptideOrder.document);
            });
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas Peptide Comparison graph metafile", 33);

            float[] concentrations    = { 0f, 60, 175, 513, 1500, 2760, 4980, 9060, 16500, 30000 };
            var     documentGrid      = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));
            var     pathConcentration = PropertyPath.Parse("AnalyteConcentration");
            var     pathSampleType    = PropertyPath.Parse("SampleType");

            RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates));
            WaitForConditionUI(() => documentGrid.RowCount == (IsFullData ? concentrations.Length * 4 : 4) &&
                               documentGrid.FindColumn(pathConcentration) != null &&
                               documentGrid.FindColumn(pathSampleType) != null);       // Let it initialize
            RunUI(() =>
            {
                // Parent is a DocPane and Parent.Parent is the floating window
                documentGrid.Parent.Parent.Size = new Size(585, 325);
                var documentGridView            = documentGrid.DataGridView;
                var colConcentration            = documentGrid.FindColumn(pathConcentration);
                var colStandardType             = documentGrid.FindColumn(pathSampleType);

                if (IsFullData)
                {
                    for (int i = 0; i < concentrations.Length; i++)
                    {
                        for (int j = i * 4; j < (i + 1) * 4; j++)
                        {
                            double?concentration = concentrations[i];
                            SetCellValue(documentGridView, j, colConcentration.Index, concentration);
                            SetCellValue(documentGridView, j, colStandardType.Index,
                                         concentration == 0 ? SampleType.BLANK : SampleType.STANDARD);
                        }
                    }
                }
                else
                {
                    SetCellValue(documentGridView, 0, colConcentration.Index, 0.0);
                    SetCellValue(documentGridView, 0, colStandardType.Index, SampleType.BLANK);
                    SetCellValue(documentGridView, 1, colConcentration.Index, 0.0);
                    SetCellValue(documentGridView, 1, colStandardType.Index, SampleType.BLANK);
                    SetCellValue(documentGridView, 2, colConcentration.Index, 175.0);
                    SetCellValue(documentGridView, 2, colStandardType.Index, SampleType.STANDARD);
                    SetCellValue(documentGridView, 3, colConcentration.Index, 175.0);
                    SetCellValue(documentGridView, 3, colStandardType.Index, SampleType.STANDARD);
                }
            });
            WaitForGraphs();
            PauseForScreenShot <DocumentGridForm>("Document grid filled (scrolled to the end)", 35);
            RunUI(() => documentGrid.Close());

            FindNode("SSDLVALSGGHTFGK"); // Not L10N
            RunUI(() =>
            {
                SkylineWindow.ShowPeakAreaReplicateComparison();
                var settings         = SkylineWindow.DocumentUI.Settings;
                var valConcentration = ReplicateValue.GetAllReplicateValues(settings).Skip(1).First();
                SkylineWindow.GroupByReplicateValue(valConcentration);
                NormalizeGraphToHeavy();
            });
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph with CVs metafile", 36);

            RunUI(() => SkylineWindow.ShowCVValues(false));
            RunUI(() => SkylineWindow.SaveDocument());
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas graph grouped by concentration metafile", 37);
            PauseForAuditLog();
            // Further Exploration, p. 33.
            RunUI(() =>
            {
                SkylineWindow.OpenFile(GetTestPath(@"Study 7\Study II\Study 7ii (site 52).sky")); // Not L10N
                SkylineWindow.ShowPeakAreaPeptideGraph();
                SkylineWindow.ShowCVValues(true);
            });
            WaitForCondition(() => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);
            RestoreViewOnScreen(38);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas peptide comparison graph metafile", 38);
            FindNode("LSEPAELTDAVK");
            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(false);
                SkylineWindow.Width = 920;
                SkylineWindow.ShowRTReplicateGraph();
            });
            PauseForScreenShot <GraphSummary.RTGraphView>("Retention Times replicate graph metafile", 38);

            FindNode("INDISHTQSVSAK");
            RunUI(SkylineWindow.ShowPeakAreaReplicateComparison);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas normalized to heave graph metafile", 39);

            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    Settings.Default.ChromatogramFontSize = 14;
                    Settings.Default.AreaFontSize         = 14;
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.AutoZoomBestPeak();
                });
                RestoreCoverViewOnScreen();
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.Parent);
                WaitForGraphs();
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.Nodes[0]);
                RunUI(SkylineWindow.FocusDocument);
                TakeCoverShot();
                return;
            }

            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(NormalizeOption.NONE));
            WaitForGraphs();
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas no normalization graph metafile", 40);

            FindNode(hgflprLight);
            RunUI(() =>
            {
                SkylineWindow.ShowAllTransitions();
                NormalizeGraphToHeavy();
            });
            WaitForGraphs();
            PauseForScreenShot <GraphSummary.AreaGraphView>("Area Ratio to Heavy graph showing interference metafile", 41);

            RunUI(() => SkylineWindow.ShowGraphPeakArea(false));
            RunUI(() => SkylineWindow.ActivateReplicate("E_ 03"));
            WaitForGraphs();
            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile showing slight interference", 41);
        }
Exemple #10
0
        protected override void DoTest()
        {
            RunUI(() =>
            {
                SkylineWindow.ResetDefaultSettings();
                SkylineWindow.NewDocument();
            });
            ShowAndPositionAuditLog(false);
            PauseForScreenShot <AuditLogForm>("Empty Audit Log form.", 2);

            // Configuring Settings for Inserting a New Peptide, p. 3
            {
                var doc = SkylineWindow.Document;
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);

                RunUI(() =>
                {
                    // Filter Settings
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.RangeFrom   = Resources.TransitionFilter_FragmentStartFinders_ion_3;
                    transitionSettingsUI.RangeTo     = Resources.TransitionFilter_FragmentEndFinders_last_ion_minus_1;
                });
                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                WaitForDocumentChange(doc);
            }

            PeptideSettingsUI peptideSettingsUi = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() => peptideSettingsUi.SelectedTab = PeptideSettingsUI.TABS.Modifications);

            var modHeavyK = new StaticMod("Label:13C(6)15N(2) (C-term K)", "K", ModTerminus.C, false, null, LabelAtoms.C13 | LabelAtoms.N15,
                                          RelativeRT.Matching, null, null, null);

            AddHeavyMod(modHeavyK, peptideSettingsUi);
            RunUI(() => peptideSettingsUi.PickedHeavyMods = new[] { modHeavyK.Name });

            OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);

            PauseForScreenShot <AuditLogForm>("Audit Log form with settings modifications.", 4);

            RunUI(() =>
            {
                SkylineWindow.AuditLogForm.Close();
                SkylineWindow.Width = 1010;
            });

            PauseForScreenShot("Undo list expanded. (manual)", 4);

            RunUI(SkylineWindow.Undo);

            PauseForScreenShot("Redo list expanded. (manual)", 5);

            RunUI(SkylineWindow.Redo);

            // Inserting a peptide sequence p. 5
            using (new CheckDocumentState(1, 1, 2, 10))
            {
                WaitForProteinMetadataBackgroundLoaderCompletedUI();

                var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);
                RunUI(() => SetClipboardText("IEAIPQIDK\tGST-tag"));
                RunUI(pasteDlg.PastePeptides);
                RunUI(() =>
                {
                    pasteDlg.Size = new Size(700, 210);
                    pasteDlg.Top  = SkylineWindow.Bottom + 20;
                });
                PauseForScreenShot <PasteDlg.PeptideListTab>("Insert Peptide List", 6);

                using (new WaitDocumentChange())
                {
                    OkDialog(pasteDlg, pasteDlg.OkDialog);
                }

                WaitForConditionUI(() => SkylineWindow.SequenceTree.Nodes.Count > 0);
            }

            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                SkylineWindow.Height = 390;
            });

            PauseForScreenShot("Main window with Targets view", 6);

            ShowAndPositionAuditLog(true);
            PauseForScreenShot <AuditLogForm>("Audit Log form with inserted peptide.", 7);

            ShowLastExtraInfo("Extra info form with inserted peptide info.", 7);

            string documentPath = GetTestPath("AuditLogTutorial" + SrmDocument.EXT);

            RunUI(() => SkylineWindow.SaveDocument(documentPath));
            WaitForCondition(() => File.Exists(documentPath));

            // Importing RAW files into Skyline p. 7
            var importResultsDlg = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);

            RunUI(() =>
            {
                var rawFiles      = DataSourceUtil.GetDataSources(TestFilesDirs[0].FullPath).First().Value;
                var namedPathSets = from rawFile in rawFiles
                                    select new KeyValuePair <string, MsDataFileUri[]>(
                    rawFile.GetFileNameWithoutExtension(), new[] { rawFile });
                importResultsDlg.NamedPathSets = namedPathSets.ToArray();
            });
            OkDialog(importResultsDlg, importResultsDlg.OkDialog);

            WaitForGraphs();

            RunUI(() =>
            {
                SkylineWindow.SelectedPath             = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0);
                Settings.Default.ArrangeGraphsOrder    = GroupGraphsOrder.Document.ToString();
                Settings.Default.ArrangeGraphsReversed = false;
                SkylineWindow.ArrangeGraphsTabbed();
                SkylineWindow.AutoZoomBestPeak();
            });
            WaitForCondition(() => Equals(9, SkylineWindow.GraphChromatograms.Count(graphChrom => !graphChrom.IsHidden)),
                             "unexpected visible graphChromatogram count");

            WaitForCondition(10 * 60 * 1000,    // ten minutes
                             () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);

            PauseForScreenShot <AuditLogForm>("Audit Log form with imported data files.", 9);

            ShowLastExtraInfo("Extra info form for the import.", 9);

            // Peptide Quantitification Settings p. 9
            peptideSettingsUi = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            RunUI(() => peptideSettingsUi.SelectedTab = (PeptideSettingsUI.TABS) 5);
            const string quantUnits = "fmol/ul";

            RunUI(() =>
            {
                peptideSettingsUi.QuantRegressionFit       = RegressionFit.LINEAR;
                peptideSettingsUi.QuantNormalizationMethod = new NormalizationMethod.RatioToLabel(IsotopeLabelType.heavy);
                peptideSettingsUi.QuantUnits = quantUnits;
            });
            OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);

            PauseForScreenShot <AuditLogForm>("Audit Log form with quantification settings.", 10);

            // Specify analyte concentrations of external standards
            RunUI(() =>
            {
                SkylineWindow.AuditLogForm.Close();
                SkylineWindow.ShowDocumentGrid(true);
            });
            var documentGridForm = FindOpenForm <DocumentGridForm>();

            RunUI(() =>
            {
                documentGridForm.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates);
            });
            WaitForConditionUI(() => documentGridForm.IsComplete);

            var concentrations = new[] { 40, 12.5, 5, 2.5, 1, .5, .25, .1 };

            string pasteString = TextUtil.LineSeparate(concentrations.Select((f, i) =>
                                                                             QuantificationStrings.SampleType_STANDARD_Standard + "\t" + f));

            ClipboardEx.SetText(pasteString);

            using (new WaitDocumentChange())
            {
                RunUI(() =>
                {
                    var colSampleType = documentGridForm.FindColumn(PropertyPath.Root.Property("SampleType"));
                    documentGridForm.DataGridView.CurrentCell = documentGridForm.DataGridView.Rows[1].Cells[colSampleType.Index];
                    documentGridForm.DataGridView.SendPaste();
                });
            }

            // ReSharper restore AccessToModifiedClosure
            WaitForConditionUI(() => documentGridForm.IsComplete);
            RunUI(() =>
            {
                var gridFloatingWindow  = documentGridForm.Parent.Parent;
                gridFloatingWindow.Size = new Size(370, 315);
                gridFloatingWindow.Top  = SkylineWindow.Bottom + 20;
            });
            PauseForScreenShot <DocumentGridForm>("Document grid with concentrations filled in", 11);
            RunUI(documentGridForm.Close);

            ShowAndPositionAuditLog(true);
            PauseForScreenShot <AuditLogForm>("Audit Log form with grid changes", 12);

            ShowLastExtraInfo("Extra Info for the analyte data import.", 12);
            RunUI(SkylineWindow.AuditLogForm.Close);

            const string unknownReplicate = "FOXN1-GST";

            RestoreViewOnScreen(13);
            ActivateReplicate(unknownReplicate);
            SelectNode(SrmDocument.Level.TransitionGroups, 1);
            RunUI(() => SkylineWindow.Size = new Size(936, 527));
            WaitForGraphs();

            PauseForScreenShot("Heavy precursor chromatogram", 13);

            RunUI(() =>
            {
                var pathHeavy = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.TransitionGroups, 1);

                var graphChrom = SkylineWindow.GetGraphChrom(unknownReplicate);
                Assert.IsNotNull(graphChrom);
                Assert.AreEqual(unknownReplicate, graphChrom.NameSet);

                var firstGroupInfo = graphChrom.ChromGroupInfos.FirstOrDefault();
                Assert.IsNotNull(firstGroupInfo, "Missing group info");
                var firstChromItem = graphChrom.GraphItems.FirstOrDefault(gci => gci.TransitionChromInfo != null);
                Assert.IsNotNull(firstChromItem, "Missing graph item");

                var listChanges = new List <ChangedPeakBoundsEventArgs>
                {
                    new ChangedPeakBoundsEventArgs(pathHeavy,
                                                   null,
                                                   graphChrom.NameSet,
                                                   firstGroupInfo.FilePath,
                                                   firstChromItem.GetValidPeakBoundaryTime(20.65),
                                                   firstChromItem.GetValidPeakBoundaryTime(21.15),
                                                   PeakIdentification.FALSE,
                                                   PeakBoundsChangeType.both)
                };
                graphChrom.SimulateChangedPeakBounds(listChanges);
            });

            ShowAndPositionAuditLog(true, 50, 200);
            WaitForConditionUI(500, () => SkylineWindow.AuditLogForm.DataGridView.Rows.Count > 0);

            PauseForScreenShot <AuditLogForm>("Audit Log form with changed integration boundary.", 14);
            int reasonIndex = 2;

            using (new WaitDocumentChange())
            {
                RunUI(() =>
                {
                    var pathReason = PropertyPath.Root.Property("Reason");
                    var colReason  = SkylineWindow.AuditLogForm.FindColumn(pathReason);
                    reasonIndex    = colReason.Index;
                    SetCellValue(SkylineWindow.AuditLogForm.DataGridView, 0, reasonIndex,
                                 "Changed peak integration as instructed by the tutorial");
                });
            }
            RunUI(() => SkylineWindow.AuditLogForm.DataGridView.AutoResizeColumn(reasonIndex));
            SetGridFormToFullWidth(SkylineWindow.AuditLogForm);
            PauseForScreenShot <AuditLogForm>("Audit Log form with updated reason.", 14);

            // View the calibration curve p. 15
            RunUI(() => SkylineWindow.ShowCalibrationForm());
            var calibrationForm = FindOpenForm <CalibrationForm>();
            var priorZoomState  = ZoomCalibrationCurve(calibrationForm, 0.52);

            RunUI(() =>
            {
                Assert.AreEqual(CalibrationCurveFitter.AppendUnits(QuantificationStrings.Analyte_Concentration, quantUnits), calibrationForm.ZedGraphControl.GraphPane.XAxis.Title.Text);
                Assert.AreEqual(string.Format(QuantificationStrings.CalibrationCurveFitter_PeakAreaRatioText__0___1__Peak_Area_Ratio, IsotopeLabelType.light.Title, IsotopeLabelType.heavy.Title),
                                calibrationForm.ZedGraphControl.GraphPane.YAxis.Title.Text);

                VerifyCalibrationCurve(calibrationForm, 5.4065E-1, -2.9539E-1, 0.999);
            });

            PauseForScreenShot <CalibrationForm>("Calibration curve zoomed", 15);
            RunUI(() =>
            {
                priorZoomState?.ApplyState(calibrationForm.ZedGraphControl.GraphPane);

                var chromatograms = SkylineWindow.DocumentUI.Settings.MeasuredResults.Chromatograms;
                new [] { 5, 6, 7, 8 }.ForEach((index) =>
                {
                    int replicateIdx = chromatograms.IndexOf((ch) => ch.Name.Equals("Standard_" + index));
                    Assert.IsTrue(replicateIdx >= 0);
                    using (var excludeStandardMenu = calibrationForm.MakeExcludeStandardMenuItem(replicateIdx))
                    {
                        excludeStandardMenu?.PerformClick();
                    }
                });
            });
            WaitForGraphs();
            RunUI(() => VerifyCalibrationCurve(calibrationForm, 5.52E-1, -6.3678E-1, 1));
            OkDialog(calibrationForm, calibrationForm.Close);

            PauseForScreenShot <AuditLogForm>("Audit Log with excluded standard records", 16);

            PauseForScreenShot <AuditLogForm>("Audit Log Reports menu (manual)", 16);

            // TODO(nicksh): Audit log reason field does not currently support fill down
//            RunUI(() =>
//            {
//                SetCellValue(SkylineWindow.AuditLogForm.DataGridView, 0, reasonIndex, "Excluded standard below LOD");
//                for (int i = 0; i < 4; i++)
//                    SkylineWindow.AuditLogForm.DataGridView.Rows[i].Cells[reasonIndex].Selected = true;
//            });
//            RunUI(() => SkylineWindow.AuditLogForm.DataboundGridControl.FillDown());
            RunUI(() =>
            {
                for (int i = 0; i < 4; i++)
                {
                    SetCellValue(SkylineWindow.AuditLogForm.DataGridView, i, reasonIndex, "Excluded standard below LOD");
                }
            });
            RunUI(() =>
            {
                SkylineWindow.AuditLogForm.ChooseView(AuditLogStrings.AuditLogForm_MakeAuditLogForm_Undo_Redo);
            });
            SetGridFormToFullWidth(SkylineWindow.AuditLogForm);
            RunUI(() =>
            {
                var floatingWindow    = SkylineWindow.AuditLogForm.Parent.Parent;
                floatingWindow.Height = 334;
                floatingWindow.Width -= 15;
            });
            PauseForScreenShot <AuditLogForm>("Audit Log with UndoRedo view.", 17);
            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                });

                RestoreCoverViewOnScreen();

                var calibrationCoverForm = WaitForOpenForm <CalibrationForm>();
                ZoomCalibrationCurve(calibrationCoverForm, 0.53);
                var floatingLogWindow = SkylineWindow.AuditLogForm.Parent.Parent;
                var floatingCalWindow = calibrationCoverForm.Parent.Parent;
                RunUI(() =>
                {
                    floatingLogWindow.Top  = SkylineWindow.Bottom - floatingLogWindow.Height - 8;
                    floatingLogWindow.Left =
                        (SkylineWindow.Left + SkylineWindow.Right) / 2 - floatingLogWindow.Width / 2;
                    floatingCalWindow.Top  = SkylineWindow.Top + 8;
                    floatingCalWindow.Left = SkylineWindow.Right - floatingCalWindow.Width - 8;
                    SkylineWindow.AuditLogForm.DataGridView.AutoResizeColumn(reasonIndex);
                    SkylineWindow.AuditLogForm.DataGridView.AutoResizeColumn(reasonIndex - 1);
                });
                TakeCoverShot();
            }

            var customizeDialog = ShowDialog <ViewEditor>(SkylineWindow.AuditLogForm.NavBar.CustomizeView);

            RunUI(() =>
            {
                customizeDialog.ViewName = "Custom Columns";
                var columnsToAdd         = new[]
                {
                    PropertyPath.Parse("SkylineVersion"),
                    PropertyPath.Parse("User"),
                };
                foreach (var id in columnsToAdd)
                {
                    Assert.IsTrue(customizeDialog.ChooseColumnsTab.TrySelect(id), "Unable to select {0}", id);
                    customizeDialog.ChooseColumnsTab.AddSelectedColumn();
                }

                customizeDialog.Height = 370;
            });
            PauseForScreenShot <ViewEditor.ChooseColumnsView>("Custom Columns report template", 17);
            OkDialog(customizeDialog, customizeDialog.OkDialog);
            SetGridFormToFullWidth(SkylineWindow.AuditLogForm);
            RunUI(() => SkylineWindow.AuditLogForm.Parent.Parent.Height += 10); // Extra for 2-line headers
            PauseForScreenShot <AuditLogForm>("Audit Log with custom view.", 18);

            var registrationDialog = ShowDialog <MultiButtonMsgDlg>(() => SkylineWindow.ShowPublishDlg(null));

            PauseForScreenShot <MultiButtonMsgDlg>("Upload confirmation dialog.", 19);

            var loginDialog = ShowDialog <EditServerDlg>(registrationDialog.ClickNo);

            PauseForScreenShot <EditServerDlg>("Login dialog.", 20);

            RunUI(() =>
            {
                loginDialog.URL      = SERVER_URL;
                loginDialog.Username = PANORAMA_USER_NAME;
            });

            if (!IsPauseForScreenShots)
            {
                OkDialog(loginDialog, loginDialog.CancelButton.PerformClick);
            }
            else
            {
                PauseTest("Enter password. (manual) No screen shot.");

                var publishDialog = ShowDialog <PublishDocumentDlg>(loginDialog.OkDialog);
                WaitForCondition(() => publishDialog.IsLoaded);
                RunUI(() =>
                {
                    publishDialog.SelectItem(testFolderName);
                });
                PauseForScreenShot <PublishDocumentDlg>("Folder selection dialog.", 21);
                var browserConfirmationDialog = ShowDialog <MultiButtonMsgDlg>(publishDialog.OkDialog);

                OkDialog(browserConfirmationDialog, browserConfirmationDialog.ClickYes);

                PauseForScreenShot("Uploaded document in Panorama (in browser).");

                Regex reDocId = new Regex(@"\?id=([0-9]+)");
                Assert.IsTrue(reDocId.IsMatch(publishDialog.PanoramaPublishClient.UploadedDocumentUri.ToString()));

                string docId      = reDocId.Match(publishDialog.PanoramaPublishClient.UploadedDocumentUri.ToString()).Groups[1].Captures[0].Value;
                Uri    serverUri  = new Uri(SERVER_URL);
                Uri    requestUri = PanoramaUtil.Call(serverUri, "targetedms", String.Format("{0}/{1}", PANORAMA_FOLDER, testFolderName),
                                                      "showSkylineAuditLog", "id=" + docId);
                Process.Start(requestUri.ToString());
                PauseForScreenShot("Uploaded document audit log in Panorama (in browser).");
            }
        }
Exemple #11
0
 public void ChangeTextSize(double textFactor)
 {
     SkylineWindow.ChangeTextSize(textFactor);
 }
Exemple #12
0
        protected override void DoTest()
        {
            // Clear all the settings lists that will be defined in this tutorial
            ClearSettingsLists();

            // Open the file
            RunUI(() => SkylineWindow.OpenFile(GetTestPath(DIA_START_CHECKPOINT)));
            WaitForDocumentLoaded();

            // Specify DIA acquisition scheme and machine settings
            var transitionSettings = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);

            RunUI(() =>
            {
                transitionSettings.SelectedTab              = TransitionSettingsUI.TABS.FullScan;
                transitionSettings.AcquisitionMethod        = FullScanAcquisitionMethod.DIA;
                transitionSettings.PrecursorIsotopesCurrent = FullScanPrecursorIsotopes.Count;
                transitionSettings.PrecursorMassAnalyzer    = FullScanMassAnalyzerType.orbitrap;
                transitionSettings.PrecursorRes             = 35000;
                transitionSettings.PrecursorResMz           = 200;
                transitionSettings.ProductMassAnalyzer      = FullScanMassAnalyzerType.orbitrap;
                transitionSettings.ProductRes   = 17500;
                transitionSettings.ProductResMz = 200;
            });
            PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Transition Settings - Full-Scan", 4);

            // Set up isolation scheme
            var isolationSchemeDlg = ShowDialog <EditIsolationSchemeDlg>(transitionSettings.AddIsolationScheme);

            PauseForScreenShot <EditIsolationSchemeDlg>("Edit Isolation Scheme form", 5);

            RunUI(() =>
            {
                isolationSchemeDlg.UseResults = false;
            });

            var calculateIsolationDlg = ShowDialog <CalculateIsolationSchemeDlg>(isolationSchemeDlg.Calculate);

            RunUI(() =>
            {
                calculateIsolationDlg.WindowWidth             = 20;
                calculateIsolationDlg.Start                   = 500;
                calculateIsolationDlg.End                     = 900;
                calculateIsolationDlg.OptimizeWindowPlacement = true;
            });
            PauseForScreenShot <CalculateIsolationSchemeDlg>("Calculate Isolation Scheme form", 6);
            OkDialog(calculateIsolationDlg, calculateIsolationDlg.OkDialog);
            PauseForScreenShot <EditIsolationSchemeDlg>("Edit Isolation Scheme Dialog Filled", 7);

            var isolationSchemeGraphDlg = ShowDialog <DiaIsolationWindowsGraphForm>(isolationSchemeDlg.OpenGraph);

            PauseForScreenShot <DiaIsolationWindowsGraphForm>("Graph of Isolation Scheme", 8);
            OkDialog(isolationSchemeGraphDlg, isolationSchemeGraphDlg.CloseButton);
            const string isolationSchemeName = "500 to 900 by 20";

            RunUI(() => isolationSchemeDlg.IsolationSchemeName = isolationSchemeName);
            OkDialog(isolationSchemeDlg, isolationSchemeDlg.OkDialog);
            OkDialog(transitionSettings, transitionSettings.OkDialog);

            // Export isolation scheme
            var exportIsolationDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.IsolationList));

            PauseForScreenShot <ExportMethodDlg>("Export Isolation List form", 9);
            OkDialog(exportIsolationDlg, () => exportIsolationDlg.OkDialog(GetTestPath("DIA_tutorial_isolation_list.csv")));

            // Adjust modifications and filter
            var newPeptideSettings = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() => newPeptideSettings.AutoSelectMatchingPeptides = true);
            OkDialog(newPeptideSettings, newPeptideSettings.OkDialog);

            // Set up chromatogram retention time restriction
            var newTransitionSettings = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);

            RunUI(() => newTransitionSettings.SetRetentionTimeFilter(RetentionTimeFilterType.ms2_ids, 5.0));
            PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Retention time filtering options", 16);

            // Adjust library transition ranking
            RunUI(() =>
            {
                newTransitionSettings.SelectedTab    = TransitionSettingsUI.TABS.Library;
                newTransitionSettings.UseLibraryPick = true;
                newTransitionSettings.Filtered       = true;
            });
            PauseForScreenShot <TransitionSettingsUI.LibraryTab>("Transition Settings - Library tab", 22);
            OkDialog(newTransitionSettings, newTransitionSettings.OkDialog);
            PauseForScreenShot <SequenceTreeForm>("Targets pane with precursors and best 5 transitions only", 23);

            // Build spectral library using Import Peptide Search
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath(DIA_TUTORIAL_CHECKPOINT)));

            // "Build Spectral Library" page
            var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(() => SkylineWindow.ShowImportPeptideSearchDlg());

            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page);
                importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(new[] { GetTestPath("interact-20130311_DDA_Pit01.pep.xml") }); // Not L10N
                importPeptideSearchDlg.BuildPepSearchLibControl.WorkflowType = ImportPeptideSearchDlg.Workflow.dia;
            });
            PauseForScreenShot <ImportPeptideSearchDlg>("Build Library form - input files", 24);

            const string prefixKeep = "DIA_Pit0";

            if (IsFullImportMode)
            {
                SrmDocument doc = SkylineWindow.Document;
                RunUI(() => Assert.IsTrue(importPeptideSearchDlg.ClickNextButton()));
                doc = WaitForDocumentChange(doc);

                PauseForScreenShot <ImportPeptideSearchDlg.ChromatogramsDiaPage>("Import Results page", 25);

                // "Extract Chromatograms" page
                RunUI(() =>
                {
                    Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page);
                    importPeptideSearchDlg.ImportResultsControl.FoundResultsFiles =
                        _importFiles.Select(f => new ImportPeptideSearch.FoundResultsFile(f, GetTestPath(f + ExtensionTestContext.ExtThermoRaw))).ToList();
                });
                var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck);
                RunUI(() =>
                {
                    string prefix = importResultsNameDlg.Prefix;
                    Assert.IsTrue(prefix.EndsWith(prefixKeep));
                    importResultsNameDlg.Prefix = prefix.Substring(0, prefix.Length - prefixKeep.Length);
                    importResultsNameDlg.YesDialog();
                });
                WaitForClosedForm(importResultsNameDlg);

                // "Add Modifications" page
                RunUI(() =>
                {
                    const string modCarbamidomethyl = "Carbamidomethyl (C)";
                    const string modOxidation       = "Oxidation (M)";
                    Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.match_modifications_page);
                    // Define expected matched/unmatched modifications
                    var expectedMatched = new[] { modCarbamidomethyl, modOxidation };
                    // Verify matched/unmatched modifications
                    AssertEx.AreEqualDeep(expectedMatched, importPeptideSearchDlg.MatchModificationsControl.MatchedModifications.ToArray());
                    Assert.IsFalse(importPeptideSearchDlg.MatchModificationsControl.UnmatchedModifications.Any());
                    importPeptideSearchDlg.MatchModificationsControl.CheckedModifications = new[] { modCarbamidomethyl };
                    Assert.IsTrue(importPeptideSearchDlg.ClickNextButton());
                });
                WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage ==
                                   ImportPeptideSearchDlg.Pages.transition_settings_page);

                // "Configure Transition Settings" page
                RunUI(() =>
                {
                    importPeptideSearchDlg.TransitionSettingsControl.PeptidePrecursorCharges = Adduct.ProtonatedFromCharges(1, 2, 3, 4);
                    importPeptideSearchDlg.TransitionSettingsControl.PeptideIonCharges       = Adduct.ProtonatedFromCharges(1, 2);
                    importPeptideSearchDlg.TransitionSettingsControl.PeptideIonTypes         = new[] { IonType.y, IonType.b, IonType.precursor };
                    importPeptideSearchDlg.TransitionSettingsControl.ExclusionUseDIAWindow   = true;
                    importPeptideSearchDlg.TransitionSettingsControl.IonCount          = 5;
                    importPeptideSearchDlg.TransitionSettingsControl.IonMatchTolerance = 0.05;
                    Assert.IsTrue(importPeptideSearchDlg.ClickNextButton());
                });

                // "Configure Full-Scan Settings" page
                RunUI(() =>
                {
                    Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.full_scan_settings_page);
                    importPeptideSearchDlg.FullScanSettingsControl.IsolationSchemeName = isolationSchemeName;
                    Assert.IsTrue(importPeptideSearchDlg.ClickNextButton());
                });

                // "Import FASTA" page
                RunUI(() =>
                {
                    importPeptideSearchDlg.ImportFastaControl.SetFastaContent(GetTestPath("pituitary_database.fasta"));
                });

                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(6, proteinCount);
                    Assert.AreEqual(26, peptideCount);
                    Assert.AreEqual(31, precursorCount);
                    Assert.AreEqual(246, transitionCount);
                    peptidesPerProteinDlg.NewTargetsFinal(out proteinCount, out peptideCount, out precursorCount, out transitionCount);
                    Assert.AreEqual(6, proteinCount);
                    Assert.AreEqual(26, peptideCount);
                    Assert.AreEqual(31, precursorCount);
                    Assert.AreEqual(246, transitionCount);
                });
                OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog);
                WaitForClosedForm(importPeptideSearchDlg);
                WaitForCondition(10 * 60 * 1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);    // 10 minutes

                RunUI(() =>
                {
                    SkylineWindow.SaveDocument(GetTestPath(DIA_IMPORTED_CHECKPOINT));
                    SkylineWindow.SaveDocument(GetTestPath(DIA_TUTORIAL_CHECKPOINT));
                });
            }
            else
            {
                OkDialog(importPeptideSearchDlg, importPeptideSearchDlg.CancelDialog);
                RunUI(() => SkylineWindow.OpenFile(GetTestPath(DIA_IMPORTED_CHECKPOINT)));
            }
            WaitForDocumentLoaded();
            WaitForGraphs();

            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                SkylineWindow.Size = new Size(750, 788);
            });

            // Generate decoys
//            var decoysDlg = ShowDialog<GenerateDecoysDlg>(SkylineWindow.ShowGenerateDecoysDlg);
//            PauseForScreenShot<GenerateDecoysDlg>("Add Decoy Peptides form", 24);
//            RunUI(() =>
//            {
//                decoysDlg.NumDecoys = 26;
//                Assert.AreEqual(decoysDlg.DecoysMethod, DecoyGeneration.SHUFFLE_SEQUENCE);
//            });
//            OkDialog(decoysDlg, decoysDlg.OkDialog);
//            RunUI(() => SkylineWindow.SequenceTree.TopNode = SkylineWindow.SequenceTree.SelectedNode.PrevNode.Nodes[6]);
//            PauseForScreenShot<SequenceTreeForm>("Targets pane with decoys added", 25);

            RunUI(() =>
            {
                SkylineWindow.CollapsePeptides();
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 6);
                var nodePepTree            = SkylineWindow.SelectedNode as PeptideTreeNode;
                Assert.IsNotNull(nodePepTree);
                Assert.AreEqual("VLQAVLPPLPQVVCTYR", nodePepTree.DocNode.Peptide.Sequence);
                SkylineWindow.ShowSplitChromatogramGraph(true);
                SkylineWindow.AutoZoomBestPeak();
                var graphChrom   = SkylineWindow.GetGraphChrom(prefixKeep + "1");
                var labelStrings = graphChrom.GetAnnotationLabelStrings().ToArray();
                Assert.IsTrue(labelStrings.Contains(string.Format("{0}\n+{1} ppm", 75.4, 3)),
                              string.Format("Missing expected label in {0}", string.Join("|", labelStrings)));
                SkylineWindow.Width = 1250;
            });

            RunDlg <ChromChartPropertyDlg>(SkylineWindow.ShowChromatogramProperties, dlg =>
            {
                dlg.FontSize = GraphFontSize.NORMAL;
                dlg.OkDialog();
            });

            RestoreViewOnScreen(27);
            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile", 26);

            RunUI(SkylineWindow.SelectedNode.Expand);

            RunUI(() =>
            {
                var nodeTree = SkylineWindow.SelectedNode.Nodes[0].Nodes[0] as SrmTreeNode;
                Assert.IsNotNull(nodeTree);
                var expectedImageId = IsFullImportMode ? SequenceTree.StateImageId.peak : SequenceTree.StateImageId.no_peak;
                Assert.AreEqual((int)expectedImageId, nodeTree.StateImageIndex);
            });

            PauseForScreenShot <SequenceTreeForm>("Targets view - ", 27);

            RunUI(() =>
            {
                SkylineWindow.SetIntegrateAll(true);
                var nodeTree = SkylineWindow.SelectedNode.Nodes[0].Nodes[0] as SrmTreeNode;
                Assert.IsNotNull(nodeTree);
                Assert.AreEqual((int)SequenceTree.StateImageId.peak, nodeTree.StateImageIndex);
                var nodeGroupTree = SkylineWindow.SelectedNode.Nodes[0] as TransitionGroupTreeNode;
                Assert.IsNotNull(nodeGroupTree);
                Assert.AreEqual(0.99, nodeGroupTree.DocNode.GetIsotopeDotProduct(0) ?? 0, 0.005);
                Assert.AreEqual(0.83, nodeGroupTree.DocNode.GetLibraryDotProduct(0) ?? 0, 0.005);
                SkylineWindow.ShowOtherRunPeptideIDTimes(true);
            });

            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile - with ID lines", 28);

            RunUI(() =>
            {
                SkylineWindow.AutoZoomNone();
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 1);
            });

            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile - zoomed out and small peak", 30);

            RunUI(SkylineWindow.AutoZoomBestPeak);

            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile - zoomed to peak", 31);
            if (IsFullImportMode)
            {
                ClickChromatogram(74.9, 1.775E+7, PaneKey.PRECURSORS);
                RestoreViewOnScreen(33);
                PauseForScreenShot <GraphFullScan>("Full Scan graph with precursors - zoom manually", 32);

                ClickChromatogram(74.8, 1.753E+6, PaneKey.PRODUCTS);
                PauseForScreenShot <GraphFullScan>("Full Scan graph showing y7", 33);

                ClickChromatogram(74.9, 9.64E+5, PaneKey.PRODUCTS);
                PauseForScreenShot <GraphFullScan>("Full Scan graph showing b3 - zoom manually", 34);

                ClickChromatogram(74.9, 1.25E+5, PaneKey.PRODUCTS);
                PauseForScreenShot <GraphFullScan>("Full Scan graph showing y3 - zoom manually", 34);
            }

            RunUI(() =>
            {
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 2);
                Assert.AreEqual("CNTDYSDCIHEAIK", ((PeptideTreeNode)SkylineWindow.SelectedNode).DocNode.Peptide.Sequence);
            });

            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile - split between two precursors", 35);

            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    Settings.Default.ChromatogramFontSize = 14;
                    Settings.Default.AreaFontSize         = 14;
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                });

                RestoreCoverViewOnScreen();
//                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.PrevNode);
                WaitForGraphs();
                ClickChromatogram("DIA_Pit01", 75.3468, 104968093, PaneKey.PRODUCTS);
                TreeNode selectedNode = null;
                RunUI(() => selectedNode = SkylineWindow.SequenceTree.SelectedNode);
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.PrevNode);
                WaitForGraphs();
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = selectedNode);
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    transitionSettingsUI.Top  = SkylineWindow.Top;
                    transitionSettingsUI.Left = SkylineWindow.Left - transitionSettingsUI.Width - 20;
                });
                var isolationSchemeForm = ShowDialog <EditIsolationSchemeDlg>(transitionSettingsUI.EditCurrentIsolationScheme);
                RunUI(() =>
                {
                    isolationSchemeForm.Top   = SkylineWindow.Bottom - isolationSchemeForm.Height - 34;
                    isolationSchemeForm.Left  = SkylineWindow.Left + 40;
                    isolationSchemeForm.Width = 400;
                });
                var isolationSchemeGraph = ShowDialog <DiaIsolationWindowsGraphForm>(isolationSchemeForm.OpenGraph);
                RunUI(() =>
                {
                    isolationSchemeGraph.Height -= 58;
                    isolationSchemeGraph.Top     = SkylineWindow.Bottom - isolationSchemeGraph.Height;
                    isolationSchemeGraph.Left    = SkylineWindow.Left;
                    isolationSchemeGraph.Width   = 480;
                });
                TakeCoverShot();
                OkDialog(isolationSchemeGraph, isolationSchemeGraph.CloseButton);
                OkDialog(isolationSchemeForm, isolationSchemeForm.OkDialog);
                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
                return;
            }

            RunUI(() =>
            {
                SkylineWindow.SelectedNode.Expand();
                SkylineWindow.SelectedPath = ((SrmTreeNode)SkylineWindow.SelectedNode.Nodes[0]).Path;
            });

            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile - double charged precursor", 36);

            RunUI(() =>
            {
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 3);
                Assert.AreEqual("ELVYETVR", ((PeptideTreeNode)SkylineWindow.SelectedNode).DocNode.Peptide.Sequence);
            });

            RunUI(() =>
            {
                SkylineWindow.SelectedNode.Expand();
                var nodeGroupTree = SkylineWindow.SelectedNode.Nodes[0] as TransitionGroupTreeNode;
                Assert.IsNotNull(nodeGroupTree);
                Assert.AreEqual(0.99, nodeGroupTree.DocNode.GetIsotopeDotProduct(0) ?? 0, 0.005);
                Assert.AreEqual(0.99, nodeGroupTree.DocNode.GetIsotopeDotProduct(0) ?? 0, 0.005);
            });

            RestoreViewOnScreen(38);
            PauseForScreenShot <GraphSpectrum>("Library Match view - zoom manually", 37);

            RestoreViewOnScreen(39);
            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile", 38);

            if (IsFullImportMode)
            {
                RestoreViewOnScreen(40);
                ClickChromatogram(41.9, 1.166E+8, PaneKey.PRECURSORS);
                PauseForScreenShot <GraphFullScan>("Full Scan graph showing precursor interference - zoom manually", 39);

                RunUI(() => SkylineWindow.GraphFullScan.ChangeScan(-12));
                CheckFullScanSelection(41.7, 1.532E+8, PaneKey.PRECURSORS);
                PauseForScreenShot <GraphFullScan>("Full Scan graph showing transition between interference and real peak - zoom manually", 39);
            }

            // Clear all the settings lists that were defined in this tutorial
            ClearSettingsLists();
        }
        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);
        }
        protected override void DoTest()
        {
            // Creating a MS/MS Spectral Library, p. 1
            PeptideSettingsUI peptideSettingsUI = ShowDialog<PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            RunDlg<BuildLibraryDlg>(peptideSettingsUI.ShowBuildLibraryDlg, buildLibraryDlg =>
            {
                buildLibraryDlg.LibraryPath = TestFilesDirs[0].GetTestPath(@"MethodEdit\Library\"); // Not L10N
                buildLibraryDlg.LibraryName = YEAST_ATLAS;
                buildLibraryDlg.LibraryCutoff = 0.95;
                buildLibraryDlg.OkWizardPage();
                IList<string> inputPaths = new List<string>
                 {
                     TestFilesDirs[0].GetTestPath(@"MethodEdit\Yeast_atlas\interact-prob.pep.xml") // Not L10N
                 };
                buildLibraryDlg.AddInputFiles(inputPaths);
                buildLibraryDlg.OkWizardPage();
            });

            PeptideSettingsUI peptideSettingsUI1 = peptideSettingsUI;
            RunUI(() =>
                {
                    peptideSettingsUI1.SelectedTab = PeptideSettingsUI.TABS.Library;
                    peptideSettingsUI1.PickedLibraries = new[] { YEAST_ATLAS };
                });
            WaitForOpenForm<PeptideSettingsUI>();   // To show Library tab for Forms testing
            PauseForScreenShot<PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 4); // Not L10N

            RunUI(() => peptideSettingsUI1.SelectedTab = PeptideSettingsUI.TABS.Digest);
            WaitForOpenForm<PeptideSettingsUI>();   // To show Digestion tab for Forms testing

            // Creating a Background Proteome File, p. 3
            FileEx.SafeDelete(TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\Yeast" + ProteomeDb.EXT_PROTDB)); // Not L10N
            var buildBackgroundProteomeDlg =
                ShowDialog<BuildBackgroundProteomeDlg>(peptideSettingsUI.ShowBuildBackgroundProteomeDlg);
            RunUI(() =>
            {
                buildBackgroundProteomeDlg.BackgroundProteomeName = "Yeast"; // Not L10N
                buildBackgroundProteomeDlg.CreateDb(TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\Yeast" + ProteomeDb.EXT_PROTDB)); // Not L10N
            });
            AddFastaToBackgroundProteome(buildBackgroundProteomeDlg, TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\sgd_yeast.fasta"), 61);
            RunUI(buildBackgroundProteomeDlg.SelToEndBackgroundProteomePath);
            PauseForScreenShot<BuildBackgroundProteomeDlg>("Edit Background Proteome form", 5); // Not L10N

            OkDialog(buildBackgroundProteomeDlg, buildBackgroundProteomeDlg.OkDialog);

            PauseForScreenShot<PeptideSettingsUI.DigestionTab>("Peptide Settings - Digestion tab", 6); // Not L10N

            var docB = SkylineWindow.Document;
            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
            
            WaitForDocumentChange(docB);

            if (!TryWaitForCondition(() =>
                SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded &&
                SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0))
            {
                Assert.Fail("Timed out loading libraries: libCount={0}, NotLoadedExplained={1}",
                    SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count,
                    SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsNotLoadedExplained ?? "<null>");
            }

            // Wait a bit in case web access is turned on and backgroundProteome is actually resolving protein metadata
            int millis = (AllowInternetAccess ? 300 : 60) * 1000;
            WaitForConditionUI(millis, () =>
                SkylineWindow.DocumentUI.Settings.HasBackgroundProteome &&
                !SkylineWindow.DocumentUI.Settings.PeptideSettings.BackgroundProteome.NeedsProteinMetadataSearch,
                () => "backgroundProteome.NeedsProteinMetadataSearch");
            WaitForConditionUI(() => SkylineWindow.DocumentUI.RevisionIndex == 3);

            // FASTA paste will happen on the UI thread
            RunUI(() =>
            {
                // Really truly fully loaded?
                var allDescriptions = SkylineWindow.DocumentUI.NonLoadedStateDescriptionsFull.ToArray();
                if (allDescriptions.Length > 0)
                    Assert.Fail(TextUtil.LineSeparate("Document not fully loaded:", TextUtil.LineSeparate(allDescriptions)));

                // Should have been 3 changes: 1. peptide settings, 2. library load, 3. background proteome completion
                AssertEx.IsDocumentState(SkylineWindow.DocumentUI, 3, 0, 0, 0, 0);
            });

            // Pasting FASTA Sequences, p. 5
            RunUI(() => SetClipboardFileText(@"MethodEdit\FASTA\fasta.txt")); // Not L10N

            // New in v0.7 : Skyline asks about removing empty proteins.
            using (new CheckDocumentState(35, 25, 25, 75, null, true))
//            using (new ImportFastaDocChangeLogger()) // Log any unexpected document changes (i.e. changes not due to import fasta)
            {
                var emptyProteinsDlg = ShowDialog<EmptyProteinsDlg>(SkylineWindow.Paste);
                RunUI(() => emptyProteinsDlg.IsKeepEmptyProteins = true);
                OkDialog(emptyProteinsDlg, emptyProteinsDlg.OkDialog);
                WaitForCondition(millis, () => SkylineWindow.SequenceTree.Nodes.Count > 4);
            }

            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[3].Nodes[0];
                SkylineWindow.Size = new Size(1035, 511);
            });
            RestoreViewOnScreen(07);
            PauseForScreenShot("Main window", 7); // Not L10N

            RunUI(() =>
            {
                Settings.Default.ShowBIons = true;
                SkylineWindow.SequenceTree.SelectedNode.Expand();
                SkylineWindow.SequenceTree.SelectedNode =
                    SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Nodes[1];
            });
            PauseForScreenShot("Main window showing effect of selection on Library Match graph", 8); // Not L10N

            CheckTransitionCount("VDIIANDQGNR", 3); // Not L10N

            using (new CheckDocumentState(35, 28, 31, 155, null, true))
            {
                var transitionSettingsUI = ShowDialog<TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                    {
                        transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Filter;
                        transitionSettingsUI.PrecursorCharges = "2, 3"; // Not L10N
                        transitionSettingsUI.ProductCharges = "1"; // Not L10N
                        transitionSettingsUI.FragmentTypes = "y, b"; // Not L10N
                    });
                WaitForOpenForm<TransitionSettingsUI>();   // To show Filter tab for Forms testing
                PauseForScreenShot<TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 9); // Not L10N
                RunUI(() =>
                    {
                        transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Library;
                        transitionSettingsUI.IonCount = 5;
                    });
                PauseForScreenShot<TransitionSettingsUI.LibraryTab>("Transition Settings - Library tab", 10); // Not L10N
                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }
            PauseForScreenShot("Targets tree clipped from main window", 11); // Not L10N

            if (IsCoverShotMode)
            {
                RunUI(() =>
                {
                    Settings.Default.SpectrumFontSize = 14;
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                });
                RestoreCoverViewOnScreen(false);
                RunUI(() => SkylineWindow.SequenceTree.TopNode = SkylineWindow.SelectedNode.Parent.Parent.Parent);
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.PrevNode);
                WaitForGraphs();
                RunUI(() => SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SelectedNode.NextNode);
                TakeCoverShot();
                return;
            }

            CheckTransitionCount("VDIIANDQGNR", 5); // Not L10N

            // Using a Public Spectral Library, p. 9
            peptideSettingsUI = ShowDialog<PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var editListUI =
                ShowDialog<EditListDlg<SettingsListBase<LibrarySpec>, LibrarySpec>>(peptideSettingsUI.EditLibraryList);
            var addLibUI = ShowDialog<EditLibraryDlg>(editListUI.AddItem);
            RunUI(() => addLibUI.LibrarySpec =
                new BiblioSpecLibSpec(YEAST_GPM, TestFilesDirs[0].GetTestPath(@"MethodEdit\Library\yeast_cmp_20.hlf"))); // Not L10N
            OkDialog(addLibUI, addLibUI.OkDialog);
            WaitForClosedForm(addLibUI);
            OkDialog(editListUI, editListUI.OkDialog);

            // Limiting Peptides per Protein, p. 11
            using (new CheckDocumentState(35, 182, 219, 1058, null, true))
            {
                RunUI(() =>
                    {
                        peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Library;
                        peptideSettingsUI.PickedLibraries = new[] {YEAST_ATLAS, YEAST_GPM};
                    });
                PauseForScreenShot<PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 12); // Not L10N
                OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
                Assert.IsTrue(WaitForCondition(
                    () =>
                        SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded &&
                            SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0));
            }

            using (new CheckDocumentState(35, 47, 47, 223, 2, true))    // Wait for change loaded, and expect 2 document revisions.
            {
                RunDlg<PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsUI2 =>
                    {
                        peptideSettingsUI2.PickedLibraries = new[] {YEAST_GPM};
                        peptideSettingsUI2.LimitPeptides = true;
                        peptideSettingsUI2.RankID = XHunterLibSpec.PEP_RANK_EXPECT;
                        peptideSettingsUI2.PeptidesPerProtein = 3;
                        peptideSettingsUI2.OkDialog();
                    });
            }

            using (new CheckDocumentState(19, 47, 47, 223, null, true))
            {
                RunUI(() =>
                    {
                        var refinementSettings = new RefinementSettings {MinPeptidesPerProtein = 1};
                        SkylineWindow.ModifyDocument("Remove empty proteins", refinementSettings.Refine); // Not L10N
                    });
            }

            // Inserting a Protein List, p. 11
            using (new CheckDocumentState(36, 58, 58, 278, null, true))
            {
                PasteDlg pasteProteinsDlg = ShowDialog<PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);
                RunUI(() =>
                    {
                        var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                        SkylineWindow.SequenceTree.SelectedNode = node;
                        SetClipboardFileText(@"MethodEdit\FASTA\Protein list.txt"); // Not L10N
                        pasteProteinsDlg.SelectedPath = SkylineWindow.SequenceTree.SelectedPath;
                        pasteProteinsDlg.PasteProteins();
                    });
                PauseForScreenShot<PasteDlg.ProteinListTab>("Insert Protein List - For Screenshot, select last (empty) item in list", 14); // Not L10N
                OkDialog(pasteProteinsDlg, pasteProteinsDlg.OkDialog);
            }

            using (new CheckDocumentState(24, 58, 58, 278, null, true))
            {
                RunUI(() =>
                    {
                        var refinementSettings = new RefinementSettings {MinPeptidesPerProtein = 1};
                        SkylineWindow.ModifyDocument("Remove empty proteins", refinementSettings.Refine); // Not L10N
                    });
            }

            // Wait for protein metadata again to avoid changes during paste
            WaitForProteinMetadataBackgroundLoaderCompleted(millis);
            
            // Inserting a Peptide List, p. 13
            using (new CheckDocumentState(25, 70, 70, 338, null, true))
//            using (new ImportFastaDocChangeLogger()) // Log any unexpected document changes (i.e. changes not due to import fasta)
            {
                RunUI(() =>
                    {
                        SetClipboardFileText(@"MethodEdit\FASTA\Peptide list.txt"); // Not L10N
                        SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0];
                        SkylineWindow.Paste();
                    });
            }

            RunUI(() => SkylineWindow.SequenceTree.Nodes[0].Text = @"Primary Peptides");
            FindNode("TLTAQSMQNSTQSAPNK"); // Not L10N
            PauseForScreenShot("Main window", 16); // Not L10N

            using (new CheckDocumentState(35, 70, 70, 338, null, true))
            {
                RunUI(() => SkylineWindow.Undo());
                PasteDlg pastePeptidesDlg = ShowDialog<PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);
                RunUI(pastePeptidesDlg.PastePeptides);
                PauseForScreenShot<PasteDlg.PeptideListTab>("Insert Peptide List -  For screenshot, select last (empty) line in list", 17); // Not L10N
                OkDialog(pastePeptidesDlg, pastePeptidesDlg.OkDialog);
            }

            // Simple Refinement, p. 16
            var findPeptideDlg = ShowDialog<FindNodeDlg>(SkylineWindow.ShowFindNodeDlg);
            RunUI(() => findPeptideDlg.SearchString = "IPEE"); // Not L10N
            OkDialog(findPeptideDlg, () =>
                                         {
                                             findPeptideDlg.FindNext();
                                             findPeptideDlg.Close();
                                         });
            PauseForScreenShot<GraphSpectrum>("Library Match graph metafile", 18); // Not L10N

            using (new CheckDocumentState(35, 64, 64, 320, null, true))
            {
                RefineDlg refineDlg = ShowDialog<RefineDlg>(SkylineWindow.ShowRefineDlg);
                PauseForForm(typeof(RefineDlg.DocumentTab));
                RunUI(() => refineDlg.MinTransitions = 5);
                OkDialog(refineDlg, refineDlg.OkDialog);
                PauseForScreenShot("29/35 prot 50/64 pep 50/64 prec 246/320 tran", 18); // Not L10N
            }

            // Checking Peptide Uniqueness, p. 18
            RunUI(() =>
            {
                var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 2];
                SkylineWindow.SequenceTree.SelectedNode = node;
            });

            using (new CheckDocumentState(34, 63, 63, 315, null, true))
            {
                var uniquePeptidesDlg = ShowDialog<UniquePeptidesDlg>(SkylineWindow.ShowUniquePeptidesDlg);
                WaitForConditionUI(() => uniquePeptidesDlg.GetDataGridView().RowCount == 1);
                RunUI(() =>
                    {
                        Assert.AreEqual(1, uniquePeptidesDlg.GetDataGridView().RowCount);
                        Assert.AreEqual(7, uniquePeptidesDlg.GetDataGridView().ColumnCount);
                    });
                PauseForScreenShot<UniquePeptidesDlg>("Unique Peptides form", 19); // Not L10N
                var oldDoc = SkylineWindow.Document;
                OkDialog(uniquePeptidesDlg, uniquePeptidesDlg.OkDialog);
                RunUI(() => Assert.AreSame(oldDoc, SkylineWindow.DocumentUI));
                RunUI(() => SkylineWindow.EditDelete());
            }

            // Protein Name Auto-Completion
            PauseForScreenShot("(fig. 1): For screenshot, click at bottom of document tree, type 'ybl087' and see the autocomplete text.  Make sure to undo this new entry before proceeding.", 20); // Not L10N
            TestAutoComplete("ybl087", 0); // Not L10N
            var peptideGroups = new List<PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups);
            Assert.AreEqual("YBL087C", peptideGroups[peptideGroups.Count - 1].Name); // Not L10N

            // Protein Description Auto-Completion
            PauseForScreenShot("(fig. 2): For screenshot, click at bottom of document tree, type 'eft2' and see the autocomplete text, then down-arrow twice. Make sure to undo this new entry before proceeding.", 20); // Not L10N
            TestAutoComplete("eft2", 0); // Sorting logic puts this at the 0th entry in the list - Not L10N
            peptideGroups = new List<PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups);
            Assert.AreEqual("YDR385W", peptideGroups[peptideGroups.Count - 1].Name); // Not L10N

            // Peptide Sequence Auto-Completion, p. 21
            TestAutoComplete("IQGP", 0); // Not L10N
            var peptides = new List<PeptideDocNode>(Program.ActiveDocument.Peptides);
            Assert.AreEqual("K.AYLPVNESFGFTGELR.Q [769, 784]", peptides[peptides.Count - 1].Peptide.ToString()); // Not L10N
            PauseForScreenShot("(fig. 1) - For screenshot, click at the bottom of the document tree", 21); // Not L10N

            // Pop-up Pick-Lists, p. 21
            using (new CheckDocumentState(36, 71, 71, 355, null, true))
            {
                RunUI(() =>
                    {
                        var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 3];
                        SkylineWindow.SequenceTree.SelectedNode = node;
                    });
                var pickList = ShowDialog<PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
                RunUI(() =>
                    {
                        pickList.ApplyFilter(false);
                        pickList.SetItemChecked(8, true);
                        pickList.AutoManageChildren = false; // TODO: Because calling SetItemChecked does not do this
                    });
                PauseForScreenShot<PopupPickList>("(fig. 2) - YBL087C Peptides picklist", 21); // Not L10N
                RunUI(pickList.OnOk);
            }

            using (new CheckDocumentState(36, 71, 71, 355))
            {
                RunUI(() =>
                    {
                        SkylineWindow.SequenceTree.Nodes[34].ExpandAll();
                        var node =
                            SkylineWindow.SequenceTree.Nodes[34].Nodes[0].Nodes[0];
                        SkylineWindow.SequenceTree.SelectedNode = node;
                    });
                var pickList1 = ShowDialog<PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
                RunUI(() =>
                    {
                        pickList1.SearchString = "y"; // Not L10N
                        pickList1.SetItemChecked(0, false);
                        pickList1.SetItemChecked(1, false);
                        pickList1.ApplyFilter(false);
                        pickList1.ToggleFind();
                        pickList1.SearchString = "b ++"; // Not L10N
                        pickList1.SetItemChecked(4, true);
                        pickList1.SetItemChecked(6, true);
                    });
                PauseForScreenShot<PopupPickList>("b ++ filtered picklist", 22); // Not L10N
                RunUI(pickList1.OnOk);
            }

            // Bigger Picture, p. 22. Drag and Drop, p. 23
            RunUI(() =>
            {
                ITipProvider nodeTip = SkylineWindow.SequenceTree.SelectedNode as ITipProvider;
                Assert.IsTrue(nodeTip != null && nodeTip.HasTip);
                var nodeName = SkylineWindow.SequenceTree.Nodes[1].Name;
                IdentityPath selectPath;
                SkylineWindow.ModifyDocument("Drag and drop", // Not L10N
                    doc => doc.MoveNode(SkylineWindow.Document.GetPathTo(0, 1), SkylineWindow.Document.GetPathTo(0, 0), out selectPath));
                Assert.IsTrue(SkylineWindow.SequenceTree.Nodes[0].Name == nodeName);
            });

            FindNode(string.Format("L [b5] - {0:F04}+", 484.3130)); // Not L10N - may be localized " (rank 3)"
            ShowNodeTip("YBL087C");
            ShowNodeTip(string.Format("{0:F04}+++", 672.6716));
            ShowNodeTip(null);
            PauseForScreenShot("For Screenshots, First hover over YBL087C, then over 672.671+++", 23); // Not L10N

            // Preparing to Measure, p. 25
            RunDlg<TransitionSettingsUI>(() => SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.Prediction), transitionSettingsUI =>
            {
                transitionSettingsUI.RegressionCE = Settings.Default.GetCollisionEnergyByName("SCIEX"); // Not L10N
                transitionSettingsUI.RegressionDP = Settings.Default.GetDeclusterPotentialByName("SCIEX"); // Not L10N
                transitionSettingsUI.InstrumentMaxMz = 1800;
                transitionSettingsUI.OkDialog();
            });
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDirs[0].GetTestPath("MethodEdit Tutorial.sky"))); // Not L10N
            var exportDialog = ShowDialog<ExportMethodDlg>(() =>
                SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
            RunUI(() =>
            {
                exportDialog.ExportStrategy = ExportStrategy.Buckets;
                exportDialog.MethodType = ExportMethodType.Standard;
                exportDialog.OptimizeType = ExportOptimize.NONE;
                exportDialog.IgnoreProteins = true;
                exportDialog.MaxTransitions = 75;
            });
            PauseForScreenShot<ExportMethodDlg.TransitionListView>("Export Transition List form", 25); // Not L10N
            
            const string basename = "Yeast_list"; //  Not L10N
            OkDialog(exportDialog, () => exportDialog.OkDialog(TestFilesDirs[0].GetTestPath(basename)));  // write Yeast_list_000n.csv

            // check the output files
            for (int n = 0; n++ < 5;)
            {
                var csvname = String.Format("{0}_{1}.csv", basename, n.ToString("D4")); // Not L10N

                // AssertEx.FieldsEqual is hard-coded with CultureInfo.InvariantCulture, but so is transition list CSV export, so OK
                using (TextReader actual = new StreamReader(TestFilesDirs[0].GetTestPath(csvname)))
                using (TextReader target = new StreamReader(TestFilesDirs[1].GetTestPath(csvname)))
                {
                    AssertEx.FieldsEqual(target, actual, 6, null, true);
                }
            }
        }
        protected override void DoTest()
        {
            Settings.Default.PeakScoringModelList.Clear();

            // Open the file
            RunUI(() => SkylineWindow.OpenFile(GetTestPath("SRMCourse_DosR-hDP__20130501-tutorial-empty.sky"))); // Not L10N
            WaitForDocumentLoaded();

            // Add decoys
            var generateDecoysDlg = ShowDialog <GenerateDecoysDlg>(() => SkylineWindow.ShowGenerateDecoysDlg());

            RunUI(() =>
            {
                generateDecoysDlg.DecoysMethod = DecoyGeneration.REVERSE_SEQUENCE;
                generateDecoysDlg.NumDecoys    = 29;
            });
            PauseForScreenShot <GenerateDecoysDlg>("Add Decoy Peptides form", 2);

            RunUI(generateDecoysDlg.OkDialog);
            WaitForClosedForm(generateDecoysDlg);

            RestoreViewOnScreen(3);
            RunUI(() => SkylineWindow.SequenceTree.TopNode = SkylineWindow.SequenceTree.Nodes[11]);
            PauseForScreenShot("Targets view clipped from main window", 3);

            // Open the file with decoys
            RunUI(() => SkylineWindow.OpenFile(GetTestPath("SRMCourse_DosR-hDP__20130501-tutorial-empty-decoys.sky"))); // Not L10N
            WaitForDocumentLoaded();

            // Import the raw data
            var importResultsDlg = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);

            RunUI(() =>
            {
                importResultsDlg.RadioAddNewChecked = true;
                var path = new KeyValuePair <string, MsDataFileUri[]> [5];
                for (int i = 0; i < 5; ++i)
                {
                    path[i] = new KeyValuePair <string, MsDataFileUri[]>(_importFiles[i],
                                                                         new[] { MsDataFileUri.Parse(GetTestPath(_importFiles[i] + ExtAbWiff)) });
                }

                importResultsDlg.NamedPathSets = path;
            });
            var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg.OkDialog);

            PauseForScreenShot <ImportResultsNameDlg>("Import Results common prefix form", 4);
            RunUI(() =>
            {
                string prefix = importResultsNameDlg.Prefix;
                importResultsNameDlg.Prefix = prefix.Substring(0, prefix.Length - 1);
                importResultsNameDlg.YesDialog();
            });
            WaitForClosedForm(importResultsNameDlg);
            WaitForClosedForm(importResultsDlg);
            WaitForConditionUI(5 * 60 * 1000, () =>
                               SkylineWindow.DocumentUI.Settings.HasResults &&
                               SkylineWindow.DocumentUI.Settings.MeasuredResults.IsLoaded); // 5 minutes
            RestoreViewOnScreen(5);
            const string peptideSeqHighlight = "LPDGNGIELCR";

            RunUI(() =>
            {
                var nodeGroup = SkylineWindow.DocumentUI.PeptideTransitionGroups.ToArray()[71];
                Assert.AreEqual(nodeGroup.TransitionGroup.Peptide.Sequence, peptideSeqHighlight);
                var chromGroupInfo = nodeGroup.ChromInfos.ToList()[0];
                Assert.IsNotNull(chromGroupInfo.RetentionTime);
                // TODO: Fix the tutorial.  This was supposed to be an incorrectly picked peak, but our default scoring is now good enough to pick it correctly
                Assert.AreEqual(chromGroupInfo.RetentionTime.Value, 18.0, 0.1);
                SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
            });
            RunDlg <ChromChartPropertyDlg>(SkylineWindow.ShowChromatogramProperties, dlg =>
            {
                dlg.FontSize = GraphFontSize.LARGE;
                dlg.OkDialog();
            });
            PauseForScreenShot("Main window", 5);

            // Test different point types on RTLinearRegressionGraph
            RunUI(() =>
            {
                SkylineWindow.ShowRTRegressionGraphScoreToRun();
                SkylineWindow.ShowPlotType(PlotTypeRT.correlation);
                SkylineWindow.ChooseCalculator("iRT_SRMAtlas_20121202_noLGG");
            });
            const int numDecoys = 30;

            CheckPointsTypeRT(PointsTypeRT.targets, SkylineWindow.Document.PeptideCount - numDecoys);
            CheckPointsTypeRT(PointsTypeRT.standards, SkylineWindow.Document.GetRetentionTimeStandards().Count);
            CheckPointsTypeRT(PointsTypeRT.decoys, numDecoys);
            RunUI(() => SkylineWindow.ShowGraphRetentionTime(false));
            WaitForDocumentLoaded();

            // Train the peak scoring model
            var reintegrateDlg = ShowDialog <ReintegrateDlg>(SkylineWindow.ShowReintegrateDialog);

            PauseForScreenShot <ReintegrateDlg>("Reintegrate form", 6);
            var editDlg = ShowDialog <EditPeakScoringModelDlg>(reintegrateDlg.AddPeakScoringModel);

            RunUI(() => editDlg.TrainModel());
            PauseForScreenShot <EditPeakScoringModelDlg.ModelTab>("Edit Peak Scoring Model form trained model", 6);
            RunUI(() => Assert.AreEqual(0.5926, editDlg.PeakCalculatorsGrid.Items[3].PercentContribution ?? 0, 0.005));

            RunUI(() => editDlg.SelectedGraphTab = 2);
            PauseForScreenShot <EditPeakScoringModelDlg.PvalueTab>("Edit Peak Scoring Model form p value graph metafile", 7);

            RunUI(() => editDlg.SelectedGraphTab = 3);
            PauseForScreenShot <EditPeakScoringModelDlg.QvalueTab>("Edit Peak Scoring Model form q value graph metafile", 8);

            RunUI(() => editDlg.SelectedGraphTab = 1);
            RunUI(() => editDlg.PeakCalculatorsGrid.SelectRow(3));
            PauseForScreenShot <EditPeakScoringModelDlg.FeaturesTab>("Edit Peak Scoring Model form feature score", 10);

            RunUI(() =>
            {
                Assert.AreEqual(18, editDlg.PeakCalculatorsGrid.RowCount);
                // The rows which the tutorial says are missing scores are in fact missing scores
                foreach (int i in new[] { 2, 7, 8, 9, 10, 11, 13, 15 }) // MS1 scores are now missing, 19, 20, 21, 22
                {
                    Assert.IsFalse(editDlg.IsActiveCell(i, 0));
                }
                editDlg.IsFindButtonVisible = true;
                editDlg.FindMissingValues(2);   // Retention time
                editDlg.PeakScoringModelName = "test1";
            });
            PauseForScreenShot <EditPeakScoringModelDlg.FeaturesTab>("Edit Peak Scoring Model form find missing scores", 11);

            OkDialog(editDlg, editDlg.OkDialog);
            OkDialog(reintegrateDlg, reintegrateDlg.CancelDialog);

            PauseForScreenShot <FindResultsForm>("Find Results view clipped from main window", 12);

            // Remove the peptide with no library dot product, and train again
            FindResultsForm findResultsForm = null;
            var             missingPeptides = new List <string> {
                "LGGNEQVTR", "IPVDSIYSPVLK", "YFNDGDIVEGTIVK",
                "DFDSLGTLR", "GGYAGMLVGSVGETVAQLAR", "GGYAGMLVGSVGETVAQLAR"
            };
            var isDecoys = new List <bool> {
                false, false, false, false, false, true
            };

            RunUI(() =>
            {
                findResultsForm = FormUtil.OpenForms.OfType <FindResultsForm>().FirstOrDefault();
                Assert.IsNotNull(findResultsForm);
// ReSharper disable once PossibleNullReferenceException
                Assert.AreEqual(findResultsForm.ItemCount, 6);
                for (int i = 0; i < 6; ++i)
                {
                    findResultsForm.ActivateItem(i);
                    Assert.AreEqual(SkylineWindow.SelectedPeptideSequence, missingPeptides[i]);
                    if (0 < i && i < 5)
                    {
                        SkylineWindow.SetStandardType(PeptideDocNode.STANDARD_TYPE_QC);
                    }
                }
            });

            RunUI(() => findResultsForm.Close());

            for (int i = 0; i < 6; ++i)
            {
                if (!(0 < i && i < 5))
                {
                    RemovePeptide(missingPeptides[i], isDecoys[i]);
                }
            }

            if (IsCoverShotMode)
            {
                RestoreCoverViewOnScreen();
                var reintegrateDlgCover = ShowDialog <ReintegrateDlg>(SkylineWindow.ShowReintegrateDialog);
                var editModelCover      = ShowDialog <EditPeakScoringModelDlg>(reintegrateDlgCover.AddPeakScoringModel);
                RunUI(() =>
                {
                    editModelCover.Top  = SkylineWindow.Top + 8;
                    editModelCover.Left = SkylineWindow.Right - editModelCover.Width - 8;
                    editModelCover.PeakScoringModelName = "SRMCourse";
                    editModelCover.TrainModelClick();
                });
                TakeCoverShot();

                OkDialog(editModelCover, editModelCover.CancelDialog);
                OkDialog(reintegrateDlgCover, reintegrateDlgCover.CancelDialog);
                return;
            }

            var reintegrateDlgNew = ShowDialog <ReintegrateDlg>(SkylineWindow.ShowReintegrateDialog);
            var editListLibrary   = ShowDialog <EditListDlg <SettingsListBase <PeakScoringModelSpec>, PeakScoringModelSpec> >(
                reintegrateDlgNew.EditPeakScoringModel);

            RunUI(() => editListLibrary.SelectItem("test1"));
            var editDlgLibrary = ShowDialog <EditPeakScoringModelDlg>(editListLibrary.EditItem);

            RunUI(() =>
            {
                foreach (int i in new[] { 2, 8, 9, 10, 11 })
                {
                    Assert.IsTrue(editDlgLibrary.IsActiveCell(i, 0));
                    Assert.IsFalse(editDlgLibrary.PeakCalculatorsGrid.Items[i].IsEnabled);
                    editDlgLibrary.PeakCalculatorsGrid.Items[i].IsEnabled = true;
                }
                editDlgLibrary.TrainModel(true);
            });
            PauseForScreenShot <EditPeakScoringModelDlg.ModelTab>("Edit Peak Scoring Model form with library score", 13);

            RunUI(() => editDlgLibrary.SelectedGraphTab = 3);
            PauseForScreenShot <EditPeakScoringModelDlg.QvalueTab>("Edit Peak Scoring Model form q value graph with library score metafile", 14);

            OkDialog(editDlgLibrary, editDlgLibrary.OkDialog);

            // Open up the model again for editing, re-train with second best peaks and removing some scores
            RunUI(() => editListLibrary.SelectItem("test1")); // Not L10N
            var editDlgNew = ShowDialog <EditPeakScoringModelDlg>(editListLibrary.EditItem);

            RunUI(() =>
            {
                Assert.IsFalse(editDlgNew.UsesSecondBest);
                Assert.IsTrue(editDlgNew.UsesDecoys);
                Assert.IsTrue(editDlgNew.PeakCalculatorsGrid.Items[4].IsEnabled);
                Assert.IsTrue(editDlgNew.PeakCalculatorsGrid.Items[4].PercentContribution < 0);
                Assert.IsTrue(editDlgNew.PeakCalculatorsGrid.Items[2].IsEnabled);
                Assert.IsTrue(editDlgNew.PeakCalculatorsGrid.Items[2].PercentContribution > 0);
                editDlgNew.UsesSecondBest = true;
                editDlgNew.PeakCalculatorsGrid.Items[4].IsEnabled = false;
                editDlgNew.PeakCalculatorsGrid.Items[2].IsEnabled = false;
                editDlgNew.TrainModel(true);
                // Check that these cells are still active even though they've been unchecked
                Assert.IsTrue(editDlgNew.IsActiveCell(6, 0));
            });
            PauseForScreenShot <EditPeakScoringModelDlg.ModelTab>("Edit Peak Scoring Model form with second best", 15);

            OkDialog(editDlgNew, editDlgNew.CancelDialog);
            OkDialog(editListLibrary, editListLibrary.OkDialog);

            // Apply the model to reintegrate peaks
            RunUI(() =>
            {
                reintegrateDlgNew.ComboPeakScoringModelSelected = "test1";
                reintegrateDlgNew.ReintegrateAll  = true;
                reintegrateDlgNew.OverwriteManual = true;
            });
            PauseForScreenShot <ReintegrateDlg>("Reintegrate form", 16);

            OkDialog(reintegrateDlgNew, reintegrateDlgNew.OkDialog);
            RunUI(() =>
            {
                var nodeGroup = SkylineWindow.DocumentUI.PeptideTransitionGroups.ToArray()[70];
                Assert.AreEqual(nodeGroup.TransitionGroup.Peptide.Sequence, peptideSeqHighlight);
                var chromGroupInfo = nodeGroup.ChromInfos.ToList()[0];
                Assert.IsNotNull(chromGroupInfo.RetentionTime);
                Assert.AreEqual(18.0, chromGroupInfo.RetentionTime.Value, 0.1);
            });
            FindNode(peptideSeqHighlight);
            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile corrected peak at 18.0", 17);

            // Reintegrate slightly differently, with a q value cutoff
            var reintegrateDlgQ = ShowDialog <ReintegrateDlg>(SkylineWindow.ShowReintegrateDialog);

            RunUI(() =>
            {
                reintegrateDlgQ.ReintegrateAll  = false;
                reintegrateDlgQ.Cutoff          = 0.001;
                reintegrateDlgQ.OverwriteManual = true;
            });
            OkDialog(reintegrateDlgQ, reintegrateDlgQ.OkDialog);
            PauseForScreenShot("Targets view with some null peaks clipped from main window", 17);
            PauseForScreenShot <GraphChromatogram>("Chromatogram graph metafile with no picked peak", 18);

            RestoreViewOnScreen(14);
            FindNode((622.3086).ToString(CultureInfo.CurrentCulture) + "++");
            PauseForScreenShot("Main window with interference on transition", 19);

            // Export the mProphet features
            var mProphetExportDlg = ShowDialog <MProphetFeaturesDlg>(SkylineWindow.ShowMProphetFeaturesDialog);

            RunUI(() => mProphetExportDlg.BestScoresOnly = true);
            PauseForScreenShot <MProphetFeaturesDlg>("Export mProphet Features form", 20);

            // TODO: actually write the features here using WriteFeatures
            OkDialog(mProphetExportDlg, mProphetExportDlg.CancelDialog);

            // Export a report
            string       pathReport      = GetTestPath("qValues_Exported_report.csv");
            const string qvalueHeader    = "annotation_QValue";
            string       reportName      = Resources.ReportSpecList_GetDefaults_Peptide_RT_Results;
            var          reportExportDlg = ShowDialog <ExportLiveReportDlg>(SkylineWindow.ShowExportReportDialog);
            var          manageViewsForm = ShowDialog <ManageViewsForm>(reportExportDlg.EditList);

            RunUI(() => manageViewsForm.SelectView(reportName));
            PauseForScreenShot <ManageViewsForm>("Edit Reports form", 21);

            var customizeViewDlg = ShowDialog <ViewEditor>(manageViewsForm.EditView);

            PauseForScreenShot <ViewEditor.ChooseColumnsView>("Edit Report form", 22);

            RunUI(() => customizeViewDlg.ChooseColumnsTab.AddColumn(PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.Results!*.Value")
                                                                    .Property(AnnotationDef.ANNOTATION_PREFIX + qvalueHeader)));
            PauseForScreenShot <ViewEditor.ChooseColumnsView>("Edit Report form with selected columns", 23);

            OkDialog(customizeViewDlg, customizeViewDlg.OkDialog);
            OkDialog(manageViewsForm, manageViewsForm.Close);
            RunUI(() => reportExportDlg.ReportName = reportName);
            OkDialog(reportExportDlg, () => reportExportDlg.OkDialog(pathReport, TextUtil.CsvSeparator));

            Assert.IsTrue(File.Exists(pathReport));
            using (var reader = new StreamReader(pathReport))
            {
                string line = reader.ReadLine();
                Assert.IsNotNull(line);
                var       fieldHeaders      = line.Split(TextUtil.CsvSeparator);
                const int qvalueColumnIndex = 6;
                Assert.AreEqual(qvalueColumnIndex + 1, fieldHeaders.Length);
                Assert.AreEqual(qvalueHeader, fieldHeaders[qvalueColumnIndex]);
                int qvalueCount = 0;
                while ((line = reader.ReadLine()) != null)
                {
                    var    fields = line.Split(TextUtil.CsvSeparator);
                    double qvalue;
                    if (double.TryParse(fields[qvalueColumnIndex], out qvalue))
                    {
                        qvalueCount++;
                    }
                }
                Assert.AreEqual(290, qvalueCount); // PrecursorResults field means 29 peptides * 5 replicates * 2 label types
            }

            // Open OpenSWATH gold standard dataset
            RunUI(() => SkylineWindow.OpenFile(GetTestPath("AQUA4_Human_picked_napedro2-mod2.sky"))); // Not L10N
            WaitForDocumentLoaded();

            // Perform re-score of DIA data
            var manageResults = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);

            PauseForScreenShot <ManageResultsDlg>("Manage Results form", 25);

            var rescoreResultsDlg = ShowDialog <RescoreResultsDlg>(manageResults.Rescore);

            PauseForScreenShot <RescoreResultsDlg>("Re-score Results form", 25);

            RunUI(() => rescoreResultsDlg.Rescore(false));
            WaitForCondition(10 * 60 * 1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);    // 10 minutes (usually needs less, but code coverage analysis can be slow)
            WaitForClosedForm(rescoreResultsDlg);
            WaitForClosedForm(manageResults);
            WaitForConditionUI(() => FindOpenForm <AllChromatogramsGraph>() == null);
            WaitForDocumentLoaded();

            // Train the peak scoring model for the DIA dataset
            var reintegrateDlgDia = ShowDialog <ReintegrateDlg>(SkylineWindow.ShowReintegrateDialog);

            // Open the previous scoring model for use with the DIA dataset
            var editListDia = ShowDialog <EditListDlg <SettingsListBase <PeakScoringModelSpec>, PeakScoringModelSpec> >(
                reintegrateDlgDia.EditPeakScoringModel);

            RunUI(() => editListDia.SelectItem("test1"));
            var editDlgFromSrm = ShowDialog <EditPeakScoringModelDlg>(editListDia.EditItem);

            PauseForScreenShot <EditPeakScoringModelDlg.ModelTab>("Edit Peak Scoring Model form SRM model applied to DIA data", 26);
            RunUI(() =>
            {
                ValidateCoefficients(editDlgFromSrm, 0);

                for (int j = 0; j < editDlgFromSrm.PeakCalculatorsGrid.Items.Count; ++j)
                {
                    Assert.AreEqual(editDlgFromSrm.PeakCalculatorsGrid.Items[j].PercentContribution, null);
                }
                int i = 0;
                Assert.IsTrue(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsFalse(editDlgFromSrm.IsActiveCell(i++, 0));
//                    Assert.IsFalse(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsFalse(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsTrue(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsTrue(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsTrue(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsTrue(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsFalse(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsFalse(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsFalse(editDlgFromSrm.IsActiveCell(i++, 0));
                Assert.IsFalse(editDlgFromSrm.IsActiveCell(i, 0));
            });

            OkDialog(editDlgFromSrm, editDlgFromSrm.CancelDialog);
            OkDialog(editListDia, editListDia.CancelDialog);

            // Train a new model for the DIA dataset
            var editDlgDia = ShowDialog <EditPeakScoringModelDlg>(reintegrateDlgDia.AddPeakScoringModel);

            RunUI(() =>
            {
                editDlgDia.UsesDecoys     = false;
                editDlgDia.UsesSecondBest = true;
                editDlgDia.TrainModel();
            });

            RunUI(() => ValidateCoefficients(editDlgDia, 1));

            PauseForScreenShot <EditPeakScoringModelDlg.ModelTab>("Edit Peak Scoring Model form DIA peak scoring dialog with second best", 27);

            RunUI(() =>
            {
                editDlgDia.SelectedGraphTab = 1;
                editDlgDia.PeakCalculatorsGrid.SelectRow(2);
                editDlgDia.IsFindButtonVisible = true;
                editDlgDia.FindMissingValues(2);        // Retention times
                editDlgDia.PeakScoringModelName = "testDIA";
            });
            OkDialog(editDlgDia, editDlgDia.OkDialog);
            RunUI(() =>
            {
                reintegrateDlgDia.ReintegrateAll  = true;
                reintegrateDlgDia.OverwriteManual = true;
            });
            OkDialog(reintegrateDlgDia, reintegrateDlgDia.OkDialog);

            findResultsForm = FormUtil.OpenForms.OfType <FindResultsForm>().FirstOrDefault();
            Assert.IsNotNull(findResultsForm);
            Assert.AreEqual(34, findResultsForm.ItemCount);
        }
Exemple #16
0
        protected override void DoTest()
        {
            // Inserting a Transition List, p. 2
            {
                var doc = SkylineWindow.Document;

                var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);
                RunUI(() =>
                {
                    pasteDlg.IsMolecule = false;  // Default peptide view
                    pasteDlg.Size       = new Size(800, 275);
                });
                PauseForScreenShot <PasteDlg>("Paste Dialog in peptide mode", 2);

                RunUI(() =>
                {
                    pasteDlg.IsMolecule = true;
                    pasteDlg.SetSmallMoleculeColumns(null);  // Default columns
                });
                PauseForScreenShot <PasteDlg>("Paste Dialog in small molecule mode, default columns - show Columns checklist", 3);


                var columnsOrdered = new[]
                {
                    // Molecule List Name,Precursor Name,Precursor Formula,Precursor Charge,Precursor RT,Precursor CE,Product m/z,Product Charge, label type
                    SmallMoleculeTransitionListColumnHeaders.moleculeGroup,
                    SmallMoleculeTransitionListColumnHeaders.namePrecursor,
                    SmallMoleculeTransitionListColumnHeaders.formulaPrecursor,
                    SmallMoleculeTransitionListColumnHeaders.adductPrecursor,
                    SmallMoleculeTransitionListColumnHeaders.chargePrecursor,
                    SmallMoleculeTransitionListColumnHeaders.rtPrecursor,
                    SmallMoleculeTransitionListColumnHeaders.cePrecursor,
                    SmallMoleculeTransitionListColumnHeaders.mzProduct,
                    SmallMoleculeTransitionListColumnHeaders.chargeProduct,
                    SmallMoleculeTransitionListColumnHeaders.labelType
                }.ToList();
                if (_inferredLabels)
                {
                    columnsOrdered.Remove(SmallMoleculeTransitionListColumnHeaders.labelType);
                }
                RunUI(() => { pasteDlg.SetSmallMoleculeColumns(columnsOrdered); });
                WaitForConditionUI(() => pasteDlg.GetUsableColumnCount() == columnsOrdered.Count);
                PauseForScreenShot <PasteDlg>("Paste Dialog with selected and ordered columns", 4);

                SetCsvFileClipboardText(GetTestPath("SMTutorial_TransitionList.csv"), true);
                RunUI(pasteDlg.PasteTransitions);
                RunUI(pasteDlg.ValidateCells);
                PauseForScreenShot <PasteDlg>("Paste Dialog with validated contents", 5);

                OkDialog(pasteDlg, pasteDlg.OkDialog);
                var docTargets = WaitForDocumentChange(doc);

                AssertEx.IsDocumentState(docTargets, null, 6, 12, 19, 21);
                Assert.IsFalse(docTargets.MoleculeTransitions.Any(t => t.Transition.IsPrecursor()));

                RunUI(() =>
                {
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.Size = new Size(957, 654);
                });
                RestoreViewOnScreen(5);
                PauseForScreenShot <SkylineWindow>("Skyline with small molecule targets", 5);

                RunUI(() => SkylineWindow.SaveDocument(GetTestPath("Amino Acid Metabolism.sky")));

                using (new WaitDocumentChange(null, true))
                {
                    var importResultsDlg1     = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                    var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets =
                                                                                      importResultsDlg1.GetDataSourcePathsFile(null));
                    RunUI(() =>
                    {
                        openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(GetTestPath());
                        openDataSourceDialog1.SelectAllFileType(ExtWatersRaw);
                    });
                    PauseForScreenShot <ImportResultsSamplesDlg>("Import Results Files form", 6);
                    OkDialog(openDataSourceDialog1, openDataSourceDialog1.Open);

                    var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg1.OkDialog);
                    OkDialog(importResultsNameDlg, importResultsNameDlg.NoDialog);
                }

                SelectNode(SrmDocument.Level.MoleculeGroups, 0);

                PauseForScreenShot <SkylineWindow>("Skyline window multi-target graph", 8);

                var docResults = SkylineWindow.Document;

                var expectedTransCount = new Dictionary <string, int[]>
                {
                    // transition groups, heavy transition groups, tranistions, heavy transitions
                    { "ID15656_01_WAA263_3976_020415", new[] { 12, 7, 13, 8 } },
                    { "ID15658_01_WAA263_3976_020415", new[] { 12, 6, 13, 7 } },
                    { "ID15659_01_WAA263_3976_020415", new[] { 12, 7, 13, 8 } },
                    { "ID15661_01_WAA263_3976_020415", new[] { 12, 7, 13, 8 } },
                    { "ID15662_01_WAA263_3976_020415", new[] { 12, 7, 13, 8 } },
                    { "ID15663_01_WAA263_3976_020415", new[] { 11, 7, 12, 8 } },
                    { "ID15664_01_WAA263_3976_020415", new[] { 11, 6, 12, 7 } },
                    { "ID15739_01_WAA263_3976_020415", new[] { 10, 6, 10, 7 } },
                    { "ID15740_01_WAA263_3976_020415", new[] { 12, 6, 12, 7 } },
                    { "ID15740_02_WAA263_3976_020415", new[] { 11, 5, 11, 6 } },
                    { "ID15740_04_WAA263_3976_020415", new[] { 12, 6, 12, 7 } },
                    { "ID15741_01_WAA263_3976_020415", new[] { 12, 7, 13, 8 } },
                    { "ID15741_02_WAA263_3976_020415", new[] { 12, 6, 13, 7 } }
                };
                var msg = "";
                foreach (var chromatogramSet in docResults.Settings.MeasuredResults.Chromatograms)
                {
                    int[] transitions;
                    if (!expectedTransCount.TryGetValue(chromatogramSet.Name, out transitions))
                    {
                        transitions = new[] { 12, 7, 13, 8 }
                    }
                    ;                                       // Most have this value
                    try
                    {
                        AssertResult.IsDocumentResultsState(docResults, chromatogramSet.Name, 12, transitions[0], transitions[1], transitions[2], transitions[3]);
                    }
                    catch (Exception x)
                    {
                        msg = TextUtil.LineSeparate(msg, x.Message);
                    }
                }
                if (!string.IsNullOrEmpty(msg))
                {
                    Assert.IsTrue(string.IsNullOrEmpty(msg), msg);
                }
                RestoreViewOnScreen(9);
                PauseForScreenShot <SkylineWindow>("Skyline window multi-replicate layout", 9);
            }
        }
    }
Exemple #17
0
        protected override void DoTest()
        {
            // Skyline Targeted Method Refinement

            var folderMethodRefine = UseRawFiles ? "MethodRefine" : "MethodRefineMzml"; // Not L10N

            // Results Data, p. 2
            var doc = SkylineWindow.Document;

            RunUI(() => SkylineWindow.OpenFile(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\WormUnrefined.sky"))); // Not L10N
            WaitForDocumentChangeLoaded(doc);
            RunUI(() =>
            {
                // Adjust font sizes for better screen shots
                Settings.Default.ChromatogramFontSize = 14;
                Settings.Default.SpectrumFontSize     = 14;
                SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);

                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0];
                SkylineWindow.AutoZoomBestPeak();   // TODO: Mention this in the tutorial
                SkylineWindow.Size = new Size(1160, 660);

                Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode.Text, "YLGAYLLATLGGNASPSAQDVLK"); // Not L10N
            });
            PauseForScreenShot("Main window", 2);

            // TODO: Update tutorial to view b-ions.
            RunUI(() => SkylineWindow.GraphSpectrumSettings.ShowBIons = true);

            // Unrefined Methods, p. 3
            {
                var exportDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() =>
                {
                    exportDlg.ExportStrategy = ExportStrategy.Buckets;
                    exportDlg.MethodType     = ExportMethodType.Standard;
                    exportDlg.OptimizeType   = ExportOptimize.NONE;
                    exportDlg.MaxTransitions = 59;
                });
                PauseForScreenShot("Export Transition List form", 3);                                                       // Not L10N
                OkDialog(exportDlg, () => exportDlg.OkDialog(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm"))); // Not L10N
            }

            for (int i = 1; i < 10; i++)
            {
                Assert.IsTrue(File.Exists(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm_000" + i + TextUtil.EXT_CSV))); // Not L10N
            }
            for (int i = 10; i < 40; i++)
            {
                Assert.IsTrue(File.Exists(TestFilesDirs[1].GetTestPath(folderMethodRefine + @"\worm_00" + i + TextUtil.EXT_CSV))); // Not L10N
            }

            // Importing Multiple Injection Data, p. 4

            Assert.IsTrue(SkylineWindow.Document.Settings.HasResults);
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, manageResultsDlg =>
            {
                manageResultsDlg.RemoveReplicates();
                Assert.AreEqual(manageResultsDlg.Chromatograms.ToArray().Length, 0);
                manageResultsDlg.OkDialog();
            });

            RunUI(() => SkylineWindow.SaveDocument());
            Assert.IsFalse(SkylineWindow.Document.Settings.HasResults);

            const string replicateName = "Unrefined"; // Not L10N

            RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg =>
            {
                importResultsDlg.RadioAddNewChecked = true;
                var namedPathSets = DataSourceUtil.GetDataSourcesInSubdirs(TestFilesDirs[0].FullPath).ToArray();
                importResultsDlg.NamedPathSets =
                    new[] { new KeyValuePair <string, MsDataFileUri[]>(replicateName, namedPathSets[0].Value.Take(15).ToArray()) };
                importResultsDlg.OkDialog();
            });
            WaitForOpenForm <AllChromatogramsGraph>();                                                        // To make the AllChromatogramsGraph form accessible to the SkylineTester forms tab
            PauseForScreenShot <AllChromatogramsGraph>("Loading Chromatograms: Take screenshot at about 25% loaded...", 5);
            WaitForCondition(15 * 60 * 1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes

            Assert.IsTrue(SkylineWindow.Document.Settings.HasResults);
            Assert.AreEqual(15, SkylineWindow.Document.Settings.MeasuredResults.CachedFilePaths.ToArray().Length);

            RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg =>
            {
                importResultsDlg.RadioAddExistingChecked = true;
                var namedPathSets = DataSourceUtil.GetDataSourcesInSubdirs(TestFilesDirs[0].FullPath).ToArray();
                importResultsDlg.NamedPathSets =
                    new[] { new KeyValuePair <string, MsDataFileUri[]>(replicateName, namedPathSets[0].Value.Skip(15).ToArray()) };
                importResultsDlg.OkDialog();
            });
            WaitForCondition(20 * 60 * 1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);  // 15 minutes

            Assert.AreEqual(39, SkylineWindow.Document.Settings.MeasuredResults.CachedFilePaths.ToArray().Length);

            RunUI(SkylineWindow.AutoZoomNone);
            RestoreViewOnScreen(7);
            PauseForScreenShot("Chromatogram graph metafile", 7);

            // Simple Manual Refinement, p. 6
            int startingNodeCount = SkylineWindow.SequenceTree.Nodes[0].GetNodeCount(false);

            Assert.AreEqual("YLGAYLLATLGGNASPSAQDVLK", SkylineWindow.SequenceTree.Nodes[0].Nodes[0].Text); // Not L10N

            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0];
                SkylineWindow.AutoZoomNone();
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.EditDelete();
                SkylineWindow.ShowRTLinearRegressionGraph();
            });
            Assert.AreEqual(SkylineWindow.SequenceTree.Nodes[0].GetNodeCount(false), startingNodeCount - 1);
            Assert.AreEqual("VLEAGGLDCDMENANSVVDALK", SkylineWindow.SequenceTree.Nodes[0].Nodes[0].Text); // Not L10N
            PauseForScreenShot("Retention Times Regression plot metafile", 8);

            RunDlg <RegressionRTThresholdDlg>(SkylineWindow.ShowRegressionRTThresholdDlg, rtThresholdDlg =>
            {
                rtThresholdDlg.Threshold = 0.95;
                rtThresholdDlg.OkDialog();
            });
            WaitForConditionUI(() => SkylineWindow.RTGraphController.RegressionRefined != null);
            WaitForGraphs();
            PauseForScreenShot("Retention Times Regression plot metafile with 0.95 threshold", 9); // Not L10N

            TestRTResidualsSwitch();

            RunDlg <EditRTDlg>(SkylineWindow.CreateRegression, editRTDlg => editRTDlg.OkDialog());

            RunUI(() => SkylineWindow.ShowGraphRetentionTime(false));
            RunUI(SkylineWindow.AutoZoomNone);
            PauseForScreenShot("Chromatogram graph metafile zoomed out", 10); // Not L10N

            // Missing Data, p. 10
            RunUI(() =>
            {
                SkylineWindow.RTGraphController.SelectPeptide(SkylineWindow.Document.GetPathTo(1, 163));
                Assert.AreEqual("YLAEVASEDR", SkylineWindow.SequenceTree.SelectedNode.Text);     // Not L10N
            });
            RestoreViewOnScreen(11);
            //  Restoring the view changes the selection
            RunUI(SkylineWindow.CollapsePeptides);
            FindNode("YLAEVASEDR");
            RunUI(() => SkylineWindow.SequenceTree.TopNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[153]);

            PauseForScreenShot("Targets view clipped from the main window", 11);

            RunUI(() =>
            {
                var nodePep = (PeptideDocNode)((SrmTreeNode)SkylineWindow.SequenceTree.SelectedNode).Model;
                Assert.AreEqual(null,
                                nodePep.GetPeakCountRatio(
                                    SkylineWindow.SequenceTree.GetDisplayResultsIndex(nodePep)));
                SkylineWindow.SequenceTree.SelectedPath = SkylineWindow.Document.GetPathTo(1, 157);
                Assert.AreEqual("VTVVDDQSVILK", SkylineWindow.SequenceTree.SelectedNode.Text);
            });
            WaitForGraphs();
            RunUI(() =>
            {
                SkylineWindow.ActivateReplicate("Unrefined");
                SkylineWindow.AutoZoomNone();
            });
            PauseForScreenShot("Unrefined chromatogram graph page clipped from main window", 12); // Not L10N

//            foreach (var peptideDocNode in SkylineWindow.Document.Peptides)
//            {
//                var nodeGroup = ((TransitionGroupDocNode)peptideDocNode.Children[0]);
//                Console.WriteLine("{0} - {1}", peptideDocNode.Peptide.Sequence,
//                    nodeGroup.GetDisplayText(SkylineWindow.SequenceTree.GetDisplaySettings(peptideDocNode)));
//            }
//            Console.WriteLine("---------------------------------");

            RunUI(() =>
            {
                var graphChrom = SkylineWindow.GetGraphChrom("Unrefined"); // Not L10N
                Assert.AreEqual(2, graphChrom.Files.Count);
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0];

                // Picking Measurable Peptides and Transitions, p. 12
                SkylineWindow.ExpandPeptides();
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0];
            });

            RunUI(SkylineWindow.AutoZoomBestPeak);
            RestoreViewOnScreen(13);
            RunUI(() => SkylineWindow.ShowGraphSpectrum(false));
            PauseForScreenShot("Targets view clipped from the main window and chromatogram graph metafile", 13);

            RunUI(() => SkylineWindow.ShowGraphSpectrum(true));
            PauseForScreenShot("Library Match plot metafile", 14);

            RunUI(() =>
            {
                SkylineWindow.ShowGraphSpectrum(false);
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Transitions, 0);
                SkylineWindow.SelectedNode.Expand();
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0);
            });

            PauseForScreenShot("Targetes view clipped from the main window", 14); // Not L10N

            RunUI(() =>
            {
                double dotpExpect = Math.Round(Statistics.AngleToNormalizedContrastAngle(0.78), 2);  // 0.57
                AssertEx.Contains(SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Text,
                                  dotpExpect.ToString(LocalizationHelper.CurrentCulture));
                SkylineWindow.EditDelete();

                dotpExpect = 0.34; // Math.Round(Statistics.AngleToNormalizedContrastAngle(0.633), 2);  // 0.44
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0];
                AssertEx.Contains(SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Text,
                                  dotpExpect.ToString(LocalizationHelper.CurrentCulture));
                SkylineWindow.EditDelete();

                PeptideTreeNode nodePep;
                for (int i = 0; i < 2; i++)
                {
                    nodePep = (PeptideTreeNode)SkylineWindow.SequenceTree.Nodes[0].Nodes[i];
                    nodePep.ExpandAll();
                    foreach (TransitionTreeNode nodeTran in nodePep.Nodes[0].Nodes)
                    {
                        TransitionDocNode nodeTranDoc = (TransitionDocNode)nodeTran.Model;
                        Assert.AreEqual((int)SequenceTree.StateImageId.peak,
                                        TransitionTreeNode.GetPeakImageIndex(nodeTranDoc,
                                                                             (PeptideDocNode)nodePep.Model,
                                                                             SkylineWindow.SequenceTree));
                        var resultsIndex = SkylineWindow.SequenceTree.GetDisplayResultsIndex(nodePep);
                        var rank         = nodeTranDoc.GetPeakRank(resultsIndex);
                        if (rank == null || rank > 3)
                        {
                            SkylineWindow.SequenceTree.SelectedNode = nodeTran;
                        }
                        SkylineWindow.SequenceTree.KeysOverride = Keys.Control;
                    }
                }
                nodePep = (PeptideTreeNode)SkylineWindow.SequenceTree.Nodes[0].Nodes[2];
                nodePep.ExpandAll();
                foreach (TransitionTreeNode nodeTran in nodePep.Nodes[0].Nodes)
                {
                    TransitionDocNode nodeTranDoc = (TransitionDocNode)nodeTran.Model;
                    Assert.AreEqual((int)SequenceTree.StateImageId.peak,
                                    TransitionTreeNode.GetPeakImageIndex(nodeTranDoc,
                                                                         (PeptideDocNode)nodePep.Model,
                                                                         SkylineWindow.SequenceTree));
                    var name = ((TransitionDocNode)nodeTran.Model).FragmentIonName;
                    if (!(name == "y11" || name == "y13" || name == "y14")) // Not L10N
                    {
                        SkylineWindow.SequenceTree.SelectedNode = nodeTran;
                    }
                    SkylineWindow.SequenceTree.KeysOverride = Keys.Control;
                }
                SkylineWindow.SequenceTree.KeysOverride = Keys.None;
                SkylineWindow.EditDelete();
                for (int i = 0; i < 3; i++)
                {
                    Assert.IsTrue(SkylineWindow.SequenceTree.Nodes[0].Nodes[i].Nodes[0].Nodes.Count == 3);
                }
                SkylineWindow.AutoZoomNone();

                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Transitions, 5);
                SkylineWindow.Size         = new Size(722, 449);
            });

            RunUI(SkylineWindow.AutoZoomBestPeak);
            RestoreViewOnScreen(15);
            PauseForScreenShot("Targetes view clipped from main window and chromatogram graph metafile", 15);

            // Automated Refinement, p. 16
            RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, refineDlg =>
            {
                refineDlg.MaxTransitionPeakRank = 3;
                refineDlg.PreferLargerIons      = true;
                refineDlg.RemoveMissingResults  = true;
                refineDlg.RTRegressionThreshold = 0.95;
                refineDlg.DotProductThreshold   = Statistics.AngleToNormalizedContrastAngle(0.95);  // Convert from original cos(angle) dot-product
                refineDlg.OkDialog();
            });
            WaitForCondition(() => SkylineWindow.Document.PeptideCount < 73);
//            foreach (var peptideDocNode in SkylineWindow.Document.Peptides)
//            {
//                var nodeGroup = ((TransitionGroupDocNode) peptideDocNode.Children[0]);
//                Console.WriteLine("{0} - {1}", peptideDocNode.Peptide.Sequence,
//                    nodeGroup.GetDisplayText(SkylineWindow.SequenceTree.GetDisplaySettings(peptideDocNode)));
//            }
            RunUI(() =>
            {
                Assert.AreEqual(72, SkylineWindow.Document.PeptideCount);
                Assert.AreEqual(216, SkylineWindow.Document.PeptideTransitionCount);
                SkylineWindow.CollapsePeptides();
                SkylineWindow.Undo();
            });
            RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, refineDlg =>
            {
                refineDlg.MaxTransitionPeakRank = 6;
                refineDlg.RemoveMissingResults  = true;
                refineDlg.RTRegressionThreshold = 0.90;
                refineDlg.DotProductThreshold   = Statistics.AngleToNormalizedContrastAngle(0.90);  // Convert from original cos(angle) dot-product
                refineDlg.OkDialog();
            });

            WaitForCondition(() => SkylineWindow.Document.PeptideCount < 120);
            RunUI(() =>
            {
                Assert.AreEqual(113, SkylineWindow.Document.PeptideCount);

                // Scheduling for Efficient Acquisition, p. 17
                SkylineWindow.Undo();
            });

            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, mResults =>
            {
                Assert.AreEqual(1, mResults.Chromatograms.Count());

                mResults.SelectedChromatograms =
                    SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Where(
                        set => Equals("Unrefined", set.Name)); // Not L10N

                mResults.RemoveReplicates();

                Assert.AreEqual(0, mResults.Chromatograms.Count());
                mResults.OkDialog();
            });

            var importResultsDlg0 = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);

            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedNode           = SkylineWindow.SequenceTree.Nodes[0];
                importResultsDlg0.RadioCreateMultipleMultiChecked = true;
                importResultsDlg0.NamedPathSets =
                    DataSourceUtil.GetDataSourcesInSubdirs(Path.Combine(TestFilesDirs[1].FullPath,
                                                                        Path.GetFileName(TestFilesDirs[1].FullPath) ??
                                                                        string.Empty)).ToArray();
            });
            var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg0.OkDialog);

            RunUI(importResultsNameDlg.NoDialog);
            WaitForCondition(15 * 60 * 1000, () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes

            var docCurrent = SkylineWindow.Document;

            RunUI(SkylineWindow.RemoveMissingResults);
            WaitForDocumentChange(docCurrent);
            Assert.AreEqual(86, SkylineWindow.Document.PeptideCount);
            Assert.AreEqual(255, SkylineWindow.Document.PeptideTransitionCount);

            TestRTResidualsSwitch();

            // Measuring Retention Times, p. 17
            {
                var exportDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() => exportDlg.MaxTransitions = 130);
                PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 18);
                OkDialog(exportDlg, () => exportDlg.OkDialog(TestFilesDirs[1].FullPath + "\\unscheduled")); // Not L10N
            }
            ///////////////////////

            // Reviewing Retention Time Runs, p. 18
            RunUI(() =>
            {
                SkylineWindow.ShowGraphSpectrum(false);
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.AutoZoomNone();
                SkylineWindow.AutoZoomBestPeak();
            });
            FindNode("FWEVISDEHGIQPDGTFK");

            RunUI(() => SkylineWindow.Size = new Size(1060, 550));
            RestoreViewOnScreen(19);
            PauseForScreenShot("Main window", 19); // Not L10N

            RunUI(() => SkylineWindow.ShowRTSchedulingGraph());
            WaitForCondition(() => SkylineWindow.GraphRetentionTime != null);

            PauseForScreenShot("Retention Times - Scheduling graph metafile", 19);

            RestoreViewOnScreen(20);

            // Creating a Scheduled Transition List, p. 20
            {
                var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                RunUI(() =>
                {
                    peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Prediction;
                    peptideSettingsUI.TimeWindow  = 4;
                });
                PauseForScreenShot <PeptideSettingsUI.PredictionTab>("Peptide Settings - Prediction tab", 21);
                OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog); // Not L10N
            }

            var exportMethodDlg1 = ShowDialog <ExportMethodDlg>(() =>
                                                                SkylineWindow.ShowExportMethodDialog(ExportFileType.List));

            RunUI(() =>
            {
                exportMethodDlg1.ExportStrategy = ExportStrategy.Single;
                exportMethodDlg1.MethodType     = ExportMethodType.Scheduled;
            });
            // TODO: Update tutorial to mention the scheduling options dialog.
            PauseForScreenShot("Export Transition List form", 22);                                              // Not L10N
            RunDlg <SchedulingOptionsDlg>(() =>
                                          exportMethodDlg1.OkDialog(TestFilesDirs[1].FullPath + "\\scheduled"), // Not L10N
                                          schedulingOptionsDlg => schedulingOptionsDlg.OkDialog());
            WaitForClosedForm(exportMethodDlg1);

            // Reviewing Multi-Replicate Data, p. 22
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, manageResultsDlg =>
            {
                manageResultsDlg.RemoveAllReplicates();
                manageResultsDlg.OkDialog();
            });
            var importResultsDlg1 = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);

            RunDlg <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets = importResultsDlg1.GetDataSourcePathsFile(null),
                                          openDataSourceDialog =>
            {
                openDataSourceDialog.SelectAllFileType(ExtThermoRaw);
                openDataSourceDialog.Open();
            });
            RunDlg <ImportResultsNameDlg>(importResultsDlg1.OkDialog, importResultsNameDlg0 =>
            {
                importResultsNameDlg0.Prefix = "Scheduled_"; // Not L10N
                importResultsNameDlg0.YesDialog();
            });
            WaitForCondition(15 * 60 * 1000, () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes
            Assert.AreEqual(5, SkylineWindow.GraphChromatograms.Count(graphChrom => !graphChrom.IsHidden));
            RunUI(() =>
            {
                SkylineWindow.RemoveMissingResults();
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.ShowGraphRetentionTime(false);
            });
            WaitForCondition(() => SkylineWindow.GraphRetentionTime.IsHidden);
            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].Nodes[0];
                SkylineWindow.ShowRTReplicateGraph();
                SkylineWindow.ShowPeakAreaReplicateComparison();
                SkylineWindow.CollapsePeptides();
                SkylineWindow.ShowChromatogramLegends(false);
                SkylineWindow.Size = new Size(1024, 768);
            });
            RestoreViewOnScreen(24);
            WaitForGraphs();
            PauseForScreenShot("Main window", 24); // Not L10N

            RunUI(() => SkylineWindow.SaveDocument());
            RunUI(SkylineWindow.NewDocument);
        }
Exemple #18
0
        protected override void DoTest()
        {
            // Inserting a Transition List, p. 2
            {
                var doc = SkylineWindow.Document;

                var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);
                RunUI(() =>
                {
                    pasteDlg.IsMolecule = false;  // Default peptide view
                    pasteDlg.Size       = new Size(800, 275);
                });
                PauseForScreenShot <PasteDlg>("Paste Dialog in peptide mode", 2);

                RunUI(() =>
                {
                    pasteDlg.IsMolecule = true;
                    pasteDlg.SetSmallMoleculeColumns(null);  // Default columns
                });
                PauseForScreenShot <PasteDlg>("Paste Dialog in small molecule mode, default columns", 3);

                if (IsPauseForScreenShots)
                {
                    var columnsRestricted = new[]
                    {
                        // Molecule List Name,Precursor Name,Precursor Formula,Product m/z,Precursor Charge,Product Charge,Precursor RT,Precursor CE
                        PasteDlg.SmallMoleculeTransitionListColumnHeaders.moleculeGroup,
                        PasteDlg.SmallMoleculeTransitionListColumnHeaders.namePrecursor,
                        PasteDlg.SmallMoleculeTransitionListColumnHeaders.formulaPrecursor,
                        PasteDlg.SmallMoleculeTransitionListColumnHeaders.mzProduct,
                        PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargePrecursor,
                        PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargeProduct,
                        PasteDlg.SmallMoleculeTransitionListColumnHeaders.rtPrecursor,
                        PasteDlg.SmallMoleculeTransitionListColumnHeaders.cePrecursor,
                    }.ToList();
                    RunUI(() =>
                    {
                        pasteDlg.SetSmallMoleculeColumns(columnsRestricted);
                        pasteDlg.Height = 339;
                    });
                    WaitForConditionUI(() => pasteDlg.GetUsableColumnCount() == columnsRestricted.Count);
                    PauseForScreenShot <PasteDlg>("Paste Dialog with selected columns - show Columns checklist", 4);
                }

                var columnsOrdered = new[]
                {
                    // Molecule List Name,Precursor Name,Precursor Formula,Precursor Charge,Precursor RT,Precursor CE,Product m/z,Product Charge
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.moleculeGroup,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.namePrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.formulaPrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargePrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.rtPrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.cePrecursor,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.mzProduct,
                    PasteDlg.SmallMoleculeTransitionListColumnHeaders.chargeProduct
                }.ToList();
                RunUI(() => { pasteDlg.SetSmallMoleculeColumns(columnsOrdered); });
                WaitForConditionUI(() => pasteDlg.GetUsableColumnCount() == columnsOrdered.Count);
                PauseForScreenShot <PasteDlg>("Paste Dialog with selected and ordered columns", 4);

                SetCsvFileClipboardText(GetTestPath("SMTutorial_TransitionList.csv"), true);
                RunUI(pasteDlg.PasteTransitions);
                RunUI(pasteDlg.ValidateCells);
                PauseForScreenShot <PasteDlg>("Paste Dialog with validated contents", 5);

                OkDialog(pasteDlg, pasteDlg.OkDialog);
                var docTargets = WaitForDocumentChange(doc);

                AssertEx.IsDocumentState(docTargets, null, 6, 19, 19, 21);
                Assert.IsFalse(docTargets.MoleculeTransitions.Any(t => t.Transition.IsPrecursor()));

                RunUI(() =>
                {
                    SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
                    SkylineWindow.Size = new Size(957, 654);
                });
                RestoreViewOnScreen(5);
                PauseForScreenShot <SkylineWindow>("Skyline with small molecule targets", 5);

                RunUI(() => SkylineWindow.SaveDocument(GetTestPath("Amino Acid Metabolism.sky")));

                var importResultsDlg1     = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.NamedPathSets =
                                                                                  importResultsDlg1.GetDataSourcePathsFile(null));
                RunUI(() =>
                {
                    openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(GetTestPath());
                    openDataSourceDialog1.SelectAllFileType(UseRawFiles
                        ? ExtensionTestContext.ExtWatersRaw
                        : ExtensionTestContext.ExtMzml);
                });
                PauseForScreenShot <ImportResultsSamplesDlg>("Import Results Files form", 6);
                OkDialog(openDataSourceDialog1, openDataSourceDialog1.Open);

                var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importResultsDlg1.OkDialog);
                OkDialog(importResultsNameDlg, importResultsNameDlg.NoDialog);

                WaitForCondition(() =>
                                 SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);

                SelectNode(SrmDocument.Level.MoleculeGroups, 0);

                PauseForScreenShot <SkylineWindow>("Skyline window multi-target graph", 8);

                var docResults         = SkylineWindow.Document;
                var expectedTransCount = new Dictionary <string, int>
                {
                    { "ID15655_01_WAA263_3976_020415", 21 },
                    { "ID15657_01_WAA263_3976_020415", 21 },
                    { "ID15658_01_WAA263_3976_020415", 21 },
                    { "ID15662_01_WAA263_3976_020415", 21 },
                    { "ID15740_02_WAA263_3976_020415", 19 },
                    { "ID15741_01_WAA263_3976_020415", 21 },
                };
                foreach (var chromatogramSet in docResults.Settings.MeasuredResults.Chromatograms)
                {
                    int trans;
                    if (!expectedTransCount.TryGetValue(chromatogramSet.Name, out trans))
                    {
                        trans = 20; // Most have this value
                    }
                    AssertResult.IsDocumentResultsState(docResults, chromatogramSet.Name, 19, 19, 0, trans, 0);
                }

                RestoreViewOnScreen(9);
                PauseForScreenShot <SkylineWindow>("Skyline window multi-replicate layout", 9);
            }
        }