Skip to content

Instantly share code, notes, and snippets.

@vjcitn
Last active March 25, 2023 02:54
Show Gist options
  • Save vjcitn/286466efdf445819e6dd8441d500a590 to your computer and use it in GitHub Desktop.
Save vjcitn/286466efdf445819e6dd8441d500a590 to your computer and use it in GitHub Desktop.
transform a .bib file to queries to pubmed batch processor
# process .bib file into a batch query to pubmed (https://pubmed.ncbi.nlm.nih.gov/batchcitmatch/)
# get first page
fixp = function(x) gsub("--.*", "", x)
# produce a batch query
build_query = function (x)
paste(x$journal, x$year, x$volume, fixp(x$pages), x$author[[1]]$family,
paste0(x$author[[1]]$family, x$year), sep = "|")
# demonstration
library(bibtex)
scbib = read.bib(system.file("scripts", "ref.bib", package="scRNAseq"))
allq = lapply(scbib, build_query)
unlist(unname(allq))
yields (needed to revise Srivastava 2020 and Nestorowa)
Science|2015|347|1138|Zeisel|Zeisel2015|25700174
Nat. Biotechnol.|2014|32|1053|Pollen|Pollen2014|25086649
Nat Protoc|2014|9|171|Picelli|Picelli2014|24385147
Cell Metab.|2016|24|593|Segerstolpe|Segerstolpe2016|27667667
Nat. Neurosci.|2016|19|335|Tasic|Tasic2016|26727548
Nat. Neurosci.|2017|20|176|Romanov|Romanov2017|27991900
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment