Re: [Rdkit-discuss] H atoms at ring junction

2023-06-08 Thread Jean-Marc Nuzillard

Thanks again!

Jean-Marc


Le 08/06/2023 à 10:31, Paolo Tosco a écrit :

Dear Jean-Marc,

I wrote my email in an iPad, and probably attaching the image failed 
somehow.


You may save the SVG image to a file as follows; it is a plain text 
XML string:


svg_image = drawer.GetDrawingText()
with open(“ h_atoms_at_ring_jn.svg”, “w”) as hnd:
    hnd.write(svg_image)

Cheers,
p.

On 8 Jun 2023, at 10:22, Jean-Marc Nuzillard 
 wrote:



I guessed that for some reason the drawing did not show up in Paolo's 
reply
to my question but I did not try to investigate further to find an 
explanation,
since I run his code without any problem and was then able to adapt 
it for the

creation of PNG images.

How did you create file h_atoms_at_ring_jn.svg?

The execution of SVG(drawer.GetDrawingText())
returns an object of type IPython.core.display.SVG
that is nicely displayed as a chemical structure by spyder
but from which I do not know how to produce a .svg file.

Best,

Jean-Marc

Le 07/06/2023 à 23:53, Jeremy Monat a écrit :
Very nice! The picture in the thread above didn't come through for 
me. I re-ran that code and got the following output, included as 
both an inline PNG and an attached SVG so hopefully it shows up for 
folks in at least one:




On Mon, Jun 5, 2023 at 3:15 AM Jean-Marc Nuzillard 
 wrote:


Dear Paolo,

many thanks, your solution worked like a charm!

Best regards,

Jean-Marc


Le 01/06/2023 à 23:57, Paolo Tosco a écrit :

Dear Jean-Marc,

you may retain the original mol block wedging and avoid
introducing H atoms as follows:

from rdkit import Chem
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG

mol = Chem.MolFromMolBlock("""trans-decalin
  RDKit  2D

  10 11  0  0  0  0  0  0  0  0999 V2000
 1.50000.0. C   0  0  0  0  0  0  0  0  0  0 0  0
 0.7500   -1.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
-0.7500   -1.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
-1.50000.0. C   0  0  0  0  0  0  0  0  0  0 0  0
-3.0.0. C   0  0  0  0  0  0  0  0  0  0 0  0
-3.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
-3.2.59810. C   0  0  0  0  0  0  0  0  0  0 0  0
-1.50002.59810. C   0  0  0  0  0  0  0  0  0  0 0  0
-0.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
 0.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
   1  2  1  0
   2  3  1  0
   4  3  1  1
   4  5  1  0
   5  6  1  0
   6  7  1  0
   7  8  1  0
   9  8  1  6
   9 10  1  0
  10  1  1  0
   9  4  1  0
M  END
""")

drawer = rdMolDraw2D.MolDraw2DSVG(300, 200)
drawer.drawOptions().prepareMolsBeforeDrawing = False
mol_draw = rdMolDraw2D.PrepareMolForDrawing(mol, addChiralHs=False, 
wedgeBonds=False)
Chem.ReapplyMolBlockWedging(mol_draw)
drawer.DrawMolecule(mol_draw)
drawer.FinishDrawing()
SVG(drawer.GetDrawingText())


Cheers,
p.

On Thursday, June 1, 2023, Jean-Marc Nuzillard
 wrote:

Dear all,

starting from this mol block:
trans-decalin
 RDKit  2D

 10 11  0  0  0  0  0  0 0  0999 V2000
    1.5000    0.    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
    0.7500   -1.2990    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
   -0.7500   -1.2990    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
   -1.5000    0.    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
   -3.    0.    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
   -3.7500    1.2990    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
   -3.    2.5981    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
   -1.5000    2.5981    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
   -0.7500    1.2990    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
    0.7500    1.2990    0. C   0  0 0  0  0  0  0  0 
0  0  0  0
  1  2  1  0
  2  3  1  0
  4  3  1  1
  4  5  1  0
  5  6  1  0
  6  7  1  0
  7  8  1  0
  9  8  1  6
  9 10  1  0
 10  1  1  0
  9  4  1  0
M  END

I tried to experiment with the great post recently published
in the rdkit-blog about drawing options.
The Mol block hereabove has no explicit hydrogen
but the function DrawMolecule()
adds two hydrogen atoms at the ring junction :

Even though this feature can be very helpful,
is it possible to let wedges along C-C bonds
carry out the geometry information without
introducing H atoms at the ring junction?

