When a Selection Misses: A Practical Guide to Querying Node Groups

A molecular model can contain many kinds of objects, and a query that works for one kind may not match another. One common source of confusion is searching for a node group without specifying that the target is a node group. SAMSON’s Node Specification Language (NSL) provides a dedicated attribute space for this: nodeGroup, abbreviated ng.

The key detail is scope: an expression in the ng attribute space matches node group nodes only. If your query is meant to find a group, start with ng attributes rather than assuming that a general node expression will identify the right object. This simple check can save time when a selection appears to return nothing—or returns a different kind of node than you intended.

Find groups by name

Node groups inherit the node name attribute. Its short name is n, and values are written as quoted strings. For example:

  • ng.n "A" uses the short name to query a group named A.
  • ng.n "L*" is another documented name-expression example.

Keep the quotes around the name value: they make clear that the value is a string. If a name-based query does not match what you expect, check the spelling and punctuation of the group name, confirm that you are querying node groups, and consult the NSL name-matching rules before assuming that a special character has a particular meaning.

Check selection state

Groups also inherit two boolean attributes: selected and selectionFlag. They are separate attributes, so choose the one that corresponds to the state you want to inspect.

  • ng.selected tests for selected node groups.
  • not ng.selected expresses the opposite condition.
  • ng.sf uses the short name for selectionFlag.
  • ng.sf false explicitly tests for a false selection flag.

There is a small syntax difference worth remembering: selected has no short name in the node-group attribute space. Use ng.selected, not ng.s, when expressing this condition for groups. By contrast, selectionFlag can be shortened to sf.

A quick troubleshooting routine

  1. Confirm the object type. Is the thing you want to match a node group? The ng space is limited to node groups.
  2. Start with one attribute. Try a name expression such as ng.n "A", or inspect selection state with ng.selected.
  3. Check the exact syntax. Keep string values quoted, use the documented sf abbreviation only for selectionFlag, and remember that selected has no short form here.
  4. Separate the questions. First check whether the group name matches; then check whether its selected state or selection flag is the condition you intended. This makes it easier to locate which part of a query needs attention.

These attributes are inherited from the general node attribute space, but the ng prefix narrows the target to node groups. Thinking in terms of both what kind of object? and which attribute? makes NSL queries easier to read and troubleshoot, especially in structures with many nested or similarly named components.

For the complete attribute reference and additional context, see the SAMSON node group attributes documentation.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON.

Comments are closed.