When working on complex molecular models, isolating specific subsets—such as ligands, modified residues, or structural domains—can be a major time-saver. The Node Specification Language (NSL) in SAMSON provides a robust way to target these subsets using attributes, and in this post, we’ll focus on one commonly needed feature: selecting node groups efficiently based on their attributes.
Many molecular modelers face a common challenge: filtering parts of their molecular system without manually scrolling through long node trees. Whether you’re preparing figures, building simulations, or managing large assemblies, extracting just the structures you need can make all the difference.
Introducing the nodeGroup Attribute Space
If you’re targeting collections of nodes—called node groups—in SAMSON, the nodeGroup attribute space (short name: ng) is the key. These are not individual atoms or molecules, but grouped nodes that may represent a selection, a result of a tool, or a custom grouping you defined earlier.
Let’s look at three key attributes you can use in this context:
- Name (
ng.n): Allows string-based filtering of groups by their names. Use wildcards to match patterns. - Selected (
ng.selected): Checks whether a node group is currently selected in the interface. - Selection Flag (
ng.sf): Returns whether the ‘selection flag’ is enabled, which is useful for scripting or pipeline setups.
Practical Examples
Here are a few real-world scenarios that make use of these attributes—and how they help you stay focused:
🎯 Filter Groups by Name
Let’s say you consistently name your ligand groups starting with L. You can target those using a wildcard:
|
1 |
ng.n "L*" |
This will match all node groups whose name begins with “L”—for example, Ligand1 or Lig1. This is especially helpful for batch processing or visual selections.
✅ Focus on Selected Groups
If you’ve selected several node groups manually in SAMSON and you want to further operate only on those, use:
|
1 |
ng.selected |
This line isolates only the groups that are currently selected, cutting down on clutter and making your next step (e.g., hiding/displaying or applying a modification) more targeted.
🔄 Invert Selections if Needed
What if you want the opposite—find everything that’s not selected? No problem:
|
1 |
not ng.selected |
That way, you can isolate background structures or verify what’s being excluded from a workflow.
🎛️ Use the Selection Flag for More Control
The selectionFlag attribute (ng.sf) serves a subtler purpose. Think of it as a programmable flag that can influence behavior in tools and scripts. You can filter based on this flag like so:
|
1 |
ng.sf true |
Or exclude flagged groups with:
|
1 |
ng.sf false |
Streamlining Your Workflow
Using these attributes avoids tedious point-and-click selections and gives you programmatic control. You can combine them with logical operators to write expressive queries like:
|
1 |
ng.n "L*" and not ng.sf |
This would find all node groups whose name starts with “L” and aren’t flagged—useful when checking for overlooked elements in a structured workflow.
In short, mastering these selection attributes helps reduce errors and improve reproducibility when handling complex molecular systems.
Want to dive deeper into what you can do in the nodeGroup attribute space? 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.
