SBNode#

The data graph contains everything directly or indirectly added by the user through SAMSON’s user interface, plugins, etc. A data graph node has basic pre-defined data and functionalities to manage the data (models, apps, etc.).

All nodes in SAMSON’s data graph, e.g. atoms (samson.SBAtom), bonds (samson.SBBond), visual models (samson.SBVisualModel), folders (samson.SBFolder), files (samson.SBFile), etc., derive from samson.SBNode.

Topology#

SAMSON’s data graph is a directed graph, where each node has one and only one parent (with the exception of documents (samson.SBDocument), which have no parent), and possibly some children. The parent of a node can never be directly set, but can be retrieved using the samson.SBNode.getParent() function. Children are managed using the samson.SBNode.addChild() and samson.SBNode.removeChild() functions.

Node lifecycle#

In SAMSON, a data graph node may go through four lifecycle stages:

  1. C++ object creation (using the node’s constructor).

  2. Node creation (using the samson.SBNode.create() function).

  3. Node destruction (using the samson.SBNode.erase() function).

  4. C++ object destruction (usually automatically, or forced; uses the node’s destructor).

Node creation and destruction (stages 2 and 3) are necessary to more operations undoable.

Node identity#

Each node in the data graph has a type, which may be retrieved via SBNode.type. For example, the type returned by the SBAtom class, which derives from the SBNode class, is Atom, while the type returned by the SBStructuralModel class is StructuralModel. To obtain a type of a node as a string, you can use the SBNode.typeString attribute or the SBNode.getTypeString() function.

Print node type#
# get a data graph node's type
print(node.type)

# get a data graph node's type as a string
print(node.typeString)

# the same as before
print(SBNode.getTypeString(node.type))

You can also check for a particular type of a node e.g. whether it is a visual model, an interaction mode, a structural node, etc. using one of the functions like samson.SBNode.isVisualModel().

Let’s, for example, erase all visual models in the current selection:

Erase selected visual models#
# make the operation undoable
SAMSON.beginHolding("Erase selected visual models")

# loop over all currently selected nodes in the active document
for node in SAMSON.getActiveDocument().getSelectedNodes():

    # check if this node is a visual model
    if node.isVisualModel():
        # erase the node
        node.erase()

# turn the undo system off
SAMSON.endHolding()

Each data graph node also has a unique index, that is managed internally by SAMSON. All indices are contiguous unsigned integers between 0 and n-1, where n is the number of data graph nodes. As a result, the node index is not permanent: when node i is deleted (and i is different from n-1), then node n-1 becomes node i. Node indices are used for example when picking objects in a viewport, by writing integers into the framebuffer instead of colors. The unique node index can be retrieved using samson.SBNode.nodeIndex.

Flags#

Each data graph node has four flags:

Changing these flags’ values is undoable, except for the highlighting flag which has temporary purposes.

The samson.SBNode.getFlags() function returns an integer that combines the highlighting and selection flags, as well as the “mobility flag” (samson.SBAtom.mobilityFlag) of atoms.

Materials and colorization#

Each data graph node may have a material (samson.SBNodeMaterial), which may affect its rendering in the viewport. A material may be applied to a node with the samson.SBNode.setMaterial() function. When a material is added to a node, it affects the node itself and all its descendants (unless they have a material themselves, which then has priority). Precisely, the samson.SBNode.getMaterial() function returns the material directly applied to the node, or determines the deepest ancestor that has a material applied (by examining the node’s parent, then its parent’s parent, etc.). If no material is found, the samson.SBNode.getMaterial() function returns 0.

Each material has a appearance properties used when rendering nodes using path tracing and a color scheme (samson.SBNodeColorScheme) which may be modified and used to associate a color to a node or a spatial position (samson.SBPosition3).

Note

In Python Scripting you can directly apply a color or a color scheme to a node - it will internally create a material and apply it.

Getting nodes#

You can get an indexer of child nodes using the samson.SBNode.getNodes() function and the Node Specification Language.

Let’s, for example, select all node’s children atoms:

# get all atoms in the node
atomIndexer = node.getNodes('node.type atom')
# or the same using short names
atomIndexer = node.getNodes('n.t a')

# you can check the size of the indexer
print(len(atomIndexer))

Printing info#

For many node types, you can print some information on them:

# get all atoms in the active document
atomIndexer = SAMSON.getNodes('node.type atom')

# print the first atom from the indexer
if len(atomIndexer):
    atom = atomIndexer[0]
    print(atom)

See also

SAMSON SDK: SBDDataGraphNode

class samson.SBNode#

Bases: SBReferenceTarget

This class is the base class to describe a node in the data graph.

class Type(self: samson.SBNode.Type, value: int)#

Bases: pybind11_object

Members:

Undefined

StructuralModel

StructuralModelNode

Conformation

StructuralModelConformation

Path

StructuralModelPath

StructuralGroup

StructuralModelNodeGroup

Root

StructuralModelNodeRoot

Atom

StructuralModelNodeAtom

Bond

StructuralModelNodeBond

HydrogenBond

StructuralModelNodeHydrogenBond

HydrogenBondGroup

