How to do it...

Let's take a look at the following steps:

  1. Let's start by retrieving all GO terms associated with the LCT gene (you can find out how to retrieve the Ensembl ID in the previous recipe). Remember that you will need the do_request function from the previous recipe:
lct_id = 'ENSG00000115850'refs = do_request(ensembl_server, 'xrefs/id', lct_id,external_db='GO', all_levels='1')print(len(refs))print(refs[0].keys())for ref in refs:    go_id = ref['primary_id']    details = do_request(ensembl_server, 'ontology/id', go_id)    print('%s %s %s' % (go_id, details['namespace'], ref['description']))    print('%s\n' % details['definition'])

Note the free-form definition and the varying namespace for each term. The first two of the eleven reported items ...

Get Bioinformatics with Python Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.