Web Analytics Made Easy - Statcounter
Skip to content

Selectors#

A selector is an object that computes a subset of nodes from a larger set of data graph nodes.

Use a selector when you want reusable, named selection logic that can be stored, instantiated, and reused across features rather than rewriting the same filtering code inline every time.

Key class#

The base class is SBDDataGraphNodeSelector.

A selector receives an input node set and populates an output node set. In other words, it encapsulates a selection rule.

Why selectors are useful#

Selectors are useful when selection logic needs to be:

  • reusable across several commands or workflows
  • configurable through parameters
  • serializable
  • exposed through SAMSON mechanisms rather than hard-coded in one function

They are especially relevant in workflows such as visual presets, domain-specific selection commands, or scripted feature pipelines.

Selectors and NSL#

Selectors are related to the node specification language (NSL). A selector may implement getNSLExpression() and return an equivalent NSL expression when such an expression exists.

That makes selectors a bridge between:

  • object-oriented selection logic implemented in C++
  • declarative selection strings used elsewhere in SAMSON

Not every selector can be represented as NSL, but when it can, the selector becomes easier to inspect and reuse.

Creating and using selectors#

Selectors can be instantiated directly in your code, and SAMSON can also create them dynamically through mechanisms such as SAMSON::makeSelector when the selector is exposed and registered appropriately.

That is useful when you want extensions or scripts to request a selection strategy by class name and extension UUID rather than by direct C++ type access.

Example scenario#

Suppose you often need "all atoms of a ligand neighborhood within a given cutoff that also satisfy a custom property test".

You could write that logic inline every time, but a selector gives you a better abstraction:

  • the cutoff becomes a parameter
  • the selection logic becomes reusable
  • the selector can later be surfaced in a richer workflow such as a preset or scripted pipeline