Beispiel #1
0
        public void Wiff2ResultsTest()
        {
            TestFilesDir testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);

            string      docPath = testFilesDir.GetTestPath("OnyxTOFMS.sky");
            SrmDocument doc     = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 1, 1, 4);

            using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
            {
                const string replicateName = "Wiff2Test";
                string       extRaw        = ExtensionTestContext.ExtAbWiff2;
                string       suffix        = ExtensionTestContext.CanImportAbWiff2 ? "" : "-sample";
                var          chromSets     = new[]
                {
                    new ChromatogramSet(replicateName, new[]
                                        { new MsDataFilePath(testFilesDir.GetTestPath("OnyxTOFMS" + suffix + extRaw)), }),
                };
                var docResults = doc.ChangeMeasuredResults(new MeasuredResults(chromSets));
                Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                docContainer.AssertComplete();
                docResults = docContainer.Document;
                AssertResult.IsDocumentResultsState(docResults, replicateName,
                                                    doc.MoleculeCount, doc.MoleculeTransitionGroupCount, 0, doc.MoleculeTransitionCount, 0);
            }

            testFilesDir.Dispose();
        }
Beispiel #2
0
        public void ShimadzuFormatsTest()
        {
            var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);

            string      docPath;
            SrmDocument doc = InitShimadzuDocument(testFilesDir, out docPath);

            using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
            {
                const string replicateName = "ShimadzuTest";
                string       extRaw        = ExtensionTestContext.ExtShimadzuRaw;
                var          chromSets     = new[]
                {
                    new ChromatogramSet(replicateName, new[]
                                        { new MsDataFilePath(testFilesDir.GetTestPath("BSA-digest__MRM_optimisation_SL_scheduled_001" + extRaw)), }),
                };
                var docResults = doc.ChangeMeasuredResults(new MeasuredResults(chromSets));
                Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                docContainer.AssertComplete();
                docResults = docContainer.Document;
                AssertResult.IsDocumentResultsState(docResults, replicateName,
                                                    doc.PeptideCount, doc.PeptideTransitionGroupCount, 0, doc.PeptideTransitionCount, 0);
            }

            testFilesDir.Dispose();
        }
Beispiel #3
0
        public void AgilentFormatsTest()
        {
            var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);

            string      docPath;
            SrmDocument doc = InitAgilentDocument(testFilesDir, out docPath);

            using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
            {
                const string replicateName = "AgilentTest";
                string       extRaw        = ExtensionTestContext.ExtAgilentRaw;
                var          chromSets     = new[]
                {
                    new ChromatogramSet(replicateName, new[]
                                        { new MsDataFilePath(testFilesDir.GetTestPath("081809_100fmol-MichromMix-05" + extRaw)), }),
                };
                var docResults = doc.ChangeMeasuredResults(new MeasuredResults(chromSets));
                Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                docContainer.AssertComplete();
                docResults = docContainer.Document;
                AssertResult.IsDocumentResultsState(docResults, replicateName,
                                                    doc.PeptideCount, doc.PeptideTransitionGroupCount, 0, doc.PeptideTransitionCount, 0);
            }

            testFilesDir.Dispose();
        }
Beispiel #4
0
        protected override void DoTest()
        {
            var resultsPath = TestFilesDir.GetTestPath("PeakSortingIssue.raw");
            var docPath     = TestFilesDir.GetTestPath("PeakSortingIssue.sky");
            var doc         = ResultsUtil.DeserializeDocument(docPath);

            AssertEx.IsDocumentState(doc, 0, 1, 3, 6, 90);
            using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
            {
                var replicateName     = Path.GetFileNameWithoutExtension(resultsPath);
                var listChromatograms =
                    new List <ChromatogramSet> {
                    new ChromatogramSet(replicateName, new[] { MsDataFileUri.Parse(resultsPath) })
                };
                var docResults = doc.ChangeMeasuredResults(new MeasuredResults(listChromatograms));
                Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                docContainer.AssertComplete();
                docResults = docContainer.Document;
                AssertResult.IsDocumentResultsState(docResults, replicateName, 0, 0, 0, 0, 3);
            }
        }
        protected override void DoTest()
        {
            // Lest we get "To export a scheduled method, you must first choose a retention time predictor in Peptide Settings / Prediction, or import results for all peptides in the document."
            TestSmallMolecules = false;

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

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

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

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

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

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

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

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

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

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

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

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

            CheckTransitionList(filePathTemplate, 1, 6);

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

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

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

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

            PauseForScreenShot("Main Skyline window", 5);

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

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

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

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

            CheckTransitionList(filePathTemplate1, 5, 9);

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

            CheckCEValues(filePath, 11);

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

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

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

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

            PauseForScreenShot("Main Skyline window", 8);

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

            FindNode("IDALNENK");

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

            PauseForScreenShot("Main Skyline window", 9);

            RunUI(SkylineWindow.EditDelete);

            RemovePeptide("LICDNTHITK");

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

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

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

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

            var graphDatas = graphRegression.RegressionGraphDatas.ToArray();

            Assert.AreEqual(2, graphDatas.Length);

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

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

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

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

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

            CheckTransitionList(filePathTemplate2, 1, 9);

            RunUI(() => SkylineWindow.SaveDocument());
            WaitForConditionUI(() => !SkylineWindow.Dirty);
        }
        protected override void DoTest()
        {
            var docInitial = SkylineWindow.Document;

            // Set up necessary modifications
            var          peptideSettingsUI = ShowPeptideSettings();
            const string oxidationMName    = "Oxidation (M)";

            AddStaticMod(oxidationMName, true, peptideSettingsUI);
            RunUI(() =>
            {
                peptideSettingsUI.PickedStaticMods = new[] { oxidationMName };
                peptideSettingsUI.MissedCleavages  = 1;
            });

            // Build the library from the pepXML
            var buildLibraryDlg = ShowDialog <BuildLibraryDlg>(peptideSettingsUI.ShowBuildLibraryDlg);

            const string libraryName = "FullScanIdTest";
            string       libraryPath = TestFilesDir.GetTestPath(libraryName + BiblioSpecLiteSpec.EXT);
            string       pepXmlPath  = TestFilesDir.GetTestPath("CAexample.pep.xml");

            RunUI(() =>
            {
                buildLibraryDlg.LibraryName          = libraryName;
                buildLibraryDlg.LibraryPath          = libraryPath;
                buildLibraryDlg.LibraryKeepRedundant = true;
                buildLibraryDlg.LibraryBuildAction   = LibraryBuildAction.Create;
                buildLibraryDlg.LibraryAuthority     = "proteomics.fhcrc.org";
                buildLibraryDlg.OkWizardPage();
                buildLibraryDlg.AddInputFiles(new [] { pepXmlPath });
            });
            OkDialog(buildLibraryDlg, buildLibraryDlg.OkWizardPage);
            Assert.IsTrue(WaitForCondition(() =>
                                           peptideSettingsUI.AvailableLibraries.Contains(libraryName)));

            // Add the library to the document
            RunUI(() => peptideSettingsUI.PickedLibraries = new[] { libraryName });
            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
            WaitForDocumentChange(docInitial);
            try
            {
                WaitForCondition(() =>
                {
                    var librarySettings = SkylineWindow.Document.Settings.PeptideSettings.Libraries;
                    return(librarySettings.IsLoaded &&
                           librarySettings.Libraries.Count > 0 &&
                           librarySettings.Libraries[0].Keys.Count() == 43);
                });
            }
            catch (Exception e)
            {
                var librarySettings   = SkylineWindow.Document.Settings.PeptideSettings.Libraries;
                var libraryKeysCounts = string.Join(",", librarySettings.Libraries.Select(
                                                        library => null == library ? "null" : string.Empty + library.Keys.Count()));
                string message =
                    string.Format(
                        "Timeout waiting for libraries.  IsLoaded:{0} Libraries.Count:{1} LibrariesKeysCounts:{2}",
                        librarySettings.IsLoaded,
                        librarySettings.Libraries.Count,
                        libraryKeysCounts);

                throw new Exception(message, e);
            }

            var docSetup = SkylineWindow.Document;

            // Add all but 2 of the peptides in the library to the document
            var libraryExplorer = ShowDialog <ViewLibraryDlg>(SkylineWindow.ViewSpectralLibraries);
            var matchedPepsDlg  = WaitForOpenForm <MultiButtonMsgDlg>();

            RunUI(matchedPepsDlg.BtnCancelClick);
            WaitForClosedForm <MultiButtonMsgDlg>(); // Wait for cancellation to take effect
            var filterMatchedPeptidesDlg = ShowDialog <FilterMatchedPeptidesDlg>(libraryExplorer.AddAllPeptides);

            RunDlg <MultiButtonMsgDlg>(filterMatchedPeptidesDlg.OkDialog, addLibraryPepsDlg =>
            {
                Assert.AreEqual(2, (int)addLibraryPepsDlg.Tag);
                addLibraryPepsDlg.Btn1Click();
            });
            RunUI(libraryExplorer.Close);

            var docPeptides = WaitForDocumentChange(docSetup);

            AssertEx.IsDocumentState(docPeptides, null, 1, 33, 41, 123);

            // Switch to full-scan filtering of precursors in MS1
            RunDlg <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI, transitionSettingsUI =>
            {
                transitionSettingsUI.FragmentTypes            = "p";
                transitionSettingsUI.PrecursorCharges         = "2, 3";
                transitionSettingsUI.UseLibraryPick           = false;
                transitionSettingsUI.PrecursorIsotopesCurrent = FullScanPrecursorIsotopes.Count;
                transitionSettingsUI.PrecursorMassAnalyzer    = FullScanMassAnalyzerType.qit;
                transitionSettingsUI.OkDialog();
            });

            var docFullScan = WaitForDocumentChange(docPeptides);

            AssertEx.IsDocumentState(docFullScan, null, 1, 33, 41, 41);  // precursors only
            foreach (var chromInfo in docFullScan.PeptideTransitionGroups.SelectMany(nodeGroup => nodeGroup.ChromInfos))
            {
                Assert.IsTrue(chromInfo.IsIdentified);
            }

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

            // Import results
            const string importFileName = "CAexample.mzXML";

            ImportResultsFile(importFileName);

            var docResults = WaitForDocumentChange(docFullScan);

            AssertResult.IsDocumentResultsState(docResults, Path.GetFileNameWithoutExtension(importFileName),
                                                33, 41, 0, 41, 0);

            // Make sure spectrum and chromatogram graphs behave as expected in
            // relation to MS/MS spectrum selection.
            const int level = (int)SrmDocument.Level.TransitionGroups;

            RunUI(() => SkylineWindow.SelectedPath = docResults.GetPathTo(level, 0));

            // CONSIDER: This could be a lot more interesting with a multi-replicate data set,
            //           but it is hard to get one small enough.
            WaitForGraphs();
            RunUI(() =>
            {
                Assert.IsTrue(SkylineWindow.GraphSpectrum.SelectedSpectrum.IsBest);
                var availableSpectra = SkylineWindow.GraphSpectrum.AvailableSpectra.ToArray();
                Assert.AreEqual(2, availableSpectra.Length);

                var graphChrom = SkylineWindow.GraphChromatograms.First();
                double idTime  = availableSpectra[0].RetentionTime ?? 0;
                Assert.AreEqual(idTime, graphChrom.SelectedRetentionTimeMsMs);

                graphChrom.FirePickedSpectrum(new ScaledRetentionTime(idTime, idTime));
            });

            WaitForGraphs();
            RunUI(() => Assert.IsFalse(SkylineWindow.GraphSpectrum.SelectedSpectrum.IsBest));
        }
