Drkcore

15042010 Python biopython tex

Python使ってpubmedからbibを生成

biopythonで。

#!/usr/bin/env python
# -*- encoding:utf-8 -*-
# kzfm <kerolinq [AT] gmail.com>

def pm2bib(pm):
    author = "; ".join(pm['AU'])
    year = pm['DP'][0:4]
    bib = """@article{PMID:%s,
author = {%s},
title = {%s},
journal = {%s},
year = {%s},
volume = {%s},
number = {%s},
pages = {%s},
}
""" % (pm['PMID'],author,pm['TI'],pm['TA'],year,pm['VI'],pm.get('IP',""),pm['PG'])
    return bib

if __name__ == "__main__":

    from Bio import Entrez, Medline

    Entrez.email = "xxx@gmail.com"
    record = Entrez.read(Entrez.esearch(db="pubmed",term="biopython"))
    idlist = record["IdList"]
    records = Medline.parse(Entrez.efetch(db="pubmed",id=idlist,rettype="medline",retmode="text"))

    for record in records:
        print pm2bib(record)

適当に用意したtex

\documentclass{jarticle}
\begin{document}
\bibliographystyle{plain}
「お互いの犬\cite{PMID:20015970}の写真\cite{PMID:19811691}を撮り合い、帰ったらその写真\cite{PMID:19773334}
を自分のブログ\cite{PMID:19304878}にUPして紹介\cite{PMID:18606172}
し、お互いのブログにお礼コメント\cite{PMID:16403221}をするというのが暗黙のルール\cite{PMID:16377612}です。」

X06HT予約しにいったら、携帯電話が妻名義\cite{PMID:14871861}だったので予約出来なかった。
あと名義変更に一日かかるからあと二回いかないと予約出来ない\cite{PMID:14630660}
という衝撃の事実を聞かされた。多分、アンドロイドへの何か\cite{PMID:12230038}
が試されているんだろう。

\bibliography{test}
\end{document}

できたpdf

About

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

Tag

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

Ad

© kzfm 2003-2021