"obabel ... -o svg -xS" - Ball/Stick Depiction in SVG

This section provides a tutorial example how to generate a SVG picture of a molecule structure in ball-stick style using the Open Babel 'obabel ... -o svg -xS' command.

If you want to see a ball and stick depiction of a molecule in SVG format, you can use the "-o svg -xS" option with the "obabel" command.

For example, the following command generates a ball and stick depiction of of the tyrosine molecule in SVG format:

herong$ obabel "-:c1cc(ccc1CC(C(=O)O)N)O" -O tyrosine-ball.svg --gen2D -xS

1 molecule converted

As a comparison, running the following command generates a normal skeleton depiction of of the same molecule in SVG format:

herong$ obabel "-:c1cc(ccc1CC(C(=O)O)N)O" -O tyrosine-skeleton.svg

1 molecule converted

Open both output files, tyrosine-skeleton.svg and tyrosine-ball.svg, in a Web browser, you see the differences:

Tyrosine Molecule in Skeleton and Ball/Stick Depictions
Tyrosine Molecule in skeleton and Ball/Stick Depictions

Note that the above ball and stick depiction was generated by Open Babel 2.4. The ball and stick depiction generated by Open Babel 3.1.0 does not look good. See the picture below:

Ball/Stick Depictions with Open Babel 3.1.0
Ball/Stick Depictions with Open Babel 3.1.0

Table of Contents

 About This Book

 SMILES (Simplified Molecular-Input Line-Entry System)

 Open Babel: The Open Source Chemistry Toolbox

 Using Open Babel Command: "obabel"

Generating SVG Pictures with Open Babel

 "obabel -o svg" - Molecule Picture in SVG

 "obabel -:... -o svg" - Generate SVG from SMILES

 "obabel ... -o svg -xi" - Show Atom Indices in SVG

"obabel ... -o svg -xS" - Ball/Stick Depiction in SVG

 "obabel ... -o svg -xX" - Hide Implicit H in SVG

 "obabel ... -o svg -xC" - Hide Terminal C in SVG

 "obabel ... -o svg -xP300" - Control Image Size

 "obabel ... -o svg" - Two "svg" XML Tag Levels

 "obabel ... -o svg -xd" - Hide Molecule Name

 "babel ... -o svg -xd -xP300" - Open Babel 2.4 Bug

 Scale SVG Images using "viewBox" Attribute

 Substructure Search with Open Babel

 Similarity Search with Open Babel

 Fingerprint Index for Fastsearch with Open Babel

 Stereochemistry with Open Babel

 Command Line Tools Provided by Open Babel

 RDKit: Open-Source Cheminformatics Software

 rdkit.Chem.rdchem - The Core Module

 rdkit.Chem.rdmolfiles - Molecular File Module

 rdkit.Chem.rdDepictor - Compute 2D Coordinates

 rdkit.Chem.Draw - Handle Molecule Images

 Molecule Substructure Search with RDKit

 rdkit.Chem.rdmolops - Molecule Operations

 Daylight Fingerprint Generator in RDKit

 Morgan Fingerprint Generator in RDKit

 RDKit Performance on Substructure Search

 Introduction to Molecular Fingerprints

 OCSR (Optical Chemical Structure Recognition)

 AlphaFold - Protein Structure Prediction

 Resources and Tools

 Cheminformatics Related Terminologies

 References

 Full Version in PDF/EPUB