Beispiel #7
0
        public void WiffResultsTest()
        {
            TestFilesDir testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);

            SrmDocument doc = InitWiffDocument(testFilesDir);

            using (var docContainer = new ResultsTestDocumentContainer(doc,
                                                                       testFilesDir.GetTestPath("SimpleWiffTest.sky")))
            {
                FileEx.SafeDelete(ChromatogramCache.FinalPathForName(docContainer.DocumentFilePath, null));

                var listChromatograms = new List <ChromatogramSet>();

                if (ExtensionTestContext.CanImportAbWiff)
                {
                    string   pathWiff = testFilesDir.GetTestPath("051309_digestion.wiff");
                    string[] dataIds  = MsDataFileImpl.ReadIds(pathWiff);

                    for (int i = 0; i < dataIds.Length; i++)
                    {
                        string nameSample = dataIds[i];
                        if (!Equals(nameSample, "test") && listChromatograms.Count == 0)
                        {
                            continue;
                        }
                        string pathSample = SampleHelp.EncodePath(pathWiff, nameSample, i, LockMassParameters.EMPTY, false, false);
                        listChromatograms.Add(new ChromatogramSet(nameSample, new[] { MsDataFileUri.Parse(pathSample) }));
                    }
                }
                else
                {
                    listChromatograms.Add(new ChromatogramSet("test",
                                                              new[] { MsDataFileUri.Parse(testFilesDir.GetTestPath("051309_digestion-test.mzML")) }));
                    listChromatograms.Add(new ChromatogramSet("rfp9,before,h,1",
                                                              new[] { MsDataFileUri.Parse(testFilesDir.GetTestPath("051309_digestion-rfp9,before,h,1.mzML")) }));
                }

                // Should have added test and one after
                Assert.AreEqual(2, listChromatograms.Count);

                var docResults = doc.ChangeMeasuredResults(new MeasuredResults(listChromatograms));
                Assert.IsTrue(docContainer.SetDocument(docResults, doc, true));
                docContainer.AssertComplete();

                docResults = docContainer.Document;

                AssertEx.IsDocumentState(docResults, 6, 9, 9, 18, 54);
                Assert.IsTrue(docResults.Settings.MeasuredResults.IsLoaded);

                foreach (var nodeTran in docResults.PeptideTransitions)
                {
                    Assert.IsTrue(nodeTran.HasResults);
                    Assert.AreEqual(2, nodeTran.Results.Count);
                }

                // Remove the last chromatogram
                listChromatograms.RemoveAt(1);

                var docResultsSingle = docResults.ChangeMeasuredResults(new MeasuredResults(listChromatograms));

                AssertResult.IsDocumentResultsState(docResultsSingle, "test", 9, 2, 9, 8, 27);

                // Add mzXML version of test sample
                listChromatograms.Add(new ChromatogramSet("test-mzXML", new[] { MsDataFileUri.Parse(testFilesDir.GetTestPath("051309_digestion-s3.mzXML")) }));

                var docMzxml = docResults.ChangeMeasuredResults(new MeasuredResults(listChromatograms));
                Assert.IsTrue(docContainer.SetDocument(docMzxml, docResults, true));
                docContainer.AssertComplete();
                docMzxml = docContainer.Document;
                // Verify mzXML and native contained same results
                // Unfortunately mzWiff produces chromatograms with now zeros, which
                // need to be interpolated into place.  This means a .wiff file and
                // its mzWiff mzXML file will never be the same.
                AssertResult.MatchChromatograms(docMzxml, 0, 1, -1, 0);
            }

            // TODO: Switch to a using clause when PWiz is fixed, and this assertion fails
//            AssertEx.ThrowsException<IOException>(() => testFilesDir.Dispose());
        }
