Hi all, I’ve run into a strange bug with the Pybel bindings of OpenBabel. I’m using version OpenBabel 2.3.2 installed from Macports (https://www.macports.org/ports.php?by=name&substr=openbabel) on Mac OS X 10.10.1 with Python 2.7.9. I’ve also attempted to compile and install OpenBabel (with Python bindings) from git myself, which wasn’t quite successful as it wasn’t installing the python bindings in the right place. I haven’t been able to rule out that there is some dependency confusion going on, but I’ve gone through and tried to clean it up so it *should* be using the Macports compiled versions of everything. The bug: I’ve found that whether or not Pybel works seems to be stochastic. This seems to be an older bug as this:http://forums.openbabel.org/Pybel-on-Python3-Mavericks-td4657100.html reports the same problem, but in my case I’m not using Python3. I’m loading two molecules (one heavy isotope labeled, one not) from a .SDF file. See attached for both the .sdf file and the python script. The same python script can work flawlessly, or breaks with an error upon Pybel import, without any changes on my part. Here is my very simple script: ' import openbabel import pybel print 'Script starting' molecule_list = list(pybel.readfile('sdf','/Users/tim/Dropbox/source/Bioinformatics/emzed_developlment/Necine.sdf')) for molecule in molecule_list: print 'Formula:',molecule.formula,'Exact mass:',molecule.exactmass for atom in molecule: if atom.isotope != 0: print atom.isotope print 'Script ending' ' And the execution, with the first execution working without error and the second failing stochastically: ' tim:build tim$ python /Users/tim/Dropbox/source/Bioinformatics/emzed_developlment/parse_sdf.py Script starting Formula: C8H15NO Exact mass: 143.115753836 13 15 Formula: C8H15NO Exact mass: 141.115364105 Script ending tim:build tim$ python /Users/tim/Dropbox/source/Bioinformatics/emzed_developlment/parse_sdf.py Traceback (most recent call last): File "/Users/tim/Dropbox/source/Bioinformatics/emzed_developlment/parse_sdf.py", line 2, in <module> import pybel File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pybel.py", line 87, in <module> descs = _getpluginnames("descriptors") File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pybel.py", line 85, in _getpluginnames return [x.split()[0] for x in plugins] IndexError: list index out of range Midgard:build tim$ ' Based on this post: http://forums.openbabel.org/Pybel-on-Python3-Mavericks-td4657100.html, it seems like this might be a bug with the C++ library on Mac OS X. Any thoughts? Best, -Tim Timothy R. Fallon Graduate Student Laboratory of Jing-Ke Weng Department of Biology MIT 508-274-1995 |
Necine.sdf
Description: chemical/molfile
import openbabel import pybel
print 'Script starting' molecule_list = list(pybel.readfile('sdf','/Users/tim/Dropbox/source/Bioinformatics/emzed_developlment/Necine.sdf')) for molecule in molecule_list: print 'Formula:',molecule.formula,'Exact mass:',molecule.exactmass for atom in molecule: if atom.isotope != 0: print atom.isotope print 'Script ending'
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------------ Dive into the World of Parallel Programming! The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss