Custom Wedge/Hash with SVG output

Q

How to create a molecule structure with custom wedge/hash bonds? I don't like the default presentation of wedge/hash bonds.

✍: FYIcenter.com

A

As shown in the previous tutorial, Open Babel has its own algorithm to detect stereo centers and decide which bond to presented as a wedge or hash bond.

The resulting wedge/hash bond presentation of the molecule may not match what you specified by the Stereo Code in the SDF file.

If you really want to get a custom wedge/hash bond presentation, you do it manually as described below.

1. Generate a SVG file from the existing SDF file.

fyicenter$ obabel -O L-Alanin-2D.svg L-Alanin-2D.sdf -xd

2. Clone the SDF file and flip 2 atoms connected to the stereo center. In this example, change atom #1 to C and #3 to N.

fyicenter$ cp L-Alanin-2D.sdf clone.sdf 
fyicenter$ vi clone.sdf

L-Alanin - Clone
fyicenter.com
2D Stereoinformation: Stereo Code
  6  5  0  0  1  0  0  0  0  0999 V2000
    3.6373    2.1000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.4249    1.4000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    2.4249    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    1.2124    2.1000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.2124    3.5000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    1.4000    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
  2  1  1  1  0  0  0
  3  2  1  0  0  0  0
  4  2  1  0  0  0  0
  5  4  2  0  0  0  0
  6  4  1  0  0  0  0
M  END

3. Generate a SVG file from the clone SDF file. You see the stereo center is presented with the expected wedge/hash bonds. But their connected atom symbols are incorrect.

fyicenter$ obabel -O clone.svg clone.sdf -xd

4. Open the clone SVG file and flip back those atom symbols. In this example, flip CH3 and NH2:

fyicenter$ vi clone.svg

<?xml version="1.0"?>
...
<svg width="100" height="100" x="0" y="0" viewBox="0 0 183.923 180"
font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="2"  stroke-linecap="round">
...
<text x="139.922943" y="88.000033" fill="rgb(102,102,102)" stroke-width="0" 
  font-weight="bold" font-size="16" >NH</text>
<text x="163.922943" y="91.680033" fill="rgb(102,102,102)" stroke-width="0" 
  font-weight="bold" font-size="13" >3</text>

<text x="105.282915" y="148.000083" fill="rgb(12,12,255)" stroke-width="0" 
  font-weight="bold" font-size="16" >CH</text>
<text x="129.282915" y="151.680083" fill="rgb(12,12,255)" stroke-width="0" 
  font-weight="bold" font-size="13" >2</text>

...
</svg>
...

5. View the customized clone SVG file. You see the molecule with expected wedge/hash bonds.

Molecule with Custom Wedge/Hash
Molecule with Custom Wedge/Hash

 

Hash Bond with Solid Line

R/S (Right/Left) Hand Stereo Centers

Stereochemistry with Open Babel

⇑⇑ Open Babel Tutorials

2021-12-02, 1168👍, 0💬