I am looking for a simple option to retrieve the mesh terms and publication date for a given PubMed ID. I was looking at Eutils tools like esearch and efetch. But not able to find the exact details or URL format to query PubMed using key workd and print only publication date and mesh fields - any suggestions ?
Obviously you need something like curl or wget which can run from a script and download from a URL. If you need to search by something other than PMID (e.g. a text query), use esearch to run the query and get back the IDs, then efetch to download the docs corresponding with those IDs. Does that make sense?
- Andrew Clegg
e.g. to get all MeSH terms and the pub date for PMID 19614587, try this (from a Mac or Linux command line anyway): curl -s 'http://eutils.ncbi.nlm.nih.gov/entrez... '^(MH |DP )' -- ARGH, FriendFeed being 'helpful' has mangled the command and I don't know how to override that. If you give me an email I can send better instructions :-)
- Andrew Clegg
and the more people wil use XML+XSLT or RDF, and the more you will work with structured data instead of parsing/grepping/sorting meaningless tab-delimited files.
- Pierre Lindenbaum
Yes, it's only starts to become fun when you are pulling XML from more than one document :)
- Egon Willighagen
personally, I would use an xpath library to parse the xml and output in plain text. my understanding is that xslt (which uses xpath) is great for parsing xml but pretty much is designed to output XML or HTML only.
- Andrew Su
@andrew : can you use Xpath without programming ? which of tool is it ? Anybody can use XSLT as most browser embed an internal XSLT engine. You just have to add the URL of your stylesheet at the top of your XML document ( http://www.w3schools.com/xsl... )
- Pierre Lindenbaum
Seriously guys -- XPath/XSLT is overkill for this kind of thing. It's a one-liner. I've written is up here so it doesn't get mangled this time: http://biotext.org.uk/how-to-...
- Andrew Clegg
working code wins! ;) (But I will say that learning to use the perl XPATH library was surprisingly simple, even for someone whose skills are decaying as fast as mine...)
- Andrew Su
BTW XMLStarlet is great for doing XPath/XSLT/etc. from the command line -- http://xmlstar.sourceforge.net/ or you may already have it as /usr/bin/xml -- but try it the easy way first ;-)
- Andrew Clegg
Andrew C, where I think your one-liner gets a bit more complicated is when you request multiple documents (e.g., http://eutils.ncbi.nlm.nih.gov/entrez...) and then want to parse out multiple fields from each article on a single line. That I think is where the balance shifts a bit toward xpath...
- Andrew Su
@Andrew Yeah, it very much depends on what you want to do *next*...
- Andrew Clegg
from email
(sorry to everyone else for hijacking this thread, but...) Pierre, very cool. How do you invoke your xsl? you need to reference it in an XML doc, right?
- Andrew Su
1) you can invoke a XSLT engine e.g. http://xmlsoft.org/XSLT... "xsltproc style.xsl doc.xml" 2) you can add a stylesheet url at the top of your XML document and open this document in firefox . See "Link the XSL Style Sheet to the XML Document" in http://www.w3schools.com/xsl...
- Pierre Lindenbaum
@All : Thanks a lot for the awesome responses. Let me go through them and try them. I was working on to contribute to GeneWiki3 (Thanks to Andrew Su, he assigned a small module for me to contribute to GeneWiki3) This is a true Science 2.0 learning experience. Thank you all !!
- Khader Shameer