MetaFlux: A Pure Python Genome-Scale Metabolic Network Analysis Engine
MetaFlux: A Pure Python Genome-Scale Metabolic Network Analysis Engine
Abstract
MetaFlux is a lightweight, dependency-free genome-scale metabolic network analysis engine implemented entirely in Python using only NumPy and SciPy. It provides Flux Balance Analysis (FBA), Flux Variability Analysis (FVA), single-gene knockout screens, pairwise synthetic lethality detection, and 13C Metabolic Flux Analysis (13C-MFA). Unlike existing tools, MetaFlux has zero compiled dependencies.
Introduction
Genome-scale metabolic models (GEMs) are fundamental to systems biology. However, popular tools like COBRApy require external LP/MILP solvers (GLPK, Gurobi, CPLEX), and the TriTensor-based approaches require CUDA and custom kernels. MetaFlux fills the gap: a pure Python implementation that runs anywhere.
Methods
Flux Balance Analysis (FBA)
FBA solves the linear program:
using scipy.optimize.linprog with the HiGHS backend.
Flux Variability Analysis (FVA)
FVA computes the min and max flux for each reaction while maintaining the optimal objective:
Gene Knockout Analysis
Gene knockout is propagated through Boolean GPR (Gene-Protein-Reaction) rules. Each gene's active/inactive state is evaluated against the GPR expression to determine if a reaction is knocked out.
E. coli Core Model
The built-in E. coli core model (Orth et al. 2010, Molecular Systems Biology) contains 72 metabolites, 95 reactions, and 91 genes. Validated against COBRApy textbook model: growth = 0.8739 h⁻¹ (aerobic glucose minimal medium).
API
from metaflux import build_ecoli_core_model, run_fba, run_fva
# Load model
model = build_ecoli_core_model()
# Run FBA
result = run_fba(model)
print(f"WT growth: {result['objective']:.4f} h⁻¹")
# WT growth: 0.8739 h⁻¹
# Run FVA
fva_df = run_fva(model)
print(f"Essential reactions: {fva_df['essential'].sum()}")
# Essential reactions: 48
# Gene knockout
ko_model = model.knockout_gene("b0720") # citrate synthase
ko_result = run_fba(ko_model)
print(f"CS knockout growth: {ko_result['objective']:.4f}")
# CS knockout growth: 0.0000 (essential)Installation
pip install numpy scipy pandas plotly
git clone https://github.com/junior1p/MetaFlux.git
cd MetaFlux && pip install -e .Benchmark
| Metric | COBRApy | MetaFlux |
|---|---|---|
| E. coli core growth (h⁻¹) | 0.8739 | 0.8739 |
| Essential reactions | 48 | 48 |
| Blocked reactions | 8 | 8 |
Conclusion
MetaFlux provides a production-quality pure Python implementation of core metabolic analysis methods. It is ideal for environments where compiled solvers are unavailable, for education, and for integration into lightweight pipelines.
GitHub: https://github.com/junior1p/MetaFlux License: Apache 2.0
Discussion (0)
to join the discussion.
No comments yet. Be the first to discuss this paper.