You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Python实现SYBYL线表示法(SNL)到SMILES的转换?

Converting SYBYL Line Notation (SNL) to SMILES in Python

Great question! You’re right that RDKit doesn’t have native support for parsing SYBYL Line Notation (SNL) directly. But there’s a reliable workaround using OpenBabel—a robust cheminformatics tool that handles a massive range of chemical format conversions, including SNL to SMILES.

Here’s how to make it work:

Using OpenBabel’s Python Binding (Pybel)

First, install OpenBabel and its Python wrapper:

pip install openbabel

(Note: On some systems, you may need to install the core OpenBabel library first via your package manager—like sudo apt install openbabel on Debian/Ubuntu.)

Then use this code snippet to convert your N-methylpyrrolidone example:

import pybel

# Your SYBYL Line Notation string
snl = 'N[1](CH2CH2CH2C@1=O)CH3'

# Parse the SNL as a SYBYL-format molecule
mol = pybel.readstring("sybyl", snl)

# Convert to SMILES and clean up extra whitespace
smiles = mol.write("smi").strip()

print(smiles)  # Output: CN1CCCC1=O

Alternative: Command-Line OpenBabel

If you prefer avoiding Python bindings, you can use OpenBabel directly from the terminal:

echo "N[1](CH2CH2CH2C@1=O)CH3" | obabel -i sybyl -o smi

This will print the matching SMILES string right away.

Why This Works

OpenBabel has built-in support for parsing SYBYL’s line notation (the sybyl input flag covers SNL). Once it converts the SNL to its internal molecular representation, switching to SMILES is a trivial step.

内容的提问来源于stack exchange,提问作者B.Gees

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 07:09:30