【发布时间】:2021-01-27 10:15:58
【问题描述】:
有没有办法使用 RDKit 或其他 python 模块将 SMILES 转换为化学名称或 IUPAC 名称?
我在其他帖子中找不到非常有用的内容。
非常感谢!
【问题讨论】:
标签: python rdkit cheminformatics
有没有办法使用 RDKit 或其他 python 模块将 SMILES 转换为化学名称或 IUPAC 名称?
我在其他帖子中找不到非常有用的内容。
非常感谢!
【问题讨论】:
标签: python rdkit cheminformatics
最近我使用 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```
【讨论】:
据我所知,使用 rdkit 是不可能的,而且我不知道任何具有此功能的 python 模块。如果您可以使用网络服务,您可以使用NCI resolver。
这是一个从 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
【讨论】: