code: def sanitize_gff_db(db, gid_field="gid"):
      
      def sanitized_iterator():
          # Iterate through the database by each gene's records
          for gene_recs in db.iter_by_parent_childs():
              # The gene's ID
              gene_id = gene_recs[0].id
              for rec in gene_recs:
                  # Fixup coordinates if necessary
                  if rec.start > rec.stop:
                      rec.start, rec.stop = rec.stop, rec.start
                  # Add a gene id field to each gene's records
                  rec.attributes[gid_field] = [gene_id]
                  yield rec
      # Return sanitized GFF database
      sanitized_db = \
          gffutils.create_db(sanitized_iterator(), ":memory:",
                             verbose=False)
      return sanitized_db
docs: Sanitize given GFF db. Returns a sanitized GFF db.
  
      Sanitizing means:
  
      - Ensuring that start < stop for all features
      - Standardizing gene units by adding a 'gid' attribute
        that makes the file grep-able
  
      TODO: Do something with negative coordinates?