Flux balance analysis predicts metabolic phenotypes by solving a linear program over a genome-scale model: it maximizes a biomass (or custom) objective subject to steady-state mass balance and exchange bounds. The single most important thing to internalize is that FBA is under-determined - the maximal objective is reached across a whole face of the solution space, so model.optimize() returns one arbitrary flux vector among many. The objective value is robust; individual internal fluxes are not, and must be qualified with flux variability analysis (ranges), parsimonious FBA (a minimal-flux representative), or sampling (a distribution). A nonzero growth rate is only as trustworthy as the medium and the biomass reaction that produced it.
pip install cobra
# Optional faster/more robust solvers for large or MILP/QP work:
# HiGHS ships with cobra; academic CPLEX or Gurobi are free and recommended for genome-scale models.
Inputs: a genome-scale model in SBML (.xml) or COBRA JSON, or a built-in test model (load_model('textbook'), load_model('iJO1366')). Curated models are at http://bigg.ucsd.edu/models.
Tell your AI agent: - "Run FBA on the E. coli core model and report the growth rate" - "Set glucose minimal medium and predict growth, then tell me if it looks realistic" - "Compute FVA ranges and flag which reactions are actually determined vs free" - "Give me a parsimonious flux distribution for my model" - "Sample the flux space and report the distribution for the key exchange reactions"
"Load iJO1366, set glucose-minimal aerobic medium with 10 mmol/gDW/h glucose, run FBA, and tell me whether the growth rate is biological or an artifact of an open exchange."
"Run FBA and then FVA at 100% and 90% of optimum on my model, and list the reactions whose flux is fully determined versus those free to vary - I want to know which single-FBA fluxes I can trust."
"Compare a plain FBA solution to pFBA and a loopless solution for my curated model, and explain which internal fluxes change and why."
"Uniformly sample the flux space of my model constrained to >=90% of max growth, and give me the median and interquartile range for the glycolysis and TCA reactions."
model.medium dict.optimize() / slim_optimize() and report the objective value with its solver status.slim_optimize() inside loops (medium scans, comparisons) - it returns only the objective float and is much faster than building a full Solution.with model: so they revert automatically and comparisons never leak state.solution.fluxes[rxn] for an internal reaction without checking its FVA range - a wide range means the value was arbitrary.