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

Skyline: Improvements to tutorial screenshots based on testing #3283

Merged
merged 4 commits into from
Dec 18, 2024
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
Binary file modified pwiz_tools/Shared/Lib/DigitalRune.Windows.Docking.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using pwiz.Common;
using pwiz.Common.DataBinding;
using pwiz.Common.DataBinding.Controls;
using pwiz.Common.DataBinding.Controls.Editor;
Expand All @@ -46,7 +47,7 @@ protected override ViewEditor CreateViewEditor(ViewGroup viewGroup, ViewSpec vie
viewEditor.SetViewTransformer(new DocumentViewTransformer());
viewEditor.AddViewEditorWidget(new PivotReplicateAndIsotopeLabelWidget {Dock = DockStyle.Left});
#if DEBUG
viewEditor.ShowSourceTab = true;
viewEditor.ShowSourceTab = CommonApplicationSettings.PauseSeconds == 0; // not when taking screenshots
#else
viewEditor.ShowSourceTab = false;
#endif
Expand Down
64 changes: 63 additions & 1 deletion pwiz_tools/Skyline/Controls/Graphs/AllChromatogramsGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ protected override void Dispose(bool disposing)

private void ElapsedTimer_Tick(object sender, EventArgs e)
{
if (IsProgressFrozen())
return;

// Update timer and overall progress bar.
// ReSharper disable LocalizableElement
lblDuration.Text = _stopwatch.Elapsed.ToString(@"hh\:mm\:ss");
Expand Down Expand Up @@ -376,8 +379,34 @@ private void WindowMove(object sender, EventArgs e)
/// <summary>
/// Display chromatogram data.
/// </summary>
/// <param name="status"></param>
/// <param name="status">The <see cref="MultiProgressStatus"/> to update the UI to.</param>
public void UpdateStatus(MultiProgressStatus status)
{
lock (_missedProgressStatusList)
{
// If a freeze percent is set, freeze once all status is
if (IsProgressFrozen(status))
{
// Play this back later when progress is unfrozen
_missedProgressStatusList.Add(status);
lblDuration.Text = _elapsedTimeAtFreeze;
return;
}
if (_missedProgressStatusList.Count > 0)
{
// Play the missed progress before the current status
foreach (var multiProgressStatus in _missedProgressStatusList)
{
UpdateStatusInternal(multiProgressStatus);
}
_missedProgressStatusList.Clear();
}
}

UpdateStatusInternal(status);
}

private void UpdateStatusInternal(MultiProgressStatus status)
{
// Update overall progress bar.
if (_partialProgressList.Count == 0)
Expand Down Expand Up @@ -752,6 +781,39 @@ private void btnCopyText_Click(object sender, EventArgs e)

#region Testing Support

private int? _freezeProgressPercent;
private string _elapsedTimeAtFreeze;
private List<MultiProgressStatus> _missedProgressStatusList = new List<MultiProgressStatus>();

/// <summary>
/// Provide enough information for a consistent screenshot. Set values to null to resume.
/// </summary>
/// <param name="percent">Percent to freeze at when all processing threads match this percent or greater</param>
/// <param name="elapsedTime">Text for an elapsed time during the freeze</param>
public void SetFreezeProgressPercent(int? percent, string elapsedTime)
{
lock (_missedProgressStatusList)
{
_freezeProgressPercent = percent;
_elapsedTimeAtFreeze = elapsedTime;
}
}

public bool IsProgressFrozen(MultiProgressStatus status = null)
{
lock (_missedProgressStatusList)
{
if (!_freezeProgressPercent.HasValue)
return false;

if (status == null)
return _missedProgressStatusList.Count > 0;

// Stop when anything goes over the limit
return status.ProgressList.Any(loadingStatus => loadingStatus.PercentComplete > _freezeProgressPercent);
}
}

public int ProgressTotalPercent
{
get
Expand Down
5 changes: 5 additions & 0 deletions pwiz_tools/Skyline/FileUI/PeptideSearch/ImportFastaControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,12 @@ private void tbxFasta_TextChanged(object sender, EventArgs e)
FastaFile = tbxFasta.Text;
if (!File.Exists(FastaFile))
ImportFastaHelper.ShowFastaError(Resources.ToolDescription_RunTool_File_not_found_);
}
}

public void ScrollFastaTextToEnd()
{
tbxFasta.Select(tbxFasta.Text.Length, 0);
}

public void SetFastaContent(string fastaFilePath, bool forceFastaAsFilepath = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public ImportResultsDIAControl(IModifyDocumentContainer documentContainer, strin
listResultsFiles.DisplayMember = @"Name";
SimultaneousFiles = Settings.Default.ImportResultsSimultaneousFiles;
DoAutoRetry = Settings.Default.ImportResultsDoAutoRetry;

// Hide the GPF checkbox during screenshots until we branch for 24.1 docs
if (Program.PauseSeconds != 0)
{
btnBrowse.Top = cbGpf.Top;
btnRemove.Top = cbGpf.Top;
cbGpf.Visible = false;
}
}

private BindingList<ImportPeptideSearch.FoundResultsFile> _foundResultsFiles;
Expand Down
6 changes: 5 additions & 1 deletion pwiz_tools/Skyline/Skyline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4075,8 +4075,12 @@ private void UpdateProgressUI(object sender = null, EventArgs e = null)
if (!ImportingResultsWindow.IsUserCanceled)
Settings.Default.AutoShowAllChromatogramsGraph = ImportingResultsWindow.Visible;
ImportingResultsWindow.Finish();
if (!ImportingResultsWindow.HasErrors && Settings.Default.ImportResultsAutoCloseWindow)
if (!ImportingResultsWindow.HasErrors &&
!ImportingResultsWindow.IsProgressFrozen() &&
Settings.Default.ImportResultsAutoCloseWindow)
{
DestroyAllChromatogramsGraph();
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions pwiz_tools/Skyline/SkylineTester/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,10 @@ private IEnumerable<string> GetLanguageNames()
{
foreach (var language in GetLanguages())
{
string name;
if (_languageNames.TryGetValue(language, out name))
yield return name;
yield return _languageNames
.Where(lang => lang.Key.StartsWith(language))
.Select(lang => lang.Value)
.First();
}
}

Expand Down
9 changes: 6 additions & 3 deletions pwiz_tools/Skyline/SkylineTester/SkylineTesterWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public Button DefaultButton

private readonly Dictionary<string, string> _languageNames = new Dictionary<string, string>
{
{"en", "English"},
{"fr", "French"},
{"tr", "Turkish"},
{"en-US", "English"},
{"fr-FR", "French"},
{"tr-TR", "Turkish"},
{"ja", "Japanese"},
{"zh-CHS", "Chinese"}
};
Expand Down Expand Up @@ -390,6 +390,9 @@ private void BackgroundLoad(object sender, DoWorkEventArgs e)

RunUI(() =>
{
if (!Equals(testSet.SelectedItem, testSetValue))
return;

testsTree.Nodes.Clear();
testsTree.Nodes.Add(skylineNode);
skylineNode.Expand();
Expand Down
1 change: 1 addition & 0 deletions pwiz_tools/Skyline/TestPerf/DdaTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private void TestMsFraggerSearch()
Assert.IsFalse(importPeptideSearchDlg.ImportFastaControl.DecoyGenerationEnabled);
importPeptideSearchDlg.ImportFastaControl.MaxMissedCleavages = 0;
importPeptideSearchDlg.ImportFastaControl.SetFastaContent(GetTestPath("DdaSearchMs1Filtering\\2014_01_HUMAN_UPS.fasta"));
importPeptideSearchDlg.ImportFastaControl.ScrollFastaTextToEnd(); // So that the FASTA file name is visible
//importPeptideSearchDlg.ImportFastaControl.SetFastaContent(@"D:\test\Skyline\downloads\Tutorials\DdaSearchMs1Filtering\DdaSearchMS1Filtering\2021-11-09-decoys-2014_01_HUMAN_UPS.fasta");
});
PauseForScreenShot<ImportPeptideSearchDlg.FastaPage>("Import Peptide Search - Import FASTA page", tutorialPage++);
Expand Down
18 changes: 17 additions & 1 deletion pwiz_tools/Skyline/TestPerf/DiaSwathTutorialTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using pwiz.Common.Chemistry;
using pwiz.Common.DataBinding;
Expand Down Expand Up @@ -587,6 +589,13 @@ protected override void DoTest()
Assert.IsFalse(importPeptideSearchDlg.BuildPepSearchLibControl.IncludeAmbiguousMatches);
});
WaitForConditionUI(() => importPeptideSearchDlg.IsNextButtonEnabled);
RunUIForScreenShot(() =>
{
var cols = importPeptideSearchDlg.BuildPepSearchLibControl.Grid.Columns;
cols[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
cols[0].Width = 175; // just "interact.pep.xml"
cols[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; // To show the full PeptideProphet confidence
});
PauseForScreenShot<ImportPeptideSearchDlg.SpectraPage>("Import Peptide Search - Build Spectral Library populated page", screenshotPage++);

AddIrtPeptidesDlg addIrtPeptidesDlg;
Expand Down Expand Up @@ -852,8 +861,10 @@ protected override void DoTest()
OkDialog(peptidesPerProteinDlg, peptidesPerProteinDlg.OkDialog);

var allChrom = WaitForOpenForm<AllChromatogramsGraph>();
WaitForConditionUI(() => allChrom.ProgressTotalPercent >= 20);
allChrom.SetFreezeProgressPercent(41, @"00:00:22");
WaitForCondition(() => allChrom.IsProgressFrozen());
PauseForScreenShot<AllChromatogramsGraph>("Loading chromatograms window", screenshotPage++, 30*1000); // 30 second timeout to avoid getting stuck
allChrom.SetFreezeProgressPercent(null, null);
WaitForDocumentChangeLoaded(doc, 20 * 60 * 1000); // 20 minutes

var peakScoringModelDlg = WaitForOpenForm<EditPeakScoringModelDlg>();
Expand Down Expand Up @@ -937,6 +948,11 @@ protected override void DoTest()
RunUI(() =>
{
SkylineWindow.Size = new Size(900, 900);
SkylineWindow.ForceOnScreen(); // Avoid this shifting the window under the floating window later
});
Thread.Sleep(200); // Give layout time to adjust
RunUI(() =>
{
var chromPane1 = SkylineWindow.GetGraphChrom(SkylineWindow.Document.Settings.MeasuredResults.Chromatograms[0].Name);
var chromPane2 = SkylineWindow.GetGraphChrom(SkylineWindow.Document.Settings.MeasuredResults.Chromatograms[1].Name);
var rtGraphFrame = FindFloatingWindow(SkylineWindow.GraphRetentionTime);
Expand Down
40 changes: 37 additions & 3 deletions pwiz_tools/Skyline/TestPerf/HiResMetabolomicsTutorial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,48 @@ protected override void DoTest()
});
RestoreViewOnScreen(5);

PauseForScreenShot("Skyline with 14 transition - show the right-click menu for setting DHA to be a surrogate standard", 9);
PauseForScreenShot("Skyline with 14 transition", 9);

// Set the standard type of the surrogate standards to StandardType.SURROGATE_STANDARD
SelectNode(SrmDocument.Level.Molecules, 3);

// TODO: Show right-click menu with "Surrogate Standard" selected
if (IsPauseForScreenShots)
{
RunUI(() => SkylineWindow.Height = 720); // Taller for context menu

var sequenceTree = SkylineWindow.SequenceTree;
ToolStripDropDown menuStrip = null, subMenuStrip = null;

RunUI(() =>
{
var rectSelectedItem = sequenceTree.SelectedNode.Bounds;
SkylineWindow.ContextMenuTreeNode.Show(sequenceTree.PointToScreen(
new Point(rectSelectedItem.X + rectSelectedItem.Width / 2,
rectSelectedItem.Y + rectSelectedItem.Height / 2)));
var setStandardTypeMenu = SkylineWindow.ContextMenuTreeNode.Items.OfType<ToolStripMenuItem>()
.First(i => Equals(i.Name, @"setStandardTypeContextMenuItem"));
setStandardTypeMenu.ShowDropDown();
setStandardTypeMenu.DropDownItems.OfType<ToolStripMenuItem>()
.First(i => Equals(i.Name, @"surrogateStandardContextMenuItem")).Select();

menuStrip = SkylineWindow.ContextMenuTreeNode;
subMenuStrip = setStandardTypeMenu.DropDown;
menuStrip.Closing += DenyMenuClosing;
subMenuStrip.Closing += DenyMenuClosing;
});

// Should all land on the SkylineWindow, so just screenshot the whole window
PauseForScreenShot("Skyline with 4 molecules with menu and submenu showing for surrogate standard setting");

RunUI(() =>
{
menuStrip.Closing -= DenyMenuClosing;
subMenuStrip.Closing -= DenyMenuClosing;
menuStrip.Close();
});
}

RunUI(() => SkylineWindow.SetStandardType(StandardType.SURROGATE_STANDARD));
PauseForScreenShot("Skyline with 4 molecules and one set as surrogate standard");
RunUI(() => SkylineWindow.SaveDocument(GetTestPath("FattyAcids_demo.sky")));

using (new WaitDocumentChange(1, true))
Expand Down
22 changes: 17 additions & 5 deletions pwiz_tools/Skyline/TestRunner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ internal static class Program
private static readonly string[] TEST_DLLS = { "Test.dll", "TestData.dll", "TestConnected.dll", "TestFunctional.dll", "TestTutorial.dll", "CommonTest.dll", "TestPerf.dll" };

private static readonly string executingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private static readonly string[] allLanguages = new FindLanguages(executingDirectory, "en", "fr", "tr").Enumerate().ToArray(); // Languages used in pass 1, and in pass 2 perftets
private static readonly string[] qualityLanguages = new FindLanguages(executingDirectory, "en", "fr").Enumerate().ToArray(); // "fr" and "tr" pretty much test the same thing, so just use fr in pass 2
private static readonly string[] allLanguages = new FindLanguages(executingDirectory, "en-US", "fr-FR", "tr-TR").Enumerate().ToArray(); // Languages used in pass 1, and in pass 2 perftets
private static readonly string[] qualityLanguages = allLanguages.Where(l => !l.StartsWith("tr")).ToArray(); // "fr" and "tr" pretty much test the same thing, so just use fr in pass 2

private const int LeakTrailingDeltas = 7; // Number of trailing deltas to average and check against thresholds below
// CONSIDER: Ideally these thresholds would be zero, but memory and handle retention are not stable enough to support that
Expand Down Expand Up @@ -896,7 +896,7 @@ private static bool PushToTestQueue(List<TestInfo> testList, List<TestInfo> unfi
if (commandLineArgs.ArgAsBool("buildcheck"))
{
loop = 1;
languages = new[] { "en" };
languages = new[] { "en-US" };
}

Action<string, StreamWriter, int> LogTestOutput = (testOutput, testLog, pass) =>
Expand Down Expand Up @@ -1285,7 +1285,19 @@ private static string[] GetLanguages(CommandLineArgs args)
string value = args.ArgAsString("language");
if (value == "all")
return allLanguages;
return value.Split(',');
return value.Split(',').Select(GetCanonicalLanguage).ToArray();
}

private static string GetCanonicalLanguage(string rawLanguage)
{
// If the raw language is a prefix of something from allLanguages, use
// the full name.
foreach (var language in allLanguages)
{
if (language.StartsWith(rawLanguage))
return language;
}
return rawLanguage;
}

private static DirectoryInfo GetSkylineDirectory()
Expand Down Expand Up @@ -1492,7 +1504,7 @@ private static bool RunTestPasses(

// Get list of languages
var languages = buildMode
? new[] { "en" }
? new[] { "en-US" }
: GetLanguages(commandLineArgs);

if (showFormNames)
Expand Down
Loading