Skip to main content

SBML Math <-> SymPy

Project description

sbmlmath — a Python library for handling SBML MathML

This is a Python library for interconverting SymPy expressions and SBML-MathML. SBML uses a subset of MathML that this library aims 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 (mind the differences operator precedence between sympy/Python and libsbml L3 formulas!)
    • 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

Documentation

Under construction at sbmlmath.readthedocs.io.

Installation

Releases from PyPI:

pip install sbmlmath

The latest development version from GitHub:

pip install https://github.com/dweindl/sbmlmath/archive/main.zip

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.2.0.tar.gz (22.0 kB view details)

Uploaded Source

File details

Details for the file sbmlmath-0.2.0.tar.gz.

File metadata

  • Download URL: sbmlmath-0.2.0.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for sbmlmath-0.2.0.tar.gz
Algorithm Hash digest
SHA256 227d7d3b341beadc6df043a627789f33da08906302f1d1affe5ecf5be7b4d8b5
MD5 c3e97e3c917933691968a09e7b3f2aad
BLAKE2b-256 fc39673a7785ef6cd22f2df36e70d6a1b7b4534050f0ac14a0a68e6fc0d12fa2

See more details on using hashes here.

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