Skip to content

Instantly share code, notes, and snippets.

@GenDataPro
Created March 13, 2016 00:33
Show Gist options
  • Save GenDataPro/68af3079e9adf2335535 to your computer and use it in GitHub Desktop.
Save GenDataPro/68af3079e9adf2335535 to your computer and use it in GitHub Desktop.
import requests
import sys
import json
gene_id = "ENSG00000196498"
response = requests.get("http://rest.ensembl.org/lookup/id/{}?content-type=application/json;expand=1".format(gene_id))
json_data = response.content.decode("utf-8")
data = json.loads(json_data)
pro_coding = [ortho for ortho in data['Transcript'] if ortho["biotype"] == "protein_coding"]
for transcript in pro_coding:
print transcript.get("Parent", {}),
print transcript.get('Translation', {}).get('id'),
print transcript.get('biotype', {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment