Ejemplo n.º 1
0
        protected void DoQualityControlSummaryReports()
        {
            // Quality Control Summary Reports, p. 18
            RunUI(() =>
            {
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath(@"CustomReports\study9pilot.sky")); // Not L10N
                SkylineWindow.ExpandPeptides();
            });
            RunUI(() => SkylineWindow.ShowDocumentGrid(true));
            RestoreViewOnScreen(19);
            var documentGridForm = FindOpenForm <DocumentGridForm>();
            var manageViewsForm  = ShowDialog <ManageViewsForm>(documentGridForm.ManageViews);

            RunUI(() =>
                  manageViewsForm.ImportViews(TestFilesDir.GetTestPath(@"CustomReports\Summary_stats.skyr"))
                  );
            PauseForScreenShot <ManageViewsForm>("Manage Reports form", 19);
            OkDialog(manageViewsForm, manageViewsForm.Close);
            PauseForScreenShot <DocumentGridForm>("Click the Reports dropdown and highlight 'Summary_stats'", 20);

            RunUI(() => documentGridForm.ChooseView("Summary Statistics"));
            WaitForConditionUI(() => documentGridForm.IsComplete);
            PauseForScreenShot <DocumentGridForm>("Document Grid with summary statistics", 20);

            var viewEditor = ShowDialog <ViewEditor>(documentGridForm.NavBar.CustomizeView);

            RunUI(() => Assert.AreEqual(11, viewEditor.ChooseColumnsTab.ColumnCount));
            RunUI(() =>
            {
                int indexCvTotalArea =
                    viewEditor.ChooseColumnsTab.ColumnNames.ToList().IndexOf(GetLocalizedCaption("CvTotalArea"));
                Assert.IsFalse(indexCvTotalArea < 0, "{0} < 0", indexCvTotalArea);
                viewEditor.ChooseColumnsTab.ActivateColumn(indexCvTotalArea);
            });
            PauseForScreenShot <ViewEditor.ChooseColumnsView>("Customize View form", 21);
            RunUI(() => viewEditor.TabControl.SelectTab(1));
            RunUI(() =>
            {
                viewEditor.FilterTab.AddSelectedColumn();
                Assert.IsTrue(viewEditor.FilterTab.SetFilterOperation(0, FilterOperations.OP_IS_GREATER_THAN));
                viewEditor.FilterTab.SetFilterOperand(0, .2.ToString(CultureInfo.CurrentCulture));
            });
            PauseForScreenShot <ViewEditor.FilterView>("Customize View - Filter tab", 22);
            OkDialog(viewEditor, viewEditor.OkDialog);
            PauseForScreenShot <DocumentGridForm>("Document Grid filtered", 23);
            RunUI(documentGridForm.Close);
            RunDlg <FindNodeDlg>(SkylineWindow.ShowFindNodeDlg, findPeptideDlg =>
            {
                findPeptideDlg.SearchString = "INDISHTQSVSAK"; // Not L10N
                findPeptideDlg.FindNext();
                findPeptideDlg.Close();
            });
            PauseForScreenShot("Highlight the menu item 'View>Peak Areas>Replicate Comparison'", 23);
            RunUI(SkylineWindow.ShowPeakAreaReplicateComparison);
            WaitForGraphs();
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas view", 24);
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
        protected override void DoTest()
        {
            LinkPdf = "http://www.srmcourse.ch/tutorials2014/Tutorial-1_Settings.pdf";

            //Tutorial 1
            string fastaFile = GetTestPath("Tutorial-1_Settings/TubercuList_v2-6.fasta.txt");

            WaitForCondition(() => File.Exists(fastaFile));
            var pepSettings = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() =>
            {
                SkylineWindow.Size              = new Size(1600, 800);
                pepSettings.SelectedTab         = PeptideSettingsUI.TABS.Digest;
                pepSettings.ComboEnzymeSelected = "Trypsin [KR | P]";
                pepSettings.MaxMissedCleavages  = 0;
            });

            var backProteomeDlg = ShowDialog <BuildBackgroundProteomeDlg>(pepSettings.AddBackgroundProteome);

            RunUI(() =>
            {
                backProteomeDlg.BackgroundProteomePath = GetTestPath("Skyline");
                backProteomeDlg.BackgroundProteomeName = "TubercuList_v2-6";
                backProteomeDlg.AddFastaFile(fastaFile);
                WaitForCondition(() => backProteomeDlg.StatusText.Length > 10);
                Assert.IsTrue(backProteomeDlg.StatusText.Contains("3982".ToString(CultureInfo.CurrentCulture)));
            });
            OkDialog(backProteomeDlg, backProteomeDlg.OkDialog);

            RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Prediction);

            RunUI(() =>
            {
                pepSettings.SelectedTab                = PeptideSettingsUI.TABS.Filter;
                pepSettings.TextMinLength              = 7;
                pepSettings.TextMaxLength              = 25;
                pepSettings.TextExcludeAAs             = 0;
                pepSettings.AutoSelectMatchingPeptides = true;
            });

            RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Library);
            var editListDlg =
                ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(pepSettings.EditLibraryList);
            var editLibraryDlg = ShowDialog <EditLibraryDlg>(editListDlg.AddItem);

            RunUI(() =>
            {
                editLibraryDlg.LibraryName = "Mtb_proteome_library";
                editLibraryDlg.LibraryPath = GetTestPath("Skyline\\Mtb_DirtyPeptides_QT_filtered_cons.sptxt");
            });
            OkDialog(editLibraryDlg, editLibraryDlg.OkDialog);
            OkDialog(editListDlg, editListDlg.OkDialog);
            RunUI(() => pepSettings.SetLibraryChecked(0, true));

            RunUI(() => { pepSettings.SelectedTab = PeptideSettingsUI.TABS.Modifications; });
            var editHeavyModListDlg =
                ShowDialog <EditListDlg <SettingsListBase <StaticMod>, StaticMod> >(pepSettings.EditHeavyMods);
            var addDlgOne = ShowDialog <EditStaticModDlg>(editHeavyModListDlg.AddItem);

            RunUI(() => addDlgOne.SetModification("Label:13C(6)15N(2) (C-term K)"));
            PauseForScreenShot("Isotope modification 1", 3);
            OkDialog(addDlgOne, addDlgOne.OkDialog);
            var addDlgTwo = ShowDialog <EditStaticModDlg>(editHeavyModListDlg.AddItem);

            RunUI(() => addDlgTwo.SetModification("Label:13C(6)15N(4) (C-term R)"));
            PauseForScreenShot("Isotope modification 2", 3);
            OkDialog(addDlgTwo, addDlgTwo.OkDialog);
            OkDialog(editHeavyModListDlg, editHeavyModListDlg.OkDialog);
            RunUI(() =>
            {
                pepSettings.SetIsotopeModifications(0, true);
                pepSettings.SetIsotopeModifications(1, true);
            });
            RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Digest);
            PauseForScreenShot("Digestion tab", 4);
            RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Prediction);
            PauseForScreenShot("Prediction tab", 4);
            RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Filter);
            PauseForScreenShot("Filter tab", 4);
            RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Library);
            PauseForScreenShot("Library tab", 4);
            RunUI(() => pepSettings.SelectedTab = PeptideSettingsUI.TABS.Modifications);
            PauseForScreenShot("Modifications tab", 4);

            OkDialog(pepSettings, pepSettings.OkDialog);

            WaitForCondition(
                () => SkylineWindow.Status.Contains(Resources.BackgroundProteomeSpec_Digest_Digesting__0__.Split('{').First()) &&
                SkylineWindow.Status.Contains(Resources.BackgroundProteomeSpec_Digest_Digesting__0__.Split('}').Last()));
            WaitForCondition(
                () => SkylineWindow.Status.Contains(Resources.BackgroundProteomeManager_LoadBackground_Resolving_protein_details_for__0__proteome.Split('{').First()) &&
                SkylineWindow.Status.Contains(Resources.BackgroundProteomeManager_LoadBackground_Resolving_protein_details_for__0__proteome.Split('}').Last()));
            WaitForCondition(() => SkylineWindow.Status.Contains(Resources.SkylineWindow_UpdateProgressUI_Ready));
            WaitForDocumentLoaded();

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

            RunUI(() =>
            {
                transitionDlg.SelectedTab       = TransitionSettingsUI.TABS.Prediction;
                transitionDlg.PrecursorMassType = MassType.Monoisotopic;
                transitionDlg.FragmentMassType  = MassType.Monoisotopic;
                transitionDlg.RegressionCEName  = "ABI 5500 QTrap";
            });

            RunUI(() =>
            {
                transitionDlg.SelectedTab      = TransitionSettingsUI.TABS.Filter;
                transitionDlg.PrecursorCharges = "2,3".ToString(CultureInfo.CurrentCulture);
                transitionDlg.ProductCharges   = "1,2".ToString(CultureInfo.CurrentCulture);
                transitionDlg.FragmentTypes    = "y";
                transitionDlg.RangeFrom        = Resources.TransitionFilter_FragmentStartFinders_ion_1;
                transitionDlg.RangeTo          = Resources.TransitionFilter_FragmentEndFinders_last_ion;
                transitionDlg.SetListAlwaysAdd(0, false);
                transitionDlg.ExclusionWindow = 5;
                transitionDlg.SetAutoSelect   = true;
            });

            RunUI(() =>
            {
                transitionDlg.SelectedTab       = TransitionSettingsUI.TABS.Library;
                transitionDlg.IonMatchTolerance = 1.0;
                transitionDlg.UseLibraryPick    = true;
                transitionDlg.IonCount          = 5;
                transitionDlg.Filtered          = true;
            });

            RunUI(() =>
            {
                transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Instrument;
                transitionDlg.MinMz       = 300;
                transitionDlg.MaxMz       = 1250;
            });

            RunUI(() => transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Prediction);
            PauseForScreenShot("Prediction Tab", 7);
            RunUI(() => transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Filter);
            PauseForScreenShot("Filter Tab", 7);
            RunUI(() => transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Library);
            PauseForScreenShot("Library Tab", 7);
            RunUI(() => transitionDlg.SelectedTab = TransitionSettingsUI.TABS.Instrument);
            PauseForScreenShot("Instrument Tab", 7);
            OkDialog(transitionDlg, transitionDlg.OkDialog);
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath("Tutorial-1_Settings\\SRMcourse_20140210_Settings.sky")));


            //Tutorial 2
            LinkPdf = "http://www.srmcourse.ch/tutorials2014/Tutorial-2_TransitionList.pdf";

            RunUI(() => { });
            SetExcelFileClipboardText(GetTestPath(@"Tutorial-2_TransitionList\\target_peptides.xlsx"), "Sheet1", 1,
                                      false);
            var peptidePasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);
            var matchingDlg     = ShowDialog <FilterMatchedPeptidesDlg>(peptidePasteDlg.PastePeptides);

            PauseForScreenShot("Filter Peptides", 1);
            OkDialog(matchingDlg, matchingDlg.OkDialog);
            OkDialog(peptidePasteDlg, peptidePasteDlg.OkDialog);

            int expectedTrans = TransitionGroup.IsAvoidMismatchedIsotopeTransitions ? 306 : 313;

            AssertEx.IsDocumentState(SkylineWindow.Document, null, 10, 30, 68, expectedTrans);
            RunUI(() =>
            {
                SkylineWindow.ExpandProteins();
                SkylineWindow.ExpandPeptides();
                SkylineWindow.ExpandPrecursors();
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode;
            });
            PauseForScreenShot("Skyline Window", 2);

            var exportDlg = ShowDialog <ExportMethodDlg>(SkylineWindow.ShowExportTransitionListDlg);

            RunUI(() =>
            {
                exportDlg.InstrumentType = "AB SCIEX";
                exportDlg.ExportStrategy = ExportStrategy.Single;
                exportDlg.DwellTime      = 20;
            });
            PauseForScreenShot("Export Transition List", 3);
            var declusteringWarningDlg = ShowDialog <MultiButtonMsgDlg>(
                () => exportDlg.OkDialog(GetTestPath("Tutorial-2_TransitionList\\SRMcourse_20140210_MtbProteomeLib_TransList.csv")));

            PauseForScreenShot("Decluster Window", 3);
            OkDialog(declusteringWarningDlg, declusteringWarningDlg.Btn1Click);
            WaitForClosedForm(exportDlg);

            //Tutorial 3
            LinkPdf = "http://www.srmcourse.ch/tutorials2014/Tutorial-3_Library.pdf";
            var pepSettings2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() => pepSettings2.SelectedTab = PeptideSettingsUI.TABS.Library);
            var buildLibraryDlg = ShowDialog <BuildLibraryDlg>(pepSettings2.ShowBuildLibraryDlg);

            RunUI(() =>
            {
                buildLibraryDlg.LibraryPath      = GetTestPath("Skyline");
                buildLibraryDlg.LibraryName      = "Mtb_hDP_20140210";
                buildLibraryDlg.LibraryCutoff    = 0.9;
                buildLibraryDlg.LibraryAuthority = "SRMcourse";
            });
            PauseForScreenShot("Build Library Window", 2);
            RunUI(() =>
            {
                buildLibraryDlg.OkWizardPage();
                buildLibraryDlg.AddDirectory(GetTestPath("Tutorial-3_Library"));
            });
            PauseForScreenShot("Build Library Window Next", 2);
            OkDialog(buildLibraryDlg, buildLibraryDlg.OkWizardPage);
            RunUI(() =>
            {
                pepSettings2.SetLibraryChecked(0, true);
                pepSettings2.SetLibraryChecked(1, true);
            });
            OkDialog(pepSettings2, pepSettings2.OkDialog);
            WaitForLibrary(20213);
            WaitForCondition(() => SkylineWindow.Document.PeptideTransitionCount != expectedTrans);
            int expectedTransAfter = TransitionGroup.IsAvoidMismatchedIsotopeTransitions ? 444 : 450;

            AssertEx.IsDocumentState(SkylineWindow.Document, null, 10, 30, 96, expectedTransAfter);

            var libraryExpl    = ShowDialog <ViewLibraryDlg>(SkylineWindow.ViewSpectralLibraries);
            var messageWarning = WaitForOpenForm <MultiButtonMsgDlg>();

            OkDialog(messageWarning, messageWarning.Btn1Click);
            PauseForScreenShot("Spectral Library Explorer Window", 3);
            OkDialog(libraryExpl, libraryExpl.Close);

            var exportDlg2 = ShowDialog <ExportMethodDlg>(SkylineWindow.ShowExportTransitionListDlg);

            RunUI(() =>
            {
                exportDlg2.InstrumentType = "AB SCIEX";
                exportDlg2.ExportStrategy = ExportStrategy.Buckets;
                exportDlg2.MaxTransitions = 150;
                exportDlg2.DwellTime      = 20;
                exportDlg2.IgnoreProteins = true;
            });
            var declusteringWarningDlg2 = ShowDialog <MultiButtonMsgDlg>(() =>
                                                                         exportDlg2.OkDialog(GetTestPath("Tutorial-3_Library\\SRMcourse_20140210_MtbProteomeLib_hDP_TransList.csv")));

            OkDialog(declusteringWarningDlg2, declusteringWarningDlg2.Btn1Click);
            WaitForClosedForm(exportDlg2);

            //Tutorial 4-A
            LinkPdf = "http://www.srmcourse.ch/tutorials2014/Tutorial-4_Parameters.pdf";

            SrmDocument smallDocument = SkylineWindow.Document;

            PeptideGroupDocNode[] newProteins = smallDocument.PeptideGroups.Take(0).ToArray();
            smallDocument = (SrmDocument)smallDocument.ChangeChildren(newProteins);

            Assert.IsTrue(SkylineWindow.SetDocument(smallDocument, SkylineWindow.Document)); // TODO: Must be a better way to do this

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

            RunUI(() =>
            {
                transitionSettings.SelectedTab      = TransitionSettingsUI.TABS.Prediction;
                transitionSettings.RegressionCEName = "ABI QTrap 4000";
            });
            var editCollisionEnergy = ShowDialog <EditCEDlg>(() =>
                                                             transitionSettings.RegressionCEName = Resources.SettingsListComboDriver_Edit_current);

            RunUI(() =>
            {
                editCollisionEnergy.StepSize  = 2;
                editCollisionEnergy.StepCount = 5;
            });
            PauseForScreenShot("Edit Collision Energy Equation Window", 2);
            OkDialog(editCollisionEnergy, editCollisionEnergy.OkDialog);
            OkDialog(transitionSettings, transitionSettings.OkDialog);

            SetExcelFileClipboardText(GetTestPath("Tutorial-4_Parameters\\transition_list_for_CEO.xlsx"), "Sheet1", 3,
                                      false);
            var insertTransitionDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);

            RunUI(() => insertTransitionDlg.IsMolecule = false); // Make sure it's ready to accept peptides, not small molecules
            RunUI(insertTransitionDlg.PasteTransitions);
            OkDialog(insertTransitionDlg, insertTransitionDlg.OkDialog);

            AssertEx.IsDocumentState(SkylineWindow.Document, null, 10, 30, 30, 143);

            var exportDlg3 = ShowDialog <ExportMethodDlg>(SkylineWindow.ShowExportTransitionListDlg);

            RunUI(() =>
            {
                exportDlg3.InstrumentType = "AB SCIEX";
                exportDlg3.ExportStrategy = ExportStrategy.Single;
                exportDlg3.OptimizeType   = ExportOptimize.CE;
                exportDlg3.MethodType     = ExportMethodType.Standard;
                exportDlg2.DwellTime      = 20;
            });
            PauseForScreenShot("Export Transition List", 3);
            var defaultWaringDlg = ShowDialog <MultiButtonMsgDlg>(
                () => exportDlg3.OkDialog(GetTestPath("Tutorial-4_Parameters\\SRMcourse_20140211_Parameters_CEO.csv")));

            OkDialog(defaultWaringDlg, defaultWaringDlg.Btn1Click);
            WaitForClosedForm(exportDlg3);

            var paths = new string[4];

            for (int i = 0; i < paths.Length; i++)
            {
                paths[i] = GetTestPath("Tutorial-4_Parameters\\CEO_" + (i + 1) + ".wiff");
            }

            ImportResults("CEO", paths, ExportOptimize.CE);

            RestoreViewOnScreen(43);
            RunUI(() => SkylineWindow.ShowChromatogramLegends(false));
            PauseForScreenShot("Skyline Window", 3);

            ImportResults("", new[]
            {
                GetTestPath("Tutorial-4_Parameters\\CE_plus10.wiff"),
                GetTestPath("Tutorial-4_Parameters\\CE_minus10.wiff")
            }, ExportOptimize.NONE, false);

            RunUI(() =>
            {
                SkylineWindow.ShowAllTransitions();
                SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_maximum_view);
            });
            RestoreViewOnScreen(44);
            PauseForScreenShot("Skyline Window", 4);

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

            RunUI(() => { transitionSettings2.SelectedTab = TransitionSettingsUI.TABS.Prediction; });
            var addCollisionEnergyDlg = ShowDialog <EditCEDlg>(transitionSettings2.AddToCEList);

            RunUI(() =>
            {
                addCollisionEnergyDlg.UseCurrentData();
                addCollisionEnergyDlg.RegressionName = "SRMcourse_20140211_Parameters_custom-CE-equation";
            });
            var equationGraphDlg = ShowDialog <GraphRegression>(addCollisionEnergyDlg.ShowGraph);

            PauseForScreenShot("Collision Energy Equation Graph", 6);
            OkDialog(equationGraphDlg, equationGraphDlg.CloseDialog);
            OkDialog(addCollisionEnergyDlg, addCollisionEnergyDlg.OkDialog);
            RunUI(() =>
            {
                transitionSettings2.RegressionCEName = "SRMcourse_20140211_Parameters_custom-CE-equation";
                transitionSettings2.SelectedTab      = TransitionSettingsUI.TABS.Instrument;
                transitionSettings2.MZMatchTolerance = 0.01;
            });
            PauseForScreenShot("Instrument Tab", 7);
            OkDialog(transitionSettings2, transitionSettings2.OkDialog);

            //Tutorial 4-B
            var manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);

            RunUI(manageResultsDlg.RemoveAllReplicates);
            OkDialog(manageResultsDlg, manageResultsDlg.OkDialog);
            string[] paths2 =
            {
                GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 10)),
                GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 20)),
                GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 40)),
                GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 60)),
                GetTestPath(string.Format("Tutorial-4_Parameters\\unscheduled_dwell{0}ms.wiff", 100))
            };

            ImportResults("", paths2, null, false);
            RestoreViewOnScreen(48);
            RunUI(() => SkylineWindow.AutoZoomBestPeak());
            PauseForScreenShot("Skyline Window", 8);
        }
