def _read_frame(self):
<EOL>def read_three(msg):<EOL><INDENT>"""<STR_LIT>"""<EOL>line = next(self._f)<EOL>try:<EOL><INDENT>return [float(line[:<NUM_LIT:12>]), float(line[<NUM_LIT:12>:<NUM_LIT>]), float(line[<NUM_LIT>:])]<EOL><DEDENT>except ValueError:<EOL><INDENT>raise FileFormatError(msg)<EOL><DEDENT><DEDENT>frame = {}<EOL>words = next(self._f).split()<EOL>if len(words) != <NUM_LIT:6>:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % self._counter)<EOL><DEDENT>if words[<NUM_LIT:0>] != "<STR_LIT>":<EOL><INDENT>raise FileFormatError("<STR_LIT>" % self._counter)<EOL><DEDENT>try:<EOL><INDENT>step = int(words[<NUM_LIT:1>])<EOL>frame["<STR_LIT>"] = step<EOL>if int(words[<NUM_LIT:2>]) != self.num_atoms:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % (self._counter, step))<EOL><DEDENT>if int(words[<NUM_LIT:3>]) != self.keytrj:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % (self._counter, step))<EOL><DEDENT>if int(words[<NUM_LIT:4>]) != self.imcon:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % (self._counter, step))<EOL><DEDENT>frame["<STR_LIT>"] = float(words[<NUM_LIT:5>])*self.time_unit<EOL>frame["<STR_LIT:time>"] = frame["<STR_LIT>"]*step <EOL><DEDENT>except ValueError:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % self._counter)<EOL><DEDENT>cell = np.zeros((<NUM_LIT:3>, <NUM_LIT:3>), float)<EOL>frame["<STR_LIT>"] = cell<EOL>cell_msg = "<STR_LIT>" % (self._counter, step)<EOL>for i in range(<NUM_LIT:3>):<EOL><INDENT>cell[:, i] = read_three(cell_msg)<EOL><DEDENT>cell *= self.pos_unit<EOL>symbols = []<EOL>frame["<STR_LIT>"] = symbols<EOL>masses = np.zeros(self.num_atoms, float)<EOL>frame["<STR_LIT>"] = masses<EOL>charges = np.zeros(self.num_atoms, float)<EOL>frame["<STR_LIT>"] = charges<EOL>pos = np.zeros((self.num_atoms, <NUM_LIT:3>), float)<EOL>frame["<STR_LIT>"] = pos<EOL>if self.keytrj > <NUM_LIT:0>:<EOL><INDENT>vel = np.zeros((self.num_atoms, <NUM_LIT:3>), float)<EOL>frame["<STR_LIT>"] = vel<EOL><DEDENT>if self.keytrj > <NUM_LIT:1>:<EOL><INDENT>frc = np.zeros((self.num_atoms, <NUM_LIT:3>), float)<EOL>frame["<STR_LIT>"] = frc<EOL><DEDENT>for i in range(self.num_atoms):<EOL><INDENT>words = next(self._f).split()<EOL>if len(words) != <NUM_LIT:4>:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % (self._counter, step, i+<NUM_LIT:1>))<EOL><DEDENT>symbols.append(words[<NUM_LIT:0>])<EOL>try:<EOL><INDENT>masses[i] = float(words[<NUM_LIT:2>])*self.mass_unit<EOL>charges[i] = float(words[<NUM_LIT:3>])<EOL><DEDENT>except ValueError:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>pos_msg = "<STR_LIT>" % (self._counter, step, i+<NUM_LIT:1>)<EOL>pos[i] = read_three(pos_msg)<EOL>if self.keytrj > <NUM_LIT:0>:<EOL><INDENT>vel_msg = "<STR_LIT>" % (self._counter, step, i+<NUM_LIT:1>)<EOL>vel[i] = read_three(vel_msg)<EOL><DEDENT>if self.keytrj > <NUM_LIT:1>:<EOL><INDENT>frc_msg = "<STR_LIT>" % (self._counter, step, i+<NUM_LIT:1>)<EOL>frc[i] = read_three(frc_msg)<EOL><DEDENT><DEDENT>pos *= self.pos_unit <EOL>if self.keytrj > <NUM_LIT:0>:<EOL><INDENT>vel *= self.vel_unit <EOL><DEDENT>if self.keytrj > <NUM_LIT:1>:<EOL><INDENT>frc *= self.frc_unit <EOL><DEDENT>return frame<EOL>
Read a single frame from the trajectory