From 6aac9ba6316b30678d7ccb299b172e3d0ed086cb Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 3 Feb 2021 18:05:54 +0000 Subject: [PATCH 1/2] extra pfam error for accession --- prody/database/pfam.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prody/database/pfam.py b/prody/database/pfam.py index 5b178aaee..3f188dad1 100644 --- a/prody/database/pfam.py +++ b/prody/database/pfam.py @@ -230,6 +230,9 @@ def searchPfam(query, **kwargs): return searchPfam(ag_seq) except: raise ValueError('No valid UniProt accession or ID for: ' + seq) + + if xml.find(b'No valid UniProt accession or ID') > 0: + raise ValueError('No valid UniProt accession or ID for: ' + seq) try: root = ET.XML(xml) From 3c4b11c133dc872676f18d6eb88bd3e9fa842e4d Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 3 Feb 2021 18:31:49 +0000 Subject: [PATCH 2/2] added use of uniprot redirect --- prody/database/pfam.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/prody/database/pfam.py b/prody/database/pfam.py index 3f188dad1..77ad08d2c 100644 --- a/prody/database/pfam.py +++ b/prody/database/pfam.py @@ -3,6 +3,7 @@ __author__ = 'Anindita Dutta, Ahmet Bakan, Cihan Kaya' +from prody.dynamics.analysis import calcFracDimension import re from numbers import Integral @@ -222,6 +223,7 @@ def searchPfam(query, **kwargs): elif xml.find(b'No valid UniProt accession or ID') > 0: try: url = prefix + 'protein/' + accession + '?output=xml' + LOGGER.debug('Retrieving Pfam search results: ' + url) xml = openURL(url, timeout=timeout).read() except: try: @@ -232,7 +234,17 @@ def searchPfam(query, **kwargs): raise ValueError('No valid UniProt accession or ID for: ' + seq) if xml.find(b'No valid UniProt accession or ID') > 0: - raise ValueError('No valid UniProt accession or ID for: ' + seq) + try: + url = 'https://uniprot.org/uniprot/' + accession + '.xml' + xml = openURL(url, timeout=timeout).read() + root = ET.XML(xml) + accession = root[0][0].text + + url = prefix + 'protein/' + accession + '?output=xml' + LOGGER.debug('Retrieving Pfam search results: ' + url) + xml = openURL(url, timeout=timeout).read() + except: + raise ValueError('No valid UniProt accession or ID for: ' + seq) try: root = ET.XML(xml)