From “Find the Right Group” to a Useful Molecular Filter

A common modeling bottleneck is not building a molecular system—it is locating the part of it that fits a specific question. You may need to find groups with a particular atom count, inspect groups carrying a charge, or distinguish structures by ID. Browsing a large model by eye can be slow, and criteria described informally are easy to apply inconsistently.

SAMSON’s Node Specification Language (NSL) provides attributes for expressing these kinds of structural-group criteria. The key starting point is the attribute space: sg refers to structural groups, and expressions in this space match structural group nodes. That matters when you are writing a filter: choose attributes that describe the group, rather than assuming every node in a model has the same properties.

Choose the attribute that matches your question

For a size-based search, use sg.nat, the short name for numberOfAtoms. For example, sg.nat < 1000 describes groups with fewer than 1,000 atoms, while sg.nat 100:200 describes a range from 100 to 200. A range can be more useful than a single exact count when you are screening for candidates rather than checking one known structure.

If the relevant question is about composition, use the element-count attributes instead. The documented short names are sg.nC for carbons, sg.nH for hydrogens, sg.nN for nitrogens, sg.nO for oxygens, and sg.nS for sulfurs. For instance, sg.nO 10:20 expresses an oxygen-count range. There is also sg.ncga for the number of coarse-grained atoms, which is distinct from the total atom count.

Keep formal and partial charge separate

Charge criteria have two different attributes. sg.fc checks total formal charge; sg.pc checks total partial charge. They are not interchangeable. The documentation shows sg.fc 6:8 for a formal-charge range and sg.pc 1.5:2.0 for a partial-charge range. When translating a chemistry question into a filter, first decide which charge definition you intend to use. The page describes partial-charge values as real numbers and formal-charge values as integers.

Use IDs and inherited attributes deliberately

sg.id refers to a structural group’s structure ID. It can identify a particular ID, select IDs greater than or equal to a threshold, or describe multiple ranges—for example, sg.id 5:10, 25:30. This is useful when you already have ID-based criteria, but it is different from filtering by chemical composition or atom count.

Structural groups also inherit general node attributes. These include sg.n for name, sg.v for visibility, sg.h for hidden state, and sg.hm and sg.om for material-related checks. You can also test selection-related state with sg.selected or sg.sf. One small detail worth remembering: selected has no short name in this attribute space, so use the full form rather than guessing a shorthand.

A practical way to build a filter

Start by stating the question precisely: Is it about group size, the count of a particular element, charge, identity, or display/selection state? Then choose the matching attribute and express the criterion as an exact value, comparison, or range, as shown in the reference. Keeping each criterion tied to its meaning makes filters easier to review later—and helps prevent a partial-charge check from being mistaken for a formal-charge check, or a structure ID from being mistaken for a chemical property.

For the complete attribute list and additional examples, see the structural group attributes reference.

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

Comments are closed.