Filter Molecules by Atom Count, Element Composition, and More in Seconds

When working with complex molecular systems, it’s quite common to spend a long time visually inspecting and filtering molecules based on their size or composition. For example, you might want to select all molecules in your scene that contain more than 100 atoms, or molecules that include nitrogen but no sulfur. Maybe you want to select small molecules with less than 30 atoms, or quickly tag anything that appears to be a protein chain.

If you’ve ever found this manual filtering tedious, the Node Specification Language (NSL) in SAMSON offers a precise and fast solution that can save time and reduce human error.

Introducing Attribute-Based Filtering for Molecules

In this post, we’ll focus on how to use SAMSON’s molecule attribute space—mol—to filter molecules by atom counts, elemental types (like Carbon, Hydrogen, Nitrogen…), and even substructure size. Everything is driven by readable queries, which makes it easy to automate the selection process in your molecular design work.

Example Scenarios

Let’s say you’re analyzing a PDB file containing both large proteins and small ligands. Want to select ligands with less than 40 atoms? You can run:

If you’re interested in molecules with a high number of nitrogen atoms, you can do:

Or maybe you want candidates that contain between 100 and 200 atoms:

And if you’re designing a coarse-grained model, you could filter by the number of coarse-grained atoms:

Available Attributes You Can Use

Each molecule node exposes a set of queryable attributes, such as:

  • nat: Number of atoms
  • nC, nH, nN, nO, nS: Number of Carbon, Hydrogen, Nitrogen, Oxygen, and Sulfur atoms
  • ncga: Number of coarse-grained atoms
  • fc: Formal charge
  • pc: Partial charge

Each can be used in simple expressions with comparison operators like <, >, = or even range matching valueX:valueY.

Advanced Tip: Combine Attributes

You’re not limited to a single condition—you can combine them. For example, if you want to target small, neutral molecules made of carbon and hydrogen only:

This tightly scoped query can help you pick fragments for fragment-based drug design or pre-filter data before exporting structures.

Why This Matters

Manually filtering structures, especially in crowded environments or when dealing with imported data files, slows down your workflow. These filters are not just for searching—they help you organize, edit, or export only relevant parts of your simulations or designs.

Once you learn how to compose a few of these expressions, you’ll be able to create complex filters in seconds. Think of it as giving your molecules a quick interview: who are you made of, how big are you, and are you worth a closer look?

To go deeper and explore more molecule-specific attributes in NSL, check out the official documentation page.

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

Comments are closed.