Quickly Filter Segments by Size in SAMSON Using NSL

When working with complex biomolecular structures, modelers often face the challenge of quickly identifying and operating on specific parts of the system. Whether it’s filtering out very small fragments or focusing on large, meaningful segments, being able to express these selections programmatically can save time and prevent errors.

SAMSON’s Node Specification Language (NSL) offers a concise way to select such structural elements. In this post, we’ll introduce how to filter molecular segments based on their number of residues and number of structural groups—two valuable metrics for molecular designers. If you often find yourself trying to distinguish signal from noise in your molecular systems, this is for you.

What Are Segments?

In SAMSON, segments are structural entities that can represent chains or other logical subdivisions in a molecular system. Each segment can contain multiple residues and structural groups, making them useful targets for scripting or filtering.

NSL allows you to write filters based on segment-level attributes, using the s prefix. Two particularly powerful attributes are:

  • numberOfResidues (nr): how many residues a segment contains
  • numberOfStructuralGroups (nsg): how many structural groups are in the segment

Use Case: Getting Rid of Small Fragments

Let’s say you imported a large protein structure, but it includes small unwanted segments—perhaps leftover solvent chains or fragments from a partial import. To remove them, you probably want to focus only on segments with enough residues or groups to matter. Here’s how you can filter them out:

This will match only segments with more than 100 residues. If you also want to check the number of structural groups, you can write:

Combining them gives even finer control:

You can also use range filtering. For example, to target segments with between 80 and 120 residues only:

When ‘Small’ is Actually Useful

In some cases, you might want to do the reverse—identify small peptide chains or functional groups with fewer than a specific number of components:

This could be handy for selecting ligands or small molecules within a larger model.

Simplifying Workflow

Knowing and applying these attributes lets you clean up your models, script operations, or automate pipelines using clear, compact expressions. Instead of manually inspecting every segment, trust NSL filters to focus your work where it matters.

To learn more about NSL’s segment attributes and explore other filtering options, visit the full documentation: https://documentation.samson-connect.net/users/latest/nsl/segment/.

SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.

Comments are closed.