Esempio n. 1
0
        private static void TestAddingTransition()
        {
            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                var node = SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode;
                SkylineWindow.SequenceTree.SelectedNode = node;
            });
            var moleculeDlg = ShowDialog <EditCustomMoleculeDlg>(SkylineWindow.AddSmallMolecule);

            RunUI(() =>
            {
                moleculeDlg.FormulaBox.Formula = C12H12;
                moleculeDlg.NameText           = testNametextA;
                moleculeDlg.Adduct             = Adduct.NonProteomicProtonatedFromCharge(1);
            });
            OkDialog(moleculeDlg, moleculeDlg.OkDialog);
            var newDoc     = SkylineWindow.Document;
            var compareIon = new CustomIon(C12H12, Adduct.NonProteomicProtonatedFromCharge(1), null, null, testNametextA);

            Assert.AreEqual(compareIon, newDoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon);
            Assert.AreEqual(1, newDoc.MoleculeTransitions.ElementAt(0).Transition.Charge);

            // Verify that tree selection doesn't change just because we changed an ID object
            // (formerly the tree node would collapse and focus would jump up a level)
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode, SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode);
            });
        }
Esempio n. 2
0
        private static void TestEditingTransition()
        {
            double massPrecisionTolerance = Math.Pow(10, -SequenceMassCalc.MassPrecision);
            var    doc = SkylineWindow.Document;

            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode.FirstNode;
            });
            var editMoleculeDlg =
                ShowDialog <EditCustomMoleculeDlg>(
                    () => SkylineWindow.ModifyTransition((TransitionTreeNode)SkylineWindow.SequenceTree.SelectedNode));

            RunUI(() =>
            {
                Assert.AreEqual(C12H12, editMoleculeDlg.FormulaBox.Formula);
                Assert.AreEqual(BioMassCalc.MONOISOTOPIC.CalculateMassFromFormula(C12H12), editMoleculeDlg.FormulaBox.MonoMass ?? -1, massPrecisionTolerance);
                Assert.AreEqual(BioMassCalc.AVERAGE.CalculateMassFromFormula(C12H12), editMoleculeDlg.FormulaBox.AverageMass ?? -1, massPrecisionTolerance);
                editMoleculeDlg.FormulaBox.Formula     = null;
                editMoleculeDlg.Charge                 = 2; // If we set this after we set the mass, the mass will change since m/z is the actual input
                editMoleculeDlg.FormulaBox.AverageMass = 800;
                editMoleculeDlg.FormulaBox.MonoMass    = 805;
                editMoleculeDlg.NameText               = "Fragment";
            });
            OkDialog(editMoleculeDlg, editMoleculeDlg.OkDialog);
            var newdoc = WaitForDocumentChange(doc);

            Assert.AreEqual("Fragment", newdoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon.ToString());
            Assert.AreEqual(BioMassCalc.CalculateIonMz(805, 2), newdoc.MoleculeTransitions.ElementAt(0).Mz, massPrecisionTolerance);
            Assert.IsFalse(ReferenceEquals(doc.MoleculeTransitions.ElementAt(0).Id, newdoc.MoleculeTransitions.ElementAt(0).Id)); // Changing the mass changes the Id

            // Verify that tree selection doesn't change just because we changed an ID object
            // (formerly the tree node would collapse and focus would jump up a level)
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode, SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode.FirstNode);
            });

            // And test undo/redo
            RunUI(() => SkylineWindow.Undo());
            newdoc = WaitForDocumentChange(newdoc);
            Assert.AreNotEqual("Fragment", newdoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon.ToString());
            Assert.AreNotEqual(BioMassCalc.CalculateIonMz(805, 2), newdoc.MoleculeTransitions.ElementAt(0).Mz, massPrecisionTolerance);
            Assert.IsTrue(ReferenceEquals(doc.MoleculeTransitions.ElementAt(0).Id, newdoc.MoleculeTransitions.ElementAt(0).Id));
            RunUI(() => SkylineWindow.Redo());
            newdoc = WaitForDocumentChange(newdoc);
            Assert.AreEqual("Fragment", newdoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon.ToString());
            Assert.AreEqual(BioMassCalc.CalculateIonMz(805, 2), newdoc.MoleculeTransitions.ElementAt(0).Mz, massPrecisionTolerance);

            // Verify that tree selection doesn't change just because we changed an ID object
            // (formerly the tree node would collapse and focus would jump up a level)
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode, SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode.FirstNode);
            });
        }
