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);
                }
            }
        }
예제 #2
0
        protected override void DoTest()
        {
            var folderAbsoluteQuant = UseRawFiles ? "AbsoluteQuant" : "AbsoluteQuantMzml";
            // Generating a Transition List, p. 4
            {
                var doc = SkylineWindow.Document;
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    // Predicition 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", 4);

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

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

            // Configuring Peptide settings p. 4
            PeptideSettingsUI peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() => peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Modifications);
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modification tab", 5);

            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", 5);
            RunUI(() => peptideSettingsUI.PickedHeavyMods = new[] { modHeavyK.Name });
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modification tab with mod added", 5);

            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);

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

                OkDialog(pasteDlg, pasteDlg.OkDialog);
            }

            RunUI(SkylineWindow.ExpandPrecursors);
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDir.GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            WaitForCondition(() => File.Exists(TestFilesDir.GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            PauseForScreenShot("Main window with Targets view", 6);

            // Exporting a transition list p. 6
            {
                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", 7);

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

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

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

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

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

            // Analyzing SRM Data from FOXN1-GST Sample p. 9
            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(AreaNormalizeToView.area_percent_view);
            });

            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);
            });
            PauseForScreenShot("Main window with Peak Areas, Retention Times and FOXN1-GST for light", 10);

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

            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0));
            WaitForGraphs();
            // Heavy normalization
            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_ratio_view));
            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", 11);

            // Peptide Quantitification Settings p. 11
            var          peptideSettingsUi = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            const string quantUnits        = "fmol/ul";

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

            // Specify analyte concentrations of external standards
            RunUI(() => 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 };

            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);
            }
            PauseForScreenShot("Document grid with concentrations filled in", 13);

            // View the calibration curve p. 13
            RunUI(() => SkylineWindow.ShowCalibrationForm());
            var calibrationForm = FindOpenForm <CalibrationForm>();

            PauseForScreenShot("View calibration curve", 14);

            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);
        }
예제 #3
0
파일: ViewMenu.cs 프로젝트: laeubisoft/pwiz
 private void arrangeTabbedMenuItem_Click(object sender, EventArgs e)
 {
     SkylineWindow.ArrangeGraphsTabbed();
 }
