In this chapter, you will learn how to collect nodes from the data graph and from other nodes which might not even be the part of the data graph.
The main function to collect nodes is getNodes which allows you to collect nodes that belong to some node (e.g. document, molecule, residue, etc). Please, refer to the SBDDataGraphNode::getNodes function documentation to learn more about its parameters and how it works.
You can also use SAMSON::getNodes facade functions to collect nodes either based on the Node Specification Language or based on node's position in the viewport.
The SBDDataGraphNode class defines a series of node predicates, i.e. functors that may be used to e.g. collect nodes in the data graph. For example, the SBNode::IsType predicate may be used to collect nodes by type (each node has a type):
The SBNode::IsSelected predicate may be used to collect all nodes that are selected (directly, because their selection flag is true, or because one of their ancestors is selected):
Predicates may be combined through logical operations.
For example, collecting selected atoms may be achieved with:
You may collect nodes in a node indexer from different nodes or collect nodes from a node indexer. For example, let's say we have a nodeIndexer
and we want to collect all atoms from it. This canbe done in the following way:
The SBDDataGraphNode class also defines a series of node getters, i.e. functors that may be used to collect nodes in the data graph. Node getters may be used to construct node predicates through comparison operators, so that collecting all atoms may also be achieved with:
since the statement SBNode::GetType() == SBNode::Atom
constructs a node predicate that is passed to the getNodes function.
In general, node getters have the same name as the corresponding getter function, but the first letter of their name is capitalized, since they are classes. For example, just like the SBNode::GetType getter corresponds to the SBNode::getType function, the SBAtom::GetTemperatureFactor getter corresponds to the SBAtom::getTemperatureFactor function.
Node predicates and node getters may be used to collect nodes from potentially complex rules:
Node predicates and node getters constitute the foundation of SAMSON's Node Specification Language.
SAMSON provides a powerful Node Specification Language which can be used both by users and by developers to select and collect nodes. Please refer to Node Specification Language for more information on how to use it.
SAMSON provides the SAMSON::makeNodePredicate function which make a node predicate based on an Node Specification Language selection string. Please, refer to the SAMSON::makeNodePredicate function documentation.
Examples:
Please refer to Node Specification Language for more information.