Find the Right File Nodes Without Losing Track of Selection

When a molecular project contains many file nodes, a small targeting mistake can make it harder to find the item you meant to inspect. SAMSON’s Node Specification Language (NSL) provides a focused way to describe file nodes using attributes such as their names and selection state. The key is to use the file attribute space deliberately: it matches only file nodes.

Start with the file attribute space

File attributes use the full prefix fi or, where available, an attribute’s short name. For example, fi.n is the short form for the file node’s inherited name attribute. Names are written as strings in quotation marks:

The second example is useful to recognize because the documentation includes it as a valid name expression. It does not, by itself, define every detail of how pattern characters are interpreted, so avoid assuming more than the documented example guarantees.

Using the file-specific prefix also makes your intent easier to read. A query beginning with fi is explicitly about file nodes, rather than a broader collection of node types. This can help when you are checking or refining an expression and want its target category to be clear.

Check selection state explicitly

The file attribute space includes selected, which can be used in either positive or negative form:

These examples give you a concise way to express whether the file node is selected or not selected. One small detail matters: although selected is inherited from the general node attribute space, it does not have the short name s in the file attribute space. Write fi.selected, rather than assuming a shorter form will work for files.

Use selectionFlag when that is the attribute you need

Files also inherit selectionFlag, whose short name is sf. The documentation gives these examples:

Keep selected and selectionFlag distinct when writing expressions: they are listed as separate attributes, with different example forms. The reference page does not describe them as interchangeable, so choose the one that matches the attribute you intend to test instead of substituting one for the other.

A practical way to avoid query confusion

When a file-node expression does not return what you expect, check it in this order:

  1. Confirm the target type. The fi prefix is for file nodes.
  2. Check the attribute spelling. Use n for name, sf for selectionFlag, and the full word selected for selection state.
  3. Check the value format. Name values are strings in quotes; the boolean examples use true or false.
  4. Keep the attributes separate. A name expression and a selection-state expression answer different questions.

This simple checklist is especially useful when revisiting an expression later: it makes the intended node type, attribute, and value format visible at a glance.

For the full reference and additional NSL context, see the SAMSON file attributes documentation.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON at samson-connect.net.

Comments are closed.