TogoWS を R からつかってみる。

R で TogoWS をつかってみます。TogoWS REST API 経由での利用によって、データベースレコードのフィールドの値が簡単に取り出せます。

関数定義

library(RCurl)

togows_entry <- function(query_string) {
  base_url <- "http://togows.dbcls.jp/entry"
  url = paste(base_url, query_string, sep='/')
  sub("\n$", "",  getURL(url))
}

使い方

エントリー取得。REST API の entry/ 以降を第一引数にしています。

togows_entry('genbank/HUMIGHAF')

http://togows.dbcls.jp/entry/genbank/HUMIGHAF と同等です。


フィールド指定:GenBank のレコード

> togows_entry('genbank/HUMIGHAF/definition')
[1] "Human Ig gamma3 heavy chain disease OMM protein mRNA."

http://togows.dbcls.jp/entry/genbank/HUMIGHAF/definition と同等です。


フォーマット指定:UniProt のエントリを GFF で取得

togows_entry('uniprot/A1AG1_HUMAN,A1AG1_MOUSE.gff')

http://togows.dbcls.jp/entry/uniprot/A1AG1_HUMAN,A1AG1_MOUSE.gff と同等です。


PMID の著者リスト取得

> togows_entry('pubmed/16381885/authors')
[1] "Kanehisa, M.\tGoto, S.\tHattori, M.\tAoki-Kinoshita, K. F.\tItoh, M.\tKawashima, S.\tKatayama, T.\tAraki, M.\tHirakawa, M."

http://togows.dbcls.jp/entry/pubmed/16381885/authors と同等です。

まとめ

TogoWS REST API を R からつかってみました。

togows_entry('pubmed/16381885/authors') だけでなく、

  • togows_entry('pubmed', '16381885', 'authors')
  • togows_entry(db = 'pubmed', id = '16381885', field = 'authors')
  • togows_entry('pubmed', c('16381885'), 'authors')

という引数を受け付けたい。

このような方針で entry 以外の search、convert に対応したメソッドをつくって Bioconducor パッケージにするといいと思う。