diff --git a/pwiz_tools/Skyline/FileUI/PeptideSearch/BuildPeptideSearchLibraryControl.cs b/pwiz_tools/Skyline/FileUI/PeptideSearch/BuildPeptideSearchLibraryControl.cs index 0c9e71d55f..a7f777c4c6 100644 --- a/pwiz_tools/Skyline/FileUI/PeptideSearch/BuildPeptideSearchLibraryControl.cs +++ b/pwiz_tools/Skyline/FileUI/PeptideSearch/BuildPeptideSearchLibraryControl.cs @@ -281,11 +281,40 @@ public void AddSearchFiles(IEnumerable fileNames) SearchFilenames = BuildLibraryDlg.AddInputFiles(WizardForm, SearchFilenames, fileNames, PerformDDASearch); } + // For test purposes, lets us test error handling + public string CutOffScoreText + { + set { textCutoff.Text = value; } // Can be a null or empty string under some circumstances + } + + public bool NeedsCutoffScore => comboInputFileType.SelectedIndex > 0; // Only needed if Skyline is conducting the search + + private double? _cutoffScore; // May be null when Skyline is not doing the search + public double? CutOffScore { // Only valid when Skyline performs the search - get { return comboInputFileType.SelectedIndex > 0 ? double.Parse(textCutoff.Text) : (double?) null; } - set { textCutoff.Text = value.HasValue ? value.Value.ToString(CultureInfo.CurrentCulture) : string.Empty; } + get { return NeedsCutoffScore ? _cutoffScore : null; } + set + { + _cutoffScore = value; + textCutoff.Text = _cutoffScore.HasValue ? _cutoffScore.Value.ToString(CultureInfo.CurrentCulture) : string.Empty; + } + } + + public bool ValidateCutoffScore() + { + if (!NeedsCutoffScore) + { + return true; // Doesn't matter what's in the text box, we won't use it + } + var helper = new MessageBoxHelper(this.ParentForm); + if (helper.ValidateDecimalTextBox(textCutoff, out var cutoffScore)) + { + _cutoffScore = cutoffScore; + return true; + } + return false; } public bool IncludeAmbiguousMatches @@ -643,5 +672,6 @@ private void comboInputFileType_SelectedIndexChanged(object sender, EventArgs e) { UpdatePerformDDASearch(); } + } } diff --git a/pwiz_tools/Skyline/FileUI/PeptideSearch/ImportPeptideSearchDlg.cs b/pwiz_tools/Skyline/FileUI/PeptideSearch/ImportPeptideSearchDlg.cs index 016ae5432c..2a48854399 100644 --- a/pwiz_tools/Skyline/FileUI/PeptideSearch/ImportPeptideSearchDlg.cs +++ b/pwiz_tools/Skyline/FileUI/PeptideSearch/ImportPeptideSearchDlg.cs @@ -485,6 +485,10 @@ private void NextPage() { _pagesToSkip.Clear(); + if (!BuildPepSearchLibControl.ValidateCutoffScore()) + { + return; + } ImportPeptideSearch.IsDDASearch = BuildPepSearchLibControl.PerformDDASearch; ImportFastaControl.IsDDASearch = BuildPepSearchLibControl.PerformDDASearch; if (!BuildPepSearchLibControl.UseExistingLibrary) diff --git a/pwiz_tools/Skyline/TestFunctional/DdaSearchTest.cs b/pwiz_tools/Skyline/TestFunctional/DdaSearchTest.cs index f55f7bd97f..caf2b86f99 100644 --- a/pwiz_tools/Skyline/TestFunctional/DdaSearchTest.cs +++ b/pwiz_tools/Skyline/TestFunctional/DdaSearchTest.cs @@ -224,17 +224,24 @@ private void TestSearch() // Add the test xml file to the search files list and try to // build the document library. - RunUI(() => + var errMsgDlg = ShowDialog(() => { Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); importPeptideSearchDlg.BuildPepSearchLibControl.PerformDDASearch = true; importPeptideSearchDlg.BuildPepSearchLibControl.DdaSearchDataSources = SearchFiles.Select(o => (MsDataFileUri)new MsDataFilePath(o)).Take(1).ToArray(); importPeptideSearchDlg.BuildPepSearchLibControl.WorkflowType = ImportPeptideSearchDlg.Workflow.dia; // will go back and switch to DDA - importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.9; + importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScoreText = @"12%"; // Intentionally bad importPeptideSearchDlg.BuildPepSearchLibControl.IrtStandards = IrtStandard.AUTO; Assert.IsTrue(importPeptideSearchDlg.ClickNextButton()); }); + OkDialog(errMsgDlg, errMsgDlg.OkDialog); // Expect complaint about bad cutoff score + RunUI(() => + { + Assert.IsTrue(importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.spectra_page); // Should not have advanced + importPeptideSearchDlg.BuildPepSearchLibControl.CutOffScore = 0.9; + Assert.IsTrue(importPeptideSearchDlg.ClickNextButton()); + }); // With only 1 source, no add/remove prefix/suffix dialog // We're on the "Match Modifications" page. Add M+16 mod.