public ImportPeptideSearchDlg(SkylineWindow skylineWindow, LibraryManager libraryManager)
        {
            SkylineWindow = skylineWindow;
            ImportPeptideSearch = new ImportPeptideSearch();

            InitializeComponent();

            Icon = Resources.Skyline;

            CurrentPage = Pages.spectra_page;
            btnNext.Text = Resources.ImportPeptideSearchDlg_ImportPeptideSearchDlg_Next;
            AcceptButton = btnNext;
            btnNext.Enabled = HasUnmatchedLibraryRuns(SkylineWindow.DocumentUI);

            // Create and add wizard pages
            BuildPepSearchLibControl = new BuildPeptideSearchLibraryControl(SkylineWindow, ImportPeptideSearch, libraryManager)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(2, 50)
            };
            BuildPepSearchLibControl.InputFilesChanged += BuildPepSearchLibForm_OnInputFilesChanged;
            buildSearchSpecLibPage.Controls.Add(BuildPepSearchLibControl);

            ImportFastaControl = new ImportFastaControl(SkylineWindow)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(2, 60)
            };
            importFastaPage.Controls.Add(ImportFastaControl);

            MatchModificationsControl = new MatchModificationsControl(SkylineWindow, ImportPeptideSearch)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(2, 60)
            };
            matchModificationsPage.Controls.Add(MatchModificationsControl);

            TransitionSettingsControl = new TransitionSettingsControl(SkylineWindow)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(18, 60)
            };
            transitionSettingsUiPage.Controls.Add(TransitionSettingsControl);

            FullScanSettingsControl = new FullScanSettingsControl(SkylineWindow)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(18, 50)
            };
            ms1FullScanSettingsPage.Controls.Add(FullScanSettingsControl);

            ImportResultsControl = new ImportResultsControl(ImportPeptideSearch, SkylineWindow.DocumentFilePath)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(2, 60)
            };
            getChromatogramsPage.Controls.Add((Control) ImportResultsControl);

            _pagesToSkip = new HashSet<Pages>();
        }
        public MatchModificationsControl(SkylineWindow skylineWindow, ImportPeptideSearch importPeptideSearch)
        {
            SkylineWindow = skylineWindow;
            ImportPeptideSearch = importPeptideSearch;

            InitializeComponent();
        }
 public ChooseSchedulingReplicatesDlg(SkylineWindow skylineWindow)
 {
     InitializeComponent();
     Icon = Resources.Skyline;
     SkylineWindow = skylineWindow;
     double windowLength = SkylineWindow.Document.Settings.TransitionSettings.FullScan.RetentionTimeFilterLength;
     labelInstructions.Text = string.Format(labelInstructions.Text, windowLength);
 }
        public ImportResultsDIAControl(SkylineWindow skylineWindow)
        {
            SkylineWindow = skylineWindow;

            InitializeComponent();

            _foundResultsFiles = new BindingList<ImportPeptideSearch.FoundResultsFile>();
            listResultsFiles.DataSource = _foundResultsFiles;
            listResultsFiles.DisplayMember = "Name"; // Not L10N
        }
Esempio n. 5
0
 public FindResultsForm(SkylineWindow skylineWindow, IEnumerable<FindResult> findResults)
 {
     InitializeComponent();
     SkylineWindow = skylineWindow;
     foreach (var findResult in findResults)
     {
         listView.Items.Add(MakeListViewItem(findResult));
     }
     // Width=-1 means auto-adjust to the length of the longest item
     colHdrDisplayText.Width = -1;
 }
Esempio n. 6
0
 public bool DoStartupAction(SkylineWindow skylineWindow)
 {
     if (skylineWindow.Visible)
     {
         OpenSkylineStartupSettingsUI(skylineWindow);
     }
     else
     {
         skylineWindow.Shown += (sender, eventArgs) => OpenSkylineStartupSettingsUI(skylineWindow);
     }
     return true;
 }
        public BuildPeptideSearchLibraryControl(SkylineWindow skylineWindow, ImportPeptideSearch importPeptideSearch, LibraryManager libraryManager)
        {
            SkylineWindow = skylineWindow;
            ImportPeptideSearch = importPeptideSearch;
            LibraryManager = libraryManager;

            InitializeComponent();

            textCutoff.Text = ImportPeptideSearch.CutoffScore.ToString(LocalizationHelper.CurrentCulture);

            if (SkylineWindow.Document.PeptideCount == 0)
                cbFilterForDocumentPeptides.Hide();
        }
Esempio n. 8
0
 public AlignmentForm(SkylineWindow skylineWindow)
 {
     InitializeComponent();
     SkylineWindow = skylineWindow;
     Icon = Resources.Skyline;
     bindingSource.DataSource = _dataRows;
     colIntercept.CellTemplate.Style.Format = "0.0000"; // Not L10N
     colSlope.CellTemplate.Style.Format = "0.0000"; // Not L10N
     colCorrelationCoefficient.CellTemplate.Style.Format = "0.0000"; // Not L10N
     colUnrefinedSlope.CellTemplate.Style.Format = "0.0000"; // Not L10N
     colUnrefinedIntercept.CellTemplate.Style.Format = "0.0000"; // Not L10N
     colUnrefinedCorrelationCoefficient.CellTemplate.Style.Format = "0.0000"; // Not L10N
 }
Esempio n. 9
0
        public StartPageSettingsUI(SkylineWindow skylineWindow)
        {
            _skylineWindow = skylineWindow;

            InitializeComponent();

            AcceptButton = nextBtn;
            CenterToParent();
            if (_skylineWindow.DocumentUI.Settings.TransitionSettings.Integration.IsIntegrateAll)
                radioBtnQuant.Checked = true;

            integrateAllOffText = labelIntegrateAll.Text;
            integrateAllOnText = Resources.StartPageSettingsUI_StartPageSettingsUI_Integrate_all__on;
        }
        public TransitionSettingsControl(SkylineWindow skylineWindow)
        {
            SkylineWindow = skylineWindow;
            TransitionSettings settings = SkylineWindow.DocumentUI.Settings.TransitionSettings;

            InitializeComponent();

            PrecursorCharges = settings.Filter.PrecursorCharges.ToArray();
            IonCharges = settings.Filter.ProductCharges.ToArray();
            IonTypes = settings.Filter.IonTypes.Union(new[] {IonType.precursor, IonType.y}).ToArray(); // Add p, y if not already set
            ExclusionUseDIAWindow = settings.Filter.ExclusionUseDIAWindow;
            IonMatchTolerance = settings.Libraries.IonMatchTolerance;
            IonCount = settings.Libraries.IonCount;
        }
Esempio n. 11
0
        public ImportFastaControl(SkylineWindow skylineWindow)
        {
            SkylineWindow = skylineWindow;

            InitializeComponent();

            ImportFastaHelper = new ImportFastaHelper(tbxFasta, tbxError, panelError);

            tbxFastaHeightDifference = Height - tbxFasta.Height;

            _driverEnzyme = new SettingsListComboDriver<Enzyme>(comboEnzyme, Settings.Default.EnzymeList);
            _driverEnzyme.LoadList(SkylineWindow.Document.Settings.PeptideSettings.Enzyme.GetKey());

            MaxMissedCleavages = skylineWindow.Document.Settings.PeptideSettings.DigestSettings.MaxMissedCleavages;
        }
Esempio n. 12
0
 public LiveResultsGrid(SkylineWindow skylineWindow)
 {
     InitializeComponent();
     SkylineWindow = skylineWindow;
     _dataSchema = new SkylineDataSchema(skylineWindow, SkylineDataSchema.GetLocalizedSchemaLocalizer());
     DataGridViewPasteHandler.Attach(skylineWindow, DataGridView);
     BindingListSource.ListChanged += bindingListSource_ListChanged;
     BindingListSource.CurrentChanged += bindingListSource_CurrentChanged;
     DataGridView.DataBindingComplete += boundDataGridView_DataBindingComplete;
     var contextMenuStrip = databoundGridControl.contextMenuStrip;
     contextMenuStrip.Items.Insert(0, new ToolStripSeparator());
     for (int i = contextMenuResultsGrid.Items.Count - 1; i >= 0; i--)
     {
         contextMenuStrip.Items.Insert(0, contextMenuResultsGrid.Items[i]);
     }
     contextMenuStrip.Opening += contextMenu_Opening;
 }
Esempio n. 13
0
        public CalibrationForm(SkylineWindow skylineWindow)
        {
            InitializeComponent();
            _skylineWindow = skylineWindow;

            zedGraphControl.MasterPane.Border.IsVisible = false;
            zedGraphControl.GraphPane.Border.IsVisible = false;
            zedGraphControl.GraphPane.Chart.Border.IsVisible = false;
            zedGraphControl.GraphPane.XAxis.Title.Text = QuantificationStrings.Analyte_Concentration;
            zedGraphControl.GraphPane.YAxis.Title.Text = QuantificationStrings.CalibrationCurveFitter_GetYAxisTitle_Peak_Area;
            zedGraphControl.GraphPane.Legend.IsVisible = false;
            zedGraphControl.GraphPane.Title.Text = null;
            zedGraphControl.GraphPane.Title.FontSpec.Size = 12f;
            zedGraphControl.GraphPane.XAxis.MajorTic.IsOpposite = false;
            zedGraphControl.GraphPane.XAxis.MinorTic.IsOpposite = false;
            zedGraphControl.GraphPane.YAxis.MajorTic.IsOpposite = false;
            zedGraphControl.GraphPane.YAxis.MinorTic.IsOpposite = false;
        }
Esempio n. 14
0
        public ConfigureToolsDlg(SkylineWindow parent)
        {
            InitializeComponent();
            SkylineWindowParent = parent;
            PopulateMacroList();
            // Initialize the report comboBox.
            // CONSIDER: Settings list editing is currently disabled, because
            //           it had problems with the empty element added to the list.
            //           Might be nice to allow report spec editing in this form
            //           some day, though.
            _driverReportSpec = new ComboBoxDriverWrapper(components, comboReport);

            if (ToolStoreUtil.ToolStoreClient != null)
                fromWebAddContextMenuItem.Visible = fromWebAddContextMenuItem.Enabled = true;

            Removelist = new List<ToolDescription>();
            Init(false);
        }
        public FullScanSettingsControl(SkylineWindow skylineWindow)
        {
            SkylineWindow = skylineWindow;

            InitializeComponent();

            InitializeMs1FilterUI();
            InitializeMsMsFilterUI();
            InitializeRetentionTimeFilterUI();

            // Update the precursor analyzer type in case the SelectedIndex is still -1
            UpdatePrecursorAnalyzerType();
            UpdateProductAnalyzerType();

            PrecursorIsotopesCurrent = FullScan.PrecursorIsotopes;
            PrecursorMassAnalyzer = FullScan.PrecursorMassAnalyzer;

            _prevval_comboIsolationScheme = IsolationScheme; // initialize previous value to initial value
        }
Esempio n. 16
0
 public void LongWaitDlgAction(SkylineWindow skylineWindow)
 {
     skylineWindow.ResetDefaultSettings();
     try
     {
         using (var longWaitDlg = new LongWaitDlg
         {
             Text = Resources.ActionTutorial_LongWaitDlgAction_Downloading_Tutorial_Zip_File,
             Message =
                 String.Format(
                     Resources
                         .ActionTutorial_LongWaitDlgAction_Downloading_to___0__1_Tutorial_will_open_in_browser_when_download_is_complete_,
                     getTempPath(), Environment.NewLine),
             ProgressValue = 0
         })
         {
             longWaitDlg.PerformWork(skylineWindow, 1000, DownloadTutorials);
             if (longWaitDlg.IsCanceled)
             {
                 return;
             }
         }
         using (var longWaitDlg = new LongWaitDlg
         {
             Text =
                 Resources.ActionTutorial_LongWaitDlgAction_Extracting_Tutorial_Zip_File_in_the_same_directory_,
             ProgressValue = 0
         })
         {
             longWaitDlg.PerformWork(skylineWindow, 1000, ExtractTutorial);
         }
     }
     catch (Exception exception)
     {
         MessageDlg.ShowWithException(Program.MainWindow, string.Format(Resources.ActionTutorial_DownloadTutorials_Error__0_, exception.Message), exception);
     }
 }
        private void TofTest()
        {
            // Working wih High-Resolution Mass Spectra.

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

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

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

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

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


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

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

            RunUI(() => AssertEx.AreComparableStrings(Resources.NoFullScanFilteringException_NoFullScanFilteringException_To_extract_chromatograms_from__0__full_scan_settings_must_be_enabled_,
                                                      messageDlg.Message, 1));
            PauseForScreenShot <MessageDlg>("Error message (expected)", 27);

            OkDialog(messageDlg, messageDlg.OkDialog);

            RunUI(() =>
            {
                SkylineWindow.Undo();
            });

            var document = SkylineWindow.Document;

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

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

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

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

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }

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

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

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

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

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

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

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

                OkDialog(peptideSettingsUI, peptideSettingsUI.CancelDialog);
            }

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

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

                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }

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

            RunUI(() =>
            {
                // Make sure UI is up to date to avoid race condition
                chooseSchedulingReplicateDlg.UpdateUi();
                chooseSchedulingReplicateDlg.SelectOrDeselectAll(true);
            });
            RunDlg <ImportResultsDlg>(chooseSchedulingReplicateDlg.OkDialog, importResultsDlg2 =>
            {
                string[] filePaths =
                {
                    GetTestPath(@"TOF\1-BSA-50amol" + ExtAgilentRaw),
                    GetTestPath(@"TOF\2-BSA-100amol" + ExtAgilentRaw),
                    GetTestPath(@"TOF\3-BSA-1fmol" + ExtAgilentRaw),
                    GetTestPath(@"TOF\4-BSA-10fmol" + ExtAgilentRaw),
                    GetTestPath(@"TOF\5-BSA-100fmol" + ExtAgilentRaw),
                };
                importResultsDlg2.NamedPathSets = importResultsDlg2.GetDataSourcePathsFileReplicates(filePaths.Select(MsDataFileUri.Parse));
                importResultsDlg2.OkDialog();
            });
            //Give the Raw files some time to be processed.
            WaitForCondition(15 * 60 * 1000, () => SkylineWindow.Document.Settings.HasResults && SkylineWindow.Document.Settings.MeasuredResults.IsLoaded); // 15 minutes
            RunUI(() => SkylineWindow.ShowGraphSpectrum(false));
            RunUI(() =>
            {
                Assert.IsFalse(SkylineWindow.IsGraphSpectrumVisible);
                Assert.AreEqual(6, SkylineWindow.GraphChromatograms.Count(graphChrom => !graphChrom.IsHidden));
                var chromGraphs = SkylineWindow.GraphChromatograms.ToArray();
                Assert.AreEqual(6, chromGraphs.Length);
            });

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

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

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

            RunUI(SkylineWindow.AutoZoomBestPeak);
            WaitForGraphs();

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

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

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

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

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

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

            RunUI(() => SkylineWindow.SaveDocument());
            WaitForConditionUI(() => !SkylineWindow.Dirty);
        }
Esempio n. 18
0
        protected override void DoTest()
        {
            string skyfile = TestFilesDir.GetTestPath("test.sky");

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

            Stopwatch loadStopwatch = new Stopwatch();

            loadStopwatch.Start();

            // Enable use of drift times in spectral library
            var  peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            bool useDriftTimes     = true;

            RunUI(() =>
            {
                // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                peptideSettingsUI.IsUseSpectralLibraryDriftTimes         = useDriftTimes;
                peptideSettingsUI.SpectralLibraryDriftTimeResolvingPower = 50;
            });
            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);

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

            string lo  = GetTestPath("40minG_WBP_wide_z2-3_low_BSA_5pmol_02.pep.xml");
            string mid = GetTestPath("40minG_WBP_wide_z2-3_mid_BSA_5pmol_01.pep.xml");
            string up  = GetTestPath("40minG_WBP_wide_z2-3_up_BSA_5pmol_02.pep.xml");

            string[] searchFiles = { lo, mid, up };
            var      doc         = SkylineWindow.Document;

            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage ==
                              ImportPeptideSearchDlg.Pages.spectra_page);
                importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchFiles);
                importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.95;
                importPeptideSearchDlg.BuildPepSearchLibControl.FilterForDocumentPeptides = false;
            });

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

            // Verify document library was built
            string docLibPath          = BiblioSpecLiteSpec.GetLibraryFileName(skyfile);
            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 files should be found, and we should
            // just be able to move to the next page.
            RunUI(() => Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page));
            RunUI(() =>
            {
                var importResultsControl = (ImportResultsControl)importPeptideSearchDlg.ImportResultsControl;
                importResultsControl.ExcludeSpectrumSourceFiles = true;
            });
            var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck);

            RunUI(() =>
            {
                importResultsNameDlg.NoDialog();
            });
            WaitForClosedForm(importResultsNameDlg);
            // Modifications are already set up, so that page should get skipped.
            RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorCharges      = new [] { 2, 3, 4, 5 });
            RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof);
            RunUI(() => importPeptideSearchDlg.ClickNextButton()); // Accept the full scan settings

            // We're on the "Import FASTA" page of the wizard.
            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.import_fasta_page);
                importPeptideSearchDlg.ImportFastaControl.SetFastaContent(GetTestPath("SwissProt.bsa-mature"));
            });
            var peptidesPerProteinDlg = ShowDialog <PeptidesPerProteinDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck);

            OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog);
            WaitForClosedForm(importPeptideSearchDlg);
            WaitForDocumentChangeLoaded(doc, 15 * 60 * 1000); // 15 minutes
            var doc1 = WaitForDocumentLoaded(400000);

            AssertEx.IsDocumentState(doc1, null, 1, 40, 54, 162);
            loadStopwatch.Stop();
            DebugLog.Info("load time = {0}", loadStopwatch.ElapsedMilliseconds);

            float  tolerance = (float)doc1.Settings.TransitionSettings.Instrument.MzMatchTolerance;
            double maxHeight = 0;
            var    results   = doc1.Settings.MeasuredResults;

            foreach (var pair in doc1.PeptidePrecursorPairs)
            {
                ChromatogramGroupInfo[] chromGroupInfo;
                Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup,
                                                          tolerance, true, out chromGroupInfo));

                foreach (var chromGroup in chromGroupInfo)
                {
                    foreach (var tranInfo in chromGroup.TransitionPointSets)
                    {
                        maxHeight = Math.Max(maxHeight, tranInfo.MaxIntensity);
                    }
                }
            }
            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            Assert.AreEqual(useDriftTimes ? 972186 : 1643104, maxHeight, 1);
        }
Esempio n. 19
0
        private void Testit(
            bool useDriftTimes, // If false, don't use any drift information in chromatogram extraction
            ref LibraryIonMobilityInfo driftInfoExplicitDT
            )
        {
            bool   CCSonly = driftInfoExplicitDT != null; // If true, force conversion from CCS to DT
            var    ext     = useDriftTimes ? (CCSonly ? "CCS" : "DT") : "train";
            string skyfile = TestFilesDir.GetTestPath("test_" + ext + ".sky");

            RunUI(() =>
            {
                SkylineWindow.NewDocument(true);
                SkylineWindow.SaveDocument(skyfile);
            });



            Stopwatch loadStopwatch = new Stopwatch();

            loadStopwatch.Start();

            // Enable use of drift times in spectral library
            var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() =>
            {
                // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                peptideSettingsUI.IsUseSpectralLibraryDriftTimes         = useDriftTimes;
                peptideSettingsUI.SpectralLibraryDriftTimeResolvingPower = 50;
            });
            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);

            // Launch import peptide search wizard
            var importPeptideSearchDlg = ShowDialog <ImportPeptideSearchDlg>(SkylineWindow.ShowImportPeptideSearchDlg);
            var basename      = _testCase == 1 ? "40minG_WBP_wide_z2-3_mid_BSA_5pmol_01" : "09_BSAtrypticdigest_5uL_IMQTOF_AltFramesdtramp_dAJS009";
            var nextFile      = _testCase == 1 ? null : "10_BSAtrypticdigest_5uL_IMQTOF_AltFramesdtramp_dAJS010.d";
            var searchResults = GetTestPath(basename + ".pep.xml");

            var doc = SkylineWindow.Document;

            if (CCSonly || !useDriftTimes)
            {
                // Hide the drift time info provided by SpectrumMill, so we have to convert from CCS
                var mzxmlFile    = searchResults.Replace("pep.xml", "mzXML");
                var fileContents = File.ReadAllText(mzxmlFile);
                fileContents = fileContents.Replace(" DT=", " xx=");
                if (!useDriftTimes)
                {
                    fileContents = fileContents.Replace(" CCS=", " xxx=");
                }
                File.WriteAllText(mzxmlFile, fileContents);
            }

            var searchResultsList = new[] { searchResults };

            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage ==
                              ImportPeptideSearchDlg.Pages.spectra_page);
                importPeptideSearchDlg.BuildPepSearchLibControl.AddSearchFiles(searchResultsList);
                importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.95;
                importPeptideSearchDlg.BuildPepSearchLibControl.FilterForDocumentPeptides = false;
            });

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

            // Verify document library was built
            string docLibPath          = BiblioSpecLiteSpec.GetLibraryFileName(skyfile);
            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 files should be found, and we should
            // just be able to move to the next page.
            RunUI(() => Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page));
            RunUI(() =>
            {
                var importResultsControl = (ImportResultsControl)importPeptideSearchDlg.ImportResultsControl;
                importResultsControl.ExcludeSpectrumSourceFiles = true;
                importResultsControl.UpdateResultsFiles(new [] { TestFilesDirs[0].PersistentFilesDir }, true); // Go look in the persistent files dir
            });
            if (searchResultsList.Length > 1)
            {
                // Deal with the common name start dialog
                var importResultsNameDlg = ShowDialog <ImportResultsNameDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck);
                RunUI(() =>
                {
                    importResultsNameDlg.NoDialog();
                });
                WaitForClosedForm(importResultsNameDlg);
            }
            else
            {
                RunUI(() => importPeptideSearchDlg.ClickNextButtonNoCheck());
            }
            // Modifications are already set up, so that page should get skipped.
            RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorCharges      = new [] { 2, 3, 4, 5 });
            RunUI(() => importPeptideSearchDlg.FullScanSettingsControl.PrecursorMassAnalyzer = FullScanMassAnalyzerType.tof);
            RunUI(() => importPeptideSearchDlg.ClickNextButton()); // Accept the full scan settings

            // We're on the "Import FASTA" page of the wizard.
            RunUI(() =>
            {
                Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.import_fasta_page);
                importPeptideSearchDlg.ImportFastaControl.SetFastaContent(GetTestPath("SwissProt.bsa-mature"));
            });
            var peptidesPerProteinDlg = ShowDialog <PeptidesPerProteinDlg>(importPeptideSearchDlg.ClickNextButtonNoCheck);

            OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog);

            WaitForClosedForm(importPeptideSearchDlg);
            var doc1 = WaitForDocumentChangeLoaded(doc, 15 * 60 * 1000); // 15 minutes

            if (_testCase == 1)
            {
                AssertEx.IsDocumentState(doc1, null, 1, 34, 45, 135);
            }
            else
            {
                AssertEx.IsDocumentState(doc1, null, 1, 36, 43, 129);
            }
            loadStopwatch.Stop();
            DebugLog.Info("load time = {0}", loadStopwatch.ElapsedMilliseconds);
            var errmsg = "";

            if (!useDriftTimes)
            {
                // Inspect the loaded data directly to derive DT and CCS
                // Verify ability to extract predictions from raw data
                var peptideSettingsDlg = ShowDialog <PeptideSettingsUI>(
                    () => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction));

                // Simulate user picking Edit Current from the Drift Time Predictor combo control
                var driftTimePredictorDlg = ShowDialog <EditDriftTimePredictorDlg>(peptideSettingsDlg.AddDriftTimePredictor);
                RunUI(() =>
                {
                    driftTimePredictorDlg.SetPredictorName("test");
                    driftTimePredictorDlg.SetResolvingPower(50);
                    driftTimePredictorDlg.GetDriftTimesFromResults();
                    driftTimePredictorDlg.OkDialog();
                });
                WaitForClosedForm(driftTimePredictorDlg);
                RunUI(() =>
                {
                    peptideSettingsDlg.OkDialog();
                });
                WaitForClosedForm(peptideSettingsDlg);

                var document    = SkylineWindow.Document;
                var measuredDTs = document.Settings.PeptideSettings.Prediction.IonMobilityPredictor.MeasuredMobilityIons;
                Assert.IsNotNull(driftInfoExplicitDT, "driftInfoExplicitDT != null");
                var explicitDTs = driftInfoExplicitDT.GetIonMobilityDict();

                string errMsgAll = string.Empty;
                // A handful of peptides that really should have been trained on a clean sample
                // CONSIDER: or are they multiple conformers? They have multiple hits with distinct IM in the pepXML
                var expectedDiffs = LibKeyMap <double> .FromDictionary(new Dictionary <LibKey, double>
                {
                    { new PeptideLibraryKey("LC[+57.0]VLHEK", 2), 18.09 },
                    { new PeptideLibraryKey("EC[+57.0]C[+57.0]DKPLLEK", 3), 7.0 },
                    { new PeptideLibraryKey("SHC[+57.0]IAEVEK", 3), 6.0 },
                    { new PeptideLibraryKey("DDPHAC[+57.0]YSTVFDK", 2), 24.0 }
                }).AsDictionary();

                foreach (var pair in doc1.PeptidePrecursorPairs)
                {
                    string errMsg   = string.Empty;
                    var    key      = new LibKey(pair.NodePep.ModifiedSequence, pair.NodeGroup.PrecursorAdduct);
                    double tolerCCS = 5;
                    if (expectedDiffs.ContainsKey(key))
                    {
                        tolerCCS = expectedDiffs[key] + .1;
                    }
                    if (!explicitDTs.ContainsKey(key))
                    {
                        errMsg += "Could not locate explicit IMS info for " + key + "\n";
                    }
                    var given    = explicitDTs[key][0];
                    var measured = measuredDTs[key];
                    var msg      = CheckDeltaPct(given.CollisionalCrossSectionSqA ?? 0, measured.CollisionalCrossSectionSqA ?? 0, tolerCCS, "measured CCS", key.ToString());
                    if (!string.IsNullOrEmpty(msg))
                    {
                        errMsg += msg + CheckDeltaPct(given.IonMobility.Mobility.Value, measured.IonMobility.Mobility.Value, -1, "measured drift time", key.ToString());
                    }
                    else
                    {
                        errMsg += CheckDelta(given.IonMobility.Mobility.Value, measured.IonMobility.Mobility.Value, 10.0, "measured drift time", key.ToString());
                    }
                    errMsg += CheckDelta(given.HighEnergyIonMobilityValueOffset, measured.HighEnergyIonMobilityValueOffset, 2.0, "measured drift time high energy offset", key.ToString());
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        errMsgAll += "\n" + errMsg;
                    }
                }
                if (!string.IsNullOrEmpty(errMsgAll))
                {
                    Assert.Fail(errMsgAll);
                }
                return;
            }

            LibraryIonMobilityInfo libraryIonMobilityInfo;

            doc1.Settings.PeptideSettings.Libraries.Libraries.First().TryGetIonMobilityInfos(0, out libraryIonMobilityInfo);
            if (driftInfoExplicitDT == null)
            {
                driftInfoExplicitDT = libraryIonMobilityInfo;
            }
            else
            {
                var instrumentInfo = new DataFileInstrumentInfo(new MsDataFileImpl(GetTestPath(basename + ".d")));
                var dictExplicitDT = driftInfoExplicitDT.GetIonMobilityDict();
                foreach (var pep in doc1.Peptides)
                {
                    foreach (var nodeGroup in pep.TransitionGroups)
                    {
                        double windowDT;
                        var    calculatedDriftTime = doc1.Settings.PeptideSettings.Prediction.GetIonMobility(
                            pep, nodeGroup, libraryIonMobilityInfo, instrumentInfo, 0, out windowDT);
                        var libKey = new LibKey(pep.ModifiedSequence, nodeGroup.PrecursorAdduct);
                        IonMobilityAndCCS[] infoValueExplicitDT;
                        if (!dictExplicitDT.TryGetValue(libKey, out infoValueExplicitDT))
                        {
                            errmsg += "No driftinfo value found for " + libKey + "\n";
                        }
                        else
                        {
                            var ionMobilityInfo = infoValueExplicitDT[0];
                            var delta           = Math.Abs(ionMobilityInfo.IonMobility.Mobility.Value - calculatedDriftTime.IonMobility.Mobility.Value);
                            var acceptableDelta = (libKey.Sequence.StartsWith("DDPHAC") || libKey.Sequence.EndsWith("VLHEK")) ? 3: 1; // These were ambiguous matches
                            if (delta > acceptableDelta)
                            {
                                errmsg += String.Format("calculated DT ({0}) and explicit DT ({1}, CCS={4}) do not agree (abs delta = {2}) for {3}\n",
                                                        calculatedDriftTime.IonMobility, ionMobilityInfo.IonMobility,
                                                        delta, libKey,
                                                        ionMobilityInfo.CollisionalCrossSectionSqA ?? 0);
                            }
                        }
                    }
                }
            }

            float  tolerance = (float)doc1.Settings.TransitionSettings.Instrument.MzMatchTolerance;
            double maxHeight = 0;
            var    results   = doc1.Settings.MeasuredResults;
            var    numPeaks  = _testCase == 1 ?
                               new[] { 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 10, 7, 10, 10, 10, 10, 8, 10, 10, 10, 10, 10, 10, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 10, 10, 8, 10, 10, 10, 10, 10 } :
            new[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 };

            int npIndex = 0;

            foreach (var pair in doc1.PeptidePrecursorPairs)
            {
                ChromatogramGroupInfo[] chromGroupInfo;
                Assert.IsTrue(results.TryLoadChromatogram(0, pair.NodePep, pair.NodeGroup,
                                                          tolerance, true, out chromGroupInfo));

                foreach (var chromGroup in chromGroupInfo)
                {
                    if (numPeaks[npIndex] != chromGroup.NumPeaks)
                    {
                        errmsg += String.Format("unexpected peak count {0} instead of {1} in chromatogram {2}\r\n", chromGroup.NumPeaks, numPeaks[npIndex], npIndex);
                    }
                    npIndex++;
                    foreach (var tranInfo in chromGroup.TransitionPointSets)
                    {
                        maxHeight = Math.Max(maxHeight, tranInfo.MaxIntensity);
                    }
                }
            }
            Assert.IsTrue(errmsg.Length == 0, errmsg);
            Assert.AreEqual(_testCase == 1 ? 2265204 : 1326442, maxHeight, 1);

            // Does CCS show up in reports?
            var expectedDtWindow = _testCase == 1 ? 0.74 : 0.94;

            TestReports(doc1, 0, expectedDtWindow);

            if (nextFile != null)
            {
                // Verify that we can use library generated for one file as the default for another without its own library
                ImportResults(nextFile);
                TestReports(SkylineWindow.Document, 1, expectedDtWindow);
            }

            // And verify roundtrip of ion mobility
            AssertEx.RoundTrip(SkylineWindow.Document);
            RunUI(() =>
            {
                SkylineWindow.SaveDocument(skyfile);
                SkylineWindow.NewDocument(true);
                SkylineWindow.OpenFile(skyfile);
            });
            TestReports(SkylineWindow.Document, 1, expectedDtWindow);

            // Watch for problem with reimport after changed DT window
            var docResolvingPower  = SkylineWindow.Document;
            var peptideSettingsUI2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() =>
            {
                // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                peptideSettingsUI2.IsUseSpectralLibraryDriftTimes         = useDriftTimes;
                peptideSettingsUI2.SpectralLibraryDriftTimeResolvingPower = 40;
            });
            OkDialog(peptideSettingsUI2, peptideSettingsUI2.OkDialog);
            var docReimport = WaitForDocumentChangeLoaded(docResolvingPower);

            // Reimport data for a replicate
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg =>
            {
                var chromatograms         = docReimport.Settings.MeasuredResults.Chromatograms;
                dlg.SelectedChromatograms = new[] { chromatograms[0] };
                dlg.ReimportResults();
                dlg.OkDialog();
            });
            WaitForDocumentChangeLoaded(docReimport);
            var expectedDtWindow0 = _testCase == 2 ? 1.175 : 0.92;
            var expectedDtWindow1 = _testCase == 2 ? 0.94 : 0.92;

            TestReports(SkylineWindow.Document, 0, expectedDtWindow0, string.Format(" row {0} case {1} ccsOnly {2}", 0, _testCase, CCSonly));
            TestReports(SkylineWindow.Document, 1, expectedDtWindow1, string.Format(" row {0} case {1} ccsOnly {2}", 1, _testCase, CCSonly));
        }
