Filtering Molecular Structures Using Selection Attributes in SAMSON

When working with complex molecular systems, molecular modelers often need to quickly identify and interact with specific subsets of structures—those visible in the viewport, carrying specific material properties, or comprising a targeted number of atoms. Doing this manually for large datasets can be tedious. Fortunately, the Node Specification Language (NSL) in SAMSON helps by allowing highly specific filters using selection attributes.

In this post, we explore how selection-related attributes in NSL streamline your workflow for navigating and organizing structural models. Whether you need to isolate models that are hidden, currently selected, or possess a certain visibility state, you can leverage these simple yet powerful NSL expressions.

Common Tasks: Finding and Filtering Models

Let’s consider a few cases commonly encountered in molecular modeling:

  • You want to locate all models that are currently hidden.
  • You need to make sure only visible models are selected for rendering or exporting.
  • You’re interested in identifying structures that were selected manually in the interface.

All of these can be achieved using NSL expressions that target attributes in the structuralModel attribute space.

Useful NSL Attributes for Selection

The following attributes can be used to identify models based on visibility and selection:

Attribute Abbreviation Description
hidden sm.h Matches models that are hidden from the viewport.
selected n/a Matches models currently selected in the interface (note: there is no short name).
selectionFlag sm.sf Indicates internal selection state.
visibilityFlag sm.vf Shows either explicitly visible or inherited visibility.
visible sm.v Matches models explicitly set to be visible.

Practical Examples

Here are a few queries you can run in SAMSON’s NSL:

  • not sm.h — selects all models that are not hidden.
  • sm.selected — selects models that are manually selected by the user.
  • sm.v — targets models that are explicitly marked as visible (not just exposed through parent visibility).
  • sm.sf false — filters out models not marked internally as selected.

These expressions can be combined with more complex filters. For instance, if you’re only interested in models that are both visible and contain more than 100 atoms, you could use:

Why This Matters

Using selection-related attributes helps dramatically speed up common tasks like:

  • Exporting only currently viewed models
  • Hiding unselected parts of large structures
  • Applying algorithms only to specific, filtered selections

Instead of manually toggling visibility or counting atoms, just write a query—SAMSON’s NSL interprets it instantly. You can even save these queries as reusable templates.

To learn more about all structural model attributes supported in NSL, visit the full documentation page.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. To get started, download SAMSON from https://www.samson-connect.net.

Comments are closed.