From 5b4403bfda424ff2dc342e229095af2dc24ea8f3 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 12:11:43 +0200 Subject: [PATCH 01/19] eigh evd when no turbo --- prody/utilities/eigtools.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/prody/utilities/eigtools.py b/prody/utilities/eigtools.py index ef8b141af..a40027eca 100644 --- a/prody/utilities/eigtools.py +++ b/prody/utilities/eigtools.py @@ -40,7 +40,13 @@ def _eigh(M, eigvals=None, turbo=True): if eigvals: turbo = False if not issparse(M): - values, vectors = linalg.eigh(M, turbo=turbo, eigvals=eigvals) + if hasattr('linalg.eigh', 'turbo'): + values, vectors = linalg.eigh(M, turbo=turbo, eigvals=eigvals) + else: + if turbo: + values, vectors = linalg.eigh(M, driver='evd', eigvals=eigvals) + else: + values, vectors = linalg.eigh(M, eigvals=eigvals) else: try: from scipy.sparse import linalg as scipy_sparse_la From 4ae9d107276b69399ca6e251c7ceddb94f44f632 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 12:47:29 +0200 Subject: [PATCH 02/19] try except turbo --- prody/utilities/eigtools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prody/utilities/eigtools.py b/prody/utilities/eigtools.py index a40027eca..875439ebb 100644 --- a/prody/utilities/eigtools.py +++ b/prody/utilities/eigtools.py @@ -40,9 +40,9 @@ def _eigh(M, eigvals=None, turbo=True): if eigvals: turbo = False if not issparse(M): - if hasattr('linalg.eigh', 'turbo'): + try: values, vectors = linalg.eigh(M, turbo=turbo, eigvals=eigvals) - else: + except AttributeError: if turbo: values, vectors = linalg.eigh(M, driver='evd', eigvals=eigvals) else: From 49a37142eff5538ebdc843ef6975eca5850d6f29 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 13:00:58 +0200 Subject: [PATCH 03/19] replace eigvals --- prody/utilities/eigtools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prody/utilities/eigtools.py b/prody/utilities/eigtools.py index 875439ebb..543e71c01 100644 --- a/prody/utilities/eigtools.py +++ b/prody/utilities/eigtools.py @@ -42,11 +42,11 @@ def _eigh(M, eigvals=None, turbo=True): if not issparse(M): try: values, vectors = linalg.eigh(M, turbo=turbo, eigvals=eigvals) - except AttributeError: + except TypeError: if turbo: - values, vectors = linalg.eigh(M, driver='evd', eigvals=eigvals) + values, vectors = linalg.eigh(M, driver='evd', subset_by_index=eigvals) else: - values, vectors = linalg.eigh(M, eigvals=eigvals) + values, vectors = linalg.eigh(M, subset_by_index=eigvals) else: try: from scipy.sparse import linalg as scipy_sparse_la From 6b3f753947a9e2fb830963663ae2f1e3a510af0d Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 13:04:05 +0200 Subject: [PATCH 04/19] unlimit scipy --- pyproject.toml | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 40aa5e374..146e85d9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,2 @@ [build-system] -requires = ["setuptools", "wheel", "numpy>=1.10,<1.25", "pyparsing<=3.1.1", "scipy<=1.13.1"] +requires = ["setuptools", "wheel", "numpy>=1.10,<1.24", "pyparsing<=3.1.1", "scipy"] diff --git a/setup.py b/setup.py index f85413b04..8afb6a805 100644 --- a/setup.py +++ b/setup.py @@ -14,9 +14,9 @@ sys.exit() if sys.version_info[:2] == (2, 7) or sys.version_info[:2] <= (3, 5): - INSTALL_REQUIRES=['numpy>=1.10,<1.25', 'biopython<=1.76', 'pyparsing', 'scipy'] + INSTALL_REQUIRES=['numpy>=1.10', 'biopython<=1.76', 'pyparsing', 'scipy'] else: - INSTALL_REQUIRES=['numpy>=1.10,<1.24', 'biopython', 'pyparsing<=3.1.1', 'scipy<=1.13.1', 'setuptools'] + INSTALL_REQUIRES=['numpy>=1.10,<1.24', 'biopython', 'pyparsing<=3.1.1', 'scipy', 'setuptools'] if sys.version_info[0] == 3 and sys.version_info[1] < 6: sys.stderr.write('Python 3.5 and older is not supported\n') From c8264fb699acc3d6ec93db56f28d9e7f890c1619 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 14:24:28 +0200 Subject: [PATCH 05/19] fix rtbtools I to Ii --- prody/dynamics/rtbtools.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/prody/dynamics/rtbtools.c b/prody/dynamics/rtbtools.c index ff4d2c5c7..1bbf3a8bf 100644 --- a/prody/dynamics/rtbtools.c +++ b/prody/dynamics/rtbtools.c @@ -419,7 +419,7 @@ void cross(double x[], double y[], double z[]) int dblock_projections2(dSparse_Matrix *PP, PDB_File *PDB, int nres, int nblx, int bmx) { - double **X, **I, **IC, *CM, *W, **A, **ISQT; + double **X, **Ii, **IC, *CM, *W, **A, **ISQT; double x, tr, dd, df; int *IDX, nbp, b, i, j, k, ii, jj, aa, bb, elm; @@ -429,7 +429,7 @@ int dblock_projections2(dSparse_Matrix *PP, PDB_File *PDB, X = dmatrix(1, bmx, 1, 3); IDX = ivector(1, bmx); CM = dvector(1, 3); - I = dmatrix(1, 3, 1, 3); + Ii = dmatrix(1, 3, 1, 3); IC = dmatrix(1, 3, 1, 3); W = dvector(1, 3); A = dmatrix(1, 3, 1, 3); @@ -442,7 +442,7 @@ int dblock_projections2(dSparse_Matrix *PP, PDB_File *PDB, for(j=1; j<=3; j++) { CM[j] = 0.0; - for(i=1; i<=3; i++) I[i][j] = 0.0; + for(i=1; i<=3; i++) Ii[i][j] = 0.0; for(i=1; i<=bmx; i++) X[i][j] = 0.0; } @@ -478,11 +478,11 @@ int dblock_projections2(dSparse_Matrix *PP, PDB_File *PDB, } for(i=1; i<=3; i++) { - I[i][i] += (dd - X[k][i] * X[k][i]); + Ii[i][i] += (dd - X[k][i] * X[k][i]); for(j=i+1; j<=3; j++) { - I[i][j] -= X[k][i]*X[k][j]; - I[j][i] = I[i][j]; + Ii[i][j] -= X[k][i]*X[k][j]; + Ii[j][i] = Ii[i][j]; } } } @@ -490,7 +490,7 @@ int dblock_projections2(dSparse_Matrix *PP, PDB_File *PDB, /* DIAGONALIZE INERTIA TENSOR */ for (i=1; i<=3; i++) for (j=1; j<=3; j++) - IC[i][j]=I[i][j]; + IC[i][j]=Ii[i][j]; dsvdcmp(IC, 3, 3, W, A); deigsrt(W, A, 3); righthand2(W, A, 3); @@ -545,7 +545,7 @@ int dblock_projections2(dSparse_Matrix *PP, PDB_File *PDB, free_dmatrix(X, 1, bmx, 1, 3); free_ivector(IDX, 1, bmx); free_dvector(CM, 1, 3); - free_dmatrix(I, 1, 3, 1, 3); + free_dmatrix(Ii, 1, 3, 1, 3); free_dmatrix(IC, 1, 3, 1, 3); free_dvector(W, 1, 3); free_dmatrix(A, 1, 3, 1, 3); From 4875b4e2fff8a285910c990cd4681076eddcfbd6 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 14:24:51 +0200 Subject: [PATCH 06/19] unlimit numpy --- pyproject.toml | 2 +- setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 40aa5e374..8f38e8491 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,2 @@ [build-system] -requires = ["setuptools", "wheel", "numpy>=1.10,<1.25", "pyparsing<=3.1.1", "scipy<=1.13.1"] +requires = ["setuptools", "wheel", "numpy>=1.10", "pyparsing<=3.1.1", "scipy<=1.13.1"] diff --git a/setup.py b/setup.py index f85413b04..f78ee0b21 100644 --- a/setup.py +++ b/setup.py @@ -14,9 +14,9 @@ sys.exit() if sys.version_info[:2] == (2, 7) or sys.version_info[:2] <= (3, 5): - INSTALL_REQUIRES=['numpy>=1.10,<1.25', 'biopython<=1.76', 'pyparsing', 'scipy'] + INSTALL_REQUIRES=['numpy>=1.10', 'biopython<=1.76', 'pyparsing', 'scipy'] else: - INSTALL_REQUIRES=['numpy>=1.10,<1.24', 'biopython', 'pyparsing<=3.1.1', 'scipy<=1.13.1', 'setuptools'] + INSTALL_REQUIRES=['numpy>=1.10', 'biopython', 'pyparsing<=3.1.1', 'scipy<=1.13.1', 'setuptools'] if sys.version_info[0] == 3 and sys.version_info[1] < 6: sys.stderr.write('Python 3.5 and older is not supported\n') From 73b52c5d43f8cec0d440897d855d6420bbdd9e37 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 14:25:22 +0200 Subject: [PATCH 07/19] add python 3.12 to actions --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed8d5f5c3..c0ca4c021 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["2.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["2.7", "3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 From da775e1df3cdf2ef18b18b842472b3f7aef18ba6 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 14:36:08 +0200 Subject: [PATCH 08/19] ModuleNotFoundError for numpy testing decorators --- prody/tests/dynamics/test_lda.py | 2 +- prody/tests/proteins/test_fixer.py | 2 +- prody/tests/proteins/test_waterbridges.py | 2 +- prody/utilities/misctools.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/prody/tests/dynamics/test_lda.py b/prody/tests/dynamics/test_lda.py index dc3e96f76..3c25e2c82 100644 --- a/prody/tests/dynamics/test_lda.py +++ b/prody/tests/dynamics/test_lda.py @@ -5,7 +5,7 @@ from numpy.testing import * try: import numpy.testing.decorators as dec -except ImportError: +except ModuleNotFoundError: from numpy.testing import dec from prody import * diff --git a/prody/tests/proteins/test_fixer.py b/prody/tests/proteins/test_fixer.py index 17c1aa05d..1d8002e8d 100644 --- a/prody/tests/proteins/test_fixer.py +++ b/prody/tests/proteins/test_fixer.py @@ -3,7 +3,7 @@ from numpy.testing import * try: import numpy.testing.decorators as dec -except ImportError: +except ModuleNotFoundError: from numpy.testing import dec from prody import * diff --git a/prody/tests/proteins/test_waterbridges.py b/prody/tests/proteins/test_waterbridges.py index 9418d8363..6b448ff7f 100644 --- a/prody/tests/proteins/test_waterbridges.py +++ b/prody/tests/proteins/test_waterbridges.py @@ -4,7 +4,7 @@ from numpy.testing import * try: import numpy.testing.decorators as dec -except ImportError: +except ModuleNotFoundError: from numpy.testing import dec from prody import * diff --git a/prody/utilities/misctools.py b/prody/utilities/misctools.py index 47a399717..df3ee6654 100644 --- a/prody/utilities/misctools.py +++ b/prody/utilities/misctools.py @@ -792,13 +792,13 @@ def importDec(): try: import numpy.testing.decorators as dec - except ImportError: + except ModuleNotFoundError: try: from numpy.testing import dec except ImportError: try: import numpy.testing._private.decorators as dec - except ImportError: + except ModuleNotFoundError: from pytest import mark as dec return dec From e1bf7225dfa820e864e9d814d84373636dd40e8f Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 14:51:51 +0200 Subject: [PATCH 09/19] add missing importDec --- prody/tests/dynamics/test_lda.py | 6 ++---- prody/tests/proteins/test_fixer.py | 6 ++---- prody/tests/proteins/test_waterbridges.py | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/prody/tests/dynamics/test_lda.py b/prody/tests/dynamics/test_lda.py index 3c25e2c82..839fba375 100644 --- a/prody/tests/dynamics/test_lda.py +++ b/prody/tests/dynamics/test_lda.py @@ -3,10 +3,8 @@ import numpy as np from numpy import arange from numpy.testing import * -try: - import numpy.testing.decorators as dec -except ModuleNotFoundError: - from numpy.testing import dec +from prody.utilities import importDec +dec = importDec() from prody import * from prody import LOGGER diff --git a/prody/tests/proteins/test_fixer.py b/prody/tests/proteins/test_fixer.py index 1d8002e8d..a01567dc7 100644 --- a/prody/tests/proteins/test_fixer.py +++ b/prody/tests/proteins/test_fixer.py @@ -1,10 +1,8 @@ """This module contains unit tests for :mod:`~prody.proteins`.""" from numpy.testing import * -try: - import numpy.testing.decorators as dec -except ModuleNotFoundError: - from numpy.testing import dec +from prody.utilities import importDec +dec = importDec() from prody import * from prody import LOGGER diff --git a/prody/tests/proteins/test_waterbridges.py b/prody/tests/proteins/test_waterbridges.py index 6b448ff7f..a6b7c1fca 100644 --- a/prody/tests/proteins/test_waterbridges.py +++ b/prody/tests/proteins/test_waterbridges.py @@ -2,10 +2,8 @@ import numpy as np from numpy.testing import * -try: - import numpy.testing.decorators as dec -except ModuleNotFoundError: - from numpy.testing import dec +from prody.utilities import importDec +dec = importDec() from prody import * from prody import LOGGER From 49361fbacb9c0cd866a8f5e99ea974da113afa33 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 15:12:22 +0200 Subject: [PATCH 10/19] add importImp for python 3.12 --- docs/apps/docapps.py | 5 ++++- prody/apps/evol_apps/__init__.py | 3 ++- prody/apps/prody_apps/__init__.py | 3 ++- prody/utilities/misctools.py | 11 ++++++++++- scripts/evol | 3 ++- scripts/prody | 3 ++- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/apps/docapps.py b/docs/apps/docapps.py index 07401800f..a623a3e28 100755 --- a/docs/apps/docapps.py +++ b/docs/apps/docapps.py @@ -1,7 +1,10 @@ #!/usr/bin/python import os -import imp +try: + import imp +except ModuleNotFoundError: + from importlib import import_module as imp import importlib from subprocess import Popen, PIPE diff --git a/prody/apps/evol_apps/__init__.py b/prody/apps/evol_apps/__init__.py index 9bc350aae..3b58d538d 100644 --- a/prody/apps/evol_apps/__init__.py +++ b/prody/apps/evol_apps/__init__.py @@ -1,6 +1,7 @@ """This module defines some sequence evolution applications.""" -import imp +from prody.utilities.misctools import importImp +imp = importImp() import importlib import sys diff --git a/prody/apps/prody_apps/__init__.py b/prody/apps/prody_apps/__init__.py index a31be6cff..6cecac1b6 100644 --- a/prody/apps/prody_apps/__init__.py +++ b/prody/apps/prody_apps/__init__.py @@ -1,6 +1,7 @@ """This module defines structure and dynamics analysis applications.""" -import imp +from prody.utilities.misctools import importImp +imp = importImp() import importlib import sys diff --git a/prody/utilities/misctools.py b/prody/utilities/misctools.py index df3ee6654..f2c080751 100644 --- a/prody/utilities/misctools.py +++ b/prody/utilities/misctools.py @@ -788,7 +788,7 @@ def _mad(x): def importDec(): - """Returns one of :mod:`scipy.linalg` or :mod:`numpy.linalg`.""" + """Returns an imported module equivalent to numpy testing decorators.""" try: import numpy.testing.decorators as dec @@ -802,3 +802,12 @@ def importDec(): from pytest import mark as dec return dec + +def importImp(): + """Returns an an imported module equivalent to imp.""" + try: + import imp + except ModuleNotFoundError: + from importlib import import_module as imp + + return imp diff --git a/scripts/evol b/scripts/evol index 326faafef..cdc7f60c5 100755 --- a/scripts/evol +++ b/scripts/evol @@ -1,6 +1,7 @@ #!/usr/bin/env python -import imp +from prody.utilities.misctools import importImp +imp = importImp() import importlib if sys.version_info[0] == 2: path_prody = imp.find_module('prody')[1] diff --git a/scripts/prody b/scripts/prody index ddd8cc0c9..fca0b3f78 100755 --- a/scripts/prody +++ b/scripts/prody @@ -1,6 +1,7 @@ #!/usr/bin/env python -import imp +from prody.utilities.misctools import importImp +imp = importImp() import importlib if sys.version_info[0] == 2: path_prody = imp.find_module('prody')[1] From b0b2fbfd636c4795f76659352fdf21209b93f97f Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 15:12:46 +0200 Subject: [PATCH 11/19] not numpy 2 --- pyproject.toml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8f38e8491..6301b1948 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,2 @@ [build-system] -requires = ["setuptools", "wheel", "numpy>=1.10", "pyparsing<=3.1.1", "scipy<=1.13.1"] +requires = ["setuptools", "wheel", "numpy>=1.10,<2", "pyparsing<=3.1.1", "scipy<=1.13.1"] diff --git a/setup.py b/setup.py index f78ee0b21..9f2075f19 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ if sys.version_info[:2] == (2, 7) or sys.version_info[:2] <= (3, 5): INSTALL_REQUIRES=['numpy>=1.10', 'biopython<=1.76', 'pyparsing', 'scipy'] else: - INSTALL_REQUIRES=['numpy>=1.10', 'biopython', 'pyparsing<=3.1.1', 'scipy<=1.13.1', 'setuptools'] + INSTALL_REQUIRES=['numpy>=1.10,<2', 'biopython', 'pyparsing<=3.1.1', 'scipy<=1.13.1', 'setuptools'] if sys.version_info[0] == 3 and sys.version_info[1] < 6: sys.stderr.write('Python 3.5 and older is not supported\n') From 4648ee56c6a037b131a1e5e62e54f014e3add737 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 15:13:12 +0200 Subject: [PATCH 12/19] missed importImp --- docs/apps/docapps.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/apps/docapps.py b/docs/apps/docapps.py index a623a3e28..85f570ecc 100755 --- a/docs/apps/docapps.py +++ b/docs/apps/docapps.py @@ -1,10 +1,8 @@ #!/usr/bin/python import os -try: - import imp -except ModuleNotFoundError: - from importlib import import_module as imp +from prody.utilities.misctools import importImp +imp = importImp() import importlib from subprocess import Popen, PIPE From ad74568ec4961a09997b3b6e21dbd9eed4fd4586 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 16:34:14 +0200 Subject: [PATCH 13/19] fix apps for imp --- docs/apps/docapps.py | 14 ++++++++------ prody/apps/evol_apps/__init__.py | 21 ++++++++++++++------- prody/apps/prody_apps/__init__.py | 17 +++++++++++------ prody/utilities/misctools.py | 21 ++++++++++++++++----- 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/docs/apps/docapps.py b/docs/apps/docapps.py index 85f570ecc..1a00ee854 100755 --- a/docs/apps/docapps.py +++ b/docs/apps/docapps.py @@ -1,16 +1,18 @@ #!/usr/bin/python import os -from prody.utilities.misctools import importImp -imp = importImp() +import sys import importlib from subprocess import Popen, PIPE -path = [importlib.util.find_spec("prody").submodule_search_locations[0]] -apps = imp.load_module('prody.apps', - *imp.find_module('apps', path)) +from prody.utilities.misctools import impLoadModule -for cmd, subcmds in [('prody', apps.PRODY_APPS), ('evol', apps.EVOL_APPS)]: +path_apps = importlib.util.find_spec("prody.apps").submodule_search_locations[0] + +prody_apps = impLoadModule('prody.apps.prody_apps', path_apps + '/prody_apps/', '__init__') +evol_apps = impLoadModule('prody.apps.evol_apps', path_apps + '/evol_apps/', '__init__') + +for cmd, subcmds in [('prody', prody_apps.PRODY_APPS), ('evol', evol_apps.EVOL_APPS)]: pipe = Popen([cmd, '-h'], stdout=PIPE, stderr=PIPE) with open(os.path.join(cmd, cmd + '.txt'), 'w') as rst: diff --git a/prody/apps/evol_apps/__init__.py b/prody/apps/evol_apps/__init__.py index 3b58d538d..de87ca57b 100644 --- a/prody/apps/evol_apps/__init__.py +++ b/prody/apps/evol_apps/__init__.py @@ -1,8 +1,8 @@ """This module defines some sequence evolution applications.""" -from prody.utilities.misctools import importImp -imp = importImp() import importlib +import importlib.machinery +import importlib.resources import sys try: @@ -10,14 +10,22 @@ except ImportError: from .. import argparse -from ..apptools import * +from prody.apps.apptools import * +from prody.utilities.misctools import impLoadModule if sys.version_info[0] == 2: + import imp path_prody = imp.find_module('prody')[1] else: path_prody = importlib.util.find_spec("prody").submodule_search_locations[0] -path_apps = imp.find_module('apps', [path_prody])[1] -path_apps = imp.find_module('evol_apps', [path_apps])[1] + +try: + import imp + path_apps = imp.find_module('apps', [path_prody])[1] + path_apps = imp.find_module('evol_apps', [path_apps])[1] +except ModuleNotFoundError: + path_apps = importlib.util.find_spec("prody.apps").submodule_search_locations[0] + path_apps += '/evol_apps/' EVOL_APPS = ['search', 'fetch', 'filter', 'refine', 'merge', 'occupancy', 'conserv', 'coevol', 'rankorder'] @@ -82,8 +90,7 @@ for cmd in EVOL_APPS: cmd = 'evol_' + cmd - mod = imp.load_module('prody.apps.evol_apps.' + cmd, - *imp.find_module(cmd, [path_apps])) + mod = impLoadModule('prody.apps.evol_apps.', cmd, path_apps) mod.APP.addApplication(evol_commands) diff --git a/prody/apps/prody_apps/__init__.py b/prody/apps/prody_apps/__init__.py index 6cecac1b6..0a618919c 100644 --- a/prody/apps/prody_apps/__init__.py +++ b/prody/apps/prody_apps/__init__.py @@ -1,7 +1,5 @@ """This module defines structure and dynamics analysis applications.""" -from prody.utilities.misctools import importImp -imp = importImp() import importlib import sys @@ -10,14 +8,22 @@ except ImportError: from .. import argparse -from ..apptools import * +from prody.apps.apptools import * +from prody.utilities.misctools import impLoadModule if sys.version_info[0] == 2: + import imp path_prody = imp.find_module('prody')[1] else: path_prody = importlib.util.find_spec("prody").submodule_search_locations[0] -path_apps = imp.find_module('apps', [path_prody])[1] -path_apps = imp.find_module('prody_apps', [path_apps])[1] + +try: + import imp + path_apps = imp.find_module('apps', [path_prody])[1] + path_apps = imp.find_module('prody_apps', [path_apps])[1] +except ModuleNotFoundError: + path_apps = importlib.util.find_spec("prody.apps").submodule_search_locations[0] + path_apps += '/prody_apps/' PRODY_APPS = ['anm', 'gnm', 'pca', 'eda', 'align', 'blast', 'biomol', 'catdcd', 'contacts', 'fetch', 'select', 'energy', @@ -49,7 +55,6 @@ *imp.find_module(cmd, [path_apps])) mod.addCommand(prody_commands) - def prody_main(): if len(sys.argv) == 1: diff --git a/prody/utilities/misctools.py b/prody/utilities/misctools.py index f2c080751..5dd0c92fc 100644 --- a/prody/utilities/misctools.py +++ b/prody/utilities/misctools.py @@ -22,7 +22,7 @@ 'getValue', 'indentElement', 'isPDB', 'isURL', 'isListLike', 'isSymmetric', 'makeSymmetric', 'getDistance', 'fastin', 'createStringIO', 'div0', 'wmean', 'bin2dec', 'wrapModes', 'fixArraySize', 'decToHybrid36', 'hybrid36ToDec', 'DTYPE', 'checkIdentifiers', 'split', 'mad', - 'importDec'] + 'importDec', 'impLoadModule'] DTYPE = array(['a']).dtype.char # 'S' for PY2K and 'U' for PY3K CURSORS = [] @@ -803,11 +803,22 @@ def importDec(): return dec -def importImp(): + +def impLoadModule(name, cmd, path): """Returns an an imported module equivalent to imp.""" + + if not name.endswith('.'): + name += '.' + try: import imp - except ModuleNotFoundError: - from importlib import import_module as imp + mod = imp.load_module(name + cmd, + *imp.find_module(cmd, [path])) + except ImportError: + import importlib + loader = importlib.machinery.SourceFileLoader(name + cmd, + path + cmd + '.py') + mod = importlib.util.types.ModuleType(loader.name) + loader.exec_module(mod) - return imp + return mod From 35880353687fd6d68ae3487d56353cdddca50053 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 16:38:44 +0200 Subject: [PATCH 14/19] fix scripts for imp --- scripts/evol | 12 ++++-------- scripts/prody | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/scripts/evol b/scripts/evol index cdc7f60c5..bb3581da3 100755 --- a/scripts/evol +++ b/scripts/evol @@ -1,14 +1,10 @@ #!/usr/bin/env python -from prody.utilities.misctools import importImp -imp = importImp() +from prody.utilities.misctools import impLoadModule import importlib -if sys.version_info[0] == 2: - path_prody = imp.find_module('prody')[1] -else: - path_prody = importlib.util.find_spec("prody").submodule_search_locations[0] -apps = imp.find_module('apps', [path]) -apps = imp.load_module('prody.apps', *apps) + +path_apps = importlib.util.find_spec("prody.apps").submodule_search_locations[0] +apps = impLoadModule('prody.apps.evol_apps', path_apps + '/evol_apps/', '__init__') if __name__ == '__main__': apps.evol_main() \ No newline at end of file diff --git a/scripts/prody b/scripts/prody index fca0b3f78..d05829851 100755 --- a/scripts/prody +++ b/scripts/prody @@ -1,14 +1,10 @@ #!/usr/bin/env python -from prody.utilities.misctools import importImp -imp = importImp() +from prody.utilities.misctools import impLoadModule import importlib -if sys.version_info[0] == 2: - path_prody = imp.find_module('prody')[1] -else: - path_prody = importlib.util.find_spec("prody").submodule_search_locations[0] -apps = imp.find_module('apps', [path]) -apps = imp.load_module('prody.apps', *apps) + +path_apps = importlib.util.find_spec("prody.apps").submodule_search_locations[0] +apps = impLoadModule('prody.apps.prody_apps', path_apps + '/prody_apps/', '__init__') if __name__ == '__main__': apps.prody_main() \ No newline at end of file From dd6566c99609443ddde4e25cb3068f868cdde509 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 16:39:41 +0200 Subject: [PATCH 15/19] remove bad escape --- prody/utilities/doctools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prody/utilities/doctools.py b/prody/utilities/doctools.py index dc9e843bd..98d1dcaed 100644 --- a/prody/utilities/doctools.py +++ b/prody/utilities/doctools.py @@ -45,7 +45,7 @@ def joinTerms(terms, sep=', ', last=None, sort=False): def wrapText(text, width=70, join='\n', **kwargs): - """Returns wrapped lines from :func:`textwrap.wrap` after *join*\ing them. + """Returns wrapped lines from :func:`textwrap.wrap` after *join*ing them. """ try: From 608f45ebc7d5cfa3d86adf7224399aa3bbf36d97 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 16:53:28 +0200 Subject: [PATCH 16/19] remove accidentally added imports --- prody/apps/evol_apps/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/prody/apps/evol_apps/__init__.py b/prody/apps/evol_apps/__init__.py index de87ca57b..e18a688df 100644 --- a/prody/apps/evol_apps/__init__.py +++ b/prody/apps/evol_apps/__init__.py @@ -1,8 +1,6 @@ """This module defines some sequence evolution applications.""" import importlib -import importlib.machinery -import importlib.resources import sys try: From 117e69b812bee8b65e976893142a3aa9ff703da7 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 19 Sep 2024 16:55:14 +0200 Subject: [PATCH 17/19] replace reverted code --- prody/apps/prody_apps/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/prody/apps/prody_apps/__init__.py b/prody/apps/prody_apps/__init__.py index 0a618919c..c1eeee031 100644 --- a/prody/apps/prody_apps/__init__.py +++ b/prody/apps/prody_apps/__init__.py @@ -51,8 +51,7 @@ for cmd in PRODY_APPS: cmd = 'prody_' + cmd - mod = imp.load_module('prody.apps.prody_apps.' + cmd, - *imp.find_module(cmd, [path_apps])) + mod = impLoadModule('prody.apps.prody_apps.', cmd, path_apps) mod.addCommand(prody_commands) def prody_main(): From 0c397d81af43c1b21c2fa5b3fbdfd07d366fac64 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 25 Sep 2024 18:29:21 +0200 Subject: [PATCH 18/19] extract res if only 1 --- prody/atomic/functions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prody/atomic/functions.py b/prody/atomic/functions.py index c2cab1b6c..12964c96a 100644 --- a/prody/atomic/functions.py +++ b/prody/atomic/functions.py @@ -346,7 +346,10 @@ def extendAtoms(nodes, atoms, is3d=False): if res is None: raise ValueError('atoms must contain a residue for all atoms') if isinstance(res, list): - raise ValueError('not enough data to get a single residue for all atoms') + if len(res) == 1: + res = res[0] + else: + raise ValueError('not enough data to get a single residue for all atoms') res_atom_indices = res._getIndices() if not fastin(res, residues): From 0f535583d1900f3df6656911ac40211c4a67813c Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 27 Sep 2024 14:53:39 +0200 Subject: [PATCH 19/19] merge scipy fix --- prody/utilities/eigtools.py | 8 +++++++- pyproject.toml | 2 +- setup.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/prody/utilities/eigtools.py b/prody/utilities/eigtools.py index ef8b141af..543e71c01 100644 --- a/prody/utilities/eigtools.py +++ b/prody/utilities/eigtools.py @@ -40,7 +40,13 @@ def _eigh(M, eigvals=None, turbo=True): if eigvals: turbo = False if not issparse(M): - values, vectors = linalg.eigh(M, turbo=turbo, eigvals=eigvals) + try: + values, vectors = linalg.eigh(M, turbo=turbo, eigvals=eigvals) + except TypeError: + if turbo: + values, vectors = linalg.eigh(M, driver='evd', subset_by_index=eigvals) + else: + values, vectors = linalg.eigh(M, subset_by_index=eigvals) else: try: from scipy.sparse import linalg as scipy_sparse_la diff --git a/pyproject.toml b/pyproject.toml index 6301b1948..3c81264ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,2 @@ [build-system] -requires = ["setuptools", "wheel", "numpy>=1.10,<2", "pyparsing<=3.1.1", "scipy<=1.13.1"] +requires = ["setuptools", "wheel", "numpy>=1.10,<2", "pyparsing<=3.1.1", "scipy"] diff --git a/setup.py b/setup.py index 9f2075f19..784677874 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ if sys.version_info[:2] == (2, 7) or sys.version_info[:2] <= (3, 5): INSTALL_REQUIRES=['numpy>=1.10', 'biopython<=1.76', 'pyparsing', 'scipy'] else: - INSTALL_REQUIRES=['numpy>=1.10,<2', 'biopython', 'pyparsing<=3.1.1', 'scipy<=1.13.1', 'setuptools'] + INSTALL_REQUIRES=['numpy>=1.10,<2', 'biopython', 'pyparsing<=3.1.1', 'scipy', 'setuptools'] if sys.version_info[0] == 3 and sys.version_info[1] < 6: sys.stderr.write('Python 3.5 and older is not supported\n')