Hi Jurgens,

If you wrap the OBMol with a Pybel Molecule, you can access the
property fields with the .data attribute.

pmol = pybel.Molecule(mol)
pmol.data["Name"] = "My Title"

This changes the underlying OBMol, so 'mol' now has the property
fields. It's probably a good idea to set the molecule title also
(pmol.title = "My Title").

To understand how this all works, just see the code in pybel.py (it's
really quite short).

- Noel

On 16 February 2011 11:56, Jurgens de Bruin <[email protected]> wrote:
> Hi Noel,
>
> I am trying to create 3D sdf from smiles using python and openbabel
> but I am having a bit of a snag:
>
> obConversion = openbabel.OBConversion()
> mol = openbabel.OBMol()
> conv.SetInFormat("smi")
> conv.ReadString(mol, "C(Cl)(=O)CCC(=O)Cl")
> conv.SetOutFormat("sdf")
> OBOp gen3d = OBOp.FindType("Gen3D")
> gen3d.Do(mol)
> obConversion.WriteFile(mol, 'Name.sdf')
>
> Then I would also like to add the molecule name as property to the SDF
> can this be done?
>
>
> Thanks in advance
>
> --
> Regards/Groete/Mit freundlichen Grüßen/recuerdos/meilleures salutations/
> distinti saluti/siong/duì yú/привет
>
> Jurgens de Bruin
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> OpenBabel-scripting mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openbabel-scripting
>

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
OpenBabel-scripting mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-scripting

Reply via email to