pantherdb / pantherapi-pyclient

Example code for calling Panther API services
9 stars 1 forks source link

KeyError: 'annotation_type_list' when geneinfo used on genes not having annotations #6

Closed dustine32 closed 2 years ago

dustine32 commented 2 years ago

As reported by @ariadnamorales in https://github.com/geneontology/helpdesk/discussions/371.

Running the following cmd (where geneinfo.json sets organism=9606 and gene_ids.txt contains ANKRD40CL) produces a KeyError:

python3 pthr_go_annots.py -s geneinfo -p geneinfo.json -f gene_ids.txt
Traceback (most recent call last):
  File "/Users/ebertdu/panther/pantherapi-pyclient/pthr_go_annots.py", line 227, in <module>
    response.print_results()
  File "/Users/ebertdu/panther/pantherapi-pyclient/pthr_go_annots.py", line 126, in print_results
    for dt in self.handle_annotation_data_type(r['annotation_type_list']['annotation_data_type']):
KeyError: 'annotation_type_list'

Debugging the result for the human gene with symbol ANKRD40CL (HUMAN|HGNC=26080|UniProtKB=Q53H64), it is clear that the API doesn't return an annotation_type_list key for this gene, which appears to be correct since PANTHER currently does not have any annotations for it.

The pthr_go_annots.py should handle this "no annotations" case for the geneinfo service by simply outputting the matched PANTHER long ID (e.g. HUMAN|HGNC=26080|UniProtKB=Q53H64).