【发布时间】:2019-02-28 16:23:26
【问题描述】:
我只是想知道,有没有办法将 IUPAC 或常见的分子名称转换为 SMILES?我想这样做,而不必使用在线系统手动转换每一个。任何意见将不胜感激!
作为背景,我目前正在使用 python 和 RDkit,所以我不确定 RDkit 是否可以做到这一点,我只是不知道。我当前的数据是 csv 格式。
谢谢!
【问题讨论】:
-
(Text Munging?)
我只是想知道,有没有办法将 IUPAC 或常见的分子名称转换为 SMILES?我想这样做,而不必使用在线系统手动转换每一个。任何意见将不胜感激!
作为背景,我目前正在使用 python 和 RDkit,所以我不确定 RDkit 是否可以做到这一点,我只是不知道。我当前的数据是 csv 格式。
谢谢!
【问题讨论】:
RDKit 无法将名称转换为 SMILES。 Chemical Identifier Resolver 可以转换名称和其他标识符(如 CAS No),并且有一个 API,因此您可以使用脚本进行转换。
from urllib.request import urlopen
from urllib.parse import quote
def CIRconvert(ids):
try:
url = 'http://cactus.nci.nih.gov/chemical/structure/' + quote(ids) + '/smiles'
ans = urlopen(url).read().decode('utf8')
return ans
except:
return 'Did not work'
identifiers = ['3-Methylheptane', 'Aspirin', 'Diethylsulfate', 'Diethyl sulfate', '50-78-2', 'Adamant']
for ids in identifiers :
print(ids, CIRconvert(ids))
输出
3-Methylheptane CCCCC(C)CC
Aspirin CC(=O)Oc1ccccc1C(O)=O
Diethylsulfate CCO[S](=O)(=O)OCC
Diethyl sulfate CCO[S](=O)(=O)OCC
50-78-2 CC(=O)Oc1ccccc1C(O)=O
Adamant Did not work
【讨论】:
Submit 时,它可以工作。但是 API 可以工作。
OPSIN (https://opsin.ch.cam.ac.uk/) 是 name2structure 转换的另一种解决方案。
可以通过安装cli使用,也可以通过https://github.com/gorgitko/molminer使用
(RDKit KNIME 节点也使用 OPSIN)
【讨论】:
接受的答案使用Chemical Identifier Resolver,但由于某种原因,该网站对我来说似乎是错误的,API 似乎被搞砸了。
因此,将微笑转换为 IUPAC 名称的另一种方法是使用 PubChem python API,如果您的微笑在他们的数据库中,它就可以工作
例如
#!/usr/bin/env python
import sys
import pubchempy as pcp
smiles = str(sys.argv[1])
print(smiles)
s= pcp.get_compounds(smiles,'smiles')
print(s[0].iupac_name)
【讨论】:
如果将第一行更改为:
从 urllib2 导入 url 打开
它应该适用于 python 2.7
【讨论】: