Hi all,
I was debugging my Python code and I found a behavior that doesn't make much sense to me
unless I'm missing something.
Apparently, available forcefields are not found unless an OBConversion instance is
created. I've made up an example by borrowing some code from Pybel, see attached.
In fact, I've noticed that Pybel does indeed create an instance of it very early, so I'm
wondering if there's an underlying reason for that.
Thanks,
S
--
Stefano Forli, PhD
Staff Scientist
Molecular Graphics Laboratory
Dept. of Integrative Structural
and Computational Biology, MB-112F
The Scripps Research Institute
10550 North Torrey Pines Road
La Jolla, CA 92037-1000, USA.
tel: +1 (858)784-2055
fax: +1 (858)784-2860
email: [email protected]
http://www.scripps.edu/~forli/
import openbabel as ob
import sys
_obfuncs = _obconsts = ob
def _getplugins(findplugin, names):
plugins = dict([(x, findplugin(x)) for x in names if findplugin(x)])
return plugins
def _getpluginnames(ptype):
if sys.platform[:4] == "cli":
plugins = ob.VectorString()
else:
plugins = ob.vectorString()
ob.OBPlugin.ListAsVector(ptype, None, plugins)
if sys.platform[:4] == "java":
plugins = [plugins.get(i) for i in range(plugins.size())]
return [x.split()[0] for x in plugins]
forcefields = [_x.lower() for _x in _getpluginnames("forcefields")]
"""A list of supported forcefields"""
_forcefields = _getplugins(ob.OBForceField.FindType, forcefields)
print "PRE OBCONVERT", forcefields
# THIS DOES THE TRICK?
_obconv = ob.OBConversion()
forcefields = [_x.lower() for _x in _getpluginnames("forcefields")]
"""A list of supported forcefields"""
_forcefields = _getplugins(ob.OBForceField.FindType, forcefields)
print "POST OBCONVERT", forcefields
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
OpenBabel-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-devel