Skip to content

Instantly share code, notes, and snippets.

@neilfws
Created August 10, 2009 03:17
Show Gist options
  • Save neilfws/164994 to your computer and use it in GitHub Desktop.
Save neilfws/164994 to your computer and use it in GitHub Desktop.
Search PubMed using esearch, return results as BibTeX
#!/usr/bin/ruby
# save as pubmed.rb and test using 'ruby pubmed.rb 19662644'
# keyword search may return > 1 record due to retmax bug
# http://github.com/bioruby/bioruby/commit/51c3223e033b2992a7bd95da282f88164406ff92
require 'rubygems'
require 'bio'
keywords = ARGV.join(' ')
options = {
'retmax' => 1
}
entries = Bio::PubMed.esearch(keywords, options)
entries.each do |entry|
query = Bio::PubMed.query(entry)
medline = Bio::MEDLINE.new(query)
puts medline.reference.bibtex
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment