You click an atom in a molecular scene and it appears selected—but its own selection flag is false. Or a node’s visibility flag is on, yet the node is hidden. These apparent contradictions often come from the hierarchy: in SAMSON, a node’s effective state can depend on its ancestors, not only on its own flag.
That distinction matters when you are trying to find, inspect, or troubleshoot parts of a molecular model. The Node Specification Language (NSL) provides two useful kinds of queries: one for a node’s effective state, and another for its own stored flag.
Effective state versus the node’s own flag
For selection, node.selected (short form n.s) matches nodes that are selected because their selection flag is true or because an ancestor’s selection flag is true. By contrast, node.selectionFlag (short form n.sf) checks the flag on the node itself.
For example, these queries answer different questions:
n.sfinds nodes that are selected, including through an ancestor.n.sf truefinds nodes whose own selection flag is set to true.n.sf falsefinds nodes whose own selection flag is false—even if an ancestor’s flag means they still count as selected.
This difference is useful when a broad selection on a group or structural parent affects many descendants. If you want to understand what is selected in practice, query n.s. If you are investigating which nodes have their own selection flags set, use n.sf.
The same pattern applies to visibility and locking
Visibility has a similar distinction. node.visible (n.v) matches nodes whose visibility flag is true and whose ancestors are visible. node.visibilityFlag (n.vf) checks the node’s own flag. Meanwhile, node.hidden (n.h) matches nodes hidden by their own visibility flag or by an ancestor’s flag.
So if an object seems to have visibility enabled but does not appear in the scene, checking only n.vf may not reveal the cause. Try the effective-state query n.v or its counterpart, n.h, to account for the hierarchy.
Locking works in the same way: node.locked (n.l) includes nodes locked because of their own flag or an ancestor’s flag, whereas node.lockedFlag (n.lf) checks the node’s own flag. Use n.l to find nodes that are locked in effect, and n.lf true to identify nodes with their own locked flag set.
A practical way to narrow a query
When searching a large structure, combine a node type or category with the state you care about. For example, n.t a in n.c lig identifies atoms in ligands. To focus on selected ligand atoms, add the effective selection condition:
n.t a in n.c lig and n.s
This separates the question “which atoms belong to ligands?” from “which of those atoms are selected?” You can use the same approach with visibility, locking, or other node attributes. For instance, n.t a in n.c lig and n.v narrows the search to visible ligand atoms.
A helpful rule of thumb: use selected, visible, and locked when you care about the state a node has in the hierarchy. Use selectionFlag, visibilityFlag, and lockedFlag when you need to inspect the node’s own flag. For materials, the distinction is also explicit: n.hm matches nodes that have a material through ownership or inheritance, while n.om matches nodes that own one.
For the full list of node attributes and examples, see the SAMSON node attributes reference.
Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON.
