vote up 2 vote down
star
1

This is (not) specifically related to chemistry or open source, but I don't know where to look.

I have a number of articles (a couple of hunderd) in a bibtex file, and some of them are missing their DOI, which is very useful for getting hyperlinked references in PDF files.

Is there a way to get the DOI fields for all of them automatically?

Obviously, I can parse the bibtex file on my own with some script and serve any kind of information about the article (authors, title, journal, etc.).

Solution in Python

Here is a function in Python based on the code Rich posted in Ruby, which queries crossref and return a list of matching DOIs...


import urllib
import xml.dom.minidom

def getdoi(account, journal=False, volume=False, issue=False, spage=False, date=False):
    journal = journal.replace(" ", "%20")
    url = "http://www.crossref.org/openurl?pid=account"
    if journal:
        url += "&title=%s" %journal
    if volume:
        url += "&volume=%i" %int(volume)
    if issue:
        url += "&issue=%i" %int(issue)
    if spage:
        url += "&spage=%i" %int(spage)
    if date:
        url += "&date=%si" %date
    url += "&redirect=false&format=unixref"
    txt = urllib.urlopen(url).read()
    doc = xml.dom.minidom.parseString(txt)
    dois = doc.getElementsByTagName('doi')
    dois = [doi.childNodes[0].nodeValue for doi in dois]
    return dois
flag
This is as cheminformatics as it can... – Egon Willighagen Jan 3 at 9:05
Here I thought it was as bioinformatics as it can get. :) – Andrew Dalke Jan 14 at 22:53

3 Answers

vote up 2 vote down
check

I wrote an article describing how to use CrossRef and OpenURL to assign DOIs from bibliographic information.

This Ruby library worked for me:

require 'rubygems'
require 'hpricot'
require 'open-uri'

module DOI
  # Convert a doi into a bibliographic reference.
  def biblio_for doi
    doc = Hpricot(open("http://www.crossref.org/openurl/?id=doi:#{doi}&noredirect=true&pid=ourl_sample:sample&format=unixref"))

    journal = (doc/"abbrev_title").inner_html
    year = (doc/"journal_issue/publication_date/year").inner_html
    volume = (doc/"journal_issue/journal_volume/volume").inner_html
    number = (doc/"journal_issue/issue").inner_html
    first_page = (doc/"pages/first_page").inner_html
    last_page = (doc/"pages/last_page").inner_html

    "#{journal} #{year}, #{volume}(#{number}) #{first_page}-#{last_page}"
  end

  # Convert a bibliographic reference into a DOI.
  def doi_for journal, year, volume, issue, page
    doc = Hpricot(open("http://www.crossref.org/openurl/?title=#{journal.gsub(/ /, '%20')}&volume=#{volume}&issue=#{issue}&spage=#{page}&date=#{year}&pid=ourl_sample:sample&redirect=false&format=unixref"))

   (doc/"doi").inner_html
  end
end

Not sure how well it works still - might be worth revisiting.

link|flag
That's great! I rewrote the thing in Python and integrated it with my other bibliographic tools. Problem solved. – Karol Langner Feb 12 at 15:26
vote up 1 vote down

JabRef can fetch PubMed reference details based on PMID, keywords, or title, which contain in most cases DOI. Anyway, I think your specific request might require hacking the fetching class for doing this for a list of titles automatically. Finally, actually interesting, I could use that functionality within JabRef, too, just for filling the blanks for the entries, which do not have a DOI, yet.

link|flag
vote up 0 vote down

Try Mendeley. I think you can import bibtex to Mendeley and automatically assign DOI, PMID, etc.

link|flag

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.