Esempio n. 1
0
        public KeyValuePair <string, MsDataFileUri[]>[] GetDataSourcePathsDir()
        {
            string initialDir = Path.GetDirectoryName(_documentSavedPath);

            using (FolderBrowserDialog dlg = new FolderBrowserDialog
            {
                Description = Resources.ImportResultsDlg_GetDataSourcePathsDir_Results_Directory,
                ShowNewFolderButton = false,
                SelectedPath = initialDir
            })
            {
                if (dlg.ShowDialog(this) != DialogResult.OK)
                {
                    return(null);
                }

                string dirRoot = dlg.SelectedPath;

                Settings.Default.SrmResultsDirectory = dirRoot;

                KeyValuePair <string, MsDataFileUri[]>[] namedPaths = DataSourceUtil.GetDataSourcesInSubdirs(dirRoot).ToArray();
                if (namedPaths.Length == 0)
                {
                    MessageBox.Show(this,
                                    string.Format(Resources.ImportResultsDlg_GetDataSourcePathsDir_No_results_found_in_the_folder__0__, dirRoot),
                                    Program.Name);
                    return(null);
                }
                return(namedPaths);
            }
        }
Esempio n. 2
0
        protected override void DoTest()
        {
            // Skyline Targeted Method Refinement

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

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

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

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

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

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

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

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

            // Importing Multiple Injection Data, p. 4

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

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

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

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

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

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

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

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

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

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

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

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

            TestRTResidualsSwitch();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                mResults.RemoveReplicates();

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

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

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

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

            var docCurrent = SkylineWindow.Document;

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

            TestRTResidualsSwitch();

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

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

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

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

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

            RestoreViewOnScreen(20);

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

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

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

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

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

            RunUI(() => SkylineWindow.SaveDocument());
            RunUI(SkylineWindow.NewDocument);
        }
        protected override void DoTest()
        {
            // Lest we get "To export a scheduled method, you must first choose a retention time predictor in Peptide Settings / Prediction, or import results for all peptides in the document."
            TestSmallMolecules = false;

            // Skyline Collision Energy Optimization
            RunUI(() => SkylineWindow.OpenFile(GetTestPath("CE_Vantage_15mTorr.sky"))); // Not L10N

            if (AsSmallMolecules)
            {
                var doc    = WaitForDocumentLoaded();
                var refine = new RefinementSettings();
                SkylineWindow.SetDocument(refine.ConvertToSmallMolecules(doc), doc);
            }

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

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

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

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

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

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

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

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

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

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

            CheckTransitionList(filePathTemplate, 1, 6);

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

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

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

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

            PauseForScreenShot("Main Skyline window", 5);

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

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

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

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

            CheckTransitionList(filePathTemplate1, 5, 9);

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

            CheckCEValues(filePath, 11);

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

            WaitForDocumentLoaded(15 * 60 * 1000); // 10 minutes

            if (AsSmallMolecules)
            {
                return;  // Too peptide-centric from here to end of test
            }

            FindNode("IHGFDLAAINLQR");
            RestoreViewOnScreen(8);

            PauseForScreenShot("Main Skyline window", 8);

            // p. 8
            // Not L10N
            RemovePeptide("EGIHAQQK");

            FindNode("IDALNENK");

            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_percent_view));

            PauseForScreenShot("Main Skyline window", 9);

            RunUI(SkylineWindow.EditDelete);

            RemovePeptide("LICDNTHITK");

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

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

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

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

            var graphDatas = graphRegression.RegressionGraphDatas.ToArray();

            Assert.AreEqual(2, graphDatas.Length);

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

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

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

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

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

            CheckTransitionList(filePathTemplate2, 1, 9);

            RunUI(() => SkylineWindow.SaveDocument());
            WaitForConditionUI(() => !SkylineWindow.Dirty);
        }