1

许多化学家面临的一个恼人问题是将化合物的 CAS 登记号(存储在一些不易访问的商业数据库中)转换为 Pubchem 标识符(公开可用)。Pubchem 支持两者之间的转换,但只能通过他们的手动 Web 界面,而不是他们的官方 PUG REST 编程界面。

这里给出了一个基于电子实用程序接口的 Ruby 解决方案:http: //depth-first.com/articles/2007/09/13/hacking-pubchem-convert-cas-numbers-into-pubchem-cids-与红宝石/

有人知道这将如何转化为 R 吗?

编辑:根据下面的答案,最优雅的解决方案是:

library(XML)
library(RCurl)

CAStocids=function(query) {
  xmlresponse = xmlParse( getURL(paste("http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pccompound&retmax=100&term=",query,sep="") ) )
  cids = sapply(xpathSApply(xmlresponse, "//Id"), function(n){xmlValue(n)})
  return(cids)
}

> CAStocids("64318-79-2")
[1] "6434870" "5282237"

干杯,汤姆

4

2 回答 2

6

这就是 Ruby 代码的工作方式,翻译成 R,使用RCurland XML

> xmlresponse = xmlParse( getURL("http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pccompound&retmax=100&term=64318-79-2") )

以下是如何提取 Id 节点:

> sapply(xpathSApply(xmlresponse, "//Id"), function(n){xmlValue(n)})
 [1] "6434870" "5282237"

将所有内容包装在一个函数中......

 convertU = function(query){
    xmlresponse = xmlParse(getURL(
       paste0("http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pccompound&retmax=100&term=",query))) 
    sapply(xpathSApply(xmlresponse, "//Id"), function(n){xmlValue(n)})
 }

> convertU("64318-79-2")
[1] "6434870" "5282237"
> convertU("64318-79-1")
list()
> convertU("64318-78-2")
list()
> convertU("64313-78-2")
[1] "313"

如果找不到,可能需要测试。

于 2014-02-04T12:32:24.607 回答
0

我认为您仍然应该能够使用 PUG 将 CAS 编号转换为 PubChem ID,而不是您输入 CAS 编号的化合物名称。当然,如果 CAS 编号重叠,这可能不那么具体。我没有测试过。

阿司匹林示例 https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/50-78-2/cids/JSON

于 2015-03-25T09:49:25.387 回答