Best,

Jean-Marc Nuzillard

-- 
   

Re: [Rdkit-discuss] H atoms at ring junction

2023-06-08 Thread Paolo Tosco
Dear Jean-Marc,I wrote my email in an iPad, and probably attaching the image failed somehow.You may save the SVG image to a file as follows; it is a plain text XML string:svg_image = drawer.GetDrawingText()with open(“ h_atoms_at_ring_jn.svg”, “w”) as hnd:    hnd.write(svg_image)Cheers,p.On 8 Jun 2023, at 10:22, Jean-Marc Nuzillard  wrote:
  

  
  
I guessed that for some reason the
  drawing did not show up in Paolo's reply
  to my question but I did not try to investigate further to find an
  explanation,
  since I run his code without any problem and was then able to
  adapt it for the
  creation of PNG images.
  
  How did you create file h_atoms_at_ring_jn.svg?
  
  The execution of SVG(drawer.GetDrawingText())
  returns an object of type IPython.core.display.SVG
  that is nicely displayed as a chemical structure by spyder
  but from which I do not know how to produce a .svg file.
  
  Best,
  
  Jean-Marc
  
  Le 07/06/2023 à 23:53, Jeremy Monat a écrit :


  
  
Very nice! The picture in the thread above didn't come
  through for me. I re-ran that code and got the following
  output, included as both an inline PNG and an attached SVG so
  hopefully it shows up for folks in at least one:

  
  
  
On Mon, Jun 5, 2023 at 3:15 AM
  Jean-Marc Nuzillard 
  wrote:


  
Dear Paolo,
  
  many thanks, your solution worked like a charm!
  
  Best regards,
  
  Jean-Marc
  
  
  Le 01/06/2023 à 23:57, Paolo Tosco a écrit :


  Dear Jean-Marc,


you may retain the original mol block wedging and
  avoid introducing H atoms as follows:



  from rdkit import Chem
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG

mol = Chem.MolFromMolBlock("""trans-decalin
 RDKit  2D

 10 11  0  0  0  0  0  0  0  0999 V2000
1.50000.0. C   0  0  0  0  0  0  0  0  0  0 0  0
0.7500   -1.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
   -0.7500   -1.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
   -1.50000.0. C   0  0  0  0  0  0  0  0  0  0 0  0
   -3.0.0. C   0  0  0  0  0  0  0  0  0  0 0  0
   -3.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
   -3.2.59810. C   0  0  0  0  0  0  0  0  0  0 0  0
   -1.50002.59810. C   0  0  0  0  0  0  0  0  0  0 0  0
   -0.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
0.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
  1  2  1  0
  2  3  1  0
  4  3  1  1
  4  5  1  0
  5  6  1  0
  6  7  1  0
  7  8  1  0
  9  8  1  6
  9 10  1  0
 10  1  1  0
  9  4  1  0
M  END
""")

drawer = rdMolDraw2D.MolDraw2DSVG(300, 200)
drawer.drawOptions().prepareMolsBeforeDrawing = False
mol_draw = rdMolDraw2D.PrepareMolForDrawing(mol, addChiralHs=False, wedgeBonds=False)
Chem.ReapplyMolBlockWedging(mol_draw)
drawer.DrawMolecule(mol_draw)
drawer.FinishDrawing()
SVG(drawer.GetDrawingText())
  



  
  
  Cheers,
  p.

  
  

  On Thursday, June 1, 2023, Jean-Marc Nuzillard 
  wrote:
  
 Dear all,
  
  starting from this mol block:
  trans-decalin
   RDKit  2D
  
   10 11  0  0  0  0  0  0  0 
0999 V2000
    1.5000    0.    0. C   0  0  0  0 
0  0  0  0  0  0  0  0
    0.7500   -1.2990    0. C   0  0  0  0 
0  0  0  0  0  0  0  0
   -0.7500   -1.2990    0. C   0  0  0  0 
0  0  0  0  0  0  0  0
   -1.5000    0.    0. C   0  0  0  0 
0  0  0  0  0  0  0  0
   -3.    0.    0. C   0  0  0  0 
0  0  0  0  0  0  0  0
   -3.7500    1.2990    0. C   0  0  0  0 
0  0  0  0  0  0  0  0
   -3.    2.5981    0. C   0  0  0  0 
0  0  0  0  0  0  0  0
   -1.5000    2.5981    0. C   0  0  0  0 
0  0  0  0  0 

Re: [Rdkit-discuss] H atoms at ring junction

