Select Atoms Like a Pro with Boolean Expressions

When working with molecular structures, selecting specific atoms based on precise conditions can be time-consuming and error-prone. Graphical selection tools may be sufficient for simple tasks, but what if you need to isolate only carbon and hydrogen atoms? Or atoms within a precise region of space? Or only those belonging to a specific chain?

For molecular modelers using SAMSON, the Atoms Selector Extension provides a powerful way to define atom selections using mathematical and logical expressions. This allows precise and automated selection of atoms based on their attributes—saving time and making it easier to work reproducibly.

What Is the Atoms Selector Extension?

The Atoms Selector Extension allows you to select atoms in your active document using a simple formula. You can use mathematical expressions just like in the Simple Script Extension, but instead of modifying atoms, the extension focuses only on selection.

Some common examples:

  • Select all atoms: all
  • Select hydrogen atoms: a.symbol == 'H'
  • Select carbon atoms in chain 0: a.symbol == 'C' and a.ci == 0
  • Select atoms with x and y > 0: a.x > 0 and a.y > 0

Why It Matters

Suppose you’re simulating a nanoparticle surface and want to extract data only for visible atoms inside a certain spatial cut-off. Instead of manually selecting them (which can be tedious or even impossible), you can write a short expression like:

This selects all visible atoms inside a sphere of radius 10 (centered at (0, 0, 2)).

Here’s a concrete example: let’s say you’re working with a crystalline quartz model and only want atoms within a cylindrical region of radius 10 Å centered at (15,15). You can use:

Cut cylinder out of quartz crystal

Not only does this reduce selection time, it also increases confidence in the precision of your modeling steps—especially when the dataset is large or complex.

How to Get Started

  1. Enable the Atoms Selector Extension in SAMSON (it’s available on the SAMSON Connect platform).
  2. Open the molecule or system you want to work with.
  3. Write an expression in the Atoms Selector panel based on atom attributes.
  4. Execute—and your atoms are selected.

Supported Variables and Functions

The Atoms Selector Extension supports a wide array of atomic attributes, including position (a.x, a.y, a.z), element name (a.element or a.symbol), formal charge, chain ID, visibility flag, and others. You also have access to logical operators like and, or, not, and a full suite of mathematical functions (e.g., abs, sin, sqrt).

The syntax is case-insensitive. For example, a.EI == 6 will still match carbon, just like a.ei == 6.

Conclusion

Many modeling workflows start with selecting the right atoms. With the Atoms Selector Extension, you get a powerful expression-based interface for precise selections—no more hunting for atoms manually. You define what you want, and SAMSON takes care of the rest.

To learn more and explore examples, visit the full 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 here.

Comments are closed.