Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions pwiz_tools/Skyline/Controls/ControlsResources.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pwiz_tools/Skyline/Controls/ControlsResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@
<data name="MessageBoxHelper_ValidateNumberListTextBox__0__must_contain_a_comma_separated_list_of_integers_from__1__to__2__" xml:space="preserve">
<value>{0} must contain a comma separated list of integers from {1} to {2}.</value>
</data>
<data name="PopupPickList_SiteDetermining_NoneFound" xml:space="preserve">
<value>No ions uniquely localize this modification</value>
</data>
<data name="PopupPickList_SiteDetermining_ToolTip" xml:space="preserve">
<value>Show only ions that uniquely localize modifications</value>
</data>
<data name="PopupPickList_UpdateAutoManageUI_Auto_select_filtered__0_" xml:space="preserve">
<value>Auto-select filtered {0}</value>
</data>
Expand Down
29 changes: 25 additions & 4 deletions pwiz_tools/Skyline/Controls/PopupPickList.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions pwiz_tools/Skyline/Controls/PopupPickList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public partial class PopupPickList : FormEx, ITipDisplayer
private bool _closing;
private bool _autoManageChildren;
private bool _selectalInternalChange;
private bool _siteDeterminingOnly;

private int _leftText;

Expand Down Expand Up @@ -99,6 +100,11 @@ public PopupPickList(IChildPicker picker, string childHeading, bool okOnDeactiva
_autoManageChildren = _picker.AutoManageChildren;
UpdateAutoManageUI();

// Show the site-determining ions toggle only for localizable peptides.
bool canSd = _picker is ISiteDeterminingIonPicker sd && sd.CanShowSiteDeterminingIons;
tbbSiteDetermining.Visible = canSd;
tbbSiteDetermining.ToolTipText = ControlsResources.PopupPickList_SiteDetermining_ToolTip;

// Hide the synchronize checkbox, or set its label correctly
string synchLabelText = _picker.SynchSiblingsLabel;
if (string.IsNullOrEmpty(synchLabelText))
Expand All @@ -116,6 +122,13 @@ public PopupPickList(IChildPicker picker, string childHeading, bool okOnDeactiva
cbSynchronize.Text = synchLabelText;
cbSynchronize.Checked = _picker.IsSynchSiblings;
}

// Overlay the empty-state hint on the choices list. Shown only when the
// site-determining filter is on but no ion uniquely localizes the modification.
lblSiteDeterminingEmpty.Text = ControlsResources.PopupPickList_SiteDetermining_NoneFound;
lblSiteDeterminingEmpty.Bounds = pickListMulti.Bounds;
lblSiteDeterminingEmpty.Anchor = pickListMulti.Anchor;
lblSiteDeterminingEmpty.BringToFront();
}

public IEnumerable<string> ItemNames
Expand All @@ -127,6 +140,54 @@ public IEnumerable<string> ItemNames
}
}

/// <summary>
/// Test support: the <see cref="DocNode"/> behind each currently visible choice, in
/// display order. Lets a test map a visible pick to its underlying identity (e.g. a
/// <see cref="Transition"/>) rather than relying on the (localized) label.
/// </summary>
public IEnumerable<DocNode> VisibleChoices
{
get
{
for (int i = 0; i < pickListMulti.Items.Count; i++)
yield return GetVisibleChoice(i).Choice;
}
}

/// <summary>
/// Test support: toggles the "site-determining ions only" filter the same way the
/// <see cref="tbbSiteDetermining"/> toolbar button does.
/// </summary>
public bool SiteDeterminingFilter
{
get { return _siteDeterminingOnly; }
set
{
_siteDeterminingOnly = value;
if (tbbSiteDetermining.Visible)
tbbSiteDetermining.Checked = value;
ShowChoices();
}
}

/// <summary>
/// Test support: whether the site-determining ions toggle button is showing (only for
/// localizable peptides).
/// </summary>
public bool SiteDeterminingButtonVisible
{
get { return tbbSiteDetermining.Visible; }
}

/// <summary>
/// Test support: whether the empty-state hint (shown when the site-determining filter
/// leaves no visible choices) is currently displayed.
/// </summary>
public bool SiteDeterminingEmptyHintVisible
{
get { return lblSiteDeterminingEmpty.Visible; }
}

public Rectangle GetItemTextRectangle(int i)
{
var rect = pickListMulti.GetItemRectangle(i);
Expand Down Expand Up @@ -246,12 +307,20 @@ private void ShowChoices()
for (int i = 0; i < _choices.Count; i++)
{
var choice = _choices[i];
if (_siteDeterminingOnly && _picker is ISiteDeterminingIonPicker sd2 &&
!sd2.IsSiteDeterminingChoice(choice.Choice))
continue;
if (!textSearch.Visible || AcceptChoice(choice, searches))
{
pickListMulti.Items.Add(choice);
}
}
pickListMulti.EndUpdate();

// Show the empty-state hint when the site-determining filter is on and it left the
// choices list empty (no ion uniquely localizes the modification).
lblSiteDeterminingEmpty.Visible = _siteDeterminingOnly && pickListMulti.Items.Count == 0;

UpdateSelectAll();
}

