In large molecular modeling projects, it’s often challenging to keep track of which structural models are currently selected and visible — especially if you’re navigating complex biomolecular systems. Being able to quickly filter, identify, and operate only on relevant models can significantly streamline your workflow.
That’s where the selection-related attributes of the Node Specification Language (NSL) in SAMSON come in handy. NSL allows you to write concise expressions to target exactly what you need among your models.
Common User Pain: Lost in the Model Forest?
If you’ve ever tried to operate on a specific selection within a project containing dozens (or hundreds) of molecular models, fields, or visual elements, you know how easily one can get lost. Manually selecting or deselecting items in the interface can become a time-consuming process—especially when automation is possible.
Using the selected, selectionFlag (sf), visibilityFlag (vf), and visible (v) attributes of the structuralModel attribute space, you can gain precise control over your models—without pointing and clicking or searching through lists.
What Are the Selection Attributes?
selected: Tells whether a model is currently selected. No short form, so usage issm.selected.selectionFlag(sf): Indicates if the model is flagged for selection operations. You can usesm.sforsm.sf falseto test for true or false values.visibilityFlag(vf): Similar toselectionFlag, but relates to visibility control.visible(v): Tells whether the model is currently visible in the viewport. You can usesm.vor negate it withnot sm.v.
Practical Use Cases
Here are some examples of how you might use these attributes in your selection expressions:
sm.selected: Targets all structural models that are currently selected.not sm.selected: Finds models that are not selected.sm.vf: Selects all models with visibility flag set to true (commonly manipulated by toggling visibility).sm.v: Targets models that are currently visible in the viewport.not sm.v: Quickly isolate hidden models, e.g., for cleanup or further inspection.
Why It Matters
Using NSL search syntax avoids wasted clicks and tedious filtering. You can apply materials only to selected and visible models, or verify how many models currently match certain visibility and selection states. It’s especially useful in automated scripts and workflows where manual interaction is impractical or error-prone.
For example, you might combine filters to look for visible but not selected models with:
|
1 |
sm.v and not sm.selected |
Or select only the models currently hidden from view:
|
1 |
not sm.v |
Visibility vs. Flag
Note that visible and visibilityFlag differ: sm.v reflects what’s actually visible, while sm.vf is a flag that might be used in the process of determining visibility. Though usually they align, keeping this distinction in mind can help troubleshoot complex visibility rules or scripted behavior.
Ready to Explore More?
This short guide highlights the ease of filtering models through selection and visibility control in SAMSON using NSL. These are small but powerful steps towards automating and controlling complex molecular scenes.
To learn more about the full range of options in the structuralModel attribute space, check out the official documentation: NSL documentation for structural models.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
