When dealing with complex molecular systems, controlling visualization settings is vital to understanding structures, interactions, and dynamic behavior. In SAMSON, visual styles and display presets can be organized and fine-tuned using render preset nodes. But what if you have dozens—or even hundreds—of render presets in your document? How can you efficiently select only the ones you need?
This is where the Node Specification Language (NSL) and the renderPreset attribute space come in. In this post, we explore how to use NSL expressions to filter, identify, and act on specific render preset nodes based on their attributes. If you’re looking to simplify workflows and automate selection, this is for you.
Understanding Render Preset Attributes
In SAMSON’s NSL, render preset nodes belong to the renderPreset space—shortened to rp. These nodes can be filtered by using attributes inherited from the more generic node attribute space. The three most useful attributes here are:
name (n): A string identifier you assign to render presets.selected: A boolean indicating if the node is currently selected (note: no short name for this one).selectionFlag (sf): A flag you can programmatically set totrueorfalse.
Let’s look at practical examples of how these are used.
Filtering by Name
If you’ve carefully named your presets, NSL lets you quickly select exactly what you want. For instance, to select all presets whose name starts with an ‘L‘:
|
1 |
rp.n "L*" |
This is particularly useful when rendering styles encode specific information (e.g., “LigandDefault”, “LigandHighlighted”).
Working with selected and selectionFlag
You can use these properties to create filtered groups. For example, to find all render presets that are currently selected:
|
1 |
rp.selected |
To find those that are not selected:
|
1 |
not rp.selected |
Similarly, the selectionFlag is useful when scripting or performing semi-automated selections. For instance, to match all presets where the flag is false:
|
1 |
rp.sf false |
or:
|
1 |
not rp.sf |
These expressions can be used in combination with other query filters or to manipulate selections through SAMSON’s scripting interface.
Why This Matters
In molecular modeling sessions involving multiple styles and representations, selecting and grouping render presets manually becomes time-consuming and error-prone. By incorporating even simple NSL expressions involving rp.n, rp.selected, or rp.sf, modelers save time while keeping their sessions more organized.
These filters can also serve as building blocks when developing automation scripts or SAMSON Extensions. While the syntax may feel unfamiliar at first, it becomes quite intuitive with just a few examples.
Try it Yourself
Open a SAMSON session with various render presets and try expressions like:
|
1 2 3 |
rp.n "*Hydrophobic*" not rp.sf rp.selected |
You may be surprised by how quickly you can manage your document content.
To learn more about render preset attributes and the different ways to use them in NSL expressions, visit the official documentation page: https://documentation.samson-connect.net/users/latest/nsl/renderPreset/
SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.
