Quickly Target the Right Files in SAMSON Using NSL’s selected Attribute

If you’ve ever worked with complex molecular systems in SAMSON, you know the pain of navigating through a dense data hierarchy just to find the files you’re actually working on. Whether you’re scripting, building custom nodes, or preparing selections for simulations, locating selected file nodes efficiently can be a real time-saver.

Fortunately, SAMSON’s Node Specification Language (NSL) offers a simple but often overlooked feature specifically designed to help with this: the selected attribute for file nodes.

What is selected in NSL?

In the file attribute space—shortened as fi—the selected attribute allows you to test whether a specific file node is currently selected. This attribute is inherited from the general node attribute space, but when used in the context of files, it applies directly and exclusively to file nodes.

Syntax Examples

You can formulate expressions in NSL like:

  • fi.selected — returns true for any file node that is currently selected.
  • not fi.selected — returns true for any file node that is not selected.

This proves particularly useful in scripting scenarios where you may only want to act on the files that a user has explicitly selected in the interface.

Why This Matters for Molecular Modelers 🧬

When you’re juggling simulations, dynamics, or docking runs, your document might contain numerous files: original molecular structures, results, temporary files, and more. Suppose you only want to export, duplicate, or annotate the files you’ve deliberately selected. Instead of checking manually or guessing file names, a quick NSL query with fi.selected can get the job done fast and accurately.

This is particularly helpful if you’re using the SAMSON Python scripting interface or developing a custom extension and want your tool to only interact with user-selected file nodes.

Going a Step Further: Combine with Other Attributes

The power of NSL grows exponentially when you combine attributes. For example:

  • fi.selected and fi.n "Docking*" — this targets selected file nodes whose names start with “Docking”.
  • not fi.selected and fi.sf true — this targets unselected files that still have their selectionFlag set.

These concise expressions can unlock advanced workflows with very little effort.

For Developers and Scripters

Even if you’re not using the UI, having these NSL filters available means you can write scripts that are context-aware: only modifying or referencing files that the user selected. This makes your scripts safer and more intuitive to use across different projects.

For more details and examples, refer to the official NSL documentation on the selected attribute.

To explore more attributes in the file space or see how they relate to node-level attributes, visit the full documentation:

https://documentation.samson-connect.net/users/latest/nsl/file/

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

Comments are closed.