Closed KeironO closed 7 years ago
Interestingly, the same error occurs if you use openbabel directly.
import openbabel
inchi = "InChI=1S/C21H29NO8/c1-12-10-21(13(2)29-21)19(26)28-16-7-9-22(5)8-6-15(17(16)24)11-27-18(25)20(12,4)30-14(3)23/h6,12-13,16H,7-11H2,1-5H3/b15-6-/t12-,13-,16-,20-,21-/m1/s1"
conv = openbabel.OBConversion()
conv.SetInAndOutFormats("inchi", "smi")
mol = openbabel.OBMol()
ReadString(mol, inchi)
smiles = conv.WriteString(mol).rstrip()
I think there is a problem with the installation somehow. At least it's working fine for me. Do you have the same problem in the commandline?
obabel -iinchi -:"InChI=1S/C21H29NO8/c1-12-10-21(13(2)29-21)19(26)28-16-7-9-22(5)8-6-15(17(16) 24)11-27-18(25)20(12,4)30-14(3)23/h6,12-13,16H,7-11H2,1-5H3/b15-6-/t12-,13-,16-,20-,21-/m1/s1" -osmi
*** Open Babel Error in InChI code
Reading InChI failed
0 molecules converted
Error there too. I used the openbabel package found on the standard Ubuntu repository, if that helps?
Even 2.4.0 used in the openbabel snap package throws an error.
sudo snap install openbabel
openbabel.obabel -iinchi -:"InChI=1S/C21H29NO8/c1-12-10-21(13(2)29-21)19(26)28-16-7-9-22(5)8-6-15(17(16) 24)11-27-18(25)20(12,4)30-14(3)23/h6,12-13,16H,7-11H2,1-5H3/b15-6-/t12-,13-,16-,20-,21-/m1/s1" -osmi
==============================
*** Open Babel Error in InChI code
Reading InChI failed
0 molecules converted
2.4.1 found here throws a similar error:
wget http://ftp.us.debian.org/debian/pool/main/o/openbabel/openbabel_2.4.1-1_amd64.deb
sudo dpkg -i openbabel_2.4.1-1_amd64.deb
obabel -iinchi -:"InChI=1S/C21H29NO8/c1-12-10-21(13(2)29-21)19(26)28-16-7-9-22(5)8-6-15(17(16) 24)11-27-18(25)20(12,4)30-14(3)23/h6,12-13,16H,7-11H2,1-5H3/b15-6-/t12-,13-,16-,20-,21-/m1/s1" -osmi
==============================
*** Open Babel Error in InChI code
Reading InChI failed
0 molecules converted
I'm sorry, there seems to have sneaked in a copy/paste error, there should be no space between "16)" and "24)" that occurs in the line brake in my comment. So the command should be:
obabel -iinchi -:"InChI=1S/C21H29NO8/c1-12-10-21(13(2)29-21)19(26)28-16-7-9-22(5)8-6-15(17(16)24)11-27-18(25)20(12,4)30-14(3)23/h6,12-13,16H,7-11H2,1-5H3/b15-6-/t12-,13-,16-,20-,21-/m1/s1" -osmi
obabel -iinchi -:"InChI=1S/C21H29NO8/c1-12-10-21(13(2)29-21)19(26)28-16-7-9-22(5)8-6-15(17(16)24)11-27-18(25)20(12,4)30-14(3)23/h6,12-13,16H,7-11H2,1-5H3/b15-6-/t12-,13-,16-,20-,21-/m1/s1" -osmi
[1] 9798 segmentation fault (core dumped) obabel -iinchi -osmi
Segmentation fault error.
Or, the same error as in Python...
Ok, the snap version seems to work - but I'm unable to interface with it using python. Any suggestions @fredrikw?
Install Ubuntu snap package via:
sudo snap install openbabel
And use the following script to retrieve SMILES:
from subprocess import check_output
inchi = "InChI=1S/C21H29NO8/c1-12-10-21(13(2)29-21)19(26)28-16-7-9-22(5)8-6-15(17(16)24)11-27-18(25)20(12,4)30-14(3)23/h6,12-13,16H,7-11H2,1-5H3/b15-6-/t12-,13-,16-,20-,21-/m1/s1"
smiles = check_output('openbabel.obabel -iinchi -:"%s" -osmi' %inchi, shell=True).decode().strip()
Environment Information
Open Babel version: Operating system and version: Ubuntu Linux 16.04 LTS
Expected Behavior
The correct conversion of an InChI string to SMILES.
Actual Behavior
Segmentation fault.
Steps to Reproduce
It crashes on the following line in pybel.py (186).