Skip to content

AF

momapy.sbgn.af

Classes for SBGN Activity Flow (AF) maps.

This module provides classes for modeling and laying out SBGN-AF maps, including biological activities, influences, logical operators, and their visual representations.

Classes:

Name Description
Activity

Activity in an SBGN-AF map.

AndOperator

AND logical operator.

AndOperatorLayout

Layout for AND operators.

BiologicalActivity

Biological activity.

BiologicalActivityLayout

Layout for biological activities.

Compartment

Compartment in an SBGN-AF map.

CompartmentLayout

Layout for compartments.

ComplexUnitOfInformation

Unit of information for complexes.

ComplexUnitOfInformationLayout

Layout for complex units of information.

DelayOperator

DELAY logical operator.

DelayOperatorLayout

Layout for DELAY operators.

EquivalenceArcLayout

Layout for equivalence arcs.

Influence

Influence between activities.

LogicArcLayout

Layout for logic arcs.

LogicalOperator

Logical operator.

LogicalOperatorInput

Input to a logical operator.

MacromoleculeUnitOfInformation

Unit of information for macromolecules.

MacromoleculeUnitOfInformationLayout

Layout for macromolecule units of information.

NecessaryStimulation

Necessary stimulation.

NecessaryStimulationLayout

Layout for necessary stimulations.

NegativeInfluence

Negative influence.

NegativeInfluenceLayout

Layout for negative influences.

NotOperator

NOT logical operator.

NotOperatorLayout

Layout for NOT operators.

NucleicAcidFeatureUnitOfInformation

Unit of information for nucleic acid features.

NucleicAcidFeatureUnitOfInformationLayout

Layout for nucleic acid feature units of information.

OrOperator

OR logical operator.

OrOperatorLayout

Layout for OR operators.

PerturbationUnitOfInformation

Unit of information for perturbations.

PerturbationUnitOfInformationLayout

Layout for perturbation units of information.

Phenotype

Phenotype activity.

PhenotypeLayout

Layout for phenotypes.

PositiveInfluence

Positive influence.

PositiveInfluenceLayout

Layout for positive influences.

SBGNAFLayout

SBGN-AF layout.

SBGNAFMap

SBGN-AF map.

SBGNAFModel

SBGN-AF model.

SimpleChemicalUnitOfInformation

Unit of information for simple chemicals.

SimpleChemicalUnitOfInformationLayout

Layout for simple chemical units of information.

Submap

Submap element.

SubmapLayout

Layout for submaps.

Tag

Tag element.

TagLayout

Layout for tags.

TagReference

Reference to a tag.

Terminal

Terminal element.

TerminalLayout

Layout for terminals.

TerminalReference

Reference to a terminal.

UnitOfInformation

Unit of information for activities.

UnknownInfluence

Unknown influence.

UnknownInfluenceLayout

Layout for unknown influences.

UnspecifiedEntityUnitOfInformation

Unit of information for unspecified entities.

UnspecifiedEntityUnitOfInformationLayout

Layout for unspecified entity units of information.

Attributes:

Name Type Description
SBGNAFLayoutBuilder

Builder class for SBGNAFLayout.

SBGNAFMapBuilder

Builder class for SBGNAFMap.

SBGNAFModelBuilder

Builder class for SBGNAFModel.

Activity dataclass

Activity(*, id_: str = make_uuid4_as_str())

Bases: SBGNModelElement

Activity in an SBGN-AF map.

Activities represent biological activities or processes.

Attributes:

Name Type Description
label Optional[str]

The label of the activity.

compartment Optional[Compartment]

The compartment containing this activity.

AndOperator dataclass

AndOperator(*, id_: str = make_uuid4_as_str(), inputs: frozenset[LogicalOperatorInput] = frozenset())

Bases: LogicalOperator

AND logical operator.

AndOperatorLayout dataclass

AndOperatorLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 30.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 30.0, direction: Direction = HORIZONTAL, left_to_right: bool = True, left_connector_length: float = 10.0, right_connector_length: float = 10.0, left_connector_stroke: NoneValueType | Color | None = None, left_connector_stroke_width: float | None = None, left_connector_stroke_dasharray: NoneValueType | tuple[float] | None = None, left_connector_stroke_dashoffset: float | None = None, left_connector_fill: NoneValueType | Color | None = None, left_connector_transform: NoneValueType | tuple[Transformation] | None = None, left_connector_filter: NoneValueType | Filter | None = None, right_connector_stroke: NoneValueType | Color | None = None, right_connector_stroke_width: float | None = None, right_connector_stroke_dasharray: NoneValueType | tuple[float] | None = None, right_connector_stroke_dashoffset: float | None = None, right_connector_fill: NoneValueType | Color | None = None, right_connector_transform: NoneValueType | tuple[Transformation] | None = None, right_connector_filter: NoneValueType | Filter | None = None)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Layout for AND operators.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Get the east (right) anchor point.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

left_connector_base

Get the base point of the left connector.

left_connector_tip

Get the tip point of the left connector.

north

Get the north (top) anchor point.

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

right_connector_base

Get the base point of the right connector.

right_connector_tip

Get the tip point of the right connector.

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Get the south (bottom) anchor point.

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Get the west (left) anchor point.

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east()

Get the east (right) anchor point.

Returns:

Type Description

Point on the east side of the element.

Source code in src/momapy/sbgn/core.py
def east(self):
    """Get the east (right) anchor point.

    Returns:
        Point on the east side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x + self.width / 2, self.y)
    else:
        return momapy.geometry.Point(
            self.x + self.width / 2 + self.right_connector_length, self.y
        )

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

left_connector_base

left_connector_base()

Get the base point of the left connector.

Returns:

Type Description

Point where the left connector attaches to the shape.

Source code in src/momapy/sbgn/core.py
def left_connector_base(self):
    """Get the base point of the left connector.

    Returns:
        Point where the left connector attaches to the shape.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x, self.y - self.height / 2)
    else:
        return momapy.geometry.Point(self.x - self.width / 2, self.y)

left_connector_tip

left_connector_tip()

Get the tip point of the left connector.

Returns:

Type Description

Point at the end of the left connector line.

Source code in src/momapy/sbgn/core.py
def left_connector_tip(self):
    """Get the tip point of the left connector.

    Returns:
        Point at the end of the left connector line.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y - self.height / 2 - self.left_connector_length
        )
    else:
        return momapy.geometry.Point(
            self.x - self.width / 2 - self.left_connector_length, self.y
        )

north

north()

Get the north (top) anchor point.

Returns:

Type Description

Point on the north side of the element.

Source code in src/momapy/sbgn/core.py
def north(self):
    """Get the north (top) anchor point.

    Returns:
        Point on the north side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y - self.height / 2 - self.left_connector_length
        )
    else:
        return momapy.geometry.Point(self.x, self.y - self.height / 2)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

right_connector_base

right_connector_base()

Get the base point of the right connector.

Returns:

Type Description

Point where the right connector attaches to the shape.

Source code in src/momapy/sbgn/core.py
def right_connector_base(self):
    """Get the base point of the right connector.

    Returns:
        Point where the right connector attaches to the shape.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x, self.y + self.height / 2)
    else:
        return momapy.geometry.Point(self.x + self.width / 2, self.y)

right_connector_tip

right_connector_tip()

Get the tip point of the right connector.

Returns:

Type Description

Point at the end of the right connector line.

Source code in src/momapy/sbgn/core.py
def right_connector_tip(self):
    """Get the tip point of the right connector.

    Returns:
        Point at the end of the right connector line.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y + self.height / 2 + self.right_connector_length
        )
    else:
        return momapy.geometry.Point(
            self.x + self.width / 2 + self.right_connector_length, self.y
        )

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south()

Get the south (bottom) anchor point.

Returns:

Type Description

Point on the south side of the element.