Ejemplo n.º 4
0
        protected override void DoTest()
        {
            // Exploring a Library,  p. 1
            PeptideSettingsUI peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var editListUI =
                ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(peptideSettingsUI.EditLibraryList);

            RunDlg <EditLibraryDlg>(editListUI.AddItem, editLibraryDlg =>
            {
                editLibraryDlg.LibrarySpec =
                    new BiblioSpecLibSpec("Experiment 15N", GetTestPath(@"labeled_15N.blib"));
                editLibraryDlg.OkDialog();
            });
            OkDialog(editListUI, editListUI.OkDialog);
            RunUI(() =>
            {
                peptideSettingsUI.SelectedTab     = PeptideSettingsUI.TABS.Library;
                peptideSettingsUI.PickedLibraries = new[] { "Experiment 15N" };
            });
            PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 3);

            // Modifications Tab in peptideSttingsUI to check "Carbamidomethyl Cysteine"
            const string carbamidoName = StaticModList.DEFAULT_NAME;

            RunUI(() =>
            {
                peptideSettingsUI.SelectedTab      = PeptideSettingsUI.TABS.Modifications;
                peptideSettingsUI.PickedStaticMods = new[] { carbamidoName };
            });
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modifications tab", 4);

            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);

            Assert.IsTrue(WaitForCondition(() =>
                                           SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded &&
                                           SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0));

            // Go to view menu and click Spectral Libraries
            ViewLibraryDlg viewLibraryDlg = ShowDialog <ViewLibraryDlg>(SkylineWindow.ViewSpectralLibraries);
            var            matchedPepsDlg = WaitForOpenForm <AddModificationsDlg>();

            RunUI(matchedPepsDlg.CancelDialog);
            PauseForScreenShot <ViewLibraryDlg>("Library Explorer", 5);

            // Types text in Peptide textbox in the Spectral Library Explorer Window
            RunUI(() =>
            {
                viewLibraryDlg.FilterString = "Q"; // Not L10N
                Assert.AreEqual(7, viewLibraryDlg.PeptideDisplayCount);
            });
            PauseForScreenShot("Library Explorere filtered for peptides beginning with Q", 6);

            RunUI(() =>
            {
                viewLibraryDlg.FilterString = "I"; // Not L10N
                viewLibraryDlg.SetObservedMzValues(true);
                Assert.AreEqual(1, viewLibraryDlg.PeptideDisplayCount);
            });

            // Click B and 2 buttons on the right side of Spectral Library Explorer Window to show b-ions
            RunUI(() =>
            {
                Assert.AreEqual(11, viewLibraryDlg.GraphItem.IonLabels.Count());
                viewLibraryDlg.GraphSettings.ShowBIons   = true;
                viewLibraryDlg.GraphSettings.ShowCharge2 = true;
                Assert.AreEqual(35, viewLibraryDlg.GraphItem.IonLabels.Count());
            });
            PauseForScreenShot <ViewLibraryDlg>("Library Explorer showing ISERT peptide with b and charge 2 ions", 7);

            // Right click on spectrum chart and select Observed m/z Values
            RunUI(() =>
            {
                if (!Settings.Default.ShowObservedMz)
                {
                    if (!Settings.Default.ShowIonMz)
                    {
                        var labelsBefore = viewLibraryDlg.GraphItem.IonLabels.ToArray();
                        Assert.IsFalse(labelsBefore.Contains(label => label.Contains("\n"))); // Not L10N
                    }
                    viewLibraryDlg.SetObservedMzValues(true);
                }
                var labelsAfter = viewLibraryDlg.GraphItem.IonLabels;
                Assert.IsTrue(labelsAfter.Contains(label => label.Contains("\n"))); // Not L10N
            });

            // Clearing Peptide Textbox...
            RunUI(() =>
            {
                viewLibraryDlg.FilterString = string.Empty;
                Assert.AreEqual(43, viewLibraryDlg.PeptideDisplayCount);
            });

            // Matching Modifications p. 7

            // Settings > Peptides Settings
            var          peptideSettingsUI1 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            const string glnPyroGluName     = "Gln->pyro-Glu (N-term Q)"; // Not L10N
            var          glnPyroGlu         = UniMod.GetModification(glnPyroGluName, out _);

            glnPyroGlu = glnPyroGlu.ChangeVariable(true);
            AddStaticMod(glnPyroGlu, peptideSettingsUI1, "Edit Structural Modification form", 8);

            RunUI(() => peptideSettingsUI1.PickedStaticMods = new[] { carbamidoName, glnPyroGluName });
            const string label15NName = "Label:15N"; // Not L10N
            var          mod15N       = UniMod.GetModification(label15NName, out _);

            AddHeavyMod(mod15N, peptideSettingsUI1, "Edit Structural Modification form", 9);
            RunUI(() => peptideSettingsUI1.PickedHeavyMods = new[] { label15NName });
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modificatoins tab", 10);

            OkDialog(peptideSettingsUI1, peptideSettingsUI1.OkDialog);

            Assert.IsTrue(WaitForCondition(() =>
                                           SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications.Count > 0 &&
                                           SkylineWindow.Document.Settings.PeptideSettings.Modifications.AllHeavyModifications.Any()));
            PauseForScreenShot("Peptide list clipped from Library Explorer", 11);

            if (IsCoverShotMode)
            {
                RestoreCoverViewOnScreen(false);
                RunUI(() =>
                {
                    viewLibraryDlg.SetBounds(SkylineWindow.Left, SkylineWindow.Top, SkylineWindow.Width, SkylineWindow.Height);
                });
                TakeCoverShot();

                OkDialog(viewLibraryDlg, viewLibraryDlg.CancelDialog);
                return;
            }
            // Adding Library Peptides to the Document p. 11

            // Adding AEVNGLAAQGKYEGSGEDGGAAAQSLYIANHAY
            var          docInitial       = WaitForProteinMetadataBackgroundLoaderCompletedUI();
            const string peptideSequence1 = "AEVNGLAAQGKYEGSGEDGGAAAQSLYIANHAY"; // Not L10N

            RunUI(() =>
            {
                viewLibraryDlg.FilterString = peptideSequence1;
                Assert.AreEqual(1, viewLibraryDlg.PeptideDisplayCount);
            });
            {
                var msgDlg = ShowDialog <FilterMatchedPeptidesDlg>(viewLibraryDlg.AddPeptide);
                PauseForScreenShot <FilterMatchedPeptidesDlg>("Filter peptides form", 11);

                OkDialog(msgDlg, msgDlg.OkDialog);
            }

            var docAdd1 = WaitForDocumentChange(docInitial);

            Assert.AreEqual(1, docAdd1.PeptideCount);
            Assert.AreEqual(peptideSequence1, docAdd1.Peptides.ToArray()[0].Peptide.Sequence);


            // Adding DNAGAATEEFIK++ (no ok dialog)
            const string peptideSequence2 = "DNAGAATEEFIK"; // Not L10N

            RunUI(() =>
            {
                viewLibraryDlg.FilterString = peptideSequence2 + "++"; // Not L10N
                Assert.AreEqual(2, viewLibraryDlg.PeptideDisplayCount);
            });
            RunUI(viewLibraryDlg.AddPeptide);

            var docAdd2 = WaitForDocumentChange(docAdd1);

            Assert.AreEqual(2, docAdd2.PeptideCount);
            Assert.AreEqual(peptideSequence2, docAdd2.Peptides.ToArray()[1].Peptide.Sequence);

            // Edit > ExpandAll > Peptides
            RunUI(() =>
            {
                SkylineWindow.ExpandPeptides();
                SkylineWindow.Size = new Size(918, 553);
            });
            RestoreViewOnScreen(12);
            PauseForScreenShot("Main window", 12);

            // Adding DNAGAATEEFIKR++ (has ok)
            const string peptideSequence3 = "DNAGAATEEFIKR"; // Not L10N

            RunUI(() =>
            {
                viewLibraryDlg.FilterString = peptideSequence3 + "++"; // Not L10N
                Assert.AreEqual(2, viewLibraryDlg.PeptideDisplayCount);
            });

            RunDlg <FilterMatchedPeptidesDlg>(viewLibraryDlg.AddPeptide, msgDlg => msgDlg.OkDialog());
            var docAdd3 = WaitForDocumentChange(docAdd2);

            Assert.AreEqual(3, docAdd3.PeptideCount);
            Assert.AreEqual(2, docAdd3.Peptides.ToArray()[2].Children.Count);
            Assert.AreEqual(peptideSequence3, docAdd3.Peptides.ToArray()[2].Peptide.Sequence);

            // Adding DNAGAATEEFIKR+++ (has ok)
            RunUI(() =>
            {
                viewLibraryDlg.FilterString = peptideSequence3 + "+++"; // Not L10N
                Assert.AreEqual(1, viewLibraryDlg.PeptideDisplayCount);
            });
            WaitForGraphs();

            RunDlg <FilterMatchedPeptidesDlg>(viewLibraryDlg.AddPeptide, msgDlg => msgDlg.OkDialog());
            var docAdd4 = WaitForDocumentChange(docAdd3);

            // peptideSequence4 is considered a sub of peptideSequence3
            Assert.AreEqual(3, docAdd4.PeptideCount);
            Assert.AreEqual(4, docAdd4.Peptides.ToArray()[2].Children.Count);

            // Close the Library Explorer dialog
            OkDialog(viewLibraryDlg, viewLibraryDlg.CancelDialog);

            // Save current document as 15N_library_peptides.sky
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath(@"15N_library_peptides.sky")));
            RunUI(() => SkylineWindow.NewDocument());

            // Neutral Losses p. 13
            PeptideSettingsUI settingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() =>
            {
                settingsUI.SelectedTab      = PeptideSettingsUI.TABS.Modifications;
                settingsUI.PickedStaticMods = new[] { carbamidoName };           // Not L10N
                settingsUI.PickedHeavyMods  = new string[0];
                settingsUI.PickedLibraries  = new string[0];
            });
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modifications tab", 14);

            var editListUI1 =
                ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(settingsUI.EditLibraryList);
            const string humanPhosphoLibName = "Human Phospho"; // Not L10N

            RunDlg <EditLibraryDlg>(editListUI1.AddItem, editLibraryDlg =>
            {
                editLibraryDlg.LibrarySpec =
                    new BiblioSpecLibSpec(humanPhosphoLibName, GetTestPath(@"phospho.blib"));
                editLibraryDlg.OkDialog();
            });
            OkDialog(editListUI1, editListUI1.OkDialog);
            RunUI(() =>
            {
                settingsUI.SelectedTab     = PeptideSettingsUI.TABS.Library;
                settingsUI.PickedLibraries = new[] { humanPhosphoLibName };
            });
            PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 15);

            {
                var msgDlg = ShowDialog <MultiButtonMsgDlg>(() => settingsUI.ShowViewLibraryDlg());
                PauseForScreenShot <MultiButtonMsgDlg>("Save changes", 15);

                OkDialog(msgDlg, msgDlg.Btn0Click);
            }

            Assert.IsTrue(WaitForCondition(() =>
                                           SkylineWindow.Document.Settings.PeptideSettings.Modifications.StaticModifications.Count == 1 &&
                                           !SkylineWindow.Document.Settings.PeptideSettings.Modifications.AllHeavyModifications.Any() &&
                                           SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded &&
                                           SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0));

            // Ignore modification matching form
            var matchedPepModsDlg = WaitForOpenForm <AddModificationsDlg>();

            RunUI(matchedPepModsDlg.CancelDialog);

            var       viewLibraryDlg1 = WaitForOpenForm <ViewLibraryDlg>();
            const int countLabels1    = 15;
            const int countLabels2    = 18;

            RunUI(() =>
            {
                viewLibraryDlg1.FilterString = "AISS"; // Not L10N
                Assert.AreEqual(2, viewLibraryDlg1.PeptideDisplayCount);
                Assert.AreEqual(countLabels1, viewLibraryDlg1.GraphItem.IonLabels.Count());
            });
            PauseForScreenShot <GraphSpectrum>("Spectrum graph metafile", 16);   // p. 16, figure 1a
            RunUI(() =>
            {
                viewLibraryDlg1.SelectedIndex = 1;
                Assert.AreEqual(countLabels2, viewLibraryDlg1.GraphItem.IonLabels.Count());
            });
            PauseForScreenShot <GraphSpectrum>("Spectrum graph metafile", 16);   // p. 16, figure 1b

            docInitial = SkylineWindow.Document;

            var          peptideSettingsUI2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            const string phosphoModName     = "Phospho (ST)";                                                                      // Not L10N
            var          phosphoSt          = new StaticMod(phosphoModName, "S, T", null, true, "HPO3", LabelAtoms.None,           // Not L10N
                                                            RelativeRT.Unknown, null, null, new[] { new FragmentLoss("H3PO4"), }); // Not L10N

            AddStaticMod(phosphoSt, peptideSettingsUI2, "Edit Structural Modifcation form", 17);

            // Check Phospho (ST) and Carbamidomethyl Cysteine
            RunUI(() => peptideSettingsUI2.PickedStaticMods = new[] { phosphoModName, carbamidoName }); // Not L10N
            OkDialog(peptideSettingsUI2, peptideSettingsUI2.OkDialog);

            var docPhospho = WaitForDocumentChange(docInitial);

            Assert.IsTrue(docPhospho.Settings.PeptideSettings.Modifications.StaticModifications.Count == 2);

            string    lossText         = Math.Round(-phosphoSt.Losses[0].MonoisotopicMass, 1).ToString(LocalizationHelper.CurrentCulture);
            const int countLossLabels1 = 12;
            const int countLossLabels2 = 15;
            const int countPrecursors1 = 1;
            const int countPrecursors2 = 2;

            RunUI(() =>
            {
                // New ions should be labeled, because of the added modification with loss
                viewLibraryDlg1.SelectedIndex = 0;
                Assert.AreEqual(countLabels1 + countLossLabels1, viewLibraryDlg1.GraphItem.IonLabels.Count());

                viewLibraryDlg1.GraphSettings.ShowPrecursorIon = true;

                // Make sure the precursor -98 ion was added
                var labelsPhospho = viewLibraryDlg1.GraphItem.IonLabels.ToList();
                Assert.AreEqual(countLossLabels1 + 1, labelsPhospho.Count(label => label.Contains(lossText)));
                Assert.IsTrue(labelsPhospho.Contains(label => label.Contains(string.Format("{0} {1}", IonType.precursor.GetLocalizedString(), lossText))));
                Assert.AreEqual(countLabels1 + countLossLabels1 + countPrecursors1, labelsPhospho.Count);
            });
            PauseForScreenShot <GraphSpectrum>("Spectrum graph metafile", 18);   // p. 18, figure 1a.

            RunUI(() =>
            {
                viewLibraryDlg1.SelectedIndex = 1;
                var labelsPhospho             = viewLibraryDlg1.GraphItem.IonLabels.ToList();
                Assert.AreEqual(countLossLabels2 + 1, labelsPhospho.Count(label => label.Contains(lossText)));
                Assert.IsTrue(labelsPhospho.Contains(label => label.Contains(string.Format("{0} {1}", IonType.precursor.GetLocalizedString(), lossText))));
                Assert.AreEqual(countLabels2 + countLossLabels2 + countPrecursors2, labelsPhospho.Count);
            });
            PauseForScreenShot <GraphSpectrum>("Spectrum graph metafile", 18);   // p. 18, figure 1b.

            // Matching Library Peptides to Proteins p. 18
            var peptideSettingsUI3         = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var buildBackgroundProteomeDlg =
                ShowDialog <BuildBackgroundProteomeDlg>(peptideSettingsUI3.ShowBuildBackgroundProteomeDlg);

            RunUI(() =>
            {
                buildBackgroundProteomeDlg.BackgroundProteomePath = GetTestPath(@"human.protdb");
                buildBackgroundProteomeDlg.BackgroundProteomeName = "Human (mini)";
            });
            PauseForScreenShot <BuildBackgroundProteomeDlg>("Edit Background Proteome", 19);   // p. 19

            OkDialog(buildBackgroundProteomeDlg, buildBackgroundProteomeDlg.OkDialog);

            // Select Max Missed Cleavages to be 2
            RunUI(() =>
            {
                peptideSettingsUI3.MissedCleavages = 2;
            });
            OkDialog(peptideSettingsUI3, peptideSettingsUI3.OkDialog);

            WaitForBackgroundProteomeLoaderCompleted(); // wait for protDB to populate protein metadata

            RunUI(() =>
            {
                viewLibraryDlg1.FilterString = string.Empty;
                Assert.AreEqual(100, viewLibraryDlg1.PeptideDisplayCount);
            });

            // Check Associate Proteins check box on Spectral Library Explorer form
            RunUI(() =>
            {
                viewLibraryDlg1.AssociateMatchingProteins = true;
            });

            docInitial = WaitForProteinMetadataBackgroundLoaderCompletedUI();

            var confirmUpgrade = ShowDialog <AlertDlg>(viewLibraryDlg1.AddAllPeptides);
            // Add everything in the library to the document.
            var filterMatchedPeptidesDlg =
                ShowDialog <FilterMatchedPeptidesDlg>(confirmUpgrade.ClickYes);

            RunUI(() =>
            {
                filterMatchedPeptidesDlg.DuplicateProteinsFilter =
                    BackgroundProteome.DuplicateProteinsFilter.FirstOccurence;
                filterMatchedPeptidesDlg.AddUnmatched = true;
                filterMatchedPeptidesDlg.AddFiltered  = true;

                // Checks that Peptides were added with the correct buttons selected...
                Assert.AreEqual(163, filterMatchedPeptidesDlg.DuplicateMatchesCount);
                Assert.AreEqual(2, filterMatchedPeptidesDlg.UnmatchedCount);
            });
            PauseForScreenShot <FilterMatchedPeptidesDlg>("Filter Peptides", 20);   // p. 20, figure 1

            {
                var msgDlg = ShowDialog <MultiButtonMsgDlg>(filterMatchedPeptidesDlg.OkDialog);
                PauseForScreenShot("Message form", 20);   // p. 20, figure 2

                OkDialog(msgDlg, msgDlg.Btn1Click);
            }
            OkDialog(viewLibraryDlg1, viewLibraryDlg1.CancelDialog);

            var docProteins = WaitForDocumentChange(docInitial);

            AssertEx.IsDocumentState(docProteins, null, 250, 346, 347, 1041);

            RestoreViewOnScreen(21);
            PauseForScreenShot("Main window", 21);

            OkDialog(viewLibraryDlg, viewLibraryDlg.Close);
        }
        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);
        }
