RDKit | 将rdMolDraw2D和RDKit生成的结构图输出到Excel

 

环境

  • Windows10
  • Python3.6.8
  • RDKit 2020.03.3

 


导入库 

from rdkit import Chem
from rdkit.Chem import Draw, AllChem
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG
from rdkit.Chem import PandasTools
import pandas as pd
import numpy as np
from io import BytesIO
import copy
import xlsxwriter
from PIL import Image, ImageFilter
from cairosvg import svg2png
import argparse

定义分子对象产生图片的函数

def generate_image(mol, size):

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

    view.DrawMolecule(tm)
    view.FinishDrawing()
    svg = view.GetDrawingText()
    SV

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