Hello
I've been struggling with rdkit tbh. I've got over the macOS boost <1.65 brew
issue, and found through sping how to set the bg colour of my output svg to
transparent (sping.sourceforge.net/reference.html
<http://sping.sourceforge.net/reference.html>).
But brick wall questions are left, based on this simple code:
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw.MolDrawing import MolDrawing
from rdkit.Chem.Draw.MolDrawing import DrawingOptions
## check
http://www.rdkit.org/docs/api/rdkit.Chem.Draw.MolDrawing%27.DrawingOptions-class.html
#
options = DrawingOptions()
# options.defaultColor = (1, 1, 1)
options.atomLabelFontFace = 'sans' # what are my options here?
options.bgColor = (-1, -1, -1)
options.defaultColor = (0, 0, 0)
options.selectColor = (1, 1, 1)
options.bondLineWidth = 2
options.colorBonds = False # appears not to work for P, O,
N etc.
# options.atomLabelFontSize = 12
i =
Chem.MolFromInchi("InChI=1S/C20H25N3O/c1-4-23(5-2)20(24)14-9-16-15-7-6-8-17-19(15)13(11-21-17)10-18(16)22(3)12-14/h6-9,11,14,18,21H,4-5,10,12H2,1-3H3/t14-,18-/m1/s1")
Draw.MolToFile(i, "VAYOSLLFUXYJDT-RDTXWAMCSA-N-320.svg", (320,320), True, True,
"svg", True, options=options)
# options.atomLabelFontSize = 13.5
i =
Chem.MolFromInchi("InChI=1S/C20H25N3O/c1-4-23(5-2)20(24)14-9-16-15-7-6-8-17-19(15)13(11-21-17)10-18(16)22(3)12-14/h6-9,11,14,18,21H,4-5,10,12H2,1-3H3/t14-,18-/m1/s1")
Draw.MolToFile(i, "VAYOSLLFUXYJDT-RDTXWAMCSA-N-375.svg", (375,375), True, True,
"svg", True, options=options)
# options.atomLabelFontSize = 15
i =
Chem.MolFromInchi("InChI=1S/C20H25N3O/c1-4-23(5-2)20(24)14-9-16-15-7-6-8-17-19(15)13(11-21-17)10-18(16)22(3)12-14/h6-9,11,14,18,21H,4-5,10,12H2,1-3H3/t14-,18-/m1/s1")
Draw.MolToFile(i, "VAYOSLLFUXYJDT-RDTXWAMCSA-N-414.svg", (414,414), True, True,
"svg", True, options=options)
# options.atomLabelFontSize = 22
i =
Chem.MolFromInchi("InChI=1S/C20H25N3O/c1-4-23(5-2)20(24)14-9-16-15-7-6-8-17-19(15)13(11-21-17)10-18(16)22(3)12-14/h6-9,11,14,18,21H,4-5,10,12H2,1-3H3/t14-,18-/m1/s1")
Draw.MolToFile(i, "VAYOSLLFUXYJDT-RDTXWAMCSA-N-768.svg", (768,768), True, True,
"svg", True, options=options)
# options.atomLabelFontSize = 24
i =
Chem.MolFromInchi("InChI=1S/C20H25N3O/c1-4-23(5-2)20(24)14-9-16-15-7-6-8-17-19(15)13(11-21-17)10-18(16)22(3)12-14/h6-9,11,14,18,21H,4-5,10,12H2,1-3H3/t14-,18-/m1/s1")
Draw.MolToFile(i, "VAYOSLLFUXYJDT-RDTXWAMCSA-N-1025.svg", (1025,1025), True,
True, "svg", True, options=options)
This outputs several files for various screen sizes of mobile I'm developing
for.
1) How can I make the font weight bold? or italic for that matter. The
sping/piddle docs list these with the font face and size but these are split
out in the rdkit docs
2) I found
http://www.rdkit.org/docs/api/rdkit.Chem.Draw.MolDrawing%27.DrawingOptions-class.html
<http://www.rdkit.org/docs/api/rdkit.Chem.Draw.MolDrawing'.DrawingOptions-class.html>
having looked at the code for MolDrawing, but there appears to be no
documentation as regard what each of these options does. Where is this
documentation?
3) Even with options.defaultColor = (1, 1, 1) non-carbon atoms display coloured
(O red, N blue etc). But I need a monochrome image. Can anyone confirm if
monochrome images are possible please and how this is done?
4) In the attached image, you will notice that the non-carbon, non-hydrogen
atoms are slightly out of place, too far down from exactly where they are
expected to be drawn. How can this be adjusted? It appears not to matter what
I set the font size to, they are always out of place. I think this might be
because of the fact the glyphs are aligned to the bottom of their containers in
the svg.
Great kit!
Thanks IA,
Mark Lewis
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss