From: Chris M. <c.m...@ga...> - 2008-10-14 10:38:21
|
Jérôme Hert wrote: > Dear Colleaugues, > > I was trying to use an option when converting a file into a different > format. > > I use Perl so I write something like > use Chemistry::OpenBabel; > my $obMol = new Chemistry::OpenBabel::OBMol; > my $obConversion = new Chemistry::OpenBabel::OBConversion; > $obConversion->SetInAndOutFormats( "mol2", "pdb" ); > $obConversion->ReadFile( $obMol, "infile.mol2"); > $obConversion->WriteFile( $obMol, "outfile.pdb" ); > > That works fine. > > Now I am trying to add something like: > $obConversion->AddOption("d"); > before reading thr file in, the program doesn't complain but nothing > happens (i.e., the hydrogens are still present in the output file). > > Anybody has any idea how these options are named? Any has any clue about > all those GetOptions, SetOption, GetOptions etc of that class in Perl? > In C++ it would be necessary to use: obConversion->AddOption("d", OBConversion::GENOPTIONS); where the second parameter is an enum. I don't know how this is translated with the scripting interfaces. There are three types of option INOPTIONS, OUTOPTIONS and GENOPTIONS. On the babel command-line the INOPTIONS, OUTOPTIONS have a prefix, e.g. -as and -xn respectively. The default for this function is OUTOPTIONS, but -d needs GENOPTIONS. Multi-character options are all GENOPTIONS. It's a bit confusing for the scripting interface user, and perhaps we need something like AddGenOption("d") You could also use a direct function call of DeleteHydrogens(). Chris |