From: Jérôme H. <j...@hm...> - 2008-10-13 13:13:47
|
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? Help will be very much appreciated. Thanks a lot, Jerome. |
From: Noel O'B. <bao...@gm...> - 2008-10-14 10:30:40
|
Just tested from Python and doesn't seem to work either. In fact, a nice way of generating a segfault is to call obconversion.GetOptions(). This sounds like a serious problem, so I wouldn't be hopeful there is a workaround. I'll file a bug... Noel 2008/10/13 Jérôme Hert <j...@hm...>: > 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? > > Help will be very much appreciated. > Thanks a lot, > Jerome. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > OpenBabel-scripting mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > |
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 |
From: Noel O'B. <bao...@gm...> - 2008-10-14 10:43:10
|
The enum part is fine. e.g. openbabel.OBConversion.GENOPTIONS is 1, etc. Even if you use this, you get a segfault. 2008/10/14 Chris Morley <c.m...@ga...>: > 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 > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > OpenBabel-scripting mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openbabel-scripting > |