利用python里的openbabel库将smiles转换生成canonical smiles
时间: 2024-05-11 20:14:50 浏览: 134
用python生成自定义表情包
Sure! 可以使用以下代码将smiles转换为canonical smiles:
```
import openbabel as ob
# create a converter object
conv = ob.OBConversion()
# set input format to smiles
conv.SetInFormat("smiles")
# set output format to canonical smiles
conv.SetOutFormat("can")
# read smiles string from file or variable
mol = ob.OBMol()
smiles = "CC(=O)C1=CC=CC=C1C(=O)O"
conv.ReadString(mol, smiles)
# generate canonical smiles
can_smiles = conv.WriteString(mol).strip()
# print canonical smiles
print(can_smiles)
```
可以根据需要更改输入输出格式并更改smiles字符串。希望能帮到你!
阅读全文