When a molecular model contains many groups, a simple question can become surprisingly tedious: Which groups contain a particular number of atoms? Which carry a certain formal charge? Which have more than a chosen number of carbons? Scanning names or inspecting groups one at a time is slow, and it is easy to overlook a candidate.
SAMSON’s Node Specification Language (NSL) lets you describe structural groups by their attributes. The key distinction is that the structuralGroup attribute space matches structural group nodes—not every kind of node in a model. Its short prefix is sg, so a query such as sg.nat > 100 refers to the number of atoms in a structural group.
Start with the question you need answered
For a count-based search, choose the attribute that corresponds to the quantity you care about. The documentation lists total atom count as numberOfAtoms (short name nat), with examples such as sg.nat > 100 and sg.nat 100:200. The first asks for groups with more than 100 atoms; the second specifies a range from 100 to 200.
Element counts can make the search more specific. Use sg.nC < 10 to test for fewer than 10 carbon atoms, or sg.nO 10:20 to specify an oxygen-count range. Similar attributes are available for hydrogen (nH), nitrogen (nN), sulfur (nS), and coarse-grained atoms (ncga). These counts are useful when a group’s name does not tell you enough, or when you want to express a structural criterion directly.
Keep charge and count separate
Structural groups also have total formal and partial charge attributes. For formal charge, sg.fc 6:8 matches groups with a value between 6 and 8. For partial charge, sg.pc 1.5:2.0 specifies a range between 1.5 and 2.0. The distinction matters: fc is formal charge, while pc is partial charge. If you are checking a charge-related property, choose the one that matches the question rather than treating the two as interchangeable.
A practical way to use these attributes is to translate your search into a precise sentence before writing the expression: “groups with 100–200 atoms,” “groups with fewer than 10 carbons,” or “groups whose formal charge is between 6 and 8.” Then compare each sentence with the corresponding NSL example. This small step helps prevent common slips, such as using a total atom count when you meant a count of one element.
Use IDs and inherited attributes for different tasks
sg.id refers to a structural group’s structure ID, not its atom count. For example, sg.id >= 10 tests for IDs greater than or equal to 10, while sg.id 5:10, 25:30 describes two ID ranges. Use this attribute when the identifier itself is relevant.
Structural groups also inherit general node attributes. These include visibility, hidden state, selection state, name, and material-related properties. For instance, sg.v checks visibility, and not sg.selected describes groups that are not selected. The inherited selected attribute has no short name in this attribute space, so use sg.selected, not a guessed abbreviation.
NSL’s short names make expressions compact, but the full attribute names are helpful while learning. The reference page includes both forms and additional examples; the broader NSL examples can help when you need to build more involved expressions.
For the complete attribute list and definitions, see the structural group attributes reference.
Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON.
