如何绘制正确显示键角的多环芳烃的子结构?

How to draw sub-structures of a polycyclic aromatic which shows bond angles correctly?

感谢您阅读我的问题。

假设我有一个多环芳烃(我们称之为“母分子”),如下所示:

smile = "c1ccc2ocnc2c1"   
mol = Chem.MolFromSmiles(smile)

当我绘制母分子的子结构时,我注意到子结构中的键角与母分子中的键角不同。以下是我使用的代码:

from rdkit import Chem
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG

smile_1 = 'c(cc)cc'
smile_2 = 'n(co)c(c)c'

m1 = Chem.MolFromSmiles(smile_1,sanitize=False)
Chem.SanitizeMol(m1, sanitizeOps=(Chem.SanitizeFlags.SANITIZE_ALL^Chem.SanitizeFlags.SANITIZE_KEKULIZE^Chem.SanitizeFlags.SANITIZE_SETAROMATICITY))
m2 = Chem.MolFromSmiles(smile_2,sanitize=False)
Chem.SanitizeMol(m2, sanitizeOps=(Chem.SanitizeFlags.SANITIZE_ALL^Chem.SanitizeFlags.SANITIZE_KEKULIZE^Chem.SanitizeFlags.SANITIZE_SETAROMATICITY))

mols = [m1, m2]
smiles = ["smile_1", "smile_2"]

molsPerRow=2
subImgSize=(200, 200)
nRows = len(mols) // molsPerRow
if len(mols) % molsPerRow:
  nRows += 1
  
fullSize = (molsPerRow * subImgSize[0], nRows * subImgSize[1])
d2d = rdMolDraw2D.MolDraw2DSVG(fullSize[0], fullSize[1], subImgSize[0], subImgSize[1])
d2d.drawOptions().prepareMolsBeforeDrawing=False
d2d.DrawMolecules(mols, legends=smiles)
d2d.FinishDrawing()
SVG(d2d.GetDrawingText())

结果如下图:

可以看出,子结构中的几个键之间的角度与母分子不同。
有没有办法绘制与母分子具有相同键角的子结构? 非常感谢任何帮助。

您可以将 parent 的原始位置设置为子结构。

from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import rdDepictor
rdDepictor.SetPreferCoordGen(True)

def getNiceSub(parent, sub):

    # Get the coordinates of parent (also need to built a conformer)
    mol = Chem.MolFromSmiles(parent)
    rdDepictor.Compute2DCoords(mol)
    
    # Get the coordinates of substructure to built a conformer
    substruct = Chem.MolFromSmiles(sub, sanitize=False)
    rdDepictor.Compute2DCoords(substruct)
    
    # Get the index of the matched atoms
    ms = mol.GetSubstructMatch(substruct)
    
    # Get the positions of the matched atoms
    conf1 = mol.GetConformer()
    p = [list(conf1.GetAtomPosition(x)) for x in ms]
    
    # Set the original positions of parent to substructure
    conf2 = substruct.GetConformer()
    for n in range(len(ms)):
        conf2.SetAtomPosition(n, p[n])
    
    return substruct

parent = 'c1ccc2ocnc2c1'
substructer = 'n(co)c(c)c'
nicesub = getNiceSub(parent, substructer)

parent

子结构