Skip to content

matthiaskoenig/libsbgnpy

Repository files navigation

libsbgnpy logo

libsbgnpy: Python library for SBGN

GitHub Actions CI/CD Status Version Python Versions MIT License DOI

Python library to work with the Systems Biology Graphical Notation (SBGN). This library is based on the SBGN XML schema and supports reading, writing and validation of SBGN files.

The initial library was generated using xsdata. Additional utility functions for reading, writing, and rendering SBGN documents are provided.

    map = Map(
        id="ethanol_example",
        language=MapLanguage.PROCESS_DESCRIPTION,
        bbox=Bbox(x=0, y=0, w=363, h=253),
    )
    # add map to new sbgn
    sbgn = Sbgn(map=[map])

    # create glyphs and add to map
    map.glyph.extend(
        [
            Glyph(
                class_value=GlyphClass.SIMPLE_CHEMICAL,
                id="ethanol",
                label=Label(text="Ethanol"),
                bbox=Bbox(x=40, y=120, w=60, h=60),
            ),
            Glyph(
                class_value=GlyphClass.SIMPLE_CHEMICAL,
                id="ethanal",
                label=Label(text="Ethanal"),
                bbox=Bbox(x=220, y=110, w=60, h=60),
            ),
            Glyph(
                class_value=GlyphClass.MACROMOLECULE,
                id="adh1",
                label=Label(text="ADH1"),
                bbox=Bbox(x=106, y=20, w=108, h=60),
            ),

            ...

            # glyph with ports (process)
            Glyph(
                class_value=GlyphClass.PROCESS,
                id="pn1",
                orientation=GlyphOrientation.HORIZONTAL,
                bbox=Bbox(x=148, y=168, w=24, h=24),
                port=[
                    Port(x=136, y=180, id="pn1.1"),
                    Port(x=184, y=180, id="pn1.2"),
                ],
            ),
        ]
    )
    write_sbgn_to_file(sbgn, f"{prefix}_glyphs.sbgn")
    render_sbgn(sbgn, f"{prefix}_glyphs.png")

Example

Documentation

Documentation with examples is available at https://matthiaskoenig.github.io/libsbgnpy/.

A presentation from HARMONY2026 is available here.

How to cite

DOI

Installation

libsbgnpy is available from pypi

pip install libsbgnpy

License

Funding

Matthias König (MK) was supported by the Federal Ministry of Education and Research (BMBF, Germany) within the research network Systems Medicine of the Liver (LiSyM, grant number 031L0054). MK is supported by the Federal Ministry of Education and Research (BMBF, Germany) within ATLAS by grant number 031L0304B and by the German Research Foundation (DFG) within the Research Unit Program FOR 5151 QuaLiPerF (Quantifying Liver Perfusion-Function Relationship in Complex Resection - A Systems Medicine Approach) by grant number 436883643 and by grant number 465194077 (Priority Programme SPP 2311, Subproject SimLivA).

© 2016-2026 Matthias König