Filtering Molecular Files by Name and Selection in SAMSON

Molecular modelers often work with numerous structural files during their design workflows: input files from collaborators, output files from simulations, experimental datasets, and more. Sifting through these to identify which ones are important, modified, or selected for further analysis is often time-consuming and error-prone.

Fortunately, the Node Specification Language (NSL) in SAMSON offers a precise way to tackle this issue using filters that target specific attributes of file nodes. In this post, we’ll look at three attributes available in the file (or fi) attribute space: name, selected, and selectionFlag. Understanding and combining these attributes can help streamline file management in molecular modeling workflows.

Why Use NSL to Filter File Nodes?

Whether you’re identifying the output of a docking scan, screening simulation results, or simply listing files that match a naming pattern like fi.n "Ligand_*", NSL lets you express these filters clearly and reproducibly. Instead of relying on manual browsing or filename scrolling, you can write queries that select what you need—instantly.

1. Filtering by File Name

The name attribute (n) lets you select file nodes by string comparison, with support for wildcards:

  • fi.n "A": selects file nodes whose name is exactly A.
  • fi.n "L*": selects file nodes whose name starts with L, such as Ligand_01 or Ligand_final.

2. Selecting Files by User Selection

The selected flag is very useful to isolate which files are currently selected in your workspace. Although inherited from general node attributes, it has no short form in this context.

  • fi.selected: returns only file nodes that are selected.
  • not fi.selected: selects file nodes that are not currently selected.

For example, if you’ve clicked on a few molecular models in the interface, fi.selected helps retrieve those specific file nodes quickly.

3. Using the Selection Flag

The selectionFlag attribute (sf) is another binary flag that can help identify special selections or states of interest.

  • fi.sf: selects file nodes where the selectionFlag is true.
  • fi.sf false: selects file nodes where selectionFlag is false.

Unlike selected, which reflects UI-level interaction, selectionFlag can be used programmatically to annotate files during workflows or analysis pipelines.

Combining Attributes for Powerful Queries

The real strength of NSL comes when these attributes are combined. Here are practical examples:

  • fi.n "Ligand_*" and fi.selected: selects file nodes starting with “Ligand_” that are also currently selected.
  • fi.sf false and not fi.selected: all file nodes that are neither selected nor have their selectionFlag enabled.

This type of querying opens the door to reproducible scripts and efficient filtering, especially when working in complex projects.

Where This Can Help

If you’ve ever opened a project with dozens of file nodes and struggled to remember which ones came from your latest run—or which you meant to archive—applying these filters using NSL can save you time and avoid mistakes. Whether you use templates, scripts, or work interactively, these filters help keep modeling workspaces organized.

To explore the full documentation and more examples, visit the official SAMSON NSL file attributes page: https://documentation.samson-connect.net/users/latest/nsl/file/.

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

Comments are closed.