What is the simplest way to go from Pubmed ID to citation, programmatically?
3
4
Entering edit mode
8.3 years ago

Hi,

I have a bunch of Pubmed IDs, and I need to generate citations for them. I know I can retrieve a specific Pubmed record's XML using annotate::pubmed. I also found an online script to transform a set of IDs into a dataframe: https://www.r-bloggers.com/r-function-to-retrieve-pubmed-citations-from-pmid-number/

However, the script seems a little complex, and neither solution offers an easy way to generate formated citations. Are there any libraries out there who would offer such a functionality? Writing my own function would not be very hard, but that sounds like the kind of common problem someone else must have already solved.

pubmed • 7.0k views
ADD COMMENT
0
Entering edit mode

Citations in which format?

ADD REPLY
0
Entering edit mode

You can use entrez's edirect cli tool efetch.

ADD REPLY
3
Entering edit mode
7.6 years ago
Naomi Most ▴ 60

You can use metapub (Python library) to do this pretty easily.

In a file:

from metapub import PubMedFetcher
pmids = [2020202, 1745076, 2768771, 8277124, 4031339]
fetch = PubMedFetcher()
for pmid in pmids:
    article = fetch.article_by_pmid(pmid)
    print(article.citation)

https://pypi.python.org/pypi/metapub

ADD COMMENT
0
Entering edit mode

Is there a way to pass a list of pmids instead of looping over a list? It's pretty time consuming when working even with as few as 40,50 publications.

ADD REPLY
2
Entering edit mode
8.3 years ago

Use a xslt transformation. For example https://github.com/lindenb/xslt-sandbox/blob/master/stylesheets/bio/ncbi/pubmed2wikipedia.xsl

$ curl  -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?retmode=xml&db=pubmed&id=1975550" | xsltproc --novalid pubmed2wikipedia.xsl  -

    <ref>{{cite journal
| quotes = yes
|last=Ryberg
|first=B
|authorlink=
|coauthors=Tielemans Y, Axelson J, Carlsson E, HÃ¥kanson R, Mattson H, Sundler F, Willems G
|year=[[1990]]|month=Oct.
|title=Gastrin stimulates the self-replication rate of enterochromaffinlike cells in the rat stomach. Effects of omeprazole, ranitidine, and gastrin-17 in intact and antrectomized rats
|journal=[[Gastroenterology]]
|volume=99
|issue=4
|pages=935-42
|publisher= |location = [[United States]]| issn = 0016-5085| pmid = 1975550
| bibcode = | oclc =| id = | url = |  language = | format = | accessdate = | laysummary = | laysource = | laydate = | quote = 
 }}</ref>

one can find a pubmed to bib text on the web: e.g: https://github.com/pzorin/kbibtex/blob/master/xslt/pubmed2bibtex.xsl

ADD COMMENT
2
Entering edit mode
7.6 years ago
LLTommy ★ 1.2k

I just want to add that Europe PMC has an API and TODAY there is a webinar where they talk about how to use it, might be interesting for you as well: http://www.ebi.ac.uk/training/events/2017/embl-ebi-programmatically-take-rest-manual-searching-webinar-series

Cheers.

ADD COMMENT

Login before adding your answer.

Traffic: 1890 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