Skip to content

Commit

Permalink
Skyline: First draft of TestDdaTutorial and TestPeakPickingTutorial… (#…
Browse files Browse the repository at this point in the history
…3256)

* Skyline: First draft of TestDdaTutorial and TestPeakPickingTutorial for auto-screenshots
- fixed a gap in file locking testing that cause TestDdaTutorial to fail with a strange message
  • Loading branch information
brendanx67 authored Dec 4, 2024
1 parent 6215e4f commit 48d7706
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 21 deletions.
2 changes: 2 additions & 0 deletions pwiz_tools/Skyline/FileUI/PeptideSearch/SearchControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public void SetProgressBarText(string message)
}
}

public int PercentComplete => progressBar.Value;

protected CancellationTokenSource _cancelToken;

public abstract void RunSearch();
Expand Down
12 changes: 12 additions & 0 deletions pwiz_tools/Skyline/SettingsUI/EditPeakScoringModelDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,18 @@ public int SelectedGraphTab
set { tabControl1.SelectTab(value); }
}

#region screenshot helpers

public Control GraphsControl => tabControl1;
public Control SelectedGraphControl => tabControl1.TabPages[tabControl1.SelectedIndex];

public void ShowFindButton(bool show)
{
findPeptidesButton.Visible = show;
}

#endregion

public SimpleGridViewDriver<PeakCalculatorWeight> PeakCalculatorsGrid
{
get { return _gridViewDriver; }
Expand Down
11 changes: 9 additions & 2 deletions pwiz_tools/Skyline/TestPerf/DdaTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using pwiz.Common.Chemistry;
using pwiz.Skyline.Alerts;
using pwiz.Skyline.Controls;
using pwiz.Skyline.Controls.Graphs;
using pwiz.Skyline.EditUI;
using pwiz.Skyline.FileUI;
using pwiz.Skyline.FileUI.PeptideSearch;
Expand Down Expand Up @@ -267,6 +268,7 @@ private void TestMsFraggerSearch()
{

WaitForConditionUI(() => importPeptideSearchDlg.CurrentPage == ImportPeptideSearchDlg.Pages.dda_search_page);
WaitForConditionUI(() => importPeptideSearchDlg.SearchControl.PercentComplete > 25);
PauseForScreenShot<ImportPeptideSearchDlg.DDASearchPage>("Import Peptide Search - DDA Search Progress page", tutorialPage++);

// Wait for search to finish
Expand Down Expand Up @@ -297,6 +299,7 @@ private void TestMsFraggerSearch()
else
{
var ambiguousDlg = ShowDialog<MessageDlg>(() => importPeptideSearchDlg.ClickNextButton());
RunUIForScreenShot(() => ambiguousDlg.Height = 448);
PauseForScreenShot<MessageDlg>("Import Peptide Search - Ambiguous Peptides dialog", tutorialPage++);
RunUI(() => AssertEx.Contains(ambiguousDlg.Message,
Resources.BiblioSpecLiteBuilder_AmbiguousMatches_The_library_built_successfully__Spectra_matching_the_following_peptides_had_multiple_ambiguous_peptide_matches_and_were_excluded_));
Expand Down Expand Up @@ -351,7 +354,7 @@ private void TestMsFraggerSearch()
}
}
});
PauseForScreenShot("Import Peptide Search - Empty Proteins dialog", tutorialPage++);
PauseForScreenShot<AssociateProteinsDlg>("Import Peptide Search - Associate Proteins dialog", tutorialPage++);