Beispiel #8
0
        private void DoFullScanFilterTest(RefinementSettings.ConvertToSmallMoleculesMode asSmallMolecules,
                                          out List <SrmDocument> docCheckpoints, bool centroided = false)
        {
            docCheckpoints = new List <SrmDocument>();

            var    testFilesDir            = new TestFilesDir(TestContext, ZIP_FILE);
            string docPath                 = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi.sky");
            var    expectedPepCount        = 7;
            var    expectedTransGroupCount = 7;
            var    expectedTransCount      = 49;
            var    doc = InitFullScanDocument(ref docPath, 2, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules);

            if (centroided && ExtensionTestContext.CanImportThermoRaw)
            {
                const double ppm20 = 20.0;
                doc = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs =>
                                                                               fs.ChangePrecursorResolution(FullScanMassAnalyzerType.centroided, ppm20, 0)));
            }
            using (var docContainer = new ResultsTestDocumentContainer(doc, docPath))
            {
                // Import the first RAW file (or mzML for international)
                string rawPath = testFilesDir.GetTestPath("ah_20101011y_BSA_MS-MS_only_5-2" +
                                                          ExtensionTestContext.ExtThermoRaw);
                var measuredResults = new MeasuredResults(new[] { new ChromatogramSet("Single", new[] { new MsDataFilePath(rawPath) }) });

                SrmDocument docResults = docContainer.ChangeMeasuredResults(measuredResults, 3, 3, 21);

                docCheckpoints.Add(docResults);

                // Refilter allowing multiple precursors per spectrum
                SrmDocument docMulti = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(
                                                              fs => fs.ChangeAcquisitionMethod(FullScanAcquisitionMethod.DIA, new IsolationScheme("Test", 2))));
                AssertEx.Serializable(docMulti, AssertEx.DocumentCloned);
                // Release data cache file
                Assume.IsTrue(docContainer.SetDocument(docMulti, docResults));
                // And remove it
                FileEx.SafeDelete(Path.ChangeExtension(docPath, ChromatogramCache.EXT));

                docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, 6, 6, 38));

                // Import full scan Orbi-Velos data
                docPath                 = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_long_acc_template.sky");
                expectedPepCount        = 3;
                expectedTransGroupCount = 3;
                expectedTransCount      = 21;
                doc = InitFullScanDocument(ref docPath, 1, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules);
                docCheckpoints.Add(doc);
                Assume.AreEqual(FullScanMassAnalyzerType.orbitrap, doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer);
                // Make sure saving this type of document works
                AssertEx.Serializable(doc, AssertEx.DocumentCloned);
                Assume.IsTrue(docContainer.SetDocument(doc, docContainer.Document));
                rawPath = testFilesDir.GetTestPath("ah_20101029r_BSA_CID_FT_centroid_3uscan_3" +
                                                   ExtensionTestContext.ExtThermoRaw);
                measuredResults = new MeasuredResults(new[] { new ChromatogramSet("Accurate", new[] { rawPath }) });

                docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, 3, 3, 21));

                // Import LTQ data with MS1 and MS/MS
                docPath                 = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_test4.sky");
                expectedPepCount        = 3;
                expectedTransGroupCount = 4;
                expectedTransCount      = 32;
                doc = InitFullScanDocument(ref docPath, 3, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules);
                Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer);
                Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer);
                docCheckpoints.Add(doc);
                var docBoth = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs =>
                                                                                       fs.ChangeAcquisitionMethod(FullScanAcquisitionMethod.Targeted, null)
                                                                                       .ChangePrecursorResolution(FullScanMassAnalyzerType.qit, TransitionFullScan.DEFAULT_RES_QIT, null)));
                docCheckpoints.Add(docBoth);
                AssertEx.Serializable(docBoth, AssertEx.DocumentCloned);
                Assume.IsTrue(docContainer.SetDocument(docBoth, docContainer.Document));

                string dataPath    = testFilesDir.GetTestPath("klc_20100329v_Protea_Peptide_Curve_200fmol_uL_tech1.mzML");
                var    listResults = new List <ChromatogramSet>
                {
                    new ChromatogramSet("MS1 and MS/MS", new[] { dataPath }),
                };
                measuredResults = new MeasuredResults(listResults.ToArray());

                docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, expectedPepCount, expectedTransGroupCount, expectedTransCount - 6));
                // The mzML was filtered for the m/z range 410 to 910.
                foreach (var nodeTran in docContainer.Document.MoleculeTransitions)
                {
                    Assume.IsTrue(nodeTran.HasResults);
                    Assume.IsNotNull(nodeTran.Results[0]);
                    if (410 > nodeTran.Mz || nodeTran.Mz > 910)
                    {
                        Assume.IsTrue(nodeTran.Results[0][0].IsForcedIntegration);
                    }
                    else
                    {
                        Assume.IsFalse(nodeTran.Results[0][0].IsForcedIntegration);
                    }
                }

                // Import LTQ data with MS1 and MS/MS using multiple files for a single replicate
                listResults.Add(new ChromatogramSet("Multi-file", new[]
                {
                    testFilesDir.GetTestPath("both_DRV.mzML"),
                    testFilesDir.GetTestPath("both_KVP.mzML"),
                }));
                measuredResults = new MeasuredResults(listResults.ToArray());
                docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, expectedPepCount - 1, expectedTransGroupCount - 1, expectedTransCount - 6));

                if (asSmallMolecules == RefinementSettings.ConvertToSmallMoleculesMode.masses_only)
                {
                    return; // Can't work with isotope distributions when we don't have ion formulas
                }
                int indexResults       = listResults.Count - 1;
                var matchIdentifierDRV = "DRV";
                if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none)
                {
                    matchIdentifierDRV = RefinementSettings.TestingConvertedFromProteomicPeptideNameDecorator + matchIdentifierDRV;
                }
                int index = 0;
                foreach (var nodeTran in docContainer.Document.MoleculeTransitions)
                {
                    Assume.IsTrue(nodeTran.HasResults);
                    Assume.AreEqual(listResults.Count, nodeTran.Results.Count);
                    var peptide = nodeTran.Transition.Group.Peptide;

                    if (peptide.IsCustomMolecule && index == 24)
                    {
                        // Conversion to small molecule loses some of the nuance of "Sequence" vs "FastaSequence", comparisons are inexact
                        Assume.AreEqual("pep_DRVY[+80.0]IHPF", nodeTran.PrimaryCustomIonEquivalenceKey);
                        break;
                    }

                    // DRV without FASTA sequence should not have data for non-precursor transitions
                    if (!peptide.TextId.StartsWith(matchIdentifierDRV) ||
                        (!peptide.IsCustomMolecule && !peptide.Begin.HasValue))
                    {
                        Assume.IsNotNull(nodeTran.Results[indexResults]);
                        Assume.IsFalse(nodeTran.Results[indexResults][0].IsEmpty);
                    }
                    else if (nodeTran.Transition.IonType != IonType.precursor)
                    {
                        Assert.IsTrue(nodeTran.Results[indexResults].IsEmpty);
                    }
                    else
                    {
                        // Random, bogus peaks chosen in both files
                        Assume.IsNotNull(nodeTran.Results[indexResults]);
                        Assume.AreEqual(2, nodeTran.Results[indexResults].Count);
                        Assume.IsFalse(nodeTran.Results[indexResults][0].IsEmpty);
                        Assume.IsFalse(nodeTran.Results[indexResults][1].IsEmpty);
                    }
                    index++;
                }

                // Verify handling of bad request for vendor centroided data - out-of-range PPM
                docPath                 = testFilesDir.GetTestPath("Yeast_HI3 Peptides_test.sky");
                expectedPepCount        = 2;
                expectedTransGroupCount = 2;
                expectedTransCount      = 2;
                doc = InitFullScanDocument(ref docPath, 2, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules);
                Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer);
                Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer);
                var docBad = doc;
                AssertEx.ThrowsException <InvalidDataException>(() =>
                                                                docBad.ChangeSettings(docBad.Settings.ChangeTransitionFullScan(fs =>
                                                                                                                               fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, IsotopeEnrichmentsList.DEFAULT)
                                                                                                                               .ChangePrecursorResolution(FullScanMassAnalyzerType.centroided, 50 * 1000, 400))),
                                                                string.Format(Resources.TransitionFullScan_ValidateRes_Mass_accuracy_must_be_between__0__and__1__for_centroided_data_,
                                                                              TransitionFullScan.MIN_CENTROID_PPM, TransitionFullScan.MAX_CENTROID_PPM));

                // Verify relationship between PPM and resolving power
                const double ppm           = 20.0; // Should yield same filter width as resolving power 50,000 in TOF
                var          docNoCentroid = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs =>
                                                                                                      fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, IsotopeEnrichmentsList.DEFAULT)
                                                                                                      .ChangePrecursorResolution(FullScanMassAnalyzerType.centroided, ppm, 0)));
                AssertEx.Serializable(docNoCentroid, AssertEx.DocumentCloned);
                Assume.IsTrue(docContainer.SetDocument(docNoCentroid, docContainer.Document));
                const double mzTest      = 400.0;
                var          filterWidth = docNoCentroid.Settings.TransitionSettings.FullScan.GetPrecursorFilterWindow(mzTest);
                Assume.AreEqual(mzTest * 2.0 * ppm * 1E-6, filterWidth);

                // Verify relationship between normal and high-selectivity extraction
                var docTofNormal = docNoCentroid.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs =>
                                                                                                      fs.ChangePrecursorResolution(FullScanMassAnalyzerType.tof, 50 * 1000, null)));
                AssertEx.Serializable(docTofNormal, AssertEx.DocumentCloned);
                var docTofSelective = docTofNormal.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs =>
                                                                                                        fs.ChangePrecursorResolution(FullScanMassAnalyzerType.tof, 25 * 1000, null)
                                                                                                        .ChangeUseSelectiveExtraction(true)));
                AssertEx.Serializable(docTofSelective, AssertEx.DocumentCloned);
                var filterWidthTof       = docTofNormal.Settings.TransitionSettings.FullScan.GetPrecursorFilterWindow(mzTest);
                var filterWidthSelective = docTofSelective.Settings.TransitionSettings.FullScan.GetPrecursorFilterWindow(mzTest);
                Assume.AreEqual(filterWidth, filterWidthTof);
                Assume.AreEqual(filterWidth, filterWidthSelective);


                // Verify handling of bad request for vendor centroided data - ask for centroiding in mzML
                const string fileName = "S_2_LVN.mzML";
                var          filePath = testFilesDir.GetTestPath(fileName);
                AssertEx.ThrowsException <AssertFailedException>(() =>
                {
                    listResults = new List <ChromatogramSet> {
                        new ChromatogramSet("rep1", new[] { new MsDataFilePath(filePath) }),
                    };
                    docContainer.ChangeMeasuredResults(new MeasuredResults(listResults.ToArray()), 1, 1, 1);
                },
                                                                 string.Format(Resources.NoCentroidedDataException_NoCentroidedDataException_No_centroided_data_available_for_file___0_____Adjust_your_Full_Scan_settings_, filePath));

                // Import FT data with only MS1
                docPath                 = testFilesDir.GetTestPath("Yeast_HI3 Peptides_test.sky");
                expectedPepCount        = 2;
                expectedTransGroupCount = 2;
                expectedTransCount      = 2;
                doc = InitFullScanDocument(ref docPath, 2, ref expectedPepCount, ref expectedTransGroupCount, ref expectedTransCount, asSmallMolecules);
                Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer);
                Assume.AreEqual(FullScanMassAnalyzerType.none, doc.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer);
                var docMs1 = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs =>
                                                                                      fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, IsotopeEnrichmentsList.DEFAULT)
                                                                                      .ChangePrecursorResolution(FullScanMassAnalyzerType.tof, 50 * 1000, null)));
                Assume.AreEqual(filterWidth, docMs1.Settings.TransitionSettings.FullScan.GetPrecursorFilterWindow(mzTest));
                docMs1 = doc.ChangeSettings(doc.Settings.ChangeTransitionFullScan(fs =>
                                                                                  fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count, 1, IsotopeEnrichmentsList.DEFAULT)
                                                                                  .ChangePrecursorResolution(FullScanMassAnalyzerType.ft_icr, 50 * 1000, mzTest)));
                AssertEx.Serializable(docMs1, AssertEx.DocumentCloned);
                Assume.IsTrue(docContainer.SetDocument(docMs1, docContainer.Document));
                const string rep1 = "rep1";
                listResults = new List <ChromatogramSet>
                {
                    new ChromatogramSet(rep1, new[] { filePath }),
                };
                measuredResults = new MeasuredResults(listResults.ToArray());
                docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, 1, 1, 1));
                // Because of the way the mzML files were filtered, all of the LVN peaks should be present
                // in the first replicate, and all of the NVN peaks should be present in the other.
                var matchIdentifierLVN = "LVN";
                if (asSmallMolecules != RefinementSettings.ConvertToSmallMoleculesMode.none)
                {
                    matchIdentifierLVN = RefinementSettings.TestingConvertedFromProteomicPeptideNameDecorator + matchIdentifierLVN;
                }
                foreach (var nodeTranGroup in docContainer.Document.MoleculeTransitionGroups)
                {
                    foreach (var docNode in nodeTranGroup.Children)
                    {
                        var nodeTran = (TransitionDocNode)docNode;
                        Assume.IsTrue(nodeTran.HasResults);
                        Assume.AreEqual(1, nodeTran.Results.Count);
                        if (nodeTran.Transition.Group.Peptide.Target.ToString().StartsWith(matchIdentifierLVN))
                        {
                            Assume.IsFalse(nodeTran.Results[0][0].IsEmpty);
                        }
                        else
                        {
                            Assume.IsTrue(nodeTran.Results[0][0].IsEmpty);
                        }
                    }
                }
                const string rep2 = "rep2";
                listResults.Add(new ChromatogramSet(rep2, new[] { testFilesDir.GetTestPath("S_2_NVN.mzML") }));
                measuredResults = new MeasuredResults(listResults.ToArray());
                docCheckpoints.Add(docContainer.ChangeMeasuredResults(measuredResults, 1, 1, 1));
                // Because of the way the mzML files were filtered, all of the LVN peaks should be present
                // in the first replicate, and all of the NVN peaks should be present in the other.
                foreach (var nodeTranGroup in docContainer.Document.MoleculeTransitionGroups)
                {
                    foreach (var docNode in nodeTranGroup.Children)
                    {
                        var nodeTran = (TransitionDocNode)docNode;
                        Assume.IsTrue(nodeTran.HasResults);
                        Assume.AreEqual(2, nodeTran.Results.Count);
                        if (nodeTran.Transition.Group.Peptide.Target.ToString().StartsWith(matchIdentifierLVN))
                        {
                            Assume.IsTrue(nodeTran.Results[1][0].IsEmpty);
                        }
                        else
                        {
                            Assume.IsFalse(nodeTran.Results[1][0].IsEmpty);
                        }
                    }
                }

                // Chromatograms should be present in the cache for a number of isotopes.
                var docMs1Isotopes = docContainer.Document.ChangeSettings(doc.Settings
                                                                          .ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Count,
                                                                                                                                     3, IsotopeEnrichmentsList.DEFAULT))
                                                                          .ChangeTransitionFilter(filter => filter.ChangePeptideIonTypes(new[] { IonType.precursor })
                                                                                                  .ChangeSmallMoleculeIonTypes(new[] { IonType.precursor })));
                docCheckpoints.Add(docMs1Isotopes);
                AssertEx.IsDocumentState(docMs1Isotopes, null, 2, 2, 2);   // Need to reset auto-manage for transitions
                var refineAutoSelect = new RefinementSettings {
                    AutoPickChildrenAll = PickLevel.transitions
                };
                docMs1Isotopes = refineAutoSelect.Refine(docMs1Isotopes);
                AssertEx.IsDocumentState(docMs1Isotopes, null, 2, 2, 6);
                AssertResult.IsDocumentResultsState(docMs1Isotopes, rep1, 1, 1, 0, 3, 0);
                AssertResult.IsDocumentResultsState(docMs1Isotopes, rep2, 1, 1, 0, 3, 0);
                docCheckpoints.Add(docMs1Isotopes);

                // Add M-1 transitions, and verify that they have chromatogram data also, but
                // empty peaks in all cases
                var docMs1All = docMs1Isotopes.ChangeSettings(docMs1Isotopes.Settings
                                                              .ChangeTransitionFullScan(fs => fs.ChangePrecursorIsotopes(FullScanPrecursorIsotopes.Percent,
                                                                                                                         0, IsotopeEnrichmentsList.DEFAULT))
                                                              .ChangeTransitionIntegration(i => i.ChangeIntegrateAll(false))); // For compatibility with v2.5 and earlier
                docCheckpoints.Add(docMs1All);
                AssertEx.IsDocumentState(docMs1All, null, 2, 2, 10);
                AssertResult.IsDocumentResultsState(docMs1All, rep1, 1, 1, 0, 4, 0);
                AssertResult.IsDocumentResultsState(docMs1All, rep2, 1, 1, 0, 4, 0);
                var ms1AllTranstions = docMs1All.MoleculeTransitions.ToArray();
                var tranM1           = ms1AllTranstions[0];
                Assert.AreEqual(-1, tranM1.Transition.MassIndex);
                Assert.IsTrue(!tranM1.Results[0].IsEmpty && !tranM1.Results[1].IsEmpty);
                Assert.IsTrue(tranM1.Results[0][0].IsEmpty && tranM1.Results[1][0].IsForcedIntegration);
                tranM1 = ms1AllTranstions[5];
                Assert.AreEqual(-1, tranM1.Transition.MassIndex);
                Assert.IsTrue(!tranM1.Results[0].IsEmpty && !tranM1.Results[1].IsEmpty);
                Assert.IsTrue(tranM1.Results[0][0].IsForcedIntegration && tranM1.Results[1][0].IsEmpty);
            }
        }
        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);
        }
