Three Checks Before You Filter Node Groups in SAMSON

When a molecular model gets crowded, finding the right group can be harder than finding the right atom. A name may look familiar, a selection may already be active, and a query that works for one kind of node may not match another. SAMSON’s Node Specification Language (NSL) provides a dedicated attribute space for node groups, which helps make the target of a query explicit.

Start by naming the target type

Node group attributes live in the nodeGroup attribute space, abbreviated ng. That space matches only node group nodes. Starting an expression with ng is therefore a useful way to make your intention clear: you are describing group nodes, rather than writing a general node query.

This distinction is valuable when you are organizing a model into groups and want to inspect or work with those groups by name or selection state. It also gives you a quick diagnostic question when a query does not return what you expected: is the thing you want to match actually a node group?

Check the name attribute

For group names, use ng.name or its short form, ng.n. Values are written as strings in quotes. The reference gives these examples:

  • ng.n "A"
  • ng.n "L*"

Keeping the value in quotes makes it clear that you are supplying a name string. If a name-based query does not match, check both parts: the attribute should be in the ng space, and the value should be quoted. The documentation includes "L*" as an example, but consult the NSL examples or test your expression in your workflow if you need to confirm how a particular pattern behaves.

Do not confuse selection with a short name

Node groups inherit the selected attribute from nodes, but there is an important exception: for node groups, selected has no short name s. Use the full expression ng.selected to refer to that attribute. The reference also shows the negated form not ng.selected, which is useful when you want to express the opposite selection condition.

This detail can prevent a frustrating mismatch when shortening expressions. The node attribute space has a short name for selected, but the node group reference explicitly says that short name is not available here. When writing a group query, prefer the documented full form instead of assuming a shorthand carries over.

Keep selectionFlag separate

Node groups also inherit selectionFlag, abbreviated sf. The documented examples are ng.sf and ng.sf false; its possible values are true and false. This is a separate attribute from selected, so do not substitute one for the other simply because both sound related to selection. Choose the attribute that corresponds to the state you intend to query, and use the spelling and value form shown in the reference.

A quick preflight for group queries

  1. Confirm the target: use ng when you want to match node group nodes.
  2. Confirm the attribute: use ng.n or ng.name for names, ng.selected for selected state, and ng.sf for selectionFlag.
  3. Confirm the syntax: quote name strings; use true or false for Boolean values where needed; and remember that selected has no node-group short name.

These checks are small, but they help separate three common sources of confusion: the kind of node being matched, the attribute being queried, and the syntax expected by that attribute. 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.