When working with complex molecular models, labels can help interpret specific molecular features—residues, atoms, functional groups, and more. But when there are too many of them, labels may hinder rather than help. Efficiently toggling label visibility becomes essential, especially when preparing presentations or focusing on a subset of your structure.
If you’re using SAMSON, you can manage label visibility programmatically thanks to the powerful Node Specification Language (NSL). In this post, we’ll explain how to control label visibility using NSL, especially with attributes like visible, visibilityFlag, and hidden. These capabilities are particularly useful in tasks where clarity and precision are essential.
Why manage label visibility?
Consider a few common scenarios you probably face as a molecular modeler:
- You’re zooming into a catalytic site and want to hide distracting labels from the rest of the molecule.
- You’re preparing figures for a publication and need to emphasize specific parts of a molecule using a few annotations only.
- You’re working interactively with collaborators or students and want the screen to stay uncluttered and focused.
Instead of toggling label visibility one by one through the GUI, NSL provides a fast and programmatic way to do this.
The key attributes
Let’s explore three visibility-related attributes you can use in the label (or la) attribute space in NSL.
la.v – visible
Determines whether a label node is currently visible.
Examples:
la.v– selects all visible labelsnot la.v– selects all labels that are currently hidden
la.vf – visibilityFlag
This attribute lets you test or set the flag that controls whether the label is visibly active. It’s different from visible in that it represents the user-specified intent, rather than the final visibility state (which might depend on parent nodes).
Examples:
la.vf true– selects labels with visibility flag turned onla.vf false– selects those with it turned off
la.h – hidden
This attribute is inherited from the general node attribute set and specifies whether the label is hidden. It can be useful for quickly filtering out labels that are not currently displayed.
Examples:
la.h– selects labels that are marked hiddennot la.h– selects visible labels
Putting it to use
If you want to hide all labels containing the letter ‘H’ in their names, this is one possible NSL query:
|
1 |
la.n "*H*" and la.v |
You can first select all such labels and then run a command to hide them. This lets you switch between different views dynamically, greatly improving your workflow efficiency.
If you’re concerned about what each attribute actually controls or how visibility is propagated, the node-level attributes (which these are mostly inherited from) explain the behavior deeper.
Whether you’re building publication-quality visuals or annotating structures for further analysis, mastering label visibility with NSL gives you much-needed control over how your scene is rendered.
To learn more, visit the label attributes documentation page.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
