A cleaner way to find and manage labels in a molecular scene

Labels can make a molecular scene easier to read, but they can also add visual clutter or make it harder to find the annotation you need. When a scene contains many nodes, searching by a label’s name or state can be more precise than scanning the view. SAMSON’s Node Specification Language (NSL) provides a small set of label-specific attributes for describing which label nodes to match.

The key detail is that these attributes belong to the label attribute space, abbreviated la. A query that starts with la is intended to match label nodes. This helps keep a search focused: rather than asking for a general node with a particular property, you can state that the target should be a label.

Start with the question you are trying to answer

Before writing an expression, decide what you want to identify. Are you looking for a label by name? Do you want to distinguish labels that are hidden from those that are not? Or are you checking selection or visibility state? Choosing the attribute that corresponds to that question makes the expression easier to read later.

  • Find labels by name: use la.name, or its short form la.n, followed by a quoted string. The reference includes la.n "A" and la.n "L*" as examples.
  • Check the hidden attribute: use la.hidden, abbreviated la.h. For example, la.h and not la.h express opposite conditions.
  • Check visibility: use la.visible, or la.v. The examples la.v and not la.v let you express either condition.
  • Check selection: use la.selected or not la.selected. Unlike some other attributes, selected has no short name in the label attribute space.
  • Check a flag explicitly: la.selectionFlag can be shortened to la.sf, and la.visibilityFlag to la.vf. Both accept true or false; for example, la.sf false or la.vf false.

Keep similar-looking attributes distinct

It is tempting to treat hidden, visible, and visibilityFlag as interchangeable because their names all relate to what appears in a scene. The reference lists them as separate attributes, with separate examples. Likewise, selected and selectionFlag are distinct entries. When building a query, use the exact attribute that describes the condition you want to test rather than substituting a nearby-sounding one.

This distinction is also useful when sharing or revisiting a query. A compact expression such as la.v may be convenient, while la.visible can be easier for a colleague to interpret at a glance. The short forms shown in the reference are alternatives for the attributes that provide them; they are not available for every attribute. In particular, use la.selected rather than assuming there is a label-specific la.s alias.

A practical query-building habit

Build the expression around one clear condition first. For example, if the task is to check labels that are not visible, begin with not la.v. If the task is instead to identify a label by name, start from a name expression such as la.n "A". Keeping the first expression simple makes it easier to see whether the attribute space and condition match your intention. You can then consult the broader NSL reference for syntax and examples if you need to combine conditions.

These label attributes are inherited from the general node attribute space, so their detailed behavior is documented there. The label reference is especially useful as a quick map of which names and short forms apply when you want to target label nodes.

See the Label attributes reference to learn more.

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

Comments are closed.