예제 #4
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).");
            }
        }
        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);
        }
        private void TofTest()
        {
            // Working wih High-Resolution Mass Spectra.

            // Import a new Document. High-Resolution Mass Spectra, working with TOF p22.
            string newDocumentFile = GetTestPath(@"TOF\BSA_Agilent.sky");

            WaitForCondition(() => File.Exists(newDocumentFile));
            RunUI(() => SkylineWindow.OpenFile(newDocumentFile));

            bool asSmallMolecules = AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.none;

            if (asSmallMolecules)
            {
                ConvertDocumentToSmallMolecules(AsSmallMoleculesTestMode);
            }
            var       docCalibrate1 = WaitForDocumentLoaded();
            const int pepCount1 = 5, preCount1 = 5, tranCount1 = 30;

            AssertEx.IsDocumentState(docCalibrate1, null, 1, pepCount1, preCount1, tranCount1);


            // Try to import a file to show it fails.
            ImportResultsDlg importResultsDlg3 = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);

            RunUI(() => importResultsDlg3.NamedPathSets = importResultsDlg3.GetDataSourcePathsFileReplicates(
                      new[] { MsDataFileUri.Parse(GetTestPath(@"TOF\6-BSA-500fmol" + ExtAgilentRaw)) }));
            var importProgress = ShowDialog <AllChromatogramsGraph>(importResultsDlg3.OkDialog);

            WaitForDocumentChangeLoaded(docCalibrate1);
            WaitForConditionUI(() => importProgress.Finished);
            string expectedErrorFormat = Resources.NoFullScanFilteringException_NoFullScanFilteringException_To_extract_chromatograms_from__0__full_scan_settings_must_be_enabled_;

            WaitForConditionUI(() => !string.IsNullOrEmpty(importProgress.Error), "Missing expected error text: " + expectedErrorFormat);
            RunUI(() => AssertEx.AreComparableStrings(expectedErrorFormat, importProgress.Error, 1));
            RunUI(() =>
            {
                importProgress.ClickClose();
                SkylineWindow.Undo();
            });

            var document = SkylineWindow.Document;

            // Fill out Transition Settings Menu
            int tranCount2 = (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only) ? (tranCount1 + preCount1 * 3) : (tranCount1 + preCount1); // No iostopes for mass-only document

            using (new CheckDocumentState(1, pepCount1, preCount1, tranCount2))
            {
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.FullScan;
                    transitionSettingsUI.PrecursorIsotopesCurrent = FullScanPrecursorIsotopes.Count;
                    transitionSettingsUI.PrecursorMassAnalyzer    = FullScanMassAnalyzerType.tof;
                    transitionSettingsUI.Peaks               = 3;
                    transitionSettingsUI.AcquisitionMethod   = FullScanAcquisitionMethod.Targeted;
                    transitionSettingsUI.ProductMassAnalyzer = FullScanMassAnalyzerType.tof;
                });
                PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Transition Settings - Full-Scan tab for TOF", 28);

                RunUI(() =>
                {
                    transitionSettingsUI.RetentionTimeFilterType = RetentionTimeFilterType.none;

                    transitionSettingsUI.SelectedTab    = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.FragmentTypes += ", p";
                });
                PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 29);

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }

            var docHighRes          = WaitForDocumentChange(document);
            var tranSettingsHighRes = docHighRes.Settings.TransitionSettings;

            Assert.AreEqual(FullScanPrecursorIsotopes.Count, tranSettingsHighRes.FullScan.PrecursorIsotopes);
            Assert.AreEqual(FullScanMassAnalyzerType.tof, tranSettingsHighRes.FullScan.PrecursorMassAnalyzer);
            Assert.AreEqual(FullScanAcquisitionMethod.Targeted, tranSettingsHighRes.FullScan.AcquisitionMethod);
            Assert.IsTrue(ArrayUtil.EqualsDeep(new[] { IonType.y, IonType.b, IonType.precursor },
                                               tranSettingsHighRes.Filter.IonTypes));
            RunUI(() => SkylineWindow.ExpandPrecursors());

            // Assert each peptide contains 3 precursors transitions (unless this is a masses-only small molecule doc).
            foreach (var nodeGroup in SkylineWindow.Document.MoleculeTransitionGroups)
            {
                for (int i = 0; i < nodeGroup.Children.Count; i++)
                {
                    var nodeTran = (TransitionDocNode)nodeGroup.Children[i];
                    if (i < ((AsSmallMoleculesTestMode == RefinementSettings.ConvertToSmallMoleculesMode.masses_only) ? 1 : 3))
                    {
                        Assert.AreEqual(IonType.precursor, nodeTran.Transition.IonType);
                    }
                    else
                    {
                        Assert.AreNotEqual(IonType.precursor, nodeTran.Transition.IonType);
                    }
                }
            }
            RestoreViewOnScreen(30);
            PauseForScreenShot("Targets View tree clipped from main window", 30);

            RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults, importResultsDlg2 =>
            {
                string[] filePaths =
                {
                    GetTestPath(@"TOF\6-BSA-500fmol" + ExtAgilentRaw)
                };
                importResultsDlg2.NamedPathSets = importResultsDlg2.GetDataSourcePathsFileReplicates(filePaths.Select(MsDataFileUri.Parse));
                importResultsDlg2.OkDialog();
            });
            WaitForDocumentChangeLoaded(docHighRes);
            if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only)
            {
                FindNode(asSmallMolecules ? "LVNELTEFAK" : "K.LVNELTEFAK.T [65, 74]");
            }
            else
            {
                FindNode(document.MoleculeTransitionGroups.First().CustomIon.DisplayName);
            }
            RunUI(() =>
            {
                SkylineWindow.CollapsePrecursors();
                SkylineWindow.AutoZoomNone();
                SkylineWindow.ShowGraphPeakArea(false);
                SkylineWindow.ShowProductTransitions();
            });

            RestoreViewOnScreen(31);
            RunUI(() => SkylineWindow.Width = 1013);
            PauseForScreenShot("Main window full gradient import of high concentration and Targets tree clipped", 31);

            {
                var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
                RunUI(() =>
                {
                    peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Prediction;
                    Assert.IsTrue(peptideSettingsUI.IsUseMeasuredRT);
                    Assert.AreEqual(2.0, peptideSettingsUI.TimeWindow);
                });

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

                OkDialog(peptideSettingsUI, peptideSettingsUI.CancelDialog);
            }

            using (new CheckDocumentState(1, pepCount1, preCount1, tranCount2))
            {
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.FullScan;
                    transitionSettingsUI.SetRetentionTimeFilter(RetentionTimeFilterType.scheduling_windows, 1);
                });

                PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Transition Settings - Full-Scan tab wtih scheduled extraction", 33);

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }

            var chooseSchedulingReplicateDlg = ShowDialog <ChooseSchedulingReplicatesDlg>(SkylineWindow.ImportResults);

            RunUI(() =>
            {
                // Make sure UI is up to date to avoid race condition
                chooseSchedulingReplicateDlg.UpdateUi();
                chooseSchedulingReplicateDlg.SelectOrDeselectAll(true);
            });
            RunDlg <ImportResultsDlg>(chooseSchedulingReplicateDlg.OkDialog, importResultsDlg2 =>
            {
                string[] filePaths =
                {
                    GetTestPath(@"TOF\1-BSA-50amol" + ExtAgilentRaw),
                    GetTestPath(@"TOF\2-BSA-100amol" + ExtAgilentRaw),
                    GetTestPath(@"TOF\3-BSA-1fmol" + ExtAgilentRaw),
                    GetTestPath(@"TOF\4-BSA-10fmol" + ExtAgilentRaw),
                    GetTestPath(@"TOF\5-BSA-100fmol" + ExtAgilentRaw),
                };
                importResultsDlg2.NamedPathSets = importResultsDlg2.GetDataSourcePathsFileReplicates(filePaths.Select(MsDataFileUri.Parse));
                importResultsDlg2.OkDialog();
            });
            //Give the Raw files some time to be processed.
            WaitForCondition(15 * 60 * 1000, () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes
            WaitForClosedAllChromatogramsGraph();
            RunUI(() => SkylineWindow.ShowGraphSpectrum(false));
            WaitForGraphs();
            TryWaitForConditionUI(() => SkylineWindow.GraphChromatograms.Count(graphChrom => !graphChrom.IsHidden) == 6);
            RunUI(() =>
            {
                Assert.IsFalse(SkylineWindow.IsGraphSpectrumVisible);
                var listGraphs = SkylineWindow.GraphChromatograms.Where(graphChrom => !graphChrom.IsHidden).ToList();
                if (listGraphs.Count != 6)
                {
                    string hiddenGraphs = string.Empty;
                    var listHidden      = SkylineWindow.GraphChromatograms.Where(graphChrom => graphChrom.IsHidden).ToList();
                    if (listHidden.Count != 0)
                    {
                        hiddenGraphs = TextUtil.LineSeparate(string.Empty, "Hidden:", TextUtil.LineSeparate(listHidden.Select(g => g.TabText)));
                    }
                    Assert.Fail(TextUtil.LineSeparate(string.Format("Expecting 6 visible graphs but found {0}", listGraphs.Count),
                                                      TextUtil.LineSeparate(listGraphs.Select(g => g.TabText)), hiddenGraphs));
                }
                var chromGraphs = SkylineWindow.GraphChromatograms.ToArray();
                Assert.AreEqual(6, chromGraphs.Length);
            });

            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg =>
            {
                for (int i = 0; i < 5; i++)
                {
                    dlg.MoveDown();
                }
                dlg.OkDialog();
            });
            RunDlg <ArrangeGraphsGroupedDlg>(SkylineWindow.ArrangeGraphsGrouped, dlg =>
            {
                dlg.Groups     = 6;
                dlg.GroupOrder = GroupGraphsOrder.Document;
                dlg.OkDialog();
            });
            WaitForGraphs();

            RunUI(() => SkylineWindow.Height = 768);
            PauseForScreenShot("Chromatogram graphs clipped from main window", 34);

            RunUI(() =>
            {
                var graphChrom6 = SkylineWindow.GetGraphChrom("6-BSA-500fmol");
                var graphChrom5 = SkylineWindow.GetGraphChrom("5-BSA-100fmol");
                var graphChrom4 = SkylineWindow.GetGraphChrom("4-BSA-10fmol");
                var graphChrom3 = SkylineWindow.GetGraphChrom("3-BSA-1fmol");
                var graphChrom2 = SkylineWindow.GetGraphChrom("2-BSA-100amol");
                var graphChrom1 = SkylineWindow.GetGraphChrom("1-BSA-50amol");
                Assert.AreEqual(13.3, graphChrom6.BestPeakTime ?? 0, 0.05);
                Assert.AreEqual(13.5, graphChrom5.BestPeakTime ?? 0, 0.05);
                Assert.AreEqual(13.6, graphChrom4.BestPeakTime ?? 0, 0.05);
                Assert.AreEqual(13.6, graphChrom3.BestPeakTime ?? 0, 0.05);
                Assert.AreEqual(13.6, graphChrom2.BestPeakTime ?? 0, 0.05);
                Assert.AreEqual(13.6, graphChrom1.BestPeakTime ?? 0, 0.05);
            });

            RunUI(SkylineWindow.AutoZoomBestPeak);
            WaitForGraphs();

            PauseForScreenShot("Chromatogram graphs clipped from main window zoomed", 35);

            RunUI(() =>
            {
                SkylineWindow.ShowPeakAreaReplicateComparison();
                SkylineWindow.ShowPeptideLogScale(true);
            });

            // p. 28
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas Replicate Comparison graph metafile", 36);
            WaitForDotProducts();
            RunUI(() =>
            {
                Assert.AreEqual((AsSmallMoleculesTestMode == RefinementSettings.ConvertToSmallMoleculesMode.none) ? 7 : 6, SkylineWindow.GraphPeakArea.Categories.Count());
                Assert.AreEqual(6, SkylineWindow.GraphPeakArea.CurveCount);
            });
            VerifyDotProducts(0.87, 0.67, 0.91, 0.90, 0.90, 0.90);

            RunUI(() =>
            {
                SkylineWindow.ShowAllTransitions();
                SkylineWindow.ShowSplitChromatogramGraph(false);
                SkylineWindow.ArrangeGraphsTabbed();
                SkylineWindow.ActivateReplicate("6-BSA-500fmol");
                SkylineWindow.Size = new Size(745, 545);
                SkylineWindow.ShowGraphPeakArea(false);
            });
            PauseForScreenShot("Chromatogram graph metafile for 500 fmol", 37);

            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(true);
                SkylineWindow.ShowPrecursorTransitions();
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.ActivateReplicate("4-BSA-10fmol");
            });

            WaitForDotProducts();
            RunUI(() =>
            {
                Assert.AreEqual(7, SkylineWindow.GraphPeakArea.Categories.Count());
                Assert.AreEqual((AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only) ? 3 : 1, SkylineWindow.GraphPeakArea.CurveCount);
            });
            VerifyDotProducts(0.99, 0.52, 0.98, 1.00, 1.00, 1.00);
            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(false);
                SkylineWindow.Size = new Size(1013, 768);
            });
            PauseForScreenShot("Main window", 38);
            RunUI(SkylineWindow.ShowPeakAreaReplicateComparison);
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas Replicate Comparison graph metafile", 39);

            RunUI(() => SkylineWindow.SaveDocument());
            WaitForConditionUI(() => !SkylineWindow.Dirty);
        }
        protected override void DoTest()
        {
            var folderAbsoluteQuant = UseRawFiles ? "AbsoluteQuant" : "AbsoluteQuantMzml";
            // Generating a Transition List, p. 4
            {
                var doc = SkylineWindow.Document;
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    // Predicition 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", 4);

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

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

            // Configuring Peptide settings p. 4
            PeptideSettingsUI peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() => peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Modifications);
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modification tab", 5);

            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", 5);
            RunUI(() => peptideSettingsUI.PickedHeavyMods = new[] { modHeavyK.Name });
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modification tab with mod added", 5);

            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);

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

                OkDialog(pasteDlg, pasteDlg.OkDialog);
            }

            RunUI(SkylineWindow.ExpandPrecursors);
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDir.GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            WaitForCondition(() => File.Exists(TestFilesDir.GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            PauseForScreenShot("Main window with Targets view", 6);

            // Exporting a transition list p. 6
            {
                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", 7);

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

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

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

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

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

            // Analyzing SRM Data from FOXN1-GST Sample p. 9
            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(AreaNormalizeToView.area_percent_view);
            });

            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);
            });
            PauseForScreenShot("Main window with Peak Areas, Retention Times and FOXN1-GST for light", 10);

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

            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0));
            WaitForGraphs();
            // Heavy normalization
            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_ratio_view));
            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", 11);
            const int columnsToAddCount = 4;
            var       columnSeparator   = TextUtil.CsvSeparator;
            // Generating a Calibration Curve p. 11
            var          exportLiveReportDlg = ShowDialog <ExportLiveReportDlg>(SkylineWindow.ShowExportReportDialog);
            var          editReportListDlg   = ShowDialog <ManageViewsForm>(exportLiveReportDlg.EditList);
            const string reportName          = "Peptide Ratio Results Test";
            var          columnsToAdd        = new[]
            {
                PropertyPath.Parse("Proteins!*.Peptides!*.Sequence"),
                PropertyPath.Parse("Proteins!*.Name"),
                PropertyPath.Parse("Replicates!*.Name"),
                PropertyPath.Parse("Proteins!*.Peptides!*.Results!*.Value.RatioToStandard"),
            };

            Assert.AreEqual(columnsToAddCount, columnsToAdd.Length);
            {
                var viewEditor = ShowDialog <ViewEditor>(editReportListDlg.AddView);
                RunUI(() =>
                {
                    viewEditor.ViewName = reportName;
                    foreach (var id in columnsToAdd)
                    {
                        Assert.IsTrue(viewEditor.ChooseColumnsTab.TrySelect(id), "Unable to select {0}", id);
                        viewEditor.ChooseColumnsTab.AddSelectedColumn();
                    }
                    Assert.AreEqual(columnsToAdd.Length, viewEditor.ChooseColumnsTab.ColumnCount);
                });
                // TODO: MultiViewProvider not yet supported in Common
                PauseForScreenShot <ViewEditor>("Edit Report form", 12);

                OkDialog(viewEditor, viewEditor.OkDialog);
            }

            RunUI(editReportListDlg.OkDialog);
            WaitForClosedForm(editReportListDlg);
            RunUI(() =>
            {
                exportLiveReportDlg.ReportName = reportName;
                exportLiveReportDlg.OkDialog(TestFilesDir.GetTestPath("Calibration.csv"), columnSeparator);
            });

            // Check if export file is correct.
            string filePath = TestFilesDir.GetTestPath("Calibration.csv");

            Assert.IsTrue(File.Exists(filePath));
            string[] lines = File.ReadAllLines(filePath);
            string[] line0 = lines[0].Split(columnSeparator);
            int      count = line0.Length;

            Assert.IsTrue(lines.Count() == SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Count + 1);
            Assert.AreEqual(columnsToAddCount, count);

            // Check export file data
            double ratio1 = Double.Parse(lines[1].Split(new[] { columnSeparator }, 4)[3]);
            double ratio2 = Double.Parse(lines[2].Split(new[] { columnSeparator }, 4)[3]);
            double ratio3 = Double.Parse(lines[3].Split(new[] { columnSeparator }, 4)[3]);
            double ratio4 = Double.Parse(lines[4].Split(new[] { columnSeparator }, 4)[3]);
            double ratio5 = Double.Parse(lines[5].Split(new[] { columnSeparator }, 4)[3]);
            double ratio6 = Double.Parse(lines[6].Split(new[] { columnSeparator }, 4)[3]);
            double ratio7 = Double.Parse(lines[7].Split(new[] { columnSeparator }, 4)[3]);
            double ratio8 = Double.Parse(lines[8].Split(new[] { columnSeparator }, 4)[3]);
            double ratio9 = Double.Parse(lines[9].Split(new[] { columnSeparator }, 4)[3]);

            Assert.AreEqual(21.4513, ratio1, 0.1);
            Assert.AreEqual(6.2568, ratio2, 0.1);
            Assert.AreEqual(2.0417, ratio3, 0.1);
            Assert.AreEqual(0.8244, ratio4, 0.1);
            Assert.AreEqual(0.2809, ratio5, 0.1);
            Assert.AreEqual(0.1156, ratio6, 0.1);
            Assert.AreEqual(0.0819, ratio7, 0.1);
            Assert.AreEqual(0.0248, ratio8, 0.1);
            Assert.AreEqual(0.7079, ratio9, 0.1);
            CheckReportCompatibility.CheckAll(SkylineWindow.Document);
        }