Expand Down Expand Up @@ -362,6 +431,12 @@ private void tbbAutoManageChildren_Click(object sender, EventArgs e)
ToggleAutoManageChildren();
}

private void tbbSiteDetermining_Click(object sender, EventArgs e)
{
_siteDeterminingOnly = tbbSiteDetermining.Checked;
ShowChoices();
}

public void ToggleAutoManageChildren()
{
AutoManageChildren = tbbAutoManageChildren.Checked;
Expand Down
27 changes: 27 additions & 0 deletions pwiz_tools/Skyline/Controls/SeqNode/SrmTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,33 @@ public interface IShowPicker
bool Filtered { get; set; }
}

/// <summary>
/// Optional capability a child picker may implement to expose a "site-determining
/// ions" filter in the <see cref="PopupPickList"/>, for peptides that carry an
/// ambiguous (localizable) modification.
/// </summary>
public interface ISiteDeterminingIonPicker
{
/// <summary>
/// True when the picker's peptide is localizable, so the site-determining
/// ions toggle should be offered.
/// </summary>
bool CanShowSiteDeterminingIons { get; }

/// <summary>
/// True when the given choice is a product ion that uniquely localizes the modification
/// (no other positional placement produces it). May match nothing when the placement is
/// unresolvable, in which case the filtered list is legitimately empty.
/// </summary>
bool IsSiteDeterminingChoice(DocNode choice);

/// <summary>
/// The resolved modification's name for the given choice, or null when the
/// choice is not site-determining.
/// </summary>
string GetSiteDeterminingTip(DocNode choice);
}

/// <summary>
/// Implement to support the <see cref="PopupPickList"/> user interface for
/// picking children of a <see cref="SrmTreeNode"/>.
Expand Down
51 changes: 50 additions & 1 deletion pwiz_tools/Skyline/Controls/SeqNode/TransitionGroupTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using pwiz.Skyline.Model.Databinding.Entities;
using pwiz.Skyline.Model.DocSettings;
using pwiz.Skyline.Model.Lib;
using pwiz.Skyline.Model.Localization;
using pwiz.Skyline.Model.Results.Spectra;
using pwiz.Skyline.Properties;
using pwiz.Skyline.Util;
Expand All @@ -37,8 +38,9 @@

namespace pwiz.Skyline.Controls.SeqNode
{
public class TransitionGroupTreeNode : SrmTreeNodeParent
public class TransitionGroupTreeNode : SrmTreeNodeParent, ISiteDeterminingIonPicker
{
private SiteDeterminingIonAnalyzer _siteDeterminingAnalyzer;
public static TransitionGroupTreeNode CreateInstance(SequenceTree tree, DocNode nodeDoc)
{
Debug.Assert(nodeDoc is TransitionGroupDocNode);
Expand Down Expand Up @@ -356,6 +358,53 @@ private bool IsSynchable()

#endregion

#region ISiteDeterminingIonPicker Members

private SiteDeterminingIonAnalyzer SiteDeterminingAnalyzer
{
get
{
var nodePep = PepNode;
if (nodePep == null)
return null;
return _siteDeterminingAnalyzer ??
(_siteDeterminingAnalyzer = new SiteDeterminingIonAnalyzer(DocSettings, nodePep));
}
}

public bool CanShowSiteDeterminingIons
{
get
{
var analyzer = SiteDeterminingAnalyzer;
return analyzer != null && analyzer.CanLocalize;
}
}

/// <summary>
/// True when the given choice is an ion that <em>uniquely localizes</em> the modification,
/// i.e. no other positional placement produces it (producing-set size == 1). For placements
/// that cannot be resolved (e.g. the interior of a serine run) no ion is unique, so the
/// filtered list is legitimately empty.
/// </summary>
public bool IsSiteDeterminingChoice(DocNode choice)
{
var analyzer = SiteDeterminingAnalyzer;
return analyzer != null && choice.Id is Transition transition &&
analyzer.IsUniqueToPrecursor(transition);
}

public string GetSiteDeterminingTip(DocNode choice)
{
var analyzer = SiteDeterminingAnalyzer;
if (analyzer == null || !(choice.Id is Transition transition))
return null;
var mod = analyzer.GetResolvedModification(transition);
return mod?.Name;
}

#endregion

#region ITipProvider Members

public override bool HasTip { get { return base.HasTip || !ShowAnnotationTipOnly; } }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@
<data name="LinearFit">
<value>Linear Fit</value>
</data>
<data name="LocalizationIsomerCount">
<value>Localization Isomer Count</value>
</data>
<data name="Log2FoldChange">
<value>Log 2 Fold Change</value>
</data>
Expand Down Expand Up @@ -855,6 +858,9 @@
<data name="ModelScore">
<value>Model Score</value>
</data>
<data name="ModificationLocalizationGroup">
<value>Modification Localization Group</value>
</data>
<data name="ModifiedAreaProportion">
<value>Modified Area Proportion</value>
</data>
Expand Down
Loading