Mercurial > repos > pablocarb > synbiodesign
annotate 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 |
rev | line source |
---|---|
16
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
2 """ |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
3 Created on Fri May 31 13:29:59 2019 |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
4 |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
5 @author: anael |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
6 """ |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
7 |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
8 from __future__ import print_function |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
9 from rdkit import Chem |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
10 from rdkit.Chem import rdDepictor |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
11 from rdkit.Chem.Draw import rdMolDraw2D |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
12 |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
13 |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
14 def picture(smile): |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
15 image={} |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
16 for i in smile : |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
17 mol = Chem.MolFromSmiles(smile[i]) |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
18 rdDepictor.Compute2DCoords(mol) |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
19 drawer = rdMolDraw2D.MolDraw2DSVG(200,200) |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
20 drawer.DrawMolecule(mol) |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
21 drawer.FinishDrawing() |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
22 svg = drawer.GetDrawingText() |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
23 image[i]=svg.split("?>\n")[1] |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
24 return(image) |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
25 |
fe78fd6b315a
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
pablocarb
parents:
diff
changeset
|
26 |