2 # -*- mode: python; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
6 # Copyright (c) Erik Lindahl, David van der Spoel 2003-2007.
7 # Coordinate compression (c) by Frans van Hoesel.
8 # Python wrapper (c) by Roland Schulz
10 # IN contrast to the rest of Gromacs, XDRFILE is distributed under the
11 # BSD license, so you can use it any way you wish, including closed source:
13 # Permission is hereby granted, free of charge, to any person obtaining a
14 # copy of this software and associated documentation files (the "Software"),
15 # to deal in the Software without restriction, including without limitation
16 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 # and/or sell copies of the Software, and to permit persons to whom the
18 # Software is furnished to do so, subject to the following conditions:
20 # The above copyright notice and this permission notice shall be included in
21 # all copies or substantial portions of the Software.
23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 # DEALINGS IN THE SOFTWARE.
34 #you have to compile with --enable-shared
35 #and have libxdrfile.so in the LD_LIBRARY_PATH
38 print "Missing file argument\nUsage: sample.py FILE"
42 x
=xdrfile(sys
.argv
[1])
43 for f
in x
: #iterates frames
44 print "%8s %8s %8s %8s Step: %8d "%("Atom","X","Y","Z",f
.step
) #print header
45 for i
,a
in enumerate(f
.x
): #iterate atoms
46 print "%8d %8.1f %8.1f %8.1f"%(i
+1,a
[0],a
[1],a
[2]) #print atom number, x, y, z