Quickly Filter Molecular Files in SAMSON Using NSL

When working with complex molecular systems in SAMSON, the scene graph can quickly become populated with a wide variety of node types, including atoms, residues, groups, and complete molecular files. Scrolling through and manually identifying which file nodes are selected or match specific naming patterns can be time-consuming.

This is where the Node Specification Language (NSL) becomes especially useful. NSL provides a compact and expressive way to filter and find specific elements of your molecular model—without needing to comb through menus or node trees. In this post, we’ll focus on a common task: selecting and filtering file nodes using NSL within the file (short name: fi) attribute space.

Why Filter by File Nodes?

Molecular modelers often import multiple files into the same project—for example, when comparing conformations or docking results. These files might have similar names (e.g., “Ligand1”, “Ligand2”, etc.), and the ability to rapidly retrieve or filter them is key to efficient workflows.

Using fi.n to Filter by Name

Each file node in SAMSON can be accessed via its name. The NSL expression fi.n (short for file.name) allows you to search for nodes whose names match a specific string or pattern.

For example:

This selects the file node with the exact name “Ligand1”.

This uses a wildcard expression to select all file nodes whose names start with “L”—a handy way to get all ligand files, for instance.

Selecting Based on Highlighting or Selection Flags

SAMSON distinguishes between a node being selected (i.e., actively highlighted in the UI) and having a selection flag (often used in scripts or selection propagation).

To select files that are currently selected:

To exclude them:

If you’re using selection flags (perhaps set programmatically), this filter works:

And to find files without a set selection flag:

Combining Conditions

One of the advantages of NSL is that you can combine multiple filters. Want all selected files whose name starts with “D”?

This flexibility allows modelers to quickly isolate the structures they care about—whether for analysis, visualization, or export.

Conclusion

Learning just a few expressions in NSL can save minutes, or even hours, across a project by eliminating repetitive selection work. Next time you’re dealing with multiple structural files, try filtering them with NSL. It’s a small skill that makes a big difference in complex modeling sessions.

To learn more, visit the official documentation page.

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

Comments are closed.