me_model_setup
==============

E-mail Joshua Lerman (jlerman44@gmail.com) or Teddy O'Brien (ejobrien819@gmail.com) with questions or comments.

**Directions to install and run your first simulation using the *E. coli* ME-Model:**

**Step 1:**
  Download and install [SoPlex version 1.6.0](http://soplex.zib.de/download.php?fname=soplex-1.6.0.tgz).

  To compile SoPlex version 1.6.0, use the instructions below:
```Bash
tar xvf soplex-1.6.0.tar
cd soplex-1.6.0
make USRCXXFLAGS="-DWITH_LONG_DOUBLE"
```

**Step 2:** Download and install [COBRApy (COBRA for Python)](https://github.com/opencobra/cobrapy). 
You will need to install [NumPy](http://www.numpy.org) and [SciPy](http://www.scipy.org) if you haven't already.

**Step 3:** Download and install [SymPy 0.7.1](http://sympy.googlecode.com/files/sympy-0.7.1.tar.gz). The newest version of SymPy (0.7.2) works, but is unbearably slow for unknown reasons.

**Step 4:** Download and install [glpk](http://ftp.gnu.org/gnu/glpk/glpk-4.47.tar.gz).

**Step 5:** Download and install [pyglpk](http://tfinley.net/software/pyglpk/pyglpk-0.3.tar.bz2).  Special instructions: You should manually relace all instances of '-m32' in setup.py with '-m64' prior to running the setup script.

**Step 6:** Take a coffee (or tea) break...

Now you are setup and ready to try running an *E. coli* ME-Model simulation.

**Step 7:** Look at the included python script 'load_cobra_model_substitute_and_write_lp_file.py' 
to learn how to load the model. The model is a COBRApy model object that has SymPy symbols inserted 
in various places to allow for custom parameterization. 

Parameters are set in 'load_cobra_model_substitute_and_write_lp_file.py', but explained in the
supplementary information of the associated manuscript. Running this script produces an .lp file. 
The format of this file matches the [CPLEX LP file format](http://lpsolve.sourceforge.net/5.1/CPLEX-format.htm). 
The file will be named 'e_coli_me_model.lp'.

**Step 8:** Solve the resulting LP problem using soplex. To do so, run the following command using the terminal:
```Bash
soplex -s0 -x e_coli_me_model.lp > e_coli_me_model_solution.stdout
```
If all goes well, the primal solution will be output to a file named 'e_coli_me_model_solution.stdout'.

**Step 9:** Once the solver is finished, the dictionary stored in 'basis_compatible_encode_dict.pickle' must be used to 
decode the variable names in the solution file. To do so, just run 'parse_solution_file.py'. 
A file named 'human_readable_e_coli_me_model_solution.stdout' is generated. This contains the flux vector you solved for.
The units are mmol / gDW h.

And there you have it, your first *E. coli* ME-Model simulation!
