Mathematical Expressions for Selecting Atoms in Molecular Models

When working with large molecular systems, one of the biggest challenges is the efficient and precise selection of atoms for modification, visualization, or interaction. Whether you’re building nanoscale structures or simply preparing regions for simulation or analysis, complex selections based on atom attributes are often required.

This is where the Atoms Selector Extension in SAMSON comes in handy. Instead of manually clicking to select atoms, you can use mathematical and logical expressions to select exactly the atoms you need—with just one line of code.

For molecular modelers, this removes a common bottleneck in workflows, especially when working with large systems like crystals, proteins, or nanostructured materials.

What is the Atoms Selector Extension?

The Atoms Selector Extension in SAMSON lets you define a logical condition that is evaluated for each atom in the active document. Atoms that satisfy the condition are selected.

You can use attributes like the atom position a.x, a.y, a.z, the element name a.element, atomic number a.elementID, visibility, charge, and many more.

Here are a few examples to get you started:

Example 1: Select All Atoms in a Region

Suppose you want to select all atoms whose x and y coordinates are greater than 0 (e.g., the top-right quadrant):

Example 2: Select Atoms by Element Name or Symbol

To select all carbon and hydrogen atoms, write:

Example 3: Select Atoms Inside a Cylinder

Imagine you have a quartz crystal, and you want to cut a cylinder with a radius of 10 Å centered at (15, 15, z) out of it. You can simply use the expression:

Cut cylinder out of quartz crystal

Why Use Mathematical Selection?

Manual selection can be imprecise and time-consuming, especially in large models. Mathematical selection offers:

  • Precision: Select exactly what you need, based on positions, charges, types, or other criteria.
  • Speed: A single expression can do the work of hundreds of manual selections.
  • Reproducibility: Shareable and editable expressions make work easier to verify and automate.

Need to Go Further?

If your needs go beyond selection—for example, if you want to modify properties or create shapes like nano-batarangs—consider using the Simple Script Extension, which allows scripting control over atomic properties.

To learn more about selection and scripting in SAMSON, visit the full tutorial: Making nano-batarangs (and more).

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

Comments are closed.