Esempio n. 20
0
        protected override void DoTest()
        {
            TestSmallMolecules = false; // The presence of the extra test node without any results is incompatible with what's being tested here.

            // Open 160109_Mix1_calcurve.sky under TestFunctional\ManageResultsTest.zip
            string documentPath = TestFilesDir.GetTestPath("160109_Mix1_calcurve.sky");

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

            // Make sure collision energy equation matches with instrument type to be used
            RunUI(() => SkylineWindow.ModifyDocument("Change settings", doc =>
                                                     doc.ChangeSettings(doc.Settings.ChangeTransitionPrediction(predict =>
                                                                                                                predict.ChangeCollisionEnergy(Settings.Default.GetCollisionEnergyByName("Waters Xevo"))))));

            var document        = WaitForDocumentLoaded();
            int replicateCount0 = document.Settings.MeasuredResults.Chromatograms.Count;

            // Go to export method, using scheduled option
            var exportMethodDlg1 = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));

            RunUI(() =>
            {
                exportMethodDlg1.InstrumentType = ExportInstrumentType.WATERS;
                exportMethodDlg1.ExportStrategy = ExportStrategy.Single;
                exportMethodDlg1.OptimizeType   = ExportOptimize.NONE;
                exportMethodDlg1.MethodType     = ExportMethodType.Scheduled;
            });


            // First Use retention time average
            string csvPath1 = TestFilesDir.GetTestPath("160109_Mix1_calcurve_scheduled1.csv");

            RunDlg <SchedulingOptionsDlg>(() => exportMethodDlg1.OkDialog(csvPath1),
                                          schedulingOptionsDlg =>
            {
                // Check that on default, the radio button selected is Use retention time average
                // and the Replicate combobox is disabled
                Assert.AreEqual(ExportSchedulingAlgorithm.Average, schedulingOptionsDlg.Algorithm);
                Assert.IsNull(schedulingOptionsDlg.ReplicateNum);

                schedulingOptionsDlg.OkDialog();
            });

            WaitForClosedForm(exportMethodDlg1);

            // Export method again, using values from a single data set
            // Check that by default, Replicate combobox has the last data set showing
            // Use the last data set

            string csvPath2 = TestFilesDir.GetTestPath("160109_Mix1_calcurve_scheduled2.csv");

            int replicateIndex = replicateCount0 - 2;

            ExportScheduledReplicate(csvPath2, replicateCount0, replicateIndex, false);

            VerifyRetentionTimeChange(csvPath1, csvPath2);

            // Document should not have changed
            Assert.AreSame(document, SkylineWindow.Document);

            // Remove a peak from the scheduling replicate
            RunUI(() =>
            {
                SkylineWindow.SelectedResultsIndex = replicateIndex;
                SkylineWindow.RemovePeak(
                    document.GetPathTo((int)SrmDocument.Level.TransitionGroups, 0),
                    document.PeptideTransitionGroups.ToArray()[0],
                    null);
            });

            var docRemovedPeak = WaitForDocumentChange(document);

            string csvPath2A = TestFilesDir.GetTestPath("160109_Mix1_calcurve_scheduled2a.csv");

            ExportScheduledReplicate(csvPath2A, replicateCount0, replicateIndex, true);

            VerifyRetentionTimeChange(csvPath2, csvPath2A);

            // Delete second to last result
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg =>
            {
                var chromatograms         = document.Settings.MeasuredResults.Chromatograms;
                dlg.SelectedChromatograms = new[] { chromatograms[chromatograms.Count - 2] };
                dlg.RemoveReplicates();
                dlg.OkDialog();
            });

            var docRemoved1 = WaitForDocumentChange(docRemovedPeak);

            // Since the second to last chrmatogram out of the original set just got removed,
            // there should be the number in the set should be 1 less in the new set...
            int replicateCount1 = docRemoved1.Settings.MeasuredResults.Chromatograms.Count;

            Assert.AreEqual(replicateCount0 - 1, replicateCount1);

            string csvPath3 = TestFilesDir.GetTestPath("160109_Mix1_calcurve_scheduled3.csv");

            ExportScheduledReplicate(csvPath3, replicateCount1, 0, true);

            VerifyRetentionTimeChange(csvPath2, csvPath3);

            // Delete all but one result
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg =>
            {
                var chromatograms = docRemoved1.Settings.MeasuredResults.Chromatograms;
                for (int i = chromatograms.Count - 1; i > 0; i--)
                {
                    dlg.SelectedChromatograms = new[] { chromatograms[i] };
                    dlg.RemoveReplicates();
                }
                dlg.OkDialog();
            });

            var docRemoved2 = WaitForDocumentChange(docRemoved1);

            // Removed all but one result, so there should only be 1 result left...
            Assert.AreEqual(1, docRemoved2.Settings.MeasuredResults.Chromatograms.Count);

            string csvPath4 = TestFilesDir.GetTestPath("160109_Mix1_calcurve_scheduled4.csv");

            RunDlg <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List),
                                     exportMethodDlg4 =>
            {
                exportMethodDlg4.InstrumentType = ExportInstrumentType.WATERS;
                Assert.AreEqual(ExportStrategy.Single, exportMethodDlg4.ExportStrategy);
                Assert.IsNull(exportMethodDlg4.OptimizeType);
                Assert.AreEqual(ExportMethodType.Scheduled, exportMethodDlg4.MethodType);
                exportMethodDlg4.OkDialog(csvPath4);
            });

            // With only a single replicate scheduling options should not be presented
            Assert.IsNull(FindOpenForm <SchedulingOptionsDlg>());
            Assert.AreEqual(File.ReadAllText(csvPath3), File.ReadAllText(csvPath4));
        }
Esempio n. 21
0
        protected override void DoTest()
        {
            // Load a document with results loaded without drift filter
            string skyFile = TestFilesDir.GetTestPath("tims_test.sky");

            Program.ExtraRawFileSearchFolder = TestFilesDir.PersistentFilesDir; // So we don't have to reload the raw files, which have moved relative to skyd file
            RunUI(() => SkylineWindow.OpenFile(skyFile));

            var document = WaitForDocumentLoaded(240000);  // If it decides to remake chromatograms this can take awhile

            AssertEx.IsDocumentState(document, null, 1, 34, 89, 1007);
            RunUI(() =>
            {
                SkylineWindow.SaveDocument(TestFilesDir.GetTestPath("local.sky")); // Avoid "document changed since last edit" message
                document = SkylineWindow.DocumentUI;
            });
            var transitions = document.MoleculeTransitions.ToArray();

            // Verify ability to extract predictions from raw data
            var peptideSettingsDlg = ShowDialog <PeptideSettingsUI>(
                () => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction));

            // Simulate user picking Add from the ion mobility Predictor combo control
            var driftTimePredictorDlg = ShowDialog <EditDriftTimePredictorDlg>(peptideSettingsDlg.AddDriftTimePredictor);

            RunUI(() =>
            {
                driftTimePredictorDlg.SetPredictorName("test_tims");
                driftTimePredictorDlg.SetResolvingPower(40);
                driftTimePredictorDlg.GetDriftTimesFromResults();
                driftTimePredictorDlg.OkDialog(true); // Force overwrite if a named predictor already exists
            });
            WaitForClosedForm(driftTimePredictorDlg);
            RunUI(() =>
            {
                peptideSettingsDlg.OkDialog();
            });
            WaitForClosedForm(peptideSettingsDlg);

            var docChangedDriftTimePredictor = WaitForDocumentChange(document);

            // Reimport data - should shift precursors
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg =>
            {
                var chromatograms         = docChangedDriftTimePredictor.Settings.MeasuredResults.Chromatograms;
                dlg.SelectedChromatograms = new[] { chromatograms[0] };
                dlg.ReimportResults();
                dlg.OkDialog();
            });

            document = WaitForDocumentChangeLoaded(docChangedDriftTimePredictor);
            var transitionsNew = document.MoleculeTransitions.ToArray();
            var nChanges       = 0;
            var nNonEmpty      = 0;

            for (var i = 0; i < transitions.Length; i++)
            {
                Assume.AreEqual(transitions[i].Mz, transitionsNew[i].Mz);
                if (transitions[i].AveragePeakArea.HasValue)
                {
                    nNonEmpty++;
                    if (transitions[i].AveragePeakArea != transitionsNew[i].AveragePeakArea) // Using filter should alter peak area
                    {
                        nChanges++;
                    }
                }
                else
                {
                    Assume.AreEqual(transitions[i].AveragePeakArea, transitionsNew[i].AveragePeakArea);
                }
            }
            Assume.IsTrue(nChanges >= nNonEmpty * .9); // We expect nearly all peaks to change in area with IMS filter in use

            // And read some mz5 converted from Bruker, then compare replicates - should be identical
            var mz5 = TestFilesDir.GetTestPath(bsaFmolTimsInfusionesiPrecMz5Mz5);

            ImportResultsFile(mz5);
            document = WaitForDocumentChange(document);
            foreach (var nodeGroup in document.MoleculeTransitionGroups)
            {
                Assume.AreEqual(2, nodeGroup.Results.Count);
                foreach (TransitionDocNode nodeTran in nodeGroup.Children)
                {
                    Assume.AreEqual(2, nodeTran.Results.Count);
                    Assume.AreEqual(nodeTran.Results[0], nodeTran.Results[1]);
                }
            }
        }
