view rpviz/smile2picture.py @ 26:fbf2e5072b32 draft

planemo upload commit c74b3ff2329f69ac7b309cc7d9bdf7b9d78106fb-dirty
author pablocarb
date Fri, 05 Jul 2019 17:29:50 -0400
parents fe78fd6b315a
children
line wrap: on
line source

# -*- coding: utf-8 -*-
"""
Created on Fri May 31 13:29:59 2019

@author: anael
"""

from __future__ import print_function
from rdkit import Chem
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import rdMolDraw2D


def picture(smile):
    image={}
    for i in smile :
        mol = Chem.MolFromSmiles(smile[i])
        rdDepictor.Compute2DCoords(mol)
        drawer = rdMolDraw2D.MolDraw2DSVG(200,200)
        drawer.DrawMolecule(mol)
        drawer.FinishDrawing()
        svg = drawer.GetDrawingText()
        image[i]=svg.split("?>\n")[1]
    return(image)