Quickly Isolate the Files You Need in SAMSON with NSL

When working on complex molecular systems, one of the recurrent frustrations for computational scientists is managing and filtering through large numbers of files inside a project. From simulation results to experimental structures, projects often include multiple file nodes that must be precisely targeted—for analysis, modification, or visualization.

The Node Specification Language (NSL) in SAMSON offers a structured and flexible way to query and manipulate nodes based on meaningful attributes. In this post, we’ll focus on the file attribute space and how it can be used to streamline your work by selecting file nodes based on a few practical criteria: name, selected, and selectionFlag.

Understanding the File Attribute Space

The file attribute space (fi) in NSL matches only file nodes. It inherits several attributes from the broader node attribute space, such as:

  • fi.n for file name
  • fi.selected for the selection status
  • fi.sf for the selection flag

Use Case: Targeting Specific Files by Name

If you’re working on a project with many imported structures, you may want to isolate only those that match a specific naming pattern. For example, if your project includes a series of ligand files named L1, L2, …, L100, but you’re only interested in those beginning with “L”, you can use:

This selects all file nodes whose name starts with the letter “L”. Strings in name matching must be inside quotes, and wildcard characters like * are supported.

Refining Interactions with Selection States

To identify whether a file is currently selected in the viewport, use:

If you want to find all files that are not selected, simply negate the condition:

This is helpful when you want to apply changes only to unselected files—for example, deactivating them or excluding them from a simulation step.

Leveraging the Selection Flag

The selectionFlag, accessible via fi.sf, works similarly to fi.selected but may be used programmatically to reflect temporary query-based selection states. Use it like this:

This expression identifies file nodes with the selection flag enabled. It’s particularly useful when you write scripts or develop extensions and you want a lightweight method to tag matching files.

Example: Combining Attributes

To find files starting with “L” that are selected:

Such combined conditions help you focus on the exact entities you want to control, analyze, export, or visualize.

By using the NSL file attribute space, file management in SAMSON becomes far more efficient and adaptable. Whether you’re preparing a dataset for a downstream workflow, cleaning up your scene, or simply exploring structural variations, NSL gives you the power to get there faster.

To learn more, visit the original documentation page.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. You can download it here.

Comments are closed.