Quickly Spot Files You’re Working On with the NSL ‘selected’ Attribute

When working on molecular systems, it’s common to juggle multiple files and structures at once. You might be preparing different configurations, comparing docking poses, or visualizing simulation results side by side. In such scenarios, quickly identifying which nodes are currently selected can ease your workflow—especially if you automate actions such as highlighting, deletion, or analysis. Here’s where the ‘selected’ attribute in the Node Specification Language (NSL) for SAMSON becomes useful.

Why care about selected nodes?

In SAMSON, selections are key to interacting efficiently with your model. Whether you want to export data, apply force fields, or run quantum calculations, you often need to select the relevant parts of your system first. But how do you programmatically access only those selected file nodes from the hundreds (or thousands) in your workspace?

The NSL makes it possible to filter nodes directly based on their state. Specifically, you can search for file nodes that are currently selected using the selected attribute within the file (or fi) attribute space.

Using fi.selected

Suppose you’re working with multiple PDB files or simulation trajectories, and you’ve manually selected the ones you want to export or hide. Here’s how you can retrieve them:

This query returns all file nodes that are currently selected. Similarly, to find nodes that are not selected, you can use:

This comes in handy when cleaning up your scene or checking which parts you’ve missed selecting before launching a calculation.

What about short names?

In many NSL attribute spaces, shorthand options speed up query writing. However, for the selected attribute within the file attribute space, there isn’t a short name available. So instead of using something like fi.s, you should always use the full fi.selected.

Not just true or false

You don’t need to write fi.selected true—simply writing fi.selected checks whether the attribute is set. This streamlines the query further.

Apply this to automation workflows

Are you building scripts to prepare visualizations or run series of simulations? Combine selected with other attributes like name or selectionFlag to customize your queries:

  • fi.selected and fi.n "Ligand*" — selected files with names starting with “Ligand”.
  • not fi.selected and fi.sf — unselected files with the selection flag set.

This allows nuanced control over your data in complex projects with many components.

Learn more about selected and other attributes in the official documentation.

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

Comments are closed.