Esempio n. 3
0
        private static void TestAddingTransitionAsMasses()
        {
            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                var node = SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode;
                SkylineWindow.SequenceTree.SelectedNode = node;
            });
            var editMoleculeDlg = ShowDialog <EditCustomMoleculeDlg>(SkylineWindow.AddSmallMolecule);
            var formula         = C12H12;
            var monoMass        = BioMassCalc.MONOISOTOPIC.CalculateMassFromFormula(formula);
            var averageMass     = BioMassCalc.AVERAGE.CalculateMassFromFormula(formula);
            var adduct          = Adduct.M_PLUS;

            RunUI(() =>
            {
                // Verify the interaction of explicitly set mz and charge without formula
                editMoleculeDlg.NameText = testNametextA;
                editMoleculeDlg.Adduct   = adduct;
                var mzMono    = editMoleculeDlg.Adduct.MzFromNeutralMass(monoMass);
                var mzAverage = editMoleculeDlg.Adduct.MzFromNeutralMass(averageMass);
                editMoleculeDlg.FormulaBox.MonoMass    = monoMass;
                editMoleculeDlg.FormulaBox.AverageMass = averageMass;
                var massPrecisionTolerance             = 0.00001;
                Assert.AreEqual(mzMono, double.Parse(editMoleculeDlg.FormulaBox.MonoText), massPrecisionTolerance);
                Assert.AreEqual(mzAverage, double.Parse(editMoleculeDlg.FormulaBox.AverageText), massPrecisionTolerance);
            });
            OkDialog(editMoleculeDlg, editMoleculeDlg.OkDialog);

            var newDoc     = SkylineWindow.Document;
            var compareIon = new CustomIon(null, adduct, monoMass, averageMass, testNametextA);

            Assert.AreEqual(compareIon, newDoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon);
            Assert.AreEqual(1, newDoc.MoleculeTransitions.ElementAt(0).Transition.Charge);

            // Verify that tree selection doesn't change just because we changed an ID object
            // (formerly the tree node would collapse and focus would jump up a level)
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode, SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode);
            });
        }
        private void DoMrmerTest()
        {
            // Preparing a Document to Accept a Transition List, p. 2
            var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var editListUI        =
                ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(peptideSettingsUI.EditLibraryList);

            RunDlg <EditLibraryDlg>(editListUI.AddItem, editLibraryDlg =>
            {
                editLibraryDlg.LibrarySpec =
                    new BiblioSpecLibSpec("Yeast_mini", GetTestPath(@"MRMer\Yeast_MRMer_min.blib")); // Not L10N
                editLibraryDlg.OkDialog();
            });
            OkDialog(editListUI, editListUI.OkDialog);
            RunUI(() =>
            {
                peptideSettingsUI.PickedLibraries = new[] { "Yeast_mini" }; // Not L10N
                peptideSettingsUI.SelectedTab     = PeptideSettingsUI.TABS.Library;
            });
            PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 3);

            RunUI(() => peptideSettingsUI.SelectedTab = PeptideSettingsUI.TABS.Digest);
            RunDlg <BuildBackgroundProteomeDlg>(peptideSettingsUI.ShowBuildBackgroundProteomeDlg,
                                                buildBackgroundProteomeDlg =>
            {
                buildBackgroundProteomeDlg.BackgroundProteomeName = "Yeast_mini";                                  // Not L10N
                buildBackgroundProteomeDlg.BackgroundProteomePath = GetTestPath(@"MRMer\Yeast_MRMer_mini.protdb"); // Not L10N
                buildBackgroundProteomeDlg.OkDialog();
            });
            PauseForScreenShot <PeptideSettingsUI.DigestionTab>("Peptide Settings - Digestion tab", 4);

            var modHeavyK = new StaticMod(HEAVY_K, "K", ModTerminus.C, false, null, LabelAtoms.C13 | LabelAtoms.N15, // Not L10N
                                          RelativeRT.Matching, null, null, null);

            AddHeavyMod(modHeavyK, peptideSettingsUI, "Edit Isotope Modification form", 5);
            var modHeavyR = new StaticMod(HEAVY_R, "R", ModTerminus.C, false, null, LabelAtoms.C13 | LabelAtoms.N15, // Not L10N
                                          RelativeRT.Matching, null, null, null);

            AddHeavyMod(modHeavyR, peptideSettingsUI, "Edit Isotope Modification form", 6);
            RunUI(() => peptideSettingsUI.PickedHeavyMods = new[] { HEAVY_K, HEAVY_R });
            var docBeforePeptideSettings = SkylineWindow.Document;

            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
            WaitForDocumentChangeLoaded(docBeforePeptideSettings);

            // Inserting a Transition List With Associated Proteins, p. 6
            RunUI(() =>
            {
                var filePath = GetTestPath(@"MRMer\silac_1_to_4.xls");  // Not L10N
                SetExcelFileClipboardText(filePath, "Fixed", 3, false); // Not L10N
            });
            using (new CheckDocumentState(24, 44, 88, 296))
            {
                var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);
                RunUI(() => pasteDlg.IsMolecule = false); // Make sure it's ready to accept peptides rather than small molecules
                RunUI(pasteDlg.PasteTransitions);
                PauseForScreenShot <PasteDlg.TransitionListTab>("Insert Transition List form", 8);
                OkDialog(pasteDlg, pasteDlg.OkDialog);
            }
            PauseForScreenShot("Main window with transitions added", 9);

            FindNode("LWDVAT");
            RunUI(() =>
            {
                Assert.IsTrue(((PeptideDocNode)((PeptideTreeNode)SkylineWindow.SelectedNode).Model).HasChildType(IsotopeLabelType.heavy));
                SkylineWindow.ExpandPrecursors();
            });
            FindNode(string.Format("{0:F03}", 854.4)); // I18N
            WaitForGraphs();
            // Unfortunately, label hiding may mean that the selected ion is not labeled
            Assert.IsTrue(SkylineWindow.GraphSpectrum.SelectedIonLabel != null
                              ? SkylineWindow.GraphSpectrum.SelectedIonLabel.Contains("y7")                           // Not L10N
                              : SkylineWindow.GraphSpectrum.IonLabels.Contains(ionLabel => ionLabel.Contains("y7"))); // Not L10N
            RunUI(() =>
            {
                SkylineWindow.GraphSpectrumSettings.ShowBIons   = true;
                SkylineWindow.GraphSpectrumSettings.ShowCharge2 = true;
            });
            PauseForScreenShot <GraphSpectrum>("Main window with spectral library graph showing", 10);

            // Importing Data, p. 10.
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath(@"MRMer\MRMer.sky"))); // Not L10N
            ImportResultsFile("silac_1_to_4.mzXML");                                  // Not L10N
            FindNode("ETFP");                                                         // Not L10N
            RunUI(SkylineWindow.AutoZoomBestPeak);
            PauseForScreenShot("Main window with data imported", 12);

            RunUI(() =>
            {
                var selNode = SkylineWindow.SequenceTree.SelectedNode;
                Assert.IsTrue(selNode.Text.Contains("ETFPILVEEK")); // Not L10N
                Assert.IsTrue(((PeptideDocNode)((PeptideTreeNode)selNode).Model).HasResults);
                Assert.IsTrue(Equals(selNode.StateImageIndex, (int)SequenceTree.StateImageId.keep));
                SkylineWindow.ShowAllTransitions();
                SkylineWindow.SelectedPath =
                    SkylineWindow.SequenceTree.GetNodePath(selNode.Nodes[0].Nodes[2] as TreeNodeMS);
                Assert.IsTrue(Equals(SkylineWindow.SequenceTree.SelectedNode.StateImageIndex,
                                     (int)SequenceTree.StateImageId.no_peak));
            });
            PauseForScreenShot("Main window", 13);

            // Removing a Transition with Interference, p. 13.
            FindNode(string.Format("{0:F04}", 504.2664));   // I18N
            RunUI(() =>
            {
                TransitionTreeNode selNode = (TransitionTreeNode)SkylineWindow.SequenceTree.SelectedNode;
                SkylineWindow.RemovePeak(
                    SkylineWindow.SequenceTree.SelectedPath.GetPathTo((int)SrmDocument.Level.TransitionGroups),
                    ((TransitionGroupTreeNode)selNode.Parent).DocNode, selNode.DocNode);
                // Ensure that the Total Ratio is 0.62
                // TODO(nicksh): Update tutorial Word Doc so that it has the right numbers.
                Assert.IsTrue(Equals(SkylineWindow.SequenceTree.SelectedNode.StateImageIndex,
                                     (int)SequenceTree.StateImageId.no_peak) && SkylineWindow.SequenceTree.SelectedNode.Parent.Text.Contains((0.62).ToString(LocalizationHelper.CurrentCulture)));
            });

            // Adjusting Peak Boundaries to Exclude Interference, p. 14.
            RunUI(() => SkylineWindow.Undo());
            FindNode("ETFP");
            RunUI(() =>
            {
                var pathGroup =
                    SkylineWindow.SequenceTree.GetNodePath((TreeNodeMS)SkylineWindow.SelectedNode.Nodes[0]);
                var graphChrom  = SkylineWindow.GraphChromatograms.ToList()[0];
                var listChanges = new List <ChangedPeakBoundsEventArgs>
                {
                    new ChangedPeakBoundsEventArgs(pathGroup, null, graphChrom.NameSet,
                                                   graphChrom.ChromGroupInfos[0].FilePath,
                                                   new ScaledRetentionTime(29.8, 29.8),
                                                   new ScaledRetentionTime(30.4, 30.4),
                                                   PeakIdentification.FALSE,
                                                   PeakBoundsChangeType.both)
                };
                graphChrom.SimulateChangedPeakBounds(listChanges);
                foreach (TransitionTreeNode node in SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Nodes)
                {
                    Assert.IsTrue(((TransitionDocNode)node.Model).HasResults);
                }
            });
            PauseForScreenShot("Main window", 14);

            FindNode("YVDP");
            RunUI(() =>
                  Assert.IsTrue(SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Nodes[2].StateImageIndex
                                == (int)SequenceTree.StateImageId.peak_blank));
            RunUI(() => SkylineWindow.SaveDocument());
            PauseForAuditLog();
        }
Esempio n. 5
0
        protected override void DoTest()
        {
            // Clear all the settings lists that will be defined in this tutorial
            ClearSettingsLists();

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

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

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

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

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

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

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

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

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

            PauseForScreenShot <DiaIsolationWindowsGraphForm>("Graph of Isolation Scheme", 8);
            OkDialog(isolationSchemeGraphDlg, isolationSchemeGraphDlg.CloseButton);
            RunUI(() => isolationSchemeDlg.IsolationSchemeName = "500 to 900 by 20");
            OkDialog(isolationSchemeDlg, isolationSchemeDlg.OkDialog);
            OkDialog(transitionSettings, transitionSettings.OkDialog);

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

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

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

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

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

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

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

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

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

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

            const string prefixKeep = "DIA_Pit0";

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

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

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

                // "Configure Transition Settings" page
                RunUI(() =>
                {
                    Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.transition_settings_page);
                    importPeptideSearchDlg.TransitionSettingsControl.PrecursorCharges      = new[] { 1, 2, 3, 4 };
                    importPeptideSearchDlg.TransitionSettingsControl.IonCharges            = new[] { 1, 2 };
                    importPeptideSearchDlg.TransitionSettingsControl.IonTypes              = new[] { IonType.y, IonType.b, IonType.precursor };
                    importPeptideSearchDlg.TransitionSettingsControl.ExclusionUseDIAWindow = true;
                    importPeptideSearchDlg.TransitionSettingsControl.IonCount              = 5;
                    importPeptideSearchDlg.TransitionSettingsControl.IonMatchTolerance     = 0.05;
                    Assert.IsTrue(importPeptideSearchDlg.ClickNextButton());
                });

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

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

                WaitForClosedForm(importPeptideSearchDlg);
                WaitForCondition(10 * 60 * 1000, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);    // 10 minutes

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

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

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

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

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

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

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

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

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

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

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

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

            RunUI(SkylineWindow.AutoZoomBestPeak);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // Clear all the settings lists that were defined in this tutorial
            ClearSettingsLists();
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        /// <summary>
        /// Test tree state restoration from a persistent string. Tests for proper expansion and
        /// selection of nodes, and correct vertical scrolling
        /// </summary>
        protected override void DoTest()
        {
            // tests for a blank document
            RunUI(() =>
            {
                SkylineWindow.NewDocument();
                SetCurrentState();
                SkylineWindow.SaveDocument(TestContext.GetTestPath("blank.sky"));
                // reload file from persistent string
                SkylineWindow.OpenFile(TestContext.GetTestPath("blank.sky"));
                CompareStates();
            });

            _documentFile = TestFilesDir.GetTestPath("Study7_0-7.sky");

            // tests for a fully collapsed tree
            RunUI(() =>
            {
                SkylineWindow.OpenFile(_documentFile);
                SkylineWindow.CollapseProteins();
                CheckStateMaintained();
            });

            // tests for a fully expanded tree and scrolling
            RunUI(() =>
            {
                SkylineWindow.OpenFile(_documentFile);
                SkylineWindow.ExpandPrecursors();
                CheckStateMaintained();
                SkylineWindow.SelectAll();
                CheckStateMaintained();
                // select last node in tree for scrolling test
                SelectNode(SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1], null);
                CheckStateMaintained();
            });

            // tests for expansion
            RunUI(() =>
            {
                SkylineWindow.OpenFile(_documentFile);
                SkylineWindow.CollapseProteins();
                SelectNode(SkylineWindow.SequenceTree.TopNode, null);
                CheckStateMaintained();
                TestExpansion();
            });

            // tests for selection
            RunUI(() =>
            {
                SkylineWindow.OpenFile(_documentFile);
                TestSingleSelect();
                TestSelectLastNode();
                TestRangeSelect();
                TestDisjointSelect();
                TestCombinedRangeDisjoint();
            });

            // tests that Skyline will not crash when there is a mismatch between stored data in the
            // .sky.view file and that in the tree
            RunUI(() =>
            {
                SelectNode(SkylineWindow.SequenceTree.Nodes[1], null);
                SkylineWindow.SaveDocument(_documentFile);
                System.IO.File.Copy(SkylineWindow.GetViewFile(_documentFile), _documentFile + ".copy");
                SkylineWindow.EditDelete();
                CheckStateMaintained();
                System.IO.File.Delete(SkylineWindow.GetViewFile(_documentFile));
                System.IO.File.Copy(_documentFile + ".copy", SkylineWindow.GetViewFile(_documentFile));
                SkylineWindow.OpenFile(_documentFile);
            });
        }