StructuralModelNodeHydrogenBondGroup

Residue

StructuralModelNodeResidue

Segment

StructuralModelNodeSegment

Chain

StructuralModelNodeChain

Molecule

StructuralModelNodeMolecule

Backbone

StructuralModelNodeBackbone

SideChain

StructuralModelNodeSideChain

VisualModel

Mesh

VisualModelMesh

DynamicalModel

ParticleSystem

DynamicalModelParticleSystem

RigidBodySystem

DynamicalModelRigidBodySystem

ArticulatedBodySystem

DynamicalModelArticulatedBodySystem

DynamicalNode

DynamicalModelNode

DynamicalGroup

DynamicalModelNodeGroup

DynamicalRoot

DynamicalModelNodeRoot

Particle

DynamicalModelNodeParticle

RigidBody

DynamicalModelNodeRigidBody

ArticulatedBody

DynamicalModelNodeArticulatedBody

InteractionModel

InteractionModelParticleSystem

InteractionModelRigidBodySystem

InteractionModelArticulatedBodySystem

PropertyModel

PropertyModelFunction

Simulator

SimulatorParticleSystem

SimulatorRigidBodySystem

SimulatorArticulatedBodySystem

StateUpdater

StateUpdaterParticleSystem

StateUpdaterRigidBodySystem

StateUpdaterArticulatedBodySystem

Animation

Camera

Document

DocumentManager

File

Folder

Label

Light

Note

Presentation

RenderPreset

DataGraphNodeGroup

NodeGroup

Controller

ControllerNode

Asset

Animation = <Type.Animation: 800>#
ArticulatedBody = <Type.ArticulatedBody: 603>#
ArticulatedBodySystem = <Type.ArticulatedBodySystem: 502>#
Asset = <Type.Asset: 50>#
Atom = <Type.Atom: 20100>#
Backbone = <Type.Backbone: 209>#
Bond = <Type.Bond: 202>#
Camera = <Type.Camera: 801>#
Chain = <Type.Chain: 207>#
Conformation = <Type.Conformation: 28>#
Controller = <Type.Controller: 40>#
ControllerNode = <Type.ControllerNode: 41>#
DataGraphNodeGroup = <Type.DataGraphNodeGroup: 30>#
Document = <Type.Document: 802>#
DocumentManager = <Type.DocumentManager: 803>#
DynamicalGroup = <Type.DynamicalGroup: 600>#
DynamicalModel = <Type.DynamicalModel: 5>#
DynamicalModelArticulatedBodySystem = <Type.ArticulatedBodySystem: 502>#
DynamicalModelNode = <Type.DynamicalNode: 6>#
DynamicalModelNodeArticulatedBody = <Type.ArticulatedBody: 603>#
DynamicalModelNodeGroup = <Type.DynamicalGroup: 600>#
DynamicalModelNodeParticle = <Type.Particle: 601>#
DynamicalModelNodeRigidBody = <Type.RigidBody: 602>#
DynamicalModelNodeRoot = <Type.DynamicalRoot: 60000>#
DynamicalModelParticleSystem = <Type.ParticleSystem: 500>#
DynamicalModelRigidBodySystem = <Type.RigidBodySystem: 501>#
DynamicalNode = <Type.DynamicalNode: 6>#
DynamicalRoot = <Type.DynamicalRoot: 60000>#
File = <Type.File: 804>#
Folder = <Type.Folder: 805>#
HydrogenBond = <Type.HydrogenBond: 20202>#
HydrogenBondGroup = <Type.HydrogenBondGroup: 20203>#
InteractionModel = <Type.InteractionModel: 7>#
InteractionModelArticulatedBodySystem = <Type.InteractionModelArticulatedBodySystem: 702>#
InteractionModelParticleSystem = <Type.InteractionModelParticleSystem: 700>#
InteractionModelRigidBodySystem = <Type.InteractionModelRigidBodySystem: 701>#
Label = <Type.Label: 806>#
Light = <Type.Light: 807>#
Mesh = <Type.Mesh: 300>#
Molecule = <Type.Molecule: 208>#
NodeGroup = <Type.DataGraphNodeGroup: 30>#
Note = <Type.Note: 808>#
Particle = <Type.Particle: 601>#
ParticleSystem = <Type.ParticleSystem: 500>#
Path = <Type.Path: 29>#
Presentation = <Type.Presentation: 809>#
PropertyModel = <Type.PropertyModel: 9>#
PropertyModelFunction = <Type.PropertyModelFunction: 900>#
RenderPreset = <Type.RenderPreset: 810>#
Residue = <Type.Residue: 204>#
RigidBody = <Type.RigidBody: 602>#
RigidBodySystem = <Type.RigidBodySystem: 501>#
Root = <Type.Root: 20000>#
Segment = <Type.Segment: 205>#
SideChain = <Type.SideChain: 210>#
Simulator = <Type.Simulator: 11>#
SimulatorArticulatedBodySystem = <Type.SimulatorArticulatedBodySystem: 1102>#
SimulatorParticleSystem = <Type.SimulatorParticleSystem: 1100>#
SimulatorRigidBodySystem = <Type.SimulatorRigidBodySystem: 1101>#
StateUpdater = <Type.StateUpdater: 15>#
StateUpdaterArticulatedBodySystem = <Type.StateUpdaterArticulatedBodySystem: 1503>#
StateUpdaterParticleSystem = <Type.StateUpdaterParticleSystem: 1501>#
StateUpdaterRigidBodySystem = <Type.StateUpdaterRigidBodySystem: 1502>#
StructuralGroup = <Type.StructuralGroup: 200>#
StructuralModel = <Type.StructuralModel: 1>#
StructuralModelConformation = <Type.Conformation: 28>#
StructuralModelNode = <Type.StructuralModelNode: 2>#
StructuralModelNodeAtom = <Type.Atom: 20100>#
StructuralModelNodeBackbone = <Type.Backbone: 209>#
StructuralModelNodeBond = <Type.Bond: 202>#
StructuralModelNodeChain = <Type.Chain: 207>#
StructuralModelNodeGroup = <Type.StructuralGroup: 200>#
StructuralModelNodeHydrogenBond = <Type.HydrogenBond: 20202>#
StructuralModelNodeHydrogenBondGroup = <Type.HydrogenBondGroup: 20203>#
StructuralModelNodeMolecule = <Type.Molecule: 208>#
StructuralModelNodeResidue = <Type.Residue: 204>#
StructuralModelNodeRoot = <Type.Root: 20000>#
StructuralModelNodeSegment = <Type.Segment: 205>#
StructuralModelNodeSideChain = <Type.SideChain: 210>#
StructuralModelPath = <Type.Path: 29>#
Undefined = <Type.Undefined: 0>#
VisualModel = <Type.VisualModel: 3>#
VisualModelMesh = <Type.Mesh: 300>#
property name#
property value#
addChild(self: samson.SBNode, node: samson.SBNode, nextNode: samson.SBNode = None) bool#

