opencobra/cobrapy

FVA gives back odd results

Patrickens opened this issue · 2 comments

Problem description

A dependency that Im using is trying to use cobra.flux_analysis.flux_variability_analysis and fails because there is a bug. The example below is with the e_coli_core model and Im using the gurobipy solver. When printing the reactions and bounds, and checking the bounds on the optlang.Variable objects, everything is as defined in the e_coli_core model, but this somehow still hangs.

Code Sample

from cobra.io import read_sbml_model
from cobra.flux_analysis import flux_variability_analysis
file = 'e_coli_core.xml'
model = read_sbml_model(file)
model.reactions.get_by_id('EX_glc__D_e').bounds = (-10.0, 0.0)
fva = flux_variability_analysis(model=model, processes=1)

As we can see in the output below, it seems that most minima are equal to the maxima, which is a bug. I have the feeling this is an optlang + gurobi backend issue. I don't use optlang much, so I wouldn't know how to address this.

FVA OUTPUT:

minimum maximum
PFK 7.477382 7.477382
PFL 0 0
PGI 4.860861 4.860861
PGK -16.0235 -16.0235
PGL 4.959985 4.959985
ACALD 0 0
AKGt2r 0 0
PGM -14.7161 -14.7161
PIt2r 3.214895 3.214895
ALCD2x 0 0
ACALDt 0 0
ACKr 0 0
PPC 2.504309 2.504309
ACONTa 6.00725 6.00725
ACONTb 6.00725 6.00725
ATPM 8.39 8.39
PPCK 0 0
ACt2r 0 0
PPS 0 0
ADK1 0 0
AKGDH 5.064376 5.064376
ATPS4r 45.51401 45.51401
PTAr 0 0
PYK 1.758177 1.758177
BIOMASS_Ecoli_core_w_GAM 0.873922 0.873922
PYRt2 0 0
CO2t -22.8098 -22.8098
RPE 2.678482 2.678482
CS 6.00725 6.00725
RPI -2.2815 -2.2815
SUCCt2_2 0 0
CYTBD 43.59899 43.59899
D_LACt2 0 0
ENO 14.71614 14.71614
SUCCt3 0 0
ETOHt2r 0 0
SUCDi 5.064376 1000
SUCOAS -5.06438 -5.06438
TALA 1.496984 1.496984
THD2 0 0
TKT1 1.496984 1.496984
TKT2 1.181498 1.181498
TPI 7.477382 7.477382
EX_ac_e 0 0
EX_acald_e 0 0
EX_akg_e 0 0
EX_co2_e 22.80983 22.80983
EX_etoh_e 0 0
EX_for_e 0 0
EX_fru_e 0 0
EX_fum_e 0 0
EX_glc__D_e -10 -10
EX_gln__L_e 0 0
EX_glu__L_e 0 0
EX_h_e 17.53087 17.53087
EX_h2o_e 29.17583 29.17583
EX_lac__D_e 0 0
EX_mal__L_e 0 0
EX_nh4_e -4.76532 -4.76532
EX_o2_e -21.7995 -21.7995
EX_pi_e -3.2149 -3.2149
EX_pyr_e 0 0
EX_succ_e 0 0
FBA 7.477382 7.477382
FBP 0 0
FORt2 0 0
FORt 0 0
FRD7 0 994.9356
FRUpts2 0 0
FUM 5.064376 5.064376
FUMt2_2 0 0
G6PDH2r 4.959985 4.959985
GAPD 16.02353 16.02353
GLCpts 10 10
GLNS 0.223462 0.223462
GLNabc 0 0
GLUDy -4.54186 -4.54186
GLUN 0 0
GLUSy 0 0
GLUt2r 0 0
GND 4.959985 4.959985
H2Ot -29.1758 -29.1758
ICDHyr 6.00725 6.00725
ICL 0 0
LDH_D 0 0
MALS 0 0
MALt2_2 0 0
MDH 5.064376 5.064376
ME1 0 0
ME2 0 0
NADH16 38.53461 38.53461
NADTRHD 0 0
NH4t 4.765319 4.765319
O2t 21.79949 21.79949
PDH 9.282533 9.282533

Context

python -c "import cobra;cobra.show_versions()"

-->

System Information
==================
OS         Windows
OS-release      10
Python      3.8.13
Package Versions
================
appdirs                                      1.4.4
black ; extra == 'development'       not installed
bumpversion ; extra == 'development' not installed
cobra                                       0.26.2
depinfo                                      1.7.0
diskcache                                    5.4.0
future                                      0.18.2
httpx                                       0.23.0
importlib-resources                          5.9.0
isort ; extra == 'development'       not installed
numpy                                       1.23.3
optlang                                      1.6.1
pandas                                       1.4.4
pip                                         22.2.2
poetry                                       1.4.1
pydantic                                    1.10.2
python-libsbml                              5.19.6
rich                                        12.5.1
ruamel.yaml                                0.17.21
scipy                                        1.9.1
setuptools                                  67.6.0
swiglpk                                      5.0.8
tox ; extra == 'development'         not installed
wheel                                       0.37.1

You need to allow for a little bit of variability by choosing a fraction of the optimum https://cobrapy.readthedocs.io/en/latest/simulating.html#Running-FVA

Oich, my bad. Thank you! Ill close.