Esempio n. 22
0
        protected override void DoTest()
        {
            // IsPauseForScreenShots = true;
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("SplitGraphUnitTest.sky")));
            CollectionAssert.AreEqual(new[] { "SplitGraph_rev1.clib" }, SkylineWindow.Document.Settings.PeptideSettings.Libraries.LibrarySpecs
                                      .Select(spec => Path.GetFileName(spec.FilePath)).ToArray());
            WaitForDocumentLoaded();
            // Test that AutoZoomNone and AutoZoomBestPeak work
            var graphChromatogram             = FormUtil.OpenForms.OfType <GraphChromatogram>().First();
            var graphChromatogramGraphControl = AllControls(graphChromatogram).OfType <ZedGraphControl>().First();

            RunUI(() =>
            {
                // Select the first transition group
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo(2, 0);
                SkylineWindow.AutoZoomBestPeak();
                // Make sure that we are zoomed in to approximately the best peak
                Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Min, 13.0, 1.0);
                Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Max, 14.0, 1.0);
                // Remember the zoom state so that we can pretend to manually zoom later
                var zoomStateAuto = new ZoomState(graphChromatogramGraphControl.GraphPane, ZoomState.StateType.Zoom);
                SkylineWindow.AutoZoomNone();
                Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Min, 0.0, 1.0);
                Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Max, 35.0, 1.0);
                // Pretend to manually zoom
                zoomStateAuto.ApplyState(graphChromatogramGraphControl.GraphPane);
                Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Min, 13.0, 1.0);
                // Select some other transition group:
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo(2, 1);
                SkylineWindow.ShowPeakAreaReplicateComparison();
            });
            WaitForGraphs();
            // Ensure that we zoomed out when the selected transition group changed
            Assert.AreEqual(graphChromatogramGraphControl.GraphPane.XAxis.Scale.Min, 0.0, 1.0);

            var peakAreaSummary          = FormUtil.OpenForms.OfType <GraphSummary>().First();
            var graphLibraryMatch        = FormUtil.OpenForms.OfType <GraphSpectrum>().First();
            var libraryMatchGraphControl = AllControls(graphLibraryMatch).OfType <ZedGraphControl>().First();

            RunUI(() =>
            {
                Assert.IsTrue(Settings.Default.ShowLibraryChromatograms);
                AssertCurveListsSame(graphChromatogram.CurveList,
                                     libraryMatchGraphControl.GraphPane.CurveList);
                AssertCurveListsSame(graphChromatogram.CurveList,
                                     peakAreaSummary.GraphControl.GraphPane.CurveList);
                Assert.AreEqual(9, graphChromatogram.CurveList.Count);
                Assert.AreEqual(1, graphChromatogramGraphControl.MasterPane.PaneList.Count);
                Assert.AreEqual(1, peakAreaSummary.GraphControl.MasterPane.PaneList.Count);
                SkylineWindow.ShowPrecursorTransitions();
                Assert.AreEqual(3, graphChromatogram.CurveList.Count);
                // TODO(nicksh): Enable this when libraries filter based on precursor/product
                //AssertCurveListsSame(graphChromatogram.CurveList, libraryMatchGraphControl.GraphPane.CurveList);
                AssertCurveListsSame(graphChromatogram.CurveList,
                                     peakAreaSummary.GraphControl.GraphPane.CurveList);
                SkylineWindow.ShowProductTransitions();
                Assert.AreEqual(6, graphChromatogram.CurveList.Count);
                // TODO(nicksh): Enable this when libraries filter based on precursor/product
                AssertCurveListsSame(graphChromatogram.CurveList,
                                     libraryMatchGraphControl.GraphPane.CurveList);
                AssertCurveListsSame(graphChromatogram.CurveList,
                                     peakAreaSummary.GraphControl.GraphPane.CurveList);
                SkylineWindow.ShowAllTransitions();
                SkylineWindow.ShowSplitChromatogramGraph(true);
            });
            WaitForGraphs();
            Assert.AreEqual(2, graphChromatogramGraphControl.MasterPane.PaneList.Count);
            Assert.AreEqual(2, peakAreaSummary.GraphControl.MasterPane.PaneList.Count);
            AssertCurveListsSame(graphChromatogram.GetCurveList(graphChromatogramGraphControl.MasterPane.PaneList[0]),
                                 peakAreaSummary.GraphControl.MasterPane.PaneList[0].CurveList);
            AssertCurveListsSame(graphChromatogram.GetCurveList(graphChromatogramGraphControl.MasterPane.PaneList[1]),
                                 peakAreaSummary.GraphControl.MasterPane.PaneList[1].CurveList);
        }
        protected override void DoTest()
        {
            // Formerly this little .sky file would not update its (unsearchable) protein metdata on load
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("Mutant Peptides  with Braf AG A00Y - Cut Down.sky")));
            var doc      = WaitForDocumentLoaded();
            var nodeProt = doc.MoleculeGroups.First();
            var metadata = nodeProt.ProteinMetadata;

            Assert.IsFalse(metadata.NeedsSearch());

            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("ProteinMetadataFunctionalTests.sky")));

            doc      = WaitForDocumentLoaded();
            nodeProt = doc.MoleculeGroups.First();
            metadata = nodeProt.ProteinMetadata;

            // Examine the various View | Targets | By* modes
            foreach (ProteinMetadataManager.ProteinDisplayMode mode in Enum.GetValues(typeof(ProteinMetadataManager.ProteinDisplayMode)))
            {
                ProteinMetadataManager.ProteinDisplayMode arg = mode;
                RunUI(() => SkylineWindow.ViewMenu.UpdateTargetsDisplayMode(arg)); // This should alter the text displayed by the node in the sequence tree view
                WaitForConditionUI(() =>
                {
                    var displayText = SkylineWindow.SequenceTree.GetSequenceNodes().First().Text;
                    if (arg != ProteinMetadataManager.ProteinDisplayMode.ByName &&
                        Equals(displayText, GetDisplayText(ProteinMetadataManager.ProteinDisplayMode.ByName, metadata)))
                    {
                        return(false);
                    }
                    return(Equals(displayText, GetDisplayText(arg, metadata)));
                });
            }

            // Examine the various Edit | Refine | Sort Proteins | By* modes
            Assert.AreEqual("YIL075C", nodeProt.Name); // unsorted
            foreach (ProteinMetadataManager.ProteinDisplayMode mode in Enum.GetValues(typeof(ProteinMetadataManager.ProteinDisplayMode)))
            {
                string expectedTopName = null;
                switch (mode)
                {
                case ProteinMetadataManager.ProteinDisplayMode.ByName:
                    expectedTopName = "YAL003W";
                    RunUI(() => SkylineWindow.RefineMenu.sortProteinsByNameToolStripMenuItem_Click(null, null));
                    break;

                case ProteinMetadataManager.ProteinDisplayMode.ByAccession:
                    expectedTopName = "YFL038C";
                    RunUI(() => SkylineWindow.RefineMenu.sortProteinsByAccessionToolStripMenuItem_Click(null, null));
                    break;

                case ProteinMetadataManager.ProteinDisplayMode.ByPreferredName:
                    RunUI(() => SkylineWindow.RefineMenu.sortProteinsByPreferredNameToolStripMenuItem_Click(null, null));
                    expectedTopName = "YAL016W";
                    break;

                case ProteinMetadataManager.ProteinDisplayMode.ByGene:
                    RunUI(() => SkylineWindow.RefineMenu.sortProteinsByGeneToolStripMenuItem_Click(null, null));
                    expectedTopName = "YGL234W";
                    break;
                }
                var actualTopName = WaitForDocumentLoaded().MoleculeGroups.First().Name.ToUpperInvariant();
                Assert.AreEqual(expectedTopName, actualTopName);
            }

            // Now paste in our fake fasta test data, and handle it with our fake webaccess handler
            var protdbLoader = SkylineWindow.BackgroundProteomeManager;

            protdbLoader.FastaImporter = new WebEnabledFastaImporter(new CommonTest.FastaImporterTest.PlaybackProvider());
            var treeLoader = SkylineWindow.ProteinMetadataManager;

            treeLoader.FastaImporter = new WebEnabledFastaImporter(new CommonTest.FastaImporterTest.PlaybackProvider());

            const int maxEntries = 5;
            var       fastaText  = CommonTest.FastaImporterTest.GetFastaTestText(maxEntries); // Just get the first few

            SetClipboardTextUI(fastaText);
            var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteFastaDlg); // Show the paste dialog

            RunDlg <EmptyProteinsDlg>(() =>                                        // Anticpate the EmptyProteinsDialog as a side effect
            {
                pasteDlg.PasteFasta();                                             // Doing this in pastDlg...
                pasteDlg.OkDialog();
            },
                                      dlg =>
            {
                Assert.AreEqual(maxEntries, dlg.EmptyProteins);
                dlg.KeepEmptyProteins();
                dlg.OkDialog();     // ... will cause EmptyProteinsDlg to pop up, so OK it.
            });

            // Check that IPI:IPI00197700.1 got an accession number P04638
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals("IPI:IPI00197700.1", pg.Name)));
            doc      = WaitForDocumentLoaded();
            nodeProt = doc.MoleculeGroups.First(pg => Equals("IPI:IPI00197700.1", pg.Name));
            Assert.AreEqual("P04638", nodeProt.ProteinMetadata.Accession);

            // Now make our fake fasta into a protdb file, and check statement completion against that
            const string basename   = "fake.fasta";
            var          protdbPath = TestFilesDir.GetTestPath(basename + ProteomeDb.EXT_PROTDB);
            var          fastapath  = TestFilesDir.GetTestPath(basename);

            using (StreamWriter outfile = new StreamWriter(fastapath))
            {
                outfile.Write(CommonTest.FastaImporterTest.GetFastaTestText()); // write them all
            }
            BackgroundProteomeTest.CreateBackgroundProteome(protdbPath, basename, fastapath);
            doc = WaitForDocumentChange(doc);

            // Test for getting accession info from protdb
            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1]; // Select the creation node
                sequenceTree.BeginEdit(false);
                // ReSharper disable LocalizableElement
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "NP_313205";
                // ReSharper restore LocalizableElement
                sequenceTree.CommitEditBox(false);
            });
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals("NP_313205", pg.Name));
            Assert.AreEqual("P0A7T9", nodeProt.ProteinMetadata.Accession);

            var snapshot = SkylineWindow.Document;

            // Test for getting protein from protdb by preferredName
            const string uniRef100A5Di11 = "UniRef100_A5DI11";
            const string a5Di11          = "A5DI11";

            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1]; // Select the creation node
                sequenceTree.BeginEdit(false);
                // ReSharper disable LocalizableElement
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "EF2_PICGU"; // PreferredName for UniRef100_A5DI11
                // ReSharper restore LocalizableElement
                sequenceTree.CommitEditBox(false);
            });
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(uniRef100A5Di11, pg.Name)));
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals(uniRef100A5Di11, pg.Name));
            Assert.AreEqual(a5Di11, nodeProt.ProteinMetadata.Accession);

            // Paste in some junk and make sure we handle the View Targets By* gracefully
            const string badname = "badname";

            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1]; // Select the creation node
                sequenceTree.BeginEdit(false);
                sequenceTree.StatementCompletionEditBox.TextBox.Text = badname;
                sequenceTree.CommitEditBox(false);
            });
            doc = WaitForDocumentChange(doc);
            var nodeText = SkylineWindow.SequenceTree.GetSequenceNodes().Last().Text;
            var failsafe = String.Format(Resources.PeptideGroupTreeNode_ProteinModalDisplayText__name___0__, badname);  // As in PeptideGroupTreeNode.cs

            Assert.AreEqual(failsafe, nodeText);


            // Revert those changes, so we can insert another way
            Assert.IsTrue(SkylineWindow.SetDocument(snapshot, doc));
            WaitForCondition(() => !SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(uniRef100A5Di11, pg.Name)));
            doc = SkylineWindow.Document;

            // Test for pasting accession number in protein paste dialog, and having it populate with correct name
            SetClipboardTextUI(a5Di11);
            PasteDlg pasteProteinsDlgA = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);

            RunUI(() =>
            {
                var selectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                SkylineWindow.SequenceTree.SelectedNode = selectedNode;
                pasteProteinsDlgA.SelectedPath          = SkylineWindow.SequenceTree.SelectedPath;
                pasteProteinsDlgA.PasteProteins();
            });
            OkDialog(pasteProteinsDlgA, pasteProteinsDlgA.OkDialog);
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(uniRef100A5Di11, pg.Name)));
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals(uniRef100A5Di11, pg.Name));
            Assert.AreEqual(a5Di11, nodeProt.ProteinMetadata.Accession);

            // See what happens when you paste in a gene name shared by a couple of proteins
            const string dupeGene    = "Apoa2";
            const string ipi00197700 = "IPI:IPI00197700.1";

            SetClipboardTextUI(dupeGene);
            PasteDlg pasteProteinsDlgB = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);

            RunUI(() =>
            {
                var selectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                SkylineWindow.SequenceTree.SelectedNode = selectedNode;
                pasteProteinsDlgB.SelectedPath          = SkylineWindow.SequenceTree.SelectedPath;
                pasteProteinsDlgB.PasteProteins();
            });
            OkDialog(pasteProteinsDlgB, pasteProteinsDlgB.OkDialog);
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(ipi00197700, pg.Name)));
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals(ipi00197700, pg.Name));
            Assert.AreEqual(dupeGene, nodeProt.ProteinMetadata.Gene);

            // Test for pasting in protein PasteDlg with sequence and metadata - metadata values are same as DocumentGrid column names
            const string pasteProteinName          = "Protein";
            const string pasteProteinDescription   = "Description";
            const string pasteProteinAccession     = "Accession";
            const string pasteProteinPreferredName = "PreferredName";
            const string pasteProteinGene          = "Gene";
            const string pasteProteinSpecies       = "Species";
            var          pasteProteinText          = String.Join("\t", pasteProteinName, pasteProteinDescription,
                                                                 "MFEQFDLDSELLASINK   IGYTKPTSIQELVIPQAMV", pasteProteinAccession, pasteProteinPreferredName, // Note the whitespace embedded in the sequence - UI should deal with that
                                                                 pasteProteinGene, pasteProteinSpecies);

            SetClipboardTextUI(pasteProteinText);
            PasteDlg pasteProteinsDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);

            RunUI(() =>
            {
                var selectedNode = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                SkylineWindow.SequenceTree.SelectedNode = selectedNode;
                pasteProteinsDlg.SelectedPath           = SkylineWindow.SequenceTree.SelectedPath;
                pasteProteinsDlg.PasteProteins();
            });
            OkDialog(pasteProteinsDlg, pasteProteinsDlg.OkDialog);
            WaitForCondition(() => SkylineWindow.Document.MoleculeGroups.Any(pg => Equals(pasteProteinName, pg.Name)));
            doc      = WaitForDocumentChange(doc);
            nodeProt = doc.MoleculeGroups.First(pg => Equals(pasteProteinName, pg.Name));
            Assert.AreEqual(pasteProteinAccession, nodeProt.ProteinMetadata.Accession);

            // Verify DocumentGrid's use of protein metadata - last line should agree with var pasteProteinText
            var documentGrid = ShowDialog <DocumentGridForm>(() => SkylineWindow.ShowDocumentGrid(true));

            RunUI(() => documentGrid.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Proteins));
            WaitForCondition(() => (documentGrid.RowCount > 0));  // Let it initialize
            foreach (var colName in new[]
            {
                pasteProteinAccession,
                pasteProteinPreferredName,
                pasteProteinGene,
                pasteProteinSpecies
            })
            {   // Column content should match column name, for pasteProteinText as input
                string value = null;
                string name  = colName;
                RunUI(() =>
                {
                    var col = documentGrid.FindColumn(PropertyPath.Parse(name));
                    value   =
                        documentGrid.DataGridView.Rows[documentGrid.RowCount - 1].Cells[col.Index].Value.ToString();
                });
                Assert.AreEqual(colName, value);
            }
        }
        protected override void DoTest()
        {
            string skyFile = TestFilesDir.GetTestPath("Erin 19pep test subset.sky");

            Program.ExtraRawFileSearchFolder = TestFilesDir.PersistentFilesDir; // So we don't have to reload the raw files, which have moved relative to skyd file
            RunUI(() => SkylineWindow.OpenFile(skyFile));

            const int chromIndex     = 1;
            const int waitTimeMillis = 10 * 60 * 1000;                        // 10 minutes
            var       doc0           = WaitForDocumentLoaded(waitTimeMillis); // If it decides to remake chromatograms this can take awhile

            AssertEx.IsDocumentState(doc0, null, 19, 19, 28, 607);
            RunUI(() =>
            {
                SkylineWindow.SaveDocument(); // Avoid "document changed since last edit" message
                doc0 = SkylineWindow.DocumentUI;
            });
            float  tolerance   = (float)doc0.Settings.TransitionSettings.Instrument.MzMatchTolerance;
            double maxHeight0  = 0;
            var    results0    = doc0.Settings.MeasuredResults;
            var    intensities = new List <List <float> >();

            foreach (var pair in doc0.PeptidePrecursorPairs)
            {
                ChromatogramGroupInfo[] chromGroupInfo;
                Assert.IsTrue(results0.TryLoadChromatogram(chromIndex, pair.NodePep, pair.NodeGroup,
                                                           tolerance, true, out chromGroupInfo));
                foreach (var chromGroup in chromGroupInfo)
                {
                    foreach (var tranInfo in chromGroup.TransitionPointSets)
                    {
                        maxHeight0 = Math.Max(maxHeight0, tranInfo.MaxIntensity);
                        intensities.Add(new List <float>(tranInfo.Intensities));
                    }
                }
            }

            Stopwatch loadStopwatch = new Stopwatch();

            loadStopwatch.Start();
            var manageResults = ShowDialog <ManageResultsDlg>(SkylineWindow.ManageResults);
            var doc           = SkylineWindow.Document;

            RunUI(() =>
            {
                // Just reload the CE22 stuff, using the RT info from the MS1 scan
                manageResults.SelectedChromatograms = new[] { SkylineWindow.Document.Settings.MeasuredResults.Chromatograms[chromIndex] };
                manageResults.ReimportResults();
                manageResults.OkDialog();
            });
            WaitForDocumentChange(doc);
            WaitForCondition(waitTimeMillis, () => SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);
            loadStopwatch.Stop();

            var doc1 = WaitForDocumentLoaded(400000);

            AssertEx.IsDocumentState(doc1, null, 19, 19, 28, 607);

            var chroms0 = doc0.Settings.MeasuredResults.Chromatograms[chromIndex];
            var chroms1 = doc1.Settings.MeasuredResults.Chromatograms[chromIndex];

            Assert.AreEqual(StripPathInfo(chroms0), StripPathInfo(chroms1));

            int intensityIndex = 0;
            var results1       = doc1.Settings.MeasuredResults;

            foreach (var pair in doc1.PeptidePrecursorPairs)
            {
                ChromatogramGroupInfo[] chromGroupInfo;
                Assert.IsTrue(results1.TryLoadChromatogram(chromIndex, pair.NodePep, pair.NodeGroup,
                                                           tolerance, true, out chromGroupInfo));
                foreach (var chromGroup in chromGroupInfo)
                {
                    foreach (var tranInfo in chromGroup.TransitionPointSets)
                    {
                        AssertEx.AreEqualDeep(intensities[intensityIndex++], new List <float>(tranInfo.Intensities));
                    }
                }
            }

            DebugLog.Info("load time = {1}", loadStopwatch.ElapsedMilliseconds);
        }
        protected override void DoTest()
        {
            // Creating a MS/MS Spectral Library, p. 1
            PeptideSettingsUI peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunDlg <BuildLibraryDlg>(peptideSettingsUI.ShowBuildLibraryDlg, buildLibraryDlg =>
            {
                buildLibraryDlg.LibraryPath      = TestFilesDirs[0].GetTestPath(@"MethodEdit\Library\"); // Not L10N
                buildLibraryDlg.LibraryName      = YEAST_ATLAS;
                buildLibraryDlg.LibraryCutoff    = 0.95;
                buildLibraryDlg.LibraryAuthority = "peptideatlas.org"; // Not L10N
                buildLibraryDlg.OkWizardPage();
                IList <string> inputPaths = new List <string>
                {
                    TestFilesDirs[0].GetTestPath(@"MethodEdit\Yeast_atlas\interact-prob.pep.xml")  // Not L10N
                };
                buildLibraryDlg.AddInputFiles(inputPaths);
                buildLibraryDlg.OkWizardPage();
            });

            PeptideSettingsUI peptideSettingsUI1 = peptideSettingsUI;

            RunUI(() =>
            {
                peptideSettingsUI1.SelectedTab     = PeptideSettingsUI.TABS.Library;
                peptideSettingsUI1.PickedLibraries = new[] { YEAST_ATLAS };
            });
            WaitForOpenForm <PeptideSettingsUI>();                                                  // To show Library tab for Forms testing
            PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 4); // Not L10N

            RunUI(() => peptideSettingsUI1.SelectedTab = PeptideSettingsUI.TABS.Digest);
            WaitForOpenForm <PeptideSettingsUI>();   // To show Digestion tab for Forms testing

            // Creating a Background Proteome File, p. 3
            FileEx.SafeDelete(TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\Yeast" + ProteomeDb.EXT_PROTDB)); // Not L10N
            var buildBackgroundProteomeDlg =
                ShowDialog <BuildBackgroundProteomeDlg>(peptideSettingsUI.ShowBuildBackgroundProteomeDlg);

            RunUI(() =>
            {
                buildBackgroundProteomeDlg.BackgroundProteomePath =
                    TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\Yeast");                     // Not L10N
                buildBackgroundProteomeDlg.BackgroundProteomeName = "Yeast";                     // Not L10N
                buildBackgroundProteomeDlg.AddFastaFile(
                    TestFilesDirs[0].GetTestPath(@"MethodEdit\FASTA\sgd_yeast.fasta"));          // Not L10N
            });
            PauseForScreenShot <BuildBackgroundProteomeDlg>("Edit Background Proteome form", 5); // Not L10N

            OkDialog(buildBackgroundProteomeDlg, buildBackgroundProteomeDlg.OkDialog);

            PauseForScreenShot <PeptideSettingsUI.DigestionTab>("Peptide Settings - Digestion tab", 6); // Not L10N

            OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);

            if (!TryWaitForCondition(() =>
                                     SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded &&
                                     SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0))
            {
                Assert.Fail("Timed out loading libraries: libCount={0}, NotLoadedExplained={1}",
                            SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count,
                            SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsNotLoadedExplained ?? "<null>");
            }

            WaitForCondition(() =>
            {
                var peptideSettings    = SkylineWindow.Document.Settings.PeptideSettings;
                var backgroundProteome = peptideSettings.BackgroundProteome;
                return(backgroundProteome.HasDigestion(peptideSettings));
            }, "backgroundProteome.HasDigestion");

            // Wait a bit in case web access is turned on and backgroundProteome is actually resolving protein metadata
            int millis = (AllowInternetAccess ? 300 : 60) * 1000;

            WaitForCondition(millis, () => !SkylineWindow.Document.Settings.PeptideSettings.BackgroundProteome.NeedsProteinMetadataSearch, "backgroundProteome.NeedsProteinMetadataSearch");

            // Pasting FASTA Sequences, p. 5
            RunUI(() => SetClipboardFileText(@"MethodEdit\FASTA\fasta.txt")); // Not L10N

            // New in v0.7 : Skyline asks about removing empty proteins.
            using (new CheckDocumentState(35, 25, 25, 75))
            {
                var emptyProteinsDlg = ShowDialog <EmptyProteinsDlg>(SkylineWindow.Paste);
                RunUI(() => emptyProteinsDlg.IsKeepEmptyProteins = true);
                OkDialog(emptyProteinsDlg, emptyProteinsDlg.OkDialog);
                WaitForCondition(millis, () => SkylineWindow.SequenceTree.Nodes.Count > 4);
            }

            RunUI(() =>
            {
                SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[3].Nodes[0];
            });
            RestoreViewOnScreen(07);
            PauseForScreenShot("Main window", 7); // Not L10N

            RunUI(() =>
            {
                Settings.Default.ShowBIons = true;
                SkylineWindow.SequenceTree.SelectedNode.Expand();
                SkylineWindow.SequenceTree.SelectedNode =
                    SkylineWindow.SequenceTree.SelectedNode.Nodes[0].Nodes[1];
            });
            PauseForScreenShot("Main window showing effect of selection on Library Match graph", 8); // Not L10N

            CheckTransitionCount("VDIIANDQGNR", 3);                                                  // Not L10N

            using (new CheckDocumentState(35, 28, 31, 155))
            {
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    transitionSettingsUI.SelectedTab      = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.PrecursorCharges = "2, 3";                                         // Not L10N
                    transitionSettingsUI.ProductCharges   = "1";                                            // Not L10N
                    transitionSettingsUI.FragmentTypes    = "y, b";                                         // Not L10N
                });
                WaitForOpenForm <TransitionSettingsUI>();                                                   // To show Filter tab for Forms testing
                PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 9); // Not L10N
                RunUI(() =>
                {
                    transitionSettingsUI.SelectedTab = TransitionSettingsUI.TABS.Library;
                    transitionSettingsUI.IonCount    = 5;
                });
                PauseForScreenShot <TransitionSettingsUI.LibraryTab>("Transition Settings - Library tab", 10); // Not L10N
                OkDialog(transitionSettingsUI, transitionSettingsUI.OkDialog);
            }
            PauseForScreenShot("Targets tree clipped from main window", 11); // Not L10N

            CheckTransitionCount("VDIIANDQGNR", 5);                          // Not L10N

            // Using a Public Spectral Library, p. 9
            peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var editListUI =
                ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(peptideSettingsUI.EditLibraryList);
            var addLibUI = ShowDialog <EditLibraryDlg>(editListUI.AddItem);

            RunUI(() => addLibUI.LibrarySpec =
                      new BiblioSpecLibSpec(YEAST_GPM, TestFilesDirs[0].GetTestPath(@"MethodEdit\Library\yeast_cmp_20.hlf"))); // Not L10N
            OkDialog(addLibUI, addLibUI.OkDialog);
            WaitForClosedForm(addLibUI);
            OkDialog(editListUI, editListUI.OkDialog);

            // Limiting Peptides per Protein, p. 11
            using (new CheckDocumentState(35, 182, 219, 1058))
            {
                RunUI(() =>
                {
                    peptideSettingsUI.SelectedTab     = PeptideSettingsUI.TABS.Library;
                    peptideSettingsUI.PickedLibraries = new[] { YEAST_ATLAS, YEAST_GPM };
                });
                PauseForScreenShot <PeptideSettingsUI.LibraryTab>("Peptide Settings - Library tab", 12); // Not L10N
                OkDialog(peptideSettingsUI, peptideSettingsUI.OkDialog);
                Assert.IsTrue(WaitForCondition(
                                  () =>
                                  SkylineWindow.Document.Settings.PeptideSettings.Libraries.IsLoaded &&
                                  SkylineWindow.Document.Settings.PeptideSettings.Libraries.Libraries.Count > 0));
            }

            using (new CheckDocumentState(35, 47, 47, 223, 2, true))    // Wait for change loaded, and expect 2 document revisions.
            {
                RunDlg <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsUI2 =>
                {
                    peptideSettingsUI2.PickedLibraries    = new[] { YEAST_GPM };
                    peptideSettingsUI2.LimitPeptides      = true;
                    peptideSettingsUI2.RankID             = XHunterLibSpec.PEP_RANK_EXPECT;
                    peptideSettingsUI2.PeptidesPerProtein = 3;
                    peptideSettingsUI2.OkDialog();
                });
            }

            using (new CheckDocumentState(19, 47, 47, 223))
            {
                RunUI(() =>
                {
                    var refinementSettings = new RefinementSettings {
                        MinPeptidesPerProtein = 1
                    };
                    SkylineWindow.ModifyDocument("Remove empty proteins", refinementSettings.Refine);     // Not L10N
                });
            }

            // Inserting a Protein List, p. 11
            using (new CheckDocumentState(36, 58, 58, 278))
            {
                PasteDlg pasteProteinsDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteProteinsDlg);
                RunUI(() =>
                {
                    var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                    SkylineWindow.SequenceTree.SelectedNode = node;
                    SetClipboardFileText(@"MethodEdit\FASTA\Protein list.txt");     // Not L10N
                    pasteProteinsDlg.SelectedPath = SkylineWindow.SequenceTree.SelectedPath;
                    pasteProteinsDlg.PasteProteins();
                });
                PauseForScreenShot <PasteDlg.ProteinListTab>("Insert Protein List - For Screenshot, select last (empty) item in list", 14); // Not L10N
                OkDialog(pasteProteinsDlg, pasteProteinsDlg.OkDialog);
            }

            using (new CheckDocumentState(24, 58, 58, 278))
            {
                RunUI(() =>
                {
                    var refinementSettings = new RefinementSettings {
                        MinPeptidesPerProtein = 1
                    };
                    SkylineWindow.ModifyDocument("Remove empty proteins", refinementSettings.Refine);     // Not L10N
                });
            }

            // Inserting a Peptide List, p. 13
            using (new CheckDocumentState(25, 70, 70, 338))
            {
                RunUI(() =>
                {
                    SetClipboardFileText(@"MethodEdit\FASTA\Peptide list.txt");     // Not L10N
                    SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[0];
                    SkylineWindow.Paste();
// ReSharper disable LocalizableElement
                    SkylineWindow.SequenceTree.Nodes[0].Text = "Primary Peptides";     // Not L10N
// ReSharper restore LocalizableElement
                });
                FindNode("TLTAQSMQNSTQSAPNK");         // Not L10N
                PauseForScreenShot("Main window", 16); // Not L10N
            }

            using (new CheckDocumentState(35, 70, 70, 338))
            {
                RunUI(() => SkylineWindow.Undo());
                PasteDlg pastePeptidesDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);
                RunUI(pastePeptidesDlg.PastePeptides);
                PauseForScreenShot <PasteDlg.PeptideListTab>("Insert Peptide List -  For screenshot, select last (empty) line in list", 17); // Not L10N
                OkDialog(pastePeptidesDlg, pastePeptidesDlg.OkDialog);
            }

            // Simple Refinement, p. 16
            var findPeptideDlg = ShowDialog <FindNodeDlg>(SkylineWindow.ShowFindNodeDlg);

            RunUI(() => findPeptideDlg.SearchString = "IPEE"); // Not L10N
            OkDialog(findPeptideDlg, () =>
            {
                findPeptideDlg.FindNext();
                findPeptideDlg.Close();
            });
            PauseForScreenShot <GraphSpectrum>("Library Match graph metafile", 18); // Not L10N

            using (new CheckDocumentState(35, 64, 64, 320))
            {
                RefineDlg refineDlg = ShowDialog <RefineDlg>(SkylineWindow.ShowRefineDlg);
                RunUI(() => refineDlg.MinTransitions = 5);
                OkDialog(refineDlg, refineDlg.OkDialog);
                PauseForScreenShot("29/35 prot 50/64 pep 50/64 prec 246/320 tran", 18); // Not L10N
            }

            // Checking Peptide Uniqueness, p. 18
            RunUI(() =>
            {
                var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - (TestSmallMolecules ? 3 : 2)];
                SkylineWindow.SequenceTree.SelectedNode = node;
            });

            using (new CheckDocumentState(34, 63, 63, 315))
            {
                var uniquePeptidesDlg = ShowDialog <UniquePeptidesDlg>(SkylineWindow.ShowUniquePeptidesDlg);
                WaitForConditionUI(() => uniquePeptidesDlg.GetDataGridView().RowCount == 1);
                RunUI(() =>
                {
                    Assert.AreEqual(1, uniquePeptidesDlg.GetDataGridView().RowCount);
                    Assert.AreEqual(7, uniquePeptidesDlg.GetDataGridView().ColumnCount);
                });
                PauseForScreenShot <UniquePeptidesDlg>("Unique Peptides form", 19); // Not L10N
                OkDialog(uniquePeptidesDlg, uniquePeptidesDlg.OkDialog);
                RunUI(() => SkylineWindow.EditDelete());
            }

            // Protein Name Auto-Completion
            PauseForScreenShot("(fig. 1): For screenshot, click at bottom of document tree, type 'ybl087' and see the autocomplete text.  Make sure to undo this new entry before proceeding.", 20); // Not L10N
            TestAutoComplete("ybl087", 0);                                                                                                                                                           // Not L10N
            var peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups);

            Assert.AreEqual("YBL087C", peptideGroups[peptideGroups.Count - 1].Name); // Not L10N

            // Protein Description Auto-Completion
            PauseForScreenShot("(fig. 2): For screenshot, click at bottom of document tree, type 'eft2' and see the autocomplete text, then down-arrow twice. Make sure to undo this new entry before proceeding.", 20); // Not L10N
            TestAutoComplete("eft2", 0);                                                                                                                                                                                 // Sorting logic puts this at the 0th entry in the list - Not L10N
            peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups);
            Assert.AreEqual("YDR385W", peptideGroups[peptideGroups.Count - 1].Name);                                                                                                                                     // Not L10N

            // Peptide Sequence Auto-Completion, p. 21
            TestAutoComplete("IQGP", 0); // Not L10N
            var peptides = new List <PeptideDocNode>(Program.ActiveDocument.Peptides);

            Assert.AreEqual("K.AYLPVNESFGFTGELR.Q [769, 784]", peptides[peptides.Count - 1].Peptide.ToString()); // Not L10N
            PauseForScreenShot("(fig. 1) - For screenshot, click at the bottom of the document tree", 21);       // Not L10N

            // Pop-up Pick-Lists, p. 21
            using (new CheckDocumentState(36, 71, 71, 355))
            {
                RunUI(() =>
                {
                    var node = SkylineWindow.SequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - (TestSmallMolecules ? 4 : 3)];
                    SkylineWindow.SequenceTree.SelectedNode = node;
                });
                var pickList = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
                RunUI(() =>
                {
                    pickList.ApplyFilter(false);
                    pickList.SetItemChecked(8, true);
                    pickList.AutoManageChildren = false;                                        // TODO: Because calling SetItemChecked does not do this
                });
                PauseForScreenShot <PopupPickList>("(fig. 2) - YBL087C Peptides picklist", 21); // Not L10N
                RunUI(pickList.OnOk);
            }

            using (new CheckDocumentState(36, 71, 71, 355))
            {
                RunUI(() =>
                {
                    SkylineWindow.SequenceTree.Nodes[34].ExpandAll();
                    var node =
                        SkylineWindow.SequenceTree.Nodes[34].Nodes[0].Nodes[0];
                    SkylineWindow.SequenceTree.SelectedNode = node;
                });
                var pickList1 = ShowDialog <PopupPickList>(SkylineWindow.ShowPickChildrenInTest);
                RunUI(() =>
                {
                    pickList1.SearchString = "y";     // Not L10N
                    pickList1.SetItemChecked(0, false);
                    pickList1.SetItemChecked(1, false);
                    pickList1.ApplyFilter(false);
                    pickList1.ToggleFind();
                    pickList1.SearchString = "b ++";     // Not L10N
                    pickList1.SetItemChecked(4, true);
                    pickList1.SetItemChecked(6, true);
                });
                PauseForScreenShot <PopupPickList>("b ++ filtered picklist", 22); // Not L10N
                RunUI(pickList1.OnOk);
            }

            // Bigger Picture, p. 22. Drag and Drop, p. 23
            RunUI(() =>
            {
                ITipProvider nodeTip = SkylineWindow.SequenceTree.SelectedNode as ITipProvider;
                Assert.IsTrue(nodeTip != null && nodeTip.HasTip);
                var nodeName = SkylineWindow.SequenceTree.Nodes[1].Name;
                IdentityPath selectPath;
                SkylineWindow.ModifyDocument("Drag and drop", // Not L10N
                                             doc => doc.MoveNode(SkylineWindow.Document.GetPathTo(0, 1), SkylineWindow.Document.GetPathTo(0, 0), out selectPath));
                Assert.IsTrue(SkylineWindow.SequenceTree.Nodes[0].Name == nodeName);
            });

            FindNode(string.Format("L [b5] - {0:F04}+", 484.3130));                                    // Not L10N - may be localized " (rank 3)"
            PauseForScreenShot("For Screenshots, First hover over YBL087C, then over 672.671+++", 23); // Not L10N

            // Preparing to Measure, p. 25
            RunDlg <TransitionSettingsUI>(() => SkylineWindow.ShowTransitionSettingsUI(TransitionSettingsUI.TABS.Prediction), transitionSettingsUI =>
            {
                transitionSettingsUI.RegressionCE    = Settings.Default.GetCollisionEnergyByName("ABI 4000 QTrap"); // Not L10N
                transitionSettingsUI.RegressionDP    = Settings.Default.GetDeclusterPotentialByName("ABI");         // Not L10N
                transitionSettingsUI.InstrumentMaxMz = 1800;
                transitionSettingsUI.OkDialog();
            });
            RunUI(() => SkylineWindow.SaveDocument(TestFilesDirs[0].GetTestPath("MethodEdit Tutorial.sky"))); // Not L10N
            var exportDialog = ShowDialog <ExportMethodDlg>(() =>
                                                            SkylineWindow.ShowExportMethodDialog(ExportFileType.List));

            RunUI(() =>
            {
                exportDialog.ExportStrategy = ExportStrategy.Buckets;
                exportDialog.MethodType     = ExportMethodType.Standard;
                exportDialog.OptimizeType   = ExportOptimize.NONE;
                exportDialog.IgnoreProteins = true;
                exportDialog.MaxTransitions = 75;
            });
            PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List form", 25);  // Not L10N

            const string basename = "Yeast_list";                                                        //  Not L10N

            OkDialog(exportDialog, () => exportDialog.OkDialog(TestFilesDirs[0].GetTestPath(basename))); // write Yeast_list_000n.csv

            // check the output files
            for (int n = 0; n++ < 5;)
            {
                var csvname = String.Format("{0}_{1}.csv", basename, n.ToString("D4")); // Not L10N

                // AssertEx.FieldsEqual is hard-coded with CultureInfo.InvariantCulture, but so is transition list CSV export, so OK
                using (TextReader actual = new StreamReader(TestFilesDirs[0].GetTestPath(csvname)))
                    using (TextReader target = new StreamReader(TestFilesDirs[1].GetTestPath(csvname)))
                    {
                        AssertEx.FieldsEqual(target, actual, 6, null, true, TestSmallMolecules ? 3 : 0);
                    }
            }
        }