Adds a child to the node

addMaterial(self: samson.SBNode, material: SBDDataGraphNodeMaterial) bool#

Adds the material to the node. If the node already has a material, then does not do anything and returns False. The node takes ownership of the material.

Parameters:

material (samson.SBNodeMaterial) – A material.

Returns:

Returns True if it could add the material to the node.

Return type:

bool

canAddChild(self: samson.SBNode, node: samson.SBNode, nextNode: samson.SBNode = None) bool#

Returns whether this node can add node as a child

canAddChildType(self: samson.SBNode, nodeType: SBDDataGraphNode::Type) bool#

Returns whether this node can add a node with type nodeType as a child

canAddMaterial(self: samson.SBNode) bool#

Returns whether can add a material to the node based on its type

static canAddMaterialToNodeType(nodeType: SBDDataGraphNode::Type) bool#

Returns whether can add a material to a node of type nodeType

canHaveDescendantType(self: samson.SBNode, nodeType: SBDDataGraphNode::Type) bool#

Returns whether this node can have a node with type nodeType as a descendant

castToInteractionModelParticleSystem(self: samson.SBNode) SBMInteractionModelParticleSystem#

Casts (if possible) from SBNode to SBInteractionModelParticleSystem

castToLabel(self: samson.SBNode) SBDDocumentLabel#

Casts (if possible) from SBNode to SBLabel

castToMesh(self: samson.SBNode) SBMVisualModelMesh#

Casts (if possible) from SBNode to SBMesh

castToVisualModel(self: samson.SBNode) SBMVisualModel#

Casts (if possible) from SBNode to SBVisualModel

clone(self: samson.SBNode) samson.SBNode#

Returns a copy of the node and its descendants

countNodes(*args, **kwargs)#

Overloaded function.

  1. countNodes(self: samson.SBNode, selectionString: str = ‘*’, visitString: str = ‘*’, includeDependencies: bool = False) -> int

Counts nodes based on the provided selection filter selectionString and other parameters.

This function traverses the node’s sub-tree for which a predicate based on the visitString is True (depth-first), and stores counts the nodes for which the selectionString is true. Precisely, if the predicate based on the visitString returns false, the node is not visited, and neither are its descendants. If the predicate based on the visitString returns true, the node is visited, and this visit predicate will be used to decide whether its children are visited or not. Note that the node itself must satisfy the predicate based on the visitString else nothing is visited.

When includeDependencies is true, the function also counts nodes that are not descendants of this node, but are dependencies nonetheless. For example, in a SBBond, the two atoms connected by the bond are not children of the bond, but are still dependencies of the bond. Hence, provided they satisfy the selectionString and visitString, they are counted if includeDependencies is true.

Parameters:
  • selectionString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be selected.

  • visitString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be visited.

  • includeDependencies (bool, default=False) – Whether to include node dependencies or not.

Returns:

The number of nodes.

Return type:

int

Examples

Get a number of atoms in a node:

>>> number_of_atoms = node.countNodes('node.type atom')
  1. countNodes(self: samson.SBNode, nodeType: SBDDataGraphNode::Type, selectedNodesOnly: bool = False, visitString: str = ‘*’, includeDependencies: bool = False) -> int

Counts nodes based on nodeType and other parameters.