Source code in src/momapy/sbgn/core.py
def south(self):
    """Get the south (bottom) anchor point.

    Returns:
        Point on the south side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y + self.height / 2 + self.right_connector_length
        )
    else:
        return momapy.geometry.Point(self.x, self.y + self.height / 2)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west()

Get the west (left) anchor point.

Returns:

Type Description

Point on the west side of the element.

Source code in src/momapy/sbgn/core.py
def west(self):
    """Get the west (left) anchor point.

    Returns:
        Point on the west side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x - self.width / 2, self.y)
    else:
        return momapy.geometry.Point(
            self.x - self.width / 2 - self.left_connector_length, self.y
        )

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

BiologicalActivity dataclass

BiologicalActivity(*, id_: str = make_uuid4_as_str(), units_of_information: frozenset[UnitOfInformation] = frozenset())

Bases: Activity

Biological activity.

Represents a biological activity with associated units of information.

Attributes:

Name Type Description
units_of_information frozenset[UnitOfInformation]

Units of information for the activity.

BiologicalActivityLayout dataclass

BiologicalActivityLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 30.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 60.0)

Bases: _SimpleMixin, SBGNNode

Layout for biological activities.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Compartment dataclass

Compartment(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None)

Bases: SBGNModelElement

Compartment in an SBGN-AF map.

Compartments represent distinct spatial regions where activities are located.

Attributes:

Name Type Description
label Optional[str]

The label of the compartment.

CompartmentLayout dataclass

CompartmentLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 80.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 80.0, rounded_corners: float = 5.0, border_stroke_width: float | None = 3.25)

Bases: _SimpleMixin, SBGNNode

Layout for compartments.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

ComplexUnitOfInformation dataclass

ComplexUnitOfInformation(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None)

Bases: UnitOfInformation

Unit of information for complexes.

ComplexUnitOfInformationLayout dataclass

ComplexUnitOfInformationLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 12.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 12.0, cut_corners: float = 5.0)

Bases: _SimpleMixin, SBGNNode

Layout for complex units of information.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

DelayOperator dataclass

DelayOperator(*, id_: str = make_uuid4_as_str(), inputs: frozenset[LogicalOperatorInput] = frozenset())

Bases: LogicalOperator

DELAY logical operator.

DelayOperatorLayout dataclass

DelayOperatorLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 30.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 30.0, direction: Direction = HORIZONTAL, left_to_right: bool = True, left_connector_length: float = 10.0, right_connector_length: float = 10.0, left_connector_stroke: NoneValueType | Color | None = None, left_connector_stroke_width: float | None = None, left_connector_stroke_dasharray: NoneValueType | tuple[float] | None = None, left_connector_stroke_dashoffset: float | None = None, left_connector_fill: NoneValueType | Color | None = None, left_connector_transform: NoneValueType | tuple[Transformation] | None = None, left_connector_filter: NoneValueType | Filter | None = None, right_connector_stroke: NoneValueType | Color | None = None, right_connector_stroke_width: float | None = None, right_connector_stroke_dasharray: NoneValueType | tuple[float] | None = None, right_connector_stroke_dashoffset: float | None = None, right_connector_fill: NoneValueType | Color | None = None, right_connector_transform: NoneValueType | tuple[Transformation] | None = None, right_connector_filter: NoneValueType | Filter | None = None)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Layout for DELAY operators.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Get the east (right) anchor point.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

left_connector_base

Get the base point of the left connector.

left_connector_tip

Get the tip point of the left connector.

north

Get the north (top) anchor point.

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

right_connector_base

Get the base point of the right connector.

right_connector_tip

Get the tip point of the right connector.

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Get the south (bottom) anchor point.

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Get the west (left) anchor point.

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east()

Get the east (right) anchor point.

Returns:

Type Description

Point on the east side of the element.

Source code in src/momapy/sbgn/core.py
def east(self):
    """Get the east (right) anchor point.

    Returns:
        Point on the east side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x + self.width / 2, self.y)
    else:
        return momapy.geometry.Point(
            self.x + self.width / 2 + self.right_connector_length, self.y
        )

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

left_connector_base

left_connector_base()

Get the base point of the left connector.

Returns:

Type Description

Point where the left connector attaches to the shape.

Source code in src/momapy/sbgn/core.py
def left_connector_base(self):
    """Get the base point of the left connector.

    Returns:
        Point where the left connector attaches to the shape.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x, self.y - self.height / 2)
    else:
        return momapy.geometry.Point(self.x - self.width / 2, self.y)

left_connector_tip

left_connector_tip()

Get the tip point of the left connector.

Returns:

Type Description

Point at the end of the left connector line.

Source code in src/momapy/sbgn/core.py
def left_connector_tip(self):
    """Get the tip point of the left connector.

    Returns:
        Point at the end of the left connector line.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y - self.height / 2 - self.left_connector_length
        )
    else:
        return momapy.geometry.Point(
            self.x - self.width / 2 - self.left_connector_length, self.y
        )

north

north()

Get the north (top) anchor point.

Returns:

Type Description

Point on the north side of the element.

Source code in src/momapy/sbgn/core.py
def north(self):
    """Get the north (top) anchor point.

    Returns:
        Point on the north side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y - self.height / 2 - self.left_connector_length
        )
    else:
        return momapy.geometry.Point(self.x, self.y - self.height / 2)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

right_connector_base

right_connector_base()

Get the base point of the right connector.

Returns:

Type Description

Point where the right connector attaches to the shape.

Source code in src/momapy/sbgn/core.py
def right_connector_base(self):
    """Get the base point of the right connector.

    Returns:
        Point where the right connector attaches to the shape.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x, self.y + self.height / 2)
    else:
        return momapy.geometry.Point(self.x + self.width / 2, self.y)

right_connector_tip

right_connector_tip()

Get the tip point of the right connector.

Returns:

Type Description

Point at the end of the right connector line.

Source code in src/momapy/sbgn/core.py
def right_connector_tip(self):
    """Get the tip point of the right connector.

    Returns:
        Point at the end of the right connector line.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y + self.height / 2 + self.right_connector_length
        )
    else:
        return momapy.geometry.Point(
            self.x + self.width / 2 + self.right_connector_length, self.y
        )

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south()

Get the south (bottom) anchor point.

Returns:

Type Description

Point on the south side of the element.

Source code in src/momapy/sbgn/core.py
def south(self):
    """Get the south (bottom) anchor point.

    Returns:
        Point on the south side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y + self.height / 2 + self.right_connector_length
        )
    else:
        return momapy.geometry.Point(self.x, self.y + self.height / 2)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west()

Get the west (left) anchor point.

Returns:

Type Description

Point on the west side of the element.

Source code in src/momapy/sbgn/core.py
def west(self):
    """Get the west (left) anchor point.

    Returns:
        Point on the west side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x - self.width / 2, self.y)
    else:
        return momapy.geometry.Point(
            self.x - self.width / 2 - self.left_connector_length, self.y
        )

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

EquivalenceArcLayout dataclass

EquivalenceArcLayout(path_fill: NoneValueType | Color | None = NoneValue, path_stroke: NoneValueType | Color | None = black, path_stroke_width: float | None = 1.25, arrowhead_fill: NoneValueType | Color | None = white, arrowhead_stroke: NoneValueType | Color | None = black, arrowhead_stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | BezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_filter: NoneValueType | Filter | None = None, arrowhead_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, arrowhead_stroke_dashoffset: NoneValueType | float | None = None, arrowhead_transform: NoneValueType | tuple[Transformation] | None = None)

Bases: SBGNSingleHeadedArc

Layout for equivalence arcs.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the group layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    drawing_elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=tuple(drawing_elements),
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(self.start_shorten, "start")
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=tuple(actions),
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    drawing_elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

Influence dataclass

Influence(*, id_: str = make_uuid4_as_str(), source: BiologicalActivity | LogicalOperator, target: Activity)

Bases: SBGNModelElement

Influence between activities.

