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>(); }
private bool UpdateFullScanSettings() { var helper = new MessageBoxHelper(this); // Validate and store MS1 full-scan settings // If high resolution MS1 filtering is enabled, make sure precursor m/z type // is monoisotopic and isotope enrichments are set var precursorIsotopes = FullScanSettingsControl.PrecursorIsotopesCurrent; var precursorAnalyzerType = FullScanSettingsControl.PrecursorMassAnalyzer; var precursorMassType = TransitionSettings.Prediction.PrecursorMassType; if (precursorIsotopes == FullScanPrecursorIsotopes.None) { if (WorkflowType != Workflow.dia) { MessageDlg.Show(this, Resources.ImportPeptideSearchDlg_UpdateFullScanSettings_Full_scan_MS1_filtering_must_be_enabled_in_order_to_import_a_peptide_search_); return(false); } else if (FullScanSettingsControl.AcquisitionMethod == FullScanAcquisitionMethod.None) { MessageDlg.Show(this, Resources.ImportPeptideSearchDlg_UpdateFullScanSettings_Full_scan_MS1_or_MS_MS_filtering_must_be_enabled_in_order_to_import_a_peptide_search_); return(false); } } else if (precursorAnalyzerType != FullScanMassAnalyzerType.qit) { precursorMassType = MassType.Monoisotopic; if (FullScanSettingsControl.Enrichments == null) { MessageDlg.Show(GetParentForm(this), Resources.TransitionSettingsUI_OkDialog_Isotope_enrichment_settings_are_required_for_MS1_filtering_on_high_resolution_mass_spectrometers); return(false); } } if (FullScanSettingsControl.IsolationScheme == null && FullScanSettingsControl.AcquisitionMethod == FullScanAcquisitionMethod.DIA) { MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_An_isolation_scheme_is_required_to_match_multiple_precursors); return(false); } TransitionFilter filter = TransitionSettings.Filter; if (FullScanSettingsControl.PrecursorChargesTextBox.Visible) { Adduct[] precursorCharges; if (!TransitionSettingsControl.ValidateAdductListTextBox(helper, FullScanSettingsControl.PrecursorChargesTextBox, true, TransitionGroup.MIN_PRECURSOR_CHARGE, TransitionGroup.MAX_PRECURSOR_CHARGE, out precursorCharges)) { return(false); } precursorCharges = precursorCharges.Distinct().ToArray(); FullScanSettingsControl.PrecursorChargesString = TransitionFilter.AdductListToString(precursorCharges); filter = TransitionSettings.Filter.ChangePeptidePrecursorCharges(precursorCharges); } if (WorkflowType == Workflow.dda && !filter.PeptideIonTypes.Contains(IonType.precursor)) { filter = filter.ChangePeptideIonTypes(new[] { IonType.precursor }); } if (!filter.AutoSelect) { filter = filter.ChangeAutoSelect(true); } Helpers.AssignIfEquals(ref filter, TransitionSettings.Filter); if (FullScanSettingsControl.IsDIA() && filter.ExclusionUseDIAWindow) { if (FullScanSettingsControl.IsolationScheme.IsAllIons) { MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_Cannot_use_DIA_window_for_precusor_exclusion_when__All_Ions__is_selected_as_the_isolation_scheme___To_use_the_DIA_window_for_precusor_exclusion__change_the_isolation_scheme_in_the_Full_Scan_settings_); return(false); } if (FullScanSettingsControl.IsolationScheme.FromResults) { MessageDlg.Show(this, Resources.TransitionSettingsUI_OkDialog_Cannot_use_DIA_window_for_precursor_exclusion_when_isolation_scheme_does_not_contain_prespecified_windows___Please_select_an_isolation_scheme_with_prespecified_windows_); return(false); } } TransitionFullScan fullScan; if (!FullScanSettingsControl.ValidateFullScanSettings(helper, out fullScan)) { return(false); } Helpers.AssignIfEquals(ref fullScan, TransitionSettings.FullScan); var prediction = TransitionSettings.Prediction.ChangePrecursorMassType(precursorMassType); Helpers.AssignIfEquals(ref prediction, TransitionSettings.Prediction); TransitionSettings settings; try { settings = new TransitionSettings(prediction, filter, TransitionSettings.Libraries, TransitionSettings.Integration, TransitionSettings.Instrument, fullScan); } catch (Exception x) { MessageDlg.Show(this, x.Message); return(false); } // Did user change the "use spectral libary ion mobility" values? PeptidePrediction updatedPeptidePrediction; bool peptidePredictionChanged = false; try { updatedPeptidePrediction = FullScanSettingsControl.UseSpectralLibraryIonMobilityValuesControl.ValidateNewSettings(true); if (updatedPeptidePrediction == null) { return(false); } peptidePredictionChanged = !Equals(Document.Settings.PeptideSettings.Prediction, updatedPeptidePrediction); } catch (Exception) { return(false); } // Only update, if anything changed if (Equals(settings, TransitionSettings) && !peptidePredictionChanged) { return(true); } ModifyDocumentNoUndo(doc => doc.ChangeSettings(doc.Settings.ChangeTransitionSettings(settings).ChangePeptideSettings(doc.Settings.PeptideSettings.ChangePrediction(updatedPeptidePrediction)))); _fullScanSettingsChanged = true; return(true); }
private void NextPage() { switch (CurrentPage) { case Pages.spectra_page: { HasPeakBoundaries = BuildPepSearchLibControl.SearchFilenames.All(f => f.EndsWith(BiblioSpecLiteBuilder.EXT_TSV)); if (BuildPepSearchLibControl.SearchFilenames.Any(f => f.EndsWith(BiblioSpecLiteBuilder.EXT_TSV)) && !HasPeakBoundaries) { MessageDlg.Show(this, Resources.ImportPeptideSearchDlg_NextPage_Cannot_build_library_from_OpenSWATH_results_mixed_with_results_from_other_tools_); return; } var eCancel = new CancelEventArgs(); if (!BuildPeptideSearchLibrary(eCancel)) { // Page shows error if (eCancel.Cancel) { return; } CloseWizard(DialogResult.Cancel); } // The user had the option to finish right after // building the peptide search library, but they // did not, so hide the "early finish" button for // the rest of the wizard pages. ShowEarlyFinish(false); if (FastaOptional) { lblFasta.Text = Resources.ImportPeptideSearchDlg_NextPage_Import_FASTA__optional_; } // The next page is going to be the chromatograms page. var oldImportResultsControl = (ImportResultsControl)ImportResultsControl; if (WorkflowType != Workflow.dia || HasPeakBoundaries) { oldImportResultsControl.InitializeChromatogramsPage(Document); if (WorkflowType == Workflow.dda) { _pagesToSkip.Add(Pages.transition_settings_page); } } else { // DIA workflow, replace old ImportResultsControl ImportResultsControl = new ImportResultsDIAControl(this) { Anchor = oldImportResultsControl.Anchor, Location = oldImportResultsControl.Location }; getChromatogramsPage.Controls.Remove(oldImportResultsControl); getChromatogramsPage.Controls.Add((Control)ImportResultsControl); } ImportResultsControl.ResultsFilesChanged += ImportResultsControl_OnResultsFilesChanged; // Set up full scan settings page TransitionSettingsControl.Initialize(WorkflowType); FullScanSettingsControl.ModifyOptionsForImportPeptideSearchWizard(WorkflowType); if (!MatchModificationsControl.Initialize(Document)) { _pagesToSkip.Add(Pages.match_modifications_page); } if (BuildPepSearchLibControl.FilterForDocumentPeptides) { _pagesToSkip.Add(Pages.import_fasta_page); } // Decoy options enabled only for DIA ImportFastaControl.RequirePrecursorTransition = WorkflowType != Workflow.dia; ImportFastaControl.DecoyGenerationEnabled = WorkflowType == Workflow.dia && !HasPeakBoundaries; } break; case Pages.chromatograms_page: { if (!ImportPeptideSearch.VerifyRetentionTimes(ImportResultsControl.FoundResultsFiles.Select(f => f.Path))) { MessageDlg.Show(this, TextUtil.LineSeparate(Resources.ImportPeptideSearchDlg_NextPage_The_document_specific_spectral_library_does_not_have_valid_retention_times_, Resources.ImportPeptideSearchDlg_NextPage_Please_check_your_peptide_search_pipeline_or_contact_Skyline_support_to_ensure_retention_times_appear_in_your_spectral_libraries_)); CloseWizard(DialogResult.Cancel); } if (ImportResultsControl.ResultsFilesMissing) { if (MessageBox.Show(this, Resources.ImportPeptideSearchDlg_NextPage_Some_results_files_are_still_missing__Are_you_sure_you_want_to_continue_, Program.Name, MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } } var foundResults = ImportResultsControl.FoundResultsFiles; if (foundResults.Count > 1) { // Older Resharper code inspection implementations insist on warning here // Resharper disable PossibleMultipleEnumeration string[] resultNames = foundResults.Select(f => f.Name).ToArray(); string prefix = ImportResultsDlg.GetCommonPrefix(resultNames); string suffix = ImportResultsDlg.GetCommonSuffix(resultNames); // Resharper restore PossibleMultipleEnumeration if (!string.IsNullOrEmpty(prefix) || !string.IsNullOrEmpty(suffix)) { using (var dlgName = new ImportResultsNameDlg(prefix, suffix, resultNames)) { var result = dlgName.ShowDialog(this); if (result == DialogResult.Cancel) { return; } else if (dlgName.IsRemove) { ImportResultsControl.FoundResultsFiles = ImportResultsControl.FoundResultsFiles.Select(f => new ImportPeptideSearch.FoundResultsFile(dlgName.ApplyNameChange(f.Name), f.Path)).ToList(); ImportResultsControl.Prefix = string.IsNullOrEmpty(prefix) ? null : prefix; ImportResultsControl.Suffix = string.IsNullOrEmpty(suffix) ? null : suffix; } } } } } break; case Pages.match_modifications_page: if (!UpdateModificationSettings()) { return; } break; case Pages.transition_settings_page: // Try to accept changes to transition settings if (!UpdateTransitionSettings()) { return; } break; case Pages.full_scan_settings_page: // Try to accept changes to MS1 full-scan settings if (!UpdateFullScanSettings()) { // We can't allow the user to progress any further until // we can verify that the MS1 full scan settings are valid. return; } break; case Pages.import_fasta_page: // This is the last page if (FastaOptional && !ImportFastaControl.ContainsFastaContent || ImportFastaControl.ImportFasta()) { WizardFinish(); } return; } var newPage = CurrentPage + 1; while (_pagesToSkip.Contains(newPage)) { ++newPage; } // Skip import FASTA if user filters for document peptides if (newPage > Pages.import_fasta_page) { WizardFinish(); return; } CurrentPage = newPage; UpdateButtons(); }
private void NextPage() { switch (CurrentPage) { case Pages.spectra_page: { var eCancel = new CancelEventArgs(); if (!BuildPepSearchLibControl.BuildPeptideSearchLibrary(eCancel)) { // Page shows error if (eCancel.Cancel) { return; } CloseWizard(DialogResult.Cancel); } // The user had the option to finish right after // building the peptide search library, but they // did not, so hide the "early finish" button for // the rest of the wizard pages. ShowEarlyFinish(false); if (FastaOptional) { lblFasta.Text = Resources.ImportPeptideSearchDlg_NextPage_Import_FASTA__optional_; } // The next page is going to be the chromatograms page. var oldImportResultsControl = (ImportResultsControl)ImportResultsControl; if (WorkflowType != Workflow.dia) { oldImportResultsControl.InitializeChromatogramsPage(SkylineWindow.DocumentUI); if (WorkflowType == Workflow.dda) { _pagesToSkip.Add(Pages.transition_settings_page); } } else { // DIA workflow, replace old ImportResultsControl ImportResultsControl = new ImportResultsDIAControl(SkylineWindow) { Anchor = oldImportResultsControl.Anchor, Location = oldImportResultsControl.Location }; getChromatogramsPage.Controls.Remove(oldImportResultsControl); getChromatogramsPage.Controls.Add((Control)ImportResultsControl); } ImportResultsControl.ResultsFilesChanged += ImportResultsControl_OnResultsFilesChanged; // Set up full scan settings page TransitionSettingsControl.Initialize(WorkflowType); FullScanSettingsControl.ModifyOptionsForImportPeptideSearchWizard(WorkflowType); if (!MatchModificationsControl.Initialize(SkylineWindow.Document)) { _pagesToSkip.Add(Pages.match_modifications_page); } if (BuildPepSearchLibControl.FilterForDocumentPeptides) { _pagesToSkip.Add(Pages.import_fasta_page); } } break; case Pages.chromatograms_page: { if (!ImportPeptideSearch.VerifyRetentionTimes(ImportResultsControl.FoundResultsFiles.Select(f => f.Path))) { MessageDlg.Show(this, TextUtil.LineSeparate(Resources.ImportPeptideSearchDlg_NextPage_The_document_specific_spectral_library_does_not_have_valid_retention_times_, Resources.ImportPeptideSearchDlg_NextPage_Please_check_your_peptide_search_pipeline_or_contact_Skyline_support_to_ensure_retention_times_appear_in_your_spectral_libraries_)); CloseWizard(DialogResult.Cancel); } if (ImportResultsControl.ResultsFilesMissing) { if (MessageBox.Show(this, Resources.ImportPeptideSearchDlg_NextPage_Some_results_files_are_still_missing__Are_you_sure_you_want_to_continue_, Program.Name, MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } } if (ImportResultsControl.FoundResultsFiles.Count > 1) { string prefix = ImportResultsDlg.GetCommonPrefix(ImportResultsControl.FoundResultsFiles.Select(f => f.Name)); if (prefix.Length >= ImportResultsDlg.MIN_COMMON_PREFIX_LENGTH) { using (var dlgName = new ImportResultsNameDlg(prefix)) { var result = dlgName.ShowDialog(this); if (result == DialogResult.Cancel) { return; } else if (result == DialogResult.Yes) { // Rename all the replicates to remove the specified prefix. ImportResultsControl.FoundResultsFiles = ImportResultsControl.FoundResultsFiles.Select(f => new ImportPeptideSearch.FoundResultsFile(f.Name.Substring(dlgName.Prefix.Length), f.Path)).ToList(); } } } } } break; case Pages.match_modifications_page: { var newSettings = MatchModificationsControl.AddCheckedModifications(SkylineWindow.Document); if (!ReferenceEquals(SkylineWindow.Document.Settings, newSettings)) { SkylineWindow.ChangeSettings(newSettings, true, Resources.MatchModificationsControl_AddCheckedModifications_Add_checked_modifications); SkylineWindow.Document.Settings.UpdateDefaultModifications(false); } // The next page is going to be the MS1 Full-Scan Settings // page, so initialize it. // FullScanSettingsControl.InitializeMs1FullScanSettingsPage(); } break; case Pages.transition_settings_page: // Try to accept changes to transition settings if (!UpdateTransitionSettings()) { return; } break; case Pages.full_scan_settings_page: // Try to accept changes to MS1 full-scan settings if (!UpdateFullScanSettings()) { // We can't allow the user to progress any further until // we can verify that the MS1 full scan settings are valid. return; } break; case Pages.import_fasta_page: // This is the last page if ((FastaOptional && !ImportFastaControl.ContainsFastaContent) || ImportFastaControl.ImportFasta()) { WizardFinish(); } return; } Pages newPage = CurrentPage + 1; while (_pagesToSkip.Contains(newPage)) { ++newPage; } // Skip import FASTA if user filters for document peptides if (newPage > Pages.import_fasta_page) { WizardFinish(); return; } CurrentPage = newPage; if (CurrentPage == LastPage) { btnNext.Text = Resources.ImportPeptideSearchDlg_NextPage_Finish; } }
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>(); }