code: def _parse_sequences(ilines, expect_qlen):
      while True:
          first = next(ilines)
          if first.startswith('_') and first.endswith('].'):
              break
          try:
              index, this_len, query_len = _parse_seq_preheader(first)
          except ValueError:
              logging.warn('Unparseable line (SKIPPING):\n%s', first)
              continue
          (rec_id, dbxrefs, headlen, taillen, phylum, taxchar, description
                  ) = _parse_seq_header(next(ilines))
          try:
              headseq, molseq, tailseq = _parse_seq_body(next(ilines))
          except ValueError:
              logging.warn('Unparseable sequence: %s -- SKIPPING', rec_id)
              continue
          if expect_qlen != query_len:
              logging.warn("Query length in %s given as %d; expected %d",
                           rec_id, query_len, expect_qlen)
          if not headseq and not headlen:
              headlen = 0
          if not tailseq and not taillen:
              taillen = 0
          if headseq:
              if headlen is None:
                  headlen = len(headseq)
              elif headlen != len(headseq):
                  logging.warn("Conflicting head flank lengths in %s: %d, %d",
                               rec_id, headlen, len(headseq))
          if tailseq:
              if taillen is None:
                  taillen = len(tailseq)
              elif taillen != len(tailseq):
                  logging.warn("Conflicting tail flank lengths in %s: %d, %d",
                               rec_id, taillen, len(tailseq))
          yield {'index': index,
                 'id': rec_id,
                 'description': description,
                 'dbxrefs': dbxrefs,
                 'phylum': phylum,
                 'taxchar': taxchar,
                 'head_len': headlen,
                 'tail_len': taillen,
                 'head_seq': headseq,
                 'tail_seq': tailseq,
                 'length': this_len,
                 'seq': molseq,
                 }