We are on a grant writing mode. As I’m not actively participating of the writing per se, I decided to help on the background. We needed something to gather all the references and save them in a format that some software like Endnote was capable of reading. As I mentioned before BioPython seems really convoluted when accessing PubMed, so I decided to go with BioRuby. We had the references entries and their PMID organized this way
Goldman, JM, Melo JV 2003 NEJM 349:1451 14534339
Lewis GD 1993 Cancer Immunol Immun other 37: 255 8102322
McShane LM 2009 Clin Canc Res 15: 1898 19276274
Fox JL 2007 Nature Biotech 25: 489 17483821
Bodin L 2005 Blood 106: 135 15790782
basically author name(s), journal information, two tabs and the PMID at the end of each row. From this I would need to search PubMed for the ID and download a formatted reference. The script I used was this
require 'rubygems' require 'bio' my_file = File.new(ARGV) refs = my_file.readlines ids =  refs.each do |line| pmid = line.strip().split("\t") ids.push(pmid) end ids.each do |id| entry = Bio::PubMed.query(id) medline = Bio::MEDLINE.new(entry) reference = medline.reference puts reference.endnote end
The file name with the refs table is passed to the script that reads its entirety, ids is initialized as an array and the PMIDs are extracted from each line, by using a split on the tabs (not forgetting to remove the carriage return/line feed with strip) and saved in the ids array.
After that, by iterating over the ids array, we use the Bio::PubMed to query PubMed in order get the reference in PubMed format and then by using the Bio::MEDLINE we get the reference, which then can be output onto an Endnote format.
Quite simple and useful.