Stop Manually Clicking: A Cleaner Way to Select Files in SAMSON with NSL

Have you ever found yourself manually clicking through molecular models, trying to locate and select the right file nodes? If you’re spending too much time doing this, especially on large projects, there’s a better way. The Node Specification Language (NSL) in SAMSON provides a flexible and efficient method for selecting and filtering nodes, including file nodes. This blog focuses on how to use file-level attributes in NSL to streamline selection and gain greater control over your molecular data.

Why Select File Nodes Programmatically?

File nodes in SAMSON represent data containers—like imported structures, trajectories, or model components—within your workspace. When modeling complex systems, you might have dozens or even hundreds of these. NSL allows you to write concise queries so you can focus on analysis instead of navigating through the Document View pane. Say goodbye to tedious manual selection.

The file Attribute Space: Quick Overview

Attributes for file nodes belong to the file attribute space (short name: fi). This means every time you refer to a file node in NSL, you should prefix its attribute with fi. to indicate that you’re targeting a file node.

Attribute: name (fi.n)

Use case: Selecting file nodes by name patterns.

If you want to select all file nodes that start with the letter “A”:

Or select a specific file node named “Ligands”:

This is particularly useful when you use naming conventions to organize your data, such as naming all ligand-containing files with an “L” prefix.

Attribute: selected

Use case: Checking if file nodes are selected or not.

To find which file nodes are currently selected:

To find which are not selected:

This helps you verify selections or perform actions conditionally, based on selection state.

Attribute: selectionFlag (fi.sf)

Use case: Working with temporary selections or defining flags programmatically.

To filter only those file nodes that are marked with a custom selection flag:

To find those without the flag:

This can be combined with scripts to further automate your workflows. For example, you could flag nodes for batch export or analysis based on some criteria, then use NSL to select just those flagged nodes.

Examples in Action

Imagine you’re working on a protein-ligand complex project with different conformations stored in files named Ligand_1, Ligand_2, …, Ligand_N. Instead of manually finding them, you can run:

This instantly selects all relevant file nodes, ready for comparison, visualization, or export.

Wrapping Up

Using NSL’s file node attributes can significantly reduce manual effort and improve consistency in how you interact with molecular data. It’s a small time investment with recurring benefits in every project.

To delve deeper into each attribute, visit the official NSL file attribute documentation.

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

Comments are closed.