Represents an influence from a source activity to a target activity.

Attributes:

Name Type Description
source BiologicalActivity | LogicalOperator

The source activity or logical operator.

target Activity

The target activity being influenced.

LogicArcLayout dataclass

LogicArcLayout(path_fill: NoneValueType | Color | None = NoneValue, path_stroke: NoneValueType | Color | None = black, path_stroke_width: float | None = 1.25, arrowhead_fill: NoneValueType | Color | None = white, arrowhead_stroke: NoneValueType | Color | None = black, arrowhead_stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | BezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_filter: NoneValueType | Filter | None = None, arrowhead_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, arrowhead_stroke_dashoffset: NoneValueType | float | None = None, arrowhead_transform: NoneValueType | tuple[Transformation] | None = None)

Bases: SBGNSingleHeadedArc

Layout for logic arcs.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the group layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    drawing_elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=tuple(drawing_elements),
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(self.start_shorten, "start")
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=tuple(actions),
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    drawing_elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

LogicalOperator dataclass

LogicalOperator(*, id_: str = make_uuid4_as_str(), inputs: frozenset[LogicalOperatorInput] = frozenset())

Bases: SBGNModelElement

Logical operator.

Represents logical operations (AND, OR, NOT, DELAY) on activities.

Attributes:

Name Type Description
inputs frozenset[LogicalOperatorInput]

Input connections to the logical operator.

LogicalOperatorInput dataclass

LogicalOperatorInput(*, id_: str = make_uuid4_as_str(), element: Union[BiologicalActivity, LogicalOperator])

Bases: SBGNRole

Input to a logical operator.

Represents an input connection to a logical operator.

Attributes:

Name Type Description
element Union[BiologicalActivity, LogicalOperator]

The biological activity or logical operator providing the input.

MacromoleculeUnitOfInformation dataclass

MacromoleculeUnitOfInformation(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None)

Bases: UnitOfInformation

Unit of information for macromolecules.

MacromoleculeUnitOfInformationLayout dataclass

MacromoleculeUnitOfInformationLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 12.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 12.0, rounded_corners: float = 5.0)

Bases: _SimpleMixin, SBGNNode

Layout for macromolecule units of information.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

NecessaryStimulation dataclass

NecessaryStimulation(*, id_: str = make_uuid4_as_str(), source: BiologicalActivity | LogicalOperator, target: Activity)

Bases: Influence

Necessary stimulation.

NecessaryStimulationLayout dataclass

NecessaryStimulationLayout(path_fill: NoneValueType | Color | None = NoneValue, path_stroke: NoneValueType | Color | None = black, path_stroke_width: float | None = 1.25, arrowhead_fill: NoneValueType | Color | None = white, arrowhead_stroke: NoneValueType | Color | None = black, arrowhead_stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | BezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_filter: NoneValueType | Filter | None = None, arrowhead_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, arrowhead_stroke_dashoffset: NoneValueType | float | None = None, arrowhead_transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_bar_height: float = 12.0, arrowhead_sep: float = 3.0, arrowhead_triangle_height: float = 10.0, arrowhead_triangle_width: float = 10.0)

Bases: SBGNSingleHeadedArc

Layout for necessary stimulations.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the group layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    drawing_elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=tuple(drawing_elements),
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(self.start_shorten, "start")
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=tuple(actions),
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    drawing_elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

NegativeInfluence dataclass

NegativeInfluence(*, id_: str = make_uuid4_as_str(), source: BiologicalActivity | LogicalOperator, target: Activity)

Bases: Influence

Negative influence.

NegativeInfluenceLayout dataclass

NegativeInfluenceLayout(path_fill: NoneValueType | Color | None = NoneValue, path_stroke: NoneValueType | Color | None = black, path_stroke_width: float | None = 1.25, arrowhead_fill: NoneValueType | Color | None = white, arrowhead_stroke: NoneValueType | Color | None = black, arrowhead_stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | BezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_filter: NoneValueType | Filter | None = None, arrowhead_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, arrowhead_stroke_dashoffset: NoneValueType | float | None = None, arrowhead_transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_height: float = 10.0)

Bases: SBGNSingleHeadedArc

Layout for negative influences.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the group layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    drawing_elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=tuple(drawing_elements),
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(self.start_shorten, "start")
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=tuple(actions),
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    drawing_elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

NotOperator dataclass

NotOperator(*, id_: str = make_uuid4_as_str(), inputs: frozenset[LogicalOperatorInput] = frozenset())

Bases: LogicalOperator

NOT logical operator.

NotOperatorLayout dataclass

NotOperatorLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 30.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 30.0, direction: Direction = HORIZONTAL, left_to_right: bool = True, left_connector_length: float = 10.0, right_connector_length: float = 10.0, left_connector_stroke: NoneValueType | Color | None = None, left_connector_stroke_width: float | None = None, left_connector_stroke_dasharray: NoneValueType | tuple[float] | None = None, left_connector_stroke_dashoffset: float | None = None, left_connector_fill: NoneValueType | Color | None = None, left_connector_transform: NoneValueType | tuple[Transformation] | None = None, left_connector_filter: NoneValueType | Filter | None = None, right_connector_stroke: NoneValueType | Color | None = None, right_connector_stroke_width: float | None = None, right_connector_stroke_dasharray: NoneValueType | tuple[float] | None = None, right_connector_stroke_dashoffset: float | None = None, right_connector_fill: NoneValueType | Color | None = None, right_connector_transform: NoneValueType | tuple[Transformation] | None = None, right_connector_filter: NoneValueType | Filter | None = None)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Layout for NOT operators.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Get the east (right) anchor point.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

left_connector_base

Get the base point of the left connector.

left_connector_tip

Get the tip point of the left connector.

north

Get the north (top) anchor point.

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

right_connector_base

Get the base point of the right connector.

right_connector_tip

Get the tip point of the right connector.

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Get the south (bottom) anchor point.

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Get the west (left) anchor point.

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east()

Get the east (right) anchor point.

Returns:

Type Description

Point on the east side of the element.

Source code in src/momapy/sbgn/core.py
def east(self):
    """Get the east (right) anchor point.

    Returns:
        Point on the east side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x + self.width / 2, self.y)
    else:
        return momapy.geometry.Point(
            self.x + self.width / 2 + self.right_connector_length, self.y
        )

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

left_connector_base

left_connector_base()

Get the base point of the left connector.

Returns:

Type Description

Point where the left connector attaches to the shape.

Source code in src/momapy/sbgn/core.py
def left_connector_base(self):
    """Get the base point of the left connector.

    Returns:
        Point where the left connector attaches to the shape.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x, self.y - self.height / 2)
    else:
        return momapy.geometry.Point(self.x - self.width / 2, self.y)

left_connector_tip

left_connector_tip()

Get the tip point of the left connector.

Returns:

Type Description

Point at the end of the left connector line.

Source code in src/momapy/sbgn/core.py
def left_connector_tip(self):
    """Get the tip point of the left connector.

    Returns:
        Point at the end of the left connector line.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y - self.height / 2 - self.left_connector_length
        )
    else:
        return momapy.geometry.Point(
            self.x - self.width / 2 - self.left_connector_length, self.y
        )

north

north()

Get the north (top) anchor point.

Returns:

Type Description

Point on the north side of the element.

Source code in src/momapy/sbgn/core.py
def north(self):
    """Get the north (top) anchor point.

    Returns:
        Point on the north side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y - self.height / 2 - self.left_connector_length
        )
    else:
        return momapy.geometry.Point(self.x, self.y - self.height / 2)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

right_connector_base

right_connector_base()

Get the base point of the right connector.

Returns:

Type Description

Point where the right connector attaches to the shape.

