Created
March 3, 2016 13:36
-
-
Save GenDataPro/78cc9afe1d4bc950fb4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests, sys | |
gene_id = "ENSG00000139618" | |
gene_name = "NCOR2" | |
species = "homo_sapiens" | |
transcript = "ENSP00000384018" | |
response_isoform = requests.get("http://rest.ensembl.org/lookup/id/{}?content-type=application/json;expand=2".format(gene_id)) | |
json_data_isoform = response_isoform.content.decode("utf-8") | |
data_isoform = json.loads(json_data_isoform) | |
response_paralog = requests.get("http://rest.ensembl.org/homology/id/{}?content-type=application/json".format(gene_id)) | |
json_data_paralog = response_paralog.content.decode("utf-8") | |
data_paralog = json.loads(json_data_paralog) | |
response_motif = requests.get("http://rest.ensembl.org/overlap/translation/ENSP00000384018?content-type=application/json;type=Prosite_profiles") | |
json_data_motif = response_motif.content.decode("utf-8") | |
data_motif = json.loads(json_data_motif) | |
from collections import Counter | |
cou_isoform = Counter([transcript["biotype"] for transcript in data_isoform["Transcript"]]) | |
isoforms = cou_isoform["protein_coding"] | |
print "Number of isoforms:", isoforms | |
cou_paralog = Counter([homo["type"] for homo in data_paralog["data"][0]["homologies"]]) | |
paralogs = cou_paralog["within_species_paralog"] + 1 | |
print "Number of paralogues:", paralogs | |
cou_motif = len(data_motif) | |
print "Number of motifs:", cou_motif | |
gene_complexity = (isoforms + cou_motif) * paralogs | |
print "Complexity number:", gene_complexity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment