[gmx-developers] Python interface for Gromacs

Roland Schulz roland at utk.edu
Wed Apr 8 11:36:05 CEST 2009


Hi,

I added a little bit wrapper code to easily access the atom information in
tpx. I attached the version. It is backward compatible and allows:
f = tpxfile("test/topol.tpr")
#iterate over atoms
for a in f:
  print
a.x[0],a.x[1],a.x[2],a.m,a.atomname,a.atomtype,a.type,a.resname,a.q,a.chain,a.radius
#you can also access atoms by index
print f[9].m   #mass just as example

It would be great if you could put your code under some open source license.
And a software repository would be great too (so we don't have to send
around tgz files) ;-).

Answers to your points below.

On Sun, Mar 29, 2009 at 7:14 AM, Martin Höfling <martin.hoefling at gmx.de>wrote:

> Am Samstag, den 28.03.2009, 17:55 -0400 schrieb Roland Schulz
>
>  I would be interested in collaborating in extending it to make it
>> pytonic by e.g. creating classes , writing iterators, and converting
>> all c data structures into best fitting NumPy/Python data structure,
>> writing __str__ methods, raising exceptions instead of returning
>> errorcode,...
>>
>> I think this can be done pretty quickly because the number of function
>> which make sense to export is not that large.
>>
>> Is someone else interested in that?
>>
>
> Besides me - Daniel Seeliger who wrote pymacs might be. He also has more
> expertise in writing ugly c-wrappers for python objects. I only did it
> the ctypes way so far and numpy is a different story...


I'm open to Daniel's library approach. My atom wrapper can be easily also
used for a c-wrapper. I just thing ctypes is most convenient.

Apart from that,  the embedding of a python interpreter into mdrun would be
> very interesting, which actually shouldn't be too hard.
>
> then start mdrun with something like:
>
> mpirun -np 64 mdrun_mpi -v -npy 10000 -py do_nasty_things_in_python.py
>
> Doing a normal mdrun and calls an external script every 10000 steps.
>

I don't think you can use ctypes for that, can you?  Of course (indepement
of the python wrapper method) you would as easily segv mdrun as by adding
C-code ;-).

Roland



-- 
ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
865-241-1537, ORNL PO BOX 2008 MS6309
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-developers/attachments/20090408/cbfd3e03/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: grompy-dist.tgz
Type: application/x-gzip
Size: 6925 bytes
Desc: not available
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-developers/attachments/20090408/cbfd3e03/attachment.tgz>


More information about the gromacs.org_gmx-developers mailing list