Source code in src/momapy/sbgn/core.py
def right_connector_base(self):
    """Get the base point of the right connector.

    Returns:
        Point where the right connector attaches to the shape.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x, self.y + self.height / 2)
    else:
        return momapy.geometry.Point(self.x + self.width / 2, self.y)

right_connector_tip

right_connector_tip()

Get the tip point of the right connector.

Returns:

Type Description

Point at the end of the right connector line.

Source code in src/momapy/sbgn/core.py
def right_connector_tip(self):
    """Get the tip point of the right connector.

    Returns:
        Point at the end of the right connector line.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y + self.height / 2 + self.right_connector_length
        )
    else:
        return momapy.geometry.Point(
            self.x + self.width / 2 + self.right_connector_length, self.y
        )

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south()

Get the south (bottom) anchor point.

Returns:

Type Description

Point on the south side of the element.

Source code in src/momapy/sbgn/core.py
def south(self):
    """Get the south (bottom) anchor point.

    Returns:
        Point on the south side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y + self.height / 2 + self.right_connector_length
        )
    else:
        return momapy.geometry.Point(self.x, self.y + self.height / 2)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west()

Get the west (left) anchor point.

Returns:

Type Description

Point on the west side of the element.

Source code in src/momapy/sbgn/core.py
def west(self):
    """Get the west (left) anchor point.

    Returns:
        Point on the west side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x - self.width / 2, self.y)
    else:
        return momapy.geometry.Point(
            self.x - self.width / 2 - self.left_connector_length, self.y
        )

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

NucleicAcidFeatureUnitOfInformation dataclass

NucleicAcidFeatureUnitOfInformation(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None)

Bases: UnitOfInformation

Unit of information for nucleic acid features.

NucleicAcidFeatureUnitOfInformationLayout dataclass

NucleicAcidFeatureUnitOfInformationLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 12.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 12.0, rounded_corners: float = 5.0)

Bases: _SimpleMixin, SBGNNode

Layout for nucleic acid feature units of information.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

OrOperator dataclass

OrOperator(*, id_: str = make_uuid4_as_str(), inputs: frozenset[LogicalOperatorInput] = frozenset())

Bases: LogicalOperator

OR logical operator.

OrOperatorLayout dataclass

OrOperatorLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 30.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 30.0, direction: Direction = HORIZONTAL, left_to_right: bool = True, left_connector_length: float = 10.0, right_connector_length: float = 10.0, left_connector_stroke: NoneValueType | Color | None = None, left_connector_stroke_width: float | None = None, left_connector_stroke_dasharray: NoneValueType | tuple[float] | None = None, left_connector_stroke_dashoffset: float | None = None, left_connector_fill: NoneValueType | Color | None = None, left_connector_transform: NoneValueType | tuple[Transformation] | None = None, left_connector_filter: NoneValueType | Filter | None = None, right_connector_stroke: NoneValueType | Color | None = None, right_connector_stroke_width: float | None = None, right_connector_stroke_dasharray: NoneValueType | tuple[float] | None = None, right_connector_stroke_dashoffset: float | None = None, right_connector_fill: NoneValueType | Color | None = None, right_connector_transform: NoneValueType | tuple[Transformation] | None = None, right_connector_filter: NoneValueType | Filter | None = None)

Bases: _ConnectorsMixin, _SimpleMixin, _TextMixin, SBGNNode

Layout for OR operators.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Get the east (right) anchor point.

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

left_connector_base

Get the base point of the left connector.

left_connector_tip

Get the tip point of the left connector.

north

Get the north (top) anchor point.

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

right_connector_base

Get the base point of the right connector.

right_connector_tip

Get the tip point of the right connector.

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Get the south (bottom) anchor point.

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Get the west (left) anchor point.

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east()

Get the east (right) anchor point.

Returns:

Type Description

Point on the east side of the element.

Source code in src/momapy/sbgn/core.py
def east(self):
    """Get the east (right) anchor point.

    Returns:
        Point on the east side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x + self.width / 2, self.y)
    else:
        return momapy.geometry.Point(
            self.x + self.width / 2 + self.right_connector_length, self.y
        )

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

left_connector_base

left_connector_base()

Get the base point of the left connector.

Returns:

Type Description

Point where the left connector attaches to the shape.

Source code in src/momapy/sbgn/core.py
def left_connector_base(self):
    """Get the base point of the left connector.

    Returns:
        Point where the left connector attaches to the shape.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x, self.y - self.height / 2)
    else:
        return momapy.geometry.Point(self.x - self.width / 2, self.y)

left_connector_tip

left_connector_tip()

Get the tip point of the left connector.

Returns:

Type Description

Point at the end of the left connector line.

Source code in src/momapy/sbgn/core.py
def left_connector_tip(self):
    """Get the tip point of the left connector.

    Returns:
        Point at the end of the left connector line.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y - self.height / 2 - self.left_connector_length
        )
    else:
        return momapy.geometry.Point(
            self.x - self.width / 2 - self.left_connector_length, self.y
        )

north

north()

Get the north (top) anchor point.

Returns:

Type Description

Point on the north side of the element.

Source code in src/momapy/sbgn/core.py
def north(self):
    """Get the north (top) anchor point.

    Returns:
        Point on the north side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y - self.height / 2 - self.left_connector_length
        )
    else:
        return momapy.geometry.Point(self.x, self.y - self.height / 2)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

right_connector_base

right_connector_base()

Get the base point of the right connector.

Returns:

Type Description

Point where the right connector attaches to the shape.

Source code in src/momapy/sbgn/core.py
def right_connector_base(self):
    """Get the base point of the right connector.

    Returns:
        Point where the right connector attaches to the shape.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x, self.y + self.height / 2)
    else:
        return momapy.geometry.Point(self.x + self.width / 2, self.y)

right_connector_tip

right_connector_tip()

Get the tip point of the right connector.

Returns:

Type Description

Point at the end of the right connector line.

Source code in src/momapy/sbgn/core.py
def right_connector_tip(self):
    """Get the tip point of the right connector.

    Returns:
        Point at the end of the right connector line.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y + self.height / 2 + self.right_connector_length
        )
    else:
        return momapy.geometry.Point(
            self.x + self.width / 2 + self.right_connector_length, self.y
        )

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south()

Get the south (bottom) anchor point.

Returns:

Type Description

Point on the south side of the element.