This function traverses the node’s sub-tree for which a predicate based on the visitString is True (depth-first), and counts nodes whose type is nodeType. Precisely, if the predicate based on the visitString returns false, the node is not visited, and neither are its descendants. If the predicate based on the visitString returns true, the node is visited, and this visit predicate will be used to decide whether its children are visited or not. Note that the node itself must satisfy the predicate based on the visitString else nothing is visited.

When includeDependencies is true, the function also counts nodes that are not descendants of this node, but are dependencies nonetheless. For example, in a SBBond, the two atoms connected by the bond are not children of the bond, but are still dependencies of the bond. Hence, provided they satisfy the nodeType and visitString, they are counted if includeDependencies is true.

Parameters:
  • nodeType (samson.SBNode.Type) – A type of nodes that should be collected.

  • selectedNodesOnly (bool, default=False) – If set to True, then only nodes that are selected, directly or via their parents, will be traversed.

  • visitString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be visited.

  • includeDependencies (bool, default=False) – Whether to include node dependencies or not.

Returns:

The number of nodes.

Return type:

int

Examples

Get a number of residues in a node:

>>> number_of_residues = node.countNodes(SBNode.Residue)
create(self: samson.SBNode) None#

Creates the node

descendsFrom(*args, **kwargs)#

Overloaded function.

  1. descendsFrom(self: samson.SBNode, node: samson.SBNode) -> bool

Returns True if and only if this node is node, or descends from it

  1. descendsFrom(self: samson.SBNode, nodeIndexer: SBDDataGraphNodeIndexer) -> bool

Returns True if and only if this node is one of the nodes of the nodeIndexer, or descends from one of them

erase(self: samson.SBNode) None#

Erases the node

getDocument(self: samson.SBNode) SBDDocument#

Returns the document the node belongs to

getFlags(self: samson.SBNode) int#

Returns the flags

getHierarchyString(self: samson.SBNode, separator: str = ' / ', includeNodeType: bool = False) str#

Returns a string with hierarchical information on the node and its parents names.

getInheritedFlags(self: samson.SBNode) int#

Returns the inherited flags

getMaterial(self: samson.SBNode) SBDDataGraphNodeMaterial#

Returns the material of the node.

getMaterialOwner(self: samson.SBNode) samson.SBNode#

Returns the node whose material is inherited.

getNextNode(*args, **kwargs)#

Overloaded function.

  1. getNextNode(self: samson.SBNode) -> samson.SBNode

Returns the pointer to the next node in the children of the node’s parent

  1. getNextNode(self: samson.SBNode, nodeType: SBDDataGraphNode::Type) -> samson.SBNode

Returns the pointer to the next node with type nodeType in the children of the node’s parent

static getNode(nodeIndex: int) samson.SBNode#

Returns the unique node corresponding to the node index nodeIndex

getNodes(*args, **kwargs)#

Overloaded function.

  1. getNodes(self: samson.SBNode, selectionString: str = ‘*’, visitString: str = ‘*’, includeDependencies: bool = False) -> SBDDataGraphNodeIndexer

Returns a node indexer with nodes based on the provided selection filter selectionString and other parameters.

This function traverses the node’s sub-tree for which a predicate based on the visitString is True (depth-first), and stores in nodeIndexer the nodes for which the selectionString is True. Precisely, if the predicate based on the visitString returns false, the node is not visited, and neither are its descendants. If the predicate based on the visitString returns True, the node is visited, and this visit predicate will be used to decide whether its children are visited or not. Note that the node itself must satisfy the predicate based on the visitString else nothing is visited.

When includeDependencies is True, the function also adds to nodeIndexer nodes that are not descendants of this node, but are dependencies nonetheless. For example, in a SBBond, the two atoms connected by the bond are not children of the bond, but are still dependencies of the bond. Hence, provided they satisfy the selectionString and visitString, they are added to the nodeIndexer if includeDependencies is True.

Parameters:
  • selectionString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be selected.

  • visitString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be visited.

  • includeDependencies (bool, default=False) – Whether to include node dependencies or not.

Returns:

A node indexer.

Return type:

samson.SBNodeIndexer

Examples

Get a node indexer with all the atoms in a node:

>>> nodeIndexer = node.getNodes('node.type atom')
  1. getNodes(self: samson.SBNode, nodeIndexer: SBDDataGraphNodeIndexer, selectionString: str = ‘*’, visitString: str = ‘*’, includeDependencies: bool = False) -> None

Collects into the nodeIndexer nodes based on the provided selection filter selectionString and other parameters.

This function traverses the node’s sub-tree for which a predicate based on the visitString is True (depth-first), and stores in nodeIndexer the nodes for which the selectionString is true. Precisely, if the predicate based on the visitString returns false, the node is not visited, and neither are its descendants. If the predicate based on the visitString returns true, the node is visited, and this visit predicate will be used to decide whether its children are visited or not. Note that the node itself must satisfy the predicate based on the visitString else nothing is visited.