Esempio n. 26
0
        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.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 <AddModificationsDlg>();

            RunUI(matchedPepsDlg.CancelDialog);
            WaitForClosedForm <AddModificationsDlg>(); // 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            = ""; // Set this empty to verify that we automatically set it to "p" due to MS1 fullscan settings enabled
                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));
        }
Esempio n. 27
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;

                var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);

                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);
            }
        }
Esempio n. 28
0
 /// <summary>
 /// For modifying at the Molecule level
 /// </summary>
 public EditCustomMoleculeDlg(SkylineWindow parent, string title,
     SrmSettings settings, string defaultName, string defaultFormula, ExplicitRetentionTimeInfo explicitRetentionTime)
     : this(parent, title, null, null, 0, 0, null, defaultName, defaultFormula, null, null, explicitRetentionTime, null, false)
 {
 }
Esempio n. 29
0
        protected override void DoTest()
        {
            const int    numStandardPeps = 11;
            const int    numLibraryPeps  = 18;
            const string irtCalc         = "iRT-C18";
            const string ssrCalc         = "SSRCalc 3.0 (300A)";

            var    testFilesDir = new TestFilesDir(TestContext, TestFilesZip);
            string databasePath = testFilesDir.GetTestPath("irt-c18.irtdb");

            string documentPath = testFilesDir.GetTestPath("iRT Test.sky");

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

            var peptideSettingsDlg1 = ShowDialog <PeptideSettingsUI>(
                () => SkylineWindow.ShowPeptideSettingsUI(PeptideSettingsUI.TABS.Prediction));
            var editRT1 = ShowDialog <EditRTDlg>(peptideSettingsDlg1.AddRTRegression);
            var irtDlg1 = ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator);

            RunUI(() =>
            {
                irtDlg1.CalcName = irtCalc;
                irtDlg1.CreateDatabase(databasePath);
            });

            var calibratePeptides = new List <MeasuredPeptide>();

            /*
             * Check several error handling cases
             * Check the peptide choosing algorithm for sanity (correct # peptides)
             * Check that the info dialog comes up when too many are requested
             * Check the peptide linear transformation for sanity
             * Check that the peptides get passed back to EditIrtCalcDlg
             */
            var calibrateDlg = ShowDialog <CalibrateIrtDlg>(irtDlg1.Calibrate);

            //Check the peptide choosing algorithm
            int peptideCount = SkylineWindow.Document.PeptideCount; //29 peptides in the document

            //Use the dialog box UI
            var countDlg = ShowDialog <AddIrtStandardsDlg>(calibrateDlg.UseResults);

            RunUI(() => countDlg.StandardCount = CalibrateIrtDlg.MIN_STANDARD_PEPTIDES - 1);
            RunDlg <MessageDlg>(countDlg.OkDialog, messageDlg => messageDlg.OkDialog());
            RunUI(() =>
            {
                countDlg.StandardCount = peptideCount;
                countDlg.OkDialog();
            });
            WaitForClosedForm(countDlg);

            Assert.AreEqual(peptideCount, calibrateDlg.StandardPeptideCount);

            //Bypass the UI
            foreach (int i in new[]
            {
                peptideCount,
                peptideCount / 2,
                CalibrateIrtDlg.MIN_STANDARD_PEPTIDES *2,
                CalibrateIrtDlg.MIN_STANDARD_PEPTIDES
            })
            {
                int j = i;
                RunUI(() =>
                {
                    calibratePeptides = calibrateDlg.Recalculate(SkylineWindow.Document, j);
                    Assert.AreEqual(calibratePeptides.Count, j);
                    Assert.IsNull(FindOpenForm <MessageDlg>());
                });
            }

            RunUI(() =>
            {
                calibrateDlg.Recalculate(SkylineWindow.Document, 11);
                //After closing this dialog, there should be 3 iRT values below 0
                //and 3 above 100
                calibrateDlg.SetFixedPoints(3, 7);

                calibrateDlg.OkDialog();
            });
            WaitForClosedForm(calibrateDlg);

            //Now check that the peptides were passed to the EditIrtCalcDlg
            RunUI(() =>
            {
                Assert.AreEqual(numStandardPeps, irtDlg1.StandardPeptideCount);
                //And that there are 3 below 0 and 3 above 100
                Assert.AreEqual(3, irtDlg1.StandardPeptides.Count(pep => pep.Irt < 0));
                Assert.AreEqual(3, irtDlg1.StandardPeptides.Count(pep => pep.Irt > 100));
                irtDlg1.ClearStandardPeptides();
            });

            /*
             * Test pasting into EditIrtCalcDlg
             * Test that the dialog requires the whole standard to be in the document
             * Test that add results gets everything in the document besides the standard
             * Test that there were no errors along the way
             */

            //Now paste in iRT with each peptide truncated by one amino acid
            var standard = new[]
            {
                BuildMeasuredPeptide("LGGNEQVTR", -24.92),
                BuildMeasuredPeptide("GAGSSEPVTGLDAK", 0.00),
                BuildMeasuredPeptide("VEATFGVDESNAK", 12.39),
                BuildMeasuredPeptide("YILAGVENSK", 19.79),
                BuildMeasuredPeptide("TPVISGGPYEYR", 28.71),
                BuildMeasuredPeptide("TPVITGAPYEYR", 33.38),
                BuildMeasuredPeptide("DGLDAASYYAPVR", 42.26),
                BuildMeasuredPeptide("ADVTPADFSEWSK", 54.62),
                BuildMeasuredPeptide("GTFIIDPGGVIR", 70.52),
                BuildMeasuredPeptide("GTFIIDPAAVIR", 87.23),
                BuildMeasuredPeptide("LFLQFGAQGSPFLK", 100.00),
            };

            RunUI(() =>
            {
                string standardText = BuildStandardText(standard, seq => seq.Substring(0, seq.Length - 1));
                SetClipboardText(standardText);
                irtDlg1.DoPasteStandard();
            });

            // Cannot add results because standard peptides are not in the document
            RunDlg <AddIrtPeptidesDlg>(irtDlg1.AddResults, messageDlg => messageDlg.OkDialog());

            // Paste Biognosys-provided values
            RunUI(() =>
            {
                string standardText = BuildStandardText(standard, seq => seq);
                SetClipboardText(standardText);
                irtDlg1.ClearStandardPeptides();
                irtDlg1.DoPasteStandard();

                //Check count
                Assert.AreEqual(numStandardPeps, irtDlg1.StandardPeptideCount);
            });

            //Add results
            var addPeptidesDlg1 = ShowDialog <AddIrtPeptidesDlg>(irtDlg1.AddResults);
            var recalibrateDlg1 = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg1.OkDialog);

            OkDialog(recalibrateDlg1, recalibrateDlg1.Btn1Click);

            RunUI(() => Assert.AreEqual(numLibraryPeps, irtDlg1.LibraryPeptideCount));

            // Recalibrate
            const int shift = 100;
            const int skew  = 10;

            RunDlg <RecalibrateIrtDlg>(irtDlg1.Calibrate, recalDlg =>
            {
                recalDlg.MinIrt      = standard[1].RetentionTime + shift;
                recalDlg.MaxIrt      = standard[standard.Length - 1].RetentionTime * skew + shift;
                recalDlg.FixedPoint1 = standard[1].Sequence;
                recalDlg.FixedPoint2 = standard[standard.Length - 1].Sequence;
                recalDlg.OkDialog();
            });
            RunUI(() =>
            {
                for (int i = 0; i < irtDlg1.StandardPeptideCount; i++)
                {
                    Assert.AreEqual(standard[i].RetentionTime * skew + shift,
                                    irtDlg1.StandardPeptides.Skip(i).First().Irt);
                }
            });
            RunDlg <RecalibrateIrtDlg>(irtDlg1.Calibrate, recalDlg =>
            {
                recalDlg.FixedPoint1 = standard[2].Sequence;
                recalDlg.FixedPoint2 = standard[standard.Length - 2].Sequence;
                recalDlg.MinIrt      = standard[2].RetentionTime;
                recalDlg.MaxIrt      = standard[standard.Length - 2].RetentionTime;
                recalDlg.OkDialog();
            });

            // Change peptides
            var changePeptides = irtDlg1.LibraryPeptides.Where((p, i) => i % 2 == 0).ToArray();
            var resetPeptides  = irtDlg1.StandardPeptides.ToArray();

            RunDlg <ChangeIrtPeptidesDlg>(irtDlg1.ChangeStandardPeptides, changeDlg =>
            {
                changeDlg.Peptides = changePeptides;
                changeDlg.OkDialog();
            });
            Assert.IsTrue(ArrayUtil.EqualsDeep(changePeptides.Select(p => p.Target).ToArray(),
                                               irtDlg1.StandardPeptides.Select(p => p.Target).ToArray()));
            Assert.IsTrue(ArrayUtil.EqualsDeep(changePeptides.Select(p => p.Irt).ToArray(),
                                               irtDlg1.StandardPeptides.Select(p => p.Irt).ToArray()));
            RunDlg <ChangeIrtPeptidesDlg>(irtDlg1.ChangeStandardPeptides, changeDlg =>
            {
                changeDlg.Peptides = resetPeptides;
                changeDlg.OkDialog();
            });

            OkDialog(irtDlg1, irtDlg1.OkDialog);

            Assert.IsNull(FindOpenForm <MessageDlg>());

            /*
             * Check that the database was created successfully
             * Check that it has the correct numbers of standard and library peptides
             */
            IrtDb db = IrtDb.GetIrtDb(databasePath, null);

            Assert.AreEqual(numStandardPeps, db.StandardPeptideCount);
            Assert.AreEqual(numLibraryPeps, db.LibraryPeptideCount);

            /*
             * Make sure that loading the database brings back up the right numbers of peptides
             */

            //Rather than rigging SettingsListComboDriver, just create a new one and load
            var irtDlg1A = ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator);

            RunDlg <MessageDlg>(() => irtDlg1A.OpenDatabase(testFilesDir.GetTestPath("bogus.irtdb")),
                                messageDlg => messageDlg.OkDialog());

            //There was a _bug_ where opening a path and then clicking OK would save all the peptides
            //twice, doubling the size of the database. So check that that is fixed.
            EditIrtCalcDlgPepCountTest(irtDlg1A, numStandardPeps, numLibraryPeps, databasePath, false);
            EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator),
                                       numStandardPeps, numLibraryPeps, databasePath, false);
            EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator),
                                       numStandardPeps, numLibraryPeps, databasePath, true);
            EditIrtCalcDlgPepCountTest(ShowDialog <EditIrtCalcDlg>(editRT1.AddCalculator),
                                       numStandardPeps, numLibraryPeps, databasePath, false);

            /*
             * Create a regression based on the new calculator
             * Create a regression based on SSRCalc
             * Open the graph
             * Switch to new calculator, verify r = 1.00 and graph is labeled iRT-C18
             * Switch to SSRCalc, verify graph label changes
             */

            RunUI(() =>
            {
                editRT1.SetRegressionName("iRT Regression");
                editRT1.AddResults();
                editRT1.ChooseCalculator(irtCalc);
                editRT1.OkDialog();
            });
            WaitForClosedForm(editRT1);

            var editRT1A = ShowDialog <EditRTDlg>(peptideSettingsDlg1.AddRTRegression);

            RunUI(() =>
            {
                editRT1A.SetRegressionName("SSRCalc Regression");
                editRT1A.AddResults();
                editRT1A.ChooseCalculator(ssrCalc);
            });

            RunDlg <RTDetails>(editRT1A.ShowDetails, detailsDlg => detailsDlg.Close());

            OkDialog(editRT1A, editRT1A.OkDialog);
            RunUI(peptideSettingsDlg1.CancelButton.PerformClick);
            WaitForClosedForm(peptideSettingsDlg1);

            var docPeptides = new List <MeasuredRetentionTime>();

            RunUI(() =>
            {
                var document = Program.ActiveDocumentUI;
                foreach (var docPepNode in document.Peptides)
                {
                    docPeptides.Add(new MeasuredRetentionTime(document.Settings.GetModifiedSequence(docPepNode),
                                                              docPepNode.AverageMeasuredRetentionTime ?? 0));
                }
            });

            RetentionTimeStatistics stats = null;
            RegressionLineElement   line  = null;

            RunUI(() => SkylineWindow.ShowRTRegressionGraphScoreToRun());
            WaitForRegression();
            RunUI(() =>
            {
                SkylineWindow.SetupCalculatorChooser();
                SkylineWindow.ChooseCalculator(irtCalc);
            });
            WaitForRegression();
            RunUI(() =>
            {
                stats = SkylineWindow.RTGraphController.RegressionRefined.CalcStatistics(docPeptides, null);
                line  = SkylineWindow.RTGraphController.RegressionRefined.Conversion as RegressionLineElement;
            });
            Assert.IsNotNull(stats);
            Assert.IsTrue(stats.R > 0.999);
            Assert.IsNotNull(line);
            //These values were taken from the graph, which shows values to 2 decimal places, so the real values must
            //be +/- 0.01 from these values
            Assert.IsTrue(Math.Abs(line.Intercept - 14.17) < 0.01);
            Assert.IsTrue(Math.Abs(line.Slope - 0.15) < 0.01);

            RunUI(() => SkylineWindow.ChooseCalculator(ssrCalc));
            WaitForRegression();
            RunUI(() => stats = SkylineWindow.RTGraphController.RegressionRefined.CalcStatistics(docPeptides, null));

            Assert.IsNotNull(stats);
            Assert.IsTrue(Math.Abs(stats.R - 0.97) < 0.01);

            /*
             * Delete all peptides except the standard
             * Create a new calculator with the document standard (instead of pasting)
             * Create a regression with that calculator
             * Export a transition list using measured retention times
             * Export a method using predicted retention times
             * Test that they are identical
             */

            //Delete from the document all but the last protein, which has all the standard peptides
            RunUI(() =>
            {
                SkylineWindow.CollapseProteins();
                var seqTree          = SkylineWindow.SequenceTree;
                seqTree.SelectedNode = seqTree.Nodes[0];
                seqTree.KeysOverride = Keys.Shift;
                seqTree.SelectedNode = seqTree.Nodes[17];
                SkylineWindow.EditDelete();
            });

            //Peptide settings dialog -> Add a regression
            var peptideSettingsDlg2 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var editRT2             = ShowDialog <EditRTDlg>(peptideSettingsDlg2.AddRTRegression);

            //Set regression name
            RunUI(() => editRT2.SetRegressionName("iRT Document Regression"));

            //Regression dialog -> add a calculator
            var irtDlg2 = ShowDialog <EditIrtCalcDlg>(editRT2.AddCalculator);

            //Set calc name, database
            RunUI(() =>
            {
                irtDlg2.CalcName = "iRT Document Calculator";
                irtDlg2.CreateDatabase(testFilesDir.GetTestPath("irt-doc.irtdb"));
            });

            //Calc dialog -> calibrate standard
            RunDlg <CalibrateIrtDlg>(irtDlg2.Calibrate, calibrateDlg2 =>
            {
                //Get 11 peptides from the document (all of them) and go back to calculator dialog
                calibrateDlg2.Recalculate(SkylineWindow.Document, 11);
                calibrateDlg2.OkDialog();
            });

            Assert.AreEqual(11, irtDlg2.StandardPeptideCount);
            Assert.AreEqual(0, irtDlg2.LibraryPeptideCount);

            // Close dialog to save calculator
            OkDialog(irtDlg2, irtDlg2.OkDialog);

            // Test adding irt calculator
            {
                var irtDlgAdd = ShowDialog <EditIrtCalcDlg>(editRT2.EditCurrentCalculator);
                var addDlg    = ShowDialog <AddIrtCalculatorDlg>(irtDlgAdd.AddIrtDatabase);

                // Check error messages
                RunUI(() => addDlg.Source = IrtCalculatorSource.file);
                RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg =>
                {
                    Assert.AreEqual(Resources.AddIrtCalculatorDlg_OkDialog_Please_specify_a_path_to_an_existing_iRT_database, messageDlg.Message);
                    messageDlg.OkDialog();
                });
                RunUI(() => addDlg.FilePath = "not_irtdb.docx");
                RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg =>
                {
                    AssertEx.AreComparableStrings(Resources.AddIrtCalculatorDlg_OkDialog_The_file__0__is_not_an_iRT_database, messageDlg.Message);
                    messageDlg.OkDialog();
                });
                RunUI(() => addDlg.FilePath = "not_exist.irtdb");
                RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg =>
                {
                    AssertEx.AreComparableStrings(TextUtil.LineSeparate(
                                                      Resources.AddIrtCalculatorDlgOkDialogThe_file__0__does_not_exist,
                                                      Resources.AddIrtCalculatorDlg_OkDialog_Please_specify_a_path_to_an_existing_iRT_database), messageDlg.Message);
                    messageDlg.OkDialog();
                });
                RunUI(() => addDlg.CalculatorName = "noexist");
                PauseForScreenShot();
                RunDlg <MessageDlg>(addDlg.OkDialog, messageDlg =>
                {
                    Assert.AreEqual(Resources.AddIrtCalculatorDlg_OkDialog_Please_choose_the_iRT_calculator_you_would_like_to_add, messageDlg.Message);
                    messageDlg.OkDialog();
                });

                RunUI(() => addDlg.FilePath = databasePath);
                var addPepDlg      = ShowDialog <AddIrtPeptidesDlg>(addDlg.OkDialog);
                var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPepDlg.OkDialog);
                OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click);
                Assert.AreEqual(18, irtDlgAdd.LibraryPeptideCount);

                OkDialog(irtDlgAdd, irtDlgAdd.CancelButton.PerformClick);
            }

            // Add from existing calculator
            {
                var irtDlgAdd = ShowDialog <EditIrtCalcDlg>(editRT2.EditCurrentCalculator);
                var addDlg    = ShowDialog <AddIrtCalculatorDlg>(irtDlgAdd.AddIrtDatabase);
                RunUI(() => addDlg.CalculatorName = irtCalc);
                var addPepDlg      = ShowDialog <AddIrtPeptidesDlg>(addDlg.OkDialog);
                var recalibrateDlg = ShowDialog <MultiButtonMsgDlg>(addPepDlg.OkDialog);
                OkDialog(recalibrateDlg, recalibrateDlg.Btn1Click);
                Assert.AreEqual(18, irtDlgAdd.LibraryPeptideCount);

                OkDialog(irtDlgAdd, irtDlgAdd.CancelButton.PerformClick);
            }


            var docIrtBefore = SkylineWindow.Document;

            OkDialog(editRT2, editRT2.OkDialog);
            OkDialog(peptideSettingsDlg2, peptideSettingsDlg2.OkDialog);
            WaitForClosedForm(peptideSettingsDlg2);

            var docIrt = VerifyIrtStandards(docIrtBefore, true);

            RunUI(() =>
            {
                // Select 3 of the standards and delete them
                SkylineWindow.SequenceTree.KeysOverride = Keys.None;
                SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0);
                SkylineWindow.SequenceTree.KeysOverride = Keys.Shift;
                SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 2);
                SkylineWindow.SequenceTree.KeysOverride = Keys.None;
                SkylineWindow.EditDelete();
            });

            // Should still have iRT peptides
            docIrt = VerifyIrtStandards(docIrt, true);
            // Remove one more and standards should be cleared
            RunUI(SkylineWindow.Cut);
            docIrt = VerifyIrtStandards(docIrt, false);
            RunUI(SkylineWindow.Paste);
            docIrt = VerifyIrtStandards(docIrt, true);

            // Repeat without results
            RunDlg <ManageResultsDlg>(SkylineWindow.ManageResults, dlg =>
            {
                dlg.RemoveAllReplicates();
                dlg.OkDialog();
            });

            docIrt = VerifyIrtStandards(docIrt, true);
            RunUI(SkylineWindow.EditDelete);
            docIrt = VerifyIrtStandards(docIrt, false);
            RunUI(SkylineWindow.Paste);
            VerifyIrtStandards(docIrt, true);

            //Restore the document to contain all 29 peptides
            RunUI(() => SkylineWindow.UndoRestore(7));

            //Open peptide settings
            var peptideSettingsDlg3 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunDlg <EditListDlg <SettingsListBase <RetentionTimeRegression>, RetentionTimeRegression> >(peptideSettingsDlg3.EditRegressionList,
                                                                                                        dlg =>
            {
                dlg.SelectLastItem();
                dlg.RemoveItem();
                dlg.OkDialog();
            });

            //Add a new regression
            var editRT3 = ShowDialog <EditRTDlg>(peptideSettingsDlg3.AddRTRegression);

            RunUI(() => editRT3.SetRegressionName("iRT Document Regression"));

            //Edit the calculator list
            var editCalculator =
                ShowDialog <EditListDlg <SettingsListBase <RetentionScoreCalculatorSpec>, RetentionScoreCalculatorSpec> >(
                    editRT3.EditCalculatorList);

            RunUI(() => editCalculator.SelectItem("iRT Document Calculator"));

            //Edit the document-based calculator
            var irtDlg3 = ShowDialog <EditIrtCalcDlg>(editCalculator.EditItem);

            //Add the 18 non-standard peptides to the calculator, then OkDialog back to Skyline
            var addPeptidesDlg  = ShowDialog <AddIrtPeptidesDlg>(irtDlg3.AddResults);
            var recalibrateDlg2 = ShowDialog <MultiButtonMsgDlg>(addPeptidesDlg.OkDialog);

            OkDialog(recalibrateDlg2, recalibrateDlg2.Btn1Click);

            RunUI(() =>
            {
                Assert.AreEqual(18, irtDlg3.LibraryPeptideCount);
                irtDlg3.OkDialog();
            });
            WaitForClosedForm(irtDlg3);

            RunUI(editCalculator.OkDialog);
            WaitForClosedForm(editCalculator);

            RunUI(() =>
            {
                editRT3.AddResults();
                editRT3.ChooseCalculator("iRT Document Calculator");
                editRT3.SetTimeWindow(2.0);
                editRT3.OkDialog();
            });
            WaitForClosedForm(editRT3);

            //Then choose the new, document-based regression and turn off prediction
            RunUI(() =>
            {
                peptideSettingsDlg3.ChooseRegression("iRT Document Regression");
                peptideSettingsDlg3.IsUseMeasuredRT = true;
                peptideSettingsDlg3.OkDialog();
            });

            WaitForClosedForm(peptideSettingsDlg3);

            Assert.IsNull(FindOpenForm <MessageDlg>());

            //Export the measurement-based transition list
            ExportMethod(testFilesDir.GetTestPath("EmpiricalTL.csv"));

            //Turn on prediction for scheduling
            var peptideSettingsDlg4 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunUI(() =>
            {
                peptideSettingsDlg4.IsUseMeasuredRT = false;
                peptideSettingsDlg4.OkDialog();
            });
            WaitForClosedForm(peptideSettingsDlg4);

            //Export the prediction-based transition list
            ExportMethod(testFilesDir.GetTestPath("PredictionTL.csv"));

            //Now open both files and compare
            AssertEx.NoDiff(File.ReadAllText(testFilesDir.GetTestPath("EmpiricalTL.csv")),
                            File.ReadAllText(testFilesDir.GetTestPath("PredictionTL.csv")));

            // Close and re-open, and try again
            RunUI(() =>
            {
                Assert.IsTrue(SkylineWindow.SaveDocument());
                SkylineWindow.NewDocument();
                Assert.IsTrue(SkylineWindow.OpenFile(documentPath));
            });

            WaitForDocumentLoaded();

            ExportMethod(testFilesDir.GetTestPath("PredictionTL_reopen.csv"));

            AssertEx.NoDiff(File.ReadAllText(testFilesDir.GetTestPath("EmpiricalTL.csv")),
                            File.ReadAllText(testFilesDir.GetTestPath("PredictionTL_reopen.csv")));

            /*
             * Rename the database
             * Switch to the calculator in EditRTDlg and check for an error
             * Go to edit the calculator and check for an error
             * Try to export a transition list and check for an error
             * Switch to the calculator in the graph and check for an error
             */
            var stream = File.Create(testFilesDir.GetTestPath("irt-c18-copy.irtdb"));

            stream.Close();
            File.Replace(databasePath, testFilesDir.GetTestPath("irt-c18-copy.irtdb"),
                         testFilesDir.GetTestPath("backup.irtdb"));

            // The database renaming doesn't break usage anymore, since
            // the iRT databases are loaded into memory during initialization.
            // So, create a new calculator with a bogus path.
            const string irtCalcMissing = "iRT-C18-missing";

            Settings.Default.RTScoreCalculatorList.SetValue(new RCalcIrt(irtCalcMissing, testFilesDir.GetTestPath("irt-c18-missing.irtdb")));

            var peptideSettingsDlg5 = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);
            var editRT5             = ShowDialog <EditRTDlg>(peptideSettingsDlg5.AddRTRegression);

            //Add results and switch to a calculator whose database is not connected: error
            RunDlg <MessageDlg>(() =>
            {
                editRT5.AddResults();
                editRT5.ChooseCalculator(irtCalcMissing);
            },
                                errorMessage => errorMessage.OkDialog());

            //Go to add a new calculator
            var irtDlg5 = ShowDialog <EditIrtCalcDlg>(editRT5.AddCalculator);

            //Try to open a file that does not exist: error
            RunDlg <MessageDlg>(() => irtDlg5.OpenDatabase(databasePath), messageDlg => messageDlg.OkDialog());

            RunUI(() => irtDlg5.CancelButton.PerformClick());
            WaitForClosedForm(irtDlg5);

            //In order to export a transition list, we have to set the RT regression to have the iRT Calc.
            //This means that the iRT calc must have its database connected - else the dialog will not let
            //the user choose it. So here we will restore the file so we can choose the calculator.
            //Then once that dialog is closed and the regression is saved, switch the file back again.
            stream = File.Create(databasePath);
            stream.Close();
            File.Replace(testFilesDir.GetTestPath("irt-c18-copy.irtdb"), databasePath,
                         testFilesDir.GetTestPath("backup.irtdb"));

            RunUI(() =>
            {
                editRT5.SetRegressionName("iRT Test Regression");
                editRT5.AddResults();
                editRT5.ChooseCalculator(irtCalc);
                editRT5.OkDialog();
            });
            WaitForClosedForm(editRT5);

            RunUI(() =>
            {
                peptideSettingsDlg5.ChooseRegression("iRT Test Regression");
                peptideSettingsDlg5.IsUseMeasuredRT = false;           //Use prediction
                peptideSettingsDlg5.OkDialog();
            });
            WaitForClosedForm(peptideSettingsDlg5);

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

            //Switch the file back to the copy, destroying the original
            stream = File.Create(testFilesDir.GetTestPath("irt-c18-copy.irtdb"));
            stream.Close();
            File.Replace(databasePath, testFilesDir.GetTestPath("irt-c18-copy.irtdb"),
                         testFilesDir.GetTestPath("backup.irtdb"));

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

            // Used to cause a message box, but should work now, because iRT databases get loaded once
            RunUI(() => exportTransList.SetMethodType(ExportMethodType.Scheduled));

            RunUI(() => exportTransList.CancelButton.PerformClick());
            WaitForClosedForm(exportTransList);

            // Used to cause a message box, but should work now, because iRT databases get loaded once
            RunUI(() => SkylineWindow.ChooseCalculator(irtCalc));

            /*
             * Now clean up by deleting all these calculators. If we don't, then the next functional test
             * will fail because it will try to use a calculator from settings which will not have its
             * database.
             */
            RunDlg <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI, peptideSettingsDlg6 =>
            {
                peptideSettingsDlg6.ChooseRegression(Resources.SettingsList_ELEMENT_NONE_None);
                peptideSettingsDlg6.OkDialog();
            });

            // Finally, close and re-open the document to see MissingFileDlg
            int pepCount = SkylineWindow.Document.PeptideCount;

            RunUI(() => SkylineWindow.NewDocument(true));
            Assert.AreEqual(0, SkylineWindow.Document.PeptideCount);
            RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath),
                                    dlg => dlg.OkDialog());
            Assert.AreEqual(pepCount, SkylineWindow.Document.PeptideCount);
            RunUI(() => SkylineWindow.NewDocument(true));
            RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath),
                                    dlg => dlg.CancelDialog());
            Assert.AreEqual(0, SkylineWindow.Document.PeptideCount);

            // Make sure no message boxes are left open
            Assert.IsNull(FindOpenForm <MessageDlg>());
        }
