Quickly Find Molecules with Specific Features in SAMSON Using NSL

One common need for molecular modelers working with complex systems is to quickly identify and select molecules with particular properties — such as those with a high number of atoms, a specific charge, or visibility status. Finding such molecules manually in large models can be tedious and error-prone.

The Node Specification Language (NSL) in SAMSON provides a straightforward way to do this by allowing you to use precise attribute-based queries. This blog post focuses on how you can use NSL to select molecules based on their attributes in SAMSON. This approach is particularly helpful when analyzing large simulations or imported datasets containing hundreds or thousands of molecular structures.

What is the mol attribute space?

In NSL, the mol keyword refers to the molecule attribute space, which matches only “molecule” nodes. This space includes both attributes unique to molecules and those inherited from broader attribute spaces like node and structuralGroup.

Some practical attributes you can search with:

  • Number of atoms: mol.nat — total atom count in a molecule.
  • Number of residues: mol.nr — total number of residues.
  • Formal charge: mol.fc — net formal charge on molecule.
  • Name: mol.n — string-based filter (e.g. mol.n "ATP").
  • Visibility: mol.v — whether the molecule is visible or not.

Example 1: Select molecules with more than 100 atoms

This returns all molecules with more than 100 atoms. You can use similar syntax for other attributes like number of hydrogens (mol.nH) or heavy atoms.

Example 2: Select molecules that are not visible

Use this to target molecules currently hidden in the scene, useful when cleaning up imported files or troubleshooting visibility.

Example 3: Filter by molecule name patterns

This selects all molecules whose names start with GLY. You can use wildcard patterns to match multiple naming styles.

Example 4: Select charged molecules

This expression selects molecules with a positive formal charge. For negative charges, just use < 0.

When combining multiple conditions

You can chain multiple conditions for more refined queries, like this:

This returns all positively charged molecules with fewer than 200 atoms.

Why this matters

If you’re working with structurally diverse datasets — such as those from docking pipelines, molecular simulations, or imported experimental data — it’s often essential to filter and isolate subsets of interest. Using NSL filters tailored to molecular attributes is faster and more precise than manual inspection. It also ensures reproducibility by keeping your selection criteria explicit and scriptable.

You can find the full list of molecule attributes and examples in the official documentation. To keep exploring, check out SAMSON’s Molecule Attribute NSL documentation.

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

Comments are closed.