Selecting Node Groups in SAMSON: A Guided Look at Useful Attributes

When working on complex molecular systems in SAMSON, focusing on the relevant parts of your model can help you avoid getting overwhelmed by visual clutter. One way to streamline this process is by understanding how node groups and their attributes work in the Node Specification Language (NSL).

Node groups act as containers that bundle related elements in your model, such as atoms, molecules, or custom selections. Knowing how to precisely select node groups using NSL can make model organization and automation significantly more efficient. This blog post explores how to use nodeGroup attributes to filter and select node group nodes based on their name, selected status, and selectionFlag.

Understanding the Namespace

In NSL, node group-related attributes are scoped into a distinct attribute space, nodeGroup (short name: ng). This namespace matches only node group nodes. For example, if you want to filter only node group nodes that start with a specific name, such as “Ligand”, you can write:

This will match any node group whose name begins with “Ligand”. It’s a simple yet powerful way to select meaningful substructures.

The name Attribute

The name attribute filters node groups by their name. Since it is inherited directly from the general node space, it accepts strings in quotation marks:

Using wildcards like * makes this attribute particularly useful when dealing with systematic naming conventions or hierarchical naming patterns in larger models.

The selected Attribute

This boolean attribute checks whether a node group is currently selected. For instance:

returns all node groups that are currently selected, while

returns node groups that are not selected. This is useful for scripting logic where your operations apply to either selected or unselected groups.

It’s worth noting that unlike its node counterpart, nodeGroup.selected does not have a short form like s.

The selectionFlag Attribute

Inherited from the node.selectionFlag attribute, selectionFlag identifies whether a node group is tagged with the selection flag:

This flag can be set programmatically or through user actions and is especially useful in more advanced scenario scripting. For example, you might use it to track temporary selections during interaction or automation workflows.

When Is This Useful?

If you routinely work with complex molecular assemblies—say, in drug discovery or protein-ligand interaction studies—being able to programmatically refer to node groups that match certain names or selection states is a major time-saver. Rather than endlessly clicking through visual components, you can precisely define what you want and act on it with a single query.

It also helps ensure reproducibility. Snapshot queries (like ng.n "Ligand*" and ng.selected) can be recorded and reused in Jupyter notebooks or automation scripts to recreate your work or apply it to new structures.

All of this makes the modest-looking nodeGroup space worth mastering, especially for anyone looking to scale up their use of SAMSON in molecular modeling workflows.

To explore more about node group attributes in NSL, visit the official documentation: https://documentation.samson-connect.net/users/latest/nsl/nodeGroup/

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

Comments are closed.