BioPython ESearch XML File & Dates
1
0
Entering edit mode
5.2 years ago
chrisgbeldam ▴ 20

Hi,

So I am attempting to do an esearch like the following in Biopython:

 handle = Entrez.esearch(
    db="pubmed",
    sort="relevance",
    term=disease,
    mindate=year,
    retmode="xml",
)
results = Entrez.read(handle) 
handle.close()

How would I go about returning this result as an xml file? Currently results = python dictionary of all the results but I would like to be able to output this as an xml file. So that I can use the file to plot a graph of some kind?

Also, I've put an min date to return the results of a specific year. I would like to know if it's possible to return results for a range of years?

Search eSearch • 1.8k views
ADD COMMENT
1
Entering edit mode
5.2 years ago
Ram 43k

I did a quick scan of Bio.Entrez, and it doesn't seem to be equipped for writing eutils results as XML. I think it would be easier to build a eutils URL query and curl the results into a custom file.

As for the date, you can add it into your search term using ("<Start_date>"[PDAT] : "<end_date>"[PDAT])

Example: "Triple Negative Breast Cancer" AND ("2015/1/1"[PDAT] : "2016/1/1"[PDAT]) which becomes the URL: https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term="triple negative breast cancer" AND ("2015/1/1"[PDAT] : "2016/1/1"[PDAT])

Note: I cleaned up the URL so it would be easier to read, but I'm sure python can HTTP encode the readable URL (in this case by replacing (blank space) with %20 and " with %22

ADD COMMENT

Login before adding your answer.

Traffic: 1943 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6