using (new WaitDocumentChange(null, true, 600 * 1000))
{
Expand All @@ -376,7 +379,7 @@ private void TestMsFraggerSearch()

RunUI(() => SkylineWindow.ShowPeakAreaReplicateComparison());
RefreshGraphs();
PauseForScreenShot("Peak Areas - Replicate Comparison", tutorialPage++);
PauseForScreenShot<GraphSummary.AreaGraphView>("Peak Areas - Replicate Comparison", tutorialPage++);

RunUI(() =>
{
Expand Down Expand Up @@ -406,6 +409,10 @@ private void TestMsFraggerSearch()
RunUI(() => SkylineWindow.SaveDocument());

DirectoryEx.SafeDelete(Path.Combine(Path.GetDirectoryName(SearchFiles.First())!, "converted"));
foreach (var searchFile in SearchFiles)
{
FileEx.SafeDelete(Path.ChangeExtension(searchFile, ".mzid.gz"));
}
}

private void RefreshGraphs()
Expand Down
69 changes: 54 additions & 15 deletions pwiz_tools/Skyline/TestTutorial/PeakPickingTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using pwiz.Common.DataBinding;
using pwiz.Common.DataBinding.Controls.Editor;
Expand Down Expand Up @@ -118,8 +119,12 @@ protected override void DoTest()
OkDialog(generateDecoysDlg, generateDecoysDlg.OkDialog);

RestoreViewOnScreen(3);
RunUI(() => SkylineWindow.SequenceTree.TopNode = SkylineWindow.SequenceTree.Nodes[11]);
PauseForScreenShot("Targets view clipped from main window", 3);
RunUIForScreenShot(() =>
{
SkylineWindow.SequenceTree.TopNode = SkylineWindow.SequenceTree.Nodes[11];
SkylineWindow.SequenceTree.SelectedNode = SkylineWindow.SequenceTree.Nodes[12];
});
PauseForTargetsScreenShot("Targets view clipped from main window");

// Open the file with decoys
RunUI(() => SkylineWindow.OpenFile(GetTestPath("SRMCourse_DosR-hDP__20130501-tutorial-empty-decoys.sky")));
Expand Down Expand Up @@ -193,15 +198,24 @@ protected override void DoTest()
PauseForScreenShot<EditPeakScoringModelDlg.ModelTab>("Edit Peak Scoring Model form trained model", 6);
RunUI(() => Assert.AreEqual(0.5893, editDlg.PeakCalculatorsGrid.Items[3].PercentContribution ?? 0, 0.005));

RunUI(() => editDlg.SelectedGraphTab = 2);
PauseForScreenShot<EditPeakScoringModelDlg.PvalueTab>("Edit Peak Scoring Model form p value graph metafile", 7);
Control selectedGraphControl = null;
RunUI(() =>
{
editDlg.SelectedGraphTab = 2;
selectedGraphControl = editDlg.SelectedGraphControl;
});
PauseForGraphScreenShot("Edit Peak Scoring Model form p value graph metafile", selectedGraphControl);

RunUI(() => editDlg.SelectedGraphTab = 3);
PauseForScreenShot<EditPeakScoringModelDlg.QvalueTab>("Edit Peak Scoring Model form q value graph metafile", 8);
RunUI(() =>
{
editDlg.SelectedGraphTab = 3;
selectedGraphControl = editDlg.SelectedGraphControl;
});
PauseForGraphScreenShot("Edit Peak Scoring Model form q value graph metafile", selectedGraphControl);

RunUI(() => editDlg.SelectedGraphTab = 1);
RunUI(() => editDlg.PeakCalculatorsGrid.SelectRow(3));
PauseForScreenShot<EditPeakScoringModelDlg.FeaturesTab>("Edit Peak Scoring Model form feature score", 10);
RunUI(() => editDlg.PeakCalculatorsGrid.SelectRow(2));
PauseForScreenShot<EditPeakScoringModelDlg.FeaturesTab>("Edit Peak Scoring Model form library dotp feature score", 10);

RunUI(() =>
{
Expand All @@ -215,15 +229,26 @@ protected override void DoTest()
editDlg.FindMissingValues(2); // Retention time
editDlg.PeakScoringModelName = "test1";
});
PauseForScreenShot<EditPeakScoringModelDlg.FeaturesTab>("Edit Peak Scoring Model form find missing scores", 11);
RunUIForScreenShot(() => editDlg.ShowFindButton(true));
PauseForScreenShot(editDlg.GraphsControl, "Edit Peak Scoring Model form find missing scores", null, null, bmp =>
DrawLArrowCursorOnBitmap(bmp, 0.88, 0.7));
RunUIForScreenShot(() => editDlg.ShowFindButton(false));

OkDialog(editDlg, editDlg.OkDialog);
OkDialog(reintegrateDlg, reintegrateDlg.CancelDialog);

var findResultsForm = FindOpenForm<FindResultsForm>();
int oldSkylineWindowHeight = SkylineWindow.Height;
RunUIForScreenShot(() =>
{
SkylineWindow.Height = 715;
findResultsForm.ActivateItem(0);
findResultsForm.Focus();
});
PauseForScreenShot<FindResultsForm>("Find Results view clipped from main window", 12);
RunUIForScreenShot(() => SkylineWindow.Height = oldSkylineWindowHeight);

// Remove the peptide with no library dot product, and train again
FindResultsForm findResultsForm = null;
var missingPeptides = new List<string> { "LGGNEQVTR", "IPVDSIYSPVLK", "YFNDGDIVEGTIVK",
"DFDSLGTLR", "GGYAGMLVGSVGETVAQLAR", "GGYAGMLVGSVGETVAQLAR"};
var isDecoys = new List<bool> {false, false, false, false, false, true};
Expand Down Expand Up @@ -287,8 +312,12 @@ protected override void DoTest()
});
PauseForScreenShot<EditPeakScoringModelDlg.ModelTab>("Edit Peak Scoring Model form with library score", 13);

RunUI(() => editDlgLibrary.SelectedGraphTab = 3);
PauseForScreenShot<EditPeakScoringModelDlg.QvalueTab>("Edit Peak Scoring Model form q value graph with library score metafile", 14);
RunUI(() =>
{
editDlgLibrary.SelectedGraphTab = 3;
selectedGraphControl = editDlgLibrary.SelectedGraphControl;
});
PauseForGraphScreenShot("Edit Peak Scoring Model form q value graph with library score metafile", selectedGraphControl);

