Skip to content

dweindl/sbmlmath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

None yet.

Installation

Releases from PyPI:

pip install sbmlmath

The latest development version from GitHub:

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