Use "ok = $obconversion->SetInFormat("sdf")" I presume this returns false.
Does a single .so build help? - Noel On 12 June 2013 19:42, Craig James <cja...@emolecules.com> wrote: > After struggling for two days to get my own swig Perl wrappers to work, I > decided to start with OpenBabel's and work backwards. However, I can't even > get OpenBabel's perl bindings to work. It seems to be the exact same > problem: it can't find the plug-ins. > > One detail. The default configuration installed the OpenBabel.pm module in > /usr/local/openbabel/lib, but since the module is called > "Chemistry::OpenBabel", I had to create a subdirectory > /usr/local/openbabel/lib/Chemistry, and move the OpenBabel.pm file to that. > Once I did that, perl was able to find it. > > Functions that just manipulate the atoms and bonds directly work. But > OBConversion just fails. This example prints the number of atoms and bonds, > but won't print the SMILES: > > use lib '/usr/local/openbabel/lib'; > 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 > $numAtoms = $obMol->NumAtoms(); # now 5 atoms > print "numAtoms: $numAtoms, numBonds: $numBonds\n"; > > my $obConversion = new Chemistry::OpenBabel::OBConversion; > $obConversion->SetInAndOutFormats("smi", "smi"); > my $smiles = $obConversion->WriteString($obMol); > > print "smiles: $smiles\n"; > > Output is: > numAtoms: 2, numBonds: 1 > ============================== > *** Open Babel Error in RegisterOptionParam > The number of parameters needed by option "a" in API differs from an > earlier registration. > smiles: > > And this example doesn't do anything; the ReadFile() returns "at end" > immediately: > > use lib '/usr/local/openbabel/lib'; > use Chemistry::OpenBabel; > > my $obconversion = new Chemistry::OpenBabel::OBConversion; > $obconversion->SetInFormat("sdf"); > my $obmol = new Chemistry::OpenBabel::OBMol; > > my $notatend = $obconversion->ReadFile($obmol, > "../chemistry/test/test.smi"); > while ($notatend) { > print "mwt: ", $obmol->GetMolWt(), "\n"; > $obmol->Clear(); > $notatend = $obconversion->Read($obmol); > } > > There are no errors or warnings. Any thoughts? > > Thanks, > Craig > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Windows: > > Build for Windows Store. > > http://p.sf.net/sfu/windows-dev2dev > _______________________________________________ > OpenBabel-Devel mailing list > OpenBabel-Devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-devel > ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ OpenBabel-Devel mailing list OpenBabel-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-devel