{"id":18260383,"url":"https://github.com/carrascomj/kair","last_synced_at":"2025-04-04T19:33:16.218Z","repository":{"id":53551687,"uuid":"304619154","full_name":"carrascomj/kair","owner":"carrascomj","description":"COnstraint-Based Reconstruction and Analysis in Rust","archived":false,"fork":false,"pushed_at":"2021-05-09T14:28:06.000Z","size":143,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"trunk","last_synced_at":"2024-10-11T09:42:56.392Z","etag":null,"topics":["cobra","metabolism","modeling","simulation","systems-biology"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carrascomj.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-16T12:21:20.000Z","updated_at":"2024-03-08T20:52:21.000Z","dependencies_parsed_at":"2022-09-26T20:20:38.798Z","dependency_job_id":null,"html_url":"https://github.com/carrascomj/kair","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carrascomj%2Fkair","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carrascomj%2Fkair/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carrascomj%2Fkair/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carrascomj%2Fkair/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carrascomj","download_url":"https://codeload.github.com/carrascomj/kair/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223157390,"owners_count":17097362,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cobra","metabolism","modeling","simulation","systems-biology"],"created_at":"2024-11-05T10:45:05.730Z","updated_at":"2024-11-05T10:45:06.625Z","avatar_url":"https://github.com/carrascomj.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KAIr (COBRA Alternative In rust)\n\n[![Crates.io](https://img.shields.io/crates/v/kair.svg)](https://crates.io/crates/kair)\n[![Documentation](https://docs.rs/kair/badge.svg)](https://docs.rs/kair/)\n[![Build](https://github.com/carrascomj/kair/workflows/build/badge.svg)](https://github.com/carrascomj/kair)\n[![Codecov](https://codecov.io/github/carrascomj/kair/coverage.svg?branch=trunk)](https://codecov.io/gh/carrascomj/kair)\n\n*COnstraint-Based Reconstruction and Analysis* (COBRA) methods\nenable the use of knowledge-based reconstructions of the metabolism of a\nparticular organism to simulate its metabolic network.\n\n**kair** provides the translation from a [SBML](http://sbml.org/Special/specifications/sbml-level-3/version-2/core/release-2/sbml-level-3-version-2-release-2-core.pdf) (using [rust_sbml](https://github.com/carrascomj/rust_sbml/)) document to the most basic\nLinear Programming formulation of COBRA: Flux Balance Analysis (FBA). Being\n`f(z)` a function to optimize (historically, the biomass pseudoreaction or the ATPase),\n`S` and stoichimetry matrix; and `v` the flux vector representing\nthe reactions in the reconstruction:\n\n\u003ca href=\"https://www.codecogs.com/eqnedit.php?latex=\\begin{array}{l@{\\quad}\u0026space;r\u0026space;c\u0026space;r}\u0026space;\\max\u0026space;\u0026\u0026space;f(\\overrightarrow\u0026space;z)\u0026space;\\\\\u0026space;\\mathrm{s.t.}\u0026space;\u0026\u0026space;S\\overrightarrow{v}\u0026space;=\u0026space;0\u0026space;\\\\\u0026space;\\mathrm{where}\u0026\u0026space;lb_j\u0026space;\\le\u0026space;v_j\u0026space;\\le\u0026space;ub_j\u0026space;\\end{array}\" target=\"_blank\"\u003e\u003cimg src=\"https://latex.codecogs.com/gif.latex?\\begin{array}{l@{\\quad}\u0026space;r\u0026space;c\u0026space;r}\u0026space;\\max\u0026space;\u0026\u0026space;f(\\overrightarrow\u0026space;z)\u0026space;\\\\\u0026space;\\mathrm{s.t.}\u0026space;\u0026\u0026space;S\\overrightarrow{v}\u0026space;=\u0026space;0\u0026space;\\\\\u0026space;\\mathrm{where}\u0026\u0026space;lb_j\u0026space;\\le\u0026space;v_j\u0026space;\\le\u0026space;ub_j\u0026space;\\end{array}\" title=\"\\begin{array}{l@{\\quad} r c r} \\max \u0026 f(\\overrightarrow z) \\\\ \\mathrm{s.t.} \u0026 S\\overrightarrow{v} = 0 \\\\ \\mathrm{where}\u0026 lb_j \\le v_j \\le ub_j \\end{array}\" /\u003e\u003c/a\u003e\n\nThe FBA problem can then be optimized thanks to [lp_modeler](https://github.com/jcavat/rust-lp-modeler).\n\nSee [What is flux balance analysis?, Orth et al., 2010](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3108565/)\nfor a brief description of FBA.\n\n## Installation\nAdd **kair** it to your Cargo.toml:\n```toml\n[dependencies]\nkair = \"0.5.0\"\n```\n\nIn addition, add [`good_lp`](https://github.com/rust-or/good_lp) with the solver of choice, for instance `coin_cbc` (default):\n```toml\n[dependencies]\ngood_lp = { version=\"1.1.0\", default_features=true }\n```\n\nMake sure you have installed the [Cbc solver](https://github.com/coin-or/Cbc#binaries)\n(other solvers do not require installation).\n```shell\n# Debian\nsudo apt install coinor-cbc\n# Arch\nsudo pacman -S coin-or\n# Mac OS\nbrew tap coin-or-tools/coinor \u0026\u0026 brew install coin-or-tools/coinor/cbc\n```\n\n## Example\nSome `use` statements to get started.\n```rust\nuse kair::{ModelLP, fba, flux_analysis::fva};\nuse good_lp::default_solver;\nuse std::str::FromStr;\n```\nFirst, read the SBML document, we will be using the [e_coli_core model](http://bigg.ucsd.edu/models/e_coli_core).\n```rust\nlet file_str = std::fs::read_to_string(\"examples/EcoliCore.xml\").unwrap();\nlet model = ModelLP::from_str(\u0026file_str).unwrap();\n```\nNow, we can optimize it and print the solution, which is just a\n[HashMap](https://doc.rust-lang.org/std/collections/struct.HashMap.html) of\npairs _variable name_ -\u003e _solution value_.\n```rust\nfor (name, val) in fba(\u0026mut model, default_solver).unwrap().iter() {\n    println!(\"{} = {}\", name, val)\n}\n```\n_Output_\n```\nR_EX_co2_e_ = 22.809834\nR_ATPM_ = 8.39\nR_H2Ot_ = -29.175827\nR_GLNS_ = 0.22346173\n...\nR_BIOMASS_Ecoli_core_w_GAM_ = 0.8739215\n...\nR_EX_pi_e_ = -3.214895\nR_SUCOAS_ = -5.064376\nR_PGL_ = 4.959985\nR_TKT1_ = 1.4969838\n```\n\nTo run this example, on the root of this repository, run\n```shell\ncargo run --example ecoli\n```\n\nFlux variability analysis is also implemented:\n```rust\nlet reactions: Vec\u003cString\u003e = model.reactions.iter().map(|(k, _v)| k.clone()).collect();\nfor (name, val) in fva(\u0026mut model, default_solver, reactions).unwrap().iter() {\n    println!(\"{} = {:?}\", name, val)\n}\n```\n_Output (you would need to use a bigger model to see the difference)_\n```\nR_ACONTa = (6.007249575350586, 6.007249575350007)\nR_ACALD = (0.0, 0.0)\nR_ACKr = (-0.0, -0.0)\nR_ICDHyr = (6.007249575351851, 6.007249575350007)\nR_CO2t = (-22.80983331020489, -22.809833310205118)\nR_RPI = (-2.2815030940668573, -2.2815030940674283)\nR_ADK1 = (-0.0, -0.0000000000003395200787181807)\nR_PGK = (-16.0235261431673, -16.02352614316787)\nR_SUCCt3 = (0.0, -0.0000000000004168517383125921)\nR_EX_pyr_e = (0.0, 0.0)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarrascomj%2Fkair","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarrascomj%2Fkair","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarrascomj%2Fkair/lists"}