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?
1 answer
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
Log in to answer this question.