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):
'comment': entry.find('pfam:comment', ns).text.strip()
}
go_terms = entry.find('pfam:go_terms', ns)
categories = go_terms.findall('pfam:category', ns)
for category in categories:
terms = category.findall('pfam:term', ns)
for term in terms:
annotation['terms'].append({
'id': term.attrib['go_id'],
'description': term.text
})
if go_terms:
categories = go_terms.findall('pfam:category', ns)
for category in categories:
terms = category.findall('pfam:term', ns)
for term in terms:
annotation['terms'].append({
'id': term.attrib['go_id'],
'description': term.text
})
return annotation
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