Install¶
PSAMM can be installed using the Python package installer pip
. We recommend
that you use a Virtualenv when installing PSAMM. First, create a Virtualenv
in your project directory and activate the environment. On Linux/OSX the
following terminal commands can be used:
$ virtualenv env
$ source env/bin/activate
Then, install PSAMM using the pip
command:
(env) $ pip install psamm
When returning to the project from a new terminal window, simply reactivate the environment by running
$ source env/bin/activate
The psamm-import tool is included in the main PSAMM repository. Some additional model specific importers for Excel format models associated with publications are maintained in a separate repository. After installing PSAMM, support for these import functions can be added through installing this additional program:
(env) $ pip install git+https://github.com/zhanglab/psamm-import.git
Dependencies¶
- Linear programming solver (Cplex, Gurobi, GLPK or QSopt_ex)
- PyYAML (for reading the native model format)
- NumPy (optional; model matrix can be exported to NumPy matrix if available)
PyYAML is installed automatically when PSAMM is installed through pip
. The
linear programming solver is not strictly required but most analyses require
one to work. The LP solver Cplex is the preferred solver. We recently added
support for the LP solver Gurobi and GLPK.
The rational solver QSopt_ex does not support MILP problems which means that some analyses require one of the other solvers. The MILP support in GLPK is still experimental so it is disabled by default.
Cplex¶
The Cplex Python bindings will have to be installed manually. Make sure that you are using at least Cplex version 12.6. If you are using a virtual environment (as described above) this should be done after activating the virtual environment:
- Locate the directory where Cplex was installed (e.g.
/path/to/IBM/ILOG/CPLEX_StudioXXX
). - Locate the appropriate subdirectory based on your platform and Python
version:
cplex/python/<version>/<platform>
(e.g.cplex/python/2.7/x86-64_osx
). - Use
pip
to install the package from this directory using the following command.
(env) $ pip install \
/path/to/IBM/ILOG/CPLEX_Studio1262/cplex/python/<version>/<platform>
Further documentation on installing Cplex can be found in the Cplex documentation.
Note
Python 3 support was added in a recent release of Cplex. Older versions only support Python 2. If you are using Python 3 make sure that you have the latest version of Cplex installed.
Gurobi¶
The Gurobi Python bindings will have to be installed into the virtualenv. After activating the virtualenv:
- Change the directory to where the Guropi python bindings were installed. For
example, on OSX this directory is
/Library/gurobiXXX/mac64
whereXXX
is a version code. - Use
python
to install the package from this directory. For example:
(env) $ cd /Library/gurobi604/mac64
(env) $ python setup.py install
GLPK¶
The GLPK solver requires the GLPK library to be installed. The swiglpk
Python bindings are required for PSAMM to use the GLPK library.
(env) $ pip install swiglpk
QSopt_ex¶
QSopt_ex is supported through python-qsoptex which requires GnuMP and
the QSopt_ex library. After installing these libraries the Python bindings
can be installed using pip
:
(env) $ pip install python-qsoptex
The installation method detailed above is only supported on Python 3.4 or lower. If you want to use this solver with later versions of Python, you must first install this python-qsoptex_higherPython, a different library for this solver, and different bindings from QSopt_ex_higherPython
(env) $ pip install cython
(env) $ pip install python-qsoptex
LP Solver Compatibility¶
Not all of the LP solvers supported are supported across all python versions. A table showing which solvers are compatible with which versions of python is shown below:
Solver | Python 2.7 | Python 3.5 | Python 3.6 | Python 3.7 | Python 3.8 |
---|---|---|---|---|---|
Cplex | Yes | Yes | Yes | Yes | Yes |
Qsopt_ex | Yes | Yes | Yes | Yes | Yes |
Gurobi | Yes | Yes | No | No | No |
GLPK | Yes | No | Yes | Yes | Yes |
LP Solver Global Options¶
Additionally, not all LP solvers are compatible with all of the global parameters for solvers. Reference the table below for the global parameters you might require before choosing a solver.
Solver | feasibility tolerance | optimality tolerance | inegrality tolerance | threads |
---|---|---|---|---|
Cplex | Yes | Yes | Yes | Yes |
Qsopt_ex | Yes | Yes | No | No |
Gurobi | Yes | Yes | Yes | Yes |
GLPK | Yes | Yes | Yes | No |