Find the Right File Node Without Losing Your Place

Molecular projects can accumulate many files: imported structures, supporting data, and other items in the document. When the project gets busy, finding the file node you want—or separating selected files from the rest—can become a small but persistent source of friction.

SAMSON’s Node Specification Language (NSL) lets you describe file nodes by their attributes. The key detail is the attribute space: file, abbreviated fi, matches only file nodes. That makes it a useful starting point when your goal is to target files rather than other kinds of nodes.

Start with a file’s name

To specify a file node by name, use the name attribute. Its short form is n, and values are written in quotes:

  • fi.n "A"
  • fi.n "L*"

These examples show the full and short forms in context. If you are building a query, the short form can make it more compact; the full attribute name can be easier to read later. Choose the form that makes your expression clearest to you and your collaborators.

A practical habit is to begin with the narrowest useful description. If you know the file’s name, start there. If you are checking a query someone else wrote, identify the attribute space first: fi tells you the expression is aimed at file nodes, while n or name tells you what property is being used.

Check selection state explicitly

File nodes inherit the selected attribute from the node attribute space. For files, it does not have the short name s. The documented forms are:

  • fi.selected
  • not fi.selected

The first expresses the selected state; the second expresses its negation. Writing the attribute explicitly can help make the intent of a query easier to inspect, especially when you are returning to a project after a break or sharing an expression with another person.

File nodes also inherit selectionFlag, with the short name sf. The reference gives these examples:

  • fi.sf false
  • fi.sf

selected and selectionFlag are separate attributes in the reference. If you are unsure which one a workflow calls for, keep their names distinct rather than assuming they are interchangeable. The full name selectionFlag is useful when readability matters; sf offers a shorter alternative.

A simple way to avoid query confusion

When a file-oriented expression does not seem to describe the target you intended, check it in three steps:

  1. Confirm the node type. Use the file attribute space, or fi, when the target should be a file node.
  2. Confirm the property. Use name or n for a name-based expression, and put the value in quotes.
  3. Confirm the state attribute. Use selected for selected state or selectionFlag/sf when that is the attribute you mean to test.

This small checklist helps separate two questions that are easy to blur together: “Which file node am I describing?” and “What selection-related state am I checking?” Keeping those questions separate makes expressions easier to read and troubleshoot.

For the complete attribute reference and additional context, see the SAMSON file attributes documentation.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON.

Comments are closed.