For anyone working with complex molecular systems, a common challenge is quickly filtering and selecting molecules based on specific characteristics—like the number of atoms, chains, or even the number of specific elements (e.g., carbon, oxygen, sulfur). If you’ve ever panned endlessly through molecular data trying to find structures with more than 130 residues or fewer than three chains, you know time adds up.
Fortunately, SAMSON’s Node Specification Language (NSL) offers a highly effective solution. NSL lets you write concise and powerful queries to filter molecular structures based on dozens of attributes. In this post, we’ll focus on how to use NSL to filter molecules by basic structural characteristics—without writing a single line of code.
Why This Matters
Whether you’re optimizing a simulation, cleaning up a dataset, or preparing figures, you often need to isolate molecules that meet certain criteria. For example:
- Only want to simulate molecules with fewer than 1,000 atoms?
- Need to check which molecules in your system contain sulfur?
- Curious which parts of a large model have a formal charge above +1?
NSL supports all of these tasks—and more—through human-readable queries that plug directly into SAMSON.
Examples You Can Use Right Now
In SAMSON, you can filter molecules using the mol namespace. Here are some real-world examples you might find useful:
Filter by Atom Count
To match molecules with fewer than 1,000 atoms:
|
1 |
mol.nat < 1000 |
To match molecules with 100 to 200 atoms:
|
1 |
mol.nat 100:200 |
Filter by Number of Carbons
Only want small carbon frameworks?
|
1 |
mol.nC < 10 |
Or filter medium-sized carbon structures:
|
1 |
mol.nC 10:20 |
Other Useful Filters
mol.nH: Number of hydrogensmol.nN: Number of nitrogensmol.nO: Number of oxygensmol.nS: Number of sulfursmol.pc: Partial charge (float values)
All these attributes let you write highly specific filters like:
|
1 |
mol.nS > 0 and mol.pc > 1.0 |
—which matches molecules containing sulfur with high partial charge.
Range Queries: Powerful and Intuitive
One of NSL’s great time-saving tricks is range-based matching. Instead of combining comparison operators, you can use an intuitive range syntax:
|
1 |
mol.fc 1:4 |
This matches all molecules with a formal charge between +1 and +4. No need to write multiple clauses.
Quick Recap Table
Here are some of the most useful molecule attributes in NSL:
mol.nat: total number of atomsmol.nC: number of carbon atomsmol.nH,mol.nO,mol.nN: hydrogen, oxygen, nitrogen countsmol.pc: partial chargemol.fc: formal charge
Next Steps
Knowing how to quickly and precisely target molecules based on structure is a foundational skill for any molecule modeler. It accelerates workflows and reduces manual filtering. NSL keeps this process transparent, flexible, and scalable.
To learn more about what’s possible and see the full list of attributes, visit the SAMSON documentation on molecule attributes.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
