How to find atoms near residues using NSL in SAMSON

One of the most repetitive (and error-prone) tasks in molecular modeling is selecting atoms or groups of atoms located close to a residue, a ligand, or a functional group. Whether you’re preparing a simulation, inspecting an interaction site, or filtering parts of a large molecular complex, you’ve probably found yourself clicking endlessly or writing scripts to select what you need.

Fortunately, SAMSON offers a powerful targeting system through NSL, the Node Specification Language. In this post, we’ll explore how NSL’s proximity operators let you perform precise spatial selections in just one line — such as finding atoms within 5 Å of a residue of interest, or filtering residues beyond a given distance.

Why should you use NSL proximity operators?

Here’s a common problem: you want to select all atoms within a 5 Å radius of a specific residue, say "GLN 2". With NSL, this is done in seconds using:

Let’s break that down:

  • n.t a means “node type atom,” to ensure you are selecting atomic nodes only.
  • within 5A of is the proximity operator.
  • "GLN 2" is the string identifier for the residue.

This captures all atoms within 5 angstroms of GLN 2, including potentially the atoms of GLN 2 itself.

What if you want to exclude the residue itself?

A useful refinement is to add an additional exclusion:

This expression ensures that the selected atoms do not belong to GLN 2 — efficient and specific.

Beyond proximity: advanced examples

You might need the opposite — elements completely outside the interaction zone. NSL allows this via the beyond operator. For example:

This selects atoms farther than 5 Å from a group or molecule named 2AZ8-IA.

You can also work at the residue level:

This selects all residues located beyond 5 Å from your current selection.

Combining logical and spatial conditions

Here’s where things get powerful. NSL supports combining spatial selection with logical operators. For instance:

This picks carbon atoms that are near GLN 2 — but not part of it — which is particularly useful for identifying potential bonding or interaction partners.

Where do I type these expressions?

You can use NSL expressions in SAMSON’s Find command or the Document View to filter and select nodes. In the Find tool, press Tab to autocomplete parts of the query. You can even click the Ask AI button to let SAMSON help you write the expression.

Select nodes with the Find command

More tips

  • Use quotes around names that contain spaces (e.g., "ALA 22 Side chain").
  • Use short versions like w for within or b for beyond to write more concise expressions. Example: n.t a w 5A of "GLN 2"

To learn more about proximity selections and NSL in general, visit the NSL documentation page.

SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at www.samson-connect.net.

Comments are closed.