Quickly Hiding and Showing Labels in SAMSON with NSL

Efficient molecular modeling often depends on clarity and focus — especially when working on complex systems packed with annotations and visual markers. In SAMSON, molecular modelers frequently use labels to track properties, monitor molecular dynamics, or assist in group-based selections. However, as your system becomes more intricate, label clutter can significantly reduce visual clarity.

Fortunately, SAMSON’s Node Specification Language (NSL) offers a precise way to manage label visibility using attributes like la.visible, la.hidden, and la.visibilityFlag. These attributes allow you to show, hide, or filter labels efficiently — directly from queries or scripting. This post shows how to take advantage of these tools.

Understanding Label Visibility in NSL

To target label nodes specifically in your queries, use the la (label attributes) namespace. This filters out unrelated nodes and ensures you manipulate only the labels.

There are several attributes available, but for visibility control, three are especially useful:

  • la.visible (short name: v) – tells whether a label is currently visible in the viewport.
  • la.hidden (short name: h) – represents whether the label was explicitly hidden. Useful for overriding view settings.
  • la.visibilityFlag (short name: vf) – controls whether the node’s visibility is determined by its own settings or a parent group.

Use Case: Managing Label Clutter While Exploring Molecular Dynamics

Let’s say you’re simulating a protein-ligand binding and you’ve used labels to tag specific residues, binding energies, or distances. Over time, these labels may clutter your visuals. Disabling all one by one through the UI is not efficient.

Instead, you can write a simple NSL query in the search bar or scripting interface:

This query selects all currently visible labels. You can then toggle their visibility off in one command or via a batch script. To do the inverse and select hidden labels:

To force-hide all labels regardless of group settings, you can modify their hidden state:

To unhide them again:

If you are unsure whether label visibility is being driven by inheritance from a parent node (like a group node), query the visibilityFlag attribute. For example:

This returns labels whose visibility is not dictated by their parent group — ideal for finding labels behaving unexpectedly.

Visual Example

The following table shows how these attributes map to common queries and their meaning:

Label attributes table

Tips

  • Use short names like la.v, la.h, or la.vf in scripts for efficiency.
  • Combine with logical operators to fine-tune your selections, e.g., la.v and not la.selected.
  • If needed, prefix attributes with not to easily negate visibility conditions.

By learning to use these NSL visibility attributes, you can enhance both your focus and presentation in SAMSON, especially when handling complex or time-sensitive molecular systems.

Want to dig deeper into all label attributes in NSL? Visit the full documentation page here: https://documentation.samson-connect.net/users/latest/nsl/label/

SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON at https://www.samson-connect.net.

Comments are closed.