Esempio n. 30
0
        protected override void DoTest()
        {
            // Associate yeast background proteome
            var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            RunDlg <BuildBackgroundProteomeDlg>(peptideSettingsUI.ShowBuildBackgroundProteomeDlg,
                                                buildBackgroundProteomeDlg =>
            {
                buildBackgroundProteomeDlg.BackgroundProteomePath = TestFilesDir.GetTestPath(@"InsertTest\Yeast_MRMer.protdb");
                buildBackgroundProteomeDlg.BackgroundProteomeName = "Yeast";
                buildBackgroundProteomeDlg.OkDialog();
            });
            RunUI(peptideSettingsUI.OkDialog);
            WaitForClosedForm(peptideSettingsUI);
            WaitForCondition(() =>
            {
                var peptideSettings    = Program.ActiveDocument.Settings.PeptideSettings;
                var backgroundProteome = peptideSettings.BackgroundProteome;
                return(backgroundProteome.HasDigestion(peptideSettings));
            });
            WaitForBackgroundProteomeLoaderCompleted(); // Allow protDB file to populate protein metadata first

            SetClipboardTextUI(PEPTIDES_CLIPBOARD_TEXT);
            var insertPeptidesDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);

            using (new CheckDocumentState(6, 9, 9, 28))
            {
                // Keep all peptides.
                PastePeptides(insertPeptidesDlg, BackgroundProteome.DuplicateProteinsFilter.AddToAll, true, true);
                Assert.AreEqual(10, insertPeptidesDlg.PeptideRowCount);
                Assert.IsTrue(insertPeptidesDlg.PeptideRowsContainProtein(string.IsNullOrEmpty));
                Assert.IsFalse(insertPeptidesDlg.PeptideRowsContainPeptide(string.IsNullOrEmpty));
                OkDialog(insertPeptidesDlg, insertPeptidesDlg.OkDialog);
            }

            // Keep only first protein.
            var insertPeptidesDlg1 = ShowDialog <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg);

            PastePeptides(insertPeptidesDlg1, BackgroundProteome.DuplicateProteinsFilter.FirstOccurence, true, true);
            Assert.AreEqual(8, insertPeptidesDlg1.PeptideRowCount);
            Assert.IsFalse(insertPeptidesDlg1.PeptideRowsContainProtein(protein => Equals(protein, "YHR174W")));
            RunUI(insertPeptidesDlg1.ClearRows);
            // Filter peptides with multiple matches.
            PastePeptides(insertPeptidesDlg1, BackgroundProteome.DuplicateProteinsFilter.NoDuplicates, true, true);
            Assert.AreEqual(6, insertPeptidesDlg1.PeptideRowCount);
            Assert.IsFalse(insertPeptidesDlg1.PeptideRowsContainProtein(protein => Equals(protein, "YGR254W")));
            RunUI(insertPeptidesDlg1.ClearRows);
            // Filter unmatched.
            PastePeptides(insertPeptidesDlg1, BackgroundProteome.DuplicateProteinsFilter.AddToAll, false, true);
            Assert.IsFalse(insertPeptidesDlg1.PeptideRowsContainProtein(string.IsNullOrEmpty));
            RunUI(insertPeptidesDlg1.ClearRows);
            // Filter peptides not matching settings.
            PastePeptides(insertPeptidesDlg1, BackgroundProteome.DuplicateProteinsFilter.AddToAll, true, false);
            Assert.AreEqual(9, insertPeptidesDlg1.PeptideRowCount);
            Assert.IsFalse(insertPeptidesDlg1.PeptideRowsContainPeptide(peptide =>
                                                                        !SkylineWindow.Document.Settings.Accept(peptide)));
            RunUI(insertPeptidesDlg1.ClearRows);
            // Pasting garbage should throw an error then disallow the paste.
            SetClipboardTextUI(PEPTIDES_CLIPBOARD_TEXT_GARBAGE);
            RunDlg <MessageDlg>(insertPeptidesDlg1.PastePeptides, messageDlg => messageDlg.OkDialog());
            Assert.AreEqual(1, insertPeptidesDlg1.PeptideRowCount);
            RunUI(insertPeptidesDlg1.Close);
            WaitForClosedForm(insertPeptidesDlg);

            // Test pasting a transition list.
            SetClipboardTextUI(TransitionsClipboardText);
            var insertTransitionListDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);

            PasteTransitions(insertTransitionListDlg, BackgroundProteome.DuplicateProteinsFilter.AddToAll, true, true);
            Assert.AreEqual(25, insertTransitionListDlg.TransitionRowCount);
            RunUI(insertTransitionListDlg.ValidateCells);
            WaitForConditionUI(() => insertTransitionListDlg.ErrorText != null);
            RunUI(() => Assert.IsTrue(insertTransitionListDlg.ErrorText.Contains((506.7821).ToString(LocalizationHelper.CurrentCulture)),
                                      string.Format("Unexpected error: {0}", insertTransitionListDlg.ErrorText)));

            RunUI(() =>
            {
                // Test validation, OkDialog. This used to throw an exception.
                insertTransitionListDlg.OkDialog();
                insertTransitionListDlg.OkDialog();
                Assert.IsTrue(insertTransitionListDlg.DialogResult == DialogResult.None, "Second call to PasteDlg.OkDialog succeeded unexpectedly");
                insertTransitionListDlg.ClearRows();
                insertTransitionListDlg.OkDialog();
                Assert.IsTrue(insertTransitionListDlg.DialogResult == DialogResult.OK, "Third call to PastDlg.OkDialog did not succeed");
            });
            WaitForClosedForm(insertTransitionListDlg);

            // Test modification matching
            IList <TypedModifications> heavyMod = new[]
            {
                new TypedModifications(IsotopeLabelType.heavy, new List <StaticMod>
                {
                    new StaticMod("Label:13C(6)15N(4)", "R", null, null, LabelAtoms.C13 | LabelAtoms.N15, null, null)
                })
            };
            SrmDocument document = SkylineWindow.Document;

            RunUI(() =>
            {
                SkylineWindow.ModifyDocument("Add modification", doc =>
                                             doc.ChangeSettings(doc.Settings.ChangePeptideModifications(mods => new PeptideModifications(mods.StaticModifications, heavyMod))));
                SkylineWindow.Document.Settings.UpdateDefaultModifications(true);
            });
            WaitForDocumentChange(document);

            var pasteDlg = ShowDialog <PasteDlg>(SkylineWindow.ShowPasteTransitionListDlg);

            SetClipboardTextUI("LGPGRPLPTFPTSEC[+57]TS[+80]DVEPDTR[+10]\t907.081803\t1387.566968\tDDX54_CL02".Replace(".", LocalizationHelper.CurrentCulture.NumberFormat.NumberDecimalSeparator));
            RunUI(() =>
            {
                pasteDlg.IsMolecule = false;
                pasteDlg.PasteTransitions();
                pasteDlg.ValidateCells();
                Assert.AreEqual(Resources.PasteDlg_ShowNoErrors_No_errors, pasteDlg.ErrorText);
                pasteDlg.CancelDialog();
            });
            WaitForClosedForm(pasteDlg);
        }
Esempio n. 31
0
        private void OpenSkylineStartupSettingsUI(SkylineWindow skylineWindow)
        {
            ImportPeptideSearchDlg.Workflow? importPeptideSearchType = null;
            switch (ImportType)
            {
                case DataType.peptide_search_dda:
                    importPeptideSearchType = ImportPeptideSearchDlg.Workflow.dda;
                    break;
                case DataType.peptide_search_prm:
                    importPeptideSearchType = ImportPeptideSearchDlg.Workflow.prm;
                    break;
                case DataType.peptide_search_dia:
                    importPeptideSearchType = ImportPeptideSearchDlg.Workflow.dia;
                    break;
            }
            if (importPeptideSearchType.HasValue)
            {
                if (FilePath != null)
                    skylineWindow.LoadFile(FilePath);
                skylineWindow.ResetDefaultSettings();
                skylineWindow.ShowImportPeptideSearchDlg(importPeptideSearchType.Value);
                return;
            }

            using (var settingsUI = new StartPageSettingsUI(skylineWindow))
            {
                if (settingsUI.ShowDialog(skylineWindow) == DialogResult.OK)
                {
                    skylineWindow.SetIntegrateAll(settingsUI.IsIntegrateAll);

                    switch (ImportType)
                    {
                        case DataType.fasta:
                            skylineWindow.OpenPasteFileDlg(PasteFormat.fasta);
                            break;
                        case DataType.peptides:
                            skylineWindow.OpenPasteFileDlg(PasteFormat.peptide_list);
                            break;
                        case DataType.proteins:
                            skylineWindow.OpenPasteFileDlg(PasteFormat.protein_list);
                            break;
                        case DataType.transition_list:
                            skylineWindow.OpenPasteFileDlg(PasteFormat.transition_list);
                            break;
                    }
                }
            }
        }
Esempio n. 32
0
        public void CommitBatchModifyDocument(string description, DataGridViewPasteHandler.BatchModifyInfo batchModifyInfo)
        {
            if (null == _batchChangesOriginalDocument)
            {
                throw new InvalidOperationException();
            }
            string message = Resources.DataGridViewPasteHandler_EndDeferSettingsChangesOnDocument_Updating_settings;

            SkylineWindow.ModifyDocument(description, document =>
            {
                VerifyDocumentCurrent(_batchChangesOriginalDocument, document);
                using (var longWaitDlg = new LongWaitDlg
                {
                    Message = message
                })
                {
                    SrmDocument newDocument = null;
                    longWaitDlg.PerformWork(SkylineWindow, 1000, progressMonitor =>
                    {
                        var srmSettingsChangeMonitor = new SrmSettingsChangeMonitor(progressMonitor,
                                                                                    message);
                        newDocument = _document.EndDeferSettingsChanges(_batchChangesOriginalDocument.Settings, srmSettingsChangeMonitor);
                    });
                    return(newDocument);
                }
            }, docPair =>
            {
                MessageType singular, plural;
                var detailType = MessageType.set_to_in_document_grid;
                Func <EditDescription, object[]> getArgsFunc = descr => new object[]
                {
                    descr.ColumnCaption.GetCaption(DataSchemaLocalizer), descr.ElementRefName,
                    CellValueToString(descr.Value)
                };

                switch (batchModifyInfo.BatchModifyAction)
                {
                case DataGridViewPasteHandler.BatchModifyAction.Paste:
                    singular = MessageType.pasted_document_grid_single;
                    plural   = MessageType.pasted_document_grid;
                    break;

                case DataGridViewPasteHandler.BatchModifyAction.Clear:
                    singular    = MessageType.cleared_document_grid_single;
                    plural      = MessageType.cleared_document_grid;
                    detailType  = MessageType.cleared_cell_in_document_grid;
                    getArgsFunc = descr => new[] { (object)descr.ColumnCaption.GetCaption(DataSchemaLocalizer), descr.ElementRefName };
                    break;

                case DataGridViewPasteHandler.BatchModifyAction.FillDown:
                    singular = MessageType.fill_down_document_grid_single;
                    plural   = MessageType.fill_down_document_grid;
                    break;

                default:
                    return(null);
                }

                var entry = AuditLogEntry.CreateCountChangeEntry(docPair.OldDoc, singular, plural,
                                                                 _batchEditDescriptions,
                                                                 descr => MessageArgs.Create(descr.ColumnCaption.GetCaption(DataSchemaLocalizer)),
                                                                 null).ChangeExtraInfo(batchModifyInfo.ExtraInfo + Environment.NewLine);

                entry = entry.Merge(batchModifyInfo.EntryCreator.Create(docPair));

                return(entry.AppendAllInfo(_batchEditDescriptions.Select(descr => new MessageInfo(detailType,
                                                                                                  getArgsFunc(descr))).ToList()));
            });
            _batchChangesOriginalDocument = null;
            _batchEditDescriptions        = null;
            DocumentChangedEventHandler(_documentContainer, new DocumentChangedEventArgs(_document));
        }
Esempio n. 33
0
        protected override void DoTest()
        {
            RunDlg <PasteDlg>(SkylineWindow.ShowPastePeptidesDlg, pasteDlg =>
            {
                SetClipboardText(
                    TextUtil.LineSeparate("SKYLINE", "LAUREL", "YANNY", "BALLISTICALLY"));
                pasteDlg.PastePeptides();
                pasteDlg.OkDialog();
            });
            Assert.AreEqual(4, SkylineWindow.Document.PeptideCount);

            // Turn off "Auto manage children" on the second peptide and make sure the appropriate precursors still get added.
            RunUI(() =>
            {
                SkylineWindow.SelectedPath = SkylineWindow.Document.GetPathTo((int)SrmDocument.Level.Molecules, 1);
            });
            RunDlg <PopupPickList>(SkylineWindow.ShowPickChildrenInTest, dlg =>
            {
                dlg.AutoManageChildren = false;
                dlg.OnOk();
            });
            CollectionAssert.AreEqual(new[] { true, false, true, true },
                                      SkylineWindow.Document.Peptides.Select(p => p.AutoManageChildren).ToList());

            var permuteIsotopeModificationsDlg =
                ShowDialog <PermuteIsotopeModificationsDlg>(SkylineWindow.ShowPermuteIsotopeModificationsDlg);

            RunDlg <EditStaticModDlg>(permuteIsotopeModificationsDlg.AddIsotopeModification, editStaticModDlg =>
            {
                if (!Settings.Default.StaticModsShowMore)
                {
                    editStaticModDlg.ToggleLessMore();
                }
                editStaticModDlg.SetModification("Label:2H(3) (L)");
                editStaticModDlg.OkDialog();
            });
            OkDialog(permuteIsotopeModificationsDlg, permuteIsotopeModificationsDlg.OkDialog);
            var expectedHeavyLabelTypeNames = new List <string>();

            expectedHeavyLabelTypeNames.Add(IsotopeLabelType.HEAVY_NAME);
            expectedHeavyLabelTypeNames.AddRange(Enumerable.Range(1, 3).Select(i => IsotopeLabelType.HEAVY_NAME + i));
            var peptideModifications = SkylineWindow.Document.Settings.PeptideSettings.Modifications;

            CollectionAssert.AreEquivalent(expectedHeavyLabelTypeNames,
                                           peptideModifications.GetHeavyModifications().Select(typedMods => typedMods.LabelType.Name).ToList());
            foreach (var peptide in SkylineWindow.Document.Peptides)
            {
                int leucineCount = peptide.Peptide.Sequence.Count(c => c == 'L');
                Assert.AreEqual(leucineCount + 1, peptide.TransitionGroupCount);

                var fullyLabeledPrecursor =
                    peptide.TransitionGroups.FirstOrDefault(tg => tg.LabelType.Name == IsotopeLabelType.HEAVY_NAME);
                if (leucineCount == 0)
                {
                    Assert.IsNull(fullyLabeledPrecursor);
                    continue;
                }
                Assert.IsNotNull(fullyLabeledPrecursor);
                var fullyHeavyMods = peptide.ExplicitMods.GetHeavyModifications()
                                     .FirstOrDefault(typedMods => typedMods.LabelType.Name == IsotopeLabelType.HEAVY_NAME);
                Assert.IsNotNull(fullyHeavyMods);
                Assert.AreEqual(leucineCount, fullyHeavyMods.Modifications.Count);
                for (int i = 1; i < leucineCount; i++)
                {
                    var labelTypeName    = IsotopeLabelType.HEAVY_NAME + i;
                    var partialHeavyMods = peptide.ExplicitMods.GetHeavyModifications()
                                           .FirstOrDefault(typedMods => typedMods.LabelType.Name == labelTypeName);
                    Assert.IsNotNull(partialHeavyMods);
                    Assert.AreEqual(i, partialHeavyMods.Modifications.Count);
                }
            }
            permuteIsotopeModificationsDlg =
                ShowDialog <PermuteIsotopeModificationsDlg>(SkylineWindow.ShowPermuteIsotopeModificationsDlg);
            RunUI(() => permuteIsotopeModificationsDlg.SimplePermutation = false);
            OkDialog(permuteIsotopeModificationsDlg, permuteIsotopeModificationsDlg.OkDialog);
            peptideModifications = SkylineWindow.Document.Settings.PeptideSettings.Modifications;
            expectedHeavyLabelTypeNames.Clear();
            expectedHeavyLabelTypeNames.Add(IsotopeLabelType.HEAVY_NAME);
            expectedHeavyLabelTypeNames.AddRange(Enumerable.Range(1, (int)Math.Pow(2, 4) - 2).Select(i => IsotopeLabelType.HEAVY_NAME + i));
            CollectionAssert.AreEquivalent(expectedHeavyLabelTypeNames,
                                           peptideModifications.GetHeavyModifications().Select(typedMods => typedMods.LabelType.Name).ToList());
            foreach (var peptide in SkylineWindow.Document.Peptides)
            {
                int leucineCount = peptide.Peptide.Sequence.Count(c => c == 'L');
                AssertEx.AreEqual(Math.Pow(2, leucineCount), peptide.TransitionGroupCount);

                var fullyLabeledPrecursor =
                    peptide.TransitionGroups.FirstOrDefault(tg => tg.LabelType.Name == IsotopeLabelType.HEAVY_NAME);
                if (leucineCount == 0)
                {
                    Assert.IsNull(fullyLabeledPrecursor);
                    continue;
                }
                Assert.IsNotNull(fullyLabeledPrecursor);
                var fullyHeavyMods = peptide.ExplicitMods.GetHeavyModifications()
                                     .FirstOrDefault(typedMods => typedMods.LabelType.Name == IsotopeLabelType.HEAVY_NAME);
                Assert.IsNotNull(fullyHeavyMods);
                Assert.AreEqual(leucineCount, fullyHeavyMods.Modifications.Count);
                Assert.AreEqual(Math.Pow(2, leucineCount) - 1, peptide.ExplicitMods.GetHeavyModifications().Count());
                var modificationIndexSets = new HashSet <ImmutableList <int> >();
                var fullyLabeledIndexes   =
                    ImmutableList.ValueOf(fullyHeavyMods.Modifications.Select(mod => mod.IndexAA));
                Assert.AreEqual(leucineCount, fullyLabeledIndexes.Count);
                Assert.AreEqual(fullyLabeledIndexes.Count, fullyLabeledIndexes.Distinct().Count());
                modificationIndexSets.Add(fullyLabeledIndexes);
                foreach (var partialModifications in peptide.ExplicitMods.GetHeavyModifications())
                {
                    if (partialModifications.LabelType.Name == IsotopeLabelType.HEAVY_NAME)
                    {
                        continue;
                    }

                    var modificationIndexes =
                        ImmutableList.ValueOf(partialModifications.Modifications.Select(mod => mod.IndexAA));
                    CollectionAssert.IsSubsetOf(modificationIndexes.ToList(), fullyLabeledIndexes.ToList());
                    Assert.IsTrue(modificationIndexSets.Add(modificationIndexes));
                }
                Assert.AreEqual(Math.Pow(2, leucineCount) - 1, modificationIndexSets.Count);
            }

            CollectionAssert.AreEqual(new[] { true, false, true, true },
                                      SkylineWindow.Document.Peptides.Select(p => p.AutoManageChildren).ToList());
            var filePath = Path.Combine(TestContext.TestDir, "ModificationPermuterTest.sky");

            RunUI(() =>
            {
                SkylineWindow.SaveDocument(filePath);
                SkylineWindow.OpenFile(filePath);
            });
        }
