Menu

#991 Universal SMILES with "*" causes executable to abort

2.0_alpha-beta
open
nobody
None
1
2017-03-03
2017-03-03
No

Universal SMILES uses the InChI algorithm to determine the atom ordering. The algorithm does not handle atomic number 0 ("*"). Giving it a molecule with a * causes Open Babel to abort.

>>> import openbabel as ob
>>> import pybel
>>> mol = pybel.readstring("smi", "*")
>>> conv = ob.OBConversion()
>>> conv.SetOutFormat("smi")
True
>>> conv.AddOption("U", conv.OUTOPTIONS)
>>> conv.WriteString(mol.OBMol)
==============================
*** Open Babel Warning  in InChI code
 #0 :Unknown element(s): Xx
==============================
*** Open Babel Error  in InChI code
 InChI generation failed
libc++abi.dylib: terminating with uncaught exception of type std::out_of_range: vector
Abort

Discussion