If you’ve worked with complex molecular models in SAMSON, you know the importance of managing selections precisely. Whether you’re applying simulations or merely reorganizing your design, selecting the right node groups—without affecting too many unrelated parts—can be key to your success.
One often overlooked but highly effective tool for refining model selections is the use of node group attributes in the Node Specification Language (NSL). This post walks you through how to use simple yet powerful attributes to pinpoint node groups with precision.
Why node group attributes are useful
Node groups in SAMSON are containers for organizing other nodes, such as atoms, residues, or other groups. When you’re constructing complex systems or analyzing large biomolecules, you frequently rely on grouping mechanisms. Efficiently targeting these groups—without manually clicking through the GUI—can drastically improve your speed and accuracy.
This is where NSL comes into play. By using node group attributes, you can programmatically specify which groups you wish to interact with, using a structured yet readable syntax.
Where the attributes live
All node group attributes are accessed in the nodeGroup attribute space, which can be abbreviated as ng. These attributes only apply to node groups, so they won’t inadvertently affect individual atoms or bonds.
A closer look: name, selected, and selectionFlag
| Attribute | Short name | Values | Examples |
|---|---|---|---|
| name | n |
Strings (quoted) | ng.n "A"ng.n "L*" |
| selected | (none) | true, false |
ng.selectednot ng.selected |
| selectionFlag | sf |
true, false |
ng.sf falseng.sf |
Use Case: Selecting node groups with a specific name pattern
Suppose you’re working with a protein-ligand complex, and your system includes node groups named Ligand_A, Ligand_B, and so on. If you want to select all of these for export or coloring, you can use:
|
1 |
ng.n "Ligand_*" |
This matches all node groups whose name starts with Ligand_. The wildcard character * matches any sequence of characters, making it easy to batch-process node groups with patterned names.
Use Case: Filtering based on selection state
If you only want to apply changes to node groups that are currently selected in your workspace, just use:
|
1 |
ng.selected |
Alternatively, to target node groups that are not selected, use:
|
1 |
not ng.selected |
This is particularly useful when toggling visual properties or structure settings without disturbing certain groups you’ve already configured.
Use Case: Distinguish intent with selectionFlag
The selectionFlag (short name: sf) is another subtle but useful tool. Whereas selected refers to the current selection state in SAMSON’s workspace, selectionFlag lets you track and modify intended selection tags in your scripts. This distinction can enable workflows where state and purpose need to be separated, especially when scripting batch operations.
Putting it all together
You can of course combine these attributes. For example, to select all node groups starting with “L” that are not currently selected:
|
1 |
ng.n "L*" and not ng.selected |
By creatively combining conditions, you can create highly targeted selection filters without needing to sift through your interface manually.
To learn more and access detailed documentation, visit the official NSL node group attribute page.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
