From a3b9298de9d1c1dfc55f60332095ccef9b618f01 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 16:40:58 +0000 Subject: [PATCH] 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