When dealing with complex molecular systems in SAMSON, it can be challenging to quickly isolate groups of nodes—such as atoms, residues, or molecules—based on specific properties. If you’re spending too much time visually scanning your models or writing repetitive selection routines, you might be underutilizing the power of SAMSON’s Node Specification Language (NSL).
This post explores how to leverage the nodeGroup attribute space in NSL to efficiently and precisely filter node groups using their attributes. This can be useful when managing large assemblies, preparing simulations, or automating repetitive tasks in your workflow.
Why the nodeGroup attribute space matters
In SAMSON, node groups are logical units that help organize different parts of a molecular model—these could be groups of atoms, residues, chains, or more abstract sets like selections or annotations. The nodeGroup attribute space (short name: ng) allows you to query only these node group entities, filtering them based on their name, selection state, and flags.
Useful attributes to know
Let’s go over the available attributes in the ng space and how to use them:
- Name
ng.n: Filter groups by their name, using exact strings or wildcards. - Selected
ng.selected: Check whether a group is currently selected (no short name for this one). - Selection Flag
ng.sf: A customizable boolean tag that can serve in marking specific groups.
Example 1: Filter by name
If you want to select all node groups whose name starts with the letter “L”, use the wildcard:
|
1 |
ng.n "L*" |
This is especially helpful when you’ve organized your model using named labels and want to retrieve all lipid groups, for example.
Example 2: Find unselected node groups
Sometimes you may want to find everything except what is currently selected. This can be achieved using:
|
1 |
not ng.selected |
Combining this with other attributes like name or selection flags can refine your filtering even further.
Example 3: Filter by selectionFlag
The selectionFlag is useful for custom tagging. Perhaps you’ve programmatically flagged certain groups and now want to retrieve all that are flagged:
|
1 |
ng.sf |
To get the ones that are not flagged:
|
1 |
ng.sf false |
Shortcuts for speed
Using short names can speed up scripting and conditional statements in NSL expressions. For example, instead of nodeGroup.name, you can use ng.n. While short names are encouraged for efficiency, note that the selected attribute does not have a short form in the nodeGroup space due to naming conflicts.
Combining expressions
Need more complex filters? You can combine expressions using Boolean logic:
|
1 |
ng.n "L*" and ng.sf |
This retrieves all node groups whose name begins with “L” and which are flagged.
When is this useful?
- Highlighting or hiding specific molecular groups based on simulation stages.
- Exporting or processing only pre-defined selections.
- Automating the detection of unique structural motifs name-tagged earlier in a workflow.
Getting comfortable with the ng attribute space can save you time and help ensure you work precisely with the right parts of your molecular design.
To learn more and explore additional attributes, visit the official documentation page.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
