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
with SAMSON.holding("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()

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)
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: SupportsInt | SupportsIndex)#

Bases: pybind11_object

Members:

Undefined : The undefined type

StructuralModel : Structural model

StructuralModelNode : Structural node

Conformation : Structural conformation

StructuralModelConformation : Structural conformation

Path : Structural path

StructuralModelPath : Structural path

StructuralGroup : Structural group

StructuralModelNodeGroup : Structural group

Root : Structural root

StructuralModelNodeRoot : Structural root

Atom : Atom

StructuralModelNodeAtom : Atom

Bond : Bond

StructuralModelNodeBond : Bond

HydrogenBond : Hydrogen bond

StructuralModelNodeHydrogenBond : Hydrogen bond

HydrogenBondGroup : Hydrogen bond group

StructuralModelNodeHydrogenBondGroup : Hydrogen bond group

Residue : Residue

StructuralModelNodeResidue : Residue

Segment : Segment

StructuralModelNodeSegment : Segment

Chain : Chain

StructuralModelNodeChain : Chain

Molecule : Molecule

StructuralModelNodeMolecule : Molecule

Backbone : Residue backbone

StructuralModelNodeBackbone : Residue backbone

SideChain : Residue side chain

StructuralModelNodeSideChain : Residue side chain

VisualModel : Visual model

Mesh : Mesh

VisualModelMesh : Mesh

DynamicalModel : Dynamical model

ParticleSystem : Particle dynamical model

DynamicalModelParticleSystem : Particle dynamical model

RigidBodySystem : Rigid-body dynamical model

DynamicalModelRigidBodySystem : Rigid-body dynamical model

ArticulatedBodySystem : Articulated-body dynamical model

DynamicalModelArticulatedBodySystem : Articulated-body dynamical model

DynamicalNode : Dynamical node

DynamicalModelNode : Dynamical node

DynamicalGroup : Dynamical group

DynamicalModelNodeGroup : Dynamical group

DynamicalRoot : Dynamical root

DynamicalModelNodeRoot : Dynamical root

Particle : Particle

DynamicalModelNodeParticle : Particle

RigidBody : Rigid body

DynamicalModelNodeRigidBody : Rigid body

ArticulatedBody : Articulated body

DynamicalModelNodeArticulatedBody : Articulated body

InteractionModel : Interaction model

InteractionModelParticleSystem : Particle interaction model

InteractionModelRigidBodySystem : Rigid-body interaction model

InteractionModelArticulatedBodySystem : Articulated-body interaction model

PropertyModel : Property model

PropertyModelFunction : Scalar field

Simulator : Simulator

SimulatorParticleSystem : Particle simulator

SimulatorRigidBodySystem : Rigid-body simulator

SimulatorArticulatedBodySystem : Articulated-body simulator

StateUpdater : State updater

StateUpdaterParticleSystem : Particle state updater

StateUpdaterRigidBodySystem : Rigid-body state updater

StateUpdaterArticulatedBodySystem : Articulated-body state updater

Animation : Animation

Camera : Camera

Document : Document

DocumentManager : Document manager

File : File

Folder : Folder

Label : Label

Light : Light

Note : Note

Presentation : Presentation

RenderPreset : Render preset

DataGraphNodeGroup : Group

NodeGroup : Group

Controller : Controller

ControllerNode : Controller node

Asset : 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#

Add material to the node.

If the node already has a material, this function does nothing and returns False. The node takes ownership of material.

Parameters:

material (samson.SBNodeMaterial) – Material to attach to the node.

Returns:

True if the material was added.

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: samson.SBNode.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: samson.SBNode.Type) bool#

Returns whether a material can be added to a node of type nodeType.

canHaveDescendantType(self: samson.SBNode, nodeType: samson.SBNode.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

Count descendant nodes selected by selectionString.

Traversal is depth-first and only visits nodes for which visitString evaluates to True. A node whose visit predicate evaluates to false is not visited, and neither are its descendants.

When includeDependencies is True, matching dependencies that are not descendants of this node, such as atoms referenced by an SBBond, are also counted.

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 matching node dependencies that are not descendants.

Returns:

Number of matching 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: samson.SBNode.Type, selectedNodesOnly: bool = False, visitString: str = ‘*’, includeDependencies: bool = False) -> int

Count descendant nodes whose type matches nodeType.

Traversal is depth-first and only visits nodes for which visitString evaluates to True. A node whose visit predicate evaluates to false is not visited, and neither are its descendants.

When includeDependencies is True, matching dependencies that are not descendants of this node, such as atoms referenced by an SBBond, are also counted.

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

  • selectedNodesOnly (bool, default=False) – If True, only nodes selected directly or through their parents are 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 matching node dependencies that are not descendants.

Returns:

Number of matching 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: samson.SBNode.Type) -> samson.SBNode

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

static getNode(nodeIndex: SupportsInt | SupportsIndex) samson.SBNode#

Returns the unique node corresponding to nodeIndex.

Parameters:

nodeIndex (int) – The runtime node index.

Returns:

The node corresponding to nodeIndex, if any.

