Have you initialised an OBConversion() object first? This loads the
plugins. Also, in our own Python bindings we need to set some "dl"
flags: see lines 73 to 84 at
http://openbabel.svn.sourceforge.net/viewvc/openbabel/openbabel/trunk/scripts/CMakeLists.txt?revision=4286&view=markup.

- Noel

On 18 November 2010 01:35, Imran Haque <[email protected]> wrote:
> Hi,
>
> I have a large set of C++ molecule-manipulation libraries that
> internally use OpenBabel to handle molecule input and structure, and I'm
> trying to wrap them into a Python library using standard Python C API
> techniques. These routines work fine when called from a C program, but
> when called from the .so used for the Python library,
> OBConversion::FindFormat segfaults. I don't know how to follow the code
> path in the source code, as it appears to be generated by macros and
> eventually calls down into an independent set of .so's for each file
> format. Does anyone know how to get the molecule loader routines to work
> from dynamic libraries?
>
> I've put up a minimal test case at
> http://cs.stanford.edu/people/ihaque/ob_bug_repro.tar. You may have to
> adjust the paths in the Makefile to correspond to your Python and OB
> installations. Here's sample output (note that I added a tracing printf
> to OBConversion::FormatFromExt that isn't in the mainline OB 2.3.0 source):
>
> $ python numatoms.py test.sdf
> Molecule hasFilename test.sdf
> FormatFromExt calling FindFormat with arg sdf
> Segmentation fault
>
> $ ./numatoms test.sdf
> Filename test.sdf
> FormatFromExt calling FindFormat with arg sdf
> Detected format: MDL MOL format
> Reads and writes V2000 and V3000 versions
> Read Options, e.g. -as
>  s  determine chirality from atom parity flags
>        This is valid only for 0D information. Atom
>        parity is always ignored on reading for MOL files
>        containing 2D or 3D information.
>  T  read title only
>  P  read title and properties only
>        When filtering an sdf file on title or properties
>        only, avoid lengthy chemical interpretation by
>        using the T or P option together with copy format.
>
> Write Options, e.g. -x3
>  3  output V3000 not V2000 (used for >999 atoms/bonds)
>  m  write no properties
>  w  recalculate wedge and hash bonds(2D structures only)
>  A  output in Alias form, e.g. Ph, if present
>
>
> Molecule has 27 atoms.
>
>
> Thanks,
>
> Imran Haque
> http://cs.stanford.edu/people/ihaque
> [email protected]
>
>
> PS - Using Pybel is not an option here because I don't want to
> reimplement all the C++ functionality in Python - I just need to be able
> to call into it.
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> OpenBabel-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to