Commit 51f84a07 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Fix bug: uniprot handler has problems with position tag

parent f05f4c7f
......@@ -58,8 +58,10 @@ def retrieve(dbxrefs, basic=True, sequence=True, organism=True, annotation=True,
if features:
output['features'] = read_features(child)
except KeyError:
logger.warn('Error in retrieving %s', str(entry))
except RuntimeError as e:
output['message'] = 'an error occurred'
html = HTML.document_fromstring(r.text.replace('\n', ' '))
......@@ -166,8 +168,17 @@ def read_features(entry):
if f.find('uniprot:location', ns).find('uniprot:position', ns) is not None:
feature['position'] = f.find('uniprot:location', ns).find('uniprot:position', ns).attrib['position']
feature['begin'] = f.find('uniprot:location', ns).find('uniprot:begin', ns).attrib['position']
feature['end'] = f.find('uniprot:location', ns).find('uniprot:end', ns).attrib['position']
begin = f.find('uniprot:location', ns).find('uniprot:begin', ns)
if 'position' in begin.attrib:
feature['begin'] = begin.attrib['position']
feature['begin'] = begin.attrib['status']
end = f.find('uniprot:location', ns).find('uniprot:end', ns)
if 'position' in end.attrib:
feature['end'] = end.attrib['position']
feature['end'] = end.attrib['status']
features.append (feature)
return features
import unittest
from dbxref.retrieve import uniprot
class TestPfam(unittest.TestCase):
def test_no_position(self):
'''regression test for missing position parameter in uniprot entry'''
documents = uniprot.retrieve([{'db': 'UniProtKB/Swiss-Prot', 'id': 'P0CM58'}])
# this test failed due to an error due to missing None handling,
# so no assertions here. Once fixed. this should suffice
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment