Controlling Visibility and Selection in Molecular Models with NSL

Working with large molecular systems often means dealing with a lot of visual clutter. Whether you’re preparing illustrations for a paper or simply trying to understand a structure better, it’s common to want to hide some elements and highlight others. If you’re using SAMSON for molecular modeling, there’s a powerful tool you might not be taking full advantage of: NSL (Node Specification Language) presentation attributes.

In this post, we explore how to programmatically control visibility and selection of presentation nodes in SAMSON — helping you customize your molecular view more precisely and effectively.

Why Focus on the ‘presentation’ Attribute Space?

The presentation attribute space (short name: pr) in NSL targets presentation nodes — those responsible for how elements are visually represented in your model. This includes nodes like molecular representations (e.g., ball-and-stick, surface) that can be toggled independent of the actual molecular data.

The ability to filter, show/hide, and select/unselect presentation nodes based on specific attributes gives you high flexibility without modifying the underlying data structure.

Useful Attributes for Filtering Presentation Nodes

Attribute Short name Function Examples
hidden h Indicates if a presentation node is hidden. pr.h, not pr.h
name n Matches presentation node names (supports wildcards). pr.n "A", pr.n "L*"
selected Returns true if the node is selected. pr.selected, not pr.selected
selectionFlag sf Returns whether the selection flag is set. pr.sf, pr.sf false
visibilityFlag vf Returns whether the visibility flag is set. pr.vf, pr.vf false
visible v Combines visibility and parent visibility. pr.v, not pr.v

Real-World Scenario: Hiding All Surface Representations

Imagine you have multiple representations per molecule, and you want to hide all surfaces while keeping ribbons or sticks visible. If your surfaces follow a naming convention (e.g., names start with “Surface”), you can write:

This will select all visible surface nodes. You can then hide them in one click.

Another Case: Check Which Representations Are Currently Selected

To inspect which representations are selected (e.g., for further grouping or editing), type:

This filters your model to only show those presentation nodes you have selected.

Pro tip: Combine Filters

You can also combine attributes. For instance, to find all hidden presentation nodes whose names start with “L”:

Why This Matters

Efficient control over what’s shown or hidden in your workspace saves time and focuses your attention on what matters most. Instead of clicking through elements manually, NSL lets you define complex visual manipulations in a single query.

To learn more about the full list of presentation attributes and how they work, visit the full documentation page: Presentation attributes in NSL.

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

Comments are closed.