Esempio n. 34
0
        public static int Main(string[] args = null)
        {
            if (String.IsNullOrEmpty(Settings.Default.InstallationId)) // Each instance to have GUID
            {
                Settings.Default.InstallationId = Guid.NewGuid().ToString();
            }

            // don't allow 64-bit Skyline to run in a 32-bit process
            if (Install.Is64Bit && !Environment.Is64BitProcess)
            {
                string installUrl   = Install.Url;
                string installLabel = (installUrl == string.Empty) ? string.Empty : string.Format(Resources.Program_Main_Install_32_bit__0__, Name);
                AlertLinkDlg.Show(null,
                                  string.Format(Resources.Program_Main_You_are_attempting_to_run_a_64_bit_version_of__0__on_a_32_bit_OS_Please_install_the_32_bit_version, Name),
                                  installLabel,
                                  installUrl);
                return(1);
            }

            SecurityProtocolInitializer.Initialize(); // Enable highest available security level for HTTPS connections

            CommonFormEx.TestMode      = FunctionalTest;
            CommonFormEx.Offscreen     = SkylineOffscreen;
            CommonFormEx.ShowFormNames = FormEx.ShowFormNames = ShowFormNames;

            // For testing and debugging Skyline command-line interface
            bool openDoc = args != null && args.Length > 0 && args[0] == OPEN_DOCUMENT_ARG;

            if (args != null && args.Length > 0 && !openDoc)
            {
                if (!CommandLineRunner.HasCommandPrefix(args[0]))
                {
                    TextWriter textWriter;
                    if (Debugger.IsAttached)
                    {
                        textWriter = new DebugWriter();
                    }
                    else
                    {
                        AttachConsole(-1);
                        textWriter = Console.Out;
                    }
                    var writer = new CommandStatusWriter(textWriter);
                    if (args[0].Equals(@"--ui", StringComparison.InvariantCultureIgnoreCase))
                    {
                        // ReSharper disable once ObjectCreationAsStatement
                        new CommandLineUI(args, writer);
                    }
                    else
                    {
                        return(CommandLineRunner.RunCommand(args, writer));
                    }
                }
                else
                {
                    // For testing SkylineRunner without installation
                    CommandLineRunner clr = new CommandLineRunner();
                    clr.Start(args[0]);
                }

                return(EXIT_CODE_SUCCESS);
            }
            // The way Skyline command-line interface is run for an installation
            else if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null &&
                     AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null &&
                     AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0 &&
                     CommandLineRunner.HasCommandPrefix(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]))
            {
                CommandLineRunner clr = new CommandLineRunner();
                clr.Start(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]);

                // HACK: until the "invalid string binding" error is resolved, this will prevent an error dialog at exit
                Process.GetCurrentProcess().Kill();
                return(EXIT_CODE_SUCCESS);
            }

            try
            {
                Init();
                if (!string.IsNullOrEmpty(Settings.Default.DisplayLanguage))
                {
                    try
                    {
                        LocalizationHelper.CurrentUICulture =
                            CultureInfo.GetCultureInfo(Settings.Default.DisplayLanguage);
                    }
                    catch (CultureNotFoundException)
                    {
                    }
                }
                LocalizationHelper.InitThread(Thread.CurrentThread);

                // Make sure the user has agreed to the current license version
                // or one more recent.
                int licenseVersion = Settings.Default.LicenseVersionAccepted;
                if (licenseVersion < LICENSE_VERSION_CURRENT && !NoSaveSettings)
                {
                    // If the user has never used the application before, then
                    // they must have agreed to the current license agreement during
                    // installation.  Otherwise, make sure they agree to the new
                    // license agreement.
                    if (Install.Type == Install.InstallType.release &&
                        (licenseVersion != 0 || !Settings.Default.MainWindowSize.IsEmpty))
                    {
                        using (var dlg = new UpgradeLicenseDlg(licenseVersion))
                        {
                            if (dlg.ShowParentlessDialog() == DialogResult.Cancel)
                            {
                                return(EXIT_CODE_FAILURE_TO_START);
                            }
                        }
                    }

                    try
                    {
                        // Make sure the user never sees this again for this license version
                        Settings.Default.LicenseVersionAccepted = LICENSE_VERSION_CURRENT;
                        Settings.Default.Save();
                    }
// ReSharper disable EmptyGeneralCatchClause
                    catch (Exception)
// ReSharper restore EmptyGeneralCatchClause
                    {
                        // Just try to update the license version next time.
                    }
                }

                try
                {
                    // If this is a new installation copy over installed external tools from previous installation location.
                    var toolsDirectory = ToolDescriptionHelpers.GetToolsDirectory();
                    if (!Directory.Exists(toolsDirectory))
                    {
                        using (var longWaitDlg = new LongWaitDlg
                        {
                            Text = Name,
                            Message = Resources.Program_Main_Copying_external_tools_from_a_previous_installation,
                            ProgressValue = 0
                        })
                        {
                            longWaitDlg.PerformWork(null, 1000 * 3, broker => CopyOldTools(toolsDirectory, broker));
                        }
                    }
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch
                {
                }

                // Force live reports (though tests may reset this)
                //Settings.Default.EnableLiveReports = true;

                if (ReportShutdownDlg.HadUnexpectedShutdown())
                {
                    using (var reportShutdownDlg = new ReportShutdownDlg())
                    {
                        reportShutdownDlg.ShowParentlessDialog();
                    }
                }
                SystemEvents.DisplaySettingsChanged += SystemEventsOnDisplaySettingsChanged;
                // Careful, a throw out of the SkylineWindow constructor without this
                // catch causes Skyline just to appear to silently never start.  Makes for
                // some difficult debugging.
                try
                {
                    var activationArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments;
                    if ((activationArgs != null &&
                         activationArgs.ActivationData != null &&
                         activationArgs.ActivationData.Length != 0) ||
                        openDoc ||
                        !Settings.Default.ShowStartupForm)
                    {
                        MainWindow = new SkylineWindow(args);
                    }
                    else
                    {
                        StartWindow = new StartPage();
                        try
                        {
                            if (StartWindow.ShowParentlessDialog() != DialogResult.OK)
                            {
                                Application.Exit();
                                return(EXIT_CODE_SUCCESS);
                            }

                            MainWindow = StartWindow.MainWindow;
                        }
                        finally
                        {
                            StartWindow.Dispose();
                            StartWindow = null;
                        }
                    }
                }
                catch (Exception x)
                {
                    ReportExceptionUI(x, new StackTrace(1, true));
                }

//                ConcurrencyVisualizer.StartEvents(MainWindow);

                // Position window offscreen for stress testing.
                if (SkylineOffscreen)
                {
                    FormEx.SetOffscreen(MainWindow);
                }
                if (!UnitTest)  // Covers Unit and Functional tests
                {
                    SendAnalyticsHitAsync();
                }

                MainToolServiceName = Guid.NewGuid().ToString();
                Application.Run(MainWindow);
                StopToolService();
            }
            catch (Exception x)
            {
                // Send unhandled exceptions to the console.
                Console.WriteLine(x.Message);
                Console.Write(x.StackTrace);
            }

            MainWindow = null;
            SystemEvents.DisplaySettingsChanged -= SystemEventsOnDisplaySettingsChanged;
            return(EXIT_CODE_SUCCESS);
        }
Esempio n. 35
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);
            }
        }
Esempio n. 36
0
 /// <summary>
 /// For modifying at the Molecule level
 /// </summary>
 public EditCustomMoleculeDlg(SkylineWindow parent, string title,
                              SrmSettings settings, CustomMolecule molecule, ExplicitRetentionTimeInfo explicitRetentionTime) :
     this(parent, UsageMode.moleculeEdit, title, null, null, 0, 0, null, molecule, Adduct.EMPTY, null,
          explicitRetentionTime, null)
 {
 }
Esempio n. 37
0
        public PeptideSettingsUI(SkylineWindow parent, LibraryManager libraryManager)
        {
            InitializeComponent();

            btnUpdateIonMobilityLibraries.Visible = false; // TODO: ion mobility libraries are more complex than initially thought - put this off until after summer 2014 release

            _parent = parent;
            _libraryManager = libraryManager;
            _peptideSettings = parent.DocumentUI.Settings.PeptideSettings;

            // Initialize digestion settings
            _driverEnzyme = new SettingsListComboDriver<Enzyme>(comboEnzyme, Settings.Default.EnzymeList);
            _driverEnzyme.LoadList(_peptideSettings.Enzyme.GetKey());
            for (int i = DigestSettings.MIN_MISSED_CLEAVAGES; i <= DigestSettings.MAX_MISSED_CLEAVAGES; i++)
                comboMissedCleavages.Items.Add(i.ToString(CultureInfo.InvariantCulture));
            comboMissedCleavages.SelectedItem = Digest.MaxMissedCleavages.ToString(LocalizationHelper.CurrentCulture);
            if (comboMissedCleavages.SelectedIndex < 0)
                comboMissedCleavages.SelectedIndex = 0;
            cbRaggedEnds.Checked = Digest.ExcludeRaggedEnds;

            // Initialize prediction settings
            _driverRT = new SettingsListComboDriver<RetentionTimeRegression>(comboRetentionTime, Settings.Default.RetentionTimeList);
            string sel = (Prediction.RetentionTime == null ? null : Prediction.RetentionTime.Name);
            _driverRT.LoadList(sel);
            cbUseMeasuredRT.Checked = textMeasureRTWindow.Enabled = Prediction.UseMeasuredRTs;
            if (Prediction.MeasuredRTWindow.HasValue)
                textMeasureRTWindow.Text = Prediction.MeasuredRTWindow.Value.ToString(LocalizationHelper.CurrentCulture);

            _driverDT = new SettingsListComboDriver<DriftTimePredictor>(comboDriftTimePredictor, Settings.Default.DriftTimePredictorList);
            string selDT = (Prediction.DriftTimePredictor == null ? null : Prediction.DriftTimePredictor.Name);
            _driverDT.LoadList(selDT);
            cbUseSpectralLibraryDriftTimes.Checked = textSpectralLibraryDriftTimesResolvingPower.Enabled = Prediction.UseLibraryDriftTimes;
            if (Prediction.LibraryDriftTimesResolvingPower.HasValue)
                textSpectralLibraryDriftTimesResolvingPower.Text = Prediction.LibraryDriftTimesResolvingPower.Value.ToString(LocalizationHelper.CurrentCulture);

            // Initialize filter settings
            _driverExclusion = new SettingsListBoxDriver<PeptideExcludeRegex>(listboxExclusions, Settings.Default.PeptideExcludeList);
            _driverExclusion.LoadList(null, Filter.Exclusions);

            textExcludeAAs.Text = Filter.ExcludeNTermAAs.ToString(LocalizationHelper.CurrentCulture);
            textMaxLength.Text = Filter.MaxPeptideLength.ToString(LocalizationHelper.CurrentCulture);
            textMinLength.Text = Filter.MinPeptideLength.ToString(LocalizationHelper.CurrentCulture);
            cbAutoSelect.Checked = Filter.AutoSelect;

            // Initialize spectral library settings
            _driverLibrary = new SettingsListBoxDriver<LibrarySpec>(listLibraries, Settings.Default.SpectralLibraryList);
            IList<LibrarySpec> listLibrarySpecs = Libraries.LibrarySpecs;

            _driverLibrary.LoadList(null, listLibrarySpecs);
            _driverBackgroundProteome = new SettingsListComboDriver<BackgroundProteomeSpec>(comboBackgroundProteome, Settings.Default.BackgroundProteomeList);
            _driverBackgroundProteome.LoadList(_peptideSettings.BackgroundProteome.Name);

            panelPick.Visible = listLibrarySpecs.Count > 0;
            btnExplore.Enabled = listLibraries.Items.Count > 0;

            comboMatching.SelectedIndex = (int) Libraries.Pick;

            _lastRankId = Libraries.RankId;
            _lastPeptideCount = Libraries.PeptideCount.HasValue
                                    ? Libraries.PeptideCount.Value.ToString(LocalizationHelper.CurrentCulture)
                                    : null;

            UpdateRanks(null);

            // Initialize modification settings
            _driverStaticMod = new SettingsListBoxDriver<StaticMod>(listStaticMods, Settings.Default.StaticModList);
            _driverStaticMod.LoadList(null, Modifications.StaticModifications);
            _driverHeavyMod = new SettingsListBoxDriver<StaticMod>(listHeavyMods, Settings.Default.HeavyModList);
            _driverLabelType = new LabelTypeComboDriver(comboLabelType, Modifications, _driverHeavyMod,
                labelStandardType, comboStandardType, listStandardTypes);
            textMaxVariableMods.Text = Modifications.MaxVariableMods.ToString(LocalizationHelper.CurrentCulture);
            textMaxNeutralLosses.Text = Modifications.MaxNeutralLosses.ToString(LocalizationHelper.CurrentCulture);

            // Initialize peak scoring settings.
            _driverPeakScoringModel = new SettingsListComboDriver<PeakScoringModelSpec>(comboPeakScoringModel, Settings.Default.PeakScoringModelList);
            var peakScoringModel = _peptideSettings.Integration.PeakScoringModel;
            _driverPeakScoringModel.LoadList(peakScoringModel != null ? peakScoringModel.Name : null);

            IsShowLibraryExplorer = false;
            tabControl1.TabPages.Remove(tabIntegration);
            comboNormalizationMethod.Items.AddRange(
                NormalizationMethod.ListNormalizationMethods(parent.DocumentUI).ToArray());
            comboNormalizationMethod.SelectedItem = _peptideSettings.Quantification.NormalizationMethod;
            comboWeighting.Items.AddRange(RegressionWeighting.All.Cast<object>().ToArray());
            comboWeighting.SelectedItem = _peptideSettings.Quantification.RegressionWeighting;
            comboRegressionFit.Items.AddRange(RegressionFit.All.Cast<object>().ToArray());
            comboRegressionFit.SelectedItem = _peptideSettings.Quantification.RegressionFit;
            comboQuantMsLevel.SelectedIndex = Math.Max(0, _quantMsLevels.IndexOf(_peptideSettings.Quantification.MsLevel));
            tbxQuantUnits.Text = _peptideSettings.Quantification.Units;
        }
Esempio n. 38
0
        /// <summary>
        /// For creating at the Molecule level (create molecule and first transition group) or modifying at the transition level
        /// Null values imply "don't ask user for this"
        /// </summary>
        public EditCustomMoleculeDlg(SkylineWindow parent, UsageMode usageMode, string title, Identity initialId,
                                     IEnumerable <Identity> existingIds, int minCharge, int maxCharge,
                                     SrmSettings settings, CustomMolecule molecule, Adduct defaultCharge,
                                     ExplicitTransitionGroupValues explicitAttributes,
                                     ExplicitRetentionTimeInfo explicitRetentionTime,
                                     IsotopeLabelType defaultIsotopeLabelType)
        {
            Text                  = title;
            _parent               = parent;
            _initialId            = initialId;
            _existingIds          = existingIds;
            _minCharge            = minCharge;
            _maxCharge            = maxCharge;
            _transitionSettings   = settings != null ? settings.TransitionSettings : null;
            _peptideSettings      = settings != null ? settings.PeptideSettings : null;
            _resultAdduct         = Adduct.EMPTY;
            _resultCustomMolecule = molecule;
            _usageMode            = usageMode;

            var enableFormulaEditing = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.moleculeEdit ||
                                       usageMode == UsageMode.fragment;
            var enableAdductEditing = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.precursor ||
                                      usageMode == UsageMode.fragment;
            var suggestOnlyAdductsWithMass = usageMode != UsageMode.fragment;

            InitializeComponent();

            NameText         = molecule == null ? String.Empty : molecule.Name;
            textName.Enabled = usageMode == UsageMode.moleculeNew || usageMode == UsageMode.moleculeEdit ||
                               usageMode == UsageMode.fragment; // Can user edit name?

            var needOptionalValuesBox = explicitRetentionTime != null || explicitAttributes != null;
            var heightDelta           = 0;

            // Initialise the ion mobility units dropdown with L10N values
            foreach (eIonMobilityUnits t in Enum.GetValues(typeof(eIonMobilityUnits)))
            {
                comboBoxIonMobilityUnits.Items.Add(IonMobilityFilter.IonMobilityUnitsL10NString(t));
            }

            if (explicitAttributes == null)
            {
                ResultExplicitTransitionGroupValues = null;
                labelCollisionEnergy.Visible        = false;
                textCollisionEnergy.Visible         = false;
                labelSLens.Visible = false;
                textSLens.Visible  = false;
                labelCompensationVoltage.Visible = false;
                textCompensationVoltage.Visible  = false;
                labelCCS.Visible         = false;
                textBoxCCS.Visible       = false;
                labelConeVoltage.Visible = false;
                textConeVoltage.Visible  = false;
                labelIonMobilityHighEnergyOffset.Visible = false;
                textIonMobilityHighEnergyOffset.Visible  = false;
                labelIonMobility.Visible           = false;
                textIonMobility.Visible            = false;
                labelIonMobilityUnits.Visible      = false;
                comboBoxIonMobilityUnits.Visible   = false;
                labelDeclusteringPotential.Visible = false;
                textDeclusteringPotential.Visible  = false;
                if (needOptionalValuesBox)
                {
                    // We blanked out everything but the retention time
                    var vmargin   = labelRetentionTime.Location.Y;
                    var newHeight = textRetentionTime.Location.Y + textRetentionTime.Height + vmargin;
                    heightDelta = groupBoxOptionalValues.Height - newHeight;
                    groupBoxOptionalValues.Height = newHeight;
                }
            }
            else
            {
                ResultExplicitTransitionGroupValues = new ExplicitTransitionGroupValues(explicitAttributes);
            }

            string labelAverage = !defaultCharge.IsEmpty
                ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_m_z_
                : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_mass_;
            string labelMono = !defaultCharge.IsEmpty
                ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_m_z_
                : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_mass_;
            var defaultFormula = molecule == null ? string.Empty : molecule.Formula;
            var transition     = initialId as Transition;

            FormulaBox.EditMode editMode;
            if (enableAdductEditing && !enableFormulaEditing)
            {
                editMode = FormulaBox.EditMode.adduct_only;
            }
            else if (!enableAdductEditing && enableFormulaEditing)
            {
                editMode = FormulaBox.EditMode.formula_only;
            }
            else
            {
                editMode = FormulaBox.EditMode.formula_and_adduct;
            }
            string formulaBoxLabel;

            if (defaultCharge.IsEmpty)
            {
                formulaBoxLabel = Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_Chemi_cal_formula_;
            }
            else if (editMode == FormulaBox.EditMode.adduct_only)
            {
                var prompt = defaultFormula;
                if (string.IsNullOrEmpty(defaultFormula) && molecule != null)
                {
                    // Defined by mass only
                    prompt = molecule.ToString();
                }
                formulaBoxLabel = string.Format(Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_Addu_ct_for__0__,
                                                prompt);
            }
            else
            {
                formulaBoxLabel = Resources.EditMeasuredIonDlg_EditMeasuredIonDlg_Ion__chemical_formula_;
            }

            double?averageMass = null;
            double?monoMass    = null;

            if (transition != null && string.IsNullOrEmpty(defaultFormula) && transition.IsCustom())
            {
                averageMass = transition.CustomIon.AverageMass;
                monoMass    = transition.CustomIon.MonoisotopicMass;
            }
            else if (molecule != null)
            {
                averageMass = molecule.AverageMass;
                monoMass    = molecule.MonoisotopicMass;
            }

            _formulaBox =
                new FormulaBox(false, // Not proteomic, so offer Cl and Br in atoms popup
                               formulaBoxLabel,
                               labelAverage,
                               labelMono,
                               defaultCharge,
                               editMode,
                               suggestOnlyAdductsWithMass)
            {
                NeutralFormula = defaultFormula,
                AverageMass    = averageMass,
                MonoMass       = monoMass,
                Location       = new Point(textName.Left, textName.Bottom + 12)
            };
            _formulaBox.ChargeChange += (sender, args) =>
            {
                if (!_formulaBox.Adduct.IsEmpty)
                {
                    Adduct = _formulaBox.Adduct;
                    var revisedFormula = _formulaBox.NeutralFormula + Adduct.AdductFormula;
                    if (!Equals(revisedFormula, _formulaBox.Formula))
                    {
                        _formulaBox.Formula = revisedFormula;
                    }
                    if (string.IsNullOrEmpty(_formulaBox.NeutralFormula) && averageMass.HasValue)
                    {
                        _formulaBox.AverageMass = averageMass;
                        _formulaBox.MonoMass    = monoMass;
                    }
                }
            };
            Controls.Add(_formulaBox);
            _formulaBox.TabIndex = 2;
            _formulaBox.Enabled  = enableFormulaEditing || enableAdductEditing;
            Adduct = defaultCharge;
            var needCharge = !Adduct.IsEmpty;

            textCharge.Visible = labelCharge.Visible = needCharge;
            if (needOptionalValuesBox && !needCharge)
            {
                heightDelta += groupBoxOptionalValues.Location.Y - labelCharge.Location.Y;
                groupBoxOptionalValues.Location = new Point(groupBoxOptionalValues.Location.X, labelCharge.Location.Y);
            }
            if (explicitRetentionTime == null)
            {
                // Don't ask user for retetention times
                RetentionTime                    = null;
                RetentionTimeWindow              = null;
                labelRetentionTime.Visible       = false;
                labelRetentionTimeWindow.Visible = false;
                textRetentionTime.Visible        = false;
                textRetentionTimeWindow.Visible  = false;
                if (needOptionalValuesBox)
                {
                    var rtHeight = labelCollisionEnergy.Location.Y - labelRetentionTimeWindow.Location.Y;
                    groupBoxOptionalValues.Height -= rtHeight;
                    heightDelta += rtHeight;
                }
            }
            else
            {
                RetentionTime       = explicitRetentionTime.RetentionTime;
                RetentionTimeWindow = explicitRetentionTime.RetentionTimeWindow;
            }
            if (!needOptionalValuesBox)
            {
                groupBoxOptionalValues.Visible = false;
                heightDelta = groupBoxOptionalValues.Height;
            }
            // Initialize label
            if (settings != null && defaultIsotopeLabelType != null)
            {
                _driverLabelType = new PeptideSettingsUI.LabelTypeComboDriver(comboIsotopeLabelType,
                                                                              settings.PeptideSettings.Modifications, null, null, null, null)
                {
                    SelectedName = defaultIsotopeLabelType.Name
                };
            }
            else
            {
                comboIsotopeLabelType.Visible = false;
                labelIsotopeLabelType.Visible = false;
            }
            Height -= heightDelta;
        }
Esempio n. 39
0
 public bool DoStartupAction(SkylineWindow skylineWindow)
 {
     if (skylineWindow.Visible)
     {
         LongWaitDlgAction(skylineWindow);
     }
     else
     {
         skylineWindow.Shown += (sender, eventArgs) => LongWaitDlgAction(skylineWindow);
     }
     return true;
 }
Esempio n. 40
0
        protected override void DoTest()
        {
            // p. 1 open the file
            string documentFile = GetTestPath(@"QuaSAR_Tutorial.sky"); // Not L10N

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

            var document = SkylineWindow.Document;

            AssertEx.IsDocumentState(document, null, 34, 125, 250, 750);

            var configureToolsDlg = ShowDialog <ConfigureToolsDlg>(SkylineWindow.ShowConfigureToolsDlg);

            RunUI(() =>
            {
                configureToolsDlg.RemoveAllTools();
                configureToolsDlg.SaveTools();
            });

            PauseForScreenShot("p. 2 - External Tools");

            const string installZipName = "QuaSAR-1_0.zip"; // Not L10N

            if (IsPauseForScreenShots)
            {
                var rInstaller = ShowDialog <RInstaller>(() =>
                {
                    configureToolsDlg.RemoveAllTools();
                    configureToolsDlg.SaveTools();
                    configureToolsDlg.InstallZipTool(GetTestPath(installZipName));
                });

                PauseForScreenShot("p. 3 - R Installer");

                // cancel as we don't actually want to install R / Packages
                OkDialog(rInstaller, rInstaller.CancelButton.PerformClick);
            }

            RunUI(() =>
            {
                // bypass the R installer dialogue
                configureToolsDlg.TestInstallProgram = (container, collection, script) => @"FakeDirectory\R.exe";     // Not L10N

                configureToolsDlg.InstallZipTool(GetTestPath(installZipName));
                var installedQuaSAR = configureToolsDlg.ToolList[0];
                Assert.AreEqual(QUASAR.Title, installedQuaSAR.Title);
                Assert.AreEqual(QUASAR.Command, installedQuaSAR.Command);
                Assert.AreEqual(QUASAR.Arguments, installedQuaSAR.Arguments);
                Assert.AreEqual(QUASAR.InitialDirectory, installedQuaSAR.InitialDirectory);
                Assert.AreEqual(QUASAR.ReportTitle, installedQuaSAR.ReportTitle);
                Assert.AreEqual(QUASAR.OutputToImmediateWindow, installedQuaSAR.OutputToImmediateWindow);
            });

            PauseForScreenShot("p. 4 - External Tools (QuaSAR Installed)");

            OkDialog(configureToolsDlg, configureToolsDlg.OkDialog);
            RunUI(() => SkylineWindow.PopulateToolsMenu());

            var annotationsDlg = ShowDialog <DocumentSettingsDlg>(SkylineWindow.ShowDocumentSettingsDialog);

            RunUI(() =>
            {
                var checkedListBox = annotationsDlg.AnnotationsCheckedListBox;
                for (int i = 0; i < checkedListBox.Items.Count; i++)
                {
                    checkedListBox.SetItemChecked(i, true);
                }
            });

            PauseForScreenShot("p. 5 - Annotation Settings");

            OkDialog(annotationsDlg, annotationsDlg.OkDialog);

            RunUI(() =>
            {
                Assert.IsTrue(SkylineWindow.Document.Settings.DataSettings.AnnotationDefs.Contains(SAMPLEGROUP));
                Assert.IsTrue(SkylineWindow.Document.Settings.DataSettings.AnnotationDefs.Contains(IS_SPIKE));
                Assert.IsTrue(SkylineWindow.Document.Settings.DataSettings.AnnotationDefs.Contains(CONCENTRATION));
            });

            RunUI(() => SkylineWindow.ShowResultsGrid(true));
            RunUI(() =>
            {
                SkylineWindow.SelectedPath =
                    SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.MoleculeGroups, 0);
            });
            WaitForGraphs();
            DataGridViewColumn colSampleId = null, colConcentration = null, colIsConc = null;
            var resultsGrid = FindOpenForm <LiveResultsGrid>().DataGridView;

            WaitForConditionUI(() => 0 != resultsGrid.ColumnCount);
            RunUI(() =>
            {
                colSampleId =
                    resultsGrid.Columns.Cast <DataGridViewColumn>()
                    .First(col => SAMPLEGROUP.Name == col.HeaderText);
                colConcentration =
                    resultsGrid.Columns.Cast <DataGridViewColumn>()
                    .First(col => CONCENTRATION.Name == col.HeaderText);
                colIsConc =
                    resultsGrid.Columns.Cast <DataGridViewColumn>().First(col => IS_SPIKE.Name == col.HeaderText);
            });
            WaitForCondition(() => resultsGrid != null && colSampleId != null && colConcentration != null && colIsConc != null);

            float[]  concentrations = { 0f, .001f, .004f, .018f, .075f, .316f, 1.33f, 5.62f, 23.71f, 100 };
            string[] sampleIds      = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" }; // Not L10N

            var docBeforePaste = SkylineWindow.Document;

            RunUI(() =>
            {
                Assert.AreEqual(colSampleId.DisplayIndex + 1, colConcentration.DisplayIndex);
                Assert.AreEqual(colSampleId.DisplayIndex + 1, colConcentration.DisplayIndex);
                StringBuilder clipboardText = new StringBuilder();
                for (int i = 0; i < concentrations.Length; i++)
                {
                    for (int j = i * 4; j < (i + 1) * 4; j++)
                    {
                        if (clipboardText.Length > 0)
                        {
                            clipboardText.Append('\n');
                        }
                        clipboardText.Append(sampleIds[i]);
                        clipboardText.Append('\t');
                        clipboardText.Append(concentrations[i]);
                        clipboardText.Append('\t');
                        clipboardText.Append(10);
                    }
                }
                resultsGrid.CurrentCell = resultsGrid.Rows[0].Cells[colSampleId.Index];
                ClipboardEx.SetText(clipboardText.ToString());
                resultsGrid.SendPaste();
            });
            WaitForDocumentChange(docBeforePaste);
            WaitForGraphs();
            PauseForScreenShot("p. 7 - Results Grid");

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

            if (IsPauseForScreenShots)
            {
                int formCount = Application.OpenForms.Count;
                RunUI(() => SkylineWindow.RunTool(0));
                WaitForCondition(() => Application.OpenForms.Count == formCount + 1);
                Form argsCollector = Application.OpenForms["QuaSARUI"]; // Not L10N
                Assert.IsNotNull(argsCollector);
                PauseForScreenShot("p. 8 - Args Collector");

                Action actCancel = () => argsCollector.CancelButton.PerformClick();
                argsCollector.BeginInvoke(actCancel);
                WaitForClosedForm(argsCollector);
            }
        }
        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";
                    if (AsSmallMolecules)
                    {
                        transitionSettingsUI.FragmentTypes += ", custom";
                    }
                });
                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);
                if (AsSmallMolecules)
                {
                    Assert.IsTrue(ArrayUtil.EqualsDeep(new[] { IonType.y, IonType.b, IonType.precursor, IonType.custom },
                                                       tranSettingsFullScan.Filter.IonTypes));
                }
                else
                {
                    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);

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

            RunUI(ambiguousDlg.OkDialog);
            doc = WaitForDocumentChange(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.
            RunUI(() => Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.chromatograms_page));
            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

            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());
        }
 /// <summary>
 /// Attaches a DataGridViewPasteHandler to the specified DataGridView.
 /// </summary>
 public static DataGridViewPasteHandler Attach(SkylineWindow skylineWindow, DataGridView dataGridView)
 {
     return new DataGridViewPasteHandler(skylineWindow, dataGridView);
 }
