Find the Right Node Groups Without Losing Track of Their Selection State

Molecular models can contain many node groups: some are useful labels, some organize parts of a structure, and others may be selected temporarily while you work. When you need to target just one group—or avoid groups in a particular selection state—it helps to be precise about which node attributes you are querying.

SAMSON’s Node Specification Language (NSL) provides a dedicated attribute space for node groups: nodeGroup, abbreviated ng. An expression beginning with ng matches node group nodes, rather than every kind of node. This is a useful first check when a query should apply specifically to groups: the attribute prefix communicates what type of object you intend to find.

Find groups by name

Node groups inherit the name attribute from the general node attribute space. You can use its short name, n, and put the value in quotation marks. For example, ng.n "A" specifies node groups named A, while ng.n "L*" is an example of a name expression using an asterisk.

This gives you a straightforward way to make a query more specific than “find a group.” If your model uses meaningful group names, a name-based expression can help you focus on the group or naming pattern relevant to the task. Keep the quotation marks around the name value, as shown in the documented syntax.

Check selection state explicitly

Node groups also inherit selected. You can write ng.selected to refer to selected node groups, or not ng.selected to refer to groups that are not selected. One detail matters: although the general node attribute has the short name s, the node-group form does not. Use selected after ng, not ng.s.

That difference is easy to overlook when moving between attribute spaces. If a selection-related expression is not behaving as expected, check both the attribute name and the node type prefix. For node groups, the documented expression is ng.selected.

Do not confuse selected with selectionFlag

The page lists another inherited attribute, selectionFlag, with the short name sf. Its examples are ng.sf and ng.sf false. These are separate attribute names in the NSL reference. When writing a query, choose the one that matches the state you intend to test; do not substitute one for the other just because both names mention selection.

A practical way to avoid mistakes is to build the expression in small steps: first specify the node-group space with ng, then add the attribute you want to test, and finally add a value if the syntax calls for one. For example, compare the documented forms ng.selected, not ng.selected, ng.sf, and ng.sf false. This makes it easier to see whether you are querying the selected state or the selection flag.

In short: use ng.n when identifying groups by name, ng.selected when checking selection, and ng.sf when querying the selection flag. The complete reference, including the inherited attributes, is available in the SAMSON node group attributes documentation.

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

Comments are closed.