Stop Searching Chain by Chain: A Practical Guide to NSL Filters

When a molecular structure contains many chains, finding the one you need by clicking through the model can be slow and error-prone. A chain may be identified by its ID, but chain identity is only part of the story: its length, number of segments, or elemental composition may be the more useful clue. SAMSON’s Node Specification Language (NSL) lets you describe those traits as filters, so you can narrow the search using properties rather than relying on visual inspection alone.

This guide focuses on chain-level selectors. The chain attribute space, abbreviated c, matches chain nodes. That scope matters: these expressions are intended to find chains, not individual atoms or residues.

Start with the chain ID

If you already know a chain’s ID, use c.id. For example, c.id 1 matches a chain whose ID is 1. To match several IDs or a range, use c.id 2:4, 6. This selects chains with IDs from 2 through 4 and ID 6.

One useful distinction: chain ID and chain name are separate attributes. The chain ID is an integer; the inherited name attribute accepts a quoted string. For example, c.n "A" matches a chain named “A.” If you are unsure whether a label in your workflow refers to an ID or a name, choose the corresponding attribute rather than assuming they are interchangeable.

Find chains by length or organization

When the chain ID is unknown, the number of residues can be a practical first filter. Use c.nr for the number of residues: c.nr > 100 matches chains with more than 100 residues, while c.nr 100:120 matches chains in the range from 100 to 120.

Other structural counts can help distinguish candidates. c.ns is the number of segments, and c.nsg is the number of structural groups. For example, c.ns < 3 selects chains with fewer than three segments; c.nsg 10:12 selects chains with 10 to 12 structural groups. These are different measurements, so choose the one that reflects the structural distinction you are investigating.

Use composition as a clue

Chains inherit atom-count attributes from the structural-group attribute space. These include total atoms (c.nat) and counts of carbon, hydrogen, nitrogen, oxygen, sulfur, and coarse-grained atoms (c.nC, c.nH, c.nN, c.nO, c.nS, and c.ncga). For instance, c.nO 10:20 matches chains with 10 to 20 oxygen atoms, while c.nat < 1000 finds chains with fewer than 1,000 atoms.

Formal charge and partial charge are available too: c.fc accepts integer values, and c.pc accepts floating-point values. Examples include c.fc > 1 and c.pc 1.5:2.0. These attributes can be useful when charge is relevant to your search, but they answer different questions from residue or atom counts.

A simple way to build a search

Begin with the most reliable clue you have: an ID or name, if known. Otherwise, choose a structural measure such as residue count, then use a composition or charge attribute when it helps distinguish the remaining candidates. Keep each expression tied to one clear question, and check the attribute’s value type: IDs and counts are integers, partial charge uses floats, and names are strings in quotes.

For visibility or selection state, chains also inherit node attributes such as c.v (visible), c.h (hidden), and c.selected. These can help describe the current state of a chain, while the structural attributes above describe its identity or composition.

For the complete attribute reference and additional examples, see the SAMSON chain attributes documentation.

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

Comments are closed.