When working with complex molecular systems in SAMSON, it’s common to organize nodes into groups to simplify selection and manipulation. Whether you’re modeling biomacromolecules or designing nanosystems, node groups help provide structure. But once your model grows, quickly identifying or selecting precise node groups can become tricky—especially if their names follow certain patterns or are partially known only.
This is where the node group attributes in NSL (Node Specification Language) become especially useful. With the nodeGroup attribute space (accessible via the short name ng), you gain fine-tuned control over filtering and targeting specific node groups for further operations.
Matching Node Group Names
If you’ve named your node groups with a logical naming convention—say Ligand_A, Ligand_B, …, or Receptor_1, Receptor_2, etc.—you can leverage the name attribute (ng.n) to match groups with specific names or patterns.
For example:
|
1 |
ng.n "Ligand_A" |
would select only the node group whose name is Ligand_A. But to match multiple ligands with a shared prefix, you can write:
|
1 |
ng.n "Ligand_*" |
This flexibility saves time scrolling through long lists or clicking through the document tree, especially when working with large systems or numerous entities.
Combining with Selection State
You can also refine your selection based on whether a node group is currently selected or not. This is useful when you want to isolate only groups actively worked on, or to act on those not yet selected.
The selected attribute works as follows:
|
1 |
ng.selected |
… selects all node groups that are currently selected.
While…
|
1 |
not ng.selected |
…returns all node groups that aren’t selected.
Note that this attribute is inherited from the generic node attribute space, but it does NOT have a short name like it does there (in node, short name is s, but not in nodeGroup).
Managing Selection States with selectionFlag
Another useful filter is selectionFlag, accessible as ng.sf. This attribute checks or sets the selection flag state of a node group, distinct from whether it is currently selected. This is useful for scripting selection workflows, for example, to exclude previously flagged groups:
|
1 |
ng.sf false |
This expression selects all node groups that are not flagged. Helpful when batch processing newly added groups while avoiding interference with previously handled ones.
Why It Matters
Efficiently finding and modifying node groups using NSL unlocks powerful workflows in SAMSON. It reduces the amount of manual searching and clicking, and boosts reproducibility—especially when you’re writing queries repeatedly during simulations, visualizations, or preparing publication figures.
Whether you’re selecting ligand groups to calculate interaction energies, modifying materials in a nanosystem, or simply cleaning your document tree, learning to use ng.n, ng.selected, and ng.sf is a small investment with long-term rewards.
For the full documentation on node group attributes in NSL, visit the official page.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
