Quickly Find What You Need: Filtering Segments in SAMSON with NSL

When working with complex molecular systems, the ability to quickly identify and filter molecular segments based on specific characteristics is a tremendous time-saver. Whether you’re studying a large protein, a material surface, or a supramolecular assembly, scrolling manually through hundreds of segments to find what matters can be exhausting.

This is where the Node Specification Language (NSL) in SAMSON becomes particularly useful.

Why segment filtering matters

Do you want to select all protein segments with more than 100 residues? Or find segments that contain fewer than 10 sulfur atoms? NSL allows you to query segments based on their attributes simply and powerfully—all directly within SAMSON’s selection language.

The NSL introduces the segment attribute space (short name: s), which gives access to all relevant segment-level properties. This includes general node-level and structural group-level properties, as well as segment-specific ones.

Common segment attributes you can filter on

Here are just a few of the attributes you can filter segments on:

  • Number of residues (s.nr)
  • Number of structural groups (s.nsg)
  • Number of atoms (s.nat)
  • Number of carbons, hydrogens, nitrogens, oxygens, sulfurs (s.nC, s.nH, etc.)
  • Partial or formal charges (s.pc, s.fc)
  • Visibility and selection flags (s.h, s.vf, s.selected)
  • Ownership and material flags (s.om, s.hm)

Examples: How to use NSL to filter segments

Let’s look at some quick examples that highlight how NSL simplifies your workflow:

  • s.nr > 100 — matches segments with more than 100 residues.
  • s.nsg 15:20 — matches segments that have 15 to 20 structural groups.
  • s.nO < 10 — finds segments with fewer than 10 oxygen atoms.
  • s.pc > 1.5 — segments with partial charge greater than 1.5.
  • not s.h — segments that are not hidden.

These expressions can be combined using logical operators to form more complex queries. For example:

s.nr > 50 and s.nC < 30

This would select segments that have more than 50 residues but fewer than 30 carbon atoms.

Best practices for segment filtering

Filtering efficiently means knowing your system and combining filters logically. Here are a few tips:

  • Start with broader queries to understand your dataset before narrowing in.
  • Use visibility and selection flags (s.v, s.selected) to focus only on what you can or want to see.
  • Save frequent queries as macros or scripts to reuse them easily.

Learn more

The full list of attributes and syntax examples is available in the official SAMSON documentation. Check it out here: https://documentation.samson-connect.net/users/latest/nsl/segment/

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

Comments are closed.