1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import json import os import requests import shelve def ensembl(g) : with shelve.open("ensembl_shelf") as db : if g in db : return db[g] r = requests.get("http://rest.ensembl.org/lookup/id/{}?content-type=application/json;expand=1".format(g)) t = r.text j = json.loads(t) j["description"] = re.sub(r' \[.*\]','',j.get("description","no description")) j.pop("Transcript",None) db[g] = je return j
You can clone a snippet to your computer for local editing. Learn more.