When includeDependencies is true, the function also adds to nodeIndexer nodes that are not descendants of this node, but are dependencies nonetheless. For example, in a SBBond, the two atoms connected by the bond are not children of the bond, but are still dependencies of the bond. Hence, provided they satisfy the selectionString and visitString, they are added to the nodeIndexer if includeDependencies is true.

Parameters:
  • nodeIndexer (samson.SBNodeIndexer) – An existing node indexer in which nodes should be added. Note that this node indexer is not cleared in the function.

  • selectionString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be selected.

  • visitString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be visited.

  • includeDependencies (bool, default=False) – Whether to include node dependencies or not.

Notes

The nodeIndexer is not cleared when entering this function.

Examples

Collect in an existing nodeIndexer all the residues in a node:

>>> nodeIndexer = SBNodeIndexer()
>>> node.getNodes(nodeIndexer, 'node.type residue')
  1. getNodes(self: samson.SBNode, nodeType: SBDDataGraphNode::Type, selectedNodesOnly: bool = False, visitString: str = ‘*’, includeDependencies: bool = False) -> SBDDataGraphNodeIndexer

Returns a node indexer with nodes based on the provided nodeType, a selection status, a visit predicate, with or without dependencies.

This function traverses the node’s sub-tree for which a predicate based on the visitString is True (depth-first), and stores in nodeIndexer the nodes whose type is nodeType. Precisely, if the predicate based on the visitString returns false, the node is not visited, and neither are its descendants. If the predicate based on the visitString returns true, the node is visited, and this visit predicate will be used to decide whether its children are visited or not. Note that the node itself must satisfy the predicate based on the visitString else nothing is visited.

When includeDependencies is true, the function also adds to nodeIndexer nodes that are not descendants of this node, but are dependencies nonetheless. For example, in a SBBond, the two atoms connected by the bond are not children of the bond, but are still dependencies of the bond. Hence, provided they satisfy the nodeType and visitString, they are added to the nodeIndexer if includeDependencies is true.

Parameters:
  • nodeType (samson.SBNode.Type) – A type of nodes that should be collected.

  • selectedNodesOnly (bool, default=False) – If set to True, then only nodes that are selected, directly or via their parents, will be traversed.

  • visitString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be visited.

  • includeDependencies (bool, default=False) – Whether to include node dependencies or not.

Returns:

A node indexer.

Return type:

samson.SBNodeIndexer

Examples

Get a node indexer with all the atoms in a node:

>>> nodeIndexer = node.getNodes(SBNode.Atom)
  1. getNodes(self: samson.SBNode, nodeIndexer: SBDDataGraphNodeIndexer, nodeType: SBDDataGraphNode::Type, selectedNodesOnly: bool = False, visitString: str = ‘*’, includeDependencies: bool = False) -> None

Collects into the provided nodeIndexer nodes based on the provided nodeType, a selection status, a visit predicate, with or without dependencies.

This function traverses the node’s sub-tree for which a predicate based on the visitString is True (depth-first), and stores in nodeIndexer the nodes whose type is nodeType. Precisely, if the predicate based on the visitString returns false, the node is not visited, and neither are its descendants. If the predicate based on the visitString returns true, the node is visited, and this visit predicate will be used to decide whether its children are visited or not. Note that the node itself must satisfy the predicate based on the visitString else nothing is visited.

When includeDependencies is true, the function also adds to nodeIndexer nodes that are not descendants of this node, but are dependencies nonetheless. For example, in a SBBond, the two atoms connected by the bond are not children of the bond, but are still dependencies of the bond. Hence, provided they satisfy the nodeType and visitString, they are added to the nodeIndexer if includeDependencies is true.

Parameters:
  • nodeIndexer (samson.SBNodeIndexer) – An existing node indexer in which nodes should be added. Note that this node indexer is not cleared in the function.

  • nodeType (samson.SBNode.Type) – A type of nodes that should be collected.

  • selectedNodesOnly (bool, default=False) – If set to True, then only nodes that are selected, directly or via their parents, will be traversed.

  • visitString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be visited.

  • includeDependencies (bool, default=False) – Whether to include node dependencies or not.

Notes

The nodeIndexer is not cleared when entering this function.

Examples

Get a node indexer with all the bonds in a node:

>>> nodeIndexer = SBNodeIndexer()
>>> node.getNodes(nodeIndexer, SBNode.Bond)
getParent(self: samson.SBNode) samson.SBNode#

Returns the parent of the node

getPreviousNode(*args, **kwargs)#

Overloaded function.

  1. getPreviousNode(self: samson.SBNode) -> samson.SBNode

Returns the pointer to the previous node in the children of the node’s parent

  1. getPreviousNode(self: samson.SBNode, nodeType: SBDDataGraphNode::Type) -> samson.SBNode

Returns the pointer to the previous node with type nodeType in the children of the node’s parent

getRoot(self: samson.SBNode) samson.SBNode#

Returns the root of the hierarchy the node belongs to

getThisNode(self: samson.SBNode) samson.SBNode#

Returns the pointer to this node

static getTypeString(type: SBDDataGraphNode::Type, humanReadable: bool = False) str#

Returns a string describing the type of the data graph node type

hasNode(*args, **kwargs)#

