RDKit | 基于RDKit的指定原子或键高亮

基于RDKit的指定原子或键高亮


指定原子或键高亮

HilightChemAtom.py 

from rdkit import Chem
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG
from io import BytesIO
from PIL import Image
from cairosvg import svg2png
import argparse


def generate_image(mol, highlight_atoms, highlight_bonds, atomColors, bondColors, radii, size, output, isNumber=False):

    print(highlight_atoms)
    print(highlight_bonds)
    print(atomColors)
    print(bondColors)

    image_data = BytesIO()
    view = rdMolDraw2D.MolDraw2DSVG(size[0], size[1])
    tm = rdMolDraw2D.PrepareMolForDrawing(mol)

    option = view.drawOptions()
    if isNumber:
        for atom in mol.GetAtoms():
            option.atomLabels[atom.GetIdx()] = atom.GetSymbol() + str(atom.GetIdx() + 1)

    view.DrawMolecule(tm, highlightAtoms=highlight_atoms, highlight

你可能感兴趣的:(RDKit,化学信息学与AI)