Ensembl REST query examples¶
%load_ext autoreload
%autoreload 2
from bionty._servers import EnsemblREST
er = EnsemblREST()
ids = ["ENSG00000275717", "ENSG00000248378"]
Check if ids are current
er.archive_ids(ids)
[{'latest': 'ENSG00000275717.5',
'assembly': 'GRCh38',
'id': 'ENSG00000275717',
'peptide': None,
'is_current': '1',
'version': 5,
'release': '106',
'possible_replacement': [],
'type': 'Gene'},
{'latest': 'ENSG00000248378.1',
'assembly': 'GRCh38',
'peptide': None,
'id': 'ENSG00000248378',
'is_current': '1',
'version': 1,
'release': '106',
'possible_replacement': [],
'type': 'Gene'}]
Retrieve external references for an id
res = er.xref("ENSG00000275717")
res[:2]
[{'synonyms': [],
'display_id': 'ENSG00000275717',
'info_type': 'DIRECT',
'info_text': '',
'primary_id': 'ENSG00000275717',
'description': None,
'db_display_name': 'Expression Atlas',
'version': '0',
'dbname': 'ArrayExpress'},
{'info_type': 'DEPENDENT',
'info_text': '',
'synonyms': [],
'display_id': 'KIR3DL1',
'description': 'killer cell immunoglobulin like receptor, three Ig domains and long cytoplasmic tail 1',
'primary_id': '3811',
'db_display_name': 'NCBI gene (formerly Entrezgene)',
'dbname': 'EntrezGene',
'version': '0'}]
set([i["dbname"] for i in res])
{'ArrayExpress',
'EntrezGene',
'HGNC',
'MIM_GENE',
'MIM_MORBID',
'Uniprot_gn',
'WikiGene'}
Retrieve external references for multiple ids
res = er.xref(ids)
set([i["dbname"] for i in res[0]])
{'ArrayExpress',
'EntrezGene',
'HGNC',
'MIM_GENE',
'MIM_MORBID',
'Uniprot_gn',
'WikiGene'}