A clearer view of molecular scenes: querying presentation state with NSL

When a molecular scene gets busy, a small practical question can take time to answer: which presentation nodes are hidden, visible, or marked as selected? SAMSON’s Node Specification Language (NSL) provides a way to express these properties as queries. The presentation attribute space is designed for presentation nodes, and its short prefix is pr.

This is useful when you want to describe a particular presentation state rather than rely on names alone. For example, a name-based query can identify a presentation called “A,” while a state-based query can describe presentations according to visibility or selection attributes. The attributes documented for this space are inherited from the broader node attribute space, so their definitions are shared rather than unique to presentations.

Start with the attributes that describe what you see

Two concise expressions cover a common visibility check:

  • pr.v uses the short name for visible.
  • not pr.v expresses the opposite condition.

The page also lists hidden, with the short name h. You can write pr.h or not pr.h. These are separate attributes in the reference, so it is best to query the property you actually mean rather than assume that the two names are interchangeable.

Separate selection from selection flags

Selection-related queries include pr.selected and pr.sf, where sf is the short name for selectionFlag. Both accept true or false values. For example, the documented forms include pr.selected, not pr.selected, pr.sf, and pr.sf false.

One detail that is easy to miss: selected has no short name in the presentation attribute space. Although the node attribute space has a short name for it, the presentation reference explicitly says that this abbreviation is not available here. Use pr.selected rather than guessing a shortened form. By contrast, selectionFlag does have the short name sf.

Use names when identity matters

State queries answer “which presentations meet this condition?” A name query is useful when you already know the label you are looking for. The attribute is name, abbreviated as n, and its values are strings in quotes. The reference gives examples such as pr.n "A" and pr.n "L*". Keeping the value in quotation marks makes the intended string explicit.

A small, repeatable query checklist

  1. Begin with pr to work in the presentation attribute space.
  2. Choose the exact property: v for visible, h for hidden, selected for selection state, or sf for selectionFlag.
  3. Use not when you need to express the opposite condition, as in not pr.v.
  4. Use n with a quoted string when matching by name.

This habit helps keep queries readable and makes it easier to spot when an expression refers to a visibility property, a selection property, or a presentation’s name. It also avoids the common abbreviation trap: not every inherited attribute keeps its short name in this attribute space.

For the complete list of presentation attributes and examples, see the SAMSON presentation NSL reference.

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

Comments are closed.