Hi Markus, In the world of Open Babel, "gen3d" is an 'operation' rather than an input or output option. These are only triggered when using OBConversion::Convert, which is not very friendly for Python use (we should do something about this). Anyway, you just need to trigger the operation yourself on the molecule after reading it in, e.g. gen3d = openbabel.OBOp.FindPlugin("gen3d") and then gen3d.Do(mol.OBMol).
And just to note in passing that you can simplify things a bit by using Pybel to write out the file, e.g. out = mol.write("mop", opt={"k":"MYKEYWORDS"}), rather than messing around with OBConversion. - Noel On Wed, 8 Jan 2020 at 01:03, Markus Grimm via OpenBabel-discuss < openbabel-discuss@lists.sourceforge.net> wrote: > Hello everyone, > I'm trying to generate some mopac files with some specified key words from > smiles. In obabel in the command line I use the following code for instance: > > *obabel -:"C=C(C)CCC" -xk "SYMMETRY PM7 UHF STATIC" -omop -OE1.mop --gen3D* > > Now I'm trying to reproduce this in Pybel. SO far I have the following > code with the corresponding output: > > > > > > > > > > > > > > > *import pybel# Set up converterconv = > pybel.ob.OBConversion()conv.SetOutFormat("mop")conv.AddOption("k", > conv.OUTOPTIONS, "SYMMETRY PM7 UHF STATIC")conv.AddOption("gen3d", > conv.OUTOPTIONS)#conv.Convert()# Get a moleculemol = readstring("smi", > "C=C(C)CCC")output = conv.WriteString(mol.OBMol)print (output)* > > Output E1.mop file: > > SYMMETRY PM7 UHF STATIC > > > C 0.00000 1 0.00000 1 0.00000 1 > C 0.00000 1 0.00000 1 0.00000 1 > C 0.00000 1 0.00000 1 0.00000 1 > C 0.00000 1 0.00000 1 0.00000 1 > C 0.00000 1 0.00000 1 0.00000 1 > C 0.00000 1 0.00000 1 0.00000 1 > > As you can see the generated E1.mop file has no 3D coordinates. Every atom is > on the same position. > > How can I incorporate the option gen3D in pybel for the generation of valid > mopac files? > > Thank you very much in advance for any help! > > Best regards, > > Markus Grimm > > _______________________________________________ > 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