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 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_) 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: diff --git a/prody/proteins/wwpdb.py b/prody/proteins/wwpdb.py index 54fa73d0a..ef520c8dc 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.get('format', 'pdb') != '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 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' -