diff --git a/package/MDAnalysis/coordinates/dcdtimeseries.pyx b/package/MDAnalysis/coordinates/dcdtimeseries.pyx index d7c2ab4cb48..c3f66900eec 100644 --- a/package/MDAnalysis/coordinates/dcdtimeseries.pyx +++ b/package/MDAnalysis/coordinates/dcdtimeseries.pyx @@ -117,12 +117,17 @@ def __read_timecorrel(object self, object atoms, object atomcounts, object forma # Check if we have fixed atoms # XXX not done numskip = step - 1 + # if the number to skip is greater than the number of frames left + # to be jumped over, just take one more step to reflect np slicing + # if there is a remainder, guaranteed to have at least one more + # frame. if(remaining_frames < numskip): numskip = 1 rc = skip_dcdstep(dcd.fd, dcd.natoms, dcd.nfixed, dcd.charmm, numskip) if (rc < 0): raise IOError("Error skipping frame from DCD file") + # on first iteration, numskip = 0, first set is always read. dcd.setsread = dcd.setsread + numskip rc = read_dcdsubset(dcd.fd, dcd.natoms, lowerb, upperb, tempX, tempY, tempZ, unitcell, dcd.nfixed, dcd.first, dcd.freeind, dcd.fixedcoords, dcd.reverse, dcd.charmm) dcd.first = 0 diff --git a/package/MDAnalysis/coordinates/src/dcd.c b/package/MDAnalysis/coordinates/src/dcd.c index 9f3d6fe222f..a8ca7879dc6 100644 --- a/package/MDAnalysis/coordinates/src/dcd.c +++ b/package/MDAnalysis/coordinates/src/dcd.c @@ -531,12 +531,16 @@ __read_timeseries(PyObject *self, PyObject *args) goto error; } - /*Should actually be number of frames, not true yet*/ remaining_frames = stop-start; for (i=0;i 1 && i>0) { // Figure out how many steps to skip numskip = step -1; + /* If the number to skip is greater than the number of frames left + to be jumped over, just take one more step to reflect np slicing + if there is a remainder, guaranteed to have at least one more + frame. + */ if(remaining_frames < numskip){ numskip = 1; } @@ -547,6 +551,7 @@ __read_timeseries(PyObject *self, PyObject *args) goto error; } } + // on first iteration, numskip == 0, first set is always read. dcd->setsread += numskip; //now read from subset rc = read_dcdsubset(dcd->fd, dcd->natoms, lowerb, upperb, tempX, tempY, tempZ,