image¶
Rendering of SBGN documents as images.
The rendering is performed by the web service of Frank Bergmann at https://sbml.bioquant.uni-heidelberg.de/layout, i.e., it requires an internet connection. For the documentation of the service see http://sysbioapps.spdns.org/Layout.
from pathlib import Path
from libsbgnpy import read_sbgn_from_file, render_sbgn
sbgn = read_sbgn_from_file(Path("map.sbgn"))
render_sbgn(sbgn, Path("map.png"))
RenderError
¶
Bases: RequestException
The rendering web service answered, but not with an image.
render_sbgn
¶
Render an SBGN document to an image.
The document is sent to the rendering web service, which lays the map out and returns the image. The request is equivalent to
The image is only written if the service returns an image, and it is written atomically: an existing file is replaced as a whole or left as it is. The service currently returns a JPEG although it declares a PNG; the JPEG is written as it is and a warning is logged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sbgn
|
Sbgn
|
SBGN document |
required |
image_file
|
Path
|
path of the image to create, ending in |
required |
file_format
|
str
|
image format, only |
'png'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if the format is not supported or the file has another suffix |
RenderError
|
if the web service answers with something else than an
image, or with an image larger than |
RequestException
|
if the web service cannot be reached or fails;
|