Overloaded function.

  1. hasNode(self: samson.SBNode, selectionString: str = ‘*’, visitString: str = ‘*’, includeDependencies: bool = False) -> bool

Checks for nodes based on the provided selection filter selectionString and other parameters.

This function traverses the node’s sub-tree for which a predicate based on the visitString is True (depth-first), and stores checks for the nodes for which the selectionString is true. Precisely, if the predicate based on the visitString returns false, the node is not visited, and neither are its descendants. If the predicate based on the visitString returns true, the node is visited, and this visit predicate will be used to decide whether its children are visited or not. Note that the node itself must satisfy the predicate based on the visitString else nothing is visited.

When includeDependencies is true, the function also checks for nodes that are not descendants of this node, but are dependencies nonetheless. For example, in a SBBond, the two atoms connected by the bond are not children of the bond, but are still dependencies of the bond. Hence, provided they satisfy the selectionString and visitString, they are checked for if includeDependencies is true.

Parameters:
  • selectionString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be checked.

  • visitString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be visited.

  • includeDependencies (bool, default=False) – Whether to include node dependencies or not.

Returns:

Whether the nodes are present

Return type:

bool

Examples

Checks for the presence of atoms in a node:

>>> res = node.hasNode('node.type atom')
  1. hasNode(self: samson.SBNode, nodeType: SBDDataGraphNode::Type, selectedNodesOnly: bool = False, visitString: str = ‘*’, includeDependencies: bool = False) -> bool

Checks for nodes based on nodeType and other parameters.

This function traverses the node’s sub-tree for which a predicate based on the visitString is True (depth-first), and checks for nodes whose type is nodeType. Precisely, if the predicate based on the visitString returns false, the node is not visited, and neither are its descendants. If the predicate based on the visitString returns true, the node is visited, and this visit predicate will be used to decide whether its children are visited or not. Note that the node itself must satisfy the predicate based on the visitString else nothing is visited.

When includeDependencies is true, the function also checks for nodes that are not descendants of this node, but are dependencies nonetheless. For example, in a SBBond, the two atoms connected by the bond are not children of the bond, but are still dependencies of the bond. Hence, provided they satisfy the nodeType and visitString, they are checked for if includeDependencies is true.

Parameters:
  • nodeType (samson.SBNode.Type) – A type of nodes that should be checked for.

  • selectedNodesOnly (bool, default=False) – If set to True, then only nodes that are selected, directly or via their parents, will be traversed.

  • visitString (str, default='*') – A Node Specification Language expression (SAMSON API: Node Specification Language) that describes what nodes should be visited.

  • includeDependencies (bool, default=False) – Whether to include node dependencies or not.

Returns:

Whether the nodes are present

Return type:

bool

Examples

Checks for the presence of residues in a node:

>>> res = node.hasNode(SBNode.Residue)
hasOneOf(self: samson.SBNode, nodeIndexer: SBDDataGraphNodeIndexer) bool#

Returns True if and only if this node is one of the nodes of the nodeIndexer, or is the ancestor of one of them

isAtom(self: samson.SBNode) bool#

Returns True when the node is an atom

isBallAndStick(self: samson.SBNode) bool#

Returns True when the node is the default ball-and-stick visual model

isBond(self: samson.SBNode) bool#

Returns True when the node is a bond

isCartoon(self: samson.SBNode) bool#

Returns True when the node is the default cartoon visual model

isDynamicalModel(self: samson.SBNode) bool#

Returns True when the node is a dynamical model

isGaussianSurface(self: samson.SBNode) bool#

Returns True when the node is the default Gaussian surface visual model

isIn(*args, **kwargs)#

Overloaded function.

  1. isIn(self: samson.SBNode, node: samson.SBNode) -> bool

Returns True if and only if this node is node, or descends from it, or belongs to a group stored in node

  1. isIn(self: samson.SBNode, nodeIndexer: SBDDataGraphNodeIndexer) -> bool

Returns True if and only if this node is one of the nodes of the nodeIndexer, or descends from one of them, or belongs to a group stored in one of the nodes of the nodeIndexer

isInteractionModel(self: samson.SBNode) bool#

Returns True when the node is a interaction model

isLicorice(self: samson.SBNode) bool#

Returns True when the node is the default licorice visual model

isLight(self: samson.SBNode) bool#

Returns True when the node is a light

isMesh(self: samson.SBNode) bool#

Returns True when the node is a mesh

isModel(self: samson.SBNode) bool#

Returns True when the node is a model

isOneOf(self: samson.SBNode, nodeIndexer: SBDDataGraphNodeIndexer) bool#

Returns True if and only if this node is one of the nodes of the nodeIndexer

isPropertyModel(self: samson.SBNode) bool#

Returns True when the node is a property model

isRibbon(self: samson.SBNode) bool#

Returns True when the node is the default ribbon visual model

isSimulator(self: samson.SBNode) bool#

Returns True when the node is a simulator

isSolventAccessibleSurface(self: samson.SBNode) bool#

Returns True when the node is the default solvent accessible surface visual model

isSolventExcludedSurface(self: samson.SBNode) bool#

