まさなみブログ

主にweb系開発の記事を適当に書いてます。

NCBIのE-utilsについて簡単にまとめてみた。


仕事でNCBIのデータをAPIで取得して、もろもろ作業したので、備忘のためにメモ。

その前に簡単にE-utilsについて説明を。

●E-utilsとは?

NCBIのEntrezデータベースからデータを利用するためのAPIのことです。
NCBIではgenomeやenzyme、論文等の情報が利用できますが、それらを取得するためのAPIとしてE-utilsというサービスが公開されています。


●E-utils使い方

以下のような形式のurlをcurlやブラウザで検索することでNCBIの各種データを取得できます。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=science[journal]+AND+breast+cancer+AND+2008[pdat]

・urlの形式

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/{API名}.fcgi?{各パラメータ}


●各APIについて

・EInfo (database statistics)

指定したDBの各フィールドのレコード数、DBの最新アップデート日付、他のEntrez DBへのリンクを取得できる。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi?db=protein

 

・ESearch (text searches)

指定したDBにキーワード検索をかけ、対象のIDリストが取得できる。後述のESummary, EFetch, ELink等でそのIDが使える。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=science[journal]+AND+breast+cancer+AND+2008[pdat]&usehistory=y

 

・ESummary (document summary downloads)

指定したDBにIDで検索をかけ、対象の情報のサマリを取得する。ブラウザの検索ページの検索結果表示画面の情報に相当する。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=protein&id=6678417,9507199,28558982,28558984,28558988,28558990

 

・EFetch (data record downloads)

指定したDBにIDで検索をかけ、対象の全情報を取得する。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=34577062,24475906&rettype=fasta&retmode=text

 

・EGQuery (global query)

それぞれのEntrez DBへキーワード検索をかけ、DBごとのヒットした結果の件数が取得できる。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi?term=mouse[orgn]

 

・ELink (Entrez links)

検索したIDと関連のあるENtrezデータベースのIDリストを取得する。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?dbfrom=nuccore&db=gene&id=34577062,24475906

 

・EPost (UID uploads)

IDをアップロードするAPI。アップロードされたIDリストは後の工程で利用できる。リクエストを分割したい時などに。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi?db=gene&id=7173,22018,54314,403521,525013


 

・ESpell (spelling suggestions)

検索キーワードに対して指定したDBから類似したのキーワードを提案してくれる。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/espell.fcgi?term=fiberblast+cell+grwth&db=pmc

 

・ECitMatch (batch citation searching in PubMed)

ジャーナル名や著者名、出版年等からpubmed IDリストを取得できる。

サンプル:

https://eutils.ncbi.nlm.nih.gov/entrez/eutils/ecitmatch.cgi?db=pubmed&retmode=xml&
bdata=proc+natl+acad+sci+u+s+a|1991|88|3248|mann+bj|Art1|%0Dscience|1987|235|182|palmenberg+ac|Art2|

 

bdata のフォーマット:
journal_title|year|volume|first_page|author_name|your_key|


●パラメータについて

上記例で出てきたパラメータについて簡単に説明。詳しくは公式ドキュメントで。

db={database}
nuccore, pubmed, proteinなど検索するDBを指定。

term={query}
検索キーワードを指定。

id={uid_list}
IDのリストを指定。

rettype={retrieval_type}
データを取得する際の形式を指定。xml, fasta, gbなど。

retmode={retrieval_mode}
データを取得するファイルの形式を指定。text, xml, htmlなど。


参考:
分からないところは公式ドキュメントのドキュメント内検索でだいたいどうにかなる。
E-utilities Quick Start - Entrez Programming Utilities Help - NCBI Bookshelf

パラメータについて
The E-utilities In-Depth: Parameters, Syntax and More - Entrez Programming Utilities Help - NCBI Bookshelf

あとこのスライドがすごい分かりやすい。
E-Utilities