from rdkit.Chem import AllChem
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG
# read mol
mol = Chem.MolFromSmiles('O=C(O)C1=CC(=NNC2=CC=C(C=C2)C(=O)NCCC(=O)O)C=CC1=O')
# draw the mol
dr = rdMolDraw2D.MolDraw2DSVG(800,800)
dr.SetFontSize(0.3)
op = dr.drawOptions()
for i in range(mol.GetNumAtoms()) :
op.atomLabels[i] = mol.GetAtomWithIdx(i).GetSymbol() + str((i+1))
AllChem.Compute2DCoords(mol)
dr.DrawMolecule(mol)
dr.FinishDrawing()
svg = dr.GetDrawingText()
SVG(svg)
我想向#17的N原子添加一个质子,并使该分子离子化。如何在rdkit中实现这一目标?
答案 0 :(得分:1)
您正在寻找这些功能吗?
atom = mol.GetAtomWithIdx(17)
atom.SetNumExplicitHs(1)
atom.SetFormalCharge(1)