When working with complex molecular systems, molecular modelers often face the challenge of filtering and selecting specific groups of atoms, residues, or molecules. Whether you’re visualizing individual ligand families or bulk-editing selections in a simulation, quick and accurate selection is key. Fortunately, SAMSON’s Node Specification Language (NSL) makes this easy, especially using node group attributes.
In this post, we focus on a small but powerful part of NSL: node group attributes, grouped under the nodeGroup (or ng) attribute space. This attribute space is specifically designed to work with node group nodes, allowing for precise searches and actions within molecular models grouped in meaningful ways.
Why node group attributes matter
Imagine you’re working with a hierarchical molecular system loaded in SAMSON. Instead of manually expanding one node after another to find a group named “LigandA” or check whether a group is active in a current selection, you can leverage NSL queries like:
|
1 |
ng.n "LigandA" |
This simple line will match any node group with the exact name “LigandA”. You can also use wildcards:
|
1 |
ng.n "Ligand*" |
…which returns all node groups whose names start with “Ligand”—useful for batch processing or filtering across a series of related molecules!
Diving into the attributes
The following attributes help you filter and identify node groups based on their names and selection status:
name(ng.n): Matches strings in quotes. You can use wildcards to target families of node names.selected: A boolean indicating if a node group is currently selected in the interface. Example:ng.selectedornot ng.selectedselectionFlag(ng.sf): Similar toselected, but used for querying the selection state without changing it. Example:ng.sf false
Note that selected is inherited from the general node attribute space, but unlike individual nodes, node group queries do not have a short name alias for it.
Use cases in practice
Here are a few practical examples molecular modelers may encounter:
- 🔍 Highlight all node groups starting with “L” that are not currently selected:
ng.n "L*" and not ng.selected - ✅ Check if a particular group is selected before applying edits:
ng.n "BindingSite" and ng.selected - 🧹 Deselect multiple node groups efficiently:
not ng.sf
These kinds of queries streamline workflows for users dealing with large molecular systems, saving time and reducing the risk of manual errors.
To learn more and see the full list of node group attributes and how they relate to the broader NSL framework, visit the documentation page: Node Group Attributes Documentation.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
