Tabea-K
1/22/2019 - 8:12 PM

This is a small example on how to retrieve a gene description based on a RefSeq id.

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")