Esempio n. 8
0
        private static void TestEditingTransition()
        {
            double massPrecisionTolerance = Math.Pow(10, -SequenceMassCalc.MassPrecision);
            var    doc = SkylineWindow.Document;

            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode.FirstNode;
            });
            var editMoleculeDlg =
                ShowDialog <EditCustomMoleculeDlg>(
                    () => SkylineWindow.ModifyTransition((TransitionTreeNode)SkylineWindow.SequenceTree.SelectedNode));
            var monoMass = new TypedMass(805, MassType.Monoisotopic);

            RunUI(() =>
            {
                Assert.AreEqual(C12H12 + Adduct.NonProteomicProtonatedFromCharge(1).AdductFormula, editMoleculeDlg.FormulaBox.Formula);
                Assert.AreEqual(BioMassCalc.MONOISOTOPIC.CalculateMassFromFormula(C12H12),
                                editMoleculeDlg.FormulaBox.MonoMass ?? -1, massPrecisionTolerance);
                Assert.AreEqual(BioMassCalc.AVERAGE.CalculateMassFromFormula(C12H12),
                                editMoleculeDlg.FormulaBox.AverageMass ?? -1, massPrecisionTolerance);
                Assert.AreEqual(Adduct.NonProteomicProtonatedFromCharge(1).AdductFormula, editMoleculeDlg.FormulaBox.Adduct.AdductFormula);
                editMoleculeDlg.FormulaBox.Formula = editMoleculeDlg.FormulaBox.Adduct.AdductFormula; // Remove neutral formula, should leave masses unchanged
                Assert.AreEqual(BioMassCalc.MONOISOTOPIC.CalculateMassFromFormula(C12H12),
                                editMoleculeDlg.FormulaBox.MonoMass ?? -1, massPrecisionTolerance);
                Assert.AreEqual(BioMassCalc.AVERAGE.CalculateMassFromFormula(C12H12),
                                editMoleculeDlg.FormulaBox.AverageMass ?? -1, massPrecisionTolerance);
                editMoleculeDlg.FormulaBox.AverageMass = 800;
                editMoleculeDlg.FormulaBox.MonoMass    = monoMass.Value;
                editMoleculeDlg.NameText = "Fragment";
            });
            OkDialog(editMoleculeDlg, editMoleculeDlg.OkDialog);
            var newdoc = WaitForDocumentChange(doc);

            Assert.AreEqual("Fragment", newdoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon.ToString());
            Assert.AreEqual(BioMassCalc.CalculateIonMz(monoMass, editMoleculeDlg.Adduct), newdoc.MoleculeTransitions.ElementAt(0).Mz, massPrecisionTolerance);
            Assert.IsFalse(ReferenceEquals(doc.MoleculeTransitions.ElementAt(0).Id, newdoc.MoleculeTransitions.ElementAt(0).Id)); // Changing the mass changes the Id

            // Verify that tree selection doesn't change just because we changed an ID object
            // (formerly the tree node would collapse and focus would jump up a level)
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode, SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode.FirstNode);
            });

            // And test undo/redo
            RunUI(() => SkylineWindow.Undo());
            newdoc = WaitForDocumentChange(newdoc);
            Assert.AreNotEqual("Fragment", newdoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon.ToString());
            Assert.AreNotEqual(BioMassCalc.CalculateIonMz(monoMass, editMoleculeDlg.Adduct), newdoc.MoleculeTransitions.ElementAt(0).Mz, massPrecisionTolerance);
            Assert.IsTrue(ReferenceEquals(doc.MoleculeTransitions.ElementAt(0).Id, newdoc.MoleculeTransitions.ElementAt(0).Id));
            RunUI(() => SkylineWindow.Redo());
            newdoc = WaitForDocumentChange(newdoc);
            Assert.AreEqual("Fragment", newdoc.MoleculeTransitions.ElementAt(0).Transition.CustomIon.ToString());
            Assert.AreEqual(BioMassCalc.CalculateIonMz(monoMass, editMoleculeDlg.Adduct), newdoc.MoleculeTransitions.ElementAt(0).Mz, massPrecisionTolerance);

            // Verify that tree selection doesn't change just because we changed an ID object
            // (formerly the tree node would collapse and focus would jump up a level)
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SequenceTree.SelectedNode, SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode.FirstNode);
            });
        }
