Find the Segment That Matters: Practical NSL Filters for Molecular Models

Large molecular models can be difficult to inspect one segment at a time. Maybe you need to locate a long segment, compare segments by their size, or narrow your attention to a particular part of a structure. In SAMSON, the Node Specification Language (NSL) lets you describe segment-level criteria directly, so you can search by residue count, structural-group count, atom count, composition, charge, or name.

The key is to choose an attribute that matches the question you are asking. A segment is a node, and the segment attribute space (short name: s) matches segment nodes only. Some useful attributes belong specifically to segments; others are inherited from the broader node or structuralGroup attribute spaces.

Start with the size of the segment

If your first question is “Which segments contain many residues?”, use numberOfResidues, abbreviated nr:

  • segment.numberOfResidues > 100
  • s.nr > 100

The first expression uses the full attribute name; the second is its short form. Both match segments with more than 100 residues. To search by a range instead, use s.nr 100:120. This is useful when you want to focus on segments in a particular size band rather than set only a lower or upper threshold.

Residue count is not the same as the number of structural groups. For that criterion, use numberOfStructuralGroups or its abbreviation nsg. For example, s.nsg > 10 matches segments with more than 10 structural groups, while s.nsg 10:12 specifies a range. Choosing between nr and nsg helps keep the query aligned with the structural quantity you actually want to inspect.

Use inherited counts to ask more specific questions

Segments also inherit count attributes from structuralGroup. These include the total number of atoms (nat) and counts for several elements, such as carbons (nC), hydrogens (nH), nitrogens (nN), oxygens (nO), and sulfurs (nS). For instance, s.nat < 1000 selects segments with fewer than 1,000 atoms, while s.nO 10:20 specifies an oxygen-count range.

These attributes make it possible to search at the segment level using a measurable property, rather than relying only on a name. The same inherited attribute space includes formal charge (fc) and partial charge (pc): examples from the reference include s.fc > 1 and s.pc 1.5:2.0. Use the integer-valued attributes for counts and formal charge, and the float-valued partial charge attribute when a decimal range is relevant.

Names and display state are useful too

When you already know a segment’s label, the inherited name attribute can match a quoted string. The documentation gives s.n "A" and s.n "L*" as examples. Segments also inherit node attributes for visibility and selection. For example, s.v checks visibility, and not s.selected matches segments that are not selected. One detail worth remembering: the selected attribute is written as s.selected; it does not have a separate short name.

A simple way to build a useful search

  1. Decide what you need to distinguish: residue count, structural-group count, atoms, composition, charge, name, or display state.
  2. Choose the matching attribute and start with one condition, such as s.nr > 100.
  3. If a threshold is too broad for your purpose, try a range, such as s.nr 100:120.
  4. Check whether the attribute is segment-specific or inherited, and use the short form when it makes your expression easier to read.

Keeping the first search focused makes it easier to understand what each attribute contributes. For the complete segment attribute list and additional examples, see the Segment attributes reference.

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

Comments are closed.