How to Quickly Target File Nodes in SAMSON with NSL Filters

Managing large molecular projects in SAMSON? If you’ve ever found your workspace filled with dozens of files, and struggled to apply filters or actions only to specific file nodes (and not the nodes inside them), you’re not alone. This is a common challenge for many molecular modelers working with large systems made of multiple imported files, structural models, and simulations.

Fortunately, SAMSON’s Node Specification Language (NSL) includes an elegant solution: the file attribute space (short name: fi), which is designed specifically to match file nodes. This means you can now write simple, expressive, and powerful queries that operate only on files, avoiding the need to parse through all their underlying nodes.

What Are File Nodes, Exactly?

In SAMSON, each imported file (like a PDB, MOL, or simulation result) appears as a file node. These node containers might include molecules, trajectories, annotations, or any combination thereof. Treating file nodes separately can accelerate your workflow, especially when scripting selections or applying commands.

Common File Attributes You Can Use

There are three key attributes for file nodes in NSL:

  • name (n): Lets you target files by name. Useful when you’re loading multiple datasets and want to isolate a specific one.
  • selected: A boolean (true/false) that checks if a file node is selected. Unlike other node types, the short name s is not available for this attribute.
  • selectionFlag (sf): Also a boolean, used for advanced workflows involving programmatic selection or scripting logic.

Here are some examples:

  • fi.n "L*" – Targets all file nodes whose names start with “L”.
  • fi.selected – Matches file nodes currently selected in the workspace.
  • not fi.sf – Finds file nodes that don’t have the selection flag set, useful for deselecting or isolating work areas.

When Is This Useful?

Let’s say you’ve imported several ligand files to compare docking results across different structures. Each ligand is housed within a separate file node. Instead of clicking through your Document view to find and select each one, you can use:

to select them instantly. Even better, you could combine this with other node filters (for example, selecting ligands from a specific file) to refine your analysis more precisely.

What’s the Difference Between selected and selectionFlag?

While selected checks what is manually or visually selected in the interface, selectionFlag offers more flexibility in scripting or automated workflows. For example, you could search for nodes that were flagged by a script without interfering with your current visual selections.

In short, the file attribute space is an essential tool if you’re managing complex projects, automating selections, or cleaning up your workspace by targeting entire files instead of individual atoms or molecules.

You can find full details and more examples in the official NSL file attribute documentation.

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

Comments are closed.