Esempio n. 9
0
        protected override void DoTest()
        {
            const int molCount = 1;
            var       doc      = SkylineWindow.Document;

            for (var loop = 0; loop < 3; loop++)
            {
                // Should be able to synchronize if both sibs have formula, or neither, but not one of each
                string testname;
                switch (loop)
                {
                case 0:
                    testname = "ions_testing_masses.sky";     // Masses only
                    break;

                case 1:
                    testname = "ions_testing_mixed.sky";     // Starts out as two precursors, with no transitions, one is labeled 15N
                    break;

                default:
                    testname = "ions_testing.sky";     // Starts out as two precursors, first has a precursor transition, other has label 15N and serialized ion formula
                    break;
                }
                string testPath = TestFilesDir.GetTestPath(testname);
                RunUI(() => SkylineWindow.OpenFile(testPath));
                doc = WaitForDocumentChange(doc);

                SelectNode(SrmDocument.Level.Molecules, 0);

                Assert.AreEqual(molCount, SkylineWindow.Document.MoleculeCount);
                RunUI(SkylineWindow.ExpandPrecursors);

                Settings.Default.SynchronizeIsotopeTypes = true;

                // Select the first transition group
                SelectNode(SrmDocument.Level.TransitionGroups, 0);
                // Add precursor transition to it
                var pickList = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
                var lloop    = loop;
                RunUI(() =>
                {
                    pickList.ApplyFilter(false);
                    switch (lloop)
                    {
                    default:
                        pickList.SetItemChecked(0, true);     // 0th item is M transition
                        break;

                    case 1:
                        pickList.SetItemChecked(0, true);     // 0th item is the M-1 transition
                        pickList.SetItemChecked(1, true);     // 1th item is the M transition
                        break;
                    }
                    pickList.AutoManageChildren = false;
                    pickList.IsSynchSiblings    = true; // Cause a precursor transition to be added to heavy group
                });
                OkDialog(pickList, pickList.OnOk);
                WaitForClosedForm(pickList);
                doc = WaitForDocumentChange(doc);
                switch (loop)
                {
                default:
                    // There should now be a precursor transition for the second, heavy labeled transition group, and it
                    // should match the mz of the transition group
                    Assert.AreEqual(2, doc.MoleculeTransitions.Count());
                    Assert.AreNotEqual(doc.MoleculeTransitionGroups.ToArray()[0].PrecursorMz, doc.MoleculeTransitions.ToArray()[1].Mz);
                    Assert.AreEqual(doc.MoleculeTransitionGroups.ToArray()[1].PrecursorMz, doc.MoleculeTransitions.ToArray()[1].Mz);
                    break;

                case 1:
                    // There should now be two precursor transitions M-1 and M for the second, heavy labeled transition group, and the
                    // second precursor transition should match the mz of the transition group
                    Assert.AreEqual(4, doc.MoleculeTransitions.Count());
                    Assert.AreNotEqual(doc.MoleculeTransitionGroups.ToArray()[0].PrecursorMz, doc.MoleculeTransitions.ToArray()[3].Mz);
                    Assert.AreEqual(doc.MoleculeTransitionGroups.ToArray()[1].PrecursorMz, doc.MoleculeTransitions.ToArray()[3].Mz);
                    break;
                }
            }

            //
            // Now with isotope distributions
            //
            var documentPath = TestFilesDir.GetTestPath("ions_testing_isotopes.sky");

            RunUI(() => SkylineWindow.OpenFile(documentPath));
            var newDoc = WaitForDocumentLoaded();

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

            RunUI(() =>
            {
                transitionSettingsFilter.SelectedTab = TransitionSettingsUI.TABS.Filter;
                transitionSettingsFilter.SmallMoleculeFragmentTypes    = "p";     // Allow precursors
                transitionSettingsFilter.SmallMoleculePrecursorAdducts = "[M+H]"; // Allow precursors
            });
            OkDialog(transitionSettingsFilter, transitionSettingsFilter.OkDialog);
            newDoc = WaitForDocumentChange(newDoc);

            SelectNode(SrmDocument.Level.Molecules, 0);

            Assert.AreEqual(molCount, SkylineWindow.Document.MoleculeCount);
            RunUI(SkylineWindow.ExpandPrecursors);

            Settings.Default.SynchronizeIsotopeTypes = true;

            // Select the first transition group
            SelectNode(SrmDocument.Level.TransitionGroups, 0);

            // Add isotope labeled precursor transitions to it
            var pickList0 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                pickList0.ApplyFilter(false);
                pickList0.SetItemChecked(0, true);
                pickList0.SetItemChecked(1, true);
                pickList0.SetItemChecked(2, true);
                pickList0.AutoManageChildren = false;
                Assert.IsTrue(pickList0.CanSynchSiblings);
                pickList0.IsSynchSiblings = true; // Cause precursor transitions to be added to heavy group
            });
            OkDialog(pickList0, pickList0.OnOk);
            WaitForClosedForm(pickList0);
            Assert.AreEqual(SkylineWindow.Document.MoleculeTransitionGroups.ToArray()[1].PrecursorMz,
                            SkylineWindow.Document.MoleculeTransitions.ToArray()[4].Mz);
            Assert.AreEqual(SkylineWindow.Document.MoleculeTransitionGroups.ToArray()[1].PrecursorMz + 1.003492,
                            SkylineWindow.Document.MoleculeTransitions.ToArray()[5].Mz, 1e-6);

            // Verify that adding a custom transition prevents the synch siblings checkbox from appearing
            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                var node = SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode;
                SkylineWindow.SequenceTree.SelectedNode = node;
            });
            newDoc = WaitForDocumentChange(newDoc);
            var moleculeDlg   = ShowDialog <EditCustomMoleculeDlg>(SkylineWindow.AddSmallMolecule);
            var C12H12        = "C12H12";
            var testNametextA = "y1";

            RunUI(() =>
            {
                moleculeDlg.FormulaBox.Formula = C12H12;
                moleculeDlg.NameText           = testNametextA;
                moleculeDlg.Adduct             = Adduct.SINGLY_PROTONATED;
            });
            OkDialog(moleculeDlg, moleculeDlg.OkDialog);
            newDoc = WaitForDocumentChange(newDoc);
            var       compareIon   = new CustomIon(C12H12, Adduct.SINGLY_PROTONATED, null, null, testNametextA);
            const int transY1Index = 3;

            Assert.AreEqual(compareIon, newDoc.MoleculeTransitions.ElementAt(transY1Index).Transition.CustomIon);
            Assert.AreEqual(1, newDoc.MoleculeTransitions.ElementAt(transY1Index).Transition.Charge);
            var pickList1 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                pickList1.AutoManageChildren = true;
                Assert.IsFalse(pickList1.CanSynchSiblings);
            });
            OkDialog(pickList1, pickList1.OnOk);
            Assert.AreEqual(7, newDoc.MoleculeTransitions.Count());
            // Long as we're here, check mz filtering
            var transitionSettings = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);

            RunUI(() =>
            {
                transitionSettings.SelectedTab = TransitionSettingsUI.TABS.Instrument;
                transitionSettings.MinMz       = 160; // Should drop that custom ion
            });
            OkDialog(transitionSettings, transitionSettings.OkDialog);
            newDoc = WaitForDocumentChange(newDoc);
            Assert.AreEqual(6, newDoc.MoleculeTransitions.Count());
            RunUI(() => { SkylineWindow.Undo(); });
            newDoc = WaitForDocumentChange(newDoc);
            Assert.AreEqual(7, newDoc.MoleculeTransitions.Count());

            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                var node = SkylineWindow.SequenceTree.Nodes[0].FirstNode.Nodes[1];
                SkylineWindow.SequenceTree.SelectedNode = node;
            });
            var pickList2 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                Assert.IsFalse(pickList2.CanSynchSiblings); // The light set has a non-precursor transition
            });
            OkDialog(pickList2, pickList2.OnOk);

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

            RunUI(() =>
            {
                transitionSettings2.SelectedTab = TransitionSettingsUI.TABS.Instrument;
                transitionSettings2.MinMz       = 300; // Should drop that custom ion
            });
            OkDialog(transitionSettings2, transitionSettings2.OkDialog);
            newDoc = WaitForDocumentChange(newDoc);
            Assert.AreEqual(6, newDoc.MoleculeTransitions.Count());

            var pickList3 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                Assert.IsTrue(pickList3.CanSynchSiblings);
            });
            OkDialog(pickList3, pickList3.OnOk);

            // Add another precursor, with explicit isotope declaration in the adduct [M4C13+H]
            // Open its picklist, clear filter so all isotopes appear
            // Select them all, and check synch siblings
            // Should be 3*3 transitions in doc
            SelectNode(SrmDocument.Level.Molecules, 0);
            var moleculeDlg2 = ShowDialog <EditCustomMoleculeDlg>(SkylineWindow.AddSmallMolecule);
            var adduct       = moleculeDlg.FormulaBox.Adduct.ChangeIsotopeLabels(new Dictionary <string, int> {
                { "C'", 4 }
            });                                                                                                          // Not L10N

            RunUI(() =>
            {
                moleculeDlg2.Adduct = adduct;
            });
            OkDialog(moleculeDlg2, moleculeDlg2.OkDialog);
            newDoc = WaitForDocumentChange(newDoc);
            // Select the new transition group
            SelectNode(SrmDocument.Level.TransitionGroups, 2);
            // Add precursor transition to it
            var pickList4 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                pickList4.ApplyFilter(false);
                pickList4.SetItemChecked(0, true);
                pickList4.SetItemChecked(1, true);
                pickList4.SetItemChecked(2, true);
                pickList4.AutoManageChildren = false;
                pickList4.IsSynchSiblings    = true; // Cause a precursor transition to be added to heavy group
            });
            OkDialog(pickList4, pickList4.OnOk);
            WaitForClosedForm(pickList4);
            newDoc = WaitForDocumentChange(newDoc);
            Assert.AreEqual(9, newDoc.MoleculeTransitionCount);
        }
Esempio n. 10
0
        protected override void DoTest()
        {
            RunUI(() =>
            {
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath("SimpleRatiosTest.sky"));
                SkylineWindow.ExpandPrecursors();
            });
            Assert.IsFalse(SkylineWindow.Document.Settings.PeptideSettings.Quantification.SimpleRatios);
            Assert.AreEqual(new NormalizationMethod.RatioToLabel(IsotopeLabelType.heavy),
                            SkylineWindow.Document.Settings.PeptideSettings.Quantification.NormalizationMethod);
            PeptideTreeNode         peptideTreeNode = (PeptideTreeNode)SkylineWindow.SequenceTree.Nodes[0].Nodes[0];
            TransitionGroupTreeNode lightTreeNode   =
                (TransitionGroupTreeNode)peptideTreeNode.Nodes[0];
            TransitionGroupTreeNode heavyTreeNode = (TransitionGroupTreeNode)peptideTreeNode.Nodes[1];
            var lightTransitionAreas =
                lightTreeNode.DocNode.Transitions.Select(tran => tran.Results[0][0].Area).ToList();

            Assert.AreEqual(4, lightTransitionAreas.Count);
            var heavyTransitionAreas =
                heavyTreeNode.DocNode.Transitions.Select(tran => tran.Results[0][0].Area).ToList();

            Assert.AreEqual(2, heavyTransitionAreas.Count);
            // Verify that only the first two transition areas in both precursors contribute to the displayed ratio
            var expectedRatio = lightTransitionAreas.Take(2).Sum() / heavyTransitionAreas.Sum();

            StringAssert.Contains(lightTreeNode.Text, GetTransitionGroupRatioText(expectedRatio));

            RunUI(() =>
            {
                SkylineWindow.ShowResultsGrid(true);
                SkylineWindow.SelectedPath = peptideTreeNode.Path;
            });
            var resultsGridForm = FindOpenForm <LiveResultsGrid>();

            WaitForConditionUI(() => resultsGridForm.IsComplete);
            RunDlg <ViewEditor>(resultsGridForm.DataboundGridControl.NavBar.CustomizeView, viewEditor =>
            {
                viewEditor.ChooseColumnsTab.AddColumn(propertyPathNormalizedArea);
                viewEditor.ViewName = "PeptideResultsWithNormalizedArea";
                viewEditor.OkDialog();
            });
            VerifyExpectedRatio(resultsGridForm, expectedRatio);

            RunDlg <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsUi =>
            {
                peptideSettingsUi.SimpleRatios = true;
                peptideSettingsUi.OkDialog();
            });
            Assert.IsTrue(SkylineWindow.Document.Settings.PeptideSettings.Quantification.SimpleRatios);


            // When SimpleRatios is true, verify that all transitions contribute to the ratio
            expectedRatio = lightTransitionAreas.Sum() / heavyTransitionAreas.Sum();
            StringAssert.Contains(lightTreeNode.Text, GetTransitionGroupRatioText(expectedRatio));

            VerifyExpectedRatio(resultsGridForm, expectedRatio);

            // Verify that deleting a transition from the light precursor does not affect the heavy precursor
            Assert.AreEqual(4, lightTreeNode.DocNode.TransitionCount);
            Assert.AreEqual(2, heavyTreeNode.DocNode.TransitionCount);
            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedPaths = new[]
                { SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Transitions, 0) };
                SkylineWindow.EditDelete();
            });

            Assert.AreEqual(3, lightTreeNode.DocNode.TransitionCount);
            Assert.AreEqual(2, heavyTreeNode.DocNode.TransitionCount);

            expectedRatio = lightTransitionAreas.Skip(1).Sum() / heavyTransitionAreas.Sum();
            StringAssert.Contains(lightTreeNode.Text, GetTransitionGroupRatioText(expectedRatio));

            RunUI(() => SkylineWindow.SelectedPath = peptideTreeNode.Path);
            VerifyExpectedRatio(resultsGridForm, expectedRatio);
        }
