[gmx-users] Can not open file: traj.xtc

Sabrina Kemmerer sabrina at kemmerer-web.de
Sun Feb 17 19:04:09 CET 2013


On 02/17/2013 04:16 PM, Justin Lemkul wrote:
>
>
> On 2/17/13 10:11 AM, Sabrina Kemmerer wrote:
>> Hi,
>>
>> the 'ls -lh' output is
>>
>> -rw-r--r-- 1 sabrina sabrina   32 Feb 11 19:49 c8vectors.ndx
>> -rw-rw-r-- 1 sabrina sabrina 7.8M Jan 19 18:54 confout.gro
>> -rw-r--r-- 1 sabrina sabrina   33 Feb 11 19:49 labelvektors.ndx
>> -rw-r--r-- 1 sabrina sabrina   33 Feb 11 19:49 ligebene.ndx
>> -rw-r--r-- 1 sabrina sabrina   24 Feb 11 19:49 tailvec2.ndx
>> -rw-r--r-- 1 sabrina sabrina   22 Feb 17 15:20 tailvec.ndx
>> -rw-r--r-- 1 sabrina sabrina 3.2M Feb 11 19:48 topol.tpr
>> -rw-rw-r-- 1 sabrina sabrina   43 Feb 17 11:27 traj.md5
>> -rw-r--r-- 1 sabrina sabrina  21G Feb 11 03:56 traj.xtc
>>
>> The commands, which I used, were:
>> g_rotacf -f traj.xtc -n ligebene.ndx
>> g_rotacf -n ligebene.ndx
>>
>> The exact output part is
>>
>> Group     0 (          ebene) has     6 elements
>> There is one group in the index
>> Reading file topol.tpr, VERSION 4.5.4 (single precision)
>>
>> -------------------------------------------------------
>> Program g_rotacf, VERSION 4.5.4
>> Source code file:
>> /PathToGromacsSource/Gromacs4.5.4-src/gromacs-4.5.4/src/gmxlib/gmxfio.c, 
>> line: 519
>>
>> Can not open file:
>> traj.xtc
>>
>> Thank you for your help!
>>
>
> With a file that is 21 GB in size, I suspect all Gromacs programs are 
> going to have issues related to memory availability.  What does 
> gmxcheck tell you about the file?  Can you use trjconv to produce a 
> short trajectory (just a few frames) and run g_rotacf on that 
> shortened trajectory?  If so, the problem is that the file is too 
> large to be dealt with.
>
> -Justin
>
Thanks for that hint, Justin! Neither gmxcheck nor trjconv could handle 
the file. I used this python code

#!/usr/bin/python

# based on xtcrev.py by Tsjerk A. Wassenaar
# modified by Sebastian Marquardt

from struct import unpack
import sys
import os

def i(x): return sum([ord(x[j])<<(24-j*8) for j in range(4)])

def strseek(stream,s,bufsize=10000):
     v = len(s)
     x = stream.read(bufsize)
     n = 0
     while len(x) >= v:
         m = x.find(s)
         if m > -1:
             # If we found the tag, the position is the total length
             # read plus the index at which the tag was found
             n += m
             yield n
             # Now we strip the part up to and including the tag
             x = x[m+v:]
             n += v
         elif len(x) > v:
             # If the tag was not found, strip the string, keeping only
             # the last v-1 characters, as these could combine with the
             # next part to be read in.
             # n is incremented with the number of characters taken from
             # the current string x (len(x)-v+1)
             n += len(x)-v+1
             x = x[1-v:]
         if len(x) <= v:
             x += stream.read(bufsize)

# Get the tag to identify the start of a frame
f   = open(sys.argv[1])
tag = f.read(8)                     # Tag: magic number and number of atoms
n   = 92 + i(f.read(84)[-4:])       # Size of frame in bytes
f.close()

# Find all positions at which the tag is found and the frame lengths
frames  = [ i for i in strseek(open(sys.argv[1]),tag) ]
nf      = len(frames)
lengths = [ j-i for i,j in zip(frames,frames[1:]+[nf]) ]

# Determine numbers of frames per outputfile
NofOutputFiles = int(sys.argv[3])
nfperfile = nf/NofOutputFiles

# Write every nfperfile frames in a single xtc file
f = open(sys.argv[1])
for i in range(NofOutputFiles):
     subframes = frames[ i * nfperfile : i * nfperfile + nfperfile ]
     sublengths = lengths[ i * nfperfile : i * nfperfile + nfperfile ]
     outputfile = sys.argv[2] + str(i) + ".xtc"
     o = open(outputfile,"w")
     for pos,bytes in zip(subframes,sublengths):
         f.seek(pos)
         o.write(f.read(bytes))
     o.close()
f.close()

sys.exit()

which is based on this 
http://www.mail-archive.com/gmx-users@gromacs.org/msg46674.html
to create smaller trajectory files. These can be handled by gromacs on 
my computer.

Thanks again for your help.

Sabrina



More information about the gromacs.org_gmx-users mailing list