Source code in src/momapy/sbgn/core.py
def south(self):
    """Get the south (bottom) anchor point.

    Returns:
        Point on the south side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(
            self.x, self.y + self.height / 2 + self.right_connector_length
        )
    else:
        return momapy.geometry.Point(self.x, self.y + self.height / 2)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west()

Get the west (left) anchor point.

Returns:

Type Description

Point on the west side of the element.

Source code in src/momapy/sbgn/core.py
def west(self):
    """Get the west (left) anchor point.

    Returns:
        Point on the west side of the element.
    """
    if self.direction == momapy.core.Direction.VERTICAL:
        return momapy.geometry.Point(self.x - self.width / 2, self.y)
    else:
        return momapy.geometry.Point(
            self.x - self.width / 2 - self.left_connector_length, self.y
        )

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

PerturbationUnitOfInformation dataclass

PerturbationUnitOfInformation(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None)

Bases: UnitOfInformation

Unit of information for perturbations.

PerturbationUnitOfInformationLayout dataclass

PerturbationUnitOfInformationLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 12.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 12.0, angle: float = 70.0)

Bases: _SimpleMixin, SBGNNode

Layout for perturbation units of information.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 70.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Phenotype dataclass

Phenotype(*, id_: str = make_uuid4_as_str())

Bases: Activity

Phenotype activity.

Represents the manifestation of a phenotype or observable characteristic.

PhenotypeLayout dataclass

PhenotypeLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 30.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 60.0, angle: float = 70.0)

Bases: _SimpleMixin, SBGNNode

Layout for phenotypes.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 70.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

PositiveInfluence dataclass

PositiveInfluence(*, id_: str = make_uuid4_as_str(), source: BiologicalActivity | LogicalOperator, target: Activity)

Bases: Influence

Positive influence.

PositiveInfluenceLayout dataclass

PositiveInfluenceLayout(path_fill: NoneValueType | Color | None = NoneValue, path_stroke: NoneValueType | Color | None = black, path_stroke_width: float | None = 1.25, arrowhead_fill: NoneValueType | Color | None = white, arrowhead_stroke: NoneValueType | Color | None = black, arrowhead_stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | BezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_filter: NoneValueType | Filter | None = None, arrowhead_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, arrowhead_stroke_dashoffset: NoneValueType | float | None = None, arrowhead_transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_height: float = 10.0, arrowhead_width: float = 10.0)

Bases: SBGNSingleHeadedArc

Layout for positive influences.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the group layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    drawing_elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=tuple(drawing_elements),
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(self.start_shorten, "start")
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=tuple(actions),
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    drawing_elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

SBGNAFLayout dataclass

SBGNAFLayout(*, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, fill: NoneValueType | Color | None = white, filter: NoneValueType | Filter | None = None, height: float, label: TextLayout | None = None, position: Point, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float)

Bases: SBGNLayout

SBGN-AF layout.

Represents the visual layout of an SBGN-AF model.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

is_sublayout

Return true if another given layout is a sublayout of the layout, false otherwise

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

is_sublayout

is_sublayout(other, flattened=False, unordered=False)

Return true if another given layout is a sublayout of the layout, false otherwise

Source code in src/momapy/core.py
def is_sublayout(self, other, flattened=False, unordered=False):
    """Return `true` if another given layout is a sublayout of the layout, `false` otherwise"""

    def _is_sublist(list1, list2, unordered=False) -> bool:
        if not unordered:
            i = 0
            for elem1 in list1:
                elem2 = list2[i]
                while elem2 != elem1 and i < len(list2) - 1:
                    i += 1
                    elem2 = list2[i]
                if not elem2 == elem1:
                    return False
                i += 1
        else:
            dlist1 = collections.defaultdict(int)
            dlist2 = collections.defaultdict(int)
            for elem1 in list1:
                dlist1[elem1] += 1
            for elem2 in list2:
                dlist2[elem2] += 1
            for elem in dlist1:
                if dlist1[elem] > dlist2[elem]:
                    return False
        return True

    if self.childless() != other.childless():
        return False
    if flattened:
        return _is_sublist(
            self.flattened()[1:],
            other.flattened()[1:],
            unordered=unordered,
        )
    return _is_sublist(self.children(), other.children(), unordered=unordered)

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

SBGNAFLayoutBuilder module-attribute

SBGNAFLayoutBuilder = get_or_make_builder_cls(SBGNAFLayout)

Builder class for SBGNAFLayout.

SBGNAFMap dataclass

SBGNAFMap(*, id_: str = make_uuid4_as_str(), model: Optional[SBGNAFModel] = None, layout: Optional[SBGNAFLayout] = None, layout_model_mapping: LayoutModelMapping | None = None)

Bases: SBGNMap

SBGN-AF map.

Represents a complete SBGN Activity Flow map with model and layout.

Attributes:

Name Type Description
model Optional[SBGNAFModel]

The SBGN-AF model.

layout Optional[SBGNAFLayout]

The visual layout of the map.

Methods:

Name Description
get_mapping

Return the layout elements mapped to the given model element

is_submap

Return true if another given map is a submap of the Map, false otherwise

get_mapping

get_mapping(map_element: MapElement | tuple[ModelElement, ModelElement])

Return the layout elements mapped to the given model element

Source code in src/momapy/core.py
def get_mapping(
    self,
    map_element: MapElement | tuple[ModelElement, ModelElement],
):
    """Return the layout elements mapped to the given model element"""
    return self.layout_model_mapping.get_mapping(map_element)

is_submap

is_submap(other)

Return true if another given map is a submap of the Map, false otherwise

Source code in src/momapy/core.py
def is_submap(self, other):
    """Return `true` if another given map is a submap of the `Map`, `false` otherwise"""
    if (
        self.model is None
        or self.layout is None
        or self.layout_model_mapping is None
    ):
        return False
    return (
        self.model.is_submodel(other.model)
        and self.layout.is_sublayout(other.layout)
        and self.layout_model_mapping.is_submapping(other.layout_model_mapping)
    )

SBGNAFMapBuilder module-attribute

SBGNAFMapBuilder = get_or_make_builder_cls(SBGNAFMap, builder_namespace={'new_model': _sbgnaf_map_builder_new_model, 'new_layout': _sbgnaf_map_builder_new_layout})

Builder class for SBGNAFMap.

SBGNAFModel dataclass

SBGNAFModel(*, id_: str = make_uuid4_as_str(), activities: frozenset[Activity] = frozenset(), compartments: frozenset[Compartment] = frozenset(), influences: frozenset[Influence] = frozenset(), logical_operators: frozenset[LogicalOperator] = frozenset(), submaps: frozenset[Submap] = frozenset(), tags: frozenset[Tag] = frozenset())

Bases: SBGNModel

SBGN-AF model.

Represents a complete SBGN Activity Flow model.

Attributes:

Name Type Description
activities frozenset[Activity]

Activities in the model.

compartments frozenset[Compartment]

Compartments in the model.

influences frozenset[Influence]

Influences in the model.

logical_operators frozenset[LogicalOperator]

Logical operators in the model.

submaps frozenset[Submap]

Submaps in the model.

tags frozenset[Tag]

Tags in the model.

Methods:

Name Description
is_submodel

Check if another model is a submodel of this model.

is_submodel

is_submodel(other: SBGNAFModel) -> bool

Check if another model is a submodel of this model.

Parameters:

Name Type Description Default
other SBGNAFModel

Another SBGN-AF model to compare against.

required

Returns:

Type Description
bool

True if other is a submodel of this model, False otherwise.

Source code in src/momapy/sbgn/af.py
def is_submodel(self, other: "SBGNAFModel") -> bool:
    """Check if another model is a submodel of this model.

    Args:
        other: Another SBGN-AF model to compare against.

    Returns:
        True if other is a submodel of this model, False otherwise.
    """
    return (
        self.activities.issubset(other.activities)
        and self.compartments.issubset(other.compartments)
        and self.influences.issubset(other.influences)
        and self.logical_operators.issubset(other.logical_operators)
        and self.submaps(other.submaps)
        and self.tags.issubset(other.tags)
    )

SBGNAFModelBuilder module-attribute

SBGNAFModelBuilder = get_or_make_builder_cls(SBGNAFModel)

Builder class for SBGNAFModel.

SimpleChemicalUnitOfInformation dataclass

SimpleChemicalUnitOfInformation(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None)

Bases: UnitOfInformation

Unit of information for simple chemicals.

SimpleChemicalUnitOfInformationLayout dataclass

SimpleChemicalUnitOfInformationLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 12.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 12.0)

Bases: _SimpleMixin, SBGNNode

Layout for simple chemical units of information.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Submap dataclass

Submap(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None, terminals: frozenset[Terminal] = frozenset())

Bases: SBGNModelElement

Submap element.

Submaps represent embedded or referenced sub-diagrams.

Attributes:

Name Type Description
label Optional[str]

The label of the submap.

terminals frozenset[Terminal]

Terminal connection points of the submap.

SubmapLayout dataclass

SubmapLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 80.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 80.0, border_stroke_width: float | None = 2.25)

Bases: _SimpleMixin, SBGNNode

Layout for submaps.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

Tag dataclass

Tag(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None, refers_to: Optional[TagReference] = None)

Bases: SBGNModelElement

Tag element.

Tags provide identifiers that can be referenced from other locations.

Attributes:

Name Type Description
label Optional[str]

The label of the tag.

refers_to Optional[TagReference]

Reference to the tagged element.

TagLayout dataclass

TagLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 35.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 35.0, direction: Direction = RIGHT, angle: float = 70.0)

Bases: TagLayout

Layout for tags.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 70.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

TagReference dataclass

TagReference(*, id_: str = make_uuid4_as_str(), element: Union[Activity, Compartment])

Bases: SBGNRole

Reference to a tag.

Attributes:

Name Type Description
element Union[Activity, Compartment]

The activity or compartment being referenced.

Terminal dataclass

Terminal(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None, refers_to: Optional[TerminalReference] = None)

Bases: SBGNModelElement

Terminal element.

Terminals represent connection points to submaps.

Attributes:

Name Type Description
label Optional[str]

The label of the terminal.

refers_to Optional[TerminalReference]

Reference to the terminal target.

TerminalLayout dataclass

TerminalLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 35.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 35.0, direction: Direction = RIGHT, angle: float = 70.0)

Bases: _SimpleMixin, SBGNNode

Layout for terminals.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
angle float

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle class-attribute instance-attribute

angle: float = 70.0

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node

TerminalReference dataclass

TerminalReference(*, id_: str = make_uuid4_as_str(), element: Union[Activity, Compartment])

Bases: SBGNRole

Reference to a terminal.

Attributes:

Name Type Description
element Union[Activity, Compartment]

The activity or compartment being referenced.

UnitOfInformation dataclass

UnitOfInformation(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None)

Bases: SBGNModelElement

Unit of information for activities.

Units of information provide additional annotations about activities, such as cellular location or entity type.

Attributes:

Name Type Description
label Optional[str]

The label of the unit of information.

UnknownInfluence dataclass

UnknownInfluence(*, id_: str = make_uuid4_as_str(), source: BiologicalActivity | LogicalOperator, target: Activity)

Bases: Influence

Unknown influence.

UnknownInfluenceLayout dataclass

UnknownInfluenceLayout(path_fill: NoneValueType | Color | None = NoneValue, path_stroke: NoneValueType | Color | None = black, path_stroke_width: float | None = 1.25, arrowhead_fill: NoneValueType | Color | None = white, arrowhead_stroke: NoneValueType | Color | None = black, arrowhead_stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | BezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_filter: NoneValueType | Filter | None = None, arrowhead_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, arrowhead_stroke_dashoffset: NoneValueType | float | None = None, arrowhead_transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_height: float = 10.0, arrowhead_width: float = 10.0)

Bases: SBGNSingleHeadedArc

Layout for unknown influences.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

arrowhead_base

Return the arrowhead base anchor point of the single-headed arc

arrowhead_bbox

Return the bounding box of the single-headed arc arrowhead

arrowhead_border

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.

arrowhead_drawing_elements

Return the drawing elements of the single-headed arc arrowhead

arrowhead_length

Return the length of the single-headed arc arrowhead

arrowhead_tip

Return the arrowhead tip anchor point of the single-headed arc

bbox

Compute and return the bounding box of the group layout element

childless

Return a copy of the arc with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

end_point

Return the ending point of the arc

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

fraction

Return the position and angle on the arc at a given fraction (of the total arc length)

length

Return the total length of the arc path

path_drawing_elements

Return the drawing elements of the single-headed arc path

points

Return the points of the arc path

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_children

Return the self children of the arc

self_drawing_elements

Return the self drawing elements of the single-headed arc

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

start_point

Return the starting point of the arc

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

arrowhead_base

arrowhead_base() -> Point

Return the arrowhead base anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_base(self) -> momapy.geometry.Point:
    """Return the arrowhead base anchor point of the single-headed arc"""
    arrowhead_length = self.arrowhead_length()
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return self.arrowhead_tip() - (arrowhead_length, 0)
    fraction = 1 - (arrowhead_length + self.end_shorten) / segment_length
    return segment.get_position_at_fraction(fraction)

arrowhead_bbox

arrowhead_bbox() -> Bbox

Return the bounding box of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_bbox(self) -> momapy.geometry.Bbox:
    """Return the bounding box of the single-headed arc arrowhead"""
    return momapy.drawing.get_drawing_elements_bbox(
        self.arrowhead_drawing_elements()
    )

arrowhead_border

arrowhead_border(point) -> Point

Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def arrowhead_border(self, point) -> momapy.geometry.Point:
    """Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """

    point = momapy.drawing.get_drawing_elements_border(
        self.arrowhead_drawing_elements(), point
    )
    if point is None:
        return self.arrowhead_tip()
    return point

arrowhead_drawing_elements

arrowhead_drawing_elements() -> list[DrawingElement]

Return the drawing elements of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_drawing_elements(
    self,
) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the single-headed arc arrowhead"""
    drawing_elements = self._arrowhead_border_drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_arrowhead",
        elements=tuple(drawing_elements),
        fill=self.arrowhead_fill,
        filter=self.arrowhead_filter,
        id_=f"{self.id_}_arrowhead",
        stroke=self.arrowhead_stroke,
        stroke_dasharray=self.arrowhead_stroke_dasharray,
        stroke_dashoffset=self.arrowhead_stroke_dashoffset,
        stroke_width=self.arrowhead_stroke_width,
        transform=self.arrowhead_transform,
    )
    transformation = self._get_arrowhead_transformation()
    group = group.transformed(transformation)
    return [group]

