Skip to content

Instantly share code, notes, and snippets.

@Tabea-K
Created January 22, 2019 20:12
Show Gist options
  • Save Tabea-K/a2c83b88b1a57d2d8155c9f9e5b91d4a to your computer and use it in GitHub Desktop.
Save Tabea-K/a2c83b88b1a57d2d8155c9f9e5b91d4a to your computer and use it in GitHub Desktop.
This is a small example on how to retrieve a gene description based on a RefSeq id.
#!/usr/bin/python
from Bio import Entrez
Entrez.email = 'A.N.Other@example.com'
def get_gene_info(refseq_id):
"""
Queries the ncbi refseq database for the gene summary
"""
handle = Entrez.esearch(db="gene", term=refseq_id)
record = Entrez.read(handle)
gene_id = record['IdList'][0]
handle = Entrez.esummary(db="gene", id=gene_id)
record = Entrez.read(handle)
return record[u'DocumentSummarySet']["DocumentSummary"][0]["Summary"]
get_gene_info("NM_007313")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment