Controlling Label Visibility in Molecular Models with NSL

When working with complex molecular models, clarity is key. Whether you’re preparing figures for publication, sharing a model with collaborators, or simply trying to declutter your workspace, the ability to selectively show or hide label nodes can make a significant difference. That’s where the Node Specification Language (NSL) in SAMSON becomes very useful.

NSL provides a powerful and succinct way to query molecular models. In this blog post, we’ll explore how to control the visibility of label nodes within SAMSON using simple NSL queries. Label nodes typically include annotations or identifiers in your model and managing their visibility can streamline both analysis and presentation.

Why control label visibility?

Label nodes can quickly accumulate, especially in large biomolecular or materials simulations. While helpful for identification and debugging, they can become overwhelming or cluttered in visualizations. You might want to hide all labels temporarily, then bring back only a subset that matches a specific condition (e.g., labels that start with a specific prefix).

With NSL, this becomes a matter of writing clear, readable expressions.

Using la.v and la.vf for visibility

To filter label nodes based on their visibility, use the la attribute space, which targets label nodes only. Here are two attributes you can use:

  • la.v – Tests whether the label node is visible in the viewer.
  • la.vf – Tests whether the visibility flag is set to true or false.

These two are subtly different. The la.vf (visibilityFlag) is a flag that controls visibility, but the la.v value results from a combination of this flag and others (such as parent node visibility), which gives you more insight when debugging display issues.

Example queries

Here’s how you might use NSL to select specific label nodes:

These examples illustrate queries you can use directly inside SAMSON’s selection mechanism or to group, modify, or export subsets of your model.

Combining with name filters

You can also pair visibility filters with name filters to refine your selection. For instance:

This is helpful if your workflow involves semantic labeling during modeling or simulation (e.g., labeling ligand-binding residues or key atoms).

Inherited but specialized

Many of these attributes are inherited from the general node attribute space, but their behavior in the context of label nodes is well-defined. For example, the selected attribute is inherited but doesn’t use a short name (s) like elsewhere, reinforcing how NSL helps you think in terms of context—another reason it’s efficient for molecular modeling workflows.

Learning a few NSL patterns can help you stay focused on your science, not on software menus.

For more patterns and attribute definitions related to label nodes, check out the documentation:

https://documentation.samson-connect.net/users/latest/nsl/label/

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

Comments are closed.