Skip to main content

Support for SBGN ML v0.3 via generateDS

Project description

pysbgn: supporting SBGN-ML v0.3 in Python

This package provides support for writing and reading SBGN-ML v0.3 files. The code is auto-generated using generateDS with a few code fixes and modifications making it compatible with libsbgn-python (which supports only SBGN-ML v0.2).

Requirements

python 3.5+

Installation

pip install pysbgn

Examples

The read/write API is the same as in libsbgn-python so you can use the examples from libsbgn-python documentation. Just make sure that the import statements are compatible with libsbgn-python as shown below. Note, however, that additional modules of libsbgn-python such as utils and render are not provided.

from pysbgn import sbgn_core as libsbgn
from pysbgn.sbgn_core import notesType as Notes
from pysbgn.sbgn_core import extensionType as Extension
from pysbgn.sbgn_types import Language, Orientation, GlyphClass, ArcClass, Name, Version, ArcGroupClass

A simple example

Note: this example is taken from libsbgn-python and shortened to included only three glyphs and two arcs.

from pysbgn import sbgn_core as libsbgn
from pysbgn.sbgn_types import Language, GlyphClass, ArcClass, Orientation

sbgn = libsbgn.sbgn()
map = libsbgn.map()
map.set_language(Language.PD)
sbgn.set_map(map)

# create a bounding box for the map
box = libsbgn.bbox(x=0, y=0, w=363, h=253)
map.set_bbox(box)

# two glyphs with labels
g = libsbgn.glyph(class_=GlyphClass.SIMPLE_CHEMICAL, id='glyph1')
g.set_label(libsbgn.label(text='Ethanol'))
g.set_bbox(libsbgn.bbox(x=40, y=120, w=60, h=60))
map.add_glyph(g)

g = libsbgn.glyph(class_=GlyphClass.SIMPLE_CHEMICAL, id='glyph_ethanal')
g.set_label(libsbgn.label(text='Ethanal'))
g.set_bbox(libsbgn.bbox(x=220, y=110, w=60, h=60))
map.add_glyph(g)

# glyph with ports (process)
g = libsbgn.glyph(class_=GlyphClass.PROCESS, id='pn1', orientation=Orientation.HORIZONTAL)
g.set_bbox(libsbgn.bbox(x=148, y=168, w=24, h=24))
g.add_port(libsbgn.port(x=136, y=180, id="pn1.1"))
map.add_glyph(g)

# arcs
a = libsbgn.arc(class_=ArcClass.CONSUMPTION, source="glyph1", target="pn1.1", id="a01")
a.set_start(libsbgn.startType(x=98, y=160))
a.set_end(libsbgn.endType(x=136, y=180))
map.add_arc(a)

a = libsbgn.arc(class_=ArcClass.PRODUCTION, source="pn1.1", target="glyph_ethanal", id="a05")
a.set_start(libsbgn.startType(x=184, y=180))
a.set_end(libsbgn.endType(x=224, y=154))
map.add_arc(a)

sbgn.export('result.xml')

Author

Vid Podpečan (vid.podpecan@ijs.si)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysbgn-0.2.1.tar.gz (29.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysbgn-0.2.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file pysbgn-0.2.1.tar.gz.

File metadata

  • Download URL: pysbgn-0.2.1.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for pysbgn-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b73416523f02c09569548e7315b41d04c515bee23f0e3171df6186a263b76bd2
MD5 b9269c87a99bff1785e042e56ed9414a
BLAKE2b-256 1196269e81fbec136f8adad03ddbaf1c7bf61b6eb86fb2878136625d2c074c6f

See more details on using hashes here.

File details

Details for the file pysbgn-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pysbgn-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.10

File hashes

Hashes for pysbgn-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 50ace8458f63c40da243e283fb727c56d7f87f6a5a1b71d2505742801c290c92
MD5 0ecfb6fa332c2493e2770ec30d7d5a11
BLAKE2b-256 9c0765085510a257d65d8d3202f430b19480bba2f4d5324cb32e879be3bc0a46

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page