Esempio n. 43
0
        public void DoAction(StartupAction action)
        {
            Action = action;

            var window = Owner as SkylineWindow;
            if (window == null)
            {
                MainWindow = new SkylineWindow();
                if (!action(MainWindow))
                {
                    return;
                }
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 44
0
 protected override void OnHandleDestroyed(EventArgs e)
 {
     if (_skylineWindow != null)
     {
         _skylineWindow.SequenceTree.AfterSelect -= SequenceTreeOnAfterSelect;
         _skylineWindow = null;
     }
     base.OnHandleDestroyed(e);
 }
Esempio n. 45
0
        /// <summary>
        /// For creating at the Molecule level (create molecule and first transition group) or modifying at the transition level
        /// Null values imply "don't ask user for this"
        /// </summary>
        public EditCustomMoleculeDlg(SkylineWindow parent, string title, Identity initialId, IEnumerable<Identity> existingIds, int minCharge, int maxCharge,
            SrmSettings settings, string defaultName, string defaultFormula, int? defaultCharge, ExplicitTransitionGroupValues explicitAttributes,
            ExplicitRetentionTimeInfo explicitRetentionTime,
            IsotopeLabelType defaultIsotopeLabelType, bool enableFormulaEditing = true)
        {
            Text = title;
            _parent = parent;
            _initialId = initialId;
            _existingIds = existingIds;
            _minCharge = minCharge;
            _maxCharge = maxCharge;
            _transitionSettings = settings != null ? settings.TransitionSettings : null;
            _peptideSettings = settings != null ? settings.PeptideSettings : null;

            InitializeComponent();

            NameText = defaultName;
            var needOptionalValuesBox = explicitRetentionTime != null || explicitAttributes != null;
            var heightDelta = 0;

            if (explicitAttributes == null)
            {
                ResultExplicitTransitionGroupValues = null;
                labelCollisionEnergy.Visible = false;
                textCollisionEnergy.Visible = false;
                labelSLens.Visible = false;
                textSLens.Visible = false;
                labelCompensationVoltage.Visible = false;
                textCompensationVoltage.Visible = false;
                labelConeVoltage.Visible = false;
                textConeVoltage.Visible = false;
                labelDriftTimeHighEnergyOffsetMsec.Visible = false;
                textDriftTimeHighEnergyOffsetMsec.Visible = false;
                labelDriftTimeMsec.Visible = false;
                textDriftTimeMsec.Visible = false;
                if (needOptionalValuesBox)
                {
                    // We blanked out everything but the retention time
                    var vmargin = labelRetentionTime.Location.Y;
                    var newHeight = textRetentionTime.Location.Y + textRetentionTime.Height +  vmargin;
                    heightDelta = groupBoxOptionalValues.Height - newHeight;
                    groupBoxOptionalValues.Height = newHeight;
                }
            }
            else
            {
                ResultExplicitTransitionGroupValues = new ExplicitTransitionGroupValues(explicitAttributes);
            }

            string labelAverage = defaultCharge.HasValue
                ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_m_z_
                : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg_A_verage_mass_;
            string labelMono = defaultCharge.HasValue
                ? Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_m_z_
                : Resources.EditCustomMoleculeDlg_EditCustomMoleculeDlg__Monoisotopic_mass_;

            _formulaBox =
                new FormulaBox(Resources.EditMeasuredIonDlg_EditMeasuredIonDlg_Ion__chemical_formula_,
                    labelAverage,
                    labelMono,
                    defaultCharge)
                {
                    Formula = defaultFormula,
                    Location = new Point(textName.Left, textName.Bottom + 12)
                };
            Controls.Add(_formulaBox);
            _formulaBox.TabIndex = 2;
            _formulaBox.Enabled = enableFormulaEditing;
            bool needCharge = defaultCharge.HasValue;
            textCharge.Visible = labelCharge.Visible = needCharge;
            Charge = defaultCharge ?? 0;
            if (needOptionalValuesBox && !needCharge)
            {
                heightDelta += groupBoxOptionalValues.Location.Y - labelCharge.Location.Y;
                groupBoxOptionalValues.Location = new Point(groupBoxOptionalValues.Location.X, labelCharge.Location.Y);
            }
            if (explicitRetentionTime == null)
            {
                // Don't ask user for retetention times
                RetentionTime = null;
                RetentionTimeWindow = null;
                labelRetentionTime.Visible = false;
                labelRetentionTimeWindow.Visible = false;
                textRetentionTime.Visible = false;
                textRetentionTimeWindow.Visible = false;
                if (needOptionalValuesBox)
                {
                    var rtHeight = labelCollisionEnergy.Location.Y - labelRetentionTimeWindow.Location.Y;
                    groupBoxOptionalValues.Height -= rtHeight;
                    heightDelta += rtHeight;
                }
            }
            else
            {
                RetentionTime = explicitRetentionTime.RetentionTime;
                RetentionTimeWindow = explicitRetentionTime.RetentionTimeWindow;
            }
            if (!needOptionalValuesBox)
            {
                groupBoxOptionalValues.Visible = false;
                heightDelta = groupBoxOptionalValues.Height;
            }
            // Initialize label
            if (settings != null && defaultIsotopeLabelType != null)
            {
                _driverLabelType = new PeptideSettingsUI.LabelTypeComboDriver(comboIsotopeLabelType,
                    settings.PeptideSettings.Modifications, null, null, null, null)
                {
                    SelectedName = defaultIsotopeLabelType.Name
                };
            }
            else
            {
                comboIsotopeLabelType.Visible = false;
                labelIsotopeLabelType.Visible = false;
            }
            Height -= heightDelta;
        }
Esempio n. 46
0
        protected void DoResultsGridView()
        {
            // Results Grid View
            RestoreViewOnScreen(26);
            PauseForScreenShot(SkylineWindow, "Main window under floating windows", 26);
            RestoreViewOnScreen(27);
            PauseForScreenShot(SkylineWindow, "Main window layout", 27);

            // Not understood: WaitForOpenForm occasionally hangs in nightly test runs. Fixed it by calling
            // ShowDialog when LiveResultsGrid cannot be found.
            //var resultsGridForm = WaitForOpenForm<LiveResultsGrid>();
            var resultsGridForm = FindOpenForm <LiveResultsGrid>() ??
                                  ShowDialog <LiveResultsGrid>(() => SkylineWindow.ShowResultsGrid(true));
            BoundDataGridView resultsGrid = null;

            RunUI(() =>
            {
                resultsGrid = resultsGridForm.DataGridView;
                SkylineWindow.AutoZoomBestPeak();
                SkylineWindow.SelectedPath = ((SrmTreeNode)SkylineWindow.SequenceTree.SelectedNode.Nodes[0]).Path;
            });
            WaitForGraphs();

            RunUI(() =>
            {
                var precursorNoteColumn =
                    resultsGrid.Columns.Cast <DataGridViewColumn>()
                    .First(col => GetLocalizedCaption("PrecursorReplicateNote") == col.HeaderText);
                resultsGrid.CurrentCell = resultsGrid.Rows[0].Cells[precursorNoteColumn.Index];
                resultsGrid.BeginEdit(true);
                // ReSharper disable LocalizableElement
                resultsGrid.EditingControl.Text = "Low signal";   // Not L10N
                // ReSharper restore LocalizableElement
                resultsGrid.EndEdit();
                resultsGrid.CurrentCell = resultsGrid.Rows[1].Cells[resultsGrid.CurrentCell.ColumnIndex];
            });
            WaitForGraphs();
            RunUI(() => SkylineWindow.SelectedResultsIndex = 1);
            WaitForGraphs();
            PauseForScreenShot <LiveResultsGrid>("Results Grid view subsection", 28);

            RunDlg <ViewEditor>(resultsGridForm.NavBar.CustomizeView, resultsGridViewEditor =>
            {
                // TODO: Update tutorial instructions with new name.
                resultsGridViewEditor.ViewName = "NewResultsGridView";
                var chooseColumnTab            = resultsGridViewEditor.ChooseColumnsTab;
                foreach (
                    var column in
                    new[]
                {
                    PropertyPath.Parse("MinStartTime"), PropertyPath.Parse("MaxEndTime"),
                    PropertyPath.Parse("LibraryDotProduct"), PropertyPath.Parse("TotalBackground"),
                    PropertyPath.Parse("TotalAreaRatio")
                })
                {
                    Assert.IsTrue(chooseColumnTab.ColumnNames.Contains(GetLocalizedCaption(column.Name)));
                    Assert.IsTrue(chooseColumnTab.TrySelect(column), "Unable to select {0}", column);
                    chooseColumnTab.RemoveColumn(column);
                    Assert.IsFalse(chooseColumnTab.ColumnNames.Contains(GetLocalizedCaption(column.Name)));
                }
                resultsGridViewEditor.OkDialog();
            });

            RunUI(() => SkylineWindow.SelectedNode.Expand());

            // Custom Annotations, p. 25
            var chooseAnnotationsDlg = ShowDialog <DocumentSettingsDlg>(SkylineWindow.ShowDocumentSettingsDialog);
            var editListDlg          = ShowDialog <EditListDlg <SettingsListBase <AnnotationDef>, AnnotationDef> >(chooseAnnotationsDlg.EditAnnotationList);
            var defineAnnotationDlg  = ShowDialog <DefineAnnotationDlg>(editListDlg.AddItem);

            RunUI(() =>
            {
                defineAnnotationDlg.AnnotationName    = "Tailing"; // Not L10N
                defineAnnotationDlg.AnnotationType    = AnnotationDef.AnnotationType.true_false;
                defineAnnotationDlg.AnnotationTargets = AnnotationDef.AnnotationTargetSet.Singleton(AnnotationDef.AnnotationTarget.precursor_result);
            });
            PauseForScreenShot <DefineAnnotationDlg>("Define Annotation form", 29);

            OkDialog(defineAnnotationDlg, defineAnnotationDlg.OkDialog);
            OkDialog(editListDlg, editListDlg.OkDialog);
            RunUI(() => chooseAnnotationsDlg.AnnotationsCheckedListBox.SetItemChecked(0, true));
            PauseForScreenShot <DocumentSettingsDlg>("Annotation Settings form", 30);

            OkDialog(chooseAnnotationsDlg, chooseAnnotationsDlg.OkDialog);

            FindNode((564.7746).ToString(LocalizationHelper.CurrentCulture) + "++");
            var        liveResultsGrid = FindOpenForm <LiveResultsGrid>();
            ViewEditor viewEditor      = ShowDialog <ViewEditor>(liveResultsGrid.NavBar.CustomizeView);

            RunUI(() =>
            {
                viewEditor.ChooseColumnsTab.ActivateColumn(2);
                Assert.IsTrue(viewEditor.ChooseColumnsTab.TrySelect(
                                  PropertyPath.Root.Property(AnnotationDef.ANNOTATION_PREFIX + "Tailing")));
                viewEditor.ChooseColumnsTab.AddSelectedColumn();
            });
            PauseForScreenShot <ViewEditor.ChooseColumnsView>("Customize Report form showing Tailing annotation checked", 31);
            OkDialog(viewEditor, viewEditor.OkDialog);
            PauseForScreenShot(SkylineWindow, "Main window with Tailing column added to Results Grid", 32);
        }
Esempio n. 47
0
        public ToolUpdatesDlg(SkylineWindow parent, IEnumerable<ToolDescription> tools, IToolUpdateHelper updateHelper)
        {
            InitializeComponent();

            checkedListBoxTools.Height += labelOperation.Bottom - checkedListBoxTools.Bottom;
            Icon = Resources.Skyline;

            _parent = parent;
            _tools = new Dictionary<ToolUpdateInfo, ICollection<ToolDescription>>();
            _updateHelper = updateHelper;

            // group tools with multiple components together by their package identifier
            foreach (var tool in tools)
            {
                var info = new ToolUpdateInfo(tool.PackageIdentifier, tool.PackageName);
                ICollection<ToolDescription> toolComponents;
                if (_tools.TryGetValue(info, out toolComponents))
                {
                    toolComponents.Add(tool);
                }
                else
                {
                    _tools.Add(info, new List<ToolDescription> {tool});
                }
            }

            // populate the checklistbox with the tools package names
            checkedListBoxTools.Items.AddRange(_tools.Select(pair => pair.Key._packageName).Cast<Object>().ToArray());

            // set all tools to checked
            for (int i = 0; i < checkedListBoxTools.Items.Count; i++)
            {
                checkedListBoxTools.SetItemCheckState(i, CheckState.Checked);
            }
        }
Esempio n. 48
0
        public ImportPeptideSearchDlg(SkylineWindow skylineWindow, LibraryManager libraryManager)
        {
            SkylineWindow = skylineWindow;
            _documents    = new Stack <SrmDocument>();
            SetDocument(skylineWindow.Document, null);

            ImportPeptideSearch = new ImportPeptideSearch();

            InitializeComponent();

            Icon = Resources.Skyline;

            btnEarlyFinish.Location = btnBack.Location;

            CurrentPage     = Pages.spectra_page;
            btnNext.Text    = Resources.ImportPeptideSearchDlg_ImportPeptideSearchDlg_Next;
            AcceptButton    = btnNext;
            btnNext.Enabled = HasUnmatchedLibraryRuns(Document);

            // Create and add wizard pages
            BuildPepSearchLibControl = new BuildPeptideSearchLibraryControl(this, ImportPeptideSearch, libraryManager)
            {
                Dock = DockStyle.Fill,
            };
            BuildPepSearchLibControl.InputFilesChanged += BuildPepSearchLibForm_OnInputFilesChanged;

            buildLibraryPanel.Controls.Add(BuildPepSearchLibControl);

            ImportFastaControl = new ImportFastaControl(this, SkylineWindow.SequenceTree)
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                Location = new Point(2, 60)
            };
            importFastaPage.Controls.Add(ImportFastaControl);

            MatchModificationsControl = new MatchModificationsControl(this, ImportPeptideSearch)
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                Location = new Point(2, 60)
            };
            matchModificationsPage.Controls.Add(MatchModificationsControl);

            TransitionSettingsControl = new TransitionSettingsControl(this)
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                Location = new Point(18, 60)
            };
            transitionSettingsUiPage.Controls.Add(TransitionSettingsControl);

            FullScanSettingsControl = new FullScanSettingsControl(this)
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                Location = new Point(18, 50)
            };
            ms1FullScanSettingsPage.Controls.Add(FullScanSettingsControl);
            FullScanSettingsControl.FullScanEnabledChanged += OnFullScanEnabledChanged; // Adjusts ion settings when full scan settings change

            ImportResultsControl = new ImportResultsControl(ImportPeptideSearch, DocumentFilePath)
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                Location = new Point(2, 60)
            };
            getChromatogramsPage.Controls.Add((Control)ImportResultsControl);

            _pagesToSkip = new HashSet <Pages>();
        }
Esempio n. 49
0
        protected override void DoTest()
        {
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("CE_Vantage_15mTorr_scheduled_mini_withMod.sky")));
            WaitForGraphs();

            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;

                // Test single node copy.
                sequenceTree.ExpandAll();
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0];
                SkylineWindow.Copy();
                CheckCopiedNodes(0, 1);

                // Test multiple selection copy.
                sequenceTree.KeysOverride = Keys.Shift;
                sequenceTree.SelectedNode = sequenceTree.Nodes[1];
                SkylineWindow.Copy();

                // Test multiple selection disjoint, reverse order copy.
                CheckCopiedNodes(0, 1);
                Assert.AreSame(sequenceTree, SkylineWindow.SequenceTree);
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode = sequenceTree.Nodes[1].Nodes[0];
                sequenceTree.KeysOverride = Keys.Control;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0];
                SkylineWindow.Copy();
                // After copying in reverse order, reselect the nodes in sorted order so we don't have to
                // sort them in the test code.
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0];
                sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0];
                sequenceTree.KeysOverride = Keys.Control;
                sequenceTree.SelectedNode = sequenceTree.Nodes[1].Nodes[0];
                Assert.AreSame(sequenceTree, SkylineWindow.SequenceTree);
                CheckCopiedNodes(1, 2);

                // Test no space between parent and descendents if immediate child is not selected.
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0];
                sequenceTree.KeysOverride = Keys.Control;
                sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0].Nodes[0].Nodes[0];
                sequenceTree.SelectedNode = sequenceTree.Nodes[0].Nodes[0].Nodes[0].Nodes[2];
                SkylineWindow.Copy();
                CheckCopiedNodes(0, 1);

                // Test paste menu item enabled, copy menu item disabled when dummy node is selected.
                sequenceTree.KeysOverride = Keys.None;
                sequenceTree.SelectedNode =
                    sequenceTree.Nodes[SkylineWindow.SequenceTree.Nodes.Count - 1];
                Assert.IsFalse(SkylineWindow.CopyMenuItemEnabled(), "Copy menu should not be enabled");
                Assert.IsTrue(SkylineWindow.PasteMenuItemEnabled());

                // Test FASTA sequence copy HTML formatting
                sequenceTree.SelectedNode = sequenceTree.Nodes[0];
                SkylineWindow.Copy();
                string clipboardHtml = GetClipboardHtml();
                Assert.AreEqual(4, Regex.Matches(clipboardHtml, "<font style=\"font-weight: bold").Count);
                Assert.AreEqual(4, Regex.Matches(clipboardHtml, "</font>").Count);
                Assert.AreEqual(1, Regex.Matches(clipboardHtml, "color: blue").Count);

                sequenceTree.SelectedNode = sequenceTree.Nodes[1];
                SkylineWindow.Copy();
                clipboardHtml = GetClipboardHtml();
                Assert.AreEqual(19, Regex.Matches(clipboardHtml, "<font style=\"font-weight: bold").Count);
                Assert.AreEqual(19, Regex.Matches(clipboardHtml, "</font>").Count);
                Assert.AreEqual(2, Regex.Matches(clipboardHtml, "color: blue").Count);

                sequenceTree.SelectedNode = sequenceTree.Nodes[2];
                SkylineWindow.Copy();
                clipboardHtml = GetClipboardHtml();
                Assert.AreEqual(18, Regex.Matches(clipboardHtml, "<font style=\"font-weight: bold").Count);
                Assert.AreEqual(18, Regex.Matches(clipboardHtml, "</font>").Count);
                Assert.AreEqual(2, Regex.Matches(clipboardHtml, "color: blue").Count);

                // Test clipboard HTML contains formatting for modified peptides.
                sequenceTree.SelectedNode = sequenceTree.Nodes[3].Nodes[0];
                SkylineWindow.Copy();
                clipboardHtml = GetClipboardHtml();
                Assert.IsTrue(clipboardHtml.Contains("font") && clipboardHtml.Contains("color"));
            });

            // Paste a protein list
            var document = WaitForDocumentLoaded();

            RunUI(() =>
            {
                SetClipboardText(PROTEINLIST_CLIPBOARD_TEXT);
                SkylineWindow.Paste();
            });
            var docPaste = WaitForDocumentChange(document);

            Assert.AreEqual(document.PeptideGroupCount + 3, docPaste.PeptideGroupCount);
            Assert.AreEqual("P23978", docPaste.PeptideGroups.Last().ProteinMetadata.Accession);  // Did builtin IPI conversion work?

            // Paste an invalid protein list
            RunDlg <MessageDlg>(() =>
            {
                SetClipboardText(PROTEINLIST_CLIPBOARD_TEXT.Replace("MDAL", "***"));
                SkylineWindow.Paste();
            },
                                msgDlg => msgDlg.OkDialog());
            Assert.AreSame(docPaste, WaitForProteinMetadataBackgroundLoaderCompletedUI());

            // Test border case where protein/peptide/transition list contains a blank line
            // Should give generic error, not crash
            RunDlg <MessageDlg>(() =>
            {
                SetClipboardText(PROTEIN_LIST_BAD_FORMAT);
                SkylineWindow.Paste();
            },
                                msgDlg =>
            {
                Assert.AreEqual(msgDlg.Message, Resources.CopyPasteTest_DoTest_Could_not_read_the_pasted_transition_list___Transition_list_must_be_in_separated_columns_and_cannot_contain_blank_lines_);
                msgDlg.OkDialog();
            });

            // Paste peptides
            var precursorAdduct = Adduct.DOUBLY_PROTONATED;
            List <Tuple <string, int> > peptidePaste = new List <Tuple <string, int> >
            {
                new Tuple <string, int>("FVEGLPINDFSR", 3),
                new Tuple <string, int>("FVEGLPINDFSR", 2),
                new Tuple <string, int>("FVEGLPINDFSR", 0),
                new Tuple <string, int>("DLNELQALIEAHFENR", 0),
                new Tuple <string, int>(string.Format("C[+{0:F01}]QPLELAGLGFAELQDLC[+{1:F01}]R", 57.0, 57.0), 3),
                new Tuple <string, int>("PEPTIDER", 5),
                new Tuple <string, int>("PEPTIDER", 15)
            };
            var peptidePasteSb = new StringBuilder();

            foreach (var pep in peptidePaste)
            {
                peptidePasteSb.AppendLine(pep.Item1 + Transition.GetChargeIndicator(Adduct.FromChargeProtonated(pep.Item2)));
            }

            RunUI(() =>
            {
                SkylineWindow.NewDocument(true);
                document = SkylineWindow.Document;
                document = document.ChangeSettings(document.Settings.ChangeTransitionFilter(f => f.ChangePeptidePrecursorCharges(new[] { precursorAdduct })));
                SetClipboardText(peptidePasteSb.ToString());
                SkylineWindow.Paste();
            });
            document = WaitForDocumentChange(document);
            Assert.AreEqual(peptidePaste.Count, document.PeptideTransitionGroupCount);
            for (int i = 0; i < document.PeptideTransitionGroupCount; i++)
            {
                TransitionGroupDocNode transition = document.PeptideTransitionGroups.ElementAt(i);
                string seq    = transition.TransitionGroup.Peptide.Sequence;
                var    charge = transition.PrecursorAdduct.AdductCharge;
                Assert.AreEqual(FastaSequence.StripModifications(peptidePaste[i].Item1), seq);
                var pastedCharge = peptidePaste[i].Item2;
                Assert.AreEqual(pastedCharge != 0 ? pastedCharge : precursorAdduct.AdductCharge, charge);
            }

            // Undo paste
            RunUI(() => SkylineWindow.Undo());
            document = WaitForDocumentChange(document);
            // Change precursor charges
            Adduct[] precursorCharges = { Adduct.DOUBLY_PROTONATED, Adduct.TRIPLY_PROTONATED, Adduct.QUADRUPLY_PROTONATED };
            RunUI(() => SkylineWindow.ModifyDocument("Change precursor charges", doc => doc.ChangeSettings((document.Settings.ChangeTransitionFilter(f => f.ChangePeptidePrecursorCharges(precursorCharges))))));
            document = WaitForDocumentChange(document);
            // Re-paste in peptides
            RunUI(() => SkylineWindow.Paste());
            document = WaitForDocumentChange(document);
            int curTransitionGroup = 0;

            foreach (var peptide in peptidePaste)
            {
                if (peptide.Item2 > 0)
                {
                    // Pasted peptides with a charge indicator should have a single precursor with the specified charge state
                    TransitionGroupDocNode group = document.PeptideTransitionGroups.ElementAt(curTransitionGroup++);
                    string seq    = group.TransitionGroup.Peptide.Sequence;
                    var    charge = group.PrecursorAdduct.AdductCharge;
                    Assert.AreEqual(FastaSequence.StripModifications(peptide.Item1), seq);
                    var pastedCharge = peptide.Item2;
                    Assert.AreEqual(pastedCharge, charge);
                }
                else
                {
                    // Pasted peptides with no charge indicator should have a precursor for every charge state in transition filter settings
                    for (int j = 0; j < precursorCharges.Length; j++)
                    {
                        TransitionGroupDocNode group = document.PeptideTransitionGroups.ElementAt(curTransitionGroup++);
                        string seq    = group.TransitionGroup.Peptide.Sequence;
                        var    charge = group.PrecursorAdduct;
                        Assert.AreEqual(FastaSequence.StripModifications(peptide.Item1), seq);
                        Assert.AreEqual(precursorCharges[j], charge);
                    }
                }
            }
            Assert.AreEqual(curTransitionGroup, document.PeptideTransitionGroupCount);
        }
