One of the most common challenges in molecular modeling is efficiently navigating complex models with thousands — sometimes millions — of atoms. Whether you’re comparing fragments, analyzing substructures, or scripting selections, filtering based on atom types and counts can help streamline your workflow and avoid unnecessary clutter on screen.
If you’re using SAMSON and the Node Specification Language (NSL), there’s a powerful approach for targeting structural models that contain specific amounts of certain atoms. This blog post introduces you to a practical strategy: selecting models based on the number of atoms like Carbon, Hydrogen, Oxygen, etc.
Why filter by atom counts?
Common use cases include:
- Identifying small organic molecules (
sm.nC < 10) - Filtering water clusters by hydrogen and oxygen ratios
- Selecting ligands with specific atom combinations for docking scenarios
- Excluding models that are too large or too small for a given simulation
The NSL makes this process concise and expressive. You don’t need to write complex scripts — just use direct attribute-based filtering.
How it works
Structural models in SAMSON are represented as nodes and have various attributes. These include general properties like name and visibility, but also content-specific attributes like the number of atoms of different types.
Here are some examples of filtering based on atom counts using the shorthand sm (meaning structuralModel):
sm.nC < 10: models with fewer than 10 carbon atomssm.nH 10:20: models with 10 to 20 hydrogen atomssm.nO > 5: models with more than five oxygenssm.nS 1: exactly one sulfur atom
This is especially useful in large simulations where visually or computationally filtering out irrelevant models early can significantly lower memory and CPU usage.
Understanding atom filters
| Attribute | Short Name | Description |
|---|---|---|
numberOfCarbons |
nC |
Number of Carbon atoms |
numberOfHydrogens |
nH |
Number of Hydrogen atoms |
numberOfOxygens |
nO |
Number of Oxygen atoms |
numberOfNitrogens |
nN |
Number of Nitrogen atoms |
numberOfSulfurs |
nS |
Number of Sulfur atoms |
Because this is integrated into the NSL — which works across the entire SAMSON platform — the same approach can be used in search panels, filters, scripting, or even selection-based visualizations.
Putting it into practice
Imagine you are working on a protein-ligand complex that includes water molecules, cofactors, ligands, and possibly solvents or crystallization agents. You may want to:
- Remove solvents with less than 5 molecules:
sm.nm < 5 - Identify sugars likely to have high oxygen content:
sm.nO > 10 - Select small fragments for fragment-based docking:
sm.nat < 100
This allows you to write clear and precise expressions to structure your molecular scene before any calculation starts.
Conclusion
Atom count filtering is one of the most effective ways to make molecular modeling more manageable and insightful in SAMSON. If you frequently examine or compare molecules, filtering by atom types using the NSL can significantly speed up your workflow and help you focus on what’s most relevant.
Learn more about NSL and structural model attributes in the official SAMSON documentation.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON from https://www.samson-connect.net.
