code: def coge(args):
      
      p = OptionParser(coge.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 1:
          sys.exit(not p.print_help())
  
      cogefile, = args
      fp = must_open(cogefile)
      cogefile = cogefile.replace(".gz", "")
      ksfile = cogefile + ".ks"
      anchorsfile = cogefile + ".anchors"
      fw_ks = must_open(ksfile, "w")
      fw_ac = must_open(anchorsfile, "w")
  
      tag = "###"
      print(tag, file=fw_ks)
      for header, lines in read_block(fp, tag):
          print(tag, file=fw_ac)
          lines = list(lines)
          for line in lines:
              if line[0] == '#':
                  continue
              ks, ka, achr, a, astart, astop, bchr, \
                      b, bstart, bstop, ev, ss = line.split()
              a = a.split("||")[3]
              b = b.split("||")[3]
              print("\t".join((a, b, ev)), file=fw_ac)
              print(",".join((";".join((a, b)), ks, ka, ks, ka)), file=fw_ks)
  
      fw_ks.close()
      fw_ac.close()
docs: %prog coge cogefile
  
      Convert CoGe file to anchors file.