arrowhead_length

arrowhead_length() -> float

Return the length of the single-headed arc arrowhead

Source code in src/momapy/core.py
def arrowhead_length(self) -> float:
    """Return the length of the single-headed arc arrowhead"""
    bbox = momapy.drawing.get_drawing_elements_bbox(
        self._arrowhead_border_drawing_elements()
    )
    if math.isnan(bbox.width):
        return 0.0
    return bbox.east().x

arrowhead_tip

arrowhead_tip() -> Point

Return the arrowhead tip anchor point of the single-headed arc

Source code in src/momapy/core.py
def arrowhead_tip(self) -> momapy.geometry.Point:
    """Return the arrowhead tip anchor point of the single-headed arc"""
    segment = self.segments[-1]
    segment_length = segment.length()
    if segment_length == 0:
        return segment.p2
    fraction = 1 - self.end_shorten / segment_length
    return segment.get_position_at_fraction(fraction)

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

childless

childless() -> Self

Return a copy of the arc with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the arc with no children"""
    return dataclasses.replace(self, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

end_point

end_point() -> Point

Return the ending point of the arc

Source code in src/momapy/core.py
def end_point(self) -> momapy.geometry.Point:
    """Return the ending point of the arc"""
    return self.points()[-1]

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

fraction

fraction(fraction: float) -> tuple[Point, float]

Return the position and angle on the arc at a given fraction (of the total arc length)

Source code in src/momapy/core.py
def fraction(self, fraction: float) -> tuple[momapy.geometry.Point, float]:
    """Return the position and angle on the arc at a given fraction (of the total arc length)"""
    current_length = 0
    length_to_reach = fraction * self.length()
    for segment in self.segments:
        current_length += segment.length()
        if current_length >= length_to_reach:
            break
    position, angle = segment.get_position_and_angle_at_fraction(fraction)
    return position, angle

length

length()

Return the total length of the arc path

Source code in src/momapy/core.py
def length(self):
    """Return the total length of the arc path"""
    return sum([segment.length() for segment in self.segments])

path_drawing_elements

path_drawing_elements() -> list[Path]

Return the drawing elements of the single-headed arc path

Source code in src/momapy/core.py
def path_drawing_elements(self) -> list[momapy.drawing.Path]:
    """Return the drawing elements of the single-headed arc path"""
    arrowhead_length = self.arrowhead_length()
    if len(self.segments) == 1:
        segment = (
            self.segments[0]
            .shortened(self.start_shorten, "start")
            .shortened(self.end_shorten + arrowhead_length, "end")
        )
        actions = [
            momapy.drawing.MoveTo(segment.p1),
            self._make_path_action_from_segment(segment),
        ]
    else:
        first_segment = self.segments[0].shortened(self.start_shorten, "start")
        last_segment = self.segments[-1].shortened(
            self.end_shorten + arrowhead_length, "end"
        )
        actions = [
            momapy.drawing.MoveTo(first_segment.p1),
            self._make_path_action_from_segment(first_segment),
        ]
        for segment in self.segments[1:-1]:
            action = self._make_path_action_from_segment(segment)
            actions.append(action)
        actions.append(self._make_path_action_from_segment(last_segment))
    path = momapy.drawing.Path(
        actions=tuple(actions),
        class_=f"{type(self).__name__}_path",
        fill=self.path_fill,
        filter=self.path_filter,
        id_=f"{self.id_}_path",
        stroke=self.path_stroke,
        stroke_dasharray=self.path_stroke_dasharray,
        stroke_dashoffset=self.path_stroke_dashoffset,
        stroke_width=self.path_stroke_width,
        transform=self.path_transform,
    )
    return [path]

points

points() -> list[Point]

Return the points of the arc path

Source code in src/momapy/core.py
def points(self) -> list[momapy.geometry.Point]:
    """Return the points of the arc path"""
    points = []
    for segment in self.segments:
        points.append(segment.p1)
    points.append(segment.p2)
    return points

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_children

self_children() -> list[LayoutElement]

Return the self children of the arc

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the arc"""
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the self drawing elements of the single-headed arc

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the self drawing elements of the single-headed arc"""
    drawing_elements = (
        self.path_drawing_elements() + self.arrowhead_drawing_elements()
    )
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

start_point

start_point() -> Point

Return the starting point of the arc

Source code in src/momapy/core.py
def start_point(self) -> momapy.geometry.Point:
    """Return the starting point of the arc"""
    return self.points()[0]

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

UnspecifiedEntityUnitOfInformation dataclass

UnspecifiedEntityUnitOfInformation(*, id_: str = make_uuid4_as_str(), label: Optional[str] = None)

Bases: UnitOfInformation

Unit of information for unspecified entities.

UnspecifiedEntityUnitOfInformationLayout dataclass

UnspecifiedEntityUnitOfInformationLayout(fill: NoneValueType | Color | None = white, stroke: NoneValueType | Color | None = black, stroke_width: float | None = 1.25, *, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, filter: NoneValueType | Filter | None = None, height: float = 12.0, label: TextLayout | None = None, position: Point, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float = 12.0)

Bases: _SimpleMixin, SBGNNode

Layout for unspecified entity units of information.

Methods:

Name Description
anchor_point

Return an anchor point of the layout element

angle

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

bbox

Compute and return the bounding box of the group layout element

border

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.

center

Return the center anchor of the node

childless

Return a copy of the node with no children

children

Return the children of the group layout.

contains

Return true if another layout element is a descendant of the layout element, false otherwise

descendants

Return the descendants of the layout element

drawing_elements

Return the drawing elements of the group layout.

east

Return the east anchor of the node

east_north_east

Return the east north east anchor of the node

east_south_east

Return the east south east west anchor of the node

equals

Return true if the layout element is equal to another layout element, false otherwise

flattened

Return a list containing copy of the layout element with no children and all its descendants with no children

label_center

Return the label center anchor of the node

north

Return the north anchor of the node

north_east

Return the north east anchor of the node

north_north_east

Return the north north east anchor of the node

north_north_west

Return the north north west anchor of the node

north_west

Return the north west anchor of the node

self_angle

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

self_bbox

Compute and return the bounding box of the self drawing element of the group layout

self_border

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.

self_children

Return the self children of the node. A node has unique child that is its label

self_drawing_elements

Return the node's own drawing elements

self_to_shapely

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

size

Return the size of the node

south

Return the south anchor of the node

south_east

Return the south east anchor of the node

south_south_east

Return the south south east anchor of the node

south_south_west

Return the south south west anchor of the node

south_west

Return the south west anchor of the node

to_shapely

Return a shapely collection of geometries reproducing the drawing elements of the layout element

west

Return the west anchor of the node

west_north_west

Return the west north west anchor of the node

west_south_west

Return the west south west anchor of the node

Attributes:

Name Type Description
x float

Return the x coordinate of the node

y float

Return the y coordinate of the node

anchor_point

anchor_point(anchor_name: str) -> Point

Return an anchor point of the layout element

Source code in src/momapy/core.py
def anchor_point(self, anchor_name: str) -> momapy.geometry.Point:
    """Return an anchor point of the layout element"""
    return getattr(self, anchor_name)()

angle

angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

bbox

bbox() -> Bbox

Compute and return the bounding box of the group layout element

Source code in src/momapy/core.py
def bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the group layout element"""
    self_bbox = self.self_bbox()
    bboxes = [child.bbox() for child in self.children()]
    min_x = self_bbox.north_west().x
    min_y = self_bbox.north_west().y
    max_x = self_bbox.south_east().x
    max_y = self_bbox.south_east().y
    for bbox in bboxes:
        if bbox.north_west().x < min_x:
            min_x = bbox.north_west().x
        if bbox.north_west().y < min_y:
            min_y = bbox.north_west().y
        if bbox.south_east().x > max_x:
            max_x = bbox.south_east().x
        if bbox.south_east().y > max_y:
            max_y = bbox.south_east().y
    bbox = momapy.geometry.Bbox(
        momapy.geometry.Point(min_x / 2 + max_x / 2, min_y / 2 + max_y / 2),
        max_x - min_x,
        max_y - min_y,
    )
    return bbox

