def __iter__(self):
self._reset()<EOL>for line in self.instream:<EOL><INDENT>line = line.rstrip()<EOL>if line == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>elif line == '<STR_LIT>':<EOL><INDENT>if self.assumesorted:<EOL><INDENT>for obj in self._resolve_features():<EOL><INDENT>if self._prevrecord and self._prevrecord > obj:<EOL><INDENT>msg = '<STR_LIT>'<EOL>msg += '<STR_LIT>'.format(<EOL>self._prevrecord.slug,<EOL>obj.slug,<EOL>)<EOL>raise ValueError(msg)<EOL><DEDENT>self._prevrecord = obj<EOL>self._counter += <NUM_LIT:1><EOL>yield obj<EOL><DEDENT><DEDENT><DEDENT>elif line.startswith('<STR_LIT:#>'):<EOL><INDENT>if line == '<STR_LIT>':<EOL><INDENT>for sequence in parse_fasta(self.instream):<EOL><INDENT>self.records.append(sequence)<EOL><DEDENT>break<EOL><DEDENT>elif line.startswith('<STR_LIT>') and line[<NUM_LIT:2>] != '<STR_LIT:#>':<EOL><INDENT>record = Directive(line)<EOL>if record.type == '<STR_LIT>':<EOL><INDENT>if record.seqid in self.declared_regions:<EOL><INDENT>m = ('<STR_LIT>'<EOL>'<STR_LIT>'.format(record.seqid))<EOL>raise ValueError(m)<EOL><DEDENT>self.declared_regions[record.seqid] = record<EOL><DEDENT><DEDENT>else:<EOL><INDENT>record = Comment(line)<EOL><DEDENT>self.records.append(record)<EOL><DEDENT>else:<EOL><INDENT>feature = Feature(line)<EOL>if feature.seqid in self.declared_regions:<EOL><INDENT>seqregion = self.declared_regions[feature.seqid]<EOL>if not feature._range.within(seqregion.range):<EOL><INDENT>msg = '<STR_LIT>'.format(feature.slug)<EOL>raise ValueError(msg)<EOL><DEDENT><DEDENT>if feature.seqid not in self.inferred_regions:<EOL><INDENT>self.inferred_regions[feature.seqid] = Range(feature.start,<EOL>feature.end)<EOL><DEDENT>rstr = self.inferred_regions[feature.seqid].start<EOL>rend = self.inferred_regions[feature.seqid].end<EOL>fstr = feature.start<EOL>fend = feature.end<EOL>self.inferred_regions[feature.seqid].start = min(rstr, fstr)<EOL>self.inferred_regions[feature.seqid].end = max(rend, fend)<EOL>featureid = feature.get_attribute('<STR_LIT>')<EOL>parentid = feature.get_attribute('<STR_LIT>')<EOL>if parentid is None:<EOL><INDENT>if featureid is None or featureid not in self.featsbyid:<EOL><INDENT>self.records.append(feature)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if parentid not in self.featsbyparent:<EOL><INDENT>self.featsbyparent[parentid] = list()<EOL><DEDENT>self.featsbyparent[parentid].append(feature)<EOL><DEDENT>if featureid is not None:<EOL><INDENT>if featureid in self.featsbyid:<EOL><INDENT>other = self.featsbyid[featureid]<EOL>assert feature.type == other.type,'<STR_LIT>'% (featureid, feature.type, other.type)<EOL>other.add_sibling(feature)<EOL><DEDENT>else:<EOL><INDENT>self.featsbyid[featureid] = feature<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for obj in self._resolve_features():<EOL><INDENT>if self._counter == <NUM_LIT:0>:<EOL><INDENT>isv = isinstance(obj, Directive) and obj.type == '<STR_LIT>'<EOL>if not isv:<EOL><INDENT>self._prevrecord = Directive('<STR_LIT>')<EOL>self._counter += <NUM_LIT:1><EOL>yield self._prevrecord<EOL><DEDENT><DEDENT>self._prevrecord = obj<EOL>self._counter += <NUM_LIT:1><EOL>yield obj<EOL><DEDENT>
Generator function returns GFF3 entries.