Hello OB Team,


I am trying to use OpenBabel with Perl bindings in my project. OpenBabel compiled fine, and Perl bindings seem to work. Scripts which create molecules atom by atom work as expected. However, we have a problem when trying to use obConversion.

I have tried to use obConversion in different ways (to read molecule from file, convert from Smiles string, and using different formats). None seem to work for me. The script just executes without any apparent error, but no molecule is loaded in obMol from the data provided.

Here are examples

PROGRAM LISTING #1 (works OK)
-------------------------

#!/usr/bin/perl

use Chemistry::OpenBabel;

my $obMol = new Chemistry::OpenBabel::OBMol;

$obMol->NewAtom();
$numAtoms = $obMol->NumAtoms(); # now 1 atom

my $atom1 = $obMol->GetAtom(1); # atoms indexed from 1
$atom1->SetVector(0.0, 1.0, 2.0);
$atom1->SetAtomicNum(6); # carbon atom

$obMol->NewAtom();
$obMol->AddBond(1, 2, 1); # bond between atoms 1 and 2 with bond order 1
$numBonds = $obMol->NumBonds(); # now 1 bond
print "Atom count: " . $obMol->NumAtoms() . "\n";
print "Bond count: $numBonds \n";
$obMol->Clear();

EXECUTION
-------------------------
myhost:~/build/test # perl 1.pl
Atom count: 2
Bond count: 1

PROGRAM LISTING #2 (fails)
-------------------------

#!/usr/bin/perl

use Chemistry::OpenBabel;

my $obMol = new Chemistry::OpenBabel::OBMol;
my $obConversion = new Chemistry::OpenBabel::OBConversion;
$obConversion->SetInAndOutFormats("smi", "mdl");
$obConversion->ReadString($obMol, "C1=CC=CS1");

$numAtoms = $obMol->NumAtoms(); # now 5 atoms
print "$numAtoms\n";
$obMol->AddHydrogens();
$numAtoms = $obMol->NumAtoms(); # now 9 atoms

my $outMDL = $obConversion->WriteString($obMol);


EXECUTION
-------------------------
myhost:~/build/test # perl 2.pl
0

It shows 0 despite I expect output 5.

We have reproduced the error on two different machines (both are OpenSuSE 11.4, x86_64).

Please also find attached a listing showing OpenBabel building steps.

No ideas why this happens. I really appreciate your help.


Thank you,

Andrey
myhost:~/build/build # cmake -DPYTHON_BINDINGS=ON -DPERL_BINDINGS=ON 
-DPERL_LIBRARY=/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/CORE/libperl.so 
-DPERL_INCLUDE_PATH=/usr/lib/perl5/5.10.0/ ../openbabel-2.3.1
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Using included inchi library.
-- Found LibXml2: /usr/lib64/libxml2.so
-- Found ZLIB: /usr/lib64/libz.so
-- Could NOT find wxWidgets  (missing:  wxWidgets_FOUND)
-- Looking for conio.h
-- Looking for conio.h - not found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for time.h
-- Looking for time.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for rpc/xdr.h
-- Looking for rpc/xdr.h - found
-- Looking for regex.h
-- Looking for regex.h - found
-- Looking for C++ include sstream
-- Looking for C++ include sstream - found
-- Looking for rint
-- Looking for rint - not found.
-- Looking for snprintf
-- Looking for snprintf - found
-- Looking for sranddev
-- Looking for sranddev - not found.
-- Looking for strcasecmp
-- Looking for strcasecmp - found
-- Looking for strncasecmp
-- Looking for strncasecmp - found
-- Looking for dlopen in dl
-- Looking for dlopen in dl - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of clock_t
-- Check size of clock_t - done
-- Performing Test SCANDIR_NEEDS_CONST
-- Performing Test SCANDIR_NEEDS_CONST - Failed
-- Performing Test HAVE_GCC_VISIBILITY
-- Performing Test HAVE_GCC_VISIBILITY - Success
-- Could NOT find Eigen2  (missing:  EIGEN2_INCLUDE_DIR EIGEN2_VERSION_OK)
-- Could NOT find Cairo. PNG output will NOT be supported.
-- Looking for getopt
-- Looking for getopt - found
-- Attempting to build the GUI
--    wxWidgets not found => GUI will not be built
-- CTest cannot determine repository type. Please set UPDATE_TYPE to 'cvs' or 
'svn'. CTest update will not work.
-- Found PythonInterp: /usr/bin/python2.6
-- Could NOT find PythonLibs  (missing:  PYTHON_LIBRARIES PYTHON_INCLUDE_PATH)
-- Python libraries NOT found
-- Found Perl: /usr/bin/perl
-- Found PerlLibs: 
/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/CORE/libperl.so
-- Perl bindings will be compiled
-- Configuring done
-- Generating done
-- Build files have been written to: /root/build/build
myhost:~/build/build #make

<compiles successfully with a lot of warnings like: >
openbabel-perl.cpp:32536: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_SetClosure(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32557: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_UnsetHash(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32564: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_UnsetWedge(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32571: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_UnsetUp(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32578: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_UnsetDown(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32585: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_UnsetAromatic(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32592: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_UnsetKekule(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32599: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_GetIdx(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32607: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_GetId(PerlInterpreter*, CV*)Á-?:
openbabel-perl.cpp:32615: warning: null argument where non-null required 
(argument 1)
openbabel-perl.cpp: In function Á-?void 
_wrap_OBMolBondBFSIter_GetBO(PerlInterpreter*, CV*)Á-?:
<this is a short excerpt>

myhost:~/build/build #make install
< warnings are repeated once again here >
myhost:~/build/build #ldconfig

myhost:~/build/test # cat 1.pl
 #!/usr/bin/perl

 use Chemistry::OpenBabel;

 my $obMol = new Chemistry::OpenBabel::OBMol;

 $obMol->NewAtom();
 $numAtoms = $obMol->NumAtoms(); # now 1 atom

 my $atom1 = $obMol->GetAtom(1); # atoms indexed from 1
 $atom1->SetVector(0.0, 1.0, 2.0);
 $atom1->SetAtomicNum(6); # carbon atom

 $obMol->NewAtom();
 $obMol->AddBond(1, 2, 1); # bond between atoms 1 and 2 with bond order 1
 $numBonds = $obMol->NumBonds(); # now 1 bond
 print "Atom count: " . $obMol->NumAtoms() . "\n";
 print "Bond count: $numBonds \n";
 $obMol->Clear();
myhost:~/build/test # perl 1.pl
Atom count: 2
Bond count: 1

myhost:~/build/test # cat 2.pl
 #!/usr/bin/perl

 use Chemistry::OpenBabel;

 my $obMol = new Chemistry::OpenBabel::OBMol;
 my $obConversion = new Chemistry::OpenBabel::OBConversion;
 $obConversion->SetInAndOutFormats("smi", "mdl");
 $obConversion->ReadString($obMol, "C1=CC=CS1");

 $numAtoms = $obMol->NumAtoms(); # now 5 atoms
 print "$numAtoms\n";
 $obMol->AddHydrogens();
 $numAtoms = $obMol->NumAtoms(); # now 9 atoms

 my $outMDL = $obConversion->WriteString($obMol);
myhost:~/build/test # perl 2.pl
0
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to