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.
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.
3 answers
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)
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
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.
Log in to answer this question.
Citations in which format?
You can use entrez's edirect cli tool efetch.