Beispiel #10
0
        protected override void DoTest()
        {
            // iRT Retention Time Prediction
            string standardDocumentFile = GetTestPath("iRT-C18 Standard.sky"); // Not L10N

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

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

            ImportNewResults(new[] { unschedHuman1Fileroot, unschedHuman2Fileroot }, 41, false, false);
            var       docCalibrate = WaitForProteinMetadataBackgroundLoaderCompletedUI();
            const int pepCount = 11, tranCount = 33;

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

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

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

            RunUI(() =>
            {
                SkylineWindow.ShowRTReplicateGraph();
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.SelectedPath = docCalibrate.GetPathTo((int)SrmDocument.Level.Molecules, 0);
            });
            // Ensure graphs look like p. 3 and 4
            WaitForGraphs();

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

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

            var listTimes = new List <double>();

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

            // Calibrate a calculator p. 4-5
            const string irtCalcName        = "iRT-C18";
            var          peptideSettingsUI1 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var          editIrtCalc1       = ShowDialog <EditIrtCalcDlg>(peptideSettingsUI1.AddCalculator);

            RunUI(() =>
            {
                editIrtCalc1.CalcName = irtCalcName;
                editIrtCalc1.CreateDatabase(GetTestPath("iRT-C18.irtdb"));           // Not L10N
            });
            {
                var calibrateDlg = ShowDialog <CalibrateIrtDlg>(editIrtCalc1.Calibrate);
                RunUI(() =>
                {
                    calibrateDlg.UseResults();
                    Assert.AreEqual(11, calibrateDlg.StandardPeptideCount);
                    calibrateDlg.SetFixedPoints(1, 10);
                    for (int i = 0; i < calibrateDlg.StandardPeptideCount; i++)
                    {
                        Assert.AreEqual(listTimes[i], calibrateDlg.StandardPeptideList[i].RetentionTime, 0.2);
                    }
                });

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

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

            PauseForScreenShot <EditIrtCalcDlg>("Edit iRT Calculater form", 6);   // Edit iRT Caclulator form

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

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

                SetClipboardText(irtDefText);
                editIrtCalc1.DoPasteStandard();

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

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

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

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

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

            WaitForRegression();

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

                SkylineWindow.SelectedResultsIndex = 1;
            });

            WaitForRegression();

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

            // Create a document containing human and standard peptides, p. 9
            RunUI(() => SkylineWindow.OpenFile(GetTestPath("iRT Human.sky")));
            WaitForProteinMetadataBackgroundLoaderCompletedUI(); // let peptide metadata background loader do its work
            RunUI(() =>
            {
                SkylineWindow.SelectedPath = new IdentityPath(SequenceTree.NODE_INSERT_ID);
                SkylineWindow.ImportFiles(standardDocumentFile);
            });
            WaitForProteinMetadataBackgroundLoaderCompletedUI(); // let peptide metadata background loader do its work

            RestoreViewOnScreen(09);
            PauseForScreenShot("Targets tree clipped out of main winodw", 9);   // Target tree

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

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

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

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

            Assert.AreEqual(632, docLightOnly.PeptideTransitionCount);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                RestoreViewOnScreen(15);

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

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

            var findAllForm = WaitForOpenForm <FindResultsForm>();

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

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

                SkylineWindow.ShowAllTransitions();
                SkylineWindow.AutoZoomBestPeak();
            });

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

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

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

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

            RestoreViewOnScreen(17);

            // Calculate new iRT values for human peptides, p. 16
            {
                var editIrtCalc2 = ShowDialog <EditIrtCalcDlg>(SkylineWindow.ShowEditCalculatorDlg);
                RunUI(() => Assert.AreEqual(0, editIrtCalc2.LibraryPeptideCount));
                var addPeptidesDlg = ShowDialog <AddIrtPeptidesDlg>(editIrtCalc2.AddResults);

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

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

                PauseForScreenShot <EditIrtCalcDlg>("Edit iRT Calculator form", 16);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            RunUI(SkylineWindow.ShowRTRegressionGraphScoreToRun);
            WaitForRegression();

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

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

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

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

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

                SkylineWindow.RemoveRTOutliers();
            });
            WaitForRegression();

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

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

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

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

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

            // Import retention times from a spectral library, p. 27
            RestoreViewOnScreen(17); // get regression graph back
            {
                var editIrtCalc  = ShowDialog <EditIrtCalcDlg>(SkylineWindow.ShowEditCalculatorDlg);
                var addLibrayDlg = ShowDialog <AddIrtSpectralLibrary>(editIrtCalc.AddLibrary);
                RunUI(() =>
                {
                    addLibrayDlg.Source   = SpectralLibrarySource.file;
                    addLibrayDlg.FilePath = GetTestPath(Path.Combine("Yeast+Standard",               // Not L10N
                                                                     "Yeast_iRT_C18_0_00001.blib")); // Not L10N
                });

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

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

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

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

                Assert.IsTrue(WaitForConditionUI(() => editIrtCalc.LibraryPeptideCount == 706));
                RunUI(editIrtCalc.OkDialog);
                WaitForClosedForm(editIrtCalc);
            }

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

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

            PauseForScreenShot("Main window", 29);

            // Add results and verify add dialog counts, p. 29-30
            {
                var editIrtCalc    = ShowDialog <EditIrtCalcDlg>(SkylineWindow.ShowEditCalculatorDlg);
                var addPeptidesDlg = ShowDialog <AddIrtPeptidesDlg>(editIrtCalc.AddResults);
                RunUI(() =>
                {
                    Assert.AreEqual(0, addPeptidesDlg.PeptidesCount);
                    Assert.AreEqual(2, addPeptidesDlg.RunsConvertedCount);
                    Assert.AreEqual(558, addPeptidesDlg.OverwritePeptidesCount);
                    Assert.AreEqual(3, addPeptidesDlg.ExistingPeptidesCount);
                });

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

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

            RunUI(() => SkylineWindow.SaveDocument());
            RunUI(SkylineWindow.NewDocument);
        }
        protected override void DoTest()
        {
            int countRep = EXPECTED_REPLICATES.Length;

            // Open the .sky file
            string documentPath1 = TestFilesDir.GetTestPath("SRMCourse_DosR-hDP__20130501.sky");

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

            // Check expected initial state
            const int protCount = 13, pepCount = 71, tranCount = 312;
            var       document = SkylineWindow.Document;

            AssertEx.IsDocumentState(document, null, protCount, pepCount, pepCount, tranCount);
            int[] missing = { 1, 0, 0, 0 };
            for (int i = 0; i < EXPECTED_REPLICATES.Length; i++)
            {
                string replicateName = EXPECTED_REPLICATES[i];
                AssertResult.IsDocumentResultsState(document, replicateName,
                                                    pepCount, pepCount, 0, tranCount - missing[i], 0);
            }
            VerifyUserSets(document,
                           new[] { new UserSetCount(UserSet.FALSE, countRep * pepCount) },
                           new[] { new UserSetCount(UserSet.FALSE, countRep * tranCount) });

            // Add heavy precursors
            RunDlg <RefineDlg>(SkylineWindow.ShowRefineDlg, refineDlg =>
            {
                refineDlg.RefineLabelType = IsotopeLabelType.heavy;
                refineDlg.AddLabelType    = true;
                refineDlg.OkDialog();
            });

            // Check changed result state
            const int pepStandardCount = 13, tranStandardCount = 34;

            document = WaitForDocumentChange(document);
            AssertEx.IsDocumentState(document, null, protCount, pepCount, pepCount * 2 - pepStandardCount, tranCount * 2 - tranStandardCount);
            int[] missingHeavy = { 1, 1, 2, 2 };
            for (int i = 0; i < EXPECTED_REPLICATES.Length; i++)
            {
                string replicateName = EXPECTED_REPLICATES[i];
                AssertResult.IsDocumentResultsState(document, replicateName,
                                                    pepCount, pepCount, pepCount - pepStandardCount,
                                                    tranCount - missing[i],
                                                    tranCount - tranStandardCount - missingHeavy[i]);
            }
            const int pepRandomCount = 8;   // Randomly need no changes from default to match
            // TODO: Figure out what is up with the 6
            var matchedUserSetGroups = new[]
            {
                new UserSetCount(UserSet.FALSE, 4 * pepStandardCount + pepRandomCount),
                new UserSetCount(UserSet.MATCHED, 8 * (pepCount - pepStandardCount) - pepRandomCount),
            };
            var matchedUserSetTrans = new[]
            {
                new UserSetCount(UserSet.FALSE, countRep * tranStandardCount + countRep * pepRandomCount + 6),
                new UserSetCount(UserSet.MATCHED, 2 * countRep * (tranCount - tranStandardCount) - countRep * pepRandomCount - 6),
            };

            VerifyUserSets(document, matchedUserSetGroups, matchedUserSetTrans);

            VerifyMatchingPeakBoundaries(document, true);   // CONSIDER: Strange that these peak times match exactly

            // Test limited scoring model
            {
                var reintegrateDlg = ShowDialog <ReintegrateDlg>(SkylineWindow.ShowReintegrateDialog);
                RunDlg <EditPeakScoringModelDlg>(reintegrateDlg.AddPeakScoringModel, scoringModelDlg =>
                {
                    scoringModelDlg.TrainModelClick();
                    Assert.IsNull(scoringModelDlg.GetCalculatorWeight(typeof(MQuestWeightedReferenceShapeCalc)));
                    Assert.IsNull(scoringModelDlg.GetCalculatorWeight(typeof(MQuestWeightedReferenceCoElutionCalc)));
                    Assert.IsNotNull(scoringModelDlg.GetCalculatorWeight(typeof(MQuestReferenceCorrelationCalc)));
                    Assert.IsNotNull(scoringModelDlg.GetCalculatorWeight(typeof(LegacyUnforcedCountScoreStandardCalc)));
                    Assert.AreEqual(16, scoringModelDlg.GetTargetCount());
                    Assert.AreEqual(4, scoringModelDlg.GetDecoyCount());
                    scoringModelDlg.CancelDialog();
                });
                OkDialog(reintegrateDlg, reintegrateDlg.CancelDialog);
            }

            // Rescore
            var manageResults     = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
            var rescoreResultsDlg = ShowDialog <RescoreResultsDlg>(manageResults.Rescore);

            RunUI(() => rescoreResultsDlg.Rescore(false));
            WaitForClosedForm(rescoreResultsDlg);
            WaitForClosedForm(manageResults);
            var documentRescore = WaitForDocumentChangeLoaded(document, 5 * 60 * 1000);    // 5 minutes

            WaitForClosedForm <AllChromatogramsGraph>();

            VerifyUserSets(documentRescore, matchedUserSetGroups, matchedUserSetTrans);

            // Test corrected scoring model
            {
                const string peakScoringModelName = "Test Model";
                var          reintegrateDlg       = ShowDialog <ReintegrateDlg>(SkylineWindow.ShowReintegrateDialog);
                RunDlg <EditPeakScoringModelDlg>(reintegrateDlg.AddPeakScoringModel, scoringModelDlg =>
                {
                    scoringModelDlg.PeakScoringModelName = peakScoringModelName;
                    scoringModelDlg.TrainModelClick();
                    Assert.IsNotNull(scoringModelDlg.GetCalculatorWeight(typeof(MQuestWeightedReferenceShapeCalc)));
                    Assert.IsNotNull(scoringModelDlg.GetCalculatorWeight(typeof(MQuestWeightedReferenceCoElutionCalc)));
                    Assert.IsNotNull(scoringModelDlg.GetCalculatorWeight(typeof(MQuestReferenceCorrelationCalc)));
                    Assert.IsNotNull(scoringModelDlg.GetCalculatorWeight(typeof(LegacyUnforcedCountScoreStandardCalc)));
                    const int pepTargetCount = (pepCount - pepStandardCount) / 2;
                    Assert.AreEqual(pepTargetCount * countRep, scoringModelDlg.GetTargetCount());
                    Assert.AreEqual(pepTargetCount * countRep, scoringModelDlg.GetDecoyCount());
                    scoringModelDlg.OkDialog();
                });
                RunUI(() =>
                {
                    reintegrateDlg.OverwriteManual = true;
                    reintegrateDlg.ComboPeakScoringModelSelected = peakScoringModelName;
                });
                OkDialog(reintegrateDlg, reintegrateDlg.OkDialog);
            }
            WaitForClosedForm <AllChromatogramsGraph>();
            documentRescore = WaitForDocumentChangeLoaded(documentRescore);

            matchedUserSetGroups = new[]
            {
                new UserSetCount(UserSet.FALSE, 272),
                new UserSetCount(UserSet.REINTEGRATED, 12),
            };
            matchedUserSetTrans = new[]
            {
                new UserSetCount(UserSet.FALSE, 1192),
                new UserSetCount(UserSet.REINTEGRATED, 56),
            };

            VerifyUserSets(documentRescore, matchedUserSetGroups, matchedUserSetTrans, true);
            VerifyMatchingPeakBoundaries(documentRescore, true);

            int changeCount = CountChangedPeaks(document, documentRescore);

            Assert.IsTrue(changeCount > 200);
        }
        protected override void DoTest()
        {
            var files = new [] {"8fmol.mz5", "20fmol.mz5", "40fmol.mz5", "200fmol.mz5"};
            OpenDocument("RetentionTimeFilterTest.sky");
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDir.GetTestPath("TestImportResultsCancel.sky"))); // Make a clean copy

            // Try individual cancellation - can be timing dependent (do we get to the cancel button quickly enough?) so allow some retry
            for (var retry = 10; retry-- > 0;)
            {
                OpenDocument("TestImportResultsCancel.sky");
                ImportResultsAsync(files);
                var dlg2 = WaitForOpenForm<AllChromatogramsGraph>();
                WaitForCondition(30 * 1000, () => dlg2.ProgressTotalPercent >= 1);  // Get a least a little way in
                var cancelTarget = files[retry % 4].Replace(".mz5", "");
                RunUI(() => dlg2.FileButtonClick(cancelTarget));
                WaitForDocumentLoaded();
                foreach (var file in files)
                {
                    int index;
                    ChromatogramSet chromatogramSet;
                    var chromatogramSetName = file.Replace(".mz5", "");
                    // Can we find a loaded chromatogram set by this name?
                    SkylineWindow.Document.Settings.MeasuredResults.TryGetChromatogramSet(chromatogramSetName, out chromatogramSet, out index);
                    if (!chromatogramSetName.Equals(cancelTarget))
                    {
                        // Should always find it since we didn't try to cancel this one
                        Assert.AreNotEqual(-1, index);
                    }
                    else
                    {
                        // Should not find anything by that name, but sometimes we're not quick enough on the cancel button
                        if (retry == 0)
                        {
                            Assert.AreEqual(-1, index);  // No more retries, declare failure or success
                        }
                        else if (index == -1)
                        {
                            retry = 0;  // Success, no more retry needed
                        }
                        else
                        {
                            break;  // Go back and retry
                        }
                    }
                }
            }

            // Cancelled load should revert to initial document
            OpenDocument("RetentionTimeFilterTest.sky");
            var docUnloaded = SkylineWindow.Document;
            ImportResultsAsync(files);
            var dlg = WaitForOpenForm<AllChromatogramsGraph>();
            WaitForCondition(30 * 1000, () => dlg.ProgressTotalPercent >= 1);  // Get a least a little way in
            RunUI(() => dlg.ClickCancel());   // Simulate user clicking the cancel button
            Assert.AreEqual(docUnloaded, SkylineWindow.Document);
            Assert.IsFalse(SkylineWindow.Document.Settings.HasResults);

            // Now try a proper import
            ImportResults(files);
            AssertResult.IsDocumentResultsState(SkylineWindow.Document, "8fmol", 4, 4, 0, 13, 0);
            AssertResult.IsDocumentResultsState(SkylineWindow.Document, "20fmol", 5, 5, 0, 13, 0);
            AssertResult.IsDocumentResultsState(SkylineWindow.Document, "40fmol", 3, 3, 0, 11, 0);
            AssertResult.IsDocumentResultsState(SkylineWindow.Document, "200fmol", 4, 4, 0, 12, 0);
        }
        protected override void DoTest()
        {
            RunUI(() => SkylineWindow.SetUIMode(SrmDocument.DOCUMENT_TYPE.small_molecules));

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

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

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

                var docTargets = WaitForDocumentChange(doc);

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

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


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

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

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


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

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

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

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

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

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

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

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

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

                var docResults = SkylineWindow.Document;

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

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

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

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

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

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

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

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

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

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

                    RunUI(manageResultsDlg.RemoveReplicates);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    RestoreCoverViewOnScreen();
                    TakeCoverShot();
                    return;
                }

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

                    var scheduleDlg = ShowDialog <SchedulingOptionsDlg>(() => exportTransitionList.OkDialog(GetTestPath("EnergyMet_5minutes_optimal.csv")));
                    PauseForScreenShot <SchedulingOptionsDlg>("Final Scheduling", 37);
                    OkDialog(scheduleDlg, scheduleDlg.OkDialog);
                }
            }
        }
        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());
        }