Return type:

samson.SBNode

getNodes(*args, **kwargs)#

Overloaded function.

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

Return descendant nodes selected by selectionString.

Traversal is depth-first and only visits nodes for which visitString evaluates to True. A node whose visit predicate evaluates to false is not visited, and neither are its descendants.

When includeDependencies is True, the result may also include dependencies that are not descendants of this node, such as atoms referenced by an SBBond, provided they satisfy both predicates.

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 matching node dependencies that are not descendants.

Returns:

Node indexer containing the matching nodes.

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

Append matching descendant nodes to nodeIndexer.

Traversal is depth-first and only visits nodes for which visitString evaluates to True. A node whose visit predicate evaluates to false is not visited, and neither are its descendants.

When includeDependencies is True, the result may also include dependencies that are not descendants of this node, such as atoms referenced by an SBBond, provided they satisfy both predicates.

Parameters:
  • nodeIndexer (samson.SBNodeIndexer) – Existing destination indexer. It is not cleared by this 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 matching node dependencies that are not descendants.

Notes

The nodeIndexer argument 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: samson.SBNode.Type, selectedNodesOnly: bool = False, visitString: str = ‘*’, includeDependencies: bool = False) -> SBDDataGraphNodeIndexer

Return descendant nodes whose type matches nodeType.

Traversal is depth-first and only visits nodes for which visitString evaluates to True. A node whose visit predicate evaluates to false is not visited, and neither are its descendants.

When includeDependencies is True, the result may also include dependencies that are not descendants of this node, such as atoms referenced by an SBBond, provided they satisfy the type filter and visit predicate.

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

  • selectedNodesOnly (bool, default=False) – If True, only nodes selected directly or through their parents are 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 matching node dependencies that are not descendants.

Returns:

Node indexer containing the matching nodes.

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: samson.SBNode.Type, selectedNodesOnly: bool = False, visitString: str = ‘*’, includeDependencies: bool = False) -> None

Append descendant nodes whose type matches nodeType to nodeIndexer.

Traversal is depth-first and only visits nodes for which visitString evaluates to True. A node whose visit predicate evaluates to false is not visited, and neither are its descendants.

When includeDependencies is True, the destination indexer may also receive dependencies that are not descendants of this node, such as atoms referenced by an SBBond, provided they satisfy the type filter and visit predicate.

Parameters:
  • nodeIndexer (samson.SBNodeIndexer) – Existing destination indexer. It is not cleared by this function.

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

  • selectedNodesOnly (bool, default=False) – If True, only nodes selected directly or through their parents are 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 matching node dependencies that are not descendants.

Notes

The nodeIndexer argument 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: samson.SBNode.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: samson.SBNode.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

Check whether any descendant node matches selectionString.

Traversal is depth-first and only visits nodes for which visitString evaluates to True. A node whose visit predicate evaluates to false is not visited, and neither are its descendants.

When includeDependencies is True, the check also considers matching dependencies that are not descendants of this node, such as atoms referenced by an SBBond.

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 matching node dependencies that are not descendants.

Returns:

True if at least one matching node is found.

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: samson.SBNode.Type, selectedNodesOnly: bool = False, visitString: str = ‘*’, includeDependencies: bool = False) -> bool

Check whether any descendant node matches nodeType.

Traversal is depth-first and only visits nodes for which visitString evaluates to True. A node whose visit predicate evaluates to false is not visited, and neither are its descendants.

When includeDependencies is True, the check also considers matching dependencies that are not descendants of this node, such as atoms referenced by an SBBond.

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

  • selectedNodesOnly (bool, default=False) – If True, only nodes selected directly or through their parents are 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 matching node dependencies that are not descendants.

Returns:

True if at least one matching node is found.

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: samson.SBNode.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

print(self: samson.SBNode, offset: SupportsInt | SupportsIndex = 0) None#

Prints 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#

Set the node color to color.

This updates the existing material when present, or creates a material when the node has none. The color is applied through a constant SBColorSchemeConstant.

Parameters:

color (samson.SBColor) – Color to apply.

Returns:

True if the color was applied, or False otherwise.

Return type:

bool

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

Set the node color scheme to colorScheme.

This updates the existing material when present, or creates a material when the node has none. colorScheme is cloned internally because the material owns the stored scheme.

Parameters:

colorScheme (samson.SBNodeColorScheme) – Color scheme to apply.

Returns:

True if the color scheme was applied, or False otherwise.

Return type:

bool

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

Replace the node material with material.

If the node already has a material, it is removed first. The node takes ownership of material.

Parameters:

material (samson.SBNodeMaterial) – Material to attach to the node.

Returns:

True if the material was set successfully.

Return type:

bool

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

Set the node material appearance to materialAppearance.

If the node does not already have a material, one is created first.

Parameters:

materialAppearance (samson.SBNodeMaterialAppearance) – Appearance parameters to apply to the node material.

Returns:

True if the appearance was applied, or False otherwise.

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 inheritedOpacity#

Returns the cumulative inherited opacity.

property inheritedTransparency#

Returns the cumulative inherited transparency.

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