After I did the last blog post about the new drawing options and Pen did his followup post, Ed Griffen at MedChemica sent along another nice example. This one is a more attractive version of the "highlight the ring systems" example I did to show how to use multiple highlights.
You can read the other posts for more info, here's the example:
In [1]:
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import rdMolDraw2D
from rdkit.Chem import rdDepictor
rdDepictor.SetPreferCoordGen(True)
from rdkit.Chem.Draw import IPythonConsole
from IPython.display import SVG
import rdkit
print(rdkit.__version__)
In [2]:
from collections import defaultdict
polycyclic = Chem.MolFromSmiles('CN1C[C@@H](C=C2[C@H]1CC3=CNC4=CC=CC2=C34)C(=O)O')
rings = polycyclic.GetRingInfo()
colors = [(0.8, 0.0, 0.8), (0.8, 0.8, 0), (0, 0.8, 0.8), (0, 0, 0.8)]
athighlights = defaultdict(list)
arads = {}
for i, rng in enumerate(rings.AtomRings()):
for aid in rng:
athighlights[aid].append(colors[i])
arads[aid] = 0.3
bndhighlights = defaultdict(list)
for i, rng in enumerate(rings.BondRings()):
for bid in rng:
bndhighlights[bid].append(colors[i])
d2d = rdMolDraw2D.MolDraw2DSVG(400, 400)
dos = d2d.drawOptions()
dos.atomHighlightsAreCircles = False
dos.fillHighlights=False
d2d.DrawMoleculeWithHighlights(polycyclic, 'lysergic acid', dict(athighlights), dict(bndhighlights), arads, {})
d2d.FinishDrawing()
SVG(d2d.GetDrawingText())
Out[2]:
Thanks Ed!
No comments:
Post a Comment