border

border(point: Point) -> Point

Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.drawing_elements(),
        point=point,
        center=self.center(),
    )

center

center() -> Point

Return the center anchor of the node

Source code in src/momapy/core.py
def center(self) -> momapy.geometry.Point:
    """Return the center anchor of the node"""
    return self.position

childless

childless() -> Self

Return a copy of the node with no children

Source code in src/momapy/core.py
def childless(self) -> typing_extensions.Self:
    """Return a copy of the node with no children"""
    return dataclasses.replace(self, label=None, layout_elements=tuple([]))

children

children() -> list[LayoutElement]

Return the children of the group layout. These are the self children of the group layout (returned by the self_children method) and the other children of the group layout (given by the layout_elements attribute)

Source code in src/momapy/core.py
def children(self) -> list[LayoutElement]:
    """Return the children of the group layout.
    These are the self children of the group layout (returned by the `self_children` method) and the other children of the group layout (given by the `layout_elements` attribute)
    """
    return self.self_children() + list(self.layout_elements)

contains

contains(other: LayoutElement) -> bool

Return true if another layout element is a descendant of the layout element, false otherwise

Source code in src/momapy/core.py
def contains(self, other: "LayoutElement") -> bool:
    """Return `true` if another layout element is a descendant of the layout element, `false` otherwise"""
    return other in self.descendants()

descendants

descendants() -> list[LayoutElement]

Return the descendants of the layout element

Source code in src/momapy/core.py
def descendants(self) -> list["LayoutElement"]:
    """Return the descendants of the layout element"""
    descendants = []
    for child in self.children():
        descendants.append(child)
        descendants += child.descendants()
    return descendants

drawing_elements

drawing_elements() -> list[DrawingElement]

Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children

Source code in src/momapy/core.py
def drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the drawing elements of the group layout.
    The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
    """
    drawing_elements = self.self_drawing_elements()
    for child in self.children():
        if child is not None:
            drawing_elements += child.drawing_elements()
    group = momapy.drawing.Group(
        class_=f"{type(self).__name__}_group",
        elements=tuple(drawing_elements),
        id_=f"{self.id_}_group",
        fill=self.group_fill,
        fill_rule=self.group_fill_rule,
        filter=self.group_filter,
        font_family=self.group_font_family,
        font_size=self.group_font_size,
        font_style=self.group_font_style,
        font_weight=self.group_font_weight,
        stroke=self.group_stroke,
        stroke_dasharray=self.group_stroke_dasharray,
        stroke_dashoffset=self.group_stroke_dashoffset,
        stroke_width=self.group_stroke_width,
        text_anchor=self.group_text_anchor,
        transform=self.group_transform,
    )
    return [group]

east

east() -> Point

Return the east anchor of the node

Source code in src/momapy/core.py
def east(self) -> momapy.geometry.Point:
    """Return the east anchor of the node"""
    return self.self_angle(0)

east_north_east

east_north_east() -> Point

Return the east north east anchor of the node

Source code in src/momapy/core.py
def east_north_east(self) -> momapy.geometry.Point:
    """Return the east north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

