When working with complex molecular systems, it doesn’t take long before your document in SAMSON fills with an overwhelming number of nodes—atoms, molecules, groups of molecules, visual models, annotations. Organizing and selecting them effectively can quickly become a challenge, especially when trying to automate tasks through NSL (Node Specification Language).
A lesser-known but effective way to simplify selection management is by using selectionFlag on node groups. This blog post focuses on the ng.sf attribute within SAMSON’s NSL to help you streamline node selection and clarify workspace logic for simulations, visualization, and script automation. 🎯
What Are Selection Flags?
Selection flags add a layer of control beyond manually picking groups of nodes. Think of them as programmable bookmarks. Instead of relying on visual selection or naming alone, selectionFlag allows you to tag node groups and later act on them as a batch.
In NSL (Node Specification Language), selection flag is inherited from the base node structure but still available for node group queries. Here’s how it works:
|
1 2 |
ng.sf // Select all node groups with selectionFlag true ng.sf false // Select all node groups with selectionFlag false |
You can combine this with other attributes like name or selection status:
|
1 |
ng.n "Protein*" and ng.sf |
This selects all node groups whose name begins with “Protein” and that have a selection flag set.
Why Is This Useful?
- Script-friendly selection: When scripting simulations or visualizations, you don’t want to depend on what’s currently selected. Selection flags offer stability.
- Intermediate filtering: Filters become more powerful when you decouple visible selection from internal tagging.
- Flexible automation: With selection flags, you can predefine groups of nodes to be modified, exported, or visualized together.
For example, in preparation for a trajectory export, you might run a script that only exports node groups with selection flag true. This makes the workflow much more predictable and reduces the potential for error.
Practical Scenarios
- Setting up simulations: Use
selectionFlagto identify key structural groups like ligands or active sites for special treatment. - Layered visualizations: Highlight or hide entire node groups programmatically based on the flag value.
- Batch processing: Apply operations (energy minimization, coloring, etc.) only to flagged node groups.
Compare with Manual Selection
Traditionally, selecting via the GUI or assigning distinctive names has been standard. But names can overlap, and manual selection is error-prone. Flags persist programmatically and can be batch-edited, making them a robust alternative. In large workflows where scripts are reused or automated across different structures, relying on selected or name alone can be vague or misleading. selectionFlag acts as a precise, script-targeted toggle switch.
Try It Out
You can test this in SAMSON’s search bar using the NSL queries shown in this post. Experiment by assigning flags to different node groups and confirming which ones are picked out by your queries. This also helps debug scenes where too many nodes are accidentally affected by batch operations.
To learn more, visit the official documentation: Node Group Attributes in NSL
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
