Visual clarity is critical in molecular modeling. When working with complicated systems that include hundreds or thousands of labeled nodes—atoms, residues, fragments—it’s easy to lose focus. That’s why being able to precisely control which elements are currently shown is essential.
If you’re a SAMSON user, you may already know about the Node Specification Language (NSL), which provides a powerful way to filter and manipulate molecular structures. Today, we’ll look at a focused use case: efficiently managing label visibility using NSL’s label attribute space.
Why label visibility matters
Whether you’re preparing visuals for a presentation, analyzing structural details, or scripting a repeatable operation, it’s often useful to automatically hide or show only a subset of labels—such as those that meet specific criteria. Doing this manually can be slow and prone to error. With NSL, you can do it programmatically and reproducibly.
The label attribute space (la)
The NSL defines a dedicated attribute space for labels, abbreviated as la, that includes primary attributes like:
la.v: visibilityla.h: hidden statusla.vf: visibility flagla.sf: selection flagla.selected: selection statusla.n: name of the label (supports string matching)
You can use these attributes to filter label nodes and apply batch operations. For example:
|
1 2 3 4 |
la.v // selects all visible labels not la.v // selects all labels that are not visible la.n "H*" // selects all labels with names starting with 'H' la.vf false // selects all labels with the visibility flag disabled |
Practical use cases
Here are a few real-world inspired scenarios researchers might face and how to solve them using NSL.
📌 Case 1: Hide all labels except those starting with ‘N’
This can come in handy when you only want to see specific functional groups or residues:
|
1 |
not la.n "N*" |
Select this group and hide it using the standard SAMSON hide command.
📌 Case 2: Show only currently selected labels
|
1 |
la.selected |
Now only the labels corresponding to your active selection are shown—useful for focusing your analysis.
📌 Case 3: Automatically hide unimportant labels
Say you’re working on an image or animation and want to reduce clutter:
|
1 |
not la.v |
This helps you quickly toggle visibility across the entire scene.
Notes on behavior
Some label attributes behave slightly differently from their node counterparts:
- The
selectedattribute exists but does not have a short name. - You can use wildcards in string matching with
la.n, which is helpful for grouped names like chain identifiers.
These distinctions allow you to refine your target selections and operations even further.
Wrapping up
NSL’s attribute-based querying system offers a clean, readable, and powerful way to keep control over your molecular scenes. By filtering and modifying label node visibility from the command line or scripts, you can streamline your workflow and focus only on what matters in your model.
To see the full documentation on label attributes in NSL, visit the NSL label documentation page.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
