From c58be86c643edd6e2b48cecef772a7b76d2eec5c Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 15:18:21 +0000 Subject: [PATCH 1/6] 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 e4e29382e652e74f7499756df3fc3c7577e5ba1d Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 16:40:58 +0000 Subject: [PATCH 2/6] 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 81dd6121ae38bdad0f2063cc77f7ac533d5e00da Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:12:53 +0000 Subject: [PATCH 3/6] 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 3b0caa151135996add5bea9a20a786614ac8859b Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:13:34 +0000 Subject: [PATCH 4/6] 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 9b9b97df86c7996e0158e69048a4d55924b0058f Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:14:34 +0000 Subject: [PATCH 5/6] 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 0d8582459d1fa42c6d0e6e5a4ec58f97a8e3c4d8 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:38:04 +0000 Subject: [PATCH 6/6] 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: