In molecular modeling projects, it’s common to group elements—such as atoms, residues, or entire molecular domains—for better control and visualization. With larger molecular models, efficiently selecting and working with these groups can become cumbersome, especially if you need to apply filters or interact programmatically with groups rather than individual elements.
This is where the Node Specification Language (NSL) in SAMSON can be particularly helpful. NSL gives users the descriptive power to target specific subsets of a model, including node groups, using simple, readable commands. This blog post introduces you to node group attributes and how they can simplify node selection in your modeling workflow.
What is a Node Group?
In SAMSON, a node group represents a collection of nodes that are grouped together. This may be for organizational purposes, for performing collective operations, or for visualization. To work with node groups in NSL, we use the nodeGroup attribute space, abbreviated as ng.
Filtering Node Groups
The ng space provides access to several useful attributes for filtering:
name(n): String-based name of the node group (e.g.,ng.n "Ligands"orng.n "L*"to use wildcards).selected: A boolean attribute indicating if the group is currently selected in the user interface. This attribute must be used with the full syntax (since there’s no short name).selectionFlag(sf): Another boolean that reflects internal selection flags used in scripting or during more advanced interactions.
These attributes make it easier to work with specific collections of elements in complex models. For example, to filter for all node groups starting with the letter “L” and currently selected, you might write:
|
1 |
ng.n "L*" and ng.selected |
Or to find all node groups that are *not* currently selected:
|
1 |
not ng.selected |
Why It’s Useful
As project complexity grows, keeping track of different parts of your molecular system becomes more important. NSL provides a compact way to manage this complexity. Whether you’re scripting with NSL, building custom apps, or just navigating a large structure more comfortably in the GUI, these simple filters can improve your modeling speed and clarity.
The selectionFlag in particular is useful for distinguishing between what’s visually selected in the user interface versus what is logically selected in scripts or operations, giving you more control over conditional actions.
Examples in Practice
Suppose you have different domains of a protein grouped and named accordingly (“DomainA”, “DomainB”, etc.). You can instruct SAMSON to isolate just “DomainA” using:
|
1 |
ng.n "DomainA" |
Or apply an operation on all visually selected node groups:
|
1 |
ng.selected |
These filters can be used not just in selection, but in scripting, user commands, and even visual representations like coloring, hiding, or applying simulations to specific parts.
To learn more, visit the official documentation page: https://documentation.samson-connect.net/users/latest/nsl/nodeGroup/
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
