skeujam分享好玩有趣的有机分子可视化,建议Jupyter 中发帖

import py3Dmol
from rdkit import Chem
from rdkit.Chem import AllChem
from ipywidgets import interact

@interact
def show_molecule(smiles=''):
if not smiles:
return
mol = Chem.MolFromSmiles(smiles)
display(mol)
if not mol:
return
mol = Chem.AddHs(mol)
AllChem.EmbedMolecule(mol)
AllChem.MMFFOptimizeMolecule(mol)
Chem.MolToMolBlock(mol, kekulize=False)
...