Saturday, March 28, 2015

bpy18. Posting IDs in a NCBI EUtil using Biopython

We can use the keyword parameter usehistory='y' to Bio.Entrez.esearch.


We searched for mitochondria review articles, that have free full text available, from years 2012 through 2014.


Because of the additional parameter, two new keywords were returned and we can use in a subsequent eUtil. We print the title of a few records, from the 1223 that were returned.

# bpy18.py

from __future__ import print_function
from Bio import Entrez
Entrez.email = "A.N.Other@example.com"
term = ('"mitochondria"[MeSH Terms] OR "mitochondria"[All Fields])'
        ' AND (Review[ptyp] AND "loattrfree full text"[sb] AND'
        ' ("2012/01/01"[PDAT] : "2014/12/31"[PDAT]))')
handle = Entrez.esearch("pubmed", retmax = 1500, term = term,
                        usehistory = 'y' )

values = Entrez.read(handle)
print("Count:",values['Count'])
print("len(IdList)",len(values['IdList']))
print("QueryKey:", values['QueryKey'])
print("len(WebEnv):", len(values['WebEnv']))

summary = Entrez.esummary(db="pubmed", retmax=values['Count'],
                          webenv=values["WebEnv"],
                          query_key=values["QueryKey"])
records = Entrez.read(summary)

for i,record in enumerate(records):
    if i%300 != 0: continue
    print('%d. %s' % (i+1,record['Title']))
    print('')

#Count: 1223
#len(IdList) 1223
#QueryKey: 1
#len(WebEnv): 78
#1. The role of SIGMAR1 gene mutation and mitochondrial dysfunction
# in amyotrophic lateral sclerosis.
#
#301. You are what you eat: multifaceted functions of autophagy
# during elegans development.
#
#601. Mitochondrial deficiency in Cockayne syndrome.
#
#901. Transcriptional repression of mitochondrial function in
# aging: a novel role for the silencing mediator of retinoid
# and thyroid hormone receptors co-repressor.
#
#1201. Signal transduction by mitochondrial oxidants.

No comments:

Post a Comment