Hi Greg,

 

Thanks for the prompt response, I’ve already patched it in this way and 
although it is just a one I look forward to the patched release to have it 
cleaner.

 

Cheers,

Lukas

 

From: Greg Landrum <greg.land...@gmail.com>
Date: Tuesday, 30 October 2018 at 17:16
To: Lukas Pravda <lpra...@ebi.ac.uk>
Cc: RDKIT mailing list <rdkit-discuss@lists.sourceforge.net>
Subject: Re: [Rdkit-discuss] How to set bond width with use of MolDraw2DSVG

 

Hi Lukas,

 

It looks like I forgot to expose the method to change line width to the Python 
wrapper, so you can't currently change it using the new drawing code.

Until that's fixed (and I think we can describe the missing wrapper method as a 
bug and get it in the next patch release, but I will have to confirm that), I'm 
afraid that you'll need to edit the SVG. Let know if you want tips on how to do 
that.

 

For the next release, the drawing options object should certainly support a 
bondWidth.

 

-greg

 

 

On Tue, Oct 30, 2018 at 4:37 PM Lukas Pravda <lpra...@ebi.ac.uk> wrote:

Hi all,

 

First of all, my configuration is following:

macOS: 10.14

conda: 4.5.11

python: 3.6.6

rdkit: 2018.09.01

 

I just tried to set bond width for 2D SVG images and I run into situation I 
don’t understand much (nothing surprising ☺). I’m aware of 2 ways how to 
generate SVG images

 

A simple one

from rdkit import Chem

from rdkit.Chem import Draw

width=100

mol = Chem.MolFromSmiles('c1cc(CCCO)ccc1')

Draw.DrawingOptions.bondLineWidth = 10

Draw.MolToFile(mol, 'img.svg', size=(width, width))

 

Here I can set bondLineWidth, it works like a charm, but if I use the other 
approach I know, which allows a bit more configuration,

 

from rdkit import Chem

from rdkit.Chem import Draw

mol = Chem.MolFromSmiles('c1cc(CCCO)ccc1')

drawer = Draw.MolDraw2DSVG(width, width)

options = drawer.drawOptions()

options.bondLineWidth = 10 # does not work

Draw.DrawingOptions.bondLineWidth = 10 # does not work either

mol = Draw.PrepareMolForDrawing(mol)

drawer.DrawMolecule(mol)

drawer.FinishDrawing()

with open(f'img.svg', 'w') as f:

    f.write(drawer.GetDrawingText())

 

the bondLineWidth property is not part of the object returned by drawOptions(). 
And setting it in a similar fashion as with the previous case does not work. 
So, I am bit puzzled at this point, If I do something wrong, or if it is 
possible to set it at all in the other approach.

At best, I’d like to set the other approach as it allows a bit more 
configuration and I would like to avoid manipulating the svg text directly. I 
appreciate all your help.

 

Thank you!

Lukas 

                                                                                
                                                                                
                                                

_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to