Depending on the size and complexity of your molecular system, selecting and filtering parts of the model can easily become one of the most repetitive and time-consuming tasks during molecular modeling. If you’ve ever found yourself endlessly clicking between interface panels to isolate specific groups in a molecular structure, SAMSON’s Node Specification Language (NSL) might be worth exploring more deeply.
In this post, we’ll take a closer look at how to simplify workflows using just a few lines of NSL, focusing on three selection attributes available in the nodeGroup context: name, selected, and selectionFlag. These tools provide a fast and flexible way to programmatically define groups of nodes without relying solely on manual selections.
Working in the nodeGroup Context
When modeling in SAMSON, a node group is a collection of nodes (atoms, molecules, etc.) that can be treated together as one entity. By specifying attributes in the nodeGroup (or short ng) context, you ensure that your query applies only to such groups.
1. Filtering by Group Name
The name attribute allows for selecting groups by name using string matching, including wildcards. This can be especially useful in projects with consistent naming conventions for chains, ligands, or simulation steps.
Examples:
|
1 |
ng.n "A" |
|
1 |
ng.n "L*" |
The first selects node groups named exactly “A”, while the second selects all whose names begin with “L” (e.g., ligands).
2. Selecting Based on Current User Selection
If you’re often manually selecting parts of the system and want to then perform actions on the full node groups to which these selected nodes belong, the selected attribute is useful.
Examples:
|
1 |
ng.selected</code> <br><code>not ng.selected |
Note: Unlike the individual node context (n), the selected attribute for groups does not have a short name, for increased clarity.
3. The selectionFlag Attribute
Sometimes, especially during scripting or iterative workflows, you need a way to temporarily tag node groups. The selectionFlag attribute, with short form sf, provides this mechanism.
Examples:
|
1 |
ng.sf</code> <br><code>ng.sf false |
This offers an efficient way to mark different groups with flags and use them later in selection logic or automation without affecting the main selection state.
Combining Attributes for Sophisticated Queries
The real power of NSL shows up when you start chaining conditions, such as querying for all unselected node groups with names starting with “L”:
|
1 |
not ng.selected and ng.n "L*" |
This type of declarative selection model saves time compared to manual browsing or scripting. It also reduces errors by allowing you to create reproducible queries with precision.
When to Use This in Practice
- To define specific ligand or domain clusters in large protein structures.
- When automating workflows and needing new targets dynamically.
- To consistently access parts of a model across multiple steps in simulations.
Learning to apply NSL in this way helps molecular modelers spend less time clicking and more time thinking about structure, function, and results.
To learn more about node group attribute selection in NSL, visit the full documentation page here: 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.