2023-06-08 Thread Jean-Marc Nuzillard

I guessed that for some reason the drawing did not show up in Paolo's reply
to my question but I did not try to investigate further to find an 
explanation,
since I run his code without any problem and was then able to adapt it 
for the

creation of PNG images.

How did you create file h_atoms_at_ring_jn.svg?

The execution of SVG(drawer.GetDrawingText())
returns an object of type IPython.core.display.SVG
that is nicely displayed as a chemical structure by spyder
but from which I do not know how to produce a .svg file.

Best,

Jean-Marc

Le 07/06/2023 à 23:53, Jeremy Monat a écrit :
Very nice! The picture in the thread above didn't come through for me. 
I re-ran that code and got the following output, included as both an 
inline PNG and an attached SVG so hopefully it shows up for folks in 
at least one:

h_atoms_at_ring_jn.png

On Mon, Jun 5, 2023 at 3:15 AM Jean-Marc Nuzillard 
 wrote:


Dear Paolo,

many thanks, your solution worked like a charm!

Best regards,

Jean-Marc


Le 01/06/2023 à 23:57, Paolo Tosco a écrit :

Dear Jean-Marc,

you may retain the original mol block wedging and avoid
introducing H atoms as follows:

from rdkit import Chem
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG

mol = Chem.MolFromMolBlock("""trans-decalin
  RDKit  2D

  10 11  0  0  0  0  0  0  0  0999 V2000
 1.50000.0. C   0  0  0  0  0  0  0  0  0  0 0  0
 0.7500   -1.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
-0.7500   -1.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
-1.50000.0. C   0  0  0  0  0  0  0  0  0  0 0  0
-3.0.0. C   0  0  0  0  0  0  0  0  0  0 0  0
-3.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
-3.2.59810. C   0  0  0  0  0  0  0  0  0  0 0  0
-1.50002.59810. C   0  0  0  0  0  0  0  0  0  0 0  0
-0.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
 0.75001.29900. C   0  0  0  0  0  0  0  0  0  0 0  0
   1  2  1  0
   2  3  1  0
   4  3  1  1
   4  5  1  0
   5  6  1  0
   6  7  1  0
   7  8  1  0
   9  8  1  6
   9 10  1  0
  10  1  1  0
   9  4  1  0
M  END
""")

drawer = rdMolDraw2D.MolDraw2DSVG(300, 200)
drawer.drawOptions().prepareMolsBeforeDrawing = False
mol_draw = rdMolDraw2D.PrepareMolForDrawing(mol, addChiralHs=False, 
wedgeBonds=False)
Chem.ReapplyMolBlockWedging(mol_draw)
drawer.DrawMolecule(mol_draw)
drawer.FinishDrawing()
SVG(drawer.GetDrawingText())


Cheers,
p.

On Thursday, June 1, 2023, Jean-Marc Nuzillard
 wrote:

Dear all,

starting from this mol block:
trans-decalin
 RDKit  2D

 10 11  0  0  0  0  0  0  0 0999 V2000
    1.5000    0.    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
    0.7500   -1.2990    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
   -0.7500   -1.2990    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
   -1.5000    0.    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
   -3.    0.    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
   -3.7500    1.2990    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
   -3.    2.5981    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
   -1.5000    2.5981    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
   -0.7500    1.2990    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
    0.7500    1.2990    0. C   0  0  0  0 0  0  0  0  0 
0  0  0
  1  2  1  0
  2  3  1  0
  4  3  1  1
  4  5  1  0
  5  6  1  0
  6  7  1  0
  7  8  1  0
  9  8  1  6
  9 10  1  0
 10  1  1  0
  9  4  1  0
M  END

I tried to experiment with the great post recently published
in the rdkit-blog about drawing options.
The Mol block hereabove has no explicit hydrogen
but the function DrawMolecule()
adds two hydrogen atoms at the ring junction :

Even though this feature can be very helpful,
is it possible to let wedges along C-C bonds
carry out the geometry information without
introducing H atoms at the ring junction?

Best,

Jean-Marc Nuzillard

-- 
Jean-Marc Nuzillard

Directeur de Recherches au CNRS

Institut de Chimie Moléculaire de Reims
CNRS UMR 7312
Moulin de la Housse
CPCBAI, Bâtiment 18
BP 1039
51687 REIMS Cedex 2
France

ORCID : -0002-5120-2556
Tel : +33 (0)3 26 91 82 10

http://www.univ-reims.fr/icmr

https://nuzillard.github.io/PyLSD




--