From c6e88c3328f4e1737ae2e5acfcc1f70a3a5988f8 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 31 Oct 2024 10:15:17 +0000 Subject: [PATCH 1/8] permit atomic input to deformAtoms --- prody/dynamics/sampling.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prody/dynamics/sampling.py b/prody/dynamics/sampling.py index 272b230bd..0af1f0404 100644 --- a/prody/dynamics/sampling.py +++ b/prody/dynamics/sampling.py @@ -260,8 +260,8 @@ def deformAtoms(atoms, mode, rmsd=None, replace=False, scale=None): generate a coordinate set with given RMSD distance to the active coordinate set.""" - if not isinstance(atoms, AtomGroup): - raise TypeError('atoms must be an AtomGroup, not {0}' + if not isinstance(atoms, Atomic): + raise TypeError('atoms must be an Atomic object, not {0}' .format(type(atoms))) if not isinstance(mode, VectorBase): raise TypeError('mode must be a Mode or Vector instance, ' From 2ec6f886b68e927c8454636af686587ad7e71f9a Mon Sep 17 00:00:00 2001 From: James Krieger Date: Mon, 4 Nov 2024 18:24:29 +0000 Subject: [PATCH 2/8] simplify deformAtoms --- prody/dynamics/sampling.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/prody/dynamics/sampling.py b/prody/dynamics/sampling.py index 0af1f0404..3c06c6f6d 100644 --- a/prody/dynamics/sampling.py +++ b/prody/dynamics/sampling.py @@ -280,15 +280,12 @@ def deformAtoms(atoms, mode, rmsd=None, replace=False, scale=None): rmsd = float(rmsd) # rmsd = ( ((scalar * array)**2).sum() / n_atoms )**0.5 scalar = (atoms.numAtoms() * rmsd**2 / (array**2).sum())**0.5 + scale *= scalar LOGGER.info('Mode is scaled by {0}.'.format(scalar)) - if replace is False: - atoms.addCoordset(atoms.getCoords() + array * scalar * scale) - else: - atoms.setCoords(atoms.getCoords() + array * scalar * scale) + + if replace is False: + atoms.addCoordset(atoms.getCoords() + array * scale) else: - if replace is False: - atoms.addCoordset(atoms.getCoords() + array * scale) - else: - atoms.setCoords(atoms.getCoords() + array * scale) + atoms.setCoords(atoms.getCoords() + array * scale) From e77228082c1807af5f6879bdede738b5b7266ad4 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 15:18:21 +0000 Subject: [PATCH 3/8] remove test ftp --- prody/tests/proteins/test_wwpdb.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/prody/tests/proteins/test_wwpdb.py b/prody/tests/proteins/test_wwpdb.py index a6657f635..d3962cd16 100644 --- a/prody/tests/proteins/test_wwpdb.py +++ b/prody/tests/proteins/test_wwpdb.py @@ -15,15 +15,15 @@ LOGGER.verbosity = 'none' -class TestFTP(unittest.TestCase): +class TestHTTP(unittest.TestCase): def setUp(self): self.pdb = ['1ubi', '1aar', 'arg', 1234] self.fns = [] self.len = [683, 1218, None, None] - self.fetch = fetchPDBviaFTP - self.protocol = 'FTP' + self.fetch = fetchPDBviaHTTP + self.protocol = 'HTTP' @dec.slow @@ -69,12 +69,3 @@ def tearDown(self): pass except: pass - -class TestHTTP(TestFTP): - - def setUp(self): - - TestFTP.setUp(self) - self.fetch = fetchPDBviaHTTP - self.protocol = 'HTTP' - From a3b9298de9d1c1dfc55f60332095ccef9b618f01 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 16:40:58 +0000 Subject: [PATCH 4/8] fix fetch cif from http --- prody/proteins/wwpdb.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/prody/proteins/wwpdb.py b/prody/proteins/wwpdb.py index 54fa73d0a..d2c883f52 100644 --- a/prody/proteins/wwpdb.py +++ b/prody/proteins/wwpdb.py @@ -254,7 +254,22 @@ def fetchPDBviaHTTP(*pdb, **kwargs): output_folder = kwargs.pop('folder', None) compressed = bool(kwargs.pop('compressed', True)) - extension = '.pdb' + format = kwargs.get('format', 'pdb') + noatom = bool(kwargs.pop('noatom', False)) + if format == 'pdb': + extension = '.pdb' + elif format == 'xml': + if noatom: + extension = '-noatom.xml' + else: + extension = '.xml' + elif format == 'cif': + extension = '.cif' + elif format == 'emd' or format == 'map': + extension = '.map' + else: + raise ValueError(repr(format) + ' is not valid format') + local_folder = pathPDBFolder() if local_folder: local_folder, is_divided = local_folder @@ -294,7 +309,10 @@ def fetchPDBviaHTTP(*pdb, **kwargs): filenames.append(None) continue try: - handle = openURL(getURL(pdb)) + url = getURL(pdb) + if kwargs['format'] != 'pdb': + url = url.replace('.pdb', extension) + handle = openURL(url) except Exception as err: LOGGER.warn('{0} download failed ({1}).'.format(pdb, str(err))) failure += 1 From 89d3a5fca65cd19ac0377372cc7e448c26aa56e0 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:12:53 +0000 Subject: [PATCH 5/8] fix cifheader author for consortium --- prody/proteins/cifheader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prody/proteins/cifheader.py b/prody/proteins/cifheader.py index 9a31112da..dd4475a0b 100644 --- a/prody/proteins/cifheader.py +++ b/prody/proteins/cifheader.py @@ -745,8 +745,11 @@ def _getReference(lines): except: continue if what == 'AUTH': - surname, initials = value.split(',') - author = initials+surname + try: + surname, initials = value.split(',') + author = initials+surname + except ValueError: + author = value authors.append(author.strip().upper()) ref['authors'] = authors From f21f2f2e44e465b47da513394829ecdb22ac6f36 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:13:34 +0000 Subject: [PATCH 6/8] no checkIdentifiers for format emd as can be longer --- prody/proteins/localpdb.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prody/proteins/localpdb.py b/prody/proteins/localpdb.py index a28cd74b5..a451f9938 100644 --- a/prody/proteins/localpdb.py +++ b/prody/proteins/localpdb.py @@ -212,12 +212,15 @@ def fetchPDB(*pdb, **kwargs): if len(pdb) == 1 and isinstance(pdb[0], list): pdb = pdb[0] - identifiers = checkIdentifiers(*pdb) - folder = kwargs.get('folder', '.') compressed = kwargs.get('compressed') format_ = kwargs.get('format', 'pdb') + if format_ != 'emd': + identifiers = checkIdentifiers(*pdb) + else: + identifiers = pdb + # check *folder* specified by the user, usually pwd ('.') filedict = findPDBFiles(folder, compressed=compressed, format=format_) From 6a07c432edc3e40b2257d49c08013be59146246f Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:14:34 +0000 Subject: [PATCH 7/8] more fixes to _parsePDB for cif --- prody/proteins/pdbfile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prody/proteins/pdbfile.py b/prody/proteins/pdbfile.py index a8127e72f..624ed11da 100644 --- a/prody/proteins/pdbfile.py +++ b/prody/proteins/pdbfile.py @@ -214,13 +214,15 @@ def _parsePDB(pdb, **kwargs): if filename is None: try: LOGGER.warn("Trying to parse mmCIF file instead") + chain = kwargs.pop('chain', chain) return parseMMCIF(pdb+chain, **kwargs) - except: + except OSError: try: LOGGER.warn("Trying to parse EMD file instead") + chain = kwargs.pop('chain', chain) return parseEMD(pdb+chain, **kwargs) except: - raise IOError('PDB file for {0} could not be downloaded.' + raise IOError('PDB file for {0} could not be parsed.' .format(pdb)) pdb = filename if title is None: From 6f1dc433ec7bad67a4190ed6bbcfe54284799091 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:38:04 +0000 Subject: [PATCH 8/8] fix the url fix --- prody/proteins/wwpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prody/proteins/wwpdb.py b/prody/proteins/wwpdb.py index d2c883f52..ef520c8dc 100644 --- a/prody/proteins/wwpdb.py +++ b/prody/proteins/wwpdb.py @@ -310,7 +310,7 @@ def fetchPDBviaHTTP(*pdb, **kwargs): continue try: url = getURL(pdb) - if kwargs['format'] != 'pdb': + if kwargs.get('format', 'pdb') != 'pdb': url = url.replace('.pdb', extension) handle = openURL(url) except Exception as err: