SBMLDiagrams: a python package to process and visualize SBML layout and render

Abstract Summary The systems biology markup language (SBML) is an extensible standard format for exchanging biochemical models. One of the extensions for SBML is the SBML Layout and Render package. This allows modelers to describe a biochemical model as a pathway diagram. However, up to now, there has been little support to help users easily add and retrieve such information from SBML. In this application note, we describe a new Python package called SBMLDiagrams. This package allows a user to add a layout and render information or retrieve it using a straightforward Python API. The package uses skia-python to support the rendering of the diagrams, allowing export to commons formats such as PNG or PDF. Availability and implementation SBMLDiagrams is publicly available and licensed under the liberal MIT open-source license. The package is available for all major platforms. The source code has been deposited at GitHub (github.com/sys-bio/SBMLDiagrams). Users can install the package using the standard pip installation mechanism: pip install SBMLDiagrams. Supplementary information Supplementary data are available at Bioinformatics online.


Introduction
The Systems biological Markup Language (SBML) [1] is a markup language to describe biochemical models of biological systems.SBML is used primarily to allow the exchange of models between different software tools.To read and write SBML, users are recommended to use the software library libSBML [2].libSBML allows users to read, write and create SBML documents from a wide range of languages such as C, C++, Java, and Python.libSBML also supports extensions such as SBML layout and render [3] which allows users to describe biochemical models as pathway diagrams.The layout is used to describe the positions of elements on a canvas while the render extension is used to describe how elements are rendered in graphical form.libSBML, however, can be difficult for new users to learn requiring fairly detailed knowledge of the layout and render object model.See Supplementary.
In this application note, we describe a python package called SBMLDiagrams that allows users to easily read, write, create and view layout and render specifications for a biochemical model without requiring an understanding of the underlying object model.The package makes use of python-libSBML, simplesbml [4], and skia-python to add and inspect the layout and render part of SBML files as well as render the diagram to a variety of formats such as PNG and PDF.SBMLDiagrams support all specific layout elements.

Methods
SBML level 3 supports layout and render information.The Layout describes the positions and sizes of different graphical objects, including compartments, species, and reactions.The render describes the color and shape information.SBMLDiagrams can be used to read, write, create and/or visualize SBML files based on the layout and render information.If an SBML file contains no layout or render information, SBMLDiagrams can be used to add this information.

Working with SBML Layout and Render
SBMLDiagrams can be used to read and edit the layout and render of an existing SBML model which can be subsequently exported to an updated SBML model.
A variety of color formats (as well as opacity) are supported including decimal RGB, HEX string, and all the HTML names (https://www.w3schools.com/colors/colors_names.asp).The following is an example that illustrates some simple operations.

Visualization of SBML networks
The visualization is based on skia-python The visualization is based on skia-python (pypi.org/project/skia-python/).Users can export the SBML networks as PNG, JPG or PDF files.Figure 1A shows a visualization example of an SBML file from Jana Wolf's work [5].The following example illustrates the use of a modeling package such as Tellurium with SBMLDiagrams.
import SBMLDiagrams, tellurium as te r = te.loada(''' For most Python IDEs df.draw() will display the network at the console.Users can also save the figure to a file, for instance, df.draw(output_fileName = 'fileName.pdf').
Autolayout is provided by NetworkX and is useful when an SBML model has no layout information.By use of drawing primitives it is also possible to specify networks that use some aspects from SBGN [6], see Figure 1B and 1C.SBMLDiagrams can also be driven from Tellurium to create simulation animations overlaid onto a diagram.

Implementation
SBMLDiagrams is available as a pip package (pypi.org/project/SBMLDiagrams/),and installed using the standard pip mechanism: pip install SBMLDiagrams.

Figure 1 :
Figure 1: Some visualization examples by SBMLDiagrams.A. Using SBMLDiagrams to visualize a model of glycolysis [5].Alias nodes are indicated with dashed border lines and boundary nodes have a thicker border width than floating nodes.An animation is also available on Github (https://github.com/sys-bio/SBMLDiagrams).B. Interface to SBGN with a complex species.C. Interface to SBGN with a gradient node.