Returns True when the node is the default solvent excluded surface visual model

isStructuralModel(self: samson.SBNode) bool#

Returns True when the node is a structural model

isStructuralNode(self: samson.SBNode) bool#

Returns True when the node is a structural node

isTube(self: samson.SBNode) bool#

Returns True when the node is the default tube visual model

isType(self: samson.SBNode, type: SBDDataGraphNode::Type) bool#

Returns True when the type of the node corresponds to type

isVanDerWaals(self: samson.SBNode) bool#

Returns True when the node is the default van der Waals visual model

isVisualModel(self: samson.SBNode) bool#

Returns True when the node is a visual model

printDebugInfo(self: samson.SBNode, offset: int = 0) None#

Prints some debugging information in stdout

removeChild(self: samson.SBNode, node: samson.SBNode) bool#

Removes a child from the node

removeMaterial(self: samson.SBNode) bool#

Removes material from the node.

removeMaterialsFromDescendants(self: samson.SBNode) None#

Removes materials from all nodes that descend from this node, but it does not remove the material from the node itself.

setColor(self: samson.SBNode, color: samson.SBColor) bool#

Sets the color for the node (modifies an existing material of the node or adds a material with the given color). The color is set via the constant color scheme (SBColorSchemeConstant).

Parameters:

color (samson.SBColor) – A color.

Returns:

Returns True if it could set the color, else returns False.

Return type:

bool

setColorScheme(self: samson.SBNode, colorScheme: SBDDataGraphNodeColorScheme) bool#

Sets the color scheme for the node (modifies an existing material of the node or adds a material with the given color scheme). The color scheme is cloned internally, since the material owns the color scheme.

Parameters:

colorScheme (samson.SBNodeColorScheme) – A color scheme.

Returns:

Returns True if it could set the color scheme, else returns False.

Return type:

bool

setMaterial(self: samson.SBNode, material: SBDDataGraphNodeMaterial) bool#

Sets the material to the node. If the node already has a material, it removes it first. The node takes ownership of the material.

Parameters:

material (samson.SBNodeMaterial) – A material.

Returns:

Returns True if it could set the material to the node.

Return type:

bool

setMaterialAppearance(self: samson.SBNode, materialAppearance: SBDDataGraphNodeMaterialAppearance) bool#

Sets the material appearance materialAppearance to the node’s material. If the node does not have a material, then it sets the material first.

Parameters:

materialAppearance (SBNodeMaterialAppearance) – The material appearance

Returns:

Returns True if it could set the material appearance, else returns False.

Return type:

bool

