Open daemonice opened 4 years ago
Im not sure if it is just gen3d
When trying to install our software stack mosdef with the follow commands in conda:
conda create -n test37 python=3.7
conda activate test37
yes | conda install -c mosdef -c omnia -c conda-forge mbuild foyer openmm openbabel
python -c "import openbabel"
This causes a segmentation fault as well.
Let's talk on-list (openbabel-devel at lists.sourceforge.net) - based on your code here, you're using an old (pre 3.0) version of Open Babel.
The new binding is:
from openbabel import openbabel
# or
from openbabel import pybel
See https://open-babel.readthedocs.io/en/latest/UseTheLibrary/migration.html#migrating-to-3-0
@ghutchis I get the same error as the OP in Python 3 (using the modern import style) with the latest version from conda-forge. I couldn't find the discussion on the mailing list. Has any progress been made diagnosing/fixing the issue?
@dww100 - the current master
has a fix - but I don't know if conda-forge
tracks that. We will have a 3.0.1 release fairly soon with that and other fixes.
Thanks for the information
@dww100 - can you try this with 3.1.1 or master
- it should be fixed and I'd like to close this.
@ghutchis I tried this with 3.1.1 from conda-forge and still have the same seg fault issue.
+1 to crash still happening
I am using the Perl bindings with version 3.1.1 and only see crashes with gen3d. But, when I do the FF optimization that gen3D does (according to the source code), I do not have problems. To me it seems to be a problem with the stereochemistry checks. Since I start with connectivity only, stereochemistry does not matter. I am on Debian Linux, latest version, openbabel installed from source as there are no up-to-date packages.
The following works for me in Open Babel 3.1.0 -- Nov 21 2020 -- 20:38:43 MacOS 11.2.1
import sys
sys.path.append('/usr/local/lib/python3.9/site-packages')
import pandas as pd
from openbabel import openbabel
from openbabel import pybel
gen3d = openbabel.OBOp.FindType("gen3D")
excel_file = 'test_data/blah.xlsx'
df = pd.read_excel(excel_file)
#print(df.columns)
smiles = df['SMILES ']
#print(smiles[0])
dummy_file_cml_fp2 = pybel.Outputfile('vmol', 'test_data/test_gen3d.vmol', overwrite=True)
mymol = pybel.readstring("smi", smiles[0])
#print(type(mymol.OBMol))
gen3d.Do(mymol.OBMol, "--best")
#mymol.localopt(forcefield='mmff94', steps=1000)
dummy_file_cml_fp2.write(mymol)
#
If I try to run it without an option I also get a segmentation fault. If I run it with an option then it no longer fails for me. I do not believe the option above is actually executing though. The execution time seems much too quick for the --best option. The output shape seems ok. If I run it without the dashes it takes much longer to execute (making me think the option is executing) however the shape I get does not match the command line version of --gen3d --best. If I run with the "fastest" option I do not get 3d coordinates. If I run with the "slowest" option it also takes longer to execute but again the shape does not seem correct when compared to the command line version.
My guess is that it is not defaulting to the --medium value when no option is passed. Or there is a check for the option happening and if no string is passed in python something is going on when using the swig conversion.
After some more investigation:
There seems to be some conflicting documentation on the use of the options. https://open-babel.readthedocs.io/en/latest/Command-line_tools/babel.html#minimize-option https://open-babel.readthedocs.io/en/latest/3DStructureGen/SingleConformer.html#conformer-searching
When I run without the dashes on the command line the best option does run much slower but produces an unexpected result. When running with the --best option, it seems (based off execution time) to be using the default but produces an expected result. The results from the command line seem to match the results from the python script.
Can anyone point me to the source for the gen3d Op. I've looked for a couple of hours and have not been able to find it.
Environment Information
Open Babel version: openbabel 3.0.0 Operating system and version: Ubuntu 18.04, Python 2.7.17
I want to generate a reasonable 3D structure from SMILES string (take 'C1CCCC1' for example here). The command line "echo C1CCCC1 | obabel -ismi -omol -Otemplate.mol --gen3D" works well. But when I try to do that in Python, "Segmentation fault" occured.
The code is shown below:
I'm not sure if there is something wrong in my code or there is a bug.