east_south_east

east_south_east() -> Point

Return the east south east west anchor of the node

Source code in src/momapy/core.py
def east_south_east(self) -> momapy.geometry.Point:
    """Return the east south east west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

equals

equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool

Return true if the layout element is equal to another layout element, false otherwise

Source code in src/momapy/core.py
def equals(
    self, other: "LayoutElement", flattened: bool = False, unordered: bool = False
) -> bool:
    """Return `true` if the layout element is equal to another layout element, `false` otherwise"""
    if type(self) is type(other):
        if not flattened:
            return self == other
        else:
            if not unordered:
                return self.flattened() == other.flattened()
            else:
                return set(self.flattened()) == set(other.flattened())
    return False

flattened

flattened() -> list[LayoutElement]

Return a list containing copy of the layout element with no children and all its descendants with no children

Source code in src/momapy/core.py
def flattened(self) -> list["LayoutElement"]:
    """Return a list containing copy of the layout element with no children and all its descendants with no children"""
    flattened = [self.childless()]
    for child in self.children():
        flattened += child.flattened()
    return flattened

label_center

label_center() -> Point

Return the label center anchor of the node

Source code in src/momapy/core.py
def label_center(self) -> momapy.geometry.Point:
    """Return the label center anchor of the node"""
    return self.position

north

north() -> Point

Return the north anchor of the node

Source code in src/momapy/core.py
def north(self) -> momapy.geometry.Point:
    """Return the north anchor of the node"""
    return self.self_angle(90)

north_east

north_east() -> Point

Return the north east anchor of the node

Source code in src/momapy/core.py
def north_east(self) -> momapy.geometry.Point:
    """Return the north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_east

north_north_east() -> Point

Return the north north east anchor of the node

Source code in src/momapy/core.py
def north_north_east(self) -> momapy.geometry.Point:
    """Return the north north east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, -self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_north_west

north_north_west() -> Point

Return the north north west anchor of the node

Source code in src/momapy/core.py
def north_north_west(self) -> momapy.geometry.Point:
    """Return the north north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

north_west

north_west() -> Point

Return the north west anchor of the node

Source code in src/momapy/core.py
def north_west(self) -> momapy.geometry.Point:
    """Return the north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

self_angle

self_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.

Source code in src/momapy/core.py
def self_angle(
    self,
    angle: float,
    unit: typing.Literal["degrees", "radians"] = "degrees",
) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal."""
    return momapy.drawing.get_drawing_elements_angle(
        drawing_elements=self.self_drawing_elements(),
        angle=angle,
        unit=unit,
        center=self.center(),
    )

self_bbox

self_bbox() -> Bbox

Compute and return the bounding box of the self drawing element of the group layout

Source code in src/momapy/core.py
def self_bbox(self) -> momapy.geometry.Bbox:
    """Compute and return the bounding box of the self drawing element of the group layout"""
    bounds = self.self_to_shapely().bounds
    return momapy.geometry.Bbox.from_bounds(bounds)

self_border

self_border(point: Point) -> Point

Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned

Source code in src/momapy/core.py
def self_border(self, point: momapy.geometry.Point) -> momapy.geometry.Point:
    """Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point.
    When there are multiple intersection points, the one closest to the given point is returned
    """
    return momapy.drawing.get_drawing_elements_border(
        drawing_elements=self.self_drawing_elements(),
        point=point,
        center=self.center(),
    )

self_children

self_children() -> list[LayoutElement]

Return the self children of the node. A node has unique child that is its label

Source code in src/momapy/core.py
def self_children(self) -> list[LayoutElement]:
    """Return the self children of the node. A node has unique child that is its label"""
    if self.label is not None:
        return [self.label]
    return []

self_drawing_elements

self_drawing_elements() -> list[DrawingElement]

Return the node's own drawing elements

Source code in src/momapy/core.py
def self_drawing_elements(self) -> list[momapy.drawing.DrawingElement]:
    """Return the node's own drawing elements"""
    drawing_elements = self._border_drawing_elements()
    group = momapy.drawing.Group(
        class_=type(self).__name__,
        elements=tuple(drawing_elements),
        fill=self.fill,
        filter=self.filter,
        id_=self.id_,
        stroke=self.stroke,
        stroke_dasharray=self.stroke_dasharray,
        stroke_dashoffset=self.stroke_dashoffset,
        stroke_width=self.stroke_width,
        transform=self.transform,
    )
    return [group]

self_to_shapely

self_to_shapely() -> GeometryCollection

Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout

Source code in src/momapy/core.py
def self_to_shapely(self) -> shapely.GeometryCollection:
    """Compute and return a shapely collection of geometries reproducing the self drawing elements of the group layout"""
    return momapy.drawing.drawing_elements_to_shapely(self.drawing_elements())

size

size() -> tuple[float, float]

Return the size of the node

Source code in src/momapy/core.py
def size(self) -> tuple[float, float]:
    """Return the size of the node"""
    return (self.width, self.height)

south

south() -> Point

Return the south anchor of the node

Source code in src/momapy/core.py
def south(self) -> momapy.geometry.Point:
    """Return the south anchor of the node"""
    return self.self_angle(270)

south_east

south_east() -> Point

Return the south east anchor of the node

Source code in src/momapy/core.py
def south_east(self) -> momapy.geometry.Point:
    """Return the south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_east

south_south_east() -> Point

Return the south south east anchor of the node

Source code in src/momapy/core.py
def south_south_east(self) -> momapy.geometry.Point:
    """Return the south south east anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_south_west

south_south_west() -> Point

Return the south south west anchor of the node

Source code in src/momapy/core.py
def south_south_west(self) -> momapy.geometry.Point:
    """Return the south south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 4, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

south_west

south_west() -> Point

Return the south west anchor of the node

Source code in src/momapy/core.py
def south_west(self) -> momapy.geometry.Point:
    """Return the south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 2)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

to_shapely

to_shapely(to_polygons: bool = False) -> GeometryCollection

Return a shapely collection of geometries reproducing the drawing elements of the layout element

Source code in src/momapy/core.py
def to_shapely(self, to_polygons: bool = False) -> shapely.GeometryCollection:
    """Return a shapely collection of geometries reproducing the drawing elements of the layout element"""
    geom_collection = []
    for drawing_element in self.drawing_elements():
        geom_collection += drawing_element.to_shapely(to_polygons=to_polygons).geoms
    return shapely.GeometryCollection(geom_collection)

west

west() -> Point

Return the west anchor of the node

Source code in src/momapy/core.py
def west(self) -> momapy.geometry.Point:
    """Return the west anchor of the node"""
    return self.self_angle(180)

west_north_west

west_north_west() -> Point

Return the west north west anchor of the node

Source code in src/momapy/core.py
def west_north_west(self) -> momapy.geometry.Point:
    """Return the west north west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() - (self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

west_south_west

west_south_west() -> Point

Return the west south west anchor of the node

Source code in src/momapy/core.py
def west_south_west(self) -> momapy.geometry.Point:
    """Return the west south west anchor of the node"""
    line = momapy.geometry.Line(
        self.center(), self.center() + (-self.width / 2, self.height / 4)
    )
    angle = -momapy.geometry.get_angle_to_horizontal_of_line(line)
    return self.self_angle(angle, unit="radians")

x property

x: float

Return the x coordinate of the node

y property

y: float

Return the y coordinate of the node