code: def getquals(args):
      
      p = OptionParser(getquals.__doc__)
      p.add_option("--types", default="gene,mRNA,CDS",
                  type="str", dest="quals_ftypes",
                  help="Feature types from which to extract qualifiers")
      p.add_option("--ignore", default="locus_tag,product,codon_start,translation",
                  type="str", dest="quals_ignore",
                  help="Qualifiers to exclude from parsing")
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      gbkfile, = args
      quals_ftypes = opts.quals_ftypes.split(",")
      quals_ignore = opts.quals_ignore.split(",")
  
      locus = dict()
      locus_tag = None
      for rec in SeqIO.parse(gbkfile, "gb"):
          for f in rec.features:
              if f.type in quals_ftypes:
                  locus_tag = f.qualifiers[LT][0]
                  if locus_tag not in locus:
                      locus[locus_tag] = dict()
                      for ftype in quals_ftypes:
                          if ftype not in locus[locus_tag]:
                              locus[locus_tag][ftype] = []
                          if ftype == "CDS":  # store the CDS protein_id
                              locus[locus_tag]["protein_id"] = []
  
                  quals = []
                  for qual in f.qualifiers:
                      if qual in quals_ignore:
                          continue
                      for qval in f.qualifiers[qual]:
                          quals.append((locus_tag, qual, qval))
                          if qual == "protein_id":
                              locus[locus_tag]["protein_id"].append(qval)
                  if len(quals) > 0:
                      locus[locus_tag][f.type].append(quals)
  
      for locus_tag in locus:
          print_locus_quals(locus_tag, locus, quals_ftypes)
docs: %prog getquals [--options] gbkfile > qualsfile
  
      Read GenBank file and extract all qualifiers per feature type
      into a tab-delimited file