Filtering Molecular Models by Size and Composition with NSL in SAMSON

When working with complex molecular systems, one of the recurring challenges for modelers is quickly identifying molecules based on their size or composition. Whether you’re managing assemblies of proteins, ligands, small organic compounds, or even coarse-grained structures, manually selecting or filtering through hundreds or thousands of molecular nodes can be time-consuming and error-prone.

This is where the Node Specification Language (NSL) in SAMSON becomes extremely useful. In particular, molecule-specific attributes accessible through the mol attribute space allow you to query molecular nodes quickly based on structural characteristics — such as the number of atoms, chains, residues, or even specific element counts. If you’re new to this, or haven’t explored this part of NSL before, a deeper look might save you hours of manual work.

What Can You Filter With?

The mol attribute space in SAMSON includes molecular-level information that can be used to build intuitive and expressive queries. Here’s what you can filter molecules by:

  • Number of Atoms (mol.nat)
  • Number of Carbons (mol.nC), Hydrogens (mol.nH), Nitrogens (mol.nN), Oxygens (mol.nO), and Sulfurs (mol.nS)
  • Number of Coarse-Grained Atoms (mol.ncga)
  • Formal and Partial Charge (mol.fc, mol.pc)
  • Number of Chains (mol.nc), Segments (mol.ns), Residues (mol.nr), and Structural Groups (mol.nsg)

Examples of Practical Queries

Imagine you’re preparing a system containing a mix of protein and ligand molecules. You might want to exclude small buffer molecules (e.g., less than 10 atoms) or isolate only molecules containing sulfur. NSL provides a precise syntax for this:

Range-Based Selection

A particularly flexible part of NSL is its range syntax. For example, if you’d like to select molecules with a number of carbon atoms between 10 and 20:

This notation also works for other count-based attributes such as number of atoms, residues, and structural groups.

Composing Complex Queries

You can even combine these queries with logical operators (like and, or) to form more advanced filters. Although not shown in this excerpt of the documentation, NSL fully supports compound conditions.

Why Use These Filters?

Filtering with NSL can accelerate workflows such as:

  • Bulk hiding or isolation of molecules for visualization
  • Focused analysis on charged species
  • Exclusion of unwanted solvent or buffer molecules
  • Statistical evaluation of molecular components
  • Preparation for coarse-graining or downstream simulations

Learn More and Explore

To explore a full list of molecule attributes and examples, visit the official NSL molecule documentation page.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON here.

Comments are closed.