sbmlutils.report.mathml

Rendering of formulas and Content MathML.

A common problem in rendering MathML is that the content MathML is difficult to read. The presentation MathML has a much better rendering and improves understandability. This module uses stylesheets for the conversion of content MathMl -> presentation MathML.

see also: https://docs.sympy.org/dev/modules/printing.html#module-sympy.printing.mathml

Module Contents

Functions

formula_to_astnode(formula[, model])

Convert formula string to ASTNode.

formula_to_latex(formula[, model])

Convert formula string to latex.

cmathml_to_astnode(cmathml)

Convert Content MathML string to ASTNode.

astnode_to_latex(astnode)

Convert ASTNode to Latex using XSLT transformation.

cmathml_to_latex(cmml_str)

Content MathML to latex conversion using XSLT transformation.

symbol_to_latex(symbol)

Convert symbol to latex by packing in mathit and escaping underscores.

_fix_mathit_symbols(tex_str)

Heuristic replacements for better latex rendering.

_get_variables(astnode[, variables])

Get variables from ASTNode.

Attributes

logger

xslt_cmml2pmml

xslt_pmml2tex

greek_symbols

sbmlutils.report.mathml.logger[source]
sbmlutils.report.mathml.xslt_cmml2pmml[source]
sbmlutils.report.mathml.xslt_pmml2tex[source]
sbmlutils.report.mathml.formula_to_astnode(formula, model=None)[source]

Convert formula string to ASTNode.

Parameters:
  • formula (str) – SBML formula string

  • model (Optional[libsbml.Model]) – libsbml.Model

Returns:

libsbml.ASTNode

Return type:

libsbml.ASTNode

sbmlutils.report.mathml.formula_to_latex(formula, model=None)[source]

Convert formula string to latex.

Parameters:
  • formula (str) –

  • model (Optional[libsbml.Model]) –

Return type:

str

sbmlutils.report.mathml.cmathml_to_astnode(cmathml)[source]

Convert Content MathML string to ASTNode.

Parameters:

cmathml (str) – SBML Content MathML string

Returns:

libsbml.ASTNode

Return type:

libsbml.ASTNode

sbmlutils.report.mathml.astnode_to_latex(astnode)[source]

Convert ASTNode to Latex using XSLT transformation.

Parameters:

astnode (libsbml.ASTNode) –

Return type:

str

sbmlutils.report.mathml.cmathml_to_latex(cmml_str)[source]

Content MathML to latex conversion using XSLT transformation.

Parameters:

cmml_str (str) –

Return type:

str

sbmlutils.report.mathml.greek_symbols = ['alpha', 'beta', 'gamma', 'Gammadelta', 'Delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota',...[source]
sbmlutils.report.mathml.symbol_to_latex(symbol)[source]

Convert symbol to latex by packing in mathit and escaping underscores.

Parameters:

symbol (str) –

Return type:

str

sbmlutils.report.mathml._fix_mathit_symbols(tex_str)[source]

Heuristic replacements for better latex rendering.

Single underscores are set down. Greek symbols are rendered (with exception of small lambda).

Parameters:

tex_str (str) –

Return type:

str

sbmlutils.report.mathml._get_variables(astnode, variables=None)[source]

Get variables from ASTNode.

Parameters:
  • astnode (libsbml.ASTNode) –

  • variables (Optional[Set[str]]) –

Return type:

Set[str]