Esempio n. 11
0
        protected override void DoTest()
        {
            TestSmallMolecules = false; // The presence of the extra test node without any results is incompatible with what's being tested here.

            // Clean-up before running the test
            RunUI(() => SkylineWindow.ModifyDocument("Set default settings",
                                                     d => d.ChangeSettings(SrmSettingsList.GetDefault())));

            SrmDocument doc = SkylineWindow.Document;

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

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

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

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

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

            // We're on the "Build Spectral Library" page of the wizard.
            // Add the test xml file to the search files list and try to
            // build the document library.
            string[] searchFiles =
            {
                GetTestPath("100803_0001_MCF7_TiB_L.group.xml"),      // Not L10N
                GetTestPath("100803_0005b_MCF7_TiTip3.group.xml")     // Not L10N
            };
            PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library empty page", 3);

            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage ==
                              ImportPeptideSearchDlg.Pages.spectra_page);
                importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles);
            });
            PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library populated page", 4);

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

            OkDialog(ambiguousDlg, ambiguousDlg.OkDialog);

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

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

            Assert.IsTrue(librarySettings.HasDocumentLibrary);

            // We're on the "Extract Chromatograms" page of the wizard.
            // All the test results files are in the same directory as the
            // document file, so all the files should be found, and we should
            // just be able to move to the next page.
            WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page);
            PauseForScreenShot <ImportPeptideSearchDlg.ChromatogramsPage>("Import Peptide Search - Extract Chromatograms page", 5);

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

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

            OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog);

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

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

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

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

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

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

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

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

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

            WaitForCondition(() => peptidesPerProteinDlg.DocumentFinalCalculated);
            RunUI(() =>
            {
                int proteinCount, peptideCount, precursorCount, transitionCount;
                peptidesPerProteinDlg.NewTargetsAll(out proteinCount, out peptideCount, out precursorCount, out transitionCount);
                Assert.AreEqual(11, proteinCount);
                Assert.AreEqual(51, peptideCount);
                Assert.AreEqual(52, precursorCount);
                Assert.AreEqual(156, transitionCount);
                peptidesPerProteinDlg.NewTargetsFinal(out proteinCount, out peptideCount, out precursorCount, out transitionCount);
                Assert.AreEqual(11, proteinCount);
                Assert.AreEqual(51, peptideCount);
                Assert.AreEqual(52, precursorCount);
                Assert.AreEqual(156, transitionCount);
            });
            OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog);
            PauseForScreenShot <AllChromatogramsGraph>("Loading chromatograms window", 11);
            WaitForDocumentChangeLoaded(doc, 8 * 60 * 1000); // 10 minutes

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

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

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

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

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

            // Select the first transition group.
            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedPath =
                    SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 0);
                SkylineWindow.GraphSpectrumSettings.ShowAIons        = true;
                SkylineWindow.GraphSpectrumSettings.ShowBIons        = true;
                SkylineWindow.GraphSpectrumSettings.ShowYIons        = true;
                SkylineWindow.GraphSpectrumSettings.ShowPrecursorIon = true;
                SkylineWindow.ExpandPrecursors();
                SkylineWindow.ChangeTextSize(TreeViewMS.LRG_TEXT_FACTOR);
            });
            RunDlg <SpectrumChartPropertyDlg>(SkylineWindow.ShowSpectrumProperties, dlg =>
            {
                dlg.FontSize = GraphFontSize.NORMAL;
                dlg.OkDialog();
            });
            RunDlg <ChromChartPropertyDlg>(SkylineWindow.ShowChromatogramProperties, dlg =>
            {
                dlg.FontSize = GraphFontSize.NORMAL;
                dlg.OkDialog();
            });
            RunUI(() =>
            {
                // Make window screenshot size
                if (IsPauseForScreenShots && SkylineWindow.WindowState != FormWindowState.Maximized)
                {
                    SkylineWindow.Width  = 1160;
                    SkylineWindow.Height = 792;
                }
            });
            RestoreViewOnScreen(13);
            PauseForScreenShot("Main window with imported data", 14);

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

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

            int atest = 0;

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

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

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

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

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

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

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

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

            ChangePeakBounds(TIB_L, pepIndex, 36.5, 38.0);

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

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

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

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

            RevertDoc(undoIndex);                             // undo changes
            pepIndex = JumpToPeptide("ASLGSLEGEAEAEASSPKGK"); // Not L10N
            Assert.IsTrue(10 == pepIndex);
            PauseForScreenShot("Chhromatogram graph meta files for peptide ASLGSLEGEAEAEASSPKGK", 26);
            CheckAnnotations(TIB_L, pepIndex, atest++);
            CheckAnnotations(TIP3, pepIndex, atest++);

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

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

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

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

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

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

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

            RestoreViewOnScreen(33);                                                                                                      // float the  Library Match window TODO this causes a crash at next call to ChangePeakBounds, in pwiz.Skyline.Controls.Graphs.GraphChromatogram.ChromGroupInfos.get() Line 492 , why?
            RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(MsDataFileUri.Parse(Tip3Filename), 37.6076f))); // set the Library Match view
            PauseForScreenShot <GraphSpectrum>("Library Match graph metafile - 5b_MCF7_TiTip3 (37.61 Min)", 33);

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

            RestoreViewOnScreen(34);                    // back to normal view

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

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

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

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

            var docAfter = WaitForProteinMetadataBackgroundLoaderCompletedUI();

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

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

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

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

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

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

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

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

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

            RunUI(() => SkylineWindow.SaveDocument());
            RunUI(SkylineWindow.NewDocument);
        }
Esempio n. 12
0
        protected override void DoTest()
        {
            RunUI(() =>
            {
                SkylineWindow.ResetDefaultSettings();
                SkylineWindow.NewDocument();
            });
            ShowAndPositionAuditLog(false);
            PauseForScreenShot <AuditLogForm>("Empty Audit Log form.", 2);

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

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

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

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

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

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

            OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);

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

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

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

            RunUI(SkylineWindow.Undo);

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

            RunUI(SkylineWindow.Redo);

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

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

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

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

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

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

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

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

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

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

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

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

            WaitForGraphs();

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

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

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

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

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

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

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

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

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

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

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

            ClipboardEx.SetText(pasteString);

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

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

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

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

            const string unknownReplicate = "FOXN1-GST";

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

            PauseForScreenShot("Heavy precursor chromatogram", 13);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                RestoreCoverViewOnScreen();

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

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

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

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

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

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

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

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

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

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

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

                OkDialog(browserConfirmationDialog, browserConfirmationDialog.ClickYes);

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

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

                string docId      = reDocId.Match(publishDialog.PanoramaPublishClient.UploadedDocumentUri.ToString()).Groups[1].Captures[0].Value;
                Uri    serverUri  = new Uri(SERVER_URL);
                Uri    requestUri = PanoramaUtil.Call(serverUri, "targetedms", String.Format("{0}/{1}", PANORAMA_FOLDER, testFolderName),
                                                      "showSkylineAuditLog", "id=" + docId);
                Process.Start(requestUri.ToString());
                PauseForScreenShot("Uploaded document audit log in Panorama (in browser).");
            }
        }
