KAIr (COBRA Alternative In rust)

Crates.io Documentation Build Codecov

COnstraint-Based Reconstruction and Analysis (COBRA) methods enable the use of knowledge-based reconstructions of the metabolism of a particular organism to simulate its metabolic network.

kair provides the translation from a SBML (using rust_sbml) document to the most basic Linear Programming formulation of COBRA: Flux Balance Analysis (FBA). Being f(z) a function to optimize (historically, the biomass pseudoreaction or the ATPase), S and stoichimetry matrix; and v the flux vector representing the reactions in the reconstruction:

The FBA problem can then be optimized thanks to lp_modeler.

See What is flux balance analysis?, Orth et al., 2010 for a brief description of FBA.

Installation

Add kair it to your Cargo.toml: toml [dependencies] kair = "0.2.0" Make sure you have installed the Cbc solver. ```shell

Debian

sudo apt install coinor-cbc

Arch

sudo pacman -S coin-or

Mac OS

brew tap coin-or-tools/coinor && brew install coin-or-tools/coinor/cbc ```

Example

Some use statements to get started. rust use kair::ModelLP; use std::str::FromStr; First, read the SBML document, we will be using the ecolicore model. rust let file_str = std::fs::read_to_string("examples/EcoliCore.xml").unwrap(); let model = ModelLP::from_str(&file_str).unwrap(); Having read the document, the LP problem is already formulated. We can print some information about it: rust println!( "Model has {:?} constraints and {:?} variables", &model.constraints.len(), &model.variables.len() ); Output Model has 144 constraints and 95 variables Finally, we can optimize it and print the solution, which is just a HashMap of pairs variable name -> solution value. rust for (name, val) in model.optimize().unwrap().iter() { println!("{} = {}", name, val) } Output R_EX_co2_e_ = 22.809834 R_ATPM_ = 8.39 R_H2Ot_ = -29.175827 R_GLNS_ = 0.22346173 ... R_BIOMASS_Ecoli_core_w_GAM_ = 0.8739215 ... R_EX_pi_e_ = -3.214895 R_SUCOAS_ = -5.064376 R_PGL_ = 4.959985 R_TKT1_ = 1.4969838

To run this example, on the root of this repository, run shell cargo run --example ecoli