openbabel / openbabel

Open Babel is a chemical toolbox designed to speak the many languages of chemical data.
http://openbabel.org/
GNU General Public License v2.0
1.08k stars 414 forks source link

Open Babel Error in OpenBabel::OBBuilder::GetFragmentCoord Rigid fragment C1CCCNC1 in rigid-fragments.txt has all zero coordinates #2356

Open StashOfCode opened 3 years ago

StashOfCode commented 3 years ago

Environment Information

Open Babel version: 3.1.0 Operating system and version: Windows 10

Expected Behavior

mol = pybel.readstring("smi", 'BrC/C=C/c1ccc(O[C@@H]2CCCNC2)cc1')
mol.make3D()

Actual Behavior

jupyter lab Kernel dies with this output in the cmd

Open Babel Error  in OpenBabel::OBBuilder::GetFragmentCoord
Rigid fragment C1CCCNC1 in rigid-fragments.txt has all zero coordinates
welcome[bot] commented 3 years ago

Thanks for opening your first issue here! Be sure to follow the issue template!

StashOfCode commented 3 years ago

Try this one too. Babel hangs with it forever BrC/C=C/c1ccc(O[C@@H]2C[C@H]3CC[C@H]2NC3)cc1. "smilies to sdf" with "generate 3d coords" checked

HuMuK commented 2 years ago

Open Babel 3.1.1 has the same problem when generating 3d structure (does not matter the output format) from .smi files.

PatReis commented 2 years ago

Is there a at least a way to catch this error without resorting to subprocesses?

try:
    mol = pybel.readstring("smi", 'BrC/C=C/c1ccc(O[C@@H]2CCCNC2)cc1')
    mol.make3D()
except:
    print("failed")

This does not work

PatReis commented 2 years ago

okay you can check if BABEL_DATADIR is correctly set (assuming you have conda install). This worked for me (setting manually).

import os
os.environ["BABEL_DATADIR"] = "C:\Users\...\anaconda3\envs\...\share\openbabel"  # Adjust for your conda path
import openbabel
import openbabel.pybel as pybel
mol = pybel.readstring("smi", 'BrC/C=C/c1ccc(O[C@@H]2CCCNC2)cc1')
mol.make3D()
print("everything is fine.")
mainguyenanhvu commented 2 weeks ago

Hi, I understand that with this case, there is no way for us to convert 3D structure by using pybel. Is it right?

fredrikw commented 2 weeks ago

No, normally it works. You just need to make sure that the BABEL_DATADIR environmental variable is set correctly. How you do that depends on your installation method, see e.g. https://openbabel.org/docs/Installation/install.html#troubleshooting-build-problems