Beispiel #15
0
        protected override void DoTest()
        {
            // Setting the UI mode, p 2
            var startPage = WaitForOpenForm <StartPage>();

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

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

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

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


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

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

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

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

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


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

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


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

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

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

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

                    OkDialog(importResultsDlg1, importResultsDlg1.OkDialog);
                }

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

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

                var docResults = SkylineWindow.Document;

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

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

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

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

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

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

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

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

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

                RunUI(() => SkylineWindow.ShowCalibrationForm());
                SelectNode(SrmDocument.Level.Molecules, 0);
                PauseForScreenShot <DocumentGridForm>("Calibration curve", 12);
            }
        }
        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);
        }
Beispiel #17
0
        protected override void DoTest()
        {
            // Inserting a Transition List, p. 2
            {
                var doc = SkylineWindow.Document;

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

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


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

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

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

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

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

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

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

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

                SelectNode(SrmDocument.Level.MoleculeGroups, 0);

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

                var docResults = SkylineWindow.Document;

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

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

            if (libraryMatchPanel != null)
            {
                RunUI(libraryMatchPanel.Close);
            }

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

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

                PauseForScreenShot <SkylineWindow>("after paste from csv", 3);

                var docTargets = WaitForDocumentChange(doc);

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

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

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


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


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

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

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


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

                OkDialog(exportMethodDlg2, exportMethodDlg2.CancelDialog);
                WaitForClosedForm(exportMethodDlg2);


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

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

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

                    OkDialog(importResultsDlg1, importResultsDlg1.OkDialog);
                }

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

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

                // Renaming replicates
                var manageResultsDlg = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
                for (var i = 0; i < 2; i++)
                {
                    doc = SkylineWindow.Document;
                    var chromatograms = doc.Settings.MeasuredResults.Chromatograms;
                    var chrom         = chromatograms[i];
                    RunUI(() =>
                    {
                        manageResultsDlg.SelectedChromatograms = new[] { chrom };
                    });

                    var renameDlg = ShowDialog <RenameResultDlg>(manageResultsDlg.RenameResult);
                    var newName   = i == 0 ? "unscheduled_2min" : "unscheduled_5min";
                    RunUI(() =>
                    {
                        renameDlg.ReplicateName = newName;
                    });
                    if (i == 0)
                    {
                        PauseForScreenShot <SkylineWindow>("Renaming replicate", 10);
                    }
                    RunUI(() =>
                    {
                        renameDlg.OkDialog();
                    });
                    WaitForClosedForm(renameDlg);
                }
                RunUI(manageResultsDlg.OkDialog);
                WaitForClosedForm(manageResultsDlg);

                PauseForScreenShot <SkylineWindow>("Renamed", 10);

                var docResults = SkylineWindow.Document;

                var msg = "";
                foreach (var chromatogramSet in docResults.Settings.MeasuredResults.Chromatograms)
                {
                    try
                    {
                        AssertResult.IsDocumentResultsState(docResults, chromatogramSet.Name, 18, 18, 18, 18, 18);
                    }
                    catch (Exception x)
                    {
                        msg += TextUtil.LineSeparate(x.Message);
                    }
                }
                if (!string.IsNullOrEmpty(msg))
                {
                    Assert.IsTrue(string.IsNullOrEmpty(msg), msg);
                }
                RestoreViewOnScreen(9);
                SelectNode(SrmDocument.Level.MoleculeGroups, 0);
                WaitForGraphs();
                RunUI(() =>
                {
                    AdjustSequenceTreePanelWidth();
                    var ch = SkylineWindow.GraphChromatograms.FirstOrDefault((chrom) => chrom.NameSet == "unscheduled_2min");
                    ch?.ZoomTo(.85, 2.1, 1.9e+8);
                });

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

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

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

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

                var schedulingOptionsDlg = ShowDialog <SchedulingOptionsDlg>(() => exportTransitionList2.OkDialog(GetTestPath("scheduled_5min.csv")));
                RunUI(() =>
                {
                    schedulingOptionsDlg.Algorithm    = ExportSchedulingAlgorithm.Single;
                    schedulingOptionsDlg.ReplicateNum = 1;
                });
                PauseForScreenShot <SchedulingOptionsDlg>("Exporting scheduled transition list - choose replicate", 12);
                OkDialog(schedulingOptionsDlg, schedulingOptionsDlg.OkDialog);
                WaitForClosedForm(exportTransitionList2);

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

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

                // Remove 2 minute gradient
                // Renaming replicates
                var manageResultsDlg2 = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
                PauseForScreenShot <SkylineWindow>("Ready to remove", 20);

                RunUI(() =>
                {
                    doc = SkylineWindow.DocumentUI;
                    var chromatograms = doc.Settings.MeasuredResults.Chromatograms;
                    var chrom         = chromatograms[0];
                    manageResultsDlg2.SelectedChromatograms = new[] { chrom };
                    manageResultsDlg2.RemoveReplicates();
                });
                for (var i = 1; i < 5; i++)
                {
                    var iC = i;
                    RunUI(() =>
                    {
                        doc = SkylineWindow.DocumentUI;
                        var chromatograms = doc.Settings.MeasuredResults.Chromatograms;
                        var chrom         = chromatograms[iC];
                        manageResultsDlg2.SelectedChromatograms = new[] { chrom };
                    });

                    var    renameDlg = ShowDialog <RenameResultDlg>(manageResultsDlg2.RenameResult);
                    string newName;
                    switch (i)
                    {
                    case 1:
                        newName = "1:1_1";
                        break;

                    case 2:
                        newName = "1:1_2";
                        break;

                    case 3:
                        newName = "2:1_2";
                        break;

                    default:
                        newName = "1:2_2";
                        break;
                    }
                    RunUI(() =>
                    {
                        renameDlg.ReplicateName = newName;
                        renameDlg.OkDialog();
                    });
                    WaitForClosedForm(renameDlg);
                }

                PauseForScreenShot <SkylineWindow>("Renaming replicates", 15);
                RunUI(manageResultsDlg2.OkDialog);
                WaitForClosedForm(manageResultsDlg2);

                SelectNode(SrmDocument.Level.Molecules, 0);
                PauseForScreenShot <SkylineWindow>("Inspecting ratios", 16);

                // Linearity

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

                IDictionary <string, Tuple <SampleType, double?> > sampleTypes =
                    new Dictionary <string, Tuple <SampleType, double?> > {
                    { "1:1_1", new Tuple <SampleType, double?>(SampleType.STANDARD, 1) },
                    { "1:1_2", new Tuple <SampleType, double?>(SampleType.STANDARD, 1) },
                    { "2:1_2", new Tuple <SampleType, double?>(SampleType.STANDARD, 2) },
                    { "1:2_2", new Tuple <SampleType, double?>(SampleType.STANDARD, .5) },
                };
                SetDocumentGridSampleTypesAndConcentrations(sampleTypes);
                PauseForScreenShot <DocumentGridForm>("Document Grid - sample types and concentrations ", 17);
                OkDialog(documentGrid, documentGrid.Close); // Hide the document grid

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

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

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

                var calibrationForm = ShowDialog <CalibrationForm>(() => SkylineWindow.ShowCalibrationForm());
                PauseForScreenShot <CalibrationForm>("Calibration Curve ", 18);
                OkDialog(calibrationForm, calibrationForm.Close); // Hide the calibration window

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

                var editCurrentCE = ShowDialog <EditCEDlg>(transitionSettingsUI2.EditCECurrent);
                RunUI(() =>
                {
                    editCurrentCE.StepSize  = 2;
                    editCurrentCE.StepCount = 5;
                });
                PauseForScreenShot <EditCEDlg>("Edit Collision Energy Equation form", 18);

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

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

                var schedDlg = ShowDialog <SchedulingOptionsDlg>(() => exportTransitionList3.OkDialog(GetTestPath("TL_CE_Opt")));
                PauseForScreenShot <SchedulingOptionsDlg>("Scheduling", 19);
                RunUI(schedDlg.OkDialog);
                WaitForClosedForm(exportTransitionList3);

                // Import CE optimization runs
                using (new WaitDocumentChange(1, true))
                {
                    var importResultsDlg1 = ShowDialog <ImportResultsDlg>(SkylineWindow.ImportResults);
                    RunUI(() =>
                    {
                        importResultsDlg1.RadioCreateMultipleChecked = true;
                        importResultsDlg1.OptimizationName           = ExportOptimize.CE;
                        importResultsDlg1.ReplicateName = "CE Optimization";
                    });
                    PauseForScreenShot <ImportResultsDlg>("Setting new replicate name to CE Optimization", 30);
                    var openDataSourceDialog1 = ShowDialog <OpenDataSourceDialog>(() => importResultsDlg1.OkDialog());
                    RunUI(() =>
                    {
                        openDataSourceDialog1.CurrentDirectory = new MsDataFilePath(GetTestPath("CE Optimization"));
                        openDataSourceDialog1.SelectAllFileType(ExtWatersRaw);
                    });
                    PauseForScreenShot <OpenDataSourceDialog>("Import Results Files form", 20);
                    OkDialog(openDataSourceDialog1, openDataSourceDialog1.Open);
                    PauseForScreenShot <SkylineWindow>("Skyline shows new replicate \"CE Optimization\"", 32);
                    RunUI(() =>
                    {
                        SkylineWindow.Size = new Size(1600, 960);
                        AdjustSequenceTreePanelWidth();
                        SkylineWindow.ShowSingleTransition();
                        SkylineWindow.ShowSplitChromatogramGraph(true);
                    });
                    PauseForScreenShot <SkylineWindow>("Split graph", 21);

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

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

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

                    var schedDlg2 = ShowDialog <SchedulingOptionsDlg>(() => exportTransitionList4.OkDialog(GetTestPath("TL_CE_Final.csv")));
                    PauseForScreenShot <SchedulingOptionsDlg>("Final Scheduling", 26);
                    RunUI(schedDlg2.OkDialog);
                }
            }
        }
        protected override void DoTest()
        {
            // Inserting a Transition List, p. 2
            {
                var doc = SkylineWindow.Document;

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

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


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

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

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

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

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

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

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


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


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

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

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

                ImportReplicates(true);

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

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

                var docResults = SkylineWindow.Document;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                PauseForScreenShot <DocumentGridForm>("Document Grid - Peptide Ratio Results", 15);
            }
        }
