Drkcore

31 05 2011 Python Tweet

doiからアブストラクトを取ってくる

今、職場で使っている文献管理システムはpubmedのXMLサービスを使ってpubmedのIDで管理しているので、合成反応系の雑誌が収録されてなくてケミストには不評だったり、ASAPとpubmedのタイムラグがあってちょっと待たないと登録できなかったりと製薬系の研究所内では使いにくさが目立ってきている。(自分も量子化学系の論文とか管理できなくて困ったりしたのだけど、3年以上放置してきた)

ふと、やる気を出した。

from pyquery import PyQuery as pq
import re

r = re.compile('10.(\d+)/')

def get_contents(doi):
    DX_DOI = "http://dx.doi.org/"
    doi_url = DX_DOI + doi
    d = None
    try:
        d = pq(doi_url)
    except:
        pass

    return _extract(d,doi)

def _extract(d,doi):
    registrant_prefix = r.search(doi).group(1)    
    if registrant_prefix == '1021':
        return _extractACS(d,doi)
    else:
        return "no extractor"

#    SQLAlchemy
#    title            = Column(String(256), unique=True)
#    pubmed_id        = Column(Integer, unique=True)
#    doi              = Column(String(128), unique=True)
#    abstract         = Column(Text())

def _extractACS(d,doi):
    title = d("h1.articleTitle").text()
    abstract = d("p.articleBody_abstractText").text()
    return {'doi': doi, 'title': title, 'abstract': abstract}

これでACS系はいけるはず。

J.C.I.Mはもちろん

>>> doi.get_contents('10.1021/ci900416a')
{'abstract': u'We introduce SARANEA, ... freely available under the GNU \
General Public License.', 'doi': '10.1021/ci900416a', 'title': u'SARANEA:\
A Freely Available Program To Mine Structure\u2212Activity and \
Structure\u2212Selectivity Relationship Information in Compound Data Sets'}

J.O.Cもいけるで。

>>> doi.get_contents('10.1021/jo1025157')
{'abstract': u'The stereoselectivity of glycosylation reactions is affected \
by many factors. Synthesis of 1,2- cis glycosidic ... effects of the acetyl \
groups.', 'doi': '10.1021/jo1025157', 'title': 'Study of the \
Stereoselectivity of 2-Azido-2-deoxygalactosyl Donors: Remote Protecting \
Group Effects and Temperature Dependency'}

あとはスクレイプできる出版社を増やしていけばpubmedのXMLサービス使わんでもいいね。

  • ASAPも大丈夫
  • doiからたどれる出版社の文献を管理できる

あとちっと頑張れば一通り動くようなものが出来上がる予定。

pyqueryも、Web::QueryもjQueryっぽくスクレイピング出来て便利なので、結局jQueryを覚えておけば色々使い回しが効いて良いと思う。

ProductName jQueryクックブック
jQuery Community Experts
オライリージャパン / 3780円 ( 2010-08-18 )


About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021