When building or analyzing molecular animations, it’s common to need precise control over which elements are visible at any time. Whether you’re setting up an educational molecular movie or examining only key parts of a simulation, clutter can get in the way of clarity. Fortunately, SAMSON’s Node Specification Language (NSL) offers a clean and consistent way to manage visibility through the animation attribute space.
In this post, we explore how the visible, visibilityFlag, and hidden attributes can be used together effectively. These attributes are available in the animation (short name: an) attribute space, which targets animation nodes. They help you control what is shown or hidden in your animations—without needing to manually click through menus in the user interface.
Common Scenario
Imagine you’re working on a molecular dynamics animation and want to hide non-essential frames or highlight a specific conformational state. Instead of doing this manually for each frame, NSL lets you filter or select nodes programmatically.
The Key Attributes
visible (v): Indicates whether a node is currently visible (e.g.,an.vornot an.v).visibilityFlag (vf): A flag that controls whether a node’s visibility can be toggled.hidden (h): A legacy way to declare whether a node is hidden (e.g.,an.h true).
Putting It Together
If you’re trying to create an animation that shows only visible nodes, you could write a query like:
|
1 |
an.v |
To explicitly hide all nodes with a certain name, you can combine name matching with visibility control:
|
1 |
an.n "Ligand*" and not an.v |
This would match any animation node whose name starts with Ligand and is currently invisible.
Why Use Both visible and visibilityFlag?
The visible attribute reflects current visibility, while visibilityFlag determines whether that visibility can be changed by the system or user interaction. By using both, you can create more robust selections. For example:
|
1 |
an.vf and not an.v |
This returns nodes that are allowed to be visible but are currently not shown.
Legacy vs. Current Approaches
The hidden attribute is inherited from the general node attribute space and is still supported, but it is more intuitive to use visible (+ not) in most queries. For clarity, it’s good practice to standardize around an.v when writing new queries. For example:
|
1 |
not an.v |
This syntax is easier to read and understand compared to an.h true.
Benefits
Not only does using NSL for visibility control help make your animations clearer, but it also saves time. You can quickly find, hide, or reveal molecular elements based on any string pattern or property match. This is especially helpful when working with complex or time-dependent systems.
For more details, visit the original documentation page.
SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON here.
