def __next__(self):
while True:<EOL><INDENT>title = next(self.f)<EOL>if len(title) == <NUM_LIT:0>:<EOL><INDENT>raise StopIteration<EOL><DEDENT>else:<EOL><INDENT>title = title.strip()<EOL><DEDENT>next(self.f) <EOL>next(self.f) <EOL>words = next(self.f).split()<EOL>if len(words) < <NUM_LIT:2>:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>num_atoms = int(words[<NUM_LIT:0>])<EOL>num_bonds = int(words[<NUM_LIT:1>])<EOL><DEDENT>except ValueError:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>numbers = np.zeros(num_atoms, int)<EOL>coordinates = np.zeros((num_atoms, <NUM_LIT:3>), float)<EOL>for i in range(num_atoms):<EOL><INDENT>words = next(self.f).split()<EOL>if len(words) < <NUM_LIT:4>:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>coordinates[i, <NUM_LIT:0>] = float(words[<NUM_LIT:0>])<EOL>coordinates[i, <NUM_LIT:1>] = float(words[<NUM_LIT:1>])<EOL>coordinates[i, <NUM_LIT:2>] = float(words[<NUM_LIT:2>])<EOL><DEDENT>except ValueError:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>atom = periodic[words[<NUM_LIT:3>]]<EOL>if atom is None:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % words[<NUM_LIT:3>])<EOL><DEDENT>numbers[i] = atom.number<EOL><DEDENT>coordinates *= angstrom<EOL>edges = []<EOL>orders = np.zeros(num_bonds, int)<EOL>for i in range(num_bonds):<EOL><INDENT>words = next(self.f).split()<EOL>if len(words) < <NUM_LIT:3>:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>edges.append((int(words[<NUM_LIT:0>])-<NUM_LIT:1>, int(words[<NUM_LIT:1>])-<NUM_LIT:1>))<EOL>orders[i] = int(words[<NUM_LIT:2>])<EOL><DEDENT>except ValueError:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT><DEDENT>formal_charges = np.zeros(len(numbers), int)<EOL>line = next(self.f)<EOL>while line != "<STR_LIT>":<EOL><INDENT>if line.startswith("<STR_LIT>"):<EOL><INDENT>words = line[<NUM_LIT:6>:].split()[<NUM_LIT:1>:] <EOL>i = <NUM_LIT:0><EOL>while i < len(words)-<NUM_LIT:1>:<EOL><INDENT>try:<EOL><INDENT>formal_charges[int(words[i])-<NUM_LIT:1>] = int(words[i+<NUM_LIT:1>])<EOL><DEDENT>except ValueError:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>i += <NUM_LIT:2><EOL><DEDENT><DEDENT>line = next(self.f)<EOL><DEDENT>for line in self.f:<EOL><INDENT>if line == "<STR_LIT>":<EOL><INDENT>break<EOL><DEDENT><DEDENT>molecule = Molecule(numbers, coordinates, title)<EOL>molecule.formal_charges = formal_charges<EOL>molecule.formal_charges.setflags(write=False)<EOL>molecule.graph = MolecularGraph(edges, numbers, orders)<EOL>return molecule<EOL><DEDENT>
Load the next molecule from the SDF file

           This method is part of the iterator protocol.