That may not be of much help, but the same happens to me with Java bindings and 
the provided OBTest.java snippet.

OBConversion c = new OBConversion();
   OBMol mol = new OBMol();

   System.out.println("Mol: "+mol);
   System.out.println(c.SetInFormat("SMILES"));
   System.out.println(c.ReadString(mol, "c1ccccc1"));
   System.out.println("Benzene has " + mol.NumAtoms()
+ " atoms.");


The output there is also "Benzene has 0 atoms".

Cheers,

Alex


--
Alexander G. Klenner
Fraunhofer-Institute for Algorithms and Scientific Computing (SCAI)
Schloss Birlinghoven, D-53754 Sankt Augustin
Tel.: +49 - 2241 - 14 - 2736
E-mail: [email protected]
Internet: http://www.scai.fraunhofer.de


----- Original Message -----
From: "Бодров Андрей" <[email protected]>
To: [email protected]
Sent: Monday, November 21, 2011 6:43:30 PM
Subject: [Open Babel] Problem with ObConversion and Perl bindings.



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 
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to