Skip to content

Commit

Permalink
Merge pull request prody#1959 from jamesmkrieger/rtbtools_upgrade_fix
Browse files Browse the repository at this point in the history
Fix rtbtools to permit numpy upgrade
  • Loading branch information
jamesmkrieger authored Sep 30, 2024
2 parents 7bcf0e3 + 3f4f6e3 commit f1c589a
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions docs/apps/docapps.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/usr/bin/python

import os
import imp
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:
Expand Down
18 changes: 12 additions & 6 deletions prody/apps/evol_apps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This module defines some sequence evolution applications."""

import imp
import importlib
import sys

Expand All @@ -9,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('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']
Expand Down Expand Up @@ -81,8 +88,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)


Expand Down
19 changes: 12 additions & 7 deletions prody/apps/prody_apps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This module defines structure and dynamics analysis applications."""

import imp
import importlib
import sys

Expand All @@ -9,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',
Expand Down Expand Up @@ -44,11 +51,9 @@

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():

if len(sys.argv) == 1:
Expand Down
16 changes: 8 additions & 8 deletions prody/dynamics/rtbtools.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -478,19 +478,19 @@ 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];
}
}
}

/* 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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions prody/tests/dynamics/test_lda.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import numpy as np
from numpy import arange
from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec
from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
6 changes: 2 additions & 4 deletions prody/tests/proteins/test_fixer.py
Original file line number Diff line number Diff line change
@@ -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 ImportError:
from numpy.testing import dec
from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
6 changes: 2 additions & 4 deletions prody/tests/proteins/test_waterbridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import numpy as np
from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec
from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
2 changes: 1 addition & 1 deletion prody/utilities/doctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 24 additions & 4 deletions prody/utilities/misctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -788,17 +788,37 @@ 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
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


def impLoadModule(name, cmd, path):
"""Returns an an imported module equivalent to imp."""

if not name.endswith('.'):
name += '.'

try:
import 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 mod
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "numpy>=1.10,<1.24", "pyparsing<=3.1.1", "scipy"]
requires = ["setuptools", "wheel", "numpy>=1.10,<2", "pyparsing<=3.1.1", "scipy"]
11 changes: 4 additions & 7 deletions scripts/evol
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/usr/bin/env python

import imp
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()
11 changes: 4 additions & 7 deletions scripts/prody
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/usr/bin/env python

import imp
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()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,<1.24', 'biopython', 'pyparsing<=3.1.1', 'scipy', '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')
Expand Down

0 comments on commit f1c589a

Please sign in to comment.