Quickly Filter Visible Labels in Molecular Models Using SAMSON

When working with complex molecular systems in SAMSON, label nodes play a key role in annotating structures, highlighting specific data, and guiding collaborators. However, once your scene becomes crowded, it can be hard to keep track of which labels are visible or hidden — especially when you’re inspecting detailed molecular interactions or preparing visuals for publication.

If you’ve ever found yourself toggling visibility flags one by one or manually searching for specific labels, there’s a better way: use SAMSON’s Node Specification Language (NSL) to filter labels efficiently by their visibility status.

Why visibility control matters 🧬

Many molecular modelers work across multiple layers of annotations — atom labels, measurements, structural comments, custom information, and so on. Being able to quickly isolate the visible ones (or hide them in bulk) lets you:

  • Reduce visual clutter, highlighting relevant data
  • Prepare cleaner renders or presentations
  • Debug scripts that add or remove labels dynamically

Using the la.v attribute

In NSL, the la attribute space targets label nodes. One very useful attribute within this space is v, referring to the visible property. Here’s how it works:

  • la.v selects all visible labels
  • not la.v selects all hidden labels

This allows you to write compact expressions to act on specific label sets. Combined with selection or name filters, this becomes powerful:

This filters all visible labels with names containing “Energy”.

Understanding the difference between visible and visibilityFlag

It’s important to distinguish between the two closely related fields:

  • la.v – the actual visibility state (true or false)
  • la.vf – a flag indicating whether the visibility was set explicitly

This distinction is useful if you’re managing programmatic visibility. For example, you may want to toggle visibility using scripting, while understanding whether a user manually changed a label’s visibility.

Applying visibility filters in practice

Here’s how you might use this in a real workflow:

  1. Select all hidden labels: not la.v
  2. Make them visible: right-click the selection → Show
  3. Focus on labels containing “pKa”: la.v and la.n "*pKa*"

This approach avoids guessing which labels are visible or not and enables rapid scene cleanup before analysis or sharing.

A note about the short names

The short name for visible is simply v. This keeps your queries compact:

Other related visibility attributes include:

  • la.visibilityFlag (la.vf)
  • la.hidden (la.h) – inherited from node attributes

If you want even finer control, you can mix filters like la.h and la.sf to work with hidden and selected labels.

Learning to use NSL filters like la.v can save you a lot of time and make your scenes easier to manage. It’s a small feature with big impact, especially in projects with dozens or hundreds of annotations.

To learn more and see the full list of label attributes, visit the official documentation page here: https://documentation.samson-connect.net/users/latest/nsl/label/

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

Comments are closed.