Esempio n. 50
0
        /// <summary>
        /// Test the use of Molecule List Names as "Proteins" in .blib export/import
        /// They should round trip, resulting in a document with the same Molecule List names
        /// as the one that generate the spectral library
        /// </summary>
        protected override void DoTest()
        {
            // Export and check spectral library
            RunUI(() => SkylineWindow.OpenFile(TestFilesDir.GetTestPath("MoleculeGroups.sky")));
            var docOrig          = WaitForDocumentLoaded();
            var moleculeLists    = docOrig.MoleculeGroups.Select(g => g.Name).ToHashSet(); // Note the list names
            var exported         = "MolListsTest";
            var exportedBlib     = exported + BiblioSpecLiteSpec.EXT;
            var exporteDFullPath = TestFilesDir.GetTestPath(exportedBlib);
            var libraryExporter  = new SpectralLibraryExporter(SkylineWindow.Document, SkylineWindow.DocumentFilePath);

            libraryExporter.ExportSpectralLibrary(exporteDFullPath, null);
            Assert.IsTrue(File.Exists(exporteDFullPath));

            // Now import the .blib and populate document from that
            RunUI(() => SkylineWindow.NewDocument(true));

            var peptideSettingsUI = ShowDialog <PeptideSettingsUI>(SkylineWindow.ShowPeptideSettingsUI);

            Assert.IsNotNull(peptideSettingsUI);
            var editListUI = ShowDialog <EditListDlg <SettingsListBase <LibrarySpec>, LibrarySpec> >(peptideSettingsUI.EditLibraryList);

            RunDlg <EditLibraryDlg>(editListUI.AddItem, addLibUI =>
            {
                var nameTextBox = (TextBox)addLibUI.Controls.Find("textName", true)[0];
                Assert.IsNotNull(nameTextBox);
                var pathTextBox = (TextBox)addLibUI.Controls.Find("textPath", true)[0];
                Assert.IsNotNull(pathTextBox);
                nameTextBox.Text = exported;
                pathTextBox.Text = exporteDFullPath;
                addLibUI.OkDialog();
            });
            RunUI(editListUI.OkDialog);
            WaitForClosedForm(editListUI);

            // Make sure the libraries actually show up in the peptide settings dialog before continuing.
            WaitForConditionUI(() => peptideSettingsUI.AvailableLibraries.Length > 0);
            RunUI(() => Assert.IsFalse(peptideSettingsUI.IsSettingsChanged));

            // Add all the molecules in the library
            RunUI(() => SkylineWindow.ViewSpectralLibraries());
            var viewLibraryDlg = FindOpenForm <ViewLibraryDlg>();
            var docBefore      = WaitForProteinMetadataBackgroundLoaderCompletedUI();

            RunDlg <MultiButtonMsgDlg>(viewLibraryDlg.AddAllPeptides, messageDlg =>
            {
                var addLibraryMessage =
                    string.Format(Resources.ViewLibraryDlg_CheckLibraryInSettings_The_library__0__is_not_currently_added_to_your_document, exported);
                StringAssert.StartsWith(messageDlg.Message, addLibraryMessage);
                messageDlg.DialogResult = DialogResult.Yes;
            });
            var filterPeptidesDlg = WaitForOpenForm <FilterMatchedPeptidesDlg>();

            RunDlg <MultiButtonMsgDlg>(filterPeptidesDlg.OkDialog, addLibraryPepsDlg =>
            {
                addLibraryPepsDlg.Btn1Click();
            });

            OkDialog(filterPeptidesDlg, filterPeptidesDlg.OkDialog);

            var docAfter = WaitForDocumentChange(docBefore);

            OkDialog(viewLibraryDlg, viewLibraryDlg.Close);
            RunUI(() => peptideSettingsUI.OkDialog());
            WaitForClosedForm(peptideSettingsUI);

            // Expect two molecule lists instead of the old single "Library Molecules" list
            var newMoleculeLists = docAfter.MoleculeGroups.Select(g => g.Name).ToArray();

            AssertEx.AreEqual(2, newMoleculeLists.Length);
            foreach (var name in newMoleculeLists)
            {
                AssertEx.IsTrue(moleculeLists.Contains(name));
            }
        }
        public ImportPeptideSearchDlg(SkylineWindow skylineWindow, LibraryManager libraryManager, Workflow workflowType)
            : this(skylineWindow, libraryManager)
        {
            BuildPepSearchLibControl.ForceWorkflow(workflowType);

            if (workflowType == Workflow.dda)
            {
                int shortHeight = MinimumSize.Height - 110;
                MinimumSize = new Size(MinimumSize.Width, shortHeight);
                Height = shortHeight;
            }
        }
Esempio n. 52
0
        public TransitionSettingsUI(SkylineWindow parent)
        {
            InitializeComponent();

            // Populate the fragment finder combo boxes
            foreach (string item in TransitionFilter.GetStartFragmentFinderLabels())
                comboRangeFrom.Items.Add(item);
            foreach (string item in TransitionFilter.GetEndFragmentFinderLabels())
                comboRangeTo.Items.Add(item);

            _parent = parent;
            _transitionSettings = _parent.DocumentUI.Settings.TransitionSettings;

            // Initialize prediction settings
            comboPrecursorMass.SelectedItem = Prediction.PrecursorMassType.GetLocalizedString();
            comboIonMass.SelectedItem = Prediction.FragmentMassType.GetLocalizedString();

            _driverCE = new SettingsListComboDriver<CollisionEnergyRegression>(comboCollisionEnergy,
                                                                               Settings.Default.CollisionEnergyList);
            string sel = (Prediction.CollisionEnergy == null ? null : Prediction.CollisionEnergy.Name);
            _driverCE.LoadList(sel);

            _driverDP = new SettingsListComboDriver<DeclusteringPotentialRegression>(comboDeclusterPotential,
                                                                                     Settings.Default.DeclusterPotentialList);
            sel = (Prediction.DeclusteringPotential == null ? null : Prediction.DeclusteringPotential.Name);
            _driverDP.LoadList(sel);

            _driverCoV = new SettingsListComboDriver<CompensationVoltageParameters>(comboCompensationVoltage,
                                                                                    Settings.Default.CompensationVoltageList);
            _driverCoV.LoadList(Prediction.CompensationVoltage == null ? null : Prediction.CompensationVoltage.Name);

            _driverOptimizationLibrary = new SettingsListComboDriver<OptimizationLibrary>(comboOptimizationLibrary,
                Settings.Default.OptimizationLibraryList);
            _driverOptimizationLibrary.LoadList(Prediction.OptimizedLibrary == null ? null : Prediction.OptimizedLibrary.Name);

            if (Prediction.OptimizedMethodType == OptimizedMethodType.None)
                comboOptimizeType.SelectedIndex = 0;
            else
            {
                cbUseOptimized.Checked = true;
                comboOptimizeType.SelectedItem = Prediction.OptimizedMethodType.GetLocalizedString();
            }

            // Initialize filter settings
            textPrecursorCharges.Text = Filter.PrecursorCharges.ToArray().ToString(", "); // Not L10N? Internationalization of comma?
            textIonCharges.Text = Filter.ProductCharges.ToArray().ToString(", "); // Not L10N? Internationalization of comma?
            textIonTypes.Text = TransitionFilter.ToStringIonTypes(Filter.IonTypes, true);
            comboRangeFrom.SelectedItem = Filter.FragmentRangeFirst.Label;
            comboRangeTo.SelectedItem = Filter.FragmentRangeLast.Label;
            textExclusionWindow.Text = Filter.PrecursorMzWindow != 0
                                           ? Filter.PrecursorMzWindow.ToString(LocalizationHelper.CurrentCulture)
                                           : string.Empty;
            cbExclusionUseDIAWindow.Checked = Filter.ExclusionUseDIAWindow;
            cbAutoSelect.Checked = Filter.AutoSelect;

            _driverIons = new MeasuredIonListBoxDriver(listAlwaysAdd, Settings.Default.MeasuredIonList);
            _driverIons.LoadList(Filter.MeasuredIons);

            // Initialize library settings
            cbLibraryPick.Checked = (Libraries.Pick != TransitionLibraryPick.none);
            panelPick.Visible = cbLibraryPick.Checked;
            textTolerance.Text = Libraries.IonMatchTolerance.ToString(LocalizationHelper.CurrentCulture);
            textIonCount.Text = Libraries.IonCount.ToString(LocalizationHelper.CurrentCulture);
            if (Libraries.Pick == TransitionLibraryPick.filter)
                radioFiltered.Checked = true;
            else if (Libraries.Pick == TransitionLibraryPick.all_plus)
                radioAllAndFiltered.Checked = true;

            // Initialize instrument settings
            textMinMz.Text = Instrument.MinMz.ToString(LocalizationHelper.CurrentCulture);
            textMaxMz.Text = Instrument.MaxMz.ToString(LocalizationHelper.CurrentCulture);
            cbDynamicMinimum.Checked = Instrument.IsDynamicMin;
            textMzMatchTolerance.Text = Instrument.MzMatchTolerance.ToString(LocalizationHelper.CurrentCulture);
            if (Instrument.MaxTransitions.HasValue)
                textMaxTrans.Text = Instrument.MaxTransitions.Value.ToString(LocalizationHelper.CurrentCulture);
            if (Instrument.MaxInclusions.HasValue)
                textMaxInclusions.Text = Instrument.MaxInclusions.Value.ToString(LocalizationHelper.CurrentCulture);
            if (Instrument.MinTime.HasValue)
                textMinTime.Text = Instrument.MinTime.Value.ToString(LocalizationHelper.CurrentCulture);
            if (Instrument.MaxTime.HasValue)
                textMaxTime.Text = Instrument.MaxTime.Value.ToString(LocalizationHelper.CurrentCulture);

            // Initialize full-scan settings
            FullScanSettingsControl = new FullScanSettingsControl(_parent)
                                          {
                                              Anchor = (AnchorStyles.Top | AnchorStyles.Left),
                                              Location = new Point(0, 0),
                                              Size = new Size(363, 491)
                                          };
            FullScanSettingsControl.IsolationSchemeChangedEvent += IsolationSchemeChanged;
            tabFullScan.Controls.Add(FullScanSettingsControl);

            // VISUAL:
            // - Store the distance between the cbExclusionDIAWindow and the lower end of the box (to use as margin later)
            // - Shift the cbExclusionDIAWindow down (it is only higher in the designer for better manipulation)
            _lower_margin = groupBox1.Height - textExclusionWindow.Location.Y - textExclusionWindow.Height;
            int pixelShift = cbExclusionUseDIAWindow.Location.Y - lbPrecursorMzWindow.Location.Y;
            cbExclusionUseDIAWindow.Location = new Point(cbExclusionUseDIAWindow.Location.X, cbExclusionUseDIAWindow.Location.Y - pixelShift);

            DoIsolationSchemeChanged();
        }
Esempio n. 53
0
        protected override void DoTest()
        {
            var protdbPath = TestFilesDir.GetTestPath(_backgroundProteomeName + ProteomeDb.EXT_PROTDB);

            CreateBackgroundProteome(protdbPath, _backgroundProteomeName, TestFilesDir.GetTestPath("celegans_mini.fasta"));
            WaitForProteinMetadataBackgroundLoaderCompleted();

            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                sequenceTree.BeginEdit(false);
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "Y18D10A.20";        // Not L10N
                sequenceTree.CommitEditBox(false);
            });
            WaitForProteinMetadataBackgroundLoaderCompleted();
            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                sequenceTree.BeginEdit(false);
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "AccessionWithout";
            });
            WaitForOpenForm <StatementCompletionForm>();
            Assert.IsNotNull(FindOpenForm <StatementCompletionForm>());
            RunUI(() =>
            {
                var statementCompletionForm = FindOpenForm <StatementCompletionForm>();
                Assert.IsNotNull(statementCompletionForm);
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                Assert.IsNotNull(sequenceTree.StatementCompletionEditBox);
                sequenceTree.StatementCompletionEditBox.OnSelectionMade(
                    (StatementCompletionItem)statementCompletionForm.ListView.Items[0].Tag);
            });
            WaitForProteinMetadataBackgroundLoaderCompleted();
            RunUI(() =>
            {
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                sequenceTree.BeginEdit(false);
                sequenceTree.StatementCompletionEditBox.TextBox.Text = "TISEVIAQGK"; // Not L10N
            });
            WaitForOpenForm <StatementCompletionForm>();

            RunUI(() =>
            {
                var statementCompletionForm = FindOpenForm <StatementCompletionForm>();
                Assert.IsNotNull(statementCompletionForm);
                SequenceTree sequenceTree = SkylineWindow.SequenceTree;
                Assert.IsNotNull(sequenceTree.StatementCompletionEditBox);
                sequenceTree.StatementCompletionEditBox.OnSelectionMade(
                    (StatementCompletionItem)statementCompletionForm.ListView.Items[0].Tag);
            });
            var peptideGroups = new List <PeptideGroupDocNode>(Program.ActiveDocument.PeptideGroups);

            Assert.AreEqual(3, peptideGroups.Count);
            Assert.AreEqual("Y18D10A.20", peptideGroups[0].Name);
            Assert.IsTrue(peptideGroups[0].AutoManageChildren);
            Assert.AreEqual("AccessionWithoutDescription", peptideGroups[1].Name);
            Assert.IsTrue(peptideGroups[1].AutoManageChildren);
            Assert.AreEqual("C37A2.7", peptideGroups[2].Name);
            Assert.IsFalse(peptideGroups[2].AutoManageChildren);

            // Save and re-open with prot db moved to see MissingFileDlg
            int    pepCount     = SkylineWindow.Document.PeptideCount;
            string documentPath = TestFilesDir.GetTestPath("BackgroundProtDoc.sky");

            RunUI(() =>
            {
                SkylineWindow.SaveDocument(documentPath);
                SkylineWindow.SwitchDocument(new SrmDocument(SrmSettingsList.GetDefault()), null);
            });
            Assert.AreEqual(0, SkylineWindow.Document.PeptideCount);
            File.Move(protdbPath, TestFilesDir.GetTestPath(_backgroundProteomeName + "-copy" + ProteomeDb.EXT_PROTDB));
            RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath),
                                    dlg => dlg.OkDialog());
            Assert.AreEqual(pepCount, SkylineWindow.Document.PeptideCount);
            RunUI(() => SkylineWindow.NewDocument());
            RunDlg <MissingFileDlg>(() => SkylineWindow.OpenFile(documentPath),
                                    dlg => dlg.CancelDialog());
            Assert.AreEqual(0, SkylineWindow.Document.PeptideCount);
        }
Esempio n. 54
0
        protected override void DoTest()
        {
            var folderAbsoluteQuant = UseRawFiles ? "AbsoluteQuant" : "AbsoluteQuantMzml";
            // Generating a Transition List, p. 4
            {
                var doc = SkylineWindow.Document;
                var transitionSettingsUI = ShowDialog <TransitionSettingsUI>(SkylineWindow.ShowTransitionSettingsUI);
                RunUI(() =>
                {
                    // Predicition Settings
                    transitionSettingsUI.SelectedTab       = TransitionSettingsUI.TABS.Prediction;
                    transitionSettingsUI.PrecursorMassType = MassType.Monoisotopic;
                    transitionSettingsUI.FragmentMassType  = MassType.Monoisotopic;
                    transitionSettingsUI.RegressionCEName  = "Thermo TSQ Vantage";
                    transitionSettingsUI.RegressionDPName  = Resources.SettingsList_ELEMENT_NONE_None;
                });
                PauseForScreenShot <TransitionSettingsUI.PredictionTab>("Transition Settings - Prediction tab", 4);

                RunUI(() =>
                {
                    // Filter Settings
                    transitionSettingsUI.SelectedTab      = TransitionSettingsUI.TABS.Filter;
                    transitionSettingsUI.PrecursorCharges = "2";
                    transitionSettingsUI.ProductCharges   = "1";
                    transitionSettingsUI.FragmentTypes    = "y";
                    transitionSettingsUI.RangeFrom        = Resources.TransitionFilter_FragmentStartFinders_ion_3;
                    transitionSettingsUI.RangeTo          = Resources.TransitionFilter_FragmentEndFinders_last_ion_minus_1;
                    transitionSettingsUI.SpecialIons      = new string[0];
                });
                PauseForScreenShot <TransitionSettingsUI.FilterTab>("Transition Settings - Filter tab", 4);

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

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

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

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

            AddHeavyMod(modHeavyK, peptideSettingsUi, "Edit Isotope Modification over Transition Settings", 5);
            RunUI(() => peptideSettingsUi.PickedHeavyMods = new[] { modHeavyK.Name });
            PauseForScreenShot <PeptideSettingsUI.ModificationsTab>("Peptide Settings - Modification tab with mod added", 5);

            OkDialog(peptideSettingsUi, peptideSettingsUi.OkDialog);

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

                OkDialog(pasteDlg, pasteDlg.OkDialog);
            }

            RunUI(SkylineWindow.ExpandPrecursors);
            RunUI(() => SkylineWindow.SaveDocument(GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            WaitForCondition(() => File.Exists(GetTestPath(folderAbsoluteQuant + @"test_file.sky")));
            RunUI(() => SkylineWindow.Size = new Size(840, 410));

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

            // Exporting a transition list p. 6
            {
                var exportMethodDlg = ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(ExportFileType.List));
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.THERMO;
                    exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlg.OptimizeType   = ExportOptimize.NONE;
                    exportMethodDlg.MethodType     = ExportMethodType.Standard;
                });
                PauseForScreenShot <ExportMethodDlg.TransitionListView>("Export Transition List", 7);

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

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

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

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

            WaitForGraphs();

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

            RunUI(() =>
            {               //resize the window and activate the first standard chromatogram pane.
                RunUI(() => SkylineWindow.Size = new Size(1330, 720));
                var chrom = SkylineWindow.GraphChromatograms.First();
                chrom.Select();
            });

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

            // Analyzing SRM Data from FOXN1-GST Sample p. 9
            RunDlg <ImportResultsDlg>(SkylineWindow.ImportResults,
                                      importResultsDlg1 =>
            {
                var rawFiles      = DataSourceUtil.GetDataSources(TestFilesDirs[0].FullPath).First().Value.Take(1);
                var namedPathSets = from rawFile in rawFiles
                                    select new KeyValuePair <string, MsDataFileUri[]>(
                    rawFile.GetFileNameWithoutExtension(), new[] { rawFile });
                importResultsDlg1.NamedPathSets = namedPathSets.ToArray();
                importResultsDlg1.OkDialog();
            });
            WaitForGraphs();
            CheckReportCompatibility.CheckAll(SkylineWindow.Document);
            WaitForCondition(5 * 60 * 1000, // five minutes
                             () =>
                             SkylineWindow.Document.Settings.HasResults &&
                             SkylineWindow.Document.Settings.MeasuredResults.IsLoaded);

            RunUI(() =>
            {
                SkylineWindow.ToggleIntegrateAll();
                SkylineWindow.ArrangeGraphsTabbed();
                SkylineWindow.ShowRTReplicateGraph();
                SkylineWindow.ShowPeakAreaReplicateComparison();
                // Total normalization
                SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_percent_view);
            });

            RunUI(() => SkylineWindow.ActivateReplicate("FOXN1-GST"));
            WaitForGraphs();
            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.TransitionGroups, 0));
            WaitForGraphs();
            RunUI(() =>
            {
                Assert.AreEqual(SkylineWindow.SelectedResultsIndex, SkylineWindow.GraphPeakArea.ResultsIndex);
                Assert.AreEqual(SkylineWindow.SelectedResultsIndex, SkylineWindow.GraphRetentionTime.ResultsIndex);
            });

            RunUI(() =>
            {
                int transitionCount = SkylineWindow.DocumentUI.PeptideTransitionGroups.First().TransitionCount;
                CheckGstGraphs(transitionCount, transitionCount);
            });
            RestoreViewOnScreen(10);
            PauseForScreenShot("Main window with Peak Areas, Retention Times and FOXN1-GST for light", 10);

            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.TransitionGroups, 1));
            WaitForGraphs();

            RunUI(() =>
            {
                int transitionCount = SkylineWindow.DocumentUI.PeptideTransitionGroups.ToArray()[1].TransitionCount;
                CheckGstGraphs(transitionCount, transitionCount);
            });
            PauseForScreenShot("Main window with Peak Areas, Retention Times and FOXN1-GST for heavy", 10);

            RunUI(() => SkylineWindow.SelectedPath = SkylineWindow.DocumentUI.GetPathTo((int)SrmDocument.Level.Molecules, 0));
            WaitForGraphs();
            // Heavy normalization
            RunUI(() => SkylineWindow.NormalizeAreaGraphTo(AreaNormalizeToView.area_ratio_view));
            WaitForGraphs();
            RunUI(() =>
            {
                int transitionGroupCount = SkylineWindow.DocumentUI.Peptides.First().TransitionGroupCount;
                CheckGstGraphs(transitionGroupCount, transitionGroupCount - 1);
            });
            RestoreViewOnScreen(11);
            PauseForScreenShot("Main window with totals graphs for light and heavy and FOXN1-GST", 11);

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

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

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

            RunUI(() =>
            {
                documentGridForm.ChooseView(Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates);
            });
            WaitForConditionUI(() => documentGridForm.IsComplete);
            var concentrations = new[] { 40, 12.5, 5, 2.5, 1, .5, .25, .1 };

            for (int iRow = 0; iRow < concentrations.Length; iRow++)
            {
                // ReSharper disable AccessToModifiedClosure
                RunUI(() =>
                {
                    var colSampleType = documentGridForm.FindColumn(PropertyPath.Root.Property("SampleType"));
                    documentGridForm.DataGridView.Rows[iRow].Cells[colSampleType.Index].Value = SampleType.STANDARD;
                });
                WaitForConditionUI(() => documentGridForm.IsComplete);
                RunUI(() =>
                {
                    var colAnalyteConcentration =
                        documentGridForm.FindColumn(PropertyPath.Root.Property("AnalyteConcentration"));
                    var cell = documentGridForm.DataGridView.Rows[iRow].Cells[colAnalyteConcentration.Index];
                    documentGridForm.DataGridView.CurrentCell = cell;
                    cell.Value = concentrations[iRow];
                });
                // ReSharper restore AccessToModifiedClosure
                WaitForConditionUI(() => documentGridForm.IsComplete);
            }
            PauseForScreenShot("Document grid with concentrations filled in", 13);

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

            PauseForScreenShot("View calibration curve", 14);

            Assert.AreEqual(CalibrationCurveFitter.AppendUnits(QuantificationStrings.Analyte_Concentration, quantUnits), calibrationForm.ZedGraphControl.GraphPane.XAxis.Title.Text);
            Assert.AreEqual(string.Format(QuantificationStrings.CalibrationCurveFitter_PeakAreaRatioText__0___1__Peak_Area_Ratio, IsotopeLabelType.light.Title, IsotopeLabelType.heavy.Title),
                            calibrationForm.ZedGraphControl.GraphPane.YAxis.Title.Text);
        }
 private DataGridViewPasteHandler(SkylineWindow skylineWindow, DataGridView dataGridView)
 {
     SkylineWindow = skylineWindow;
     DataGridView = dataGridView;
     DataGridView.KeyDown += DataGridViewOnKeyDown;
 }
 /// <summary>
 /// Split or collapse multiple panes in the chromatogram graph.
 /// </summary>
 /// <param name="split">True to split panes, false for single pane</param>
 public static void ShowSplitChromatogramGraph(bool split)
 {
     RunUI(() => SkylineWindow.ShowSplitChromatogramGraph(split));
     WaitForGraphs();
 }
Esempio n. 57
0
 public ToolService(string serviceName, SkylineWindow skylineWindow)
     : base(serviceName)
 {
     _skylineWindow = skylineWindow;
 }
 /// <summary>
 /// Close the spectrum graph.
 /// </summary>
 public void CloseSpectrumGraph()
 {
     RunUI(() => SkylineWindow.ShowGraphSpectrum(false));
     WaitForGraphs();
 }
Esempio n. 59
0
 protected override void OnShown(EventArgs e)
 {
     base.OnShown(e);
     if (null != FoldChangeBindingSource)
     {
         _bindingListSource = FoldChangeBindingSource.GetBindingListSource();
         _bindingListSource.ListChanged += BindingListSourceOnListChanged;
         if (_skylineWindow == null)
         {
             _skylineWindow = ((SkylineDataSchema) _bindingListSource.ViewInfo.DataSchema).SkylineWindow;
             if (_skylineWindow != null)
             {
                 _skylineWindow.SequenceTree.AfterSelect += SequenceTreeOnAfterSelect;
             }
         }
         UpdateGraph();
     }
 }
Esempio n. 60
0
        protected bool DoQualityControlSummaryReports()
        {
            // Quality Control Summary Reports, p. 20
            RunUI(() =>
            {
                SkylineWindow.OpenFile(TestFilesDir.GetTestPath(@"CustomReports\study9pilot.sky")); // Not L10N
                SkylineWindow.ExpandPeptides();
            });
            RunUI(() => SkylineWindow.ShowDocumentGrid(true));
            RestoreViewOnScreen(20);
            var documentGridForm = FindOpenForm <DocumentGridForm>();
            var manageViewsForm  = ShowDialog <ManageViewsForm>(documentGridForm.ManageViews);

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

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

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

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

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

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

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

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

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

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

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