OkDialog(editDlgLibrary, editDlgLibrary.OkDialog);

Expand Down Expand Up @@ -334,7 +363,8 @@ protected override void DoTest()
Assert.AreEqual(18.0, chromGroupInfo.RetentionTime.Value, 0.1);
});
FindNode(peptideSeqHighlight);
PauseForScreenShot<GraphChromatogram>("Chromatogram graph metafile corrected peak at 18.0", 17);
const string screenshotReplicate = "006_StC-DosR_B2";
PauseForChromGraphScreenShot("Chromatogram graph metafile corrected peak at 18.0", screenshotReplicate);

// Reintegrate slightly differently, with a q value cutoff
var reintegrateDlgQ = ShowDialog<ReintegrateDlg>(SkylineWindow.ShowReintegrateDialog);
Expand All @@ -345,11 +375,20 @@ protected override void DoTest()
reintegrateDlgQ.OverwriteManual = true;
});
OkDialog(reintegrateDlgQ, reintegrateDlgQ.OkDialog);
PauseForScreenShot("Targets view with some null peaks clipped from main window", 17);
PauseForScreenShot<GraphChromatogram>("Chromatogram graph metafile with no picked peak", 18);
RunUIForScreenShot(() => SkylineWindow.SequenceTree.TopNode =
SkylineWindow.SequenceTree.SelectedNode.PrevVisibleNode.PrevVisibleNode);
FocusDocument();
PauseForTargetsScreenShot("Targets view with some null peaks clipped from main window", true, 4);
PauseForChromGraphScreenShot("Chromatogram graph metafile with no picked peak", screenshotReplicate);

RestoreViewOnScreen(14);
FindNode((622.3086).ToString(CultureInfo.CurrentCulture) + "++");
WaitForGraphs();
RunUIForScreenShot(() =>
{
SkylineWindow.GetGraphChrom(screenshotReplicate).ZoomTo(17.5, 18.4, 2E+5);
SkylineWindow.Width = 863;
});
PauseForScreenShot("Main window with interference on transition", 19);

// Export the mProphet features
Expand Down
5 changes: 3 additions & 2 deletions pwiz_tools/Skyline/TestUtil/TestFilesDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,11 @@ string GetProcessNamesLockingFile(string lockedDirectory, Exception exceptionSho
try
{
Helpers.TryTwice(() => Directory.Delete(path, true));
return; // If this succeeds then the lock was only temporary and we don't have a GUID folder to move back.
}
catch (Exception e)
{
throw new IOException($@"Directory.Move(""{path}"",""{guidName}"") failed, attempt to delete instead resulted in ""{e.Message}""{GetProcessNamesLockingFile(path, e)}");
throw new IOException($@"Directory.Move(""{path}"", ""{guidName}"") failed, attempt to delete instead resulted in ""{e.Message}""{GetProcessNamesLockingFile(path, e)}");
}
}

Expand All @@ -417,7 +418,7 @@ string GetProcessNamesLockingFile(string lockedDirectory, Exception exceptionSho
}
catch (Exception e)
{
throw new IOException($@"Directory.Move(""{guidName}"",(""{path}"") failed, attempt to delete instead resulted in ""{e.Message}""{GetProcessNamesLockingFile(path, e)}");
throw new IOException($@"Directory.Move(""{guidName}"", ""{path}"") failed, attempt to delete instead resulted in ""{e.Message}""{GetProcessNamesLockingFile(path, e)}");
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions pwiz_tools/Skyline/TestUtil/TestFunctional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ protected static TDlg ShowDialog<TDlg>(Action act, int millis = -1) where TDlg :
// Making sure if the form has a visible icon it's Skyline release icon, not daily one.
if (IsRecordingScreenShots && dlg.ShowIcon && !ReferenceEquals(dlg, SkylineWindow))
{
var ico = dlg.Icon.Handle;
if (dlg.FormBorderStyle != FormBorderStyle.FixedDialog ||
ico == Resources.Skyline_Daily.Handle)
dlg.Icon != null) // Normally a fixed dialog will not have the Skyline icon handle
{
var ico = dlg.Icon.Handle;
if (ico != SkylineWindow.Icon.Handle)
RunUI(() => dlg.Icon = SkylineWindow.Icon);
}
Expand Down Expand Up @@ -1504,6 +1504,8 @@ protected Bitmap ClipTargets(Bitmap targetsBmp, int? countTargets = null, bool f
var sequenceTreeRect = sequenceTree.Bounds;

sequenceTreeRect.Inflate(-1, -1); // Borders outside parent rect
sequenceTreeRect.X += 1;
sequenceTreeRect.Y += 1;

const int GWL_STYLE = -16;
const int WS_VSCROLL = 0x00200000;
Expand Down

0 comments on commit 48d7706

Please sign in to comment.