Skip to content

Commit

Permalink
Merge pull request #26 from EPFL-LCSB/dev
Browse files Browse the repository at this point in the history
VER: 0.9 - RedGEM is Here!
Thanks to a lot of work from @PtichapronRouge and @Redlinkk 

This release includes (finally!) a Python implementation of our redGEM[1] and lumpGEM[2] papers for systematic genome-scale metabolic model reduction.
The code is still in development, so any feedback is welcome :)

This version also features:

* Repaired autodocumentation
* Faster relaxation
* Lots of code cleanup
* Minor fixes

[1] Ataman, Meric, et al. "redGEM: Systematic reduction and analysis of genome-scale metabolic reconstructions for development of consistent core metabolic models." PLoS computational biology 13.7 (2017): e1005444.
https://doi.org/10.1371/journal.pcbi.1005444

[2] Ataman, Meric, and Vassily Hatzimanikatis. "lumpGEM: Systematic generation of subnetworks and elementally balanced lumped reactions for the biosynthesis of target metabolites." PLoS computational biology 13.7 (2017): e1005513.
https://doi.org/10.1371/journal.pcbi.1005513
  • Loading branch information
realLCSB authored May 13, 2019
2 parents a1b6429 + 0c26b16 commit f6e2a88
Show file tree
Hide file tree
Showing 33 changed files with 1,772 additions and 262 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Pycharm folders
.idea/*
.idea/
cobra_docker/work/.idea/*
*___jb_old___
*___jb_tmp___

# Docker temp files
docker/temp/

###########################################
### Standard Python .gitignore ###
###########################################
Expand Down
5 changes: 3 additions & 2 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXBUILD = python3 -msphinx
SPHINXPROJ = pytfa
SOURCEDIR = .
BUILDDIR = _build
AUTODIR = _autogen

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -17,4 +18,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
39 changes: 36 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,34 @@
import sys
sys.path.insert(0, os.path.abspath('..'))

# In order to build documentation that requires libraries to import
class Mock(object):
def __init__(self, *args, **kwargs):
return

def __call__(self, *args, **kwargs):
return Mock()

@classmethod
def __getattr__(cls, name):
if name in ('__file__', '__path__'):
return '/dev/null'
else:
return Mock()


# These modules should correspond to the importable Python packages.
MOCK_MODULES = [
'cobra',
'numpy',
'scipy',
'pandas',
'optlang', 'optlang.interface', 'optlang.symbolics',
'scipy', 'scipy.io',
]

for mod_name in MOCK_MODULES:
sys.modules[mod_name] = Mock()
# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -35,7 +62,13 @@
'sphinx.ext.intersphinx',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'sphinx.ext.mathjax']
'sphinx.ext.mathjax',
'autoapi.extension']


# Document Python Code
autoapi_type = 'python'
autoapi_dirs = ['../pytfa']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -59,10 +92,10 @@
# built documents.
#
# The short X.Y version.
version = '0.8'
version = '0.9'
# The full version, including alpha/beta/rc tags.

release = '0.8.1'
release = '0.9.0-b0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
38 changes: 0 additions & 38 deletions doc/pytfa.analysis.rst

This file was deleted.

22 changes: 0 additions & 22 deletions doc/pytfa.core.rst

This file was deleted.

62 changes: 0 additions & 62 deletions doc/pytfa.io.rst

This file was deleted.

62 changes: 0 additions & 62 deletions doc/pytfa.optim.rst

This file was deleted.

22 changes: 0 additions & 22 deletions doc/pytfa.rst

This file was deleted.

38 changes: 0 additions & 38 deletions doc/pytfa.utils.rst

This file was deleted.

2 changes: 2 additions & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sphinx
sphinx-autoapi
Empty file modified docker/run
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions models/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mat filter=lfs diff=lfs merge=lfs -text
Binary file modified models/glycolysis.mat
Binary file not shown.
Binary file modified models/small_ecoli.mat
Binary file not shown.
6 changes: 4 additions & 2 deletions pytfa/analysis/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
from sympy.core.singleton import S
from time import time
from cobra.flux_analysis.sampling import OptGPSampler, ACHRSampler, HRSampler,\
from cobra.sampling import OptGPSampler, ACHRSampler, HRSampler,\
shared_np_array
from optlang.interface import OPTIMAL

Expand All @@ -29,6 +29,8 @@ def __init__(self, model, thinning, nproj=None, seed=None):
# This currently has to be done to reset the solver basis which is
# required to get deterministic warmup point generation
# (in turn required for a working `seed` arg)
HRSampler.__init__(self, model, thinning, seed=seed)

if model.solver.is_integer:
raise TypeError("sampling does not work with integer problems :(")
self.model = model.copy()
Expand Down Expand Up @@ -200,4 +202,4 @@ def sample(model, n, method="optgp", thinning=100, processes=1, seed=None):
else:
raise ValueError("method must be 'optgp' or 'achr'!")

return sampler.sample(n, fluxes = False)
return sampler.sample(n, fluxes = False)
3 changes: 2 additions & 1 deletion pytfa/analysis/variability.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from cobra.core import Reaction
from optlang.exceptions import SolverError
from optlang.interface import INFEASIBLE
from tqdm import tqdm

from ..optim import DeltaG
from ..optim.constraints import ForbiddenProfile
Expand Down Expand Up @@ -155,7 +156,7 @@ def variability_analysis(tmodel, kind='reactions', proc_num = BEST_THREAD_RATIO)

results = {'min':{}, 'max':{}}
for sense in ['min','max']:
for k,var in these_vars.items():
for k,var in tqdm(these_vars.items(), desc=sense+'imizing'):
tmodel.logger.debug(sense + '-' + k)
results[sense][k] = _variability_analysis_element(tmodel,var,sense)

Expand Down
Loading

0 comments on commit f6e2a88

Please sign in to comment.