When a molecular structure contains hundreds or thousands of residues, finding the right subset by clicking through the model can become tedious. The challenge is not only locating residues by name: you may need a particular secondary structure, charge, sequence number, or backbone completeness. SAMSON’s Node Specification Language (NSL) lets you describe those criteria as compact queries.
This guide focuses on residue-level searches: how to choose a useful attribute, read the query syntax, and avoid a common scope mismatch—asking for residues when you actually need atoms within them.
Start with the residue scope
Residue attributes live in the residue attribute space. The short forms res and r refer to that space, so a query such as r.t ALA matches alanine residues. The short form is convenient when you are exploring several criteria, while the full attribute names can be easier to read when you return to a query later.
One important distinction: a residue query matches residue nodes. If your goal is to find atoms belonging to matching residues, the documentation also shows expressions that query atoms in a residue, such as node.type atom in residue.aminoAcid (short form: n.t a in r.aa). Thinking about the object you want to match—residue or atom—before writing the query helps prevent confusing results.
Find secondary-structure regions
To search by secondary structure, use r.ss. The accepted values include alpha (also a, helix, or h), beta (also b, strand, or s), and unstructured (also u, loop, or l).
r.ss hmatches residues in alpha helices.r.ss a, bmatches residues in alpha helices or beta sheets.
Aliases make quick queries shorter, but the full words can be useful when sharing an expression with someone who is new to NSL.
Filter by residue identity or sequence number
For specific residue types, use r.t. For example, r.t LYS, PRO matches lysine and proline residues. The documented type values include standard amino-acid names, several nucleic-acid codes, and additional residue names such as SEC and PYL.
To target positions by their structure sequence number, use r.id. For example, r.id 1:10, 20:30 matches residues numbered from 1 to 10 and from 20 to 30. A single position can be written as r.id == 42. This can be useful when investigating a known region without relying on residue identity alone.
Residue names and sequence numbers answer different questions: r.t VAL searches by type, while r.id == 42 searches by position. If a structure contains several instances of the same residue type, the type query can match more than one location.
Use chemical properties to narrow a search
For amino-acid side-chain charge, r.c accepts negative, neutral, positive, and undefined, with short aliases such as neg, neu, and pos. For example, r.c neu, pos matches residues with neutral or positive side-chain charge.
Polarity is available through r.p. Values include polar, nonpolar, acidic, and basic; for example, r.p acidic, basic matches residues with acidic or basic side chains. These classifications are based on residue type, so they describe the residue’s side-chain category rather than a measurement of the current molecular environment.
Other type-based properties include hydrophobicity and dissociation constants. Examples include r.hydrophobicity < 0, r.pI < 6.0, and r.pKa1 1.5:2.0. These can help identify residues by a numerical property instead of a named category. The documentation notes that its hydrophobicity values use the Kyte–Doolittle scale.
Check structural completeness and special cases
To find residues with a complete amino-acid backbone, use r.caab. To check for terminal residues, use r.ter. The documentation gives a useful atom-level example for the latter: "CA" in r.ter matches alpha carbons in terminal residues. This demonstrates how a residue property can provide context for an atom query.
For residue naming, r.srn matches residues with standard PDB residue names, while r.nsrn matches those without standard names. These are useful checks when a structure contains nonstandard residue labels that may not be covered by a query for a familiar amino-acid type.
A practical way to build a query
Start by stating the question in plain language: “Which residues are in beta strands?”, “Which positions are 42?”, or “Which residues have positive side-chain charge?” Then choose the attribute that directly represents that question and test the corresponding expression: r.ss beta, r.id == 42, or r.c positive. If you need atoms rather than residue nodes, use the documented in pattern to express that relationship. Keeping each criterion clear makes it easier to inspect, reuse, and share your searches.
For the complete attribute reference and additional examples, see the SAMSON residue attributes documentation.
Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON.