Animation = <Type.Animation: 800>#
ArticulatedBody = <Type.ArticulatedBody: 603>#
ArticulatedBodySystem = <Type.ArticulatedBodySystem: 502>#
Asset = <Type.Asset: 50>#
Atom = <Type.Atom: 20100>#
Backbone = <Type.Backbone: 209>#
Bond = <Type.Bond: 202>#
Camera = <Type.Camera: 801>#
Chain = <Type.Chain: 207>#
Conformation = <Type.Conformation: 28>#
Controller = <Type.Controller: 40>#
ControllerNode = <Type.ControllerNode: 41>#
DataGraphNodeGroup = <Type.DataGraphNodeGroup: 30>#
Document = <Type.Document: 802>#
DocumentManager = <Type.DocumentManager: 803>#
DynamicalGroup = <Type.DynamicalGroup: 600>#
DynamicalModel = <Type.DynamicalModel: 5>#
DynamicalModelArticulatedBodySystem = <Type.ArticulatedBodySystem: 502>#
DynamicalModelNode = <Type.DynamicalNode: 6>#
DynamicalModelNodeArticulatedBody = <Type.ArticulatedBody: 603>#
DynamicalModelNodeGroup = <Type.DynamicalGroup: 600>#
DynamicalModelNodeParticle = <Type.Particle: 601>#
DynamicalModelNodeRigidBody = <Type.RigidBody: 602>#
DynamicalModelNodeRoot = <Type.DynamicalRoot: 60000>#
DynamicalModelParticleSystem = <Type.ParticleSystem: 500>#
DynamicalModelRigidBodySystem = <Type.RigidBodySystem: 501>#
DynamicalNode = <Type.DynamicalNode: 6>#
DynamicalRoot = <Type.DynamicalRoot: 60000>#
File = <Type.File: 804>#
Folder = <Type.Folder: 805>#
HydrogenBond = <Type.HydrogenBond: 20202>#
HydrogenBondGroup = <Type.HydrogenBondGroup: 20203>#
InteractionModel = <Type.InteractionModel: 7>#
InteractionModelArticulatedBodySystem = <Type.InteractionModelArticulatedBodySystem: 702>#
InteractionModelParticleSystem = <Type.InteractionModelParticleSystem: 700>#
InteractionModelRigidBodySystem = <Type.InteractionModelRigidBodySystem: 701>#
Label = <Type.Label: 806>#
Light = <Type.Light: 807>#
Mesh = <Type.Mesh: 300>#
Molecule = <Type.Molecule: 208>#
NodeGroup = <Type.DataGraphNodeGroup: 30>#
Note = <Type.Note: 808>#
Particle = <Type.Particle: 601>#
ParticleSystem = <Type.ParticleSystem: 500>#
Path = <Type.Path: 29>#
Presentation = <Type.Presentation: 809>#
PropertyModel = <Type.PropertyModel: 9>#
PropertyModelFunction = <Type.PropertyModelFunction: 900>#
RenderPreset = <Type.RenderPreset: 810>#
Residue = <Type.Residue: 204>#
RigidBody = <Type.RigidBody: 602>#
RigidBodySystem = <Type.RigidBodySystem: 501>#
Root = <Type.Root: 20000>#
Segment = <Type.Segment: 205>#
SideChain = <Type.SideChain: 210>#
Simulator = <Type.Simulator: 11>#
SimulatorArticulatedBodySystem = <Type.SimulatorArticulatedBodySystem: 1102>#
SimulatorParticleSystem = <Type.SimulatorParticleSystem: 1100>#
SimulatorRigidBodySystem = <Type.SimulatorRigidBodySystem: 1101>#
StateUpdater = <Type.StateUpdater: 15>#
StateUpdaterArticulatedBodySystem = <Type.StateUpdaterArticulatedBodySystem: 1503>#
StateUpdaterParticleSystem = <Type.StateUpdaterParticleSystem: 1501>#
StateUpdaterRigidBodySystem = <Type.StateUpdaterRigidBodySystem: 1502>#
StructuralGroup = <Type.StructuralGroup: 200>#
StructuralModel = <Type.StructuralModel: 1>#
StructuralModelConformation = <Type.Conformation: 28>#
StructuralModelNode = <Type.StructuralModelNode: 2>#
StructuralModelNodeAtom = <Type.Atom: 20100>#
StructuralModelNodeBackbone = <Type.Backbone: 209>#
StructuralModelNodeBond = <Type.Bond: 202>#
StructuralModelNodeChain = <Type.Chain: 207>#
StructuralModelNodeGroup = <Type.StructuralGroup: 200>#
StructuralModelNodeHydrogenBond = <Type.HydrogenBond: 20202>#
StructuralModelNodeHydrogenBondGroup = <Type.HydrogenBondGroup: 20203>#
StructuralModelNodeMolecule = <Type.Molecule: 208>#
StructuralModelNodeResidue = <Type.Residue: 204>#
StructuralModelNodeRoot = <Type.Root: 20000>#
StructuralModelNodeSegment = <Type.Segment: 205>#
StructuralModelNodeSideChain = <Type.SideChain: 210>#
StructuralModelPath = <Type.Path: 29>#
Undefined = <Type.Undefined: 0>#
VisualModel = <Type.VisualModel: 3>#
VisualModelMesh = <Type.Mesh: 300>#
property defaultOpacity#

Returns the default opacity.

property defaultTransparency#

Returns the default transparency.

property hasMaterial#

Returns whether the node has a material (by itself, or inherited).

property hasOpacityRange#

Returns whether the node has opacity range.

property hasTransparencyRange#

Returns whether the node has transparency range.

property highlightingFlag#

Highlighting flag

property isCreated#

Returns True if and only if the node is created

property isErased#

Returns True if and only if the node is erased

property isHighlighted#

Returns whether the node is highlighted

property isLocked#

Returns whether the node is locked

property isSelected#

Returns whether the node is selected

property isSerializable#

Returns True when the class is serializable

property isVisible#

Returns whether the node is visible

property lockedFlag#

Locked flag

property maximumOpacity#

Returns the maximum opacity.

property maximumTransparency#

Returns the maximum transparency.

property minimumOpacity#

Returns the minimum opacity.

property minimumTransparency#

Returns the minimum transparency.

property molecularWeight#

Returns the molecular weight

property name#

The name of the node

property nodeIndex#

Returns the node index (unique in the whole data graph, but non-persistent)

property nodeUUID#

Returns the node UUID

property numberOfAtoms#

Returns the number of atoms

property numberOfCarbons#

Returns the number of carbons

property numberOfChains#

Returns the number of chains

property numberOfCoarseGrainedAtoms#

Returns the number of coarse-grained atoms

property numberOfHydrogens#

Returns the number of hydrogens

property numberOfMolecules#

Returns the number of molecules

property numberOfNitrogens#

Returns the number of nitrogens

property numberOfOtherAtoms#

Returns the number of other atoms

property numberOfOxygens#

Returns the number of oxygens

property numberOfResidues#

Returns the number of residues

property numberOfSegments#

Returns the number of segments

property numberOfStructuralGroups#

Returns the number of structural groups

property numberOfStructuralModels#

Returns the number of structural models

property numberOfSulfurs#

Returns the number of sulfurs

property opacity#

Opacity.

property ownsMaterial#

Returns whether the node owns a material.

property selectionFlag#

Selection flag

property sumOfFormalCharges#

Returns the sum of formal charges

property sumOfPartialCharges#

Returns the sum of partial charges

property transparency#

Transparency

property type#

Returns the type of the data graph node

property typeString#

Returns a string describing the type of this data graph node

property visibilityFlag#

Visibility flag