Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation for cutoff score in ImportPeptideSearchDlg #2752

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,27 @@ public void AddSearchFiles(IEnumerable<string> fileNames)
SearchFilenames = BuildLibraryDlg.AddInputFiles(WizardForm, SearchFilenames, fileNames, PerformDDASearch);
}

// For test purposes, lets us test error handling
public string CutOffScoreText
bspratt marked this conversation as resolved.
Show resolved Hide resolved
{
set { textCutoff.Text = value; } // Can be a null or empty string under some circumstances
}

public bool NeedsCutoffScore => comboInputFileType.SelectedIndex > 0;

public double? CutOffScore
{
// Only valid when Skyline performs the search
get { return comboInputFileType.SelectedIndex > 0 ? double.Parse(textCutoff.Text) : (double?) null; }
get { return NeedsCutoffScore ? double.Parse(textCutoff.Text) : (double?) null; }
set { textCutoff.Text = value.HasValue ? value.Value.ToString(CultureInfo.CurrentCulture) : string.Empty; }
}

public bool ValidateCutoffScore()
{
var helper = new MessageBoxHelper(this.ParentForm);
return !NeedsCutoffScore || helper.ValidateDecimalTextBox(textCutoff, out _);
}

public bool IncludeAmbiguousMatches
{
get { return cbIncludeAmbiguousMatches.Checked; }
Expand Down Expand Up @@ -643,5 +657,6 @@ private void comboInputFileType_SelectedIndexChanged(object sender, EventArgs e)
{
UpdatePerformDDASearch();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ private void NextPage()
{
_pagesToSkip.Clear();

if (!BuildPepSearchLibControl.ValidateCutoffScore())
{
return;
}
ImportPeptideSearch.IsDDASearch = BuildPepSearchLibControl.PerformDDASearch;
ImportFastaControl.IsDDASearch = BuildPepSearchLibControl.PerformDDASearch;
if (!BuildPepSearchLibControl.UseExistingLibrary)
Expand Down
11 changes: 9 additions & 2 deletions pwiz_tools/Skyline/TestFunctional/DdaSearchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MessageDlg>(() =>
{
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.
Expand Down