Quickly Target Visible and Selected Molecular Presentations with NSL

When working with complex molecular scenes in SAMSON, modelers often face the challenge of selecting precisely the data they want to inspect or process: a specific visual representation, or only what’s currently visible, or perhaps just the selected part of a larger system.

This is where the Node Specification Language (NSL) proves valuable—especially when dealing with presentation attributes such as visibility, selection status, or internal naming conventions. Understanding how to filter by these attributes using NSL helps streamline work dramatically.

Why This Matters

Imagine having multiple representations of a single molecule: ball-and-stick, surface, cartoon, etc. Sometimes only a few are visible or selected. If you want to apply an operation—like changing color, hiding, or exporting—it helps to focus just on the representations that are currently shown or selected. That means being able to filter:

  • Only the visible ones
  • Only what’s currently selected by the user
  • Representations matched by internal name strings

These are all accessible through the pr attribute space, which targets presentation nodes.

Quick Filtering Syntax Examples

Let’s look at a few practical cases using NSL queries that take advantage of the presentation attribute space.

  • Find all visible presentation nodes:
    pr.v
  • Find all hidden ones:
    not pr.v
  • Find selected presentation nodes:
    pr.selected
  • Find by name (e.g., all named with ‘Surface’):
    pr.n "*Surface*"
  • Filter visible and selected presentations:
    pr.v and pr.selected

These kinds of filters let you write simple queries to isolate just what you need in a scene. That makes modeling work smoother and avoids mistakes like editing hidden data.

What Each Attribute Means

Let’s break down the presentation-specific attributes and what they help you filter:

Attribute Short Name Example Use
visible v pr.v
not pr.v
hidden h pr.h
selected (none) pr.selected
selectionFlag sf pr.sf true
visibilityFlag vf pr.vf false
name n pr.n "Cartoon*"

Note: although selected does not have a short name, it is still easy to use directly as pr.selected.

Tips for Better Filtering

  • Use wildcards (e.g., "L*") with pr.n to match multiple naming patterns.
  • You can combine filters using logical operators like and, or, and not.
  • Visibility and selection flags can be dynamically changed during a session, so these filters adapt in real time.

Conclusion

Filtering based on visual and selection properties in SAMSON using the pr attribute space helps you isolate exactly the parts of your molecular scene that matter most at each step. It’s ideal for working with scenes that contain multiple representations or require cleanup based on visibility.

Learn more in the official NSL presentation attributes documentation.

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

Comments are closed.