solveME toolbox for solving nonlinear ME models. Includes interfaces (as external modules) to the quad MINOS-based Fortran 90 code by Ding Ma and Michael A. Saunders at Stanford University
If you use solveME in a scientific publication, please cite:
and the following for the Quad MINOS solver:
Author: Laurence Yang
Systems Biology Research Group, UCSD
- Python
- tested on Python 2.7 and 3.6
- cobrapy
- tested on 0.5.11
- not yet fully compatible with cobrapy 0.6 release
- cobrame (0.0.7): follow Installation instructions here: https://github.com/SBRG/cobrame
- git clone --branch v0.0.7 https://github.com/SBRG/cobrame.git
- gfortran (>=4.6)
- (Ubuntu) sudo apt-get install gfortran
- (Arch) sudo pacman -S gcc-fortran
- quadMINOS (available for academic use from Prof. Michael A. Saunders at Stanford University)
-
Compile quadMINOS
- copy Makefile.defs into quadLP_root/minos56/ and quadLP_root/qminos56/
- this step ensures the compiler flags needed to interface with Python are set
- cd qminos_root
- cd minos56; make clean; make
- cd ..
- cd qminos56; make clean; make
- copy Makefile.defs into quadLP_root/minos56/ and quadLP_root/qminos56/
-
Copy shared libraries to solveme root directory
- cd [solveme_root]
- cp [qminos_root]/qminos56/lib/libquadminos.a ./
- cp [qminos_root]/minos56/lib/libminos.a ./
-
Run: python setup.py develop
- or python setup.py develop --user
- or sudo python setup.py develop to install for all users
- (if getting an error, [undefined reference to main], try sudo python setup.py develop)
-
Special NERSC installation steps
- (shell) module swap PrgEnv-intel PrgEnv-gnu
- python setup.py config_fc --f90exec=ftn develop --user
- (need to use the ftn gfortran Cray wrapper, or else get symbol not found error during import)
-
Troubleshooting common errors
- ImportError: .../solveME/solvemepy/qminospy/qwarmLP.so: symbol _gfortran_transfer_real128_write, version GFORTRAN_1.4 not defined in file libgfortran.so.3 with link time reference
- Problem: setup.py picked up the wrong libgfortran during installation. Typically, if anaconda is installed, an older version is installed, which seems to be used by default.
- Solution (workaround): pre-load the desired libgfortran version, bypassing the anaconda one:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libgfortran.so.3
- (then, proceed with setup) python setup.py develop --user
- Link to original solution
- NaN produced by the solver.
- Problem: certain computing environments (e.g., compute clusters) may have compiled Numpy with GCC versions that don't match that used to compile Quad MINOS, and/or the Fortran 90 code in solvemepy. This may lead to unexpected behavior on just that compute environment (like NaN values).
- Solution: re-compile Numpy with GCC version matching that used to compile Quad MINOS.
- load your virtual environment
- pip install git+https://github.com/numpy/[email protected]
- here, we use numpy 1.16.0 as an example
- perform the Installation steps 1-3 (compile quad minos, copy shared libraries, python setup.py develop)
- Credit: thank you to Hui Zhong Lu at Calcul Quebéc for this solution!
- ImportError: .../solveME/solvemepy/qminospy/qwarmLP.so: symbol _gfortran_transfer_real128_write, version GFORTRAN_1.4 not defined in file libgfortran.so.3 with link time reference
- Import qminospy to access the solver methods:
from qminospy.me2 import ME_NLP
me_nlp = ME_NLP(me)
# Solve directly using LCL (linearly constrained Lagrangian) NLP method
x,stat,hs = me_nlp.solvenlp()
# Access the solution that is saved in the original minime object
sol = me.solution
sol.f
sol.x_dict
- Import
py to access the solver methods:
from qminospy.me1 import ME_NLP1
# The object containing solveME methods--composite that uses a ME model object
# Provide growth_key = 'mu' for minime models,
me_nlp = ME_NLP1(me, growth_key='mu')
# Use bisection for now (until the NLP formulation is worked out for the new prototype 44
muopt, hs, xopt, cache = me_nlp.bisectmu(precision=1e-6)
# Access the solution that is saved in the original minime object
sol = me.solution
sol.f
sol.x_dict
- Same as above but use growth_key='growth_rate_in_per_hour'
from qminospy.me1 import ME_NLP1
# The object containing solveME methods--composite that uses a ME model object
me_nlp = ME_NLP1(me, growth_key='growth_rate_in_per_hour')
# Bisection
muopt, hs, xopt, cache = me_nlp.bisectmu(precision=1e-3)
# Access the solution that is saved in the original minime object
sol = me.solution
sol.f
sol.x_dict
See the notebook: examples/test_quadLP.ipynb