16 unstable releases (6 breaking)

0.7.0 Nov 1, 2021
0.6.0 Jul 31, 2021
0.5.2 Nov 14, 2020

#1933 in Parser implementations

Used in kair


1.5K SLoC

Rust 1K SLoC // 0.0% comments Python 125 SLoC // 0.1% comments Pan 14 SLoC // 0.2% comments

Crates.io pypi Documentation Build Codecov


Parser for the Systems Biology Markup Language (SBML):

Getting started


Add it to your Cargo.toml with no default features to avoid all PyO3 nuisances.

version = "0.7.0"

For example,

use rust_sbml::Model;

let example=r#"<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
     <model timeUnits="second" extentUnits="mole" substanceUnits="mole">
let result = Model::parse(example);
println!("{:?}", result.unwrap());

See write_to_file.rs for an example on serializing to a file.


It has only been tested on Linux.

Using pip

pip install rust_sbml

From source

Clone the repository.

git clone https://github.com/carrascomj/rust_sbml.git

You need maturin for building it.

python -m pip install maturin
  • Build locally
    maturin build --release
    pip install .
  • Build on virtualenv (no pip install required)
    # --release can be omitted to speed up compilation time
    maturin develop --release

Having it installed, you can use it as a normal Python package.

from rust_sbml import Model

sbml = Model("examples/EcoliCore.xml")
reaction = sbml.getListOfReactions()[0]


  • getListOfSpecies() (id, name)
  • getListOfCompartments() (id, name)
  • getListOfReactions() (id, name)
    • .getListOfReactants() (id, name)
    • .getListOfProducts() (id, name)
  • Capable of retrieving FBC bounds.
  • Published to pypi
  • Kinetic Laws, with naive mathml tailored for SBML.
  • Metadata, with naive rdf tailored for SBML.
  • Test suite with python calls.
  • Test suite with libsbml comparison trough cobrapy.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

README.md is automatically generated on CI using cargo-readme. Please, modify README.tpl or lib.rs instead (check the github worflow for more details).


~63K SLoC