Created
January 22, 2019 20:12
-
-
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.
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
#!/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