Managing complex molecular simulations often means dealing with numerous imported or generated files within a project. When the number of nodes grows, organizing and querying these files efficiently becomes key to staying productive.
This is where the Node Specification Language (NSL) in SAMSON makes a difference. The NSL allows you to write concise queries to retrieve or interact with specific elements of your model, including individual file nodes. In this post, we’ll explore the “file” attribute space and how it can help you streamline your workflow by manipulating file nodes using meaningful names and selection flags.
Why file-level querying matters 🧬
Let’s imagine your project has dozens of trajectory files, simulation setups, and structural models loaded into SAMSON. If they’re all just listed by default names or unclear labels, navigating through them quickly becomes cumbersome. Being able to find the right file by name or filter them based on selection becomes crucial to avoid errors and save time.
With the fi attribute space, you can finely target file nodes using NSL queries. Whether you’re renaming, selecting for analysis, or filtering files based on specific criteria, NSL enhances control and readability.
Query files by name
The name attribute (short name: n) lets you filter file nodes based on naming patterns. For example:
fi.n "A"matches single file nodes named “A”fi.n "L*"matches any file node whose name starts with “L” (e.g., “LigandStructure”)
This is particularly useful when you want to isolate a set of related files using a shared naming convention. If you organize your file names from the start with identifiable prefixes, this feature becomes even more effective.
Use selection flags to manipulate file visibility
Managing file visibility or performing actions on selected files is another common task. The selected and selectionFlag attributes help in this area:
fi.selectedreturns files currently selectednot fi.selectedreturns files that are not currently selectedfi.sfandfi.sf falselet you filter based on the internal selection flag state
An important note: unlike in the general node attribute space, the selected attribute for files has no short name. So you’ll need to use its full name in your filters.
Examples in real projects
Here are practical examples of how this can be useful in modeling scenarios:
- Quickly highlight and inspect all trajectory files from a simulation run:
fi.n "traj_*" - Verify that a specific input file is correctly selected before exporting:
fi.n "input_structure" and fi.selected - Remove selection from any files not in your current working group:
not fi.sfthen deselect
When used consistently, file attributes in NSL help clean up your project space and prevent errors during analysis or export by targeting exactly what you need.
To learn more about these attributes and how they integrate with the broader Node Specification Language, check out the official documentation: NSL File Attribute Documentation.
Note: SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.