Esempio n. 13
0
        protected override void DoTest()
        {
            const int molCount = 1;
            var       doc      = SkylineWindow.Document;

            for (var loop = 0; loop < 3; loop++)
            {
                // Should be able to synchronize of both sibs have formula, or neither, but not one of each
                string testname;
                switch (loop)
                {
                case 0:
                    testname = "ions_testing_mixed.sky";
                    break;

                case 1:
                    testname = "ions_testing.sky";
                    break;

                default:
                    testname = "ions_testing_masses.sky";
                    break;
                }
                string testPath = TestFilesDir.GetTestPath(testname);
                RunUI(() => SkylineWindow.OpenFile(testPath));
                doc = WaitForDocumentChange(doc);

                SelectNode(SrmDocument.Level.Molecules, 0);

                Assert.AreEqual(molCount, SkylineWindow.Document.MoleculeCount);
                RunUI(SkylineWindow.ExpandPrecursors);

                Settings.Default.SynchronizeIsotopeTypes = true;

                // Select the first transition group
                SelectNode(SrmDocument.Level.TransitionGroups, 0);

                // Add precursor transition to it
                var pickList = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
                RunUI(() =>
                {
                    pickList.ApplyFilter(false);
                    pickList.SetItemChecked(0, true);
                    pickList.AutoManageChildren = false;
                    pickList.IsSynchSiblings    = true; // Cause a precursor transition to be added to heavy group
                });
                OkDialog(pickList, pickList.OnOk);
                WaitForClosedForm(pickList);
                doc = WaitForDocumentChange(doc);
                if (loop == 0)
                {
                    // No synch is possible - one ion is formula based, the other mass only
                    Assert.AreEqual(1, doc.MoleculeTransitions.Count());
                }
                else
                {
                    // There should now be a precursor transition for the second, heavy labeled transition group, and it
                    // should match the mz of the transition group
                    Assert.AreNotEqual(doc.MoleculeTransitionGroups.ToArray()[0].PrecursorMz, doc.MoleculeTransitions.ToArray()[1].Mz);
                    Assert.AreEqual(doc.MoleculeTransitionGroups.ToArray()[1].PrecursorMz, doc.MoleculeTransitions.ToArray()[1].Mz);
                }
            }

            //
            // Now with isotope distributions
            //
            var documentPath = TestFilesDir.GetTestPath("ions_testing_isotopes.sky");

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

            SelectNode(SrmDocument.Level.Molecules, 0);

            Assert.AreEqual(molCount, SkylineWindow.Document.MoleculeCount);
            RunUI(SkylineWindow.ExpandPrecursors);

            Settings.Default.SynchronizeIsotopeTypes = true;

            // Select the first transition group
            SelectNode(SrmDocument.Level.TransitionGroups, 0);

            // Add isotope labeled precursor transitions to it
            var pickList0 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                pickList0.ApplyFilter(false);
                pickList0.SetItemChecked(0, true);
                pickList0.SetItemChecked(1, true);
                pickList0.SetItemChecked(2, true);
                pickList0.AutoManageChildren = false;
                Assert.IsTrue(pickList0.CanSynchSiblings);
                pickList0.IsSynchSiblings = true; // Cause precursor transitions to be added to heavy group
            });
            OkDialog(pickList0, pickList0.OnOk);
            WaitForClosedForm(pickList0);
            Assert.AreEqual(SkylineWindow.Document.MoleculeTransitionGroups.ToArray()[1].PrecursorMz,
                            SkylineWindow.Document.MoleculeTransitions.ToArray()[4].Mz);
            Assert.AreEqual(SkylineWindow.Document.MoleculeTransitionGroups.ToArray()[1].PrecursorMz + 1.00349556477,
                            SkylineWindow.Document.MoleculeTransitions.ToArray()[5].Mz, 1e-6);

            // Verify that adding a custom transition prevents the synch siblings checkbox from appearing
            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                var node = SkylineWindow.SequenceTree.Nodes[0].FirstNode.FirstNode;
                SkylineWindow.SequenceTree.SelectedNode = node;
            });
            var moleculeDlg   = ShowDialog <EditCustomMoleculeDlg>(SkylineWindow.AddSmallMolecule);
            var C12H12        = "C12H12";
            var testNametextA = "y1";

            RunUI(() =>
            {
                moleculeDlg.FormulaBox.Formula = C12H12;
                moleculeDlg.NameText           = testNametextA;
                moleculeDlg.Charge             = 1;
            });
            OkDialog(moleculeDlg, moleculeDlg.OkDialog);
            var       newDoc       = SkylineWindow.Document;
            var       compareIon   = new DocNodeCustomIon(C12H12, testNametextA);
            const int transY1Index = 3;

            Assert.AreEqual(compareIon, newDoc.MoleculeTransitions.ElementAt(transY1Index).Transition.CustomIon);
            Assert.AreEqual(1, newDoc.MoleculeTransitions.ElementAt(transY1Index).Transition.Charge);
            var pickList1 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                pickList1.AutoManageChildren = true;
                Assert.IsFalse(pickList1.CanSynchSiblings);
            });
            OkDialog(pickList1, pickList1.OnOk);
            Assert.AreEqual(7, newDoc.MoleculeTransitions.Count());

            // Long as we're here, check mz filtering
            var transitionSettings = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);

            RunUI(() =>
            {
                transitionSettings.SelectedTab = TransitionSettingsUI.TABS.Instrument;
                transitionSettings.MinMz       = 160; // Should drop that custom ion
            });
            OkDialog(transitionSettings, transitionSettings.OkDialog);
            newDoc = WaitForDocumentChange(newDoc);
            Assert.AreEqual(6, newDoc.MoleculeTransitions.Count());
            RunUI(() => { SkylineWindow.Undo(); });
            newDoc = WaitForDocumentChange(newDoc);
            Assert.AreEqual(7, newDoc.MoleculeTransitions.Count());

            RunUI(() =>
            {
                SkylineWindow.ExpandPrecursors();
                var node = SkylineWindow.SequenceTree.Nodes[0].FirstNode.Nodes[1];
                SkylineWindow.SequenceTree.SelectedNode = node;
            });
            var pickList2 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                Assert.IsFalse(pickList2.CanSynchSiblings); // The light set has a non-precursor transition
            });
            OkDialog(pickList2, pickList2.OnOk);

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

            RunUI(() =>
            {
                transitionSettings2.SelectedTab = TransitionSettingsUI.TABS.Instrument;
                transitionSettings2.MinMz       = 300; // Should drop that custom ion
            });
            OkDialog(transitionSettings2, transitionSettings2.OkDialog);
            newDoc = WaitForDocumentChange(newDoc);
            Assert.AreEqual(6, newDoc.MoleculeTransitions.Count());

            var pickList3 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);

            RunUI(() =>
            {
                Assert.IsTrue(pickList3.CanSynchSiblings);
            });
            OkDialog(pickList3, pickList3.OnOk);
        }
        protected override void DoTest()
        {
            // Clean-up before running the test
            RunUI(() => SkylineWindow.ModifyDocument("Set default settings",
                                                     d => d.ChangeSettings(SrmSettingsList.GetDefault())));

            SrmDocument doc = SkylineWindow.Document;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog);

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

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

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

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

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

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

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

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

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

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

            var allChromGraph = WaitForOpenForm <AllChromatogramsGraph>();

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

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

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

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

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

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

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

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

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

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

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

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

            int atest = 0;

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

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

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

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

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

            const string TIP_NAME = "5b_MCF7_TiTip3";

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

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

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

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

            ChangePeakBounds(TIB_L, pepIndex, 36.5, 38.0);

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

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

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

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

            RevertDoc(undoIndex); // undo changes

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            var docAfter = WaitForProteinMetadataBackgroundLoaderCompletedUI();

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

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

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

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

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

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

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

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

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

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

            RunUI(() => SkylineWindow.SaveDocument());
            RunUI(SkylineWindow.NewDocument);
        }
        private void TofTest()
        {
            // Working wih High-Resolution Mass Spectra.

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

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

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

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

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


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

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

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

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

            var document = SkylineWindow.Document;

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

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

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

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

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }

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

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

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

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

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

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

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

                OkDialog(peptideSettingsUI, peptideSettingsUI.CancelDialog);
            }

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

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

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }

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

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

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

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

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

            RunUI(SkylineWindow.AutoZoomBestPeak);
            WaitForGraphs();

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

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

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

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

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

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

            RunUI(() => SkylineWindow.SaveDocument());
            WaitForConditionUI(() => !SkylineWindow.Dirty);
        }
        private void LowResTest()
        {
            string documentFile = GetTestPath(@"Low Res\BSA_Protea_label_free_meth3.sky");

            WaitForCondition(() => File.Exists(documentFile));
            RunUI(() => SkylineWindow.OpenFile(documentFile));
            bool AsSmallMolecules = AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.none;

            const int expectedMoleculeCount        = 9;
            int       expectedTransitionGroupCount = 10;
            int       expectedTransitionCount      = 78;
            var       document = SkylineWindow.Document;

            if (AsSmallMolecules)
            {
                ConvertDocumentToSmallMolecules(AsSmallMoleculesTestMode);
                document = SkylineWindow.Document;
                Assert.AreEqual(document.PeptideTransitionGroupCount, 0);
                Assert.AreEqual(document.MoleculeTransitionGroupCount, expectedTransitionGroupCount);
                Assert.AreEqual(document.PeptideTransitionCount, 0);
                Assert.AreEqual(document.MoleculeTransitionCount, expectedTransitionCount);
            }
            AssertEx.IsDocumentState(document, null, 3, expectedMoleculeCount, expectedTransitionGroupCount, expectedTransitionCount);

            // p. 3 Select first peptide
            RunUI(() => SkylineWindow.SelectedPath = document.GetPathTo((int)SrmDocument.Level.Molecules, 0));
            PauseForScreenShot("Main window", 3);

            // p. 4 Configure Document for Thermo raw files
            {
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() => transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.FullScan);
                PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Peptide Settings - Full-Scan tab blank", 5);

                RunUI(() =>
                {
                    transitionSettingsUI.PrecursorIsotopesCurrent = FullScanPrecursorIsotopes.Count;
                    transitionSettingsUI.PrecursorMassAnalyzer    = FullScanMassAnalyzerType.qit;
                    transitionSettingsUI.AcquisitionMethod        = FullScanAcquisitionMethod.Targeted;
                });
                PauseForScreenShot <TransitionSettingsUI.FullScanTab>("Peptide Settings - Full-Scan tab low res", 6);

                RunUI(() =>
                {
                    transitionSettingsUI.SetRetentionTimeFilter(RetentionTimeFilterType.ms2_ids, 2);

                    // p.6 - library ion match tolerance same as extraction window
                    transitionSettingsUI.SelectedTab       = TransitionSettingsUI.TABS.Library;
                    transitionSettingsUI.IonMatchTolerance = 0.7;
                });
                PauseForScreenShot <TransitionSettingsUI.LibraryTab>("Transition Settings - Library tab match tolerance same as MS/MS resolution", 8);

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

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);

                var docFullScan          = WaitForDocumentChange(document);
                var tranSettingsFullScan = docFullScan.Settings.TransitionSettings;
                Assert.AreEqual(FullScanPrecursorIsotopes.Count, tranSettingsFullScan.FullScan.PrecursorIsotopes);
                Assert.AreEqual(FullScanMassAnalyzerType.qit, tranSettingsFullScan.FullScan.PrecursorMassAnalyzer);
                Assert.AreEqual(FullScanAcquisitionMethod.Targeted, tranSettingsFullScan.FullScan.AcquisitionMethod);
                Assert.IsTrue(ArrayUtil.EqualsDeep(new[] { IonType.y, IonType.b, IonType.precursor },
                                                   tranSettingsFullScan.Filter.IonTypes));
            }

            RunUI(() => SkylineWindow.ExpandPrecursors());

            // Check all the precursors on picklists
            bool pausedForScreenShot = false;

            foreach (PeptideGroupTreeNode node in SkylineWindow.SequenceTree.GetSequenceNodes())
            {
                foreach (TreeNode child in node.Nodes)
                {
                    foreach (SrmTreeNodeParent grandChild in child.Nodes)
                    {
                        // Because of RunUI must copy to local variable first.
                        SrmTreeNodeParent child1 = grandChild;
                        RunUI(() => SkylineWindow.SequenceTree.SelectedNode = child1);
                        var picklist = ShowDialog <PopupPickList>(() => SkylineWindow.SequenceTree.ShowPickList(false));
                        RunUI(() =>
                        {
                            picklist.SetItemChecked(0, true);
                            Assert.IsTrue(picklist.GetItemLabel(0).Contains(IonType.precursor.GetLocalizedString()));
                            Assert.IsTrue(picklist.GetItemChecked(0));
                        });
                        if (!pausedForScreenShot)
                        {
                            PauseForScreenShot <PopupPickList>("Transitions popup pick-list", 10);
                            pausedForScreenShot = true;
                        }
                        OkDialog(picklist, picklist.OnOk);
                    }
                }
            }
            WaitForDocumentLoaded();
            if (!AsSmallMolecules)  // No libraries for small molecules, yet
            {
                foreach (var nodeGroup in SkylineWindow.Document.MoleculeTransitionGroups)
                {
                    Assert.IsFalse(nodeGroup.HasLibInfo && nodeGroup.Transitions.All(nodeTran => !nodeTran.HasLibInfo));
                }
            }
            // All transition groups should now have a precursor transition
            foreach (var nodeGroup in SkylineWindow.Document.MoleculeTransitionGroups)
            {
                Assert.AreEqual(IonType.precursor, nodeGroup.Transitions.First().Transition.IonType);
            }

            // p.8
            ExportMethodDlg exportMethodDlg =
                ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.Method));

            RunUI(() =>
            {
                exportMethodDlg.SetInstrument("Thermo LTQ");
                Assert.AreEqual("Thermo LTQ", exportMethodDlg.InstrumentType);
                exportMethodDlg.SetMethodType(ExportMethodType.Standard);
                exportMethodDlg.SetTemplateFile(GetTestPath(@"Low Res\TargetedMSMS_template.meth"));
            });
            PauseForScreenShot <ExportMethodDlg.MethodView>("Export Method form", 11);

            // p. 10 Ok the error box.
            {
                var messageDlg = ShowDialog <MessageDlg>(() => exportMethodDlg.OkDialog(GetTestPath(@"Low Res\TargetedMSMS_BSA_Protea.meth")));
                PauseForScreenShot <MessageDlg>("Error message (expected)", 12);

                OkDialog(messageDlg, messageDlg.OkDialog);
            }

            // Making a report by hand p.11
            ExportLiveReportDlg exportReportDlg = ShowDialog <ExportLiveReportDlg>(() => SkylineWindow.ShowExportReportDialog());
            var editReportListDlg = ShowDialog <ManageViewsForm>(exportReportDlg.EditList);
            var viewEditor        = ShowDialog <ViewEditor>(editReportListDlg.AddView);

            RunUI(() =>
            {
                Assert.IsTrue(viewEditor.ChooseColumnsTab.TrySelect(PropertyPath.Parse("Proteins!*.Name")));
                viewEditor.ChooseColumnsTab.AddSelectedColumn();
                Assert.AreEqual(1, viewEditor.ChooseColumnsTab.ColumnCount);
                var columnsToAdd = new[]
                {
                    PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.ModifiedSequence"),
                    PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.Charge"),
                    PropertyPath.Parse("Proteins!*.Peptides!*.Precursors!*.Mz"),
                };
                foreach (var id in columnsToAdd)
                {
                    Assert.IsTrue(viewEditor.ChooseColumnsTab.TrySelect(id), "Unable to select {0}", id);
                    viewEditor.ChooseColumnsTab.AddSelectedColumn();
                }
                Assert.AreEqual(4, viewEditor.ChooseColumnsTab.ColumnCount);
            });
            PauseForScreenShot <ViewEditor>("Edit Report form", 13);

            {
                var previewReportDlg = ShowDialog <DocumentGridForm>(viewEditor.ShowPreview);
                var expectedRows     = 10 + (TestSmallMolecules ? 1 : 0);
                WaitForConditionUI(() => previewReportDlg.IsComplete && previewReportDlg.RowCount == expectedRows);
                RunUI(() =>
                {
                    Assert.AreEqual(4, previewReportDlg.ColumnCount);
                    var precursors =
                        SkylineWindow.Document.MoleculeTransitionGroups.ToArray();
                    const int precursorIndex = 3;
                    for (int i = 0; i < expectedRows; i++)
                    {
                        Assert.AreEqual(precursors[i].PrecursorMz, double.Parse(previewReportDlg.DataGridView.Rows[i].Cells[precursorIndex].Value.ToString()), 0.000001);
                    }
                    var precursorMzCol = previewReportDlg.DataGridView.Columns[precursorIndex];
                    Assert.IsNotNull(precursorMzCol);
                    previewReportDlg.DataGridView.Sort(precursorMzCol, ListSortDirection.Ascending);
                });
                PauseForScreenShot <DocumentGridForm>("Preview New Report window", 14);

                OkDialog(previewReportDlg, previewReportDlg.Close);
            }

            // Press the Esc key until all forms have been dismissed.
            RunUI(() =>
            {
                viewEditor.Close();
                editReportListDlg.Close();
                exportReportDlg.CancelClick();
            });
            WaitForClosedForm(viewEditor);
            WaitForClosedForm(editReportListDlg);
            WaitForClosedForm(exportReportDlg);

            //p. 12 Import Full-Scan Data
            // Launch import peptide search wizard
            var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg);

            RunUI(() => importPeptideSearchDlg.BuildPepSearchLibControl.WorkflowType = ImportPeptideSearchDlg.Workflow.prm);

            PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search Build Spectral Library blank page", 15);

            const int    prefixLen             = 35;
            const string lowResDir             = "Low Res";
            const string searchDir             = "search";
            const string lowRes20Base          = "klc_20100329v_Protea_Peptide_Curve_20fmol_uL_tech1";
            string       lowRes20File          = GetTestPath(Path.Combine(lowResDir, lowRes20Base + ExtThermoRaw));
            string       lowRes20FileRaw       = Path.ChangeExtension(lowRes20File, ExtThermoRaw);
            string       lowRes20Search        = GetTestPath(Path.Combine(lowResDir, Path.Combine(searchDir, lowRes20Base + BiblioSpecLiteBuilder.EXT_PERCOLATOR)));
            string       shortLowRes20FileName = (Path.GetFileNameWithoutExtension(lowRes20File) ?? "").Substring(prefixLen);
            const string lowRes80Base          = "klc_20100329v_Protea_Peptide_Curve_80fmol_uL_tech1";
            string       lowRes80File          = GetTestPath(Path.Combine(lowResDir, lowRes80Base + ExtThermoRaw));
            string       lowRes80Search        = GetTestPath(Path.Combine(lowResDir, Path.Combine(searchDir, lowRes80Base + BiblioSpecLiteBuilder.EXT_PERCOLATOR)));
            string       shortLowRes80FileName = (Path.GetFileNameWithoutExtension(lowRes80File) ?? "").Substring(prefixLen);

            string[] searchFiles = { lowRes20Search, lowRes80Search };
            var      doc         = SkylineWindow.Document;

            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage ==
                              ImportPeptideSearchDlg.Pages.spectra_page);
                importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles);
                importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.99;
                importPeptideSearchDlg.BuildPepSearchLibControl.FilterForDocumentPeptides = true;
            });
            PauseForScreenShot <ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search Build Spectral Library with files page", 16);

            RunDlg <MessageDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck, dlg => dlg.OkDialog());
            doc = WaitForDocumentChangeLoaded(doc);

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

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

            Assert.IsTrue(librarySettings.HasDocumentLibrary);

            PauseForScreenShot <ImportPeptideSearchDlg.ChromatogramsPage>("Import Peptide Search Extract Chromatograms page", 17);

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

            ImportPeptideSearchDlg.Pages currentPage = 0;
            RunUI(() => correctPage = ImportPeptideSearchDlg.Pages.chromatograms_page == (currentPage = importPeptideSearchDlg.CurrentPage));
            if (!correctPage)
            {
                WaitForConditionUI(1, // Immediate timeout - just want the richer error message that WaitForConditionUI provides
                                   () => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page,
                                   string.Format("Expected to be on chromatograms_page, on {0} instead", currentPage));
            }
            var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(() => importPeptideSearchDlg.ClickNextButton());

            OkDialog(importResultsNameDlg, importResultsNameDlg.YesDialog);

            // Modifications are already set up, so that page should get skipped.

            // We're on the "Configure Transition Settings" page of the wizard.
            // We've already set up these settings, so just click next.
            WaitForConditionUI(() => importPeptideSearchDlg.IsNextButtonEnabled);
            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.transition_settings_page);
                Assert.IsTrue(importPeptideSearchDlg.ClickNextButton());
            });

            // We're on the "Configure Full-Scan Settings" page of the wizard.
            // We've already set up these settings, so just click next.
            WaitForConditionUI(() => importPeptideSearchDlg.IsNextButtonEnabled);
            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.full_scan_settings_page);
                Assert.IsTrue(importPeptideSearchDlg.ClickNextButton());
            });
            doc = WaitForDocumentChange(doc);

            // Add FASTA also skipped because filter for document peptides was chosen.

            WaitForClosedForm(importPeptideSearchDlg);
            PauseForScreenShot <AllChromatogramsGraph>("Loading chromatograms window", 18);
            WaitForDocumentChangeLoaded(doc, 15 * 60 * 1000); // 15 minutes
            WaitForClosedAllChromatogramsGraph();

            expectedTransitionGroupCount = 10; // Expect this many with results
            expectedTransitionCount      = 87; // Expect this many with results
            AssertResult.IsDocumentResultsState(SkylineWindow.Document, shortLowRes20FileName, expectedMoleculeCount, expectedTransitionGroupCount, 0, expectedTransitionCount, 0);
            AssertResult.IsDocumentResultsState(SkylineWindow.Document, shortLowRes80FileName, expectedMoleculeCount, expectedTransitionGroupCount, 0, expectedTransitionCount, 0);

            RunUI(() =>
            {
                Assert.IsTrue(SkylineWindow.IsGraphSpectrumVisible);
                SkylineWindow.ArrangeGraphsTiled();
                SkylineWindow.CollapsePrecursors();
                SkylineWindow.Width = 1070;
            });

            // Select the first precursor.
            if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only)
            {
                FindNode(AsSmallMolecules ? "LVNELTEFAK" : "K.LVNELTEFAK.T [65, 74]");
            }
            else
            {
                FindNode(document.MoleculeTransitionGroups.First().CustomIon.DisplayName);
            }
            // Ensure Graphs look like p17. (checked)
            WaitForGraphs();
            RestoreViewOnScreen(18);
            PauseForScreenShot("Main window with data imported", 19);

            const double minDotp = 0.9;

            foreach (var nodeGroup in SkylineWindow.Document.PeptideTransitionGroups)
            {
                double dotp = nodeGroup.Results[0][0].LibraryDotProduct ?? 0;
                Assert.IsTrue(Math.Round(dotp, 2) >= minDotp, string.Format("Library dot-product {0} found below {1}", dotp, minDotp));
            }

            RunUI(() => SkylineWindow.AutoZoomBestPeak());
            // Ensure Graphs look like p18. (checked)
            WaitForGraphs();
            PauseForScreenShot("Chromatogram graphs clipped from main window with zoomed peaks", 20);

            RestoreViewOnScreen(21);
            RunUI(() => SkylineWindow.GraphSpectrum.SelectSpectrum(new SpectrumIdentifier(lowRes20FileRaw, 77.7722)));
            PauseForScreenShot <GraphSpectrum>("Library Match view clipped from main window with noisy spectrum", 21);

            RunUI(() =>
            {
                SkylineWindow.ShowGraphSpectrum(false);
                Assert.IsFalse(SkylineWindow.IsGraphSpectrumVisible);
                SkylineWindow.ShowPeptideIDTimes(false);
            });

            RunUI(() =>
            {
                var chromGraphs = SkylineWindow.GraphChromatograms.ToArray();
                Assert.AreEqual(2, chromGraphs.Length);
                Assert.AreEqual(46.8, chromGraphs[0].GraphItems.First().BestPeakTime, 0.05);
                Assert.AreEqual(46.8, chromGraphs[1].GraphItems.First().BestPeakTime, 0.05);

                SkylineWindow.ShowPeakAreaReplicateComparison();
                SkylineWindow.ShowProductTransitions();
            });
            WaitForCondition(() => !SkylineWindow.GraphPeakArea.IsHidden);
            if (!AsSmallMolecules)  // No libraries (yet?)
            {
                WaitForDotProducts();
            }
            RunUI(() =>
            {
                // Graph p.15
                Assert.AreEqual(AsSmallMolecules ? 2 : 3, SkylineWindow.GraphPeakArea.Categories.Count());
                Assert.AreEqual(6, SkylineWindow.GraphPeakArea.CurveCount);
            });
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas Replicate Comparison graph metafile", 22);
            if (!AsSmallMolecules)  // No libraries (yet?)
            {
                VerifyDotProducts(0.99, 0.98);
            }

            // Check graph p15. (checked)
            RunUI(() =>
            {
                SkylineWindow.ShowAllTransitions();
                SkylineWindow.ShowSplitChromatogramGraph(true);
            });

            // p. 16 screenshot of full 5-point dilution curve

            // Select precursor
            if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only)
            {
                FindNode(AsSmallMolecules ? "DRVYIHPF" : "R.DRVYIHPF.- [34, 41]");  // May be localized " (missed 1)"
            }
            else
            {
                FindNode(Resources.CustomIon_DisplayName_Ion + " [1047");
            }
            WaitForGraphs();
            PauseForScreenShot <GraphSummary.AreaGraphView>("Peak Areas Replicate Comparison graph metafile with split graphs", 24);
            RunUI(() =>
            {
                SkylineWindow.Size = new Size(990, 620);
                SkylineWindow.ShowGraphPeakArea(false);
            });
            PauseForScreenShot("Chromatogram graphs clipped from main window with split graphs", 25);

            // PeakAreaGraph Normalize to total p.20.
            RunUI(() =>
            {
                SkylineWindow.ShowGraphPeakArea(true);
                SkylineWindow.ShowProductTransitions();
                SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_percent_view);
            });

            // Ensure graph looks like p20.
            if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only)
            {
                FindNode(AsSmallMolecules ? "KNLQSLDPSH" : "R.IKNLQSLDPSH.- [80, 90]");
                FindNode(AsSmallMolecules ? "KNLQSLDPSH" : "R.IKNLQSLDPSH.- [80, 90]"); // Phosphorylated
            }
            else
            {
                FindNode(Resources.CustomIon_DisplayName_Ion + " [1333");
            }
            WaitForGraphs();
            PauseForScreenShot <GraphSummary.AreaGraphView>("figure 1a - Area Replicate graph metafile for IKNLQSLDPSH", 26);
            RunUI(() =>
            {
                Assert.AreEqual(AsSmallMolecules ? 2 : 3, SkylineWindow.GraphPeakArea.Categories.Count());
                Assert.AreEqual(9, SkylineWindow.GraphPeakArea.CurveCount);
            });

            if (AsSmallMoleculesTestMode != RefinementSettings.ConvertToSmallMoleculesMode.masses_only)
            {
                FindNode(AsSmallMolecules ? "HLVDEPQNLIK" : "K.HLVDEPQNLIK.Q [401, 411]");
            }
            else
            {
                FindNode(Resources.CustomIon_DisplayName_Ion + " [1306");
            }
            WaitForGraphs();
            PauseForScreenShot("figure 1b - Area replicate graph metafile for HLVDEPQNLIK", 26);
            RunUI(() =>
            {
                Assert.AreEqual(AsSmallMolecules ? 2 : 3, SkylineWindow.GraphPeakArea.Categories.Count());
                Assert.AreEqual(7, SkylineWindow.GraphPeakArea.CurveCount);
            });

            RunUI(() => SkylineWindow.ShowGraphPeakArea(false));
            WaitForCondition(() => SkylineWindow.GraphPeakArea.IsHidden);
            RunUI(() => SkylineWindow.SaveDocument());
        }