Find the right molecular groups without counting atoms by eye

When a molecular model contains many structural groups, finding the one you need by inspecting each group can become tedious. Is it the group with a particular number of oxygen atoms? A high total formal charge? A specific structure ID? SAMSON’s Node Specification Language (NSL) lets you describe these criteria as expressions, so you can match structural groups by their properties instead of relying on visual inspection alone.

This is especially useful when your first question is about composition, size, or charge. The structural-group attribute space is written structuralGroup, with the short prefix sg. For example, sg.nO refers to the number of oxygen atoms in a structural group. The prefix matters: these expressions match structural group nodes, not every kind of node in a model.

Start with a count

Atom counts are a straightforward way to narrow down groups. The general attribute sg.nat counts atoms, while element-specific attributes include sg.nC for carbon, sg.nH for hydrogen, sg.nN for nitrogen, sg.nO for oxygen, and sg.nS for sulfur. The attribute sg.ncga counts coarse-grained atoms.

You can use a comparison or a range. For example, sg.nat > 100 matches groups with more than 100 atoms, while sg.nO 10:20 matches groups with 10 to 20 oxygen atoms. A small group can be queried with sg.nC < 10. These expressions turn a vague visual search—“somewhere in this model there’s a group with lots of oxygen”—into a criterion you can state explicitly.

Use charge to narrow the search

Composition is not always enough. Structural groups also have total formal-charge and total partial-charge attributes. Use sg.fc for formal charge, which accepts integer values, and sg.pc for partial charge, which accepts real values. For instance, sg.fc 6:8 describes groups with formal charge between 6 and 8, while sg.pc 1.5:2.0 describes groups with partial charge in that range.

These are different properties, so choose the one that matches the question you are asking. If you need an integer formal-charge threshold, the documentation gives sg.fc > 1 as an example. If you are inspecting partial charge, a decimal range such as sg.pc 1.5:2.0 is appropriate. Keeping the distinction clear helps avoid treating two different charge measures as interchangeable.

Find a group by its structure ID

If you already know the structure ID, sg.id can match it directly. For example, sg.id 1 selects groups with ID 1, and sg.id >= 100 matches IDs greater than or equal to 100. You can also specify multiple ranges: sg.id 10:20, 30:40.

A practical way to build a query

  1. Decide what you know about the group: its size, elemental composition, charge, or ID.

  2. Choose the matching attribute, such as sg.nat for total atom count or sg.nO for oxygen count.

  3. Write a clear comparison, value, or range, following the documented forms—for example, sg.nat 100:200 or sg.pc > 1.5.

  4. Check that you are querying structural groups with the sg prefix, rather than assuming the same expression targets individual atoms.

Structural groups also inherit node attributes, including name, visibility, hidden state, and selection state. These can help describe or identify groups too: examples include sg.n "A", sg.v for visible groups, and not sg.selected for groups that are not selected. The full reference lists the available attributes and their short names.

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

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

Comments are closed.