[gmx-developers] Getting the last frame in an xtc file
Ran Friedman
r.friedman at bioc.uzh.ch
Thu Apr 10 12:15:14 CEST 2008
Dear developers,
I bothered you with this question two weeks ago but received no replies.
To make this simple: is there a way to get the time or frame number for
the last frame of an xtc file? Did any of you use
xtc_get_last_frame_time or xtc_get_last_frame_number successfully, or
managed to do it in any other way that doesn't include reading all
frames one-by-one?
Thanks in advance,
Ran.
Ran Friedman wrote:
> Dear developers,
>
> I was unsuccessful in using xtc_get_last_frame_time from libxdrf.c on
> different XTC files. This function isn't used by any other function in
> GMX AFAIK.
>
> The function always exits with return value -1 after the following line:
>
> line 1639:
> time = xtc_get_current_frame_time(fp, natoms, bOK);
> xtc_get_current_frame_time, in its turn, returns -1 after calling
> xtc_at_header_start:
>
> line 1281:
> ret = xtc_at_header_start(fp,natoms,&step,&time);
>
> And xtc_at_header_start returns -1 at:
>
> lines 1159-1165:
> /* read magic natoms and timestep */
> for(i = 0;i<3;i++){
> if(!xdr_int(xdridptr[fp+1], &(i_inp[i]))){
> gmx_fseek(xdrfiles[fp+1],off+sizeof(int),SEEK_SET);
> return -1;
> }
> }
>
> It returns -1 when i=1 (i.e. for the number of atoms), but the magic
> number is also not right (and it's not the same number for different
> trajectories).
>
> Coming back to the high level function which I use
> (xtc_get_last_frame_time), I noticed that it puts the stream pointer to
> the EOF - 4 fields:
>
> lines 1634-1639
> if( (res = gmx_fseek(xdrfiles[fp+1],-4,SEEK_END)) != 0){
> *bOK = 0;
> return -1;
> }
>
> time = xtc_get_current_frame_time(fp, natoms, bOK);
>
> My questions are:
> 1. Will this location point me to the header? If the header is at the
> beginning of each frame then I guess that the answer is no.
> 2. Suppose that it doesn't point me to the header of the last frame, how
> can I get there without passing through all other frames?
>
> I'm using GMX 3.3.3.
>
> Thanks,
> Ran.
>
>
More information about the gromacs.org_gmx-developers
mailing list