Beispiel #20
0
        protected override void DoTest()
        {
            // Inserting a Transition List, p. 2
            {
                var doc = SkylineWindow.Document;

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

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

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

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

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

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

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

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

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

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

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

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

                SelectNode(SrmDocument.Level.MoleculeGroups, 0);

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

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

                RestoreViewOnScreen(9);
                PauseForScreenShot <SkylineWindow>("Skyline window multi-replicate layout", 9);
            }
        }
Beispiel #21
0
        private void TestCancellation(bool initiallyVisible)
        {
            string mz5 = ExtensionTestContext.ExtMz5;
            int    initialStatusHeight = 0;

            RunUI(() => initialStatusHeight = SkylineWindow.StatusBarHeight);
            var files = new[] { "8fmol" + mz5, "20fmol" + mz5, "40fmol" + mz5, "200fmol" + mz5 };

            OpenDocument("RetentionTimeFilterTest.sky");
            var skyfile = initiallyVisible ? "TestImportResultsCancelA.sky" : "TestImportResultsCancelB.sky";

            RunUI(() => { SkylineWindow.SaveDocument(TestFilesDir.GetTestPath(skyfile)); });  // Make a clean copy

            // Try individual cancellation - can be timing dependent (do we get to the cancel button quickly enough?) so allow some retry
            int retry = 0;

            for (; retry < maxTries; retry++)
            {
                RemovePartialCacheFiles(files);
                OpenDocument(skyfile);
                Assert.IsFalse(SkylineWindow.Document.Settings.HasResults);
                Settings.Default.AutoShowAllChromatogramsGraph  = initiallyVisible; // Start with progress window hidden?
                Settings.Default.ImportResultsSimultaneousFiles =
                    (int)MultiFileLoader.ImportResultsSimultaneousFileOptions.many; // Ensure all buttons are enabled
                ImportResultsAsync(files);
                WaitForConditionUI(
                    () => SkylineWindow.Document.IsLoaded ||
                    (SkylineWindow.ImportingResultsWindow != null &&
                     SkylineWindow.ImportingResultsWindow.ProgressTotalPercent >= 1));    // Get at least partway in
                // Make sure status bar height does not change showing import progress
                // Failure here is usually caused by statusProgress.Size y-dimension getting reset to 20 instead of 16
                RunUI(() => Assert.AreEqual(initialStatusHeight, SkylineWindow.StatusBarHeight, "Progress indicator changed status bar height"));
                if (!initiallyVisible)
                {
                    RunUI(() => SkylineWindow.ShowAllChromatogramsGraph()); // Turn it on
                }
                var dlg2 = TryWaitForOpenForm <AllChromatogramsGraph>(30000, () => SkylineWindow.Document.IsLoaded);
                if (dlg2 == null)
                {
                    if (SkylineWindow.Document.IsLoaded)
                    {
                        continue; // Loaded faster than we could react
                    }
                    else
                    {
                        dlg2 = WaitForOpenForm <AllChromatogramsGraph>();
                    }
                }
                WaitForConditionUI(30 * 1000, () => dlg2.ProgressTotalPercent >= 1 && dlg2.Files.Count() == 4); // Get a least a little way in
                int    cancelIndex  = retry % 4;
                string cancelTarget = null;
                RunUI(() =>
                {
                    var fileStatus = dlg2.Files.ToArray();
                    Assert.AreEqual(4, fileStatus.Length);
                    for (int i = 0; i < files.Length; i++)
                    {
                        var statusCancel = fileStatus[(cancelIndex + i) % 4];
                        if (0 < statusCancel.Progress && statusCancel.Progress < 100)
                        {
                            cancelTarget = Path.GetFileNameWithoutExtension(statusCancel.FilePath.GetFilePath());
                            dlg2.FileButtonClick(cancelTarget);
                            Assert.AreEqual(3, SkylineWindow.Document.Settings.MeasuredResults.Chromatograms.Count);
                            Assert.IsFalse(SkylineWindow.Document.Settings.MeasuredResults.ContainsChromatogram(cancelTarget));
                            break;
                        }
                    }
                });
                WaitForDocumentLoaded();
                WaitForClosedAllChromatogramsGraph();

                if (cancelTarget == null)
                {
                    continue;   // Found everything at 100%
                }
                int fileCheck = 0;
                foreach (var file in files)
                {
                    int             index;
                    ChromatogramSet chromatogramSet;
                    var             chromatogramSetName = file.Replace(mz5, "");
                    // Can we find a loaded chromatogram set by this name?
                    SkylineWindow.Document.Settings.MeasuredResults.TryGetChromatogramSet(chromatogramSetName,
                                                                                          out chromatogramSet, out index);
                    if (!chromatogramSetName.Equals(cancelTarget))
                    {
                        // Should always find it since we didn't try to cancel this one
                        if (index == -1)
                        {
                            Assert.AreNotEqual(-1, index, string.Format("Missing chromatogram set {0} after cancelling {1}", chromatogramSetName, cancelTarget));
                        }
                        fileCheck++;
                    }
                    else if (index == -1)
                    {
                        fileCheck++;
                    }
                }
                if (fileCheck == files.Length)
                {
                    break;  // Success
                }
            }

            if (retry >= maxTries)
            {
                Assert.Fail("Failed to cancel individual file import after {0} tries", retry);
            }

            // Cancelled load should revert to initial document
            if (initiallyVisible)
            {
                CancelAll(new[] { files[0] }, false);
                CancelAll(new[] { files[3] }, true);
                CancelAll(files, false);
                CancelAll(files, true);
            }

            for (retry = 0; retry < maxTries; retry++)
            {
                // Now try a proper import
                Settings.Default.AutoShowAllChromatogramsGraph = initiallyVisible;
                RemovePartialCacheFiles(files);
                OpenDocument("RetentionTimeFilterTest.sky");
                ImportResultsAsync(files);
                if (!TryWaitForConditionUI(() =>
                                           SkylineWindow.ImportingResultsWindow != null &&
                                           SkylineWindow.ImportingResultsWindow.ProgressTotalPercent >= 1)) // Get at least partway in
                {
                    Assert.Fail("AllChromagotramsGraph missing in action");
                }

                if (!initiallyVisible)
                {
                    RunUI(() => SkylineWindow.ShowAllChromatogramsGraph()); // Turn it on
                }

                var dlgACG = TryWaitForOpenForm <AllChromatogramsGraph>(5000, () => SkylineWindow.Document.IsLoaded);
                if (dlgACG == null)
                {
                    continue;   // Try again
                }
                Assert.IsTrue(dlgACG.ChromatogramManager.SupportAllGraphs);
                Assert.IsNotNull(dlgACG.SelectedControl,
                                 "unable to select a loader control in chromatogram progress window");
                Assert.IsTrue(dlgACG.Width > 500,
                              "Initially hidden chromatogram progress window did not size properly when enabled by user");
                // Did it resize properly?
                WaitForDocumentLoaded();
                WaitForClosedAllChromatogramsGraph();
                AssertResult.IsDocumentResultsState(SkylineWindow.Document, "8fmol", 4, 4, 0, 13, 0);
                AssertResult.IsDocumentResultsState(SkylineWindow.Document, "20fmol", 5, 5, 0, 13, 0);
                AssertResult.IsDocumentResultsState(SkylineWindow.Document, "40fmol", 3, 3, 0, 11, 0);
                AssertResult.IsDocumentResultsState(SkylineWindow.Document, "200fmol", 4, 4, 0, 12, 0);

                break;
            }
        }