Skip to content

Commit

Permalink
Merge branch 'main' of github.com:prody/ProDy into insty_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Sep 30, 2024
2 parents cbe722f + f1c589a commit 9148b47
Show file tree
Hide file tree
Showing 19 changed files with 418 additions and 108 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
5 changes: 4 additions & 1 deletion prody/atomic/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
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
28 changes: 24 additions & 4 deletions prody/proteins/fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def addMissingAtoms(infile, method='openbabel', pH=7.0, outfile=None, **kwargs):
or PDBFixer with OpenMM.
There are also options whether to *model_residues* (default False), *remove_heterogens*
(default False), *keep_waters* (default True), *overwrite* (default False).
(default False), *keep_waters* (default True), *overwrite* (default False), *keep_ids* (default True).
:arg infile: PDB file name
:type infile: str
Expand All @@ -41,9 +41,17 @@ def addMissingAtoms(infile, method='openbabel', pH=7.0, outfile=None, **kwargs):
default is 'openbabel'
:type method: str
:arg pH: pH value applyed only for PDBfixer.
:arg pH: pH value applied only for PDBfixer.
:type pH: int, float
:arg model_residues: add all missing atoms from residues, applied only for PDBfixer.
default is False
:type model_residues: bool
:arg keep_ids: keep the original residue number, applied only for PDBfixer.
default is True
:type keep_ids: bool
Instalation of Openbabel:
conda install -c conda-forge openbabel
Expand All @@ -58,6 +66,7 @@ def addMissingAtoms(infile, method='openbabel', pH=7.0, outfile=None, **kwargs):
remove_heterogens = kwargs.get("remove_heterogens", False)
keep_water = kwargs.get("keep_water", True)
overwrite = kwargs.get("overwrite", False)
keep_ids = kwargs.get("keep_ids", True)

import os

Expand All @@ -70,6 +79,9 @@ def addMissingAtoms(infile, method='openbabel', pH=7.0, outfile=None, **kwargs):
if not isinstance(keep_water, bool):
raise TypeError('keep_water should be True or False')

if not isinstance(keep_ids, bool):
raise TypeError('keep_ids should be True or False')

if not isinstance(overwrite, bool):
raise TypeError('overwrite should be True or False')

Expand Down Expand Up @@ -136,7 +148,7 @@ def addMissingAtoms(infile, method='openbabel', pH=7.0, outfile=None, **kwargs):
fixer.findMissingAtoms()
fixer.addMissingAtoms()
fixer.addMissingHydrogens(pH)
PDBFile.writeFile(fixer.topology, fixer.positions, open(outfile, 'w'))
PDBFile.writeFile(fixer.topology, fixer.positions, open(outfile, 'w'), keepIds=keep_ids)
LOGGER.info("Hydrogens were added to the structure. New structure is saved as {0}.".format(outfile))

except ImportError:
Expand Down Expand Up @@ -165,8 +177,16 @@ def fixStructuresMissingAtoms(infiles, method='openbabel', pH=7.0, outfiles=None
'pdbfixer': PDBFixer and OpenMM
default is 'openbabel'
:type method: str
:arg model_residues: add all missing atoms from residues, applied only for PDBfixer.
default is False
:type model_residues: bool
:arg keep_ids: keep the original residue number, applied only for PDBfixer.
default is True
:type keep_ids: bool
:arg pH: pH value applyed only for PDBfixer.
:arg pH: pH value applied only for PDBfixer.
:type pH: int, float
Instalation of Openbabel:
Expand Down
Loading

0 comments on commit 9148b47

Please sign in to comment.