From 83e3e3c28fbb3655d2605e61bafdc3c093701818 Mon Sep 17 00:00:00 2001 From: VonAlphaBisZulu Date: Fri, 27 Sep 2024 02:18:12 +0000 Subject: [PATCH] updated version number --- conda-recipe/meta.yaml | 2 +- docs/source/conf.py | 2 +- setup.py | 2 +- straindesign/efmtool.py | 5 +++-- straindesign/solver_interface.py | 10 +++++----- straindesign/strainDesignProblem.py | 7 ++++--- tests/test_01_load_models_and_solvers.py | 3 +++ tests/test_06_multiprocessing.py | 13 +++---------- 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 8bc950a..4af65e3 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -1,4 +1,4 @@ -{% set version = '1.12' %} +{% set version = '1.13' %} package: name: straindesign diff --git a/docs/source/conf.py b/docs/source/conf.py index 10d3e6b..dee760f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,7 +21,7 @@ author = "Philipp Schneider" # The full version, including alpha/beta/rc tags -release = "1.12" +release = "1.13" # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index b939bf9..7c4c002 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="straindesign", - version="1.12", + version="1.13", url="https://github.com/klamt-lab/straindesign.git", description="Computational strain design package for the COBRApy framework", long_description= diff --git a/straindesign/efmtool.py b/straindesign/efmtool.py index 0dc8a98..4fb18ac 100644 --- a/straindesign/efmtool.py +++ b/straindesign/efmtool.py @@ -62,7 +62,7 @@ _java_executable = '' except: _java_executable = '' - + if _java_executable == '': _java_executable = os.path.join(os.environ.get('JAVA_HOME', ''), "bin", "java") try: @@ -73,7 +73,8 @@ _java_executable = '' if _java_executable == '': _java_executable = os.path.join(str(jpype.jSystem.getProperty("java.home")), "bin", "java") - + + def basic_columns_rat(mx, tolerance=0): # mx is ch.javasoft.smx.impl.DefaultBigIntegerRationalMatrix """efmtool: Translate matrix coefficients to rational numbers""" if type(mx) is numpy.ndarray: diff --git a/straindesign/solver_interface.py b/straindesign/solver_interface.py index 23724d2..81a8d76 100644 --- a/straindesign/solver_interface.py +++ b/straindesign/solver_interface.py @@ -101,7 +101,7 @@ class MILP_LP(object): """ def __init__(self, **kwargs): - allowed_keys = { + allowed_keys = { 'c', 'A_ineq', 'b_ineq', 'A_eq', 'b_eq', 'lb', 'ub', 'vtype', 'indic_constr', 'M', SOLVER, 'skip_checks', 'tlim', SEED } # set all keys passed in kwargs @@ -115,14 +115,14 @@ def __init__(self, **kwargs): if key not in kwargs.keys(): setattr(self, key, None) # Select solver (either by choice or automatically cplex > gurobi > glpk) - if getattr(self,SOLVER) is None: + if getattr(self, SOLVER) is None: if len(avail_solvers) > 0: - setattr(self,SOLVER,list(avail_solvers)[0]) + setattr(self, SOLVER, list(avail_solvers)[0]) else: raise Exception('No solver available. Please ensure that one of the following '\ 'solvers is avaialable in your Python environment: CPLEX, Gurobi, SCIP, GLPK') - elif getattr(self,SOLVER) not in avail_solvers: - raise Exception("Selected solver '" + getattr(self,SOLVER) + "' is not installed / set up correctly.") + elif getattr(self, SOLVER) not in avail_solvers: + raise Exception("Selected solver '" + getattr(self, SOLVER) + "' is not installed / set up correctly.") # Copy parameters to object if self.A_ineq is not None: numvars = self.A_ineq.shape[1] diff --git a/straindesign/strainDesignProblem.py b/straindesign/strainDesignProblem.py index 85be354..57aae37 100644 --- a/straindesign/strainDesignProblem.py +++ b/straindesign/strainDesignProblem.py @@ -499,13 +499,14 @@ def link_z(self): logging.info(' Bounding MILP.') if processes > 1 and num_Ms > 1000: - with SDPool(processes, initializer=worker_init, - initargs=(M_A, M_A_ineq, M_b_ineq, M_A_eq, M_b_eq, M_lb, M_ub, getattr(self,SOLVER), getattr(self,SEED))) as pool: + with SDPool(processes, + initializer=worker_init, + initargs=(M_A, M_A_ineq, M_b_ineq, M_A_eq, M_b_eq, M_lb, M_ub, getattr(self, SOLVER), getattr(self, SEED))) as pool: chunk_size = num_Ms // processes for i, value in pool.imap_unordered(worker_compute, range(num_Ms), chunksize=chunk_size): max_Ax[i] = value else: - worker_init(M_A, M_A_ineq, M_b_ineq, M_A_eq, M_b_eq, M_lb, M_ub, getattr(self,SOLVER), getattr(self,SEED)) + worker_init(M_A, M_A_ineq, M_b_ineq, M_A_eq, M_b_eq, M_lb, M_ub, getattr(self, SOLVER), getattr(self, SEED)) for i in range(num_Ms): _, max_Ax[i] = worker_compute(i) diff --git a/tests/test_01_load_models_and_solvers.py b/tests/test_01_load_models_and_solvers.py index b1e152a..d811185 100644 --- a/tests/test_01_load_models_and_solvers.py +++ b/tests/test_01_load_models_and_solvers.py @@ -24,14 +24,17 @@ def model_small_example(): """Load example model with two substrates.""" return read_sbml_model(dirname(abspath(__file__)) + "/model_small_example.xml") + @pytest.fixture def model_core(): """Load example core model. Large enough to test strain design with multiprocessing""" return read_sbml_model(dirname(abspath(__file__)) + "/iMLcore.xml") + def test_import_sd(): import straindesign + def test_solver_availability(curr_solver): """Test solver availability.""" assert (curr_solver in sd.avail_solvers) diff --git a/tests/test_06_multiprocessing.py b/tests/test_06_multiprocessing.py index 601b0c1..037755a 100644 --- a/tests/test_06_multiprocessing.py +++ b/tests/test_06_multiprocessing.py @@ -3,22 +3,15 @@ import straindesign as sd import logging + @pytest.mark.timeout(600) -def test_mcs_larger_model(curr_solver,model_core): +def test_mcs_larger_model(curr_solver, model_core): logging.basicConfig(level=logging.INFO) modules = [sd.SDModule(model_core, SUPPRESS, constraints=["EX_etoh_e <= 0.5"])] modules += [sd.SDModule(model_core, SUPPRESS, constraints=["EX_etoh_e <= 0.5"])] modules += [sd.SDModule(model_core, SUPPRESS, constraints=["EX_etoh_e <= 0.5"])] # modules += [sd.SDModule(model_core, SUPPRESS, constraints=["EX_etoh_e <= 0.5"])] modules += [sd.SDModule(model_core, PROTECT, constraints=["BIOMASS_Ec_iML1515_core_75p37M >= 0.1"])] - sd_setup = { - MODULES: modules, - MAX_COST: 4, - MAX_SOLUTIONS: 0, - SOLUTION_APPROACH: ANY, - SOLVER: curr_solver, - 'compress': False - } + sd_setup = {MODULES: modules, MAX_COST: 4, MAX_SOLUTIONS: 0, SOLUTION_APPROACH: ANY, SOLVER: curr_solver, 'compress': False} solution = sd.compute_strain_designs(model_core, sd_setup=sd_setup) assert (len(solution.get_reaction_sd()) == 0) - \ No newline at end of file