KAIr (COBRA Alternative In rust)
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:
[]
= "0.5.0"
In addition, add good_lp
with the solver of choice, for instance coin_cbc
(default):
[]
= { ="1.1.0", =true }
Make sure you have installed the Cbc solver (other solvers do not require installation).
# 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.
use ;
use default_solver;
use FromStr;
First, read the SBML document, we will be using the e_coli_core model.
let file_str = read_to_string.unwrap;
let model = from_str.unwrap;
Now, we can optimize it and print the solution, which is just a HashMap of pairs variable name -> solution value.
for in fba.unwrap.iter
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
cargo run --example ecoli
Flux variability analysis is also implemented:
let reactions: = model.reactions.iter.map.collect;
for in fva.unwrap.iter
Output (you would need to use a bigger model to see the difference)
R_ACONTa = (6.007249575350586, 6.007249575350007)
R_ACALD = (0.0, 0.0)
R_ACKr = (-0.0, -0.0)
R_ICDHyr = (6.007249575351851, 6.007249575350007)
R_CO2t = (-22.80983331020489, -22.809833310205118)
R_RPI = (-2.2815030940668573, -2.2815030940674283)
R_ADK1 = (-0.0, -0.0000000000003395200787181807)
R_PGK = (-16.0235261431673, -16.02352614316787)
R_SUCCt3 = (0.0, -0.0000000000004168517383125921)
R_EX_pyr_e = (0.0, 0.0)