把分子名称转换成微笑?

2024-06-19 19:22:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我只是想知道,有没有办法把IUPAC或普通分子的名字转换成微笑?我想这样做,而不必手动转换每一个利用在线系统。任何意见都将不胜感激!在

作为背景,我目前正在使用python和RDkit,所以我不确定RDkit是否能做到这一点,我只是不知道。我当前的数据是csv格式。在

谢谢你!在


Tags: csv数据利用系统格式手动名字分子
3条回答

OPSIN(https://opsin.ch.cam.ac.uk/)是name2结构转换的另一种解决方案。在

它可以通过安装cli或通过https://github.com/gorgitko/molminer来使用

(RDKit KNIME节点也使用OPSIN)

如果将第一行更改为:

从urllib2导入url打开

它应该适用于python2.7

RDKit无法将名字转换成微笑。 Chemical Identifier Resolver可以转换名称和其他标识符(如casno),并且有一个API,因此可以使用脚本进行转换。在

from urllib.request import urlopen

def CIRconvert(ids):
    try:
        url = 'http://cactus.nci.nih.gov/chemical/structure/' + 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']

for ids in identifiers :
    print(ids, CIRconvert(ids))

输出

^{pr2}$

相关问题 更多 >