On 7 May 2010 17:47, Leonid Chepelev <leonid.chepe...@gmail.com> wrote: > Hello, > > (Sorry I posted this on Nabble OpenBabel forum already, but that seems to be > simply an archive of this list.)
It should have appeared here - must be some problem. > I would like to convert SMILES strings to their 3D forms in the SDF format. > However, the difficulty is that I am now forced to use the Java API of > OpenBabel to do this. > > One approach would be to use the class OBBuilder to build 3D structures. > However, this class seems to not be present in the Java API of openbabel, > making it impossible to use. Yes - it'll be there in the next release though. In the meanwhile you need to use the Gen3D Operation with code something similar to the following Python code: gen3d = openbabel.OBOp.FindType("Gen3D") gen3d.Do(myOBMol) > Another approach would be to generate the 3D structure with converter > options, as is shown in the following code. > > import org.openbabel.*; > > public class Main { > public static void main(String[] args) { > System.loadLibrary("openbabel_java"); > OBConversion conv = new OBConversion(); > OBMol mol = new OBMol(); > conv.SetInFormat("smi"); > conv.ReadString(mol, "C(Cl)(=O)CCC(=O)Cl"); > conv.SetOutFormat("sdf"); > conv.SetOptions("gen3D", OBConversion.Option_type.OUTOPTIONS); > System.out.print(conv.WriteString(mol)); > } > } > > However, the problem is that the gen3D option does not seem to have any > effect (with INOPTION and GENOPTION option types), and the result is quite > unexpected with OUTOPTION, as follows. > > > OpenBabel05071010562D > > 0 0 0 0 0 999 V3000 > M V30 BEGIN CTAB > M V30 COUNTS 8 7 0 0 0 > M V30 BEGIN ATOM > M V30 1 C 0 0 0 0 > M V30 2 Cl 0 0 0 0 > M V30 3 O 0 0 0 0 > M V30 4 C 0 0 0 0 > M V30 5 C 0 0 0 0 > M V30 6 C 0 0 0 0 > M V30 7 O 0 0 0 0 > M V30 8 Cl 0 0 0 0 > M V30 END ATOM > M V30 BEGIN BOND > M V30 1 1 1 2 > M V30 2 2 1 3 > M V30 3 1 1 4 > M V30 4 1 4 5 > M V30 5 1 5 6 > M V30 6 2 6 7 > M V30 7 1 6 8 > M V30 END BOND > M V30 END CTAB > M END > $$$$ > > Would you happen to know what is going on? Am I doing something wrong? Or > perhaps the 3D generation capability is not yet available through the > OpenBabel Java API, in which case I would have to do SYSTEM calls? Perhaps I > should use the CDK 3D structure generator as an alternative? > > Thank you very much for any help. > ------------------------------------------------------------------------------ > > > _______________________________________________ > OpenBabel-discuss mailing list > OpenBabel-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > > ------------------------------------------------------------------------------ _______________________________________________ OpenBabel-discuss mailing list OpenBabel-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbabel-discuss