Cheminformatics Tutorials - Herong's Tutorial Examples - v2.01, by Herong Yang
"obabel ... -o svg" - Two "svg" XML Tag Levels
This section provides a quick introduction of two 'svg' tag levels used in the SVG XML source code generated by Open Babel 'obabel ... -o svg' command.
If you are using Open Babel 2.4.1 or higher, you will notice that there are two "svg" tag levels in SVG XML source code generated by the "obabel" command.
The main reason for using two "svg" tag levels is for including multiple molecules in a single SVG file so that:
For example, the following command generates a SVG picture contains 66 molecules:
herong$ obabel mol-*.sdf -O multi-molecules.svg 66 molecules converted
If you open the SVG file, multi-molecules.svg, in a text editor, you will see the following two-level "svg" tag structure:
<svg version="1.1" id="topsvg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:cml="http://www.xml-cml.org/schema" x="0" y="0" width="100%" height="100%" viewBox="0 0 100 88"> <title>Multiple Molecules - Open Babel Depiction</title> <rect x="0" y="0" width="100" height="88" fill="white"/> <g transform="translate(0,0)"> <svg width="11.1111" height="11.1111" x="0" y="0" viewBox="0 0 425.571 500.005" font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="2" stroke-linecap="round"> <line x1="247.8" y1="160.0" x2="282.5" y2="180.0" stroke="rgb(0,0,0)" stroke-width="2.0"/> <line x1="178.6" y1="160.0" x2="155.2" y2="173.5" stroke="rgb(0,0,0)" stroke-width="2.0"/> ... </svg> </g> <g transform="translate(11.111111,0.000000)"> <svg width="11.111111" height="11.111111" x="0" y="0" viewBox="0 0 426.667619 477.075053" font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="2.000000" stroke-linecap="round"> <line x1="248.0" y1="100.0" x2="282.7" y2="80.0" stroke="rgb(0,0,0)" stroke-width="2.0"/> <line x1="282.7" y1="80.0" x2="306.1" y2="93.5" stroke="rgb(0,0,0)" stroke-width="2.0"/> ... </svg> </g> </svg>
As you can see, the two-level "svg" tag structure works nicely for multiple molecules:
However, for a single molecule, Open Babel still uses this two-level "svg" structure, which is unnecessary and confusing.
Also note that if you have a script that parses SVG files generated from older versions of Open Babel, your script may fail. Because Open Babel 2.3.1 was generating a one-level "svg" structure if there is only one molecule.
Table of Contents
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