A Precise Way to Select Atoms with Mathematical Expressions

When working with molecular structures, atom selection can become a tedious and repetitive task, especially in large systems like crystals, biomolecules, or complex nanostructures. Often, modelers want to focus on specific regions — say, atoms with certain charges, atoms within a geometric shape, or those belonging to specific chains — but using the mouse or traditional selection tools just doesn’t scale.

That’s where the Atoms Selector Extension in SAMSON comes in handy. This tool allows you to select atoms declaratively using mathematical expressions, giving you both precision and efficiency. You simply write compact, logical expressions that define exactly what you want in your selection. Here’s how it works and why it’s a time saver 💡.

Select with Expressions, Not Clicks

The Atoms Selector Extension shares the same scripting language as the Simple Script Extension. That means you can use any combination of mathematical, logical, and property-based expressions to filter atoms. All you need to provide is a single expression. The interface takes care of parsing and applying it on the active molecular document.

For instance, if you’re dealing with a quartz crystal and want to select only the atoms inside a cylinder of radius 10Å centered at (15, 15):

This expression evaluates each atom’s coordinates and selects those that fall within the defined cylindrical region. Simple, reusable, and intuitive.

Common Use Cases

  • Geometry-based selection: Cylinders, spheres, planes—select atoms inside or outside these regions.
  • Chemical type selection: Select atoms based on element type: a.symbol=='C' for carbon atoms.
  • Property filters: Need to select atoms with partial charge above a threshold? Try: a.partialCharge>0.1
  • Chain or residue-specific selection: Example: a.chainID==1 to select atoms from one chain.
  • Highlight water molecules only: Use a.water==1.

Additional Flexibility

The language supports not just simple expressions but also functions like abs(), sqrt(), sin(), and many more. You’re essentially writing mathematical filters. And yes — all is also a valid expression, if you want to select everything in the document.

Visual Results

Here’s an example of using the Atoms Selector to cut a cylinder out of a quartz crystal using the expression shown above:

Cut cylinder out of quartz crystal

With such expressions, you can create nano-patterns, customize geometry-focused selections, or even prepare subsets of molecules for simulations or analysis.

To understand the full list of supported attributes, syntax, and examples, you can check out the Simple Script tutorial, as the Atoms Selector builds directly on top of it.

To learn more and explore more advanced examples, including the use of the scripting language in creative workflows, visit the original documentation page: https://documentation.samson-connect.net/tutorials/simple-script/making-nano-batarangs-and-more/

SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.

Comments are closed.