Hi Daniel,
You diagnosed the problem exactly. If a function returns a C array, it
cannot be accessed (currently) from Python. So you will have to loop
over each atom, but that should not be any problem. For example:
molcoords = [atom.coords for atom in mol]
To store all of the coordinates for all of the molecules in a file:
allcoords = [[atom.coords for atom in mol] for mol in
pybel.readfile("sdf", "myfile.sdf")]
- Noel
2010/11/5 Daniel Álvarez García <[email protected]>:
> Hello there,
>
> I'm new using pybel/openbabel and I encountered a problem that i don't know
> how to solve...
> I want to retrieve all the 3D coordinates for a molecule in a SDF file. So I
> used mol.OBMol.GetCoordinates()
> and all i got was this:
>
> <Swig Object of type 'double *' at 0xe55bd0>
>
> So, i guess this is a pointer to the actual values returned by the C
> function and that SWIG does not know how to treat.
> Is there any way to work this out?
> I tried using numpy arrays as i did in some other ocassion i had a similar
> issue, but this time it's not working :)
>
> I would appreciate some help! Or finally i will have to loop over each atom.
> But it's not practical for retrieving coordinates of 100 molecules...
>
> Thanks in advance!
>
> --
> Daniel
>
> ------------------------------------------------------------------------------
> Centralized Desktop Delivery: Dell and VMware Reference Architecture
> Simplifying enterprise desktop deployment and management using
> Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
> client virtualization framework. Read more!
> http://p.sf.net/sfu/dell-eql-dev2dev
> _______________________________________________
> OpenBabel-scripting mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openbabel-scripting
>
>
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
OpenBabel-scripting mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-scripting