Reaction Center

The Reaction Center represents the visual anchor point of a Reaction in the network diagram. It serves as the central location where Curves connect reactants, products, and modifiers.

A Reaction Center can be represented in two ways:

  • As a Curve — for simple or implicit visual styles where the connection itself acts as the anchor.

  • As a list of Shapes — for explicit, node-like visual centers that mirror how Species or Compartments are drawn.

After loading a model and retrieving a Reaction, you can:

  • Get the Reaction Center with get_center().

Example:

import sbmlnetwork as sn

net = sn.load("my_model.xml")

# Get reaction id
reaction_id = net.get_reaction_ids()[0]

# Get the Reaction Center
center = net.get_reaction(reaction_id).get_center()

# If the center is a list of Shapes
if center.is_shapes():
   for shape in center.get_shapes_list():
       print(shape.get_type())

# Switch to curve
center.switch_to_curve()

# If the center is a Curve
if center.is_curve():
   print(len(center.get_curve().get_segments()))

Core Methods

Representation

is_curve()

Return whether this Reaction Center is represented as a Curve (i.e., no shapes present).

Return type:

bool

is_shapes()

Return whether this Reaction Center is represented as a list of Shapes.

Return type:

bool

Switching Representations

switch_to_curve()

Convert this center to its Curve representation by removing all existing shapes.

Returns:

True on success, False if any shape could not be removed.

switch_to_shapes()

Convert this center to its Shapes representation. If no shapes exist, adds a default rectangle.

Returns:

True on success, False if the default shape could not be added.

Accessing Representations

get_curve()

If the center is a curve, return the associated Curve; otherwise, return None.

Return type:

Curve or None

curve

Alias for get_curve().

get_shapes_list()

Return a ShapeList of all shapes representing the center.

Return type:

ShapeList

shapes

Alias for get_shapes_list().

Mapping to Reaction

get_reaction()

Return the parent Reaction object this center belongs to.

Return type:

Reaction

reaction

Alias for get_reaction().

Movement

move(delta)

Translate the center by the given (dx, dy) offset.

  • If it’s a curve, all segments are shifted by the offset.

  • If it’s shapes, returns True (shapes maintain relative layout).

Parameters:

delta (tuple[float, float]) – Offset vector.

Returns:

True on success, False on failure.

Information

property info

Human-readable summary of glyph state for debugging.

Return type:

str

get_info()

Generate the info string.

Example Workflow

import sbmlnetwork as sn

 # Load the SBML model
 net = sn.load("my_model.xml")

 # Fetch the Reaction Center for reaction "R1"
 center = net.get_reactions_list()[0].get_center()

 # Switch to Shapes representation if currently a curve
 if center.is_curve():
    center.switch_to_shapes()

 # Move the center downward by 40 diagram units
 center.move((0.0, -40.0))

 # Examine the shapes of the center
 for shape in center.get_shapes_list():
    print(shape.get_type(), "border color:", shape.get_border_color())