A Precise Way to Select Atoms Using Mathematical Expressions in SAMSON

When building or analyzing complex molecular systems, molecular modelers often need fine control over which atoms to keep, manipulate, or hide. Especially in large or periodic structures, identifying a specific spatial region—like a nanodisk from a larger sheet or defining a custom selection sphere—can be a tedious task.

That’s where the Atoms Selector and Simple Script Extensions in SAMSON can simplify your work. Both allow selection or modification of atoms based on mathematical expressions. In particular, the Atoms Selector Extension makes it easy to select atoms from the active document using clear, reusable logic.

Why use mathematical expressions to select atoms?

Graphical selection tools can be convenient for small structures, but in larger ones or simulations involving symmetry, precision and reproducibility are key. For example:

  • You want to select all atoms within a cylindrical volume to functionalize a nanotube tip.
  • You want to identify all atoms with an x-coordinate greater than 20 Å to apply boundary conditions.
  • You need to isolate atoms of a certain element within a nanocluster core.

The Atoms Selector Extension uses the same variables and syntax as the Simple Script Extension, allowing expressions such as:

…to select atoms within a disk of radius 10 Å centered at (15, 15) in the x-y plane. No need for manual dragging or gizmos—just a clear condition that you can store, tweak, and reuse.

Supported variables and expressions

You can create expressions using atom positions (a.x, a.y, a.z), element names or IDs (a.element, a.symbol, a.elementID), chain membership, residue numbers, charges, and more. Logical and mathematical operations let you build any expression you’d write in a scripting language. Here are a few examples:

  • a.x > 10 and a.e == 'Carbon'
    Selects all carbon atoms with x-coordinates greater than 10 Å.
  • abs(a.z) < 5
    Selects all atoms within 5 Å of the z = 0 plane.
  • a.symbol == 'H' or a.symbol == 'O'
    Selects all hydrogen and oxygen atoms.

Visual feedback to validate expressions

Selections update visually. This lets you immediately verify the expression is targeting the appropriate atoms before taking additional actions, like copying, modifying, or saving the subset.

Getting started

To use the Atoms Selector:

  1. Install the Atoms Selector Extension from SAMSON Connect if you haven’t already.
  2. Open your molecular system in SAMSON.
  3. Open the Atoms Selector and type your selection expression.

Ready to isolate a cylinder from your structure? Try this expression in the Atoms Selector:

This selects atoms inside a cylinder of radius 10 Å centered at (15, 15), regardless of z.

Cut cylinder out of quartz crystal

Whether for complex systems or repeated workflows, mathematical selections offer a flexible and reliable solution.

To learn more and discover additional examples, visit the original documentation page here:
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.