Commit f05f4c7f authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Fix bug: Pfam retriever crashes when no go_terms are available (fixes #20)

parent 1b03797b
...@@ -63,14 +63,15 @@ def read_annotation(entry): ...@@ -63,14 +63,15 @@ def read_annotation(entry):
'comment': entry.find('pfam:comment', ns).text.strip() 'comment': entry.find('pfam:comment', ns).text.strip()
} }
go_terms = entry.find('pfam:go_terms', ns) go_terms = entry.find('pfam:go_terms', ns)
categories = go_terms.findall('pfam:category', ns) if go_terms:
for category in categories: categories = go_terms.findall('pfam:category', ns)
terms = category.findall('pfam:term', ns) for category in categories:
for term in terms: terms = category.findall('pfam:term', ns)
annotation['terms'].append({ for term in terms:
'id': term.attrib['go_id'], annotation['terms'].append({
'description': term.text 'id': term.attrib['go_id'],
}) 'description': term.text
return annotation return annotation
if __name__ == "__main__": if __name__ == "__main__":
import unittest
from dbxref import retriever, resolver
class TestPfam(unittest.TestCase):
def test_no_go_terms(self):
'''regression test for missing go terms in pfam entry'''
documents = retriever.retrieve([{'db': 'pfam', 'id': 'PF10423.8'}])
# this test failed due to an error due to missing None handling,
# so no assertions here. Once fixed. this should suffice
Markdown is supported
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