Skip to main content

SBML Math <-> SymPy

Project description

sbmlmath - a Python library for handling SBML MathML

This is Python library for interconverting SymPy expressions and SBML MathML. SBML uses a subset of MathML that this library tries to support. This is not (intended to be) a general MathML parser.

Main functionality:

  • sympy -> SBML MathML
  • SBML MathML -> sympy
    • in particular for cases where sympy.sympify(libsbml.formulaToL3String(...)) won't do the job
    • retaining unit annotations and other <ci> attributes

NOTE: This is under development and the API is to be considered unstable

Python support policy: sbmlmath follows NEP 29.

Usage

from sbmlmath import SBMLMathMLPrinter, SBMLMathMLParser
import sympy as sp

sympy_expr = sp.sympify("A ** B + exp(C) * D")
mathml = SBMLMathMLPrinter().doprint(sympy_expr)
print(mathml)

cycled_sympy = SBMLMathMLParser().parse_str(mathml)
print(cycled_sympy)
assert sympy_expr == cycled_sympy

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

sbmlmath-0.0.3.tar.gz (14.8 kB view hashes)

Uploaded Source

Supported by

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