Working with complex molecular structures can be frustrating when you’re trying to locate specific segments or unsure whether a segment meets certain requirements. Whether analyzing a model with thousands of atoms or attempting to filter specific residues, identifying the right segment quickly can save significant time.
This post explores how the Node Specification Language (NSL) in SAMSON allows you to filter segments based on their attributes—like the number of residues, structural groups, or atoms—so you can focus your attention where it matters most.
Why segment filtering matters 🧩
Segments are structural components that can contain residues, atoms, and groups. Being able to filter segments lets you:
- Select target regions for simulation or visualization
- Hide or isolate large regions based on chemical composition
- Refine analyses without manual model browsing
For example, let’s say you’re working on a protein-ligand system and you need to isolate protein segments with more than 100 residues. Instead of clicking through visual models or searching identifiers, simply write:
|
1 |
s.nr > 100 |
This line uses the segment.numberOfResidues attribute (nr) and instantly matches all segments with more than 100 residues. You’ve just filtered your system in a fraction of a second.
Segment attributes at your fingertips 🔍
The segment attribute space in NSL brings several helpful filters:
s.nr: Number of residuess.nsg: Number of structural groupss.nat: Number of atomss.fc: Formal charges.nC,s.nH,s.nO,s.nN: Element-specific atom counts for carbon, hydrogen, etc.
Each filter supports expressions using ranges or comparisons. Let’s explore some practical scenarios:
s.nsg 10:15selects segments with 10 to 15 structural groups.s.nat < 500finds smaller molecular components for faster evaluation.s.nO > 5identifies oxygen-rich segments, often useful in redox reactions.
Combining attributes
NSL becomes even more powerful when combining filters with logical operators. For example:
|
1 |
s.nr > 100 and s.nC > 20 |
This selects segments with both more than 100 residues and more than 20 carbon atoms.
When visibility matters
Sometimes, you’re only interested in parts of a model that are visible or selected in the viewport. These segment attributes help:
s.v: Checks if the segment is visibles.h: Checks if the segment is hiddens.selected: Matches segments currently selected in SAMSON
Want to hide all segments with fewer than 50 atoms? Filter using s.nat < 50, then apply a visibility toggle to the result.
Flexible naming
Segment names can also be matched. Examples:
|
1 2 |
s.n "A" s.n "L*" |
The second line uses a wildcard to match any segment whose name starts with “L”.
With these simple expressions, you can reduce model complexity, prepare selections for analysis, and make your workflow faster and more precise.
To learn more, visit the original documentation page here: https://documentation.samson-connect.net/users/latest/nsl/segment/.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.
