No Matches
Node Specification Language

SAMSON has a powerful Node Specification Language (NSL) that may be used to select data graph nodes based on their properties. For example, the Find command of the user interface of SAMSON lets users enter a NSL string to select nodes from the data graph.

Internally, SAMSON converts a NSL string into a node predicate that may be passed to the getNodes function of SBDDataGraphNode. Developers may choose to collect nodes from the data graph either from a NSL string or from a constructed node predicate.

NSL expressions may be used to find nodes in SAMSON (press Ctrl / Cmd⌘ + F ) or in the SDK with the makeNodePredicate function.

See User guide: Node Specification Language for more information.

For developers, the NSL relies on the SBCFunctor library, to manage functors and predicates. These may be used to e.g. search the data graph:

// find all atoms with temperature factor > 1.0
SBNodeIndexer nodeIndexer;
SBNode::IsType(SBNode::Atom) && (SBAtom::GetTemperatureFactor() > 1.0));
static SBDDocument * getActiveDocument()
Returns a pointer to SAMSON's active document.
Definition: SAMSON.cpp:738
This node predicate compares the node type with a given type.
Definition: SBDDataGraphNode.hpp:512
@ Atom
Definition: SBDDataGraphNode.hpp:67
This class describes a node indexer.
Definition: SBDDataGraphNodeIndexer.hpp:21
virtual void getNodes(SBNodeIndexer &nodeIndexer, SBNode::Type nodeType, bool selectedNodesOnly=false, const SBNodePredicate &visitPredicate=SBDDataGraphNode::All(), bool includeDependencies=false) const override
Collects nodes into nodeIndexer, based on a nodeType, a selection status and a visitPredicate,...
Definition: SBDDocumentFolder.cpp:804

You can also use an NSL string directly to retrieve nodes from the active document:

// Select all \ref SBResidue "residue nodes" from the active document that are within 4 angstrom of any sulfur atom (note that the selection string may be abbreviated to "n.t r w 4A of S"
SBNodeIndexer nodeIndexer;
SAMSON::getNodes(nodeIndexer, "node.type residue within 4A of S");
static void getNodes(SBNodeIndexer &nodeIndexer, int x, int y, int width, int height, const SBNodePredicate &selectionFilter=SBNode::All(), bool deepSelectionFlag=false)
Stores the nodes found inside the viewport rectangle (x,y,width,height) into nodeIndexer according to...
Definition: SAMSON.cpp:1052

Or you can create a node predicate from an NSL string. Note that in this case the ownership of the predicate is passed to the caller, who should delete the predicate when it's done using it.

// Make a predicate that is true if and only if the node is a hydrogen atom bonded to an oxygen atom.
SBNodePredicate* nodePredicate = SAMSON::makeNodePredicate("H linking O");
SBDDataGraphNodePredicate SBNodePredicate
The short name of SBDDataGraphNodePredicate.
Definition: SBDDataGraphNodePredicate.hpp:27
static SBNodePredicate * makeNodePredicate(const std::string &selectionString)
Make a node predicate based on a selectionString.
Definition: SAMSON.cpp:3293

Please, refer to Getting nodes to learn more how to use the Node Specification Language to collect nodes.

See also