Ejemplo n.º 6
0
        protected override void DoTest()
        {
            // Setting the UI mode, p 2
            var startPage = WaitForOpenForm <StartPage>();

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

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

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

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


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

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

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

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

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


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

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


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

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

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

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

                    OkDialog(importResultsDlg1, importResultsDlg1.OkDialog);
                }

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

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

                var docResults = SkylineWindow.Document;

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

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

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

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

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

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

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

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

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

                RunUI(() => SkylineWindow.ShowCalibrationForm());
                SelectNode(SrmDocument.Level.Molecules, 0);
                PauseForScreenShot <DocumentGridForm>("Calibration curve", 12);
            }
        }
Ejemplo n.º 7
0
        protected override void DoTest()
        {
            RunUI(() => SkylineWindow.SetUIMode(SrmDocument.DOCUMENT_TYPE.small_molecules));

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

            var doc = SkylineWindow.Document;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            WaitForGraphs();

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

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

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

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

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

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

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

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

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

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

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

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


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


            //    Reimporting Data with Drift Time Filtering

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

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

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


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

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

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

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

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

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

            //   The following steps can be taken to easily export an updated spectral library:
            //   •	From the File menu, choose Export and click Spectral Library.
            //   •	Enter a file name and click Save.
        }
Ejemplo n.º 8
0
        protected bool DoQualityControlSummaryReports()
        {
            // Quality Control Summary Reports, p. 20
            RunUI(() =>
            {
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath(@"CustomReports\study9pilot.sky")); // Not L10N
                SkylineWindow.ExpandPeptides();
            });
            RunUI(() => SkylineWindow.ShowDocumentGrid(true));
            RestoreViewOnScreen(20);
            var documentGridForm = FindOpenForm <DocumentGridForm>();
            var manageViewsForm  = ShowDialog <ManageViewsForm>(documentGridForm.ManageViews);

            RunUI(() =>
                  manageViewsForm.ImportViews(TestFilesDir.GetTestPath(@"CustomReports\Summary_stats.skyr"))
                  );
            PauseForScreenShot <ManageViewsForm>("Manage Reports form", 20);
            OkDialog(manageViewsForm, manageViewsForm.Close);
            Size  originalSize = Size.Empty;
            Point formLocation = Point.Empty;

            if (IsPauseForScreenShots)
            {
                // CONSIDER: The ShowDropDown() use below causes User+GDI handle leaks
                RunUI(() =>
                {
                    documentGridForm.NavBar.ReportsButton.ShowDropDown();   //we need to expand it to determine its full size
                    int ddHeight = documentGridForm.NavBar.ReportsButton.DropDown.Height;
                    formLocation = new Point(SkylineWindow.DesktopBounds.Left + 200, SkylineWindow.DesktopBounds.Top + 200);
                    documentGridForm.NavBar.ReportsButton.HideDropDown();
                    originalSize = documentGridForm.Size;
                    //make sure the dropdown fits into the window with some margin.
                    documentGridForm.FloatingPane.FloatAt(new Rectangle(formLocation, new Size(documentGridForm.Width, ddHeight + 75)));
                    documentGridForm.NavBar.ReportsButton.ShowDropDown();

                    var i     = 0;  //find and select the Summary Statistics item.
                    var items = documentGridForm.NavBar.ReportsButton.DropDown.Items;
                    while (i < items.Count && items[i].Text != "Summary Statistics")
                    {
                        i++;
                    }
                    if (i < items.Count)
                    {
                        items[i].Select();
                    }
                    else
                    {
                        Assert.Fail("Summary Statistics not found in Reports menu");
                    }
                });
                PauseForScreenShot <DocumentGridForm>("Click the Reports dropdown and highlight 'Summary_stats'", 21);

                RunUI(() => documentGridForm.NavBar.ReportsButton.HideDropDown());
            }
            RunUI(() => documentGridForm.ChooseView("Summary Statistics"));
            WaitForConditionUI(() => documentGridForm.IsComplete);
            RunUI(() => documentGridForm.ExpandColumns());

            if (IsPauseForScreenShots)
            {
                RunUI(() => documentGridForm.FloatingPane.FloatAt(new Rectangle(formLocation, originalSize)));
            }

            PauseForScreenShot <DocumentGridForm>("Document Grid with summary statistics", 21);

            if (IsCoverShotMode)
            {
                RestoreCoverViewOnScreen();
                var documentGridFormCover = WaitForOpenForm <DocumentGridForm>();
                RunUI(SkylineWindow.AutoZoomBestPeak);
                WaitForGraphs();
                var viewEditorCover = ShowDialog <ViewEditor>(documentGridFormCover.NavBar.CustomizeView);
                RunUI(() =>
                {
                    viewEditorCover.Top    = SkylineWindow.Top + 10;
                    viewEditorCover.Width -= 40;
                    viewEditorCover.Left   = SkylineWindow.Right - viewEditorCover.Width;
                    var columnsExpand      = new[]
                    {
                        PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.ResultSummary.MaxFwhm.Cv"),
                        PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.ResultSummary.TotalArea.Cv"),
                        PropertyPath.Parse("Proteins!*"),
                    };
                    foreach (var id in columnsExpand)
                    {
                        Assert.IsTrue(viewEditorCover.ChooseColumnsTab.TrySelect(id), "Unable to select {0}", id);
                    }
                });
                TakeCoverShot();

                OkDialog(viewEditorCover, viewEditorCover.CancelButton.PerformClick);
                return(false);
            }

            var viewEditor = ShowDialog <ViewEditor>(documentGridForm.NavBar.CustomizeView);

            RunUI(() => Assert.AreEqual(11, viewEditor.ChooseColumnsTab.ColumnCount));
            RunUI(() =>
            {
                int indexCvTotalArea =
                    viewEditor.ChooseColumnsTab.ColumnNames.ToList().IndexOf(GetLocalizedCaption("CvTotalArea"));
                Assert.IsFalse(indexCvTotalArea < 0, "{0} < 0", indexCvTotalArea);
                viewEditor.ChooseColumnsTab.ActivateColumn(indexCvTotalArea);
            });
            PauseForScreenShot <ViewEditor.ChooseColumnsView>("Customize View form", 22);
            RunUI(() => viewEditor.TabControl.SelectTab(1));
            RunUI(() =>
            {
                viewEditor.FilterTab.AddSelectedColumn();
                Assert.IsTrue(viewEditor.FilterTab.SetFilterOperation(0, FilterOperations.OP_IS_GREATER_THAN));
                viewEditor.FilterTab.SetFilterOperand(0, .2.ToString(CultureInfo.CurrentCulture));
            });
            PauseForScreenShot <ViewEditor.FilterView>("Customize View - Filter tab", 23);
            OkDialog(viewEditor, viewEditor.OkDialog);
            PauseForScreenShot <DocumentGridForm>("Document Grid filtered", 24);
            RunUI(documentGridForm.Close);
            RunDlg <FindNodeDlg>(SkylineWindow.ShowFindNodeDlg, findPeptideDlg =>
            {
                findPeptideDlg.SearchString = "INDISHTQSVSAK"; // Not L10N
                findPeptideDlg.FindNext();
                findPeptideDlg.Close();
            });
            RunUI(SkylineWindow.ShowPeakAreaReplicateComparison);
            WaitForGraphs();

            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas view", 25);
            return(true);    // Continue subsequent tests
        }