From: Kieron T. <kr...@so...> - 2007-02-05 14:54:52
|
I've written some working code for assigning atom types for the various forcefields by Perl API. It's pretty simple, but there are differences from the v2.02 API. I get the following error with each atom, even though it performs the appropriate transformation. I am uncertain what it is trying to do that fails. Error: ============================== *** Open Babel Warning in Translate Cannot perform atom type translation: table cannot find requested types. I have a feeling I may be trying to get it to do the translation twice. Line 23 of my code $newtype = $atom_typer->Translate($type); does not match the API documentation which claims to return Boolean from the Translate call, rather than the new atom type. Here's the code: --------------- #!/usr/bin/perl use strict; use Chemistry::OpenBabel; my $obMol = new Chemistry::OpenBabel::OBMol; my $obConverter = new Chemistry::OpenBabel::OBConversion; $obConverter->SetInAndOutFormats("xyz","mol2"); $obConverter->ReadFile($obMol,"file.xyz"); my $atom_typer = new Chemistry::OpenBabel::OBTypeTable; $atom_typer->SetFromType("INT"); $atom_typer->SetToType("DRE"); # DRE = Dreiding, INT = internal, others found in # OpenBabel/data/types.txt for (1..$obMol->NumAtoms() ) { my $atom = $obMol->GetAtom($_); my $type = $atom->GetType(); my $newtype = $atom_typer->Translate($type); $atom->SetType($newtype); } $obConverter->WriteFile($obMol, "typed_molecule.mol2") ; ----end-of-Perl--------- Any ideas what I'm missing here? Thanks, Kieron |