5

有没有办法使用 RDKit 或其他 python 模块将 SMILES 转换为化学名称或 IUPAC 名称?

我在其他帖子中找不到非常有用的东西。

非常感谢!

4

2 回答 2

3

据我所知,使用 rdkit 是不可能的,而且我不知道任何具有这种能力的 python 模块。如果您可以使用网络服务,您可以使用NCI 解析器

这是一个从 SMILES 字符串中检索 IUPAC 标识符的函数的简单实现:

import requests


CACTUS = "https://cactus.nci.nih.gov/chemical/structure/{0}/{1}"


def smiles_to_iupac(smiles):
    rep = "iupac_name"
    url = CACTUS.format(smiles, rep)
    response = requests.get(url)
    response.raise_for_status()
    return response.text


print(smiles_to_iupac('c1ccccc1'))
print(smiles_to_iupac('CC(=O)OC1=CC=CC=C1C(=O)O'))

[Out]:
BENZENE
2-acetyloxybenzoic acid

您可以轻松扩展它以转换多种不同的格式,尽管该功能并不完全快速......

另一种解决方案是使用 PubChem。您可以将 API 与 python 包pubchempy 一起使用。请记住,这可能会返回多种化合物。

import pubchempy


# Use the SMILES you provided
smiles = 'O=C(NCc1ccc(C(F)(F)F)cc1)[C@@H]1Cc2[nH]cnc2CN1Cc1ccc([N+](=O)[O-])cc1'
compounds = pubchempy.get_compounds(smiles, namespace='smiles')
match = compounds[0]
print(match.iupac_name)

[Out]:
(6S)-5-[(4-nitrophenyl)methyl]-N-[[4-(trifluoromethyl)phenyl]methyl]-3,4,6,7-tetrahydroimidazo[4,5-c]pyridine-6-carboxamide
于 2020-10-13T13:02:14.323 回答
1

最近我使用 pubchempy 管理了这个转换。这是尝试的代码。


filename = open("inif.txt", "r")

for line in filename :
    event = line
    compounds = pcp.get_compounds(event, namespace='smiles') 
    match = compounds[0]
    print(i,'$$$','the CID is',compounds,'$$$','The IUPAC name is',match.iupac_name,'$$$','for the SMILE',event)
    i+=1```
于 2021-06-16T17:41:55.643 回答