def nextframe(self): """Loads the next frame into self. loads the next frame in self.frame . Hides details about wheter or not the dcd has been loaded into memory """ if self._fo == None: self._openfo() if self._framen >= self._nframes-1: #if there are 10 frames total, framen can not be #more than 9. So stoup if framen >= nframes -1 log.critical("tried to read more frames than there were. BAILING OUT!!") return None self._get_next_frame() return self._frame
def read_n_frames(self, ntoread): """Advance the current frame by the given number. Reads n frames from the dcd, only returning ( and saving in self.frame) the last one. If called with an argument of one, it behaves exactly like nextframe() Note that it might just skip the data for speed issues, it need not concern you. """ if self._fo == None: self._openfo() ntoread = int(ntoread) if self._framen + ntoread > self._nframes - 1: #can't read more than we have log.critical("tried to read more frames than there are!") ntoskip = ntoread-1 self._fo.seek( (self._natoms*4 + 8 )*3*ntoskip, 1 ) #seek, whence=1 ==> seek from current position self._framen += ntoskip self._get_next_frame() return self._frame