Skip to content

cytoscape

Module for visualization in Cytoscape.

Supports loading of networks, annotations and storing of images.

The visualization talks to a running Cytoscape through py4cytoscape, which is the optional cytoscape extra (pip install sbmlutils[cytoscape]). Without it, and without a running Cytoscape, the functions log a warning and do nothing instead of raising, so a model creation script which visualizes at the end still finishes.

AnnotationShapeType

Bases: StrEnum

Shape of an annotation on the cytoscape canvas.

AnnotationShape dataclass

AnnotationShape(
    type,
    x_pos,
    y_pos,
    height,
    width,
    fill_color="#000000",
    opacity=100,
    border_thickness=1,
    border_color="#FFFFFF",
    border_opacity=100,
    canvas="background",
    z_order=0,
)

Shape annotation on the cytoscape canvas.

AnnotationText dataclass

AnnotationText(
    text,
    x_pos,
    y_pos,
    font_size=12,
    font_family="Arial",
    font_style="bold",
    color="#000000",
    angle=0,
    canvas="background",
)

Text annotation on the cytoscape canvas.

AnnotationBoundedText dataclass

AnnotationBoundedText(
    type,
    text,
    x_pos,
    y_pos,
    height,
    width,
    fill_color="#000000",
    opacity=100,
    border_thickness=1,
    border_color="#FFFFFF",
    border_opacity=100,
    font_size=12,
    font_family="Arial",
    font_style="bold",
    color="#000000",
    angle=0,
    canvas="background",
)

Text annotation inside a shape on the cytoscape canvas.

visualize_antimony

visualize_antimony(source, delete_session=False)

Visualize antimony in cytoscape.

visualize_sbml

visualize_sbml(sbml_path, delete_session=False)

Visualize SBML networks in cytoscape.

Returns dictionary with "networks" and "views".

read_layout_xml

read_layout_xml(sbml_path, xml_path)

Read own xml layout information form cytoscape.

apply_layout

apply_layout(layout, network=None)

Apply layout information from Cytoscape to SBML networks.

add_annotations

add_annotations(annotations, network=None)

Add annotations to the network.

export_image

export_image(
    image_path,
    format="PNG",
    fit_content=False,
    hide_labels=False,
)

Helper for exporting cytoscape images.

format (str): Type of image to export, e.g., PNG (default), JPEG, PDF, SVG, PS (PostScript).