Collections:
"-o svg -xd -d" Bug in Open Babel 3.1.1
Why "obabel ... -o svg -xd -d" is not able to remove hydrogens?
✍: FYIcenter.com
It seems to be code bug in the "obabel" command in Open Babel 3.1.1 release.
In Open Babel 3.1.1 release, options -xd and -d are not respected together for SVG output in the "obabel -i sdf -o svg -xC -xt -xP400 -xd -d" command.
For example, the following commands shows you that hydrogens and molecule name are included in the SVG output:
fyicenter$ obabel -V Open Babel 3.1.1 -- Sep 27 2022 -- 18:26:52 fyicenter$ obabel -:C -O carbon.sdf -h --gen2D --title Carbon fyicenter$ cat carbon.sdf | obabel -i sdf -o svg -xC -xt -xP400 <?xml version="1.0"?> <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="200px" height="200px" viewBox="0 0 100 100"> <title>Carbon - Open Babel Depiction</title> <rect x="0" y="0" width="100" height="100" fill="white"/> <g transform="translate(0,0)"> <svg width="100" height="100" x="0" y="0" viewBox="0 0 160.002 149.28" font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="2" stroke-linecap="round"> <line x1="80.0" y1="74.6" x2="107.0" y2="74.6" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="2.0"/> <line x1="80.0" y1="74.6" x2="66.5" y2="51.3" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="2.0"/> <line x1="80.0" y1="74.6" x2="66.5" y2="98.0" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="2.0"/> <line x1="80.0" y1="74.6" x2="53.0" y2="74.6" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="2.0"/> <text x="114.001528" y="82.639914" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="54.000382" y="48.000000" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="54.000382" y="117.279827" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="34.000000" y="82.639914" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> </svg> </g> <text font-size="18.000000" fill ="black" font-family="sans-serif" x="10.000000" y="20.000000" >Carbon</text> </svg>
If you add -xd and -d options to remove molecule name and hydrogens, only -xd is respected. Only molecule name is removed.
fyicenter$ cat carbon.sdf | obabel -i sdf -o svg -xC -xt -xP400 -xd -d <?xml version="1.0"?> <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="400px" height="400px" viewBox="0 0 100 100"> <title>Carbon - Open Babel Depiction</title> <rect x="0" y="0" width="100" height="100" fill="white"/> <g transform="translate(0,0)"> <svg width="100" height="100" x="0" y="0" viewBox="0 0 160.002 149.28" font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="4" stroke-linecap="round"> <line x1="80.0" y1="74.6" x2="107.0" y2="74.6" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="4.0"/> <line x1="80.0" y1="74.6" x2="66.5" y2="51.3" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="4.0"/> <line x1="80.0" y1="74.6" x2="66.5" y2="98.0" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="4.0"/> <line x1="80.0" y1="74.6" x2="53.0" y2="74.6" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="4.0"/> <text x="114.001528" y="82.639914" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="54.000382" y="48.000000" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="54.000382" y="117.279827" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="34.000000" y="82.639914" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> </svg> </g> </svg>
If you add -d and -xd options to remove hydrogens and molecule name, only -d is respected. Only hydrogens are removed.
fyicenter$ cat carbon.sdf | obabel -i sdf -o svg -xC -xt -xP400 -d -xd <?xml version="1.0"?> <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="400px" height="400px" viewBox="0 0 100 100"> <title>Carbon - Open Babel Depiction</title> <rect x="0" y="0" width="100" height="100" fill="white"/> <g transform="translate(0,0)"> <svg width="100" height="100" x="0" y="0" viewBox="0 0 80 80" font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="4" stroke-linecap="round"> <text x="36" y="48" fill="rgb(102,102,102)" stroke-width="0" font-weight="bold" font-size="16" >CH</text> <text x="60" y="51.68" fill="rgb(102,102,102)" stroke-width="0" font-weight="bold" font-size="13" >4</text> </svg> </g> <text font-size="18" fill ="black" font-family="sans-serif" x="10" y="20" >Carbon</text> </svg>
However, in Open Babel 3.1.0, both "obabel -i sdf -o svg -xC -xt -xP400 -d -xd" and "obabel -i sdf -o svg -xC -xt -xP400 -xd -d" commands works as expected. Molecule name and hydrogens are all removed.
fyicenter$ obabel -V Open Babel 3.1.0 -- Jul 19 2021 -- 10:30:02 fyicenter$ obabel -:C -O carbon.sdf -h --gen2D --title Carbon fyicenter$ cat carbon.sdf | obabel -i sdf -o svg -xC -xt -xP400 <?xml version="1.0"?> <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="400px" height="400px" viewBox="0 0 100 100"> <title>Carbon - Open Babel Depiction</title> <rect x="0" y="0" width="100" height="100" fill="white"/> <g transform="translate(0,0)"> <svg width="100" height="100" x="0" y="0" viewBox="0 0 160.002 149.28" font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="4" stroke-linecap="round"> <line x1="80.0" y1="74.6" x2="107.0" y2="74.6" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="4.0"/> <line x1="80.0" y1="74.6" x2="66.5" y2="51.3" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="4.0"/> <line x1="80.0" y1="74.6" x2="66.5" y2="98.0" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="4.0"/> <line x1="80.0" y1="74.6" x2="53.0" y2="74.6" opacity="1.0" stroke="rgb(0,0,0)" stroke-width="4.0"/> <text x="114.001528" y="82.639914" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="54.000382" y="48.000000" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="54.000382" y="117.279827" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> <text x="34.000000" y="82.639914" fill="rgb(191,191,191)" stroke-width="0" font-weight="bold" font-size="16" >H</text> </svg> </g> <text font-size="18.000000" fill ="black" font-family="sans-serif" x="10.000000" y="20.000000" >Carbon</text> </svg> fyicenter$ cat carbon.sdf | obabel -i sdf -o svg -xC -xt -xP400 -xd -d <?xml version="1.0"?> <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="400px" height="400px" viewBox="0 0 100 100"> <title>Carbon - Open Babel Depiction</title> <rect x="0" y="0" width="100" height="100" fill="white"/> <g transform="translate(0,0)"> <svg width="100" height="100" x="0" y="0" viewBox="0 0 80 80" font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="4" stroke-linecap="round"> <text x="36" y="48" fill="rgb(102,102,102)" stroke-width="0" font-weight="bold" font-size="16" >CH</text> <text x="60" y="51.68" fill="rgb(102,102,102)" stroke-width="0" font-weight="bold" font-size="13" >4</text> </svg> </g> </svg> fyicenter$ cat carbon.sdf | obabel -i sdf -o svg -xC -xt -xP400 -d -xd <?xml version="1.0"?> <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="400px" height="400px" viewBox="0 0 100 100"> <title>Carbon - Open Babel Depiction</title> <rect x="0" y="0" width="100" height="100" fill="white"/> <g transform="translate(0,0)"> <svg width="100" height="100" x="0" y="0" viewBox="0 0 80 80" font-family="sans-serif" stroke="rgb(0,0,0)" stroke-width="4" stroke-linecap="round"> <text x="36" y="48" fill="rgb(102,102,102)" stroke-width="0" font-weight="bold" font-size="16" >CH</text> <text x="60" y="51.68" fill="rgb(102,102,102)" stroke-width="0" font-weight="bold" font-size="13" >4</text> </svg> </g> </svg>
⇒ Substructure Search with Open Babel
⇐ "babel ... -o svg -xd -xP300" Bug - Option -d takes a parameter
2023-01-24, 437🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1003325 Names: InChIKey: BANRMMWGANHCDH-UHFFFAOYS A-NSMILES: Cc2ncc(c1cc(F...
Molecule Summary: ID: FYI-1001865 SMILES: [H]/C=N\\\\c1c([H])c([H] )c(-c2c(-c3c([H])c([H])c (/N=C\\\\[...
Molecule Summary: ID: FYI-1000338 SMILES: C1=NC2=C(N1)C(=S)N=C(N2) NReceived at FYIcenter.com on: 20...
Molecule Summary: ID: FYI-1000308 SMILES: CN(C)c1ccc(cc1)/C=C(/C(= O)N/N=C/c2cc(ccc2OC)Br)\ \NC(=O)c3c...
Molecule Summary: ID: FYI-1004117 Names: InChIKey: QBCUUJGHWFKMDC-UHFFFAOYS A-NSMILES: CC(=O)C(O)Cc1...