code: def batch(args):
      
      from jcvi.apps.grid import MakeManager
  
      p = OptionParser(batch.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) < 2:
          sys.exit(not p.print_help())
  
      cdsfile = args[0]
      anchors = args[1:]
      workdirs = [".".join(op.basename(x).split(".")[:2]) for x in anchors]
      for wd in workdirs:
          mkdir(wd)
  
      mm = MakeManager()
      for wd, ac in zip(workdirs, anchors):
          pairscdsfile = wd + ".cds.fasta"
          cmd = "python -m jcvi.apps.ks prepare {} {} -o {}".\
                  format(ac, cdsfile, pairscdsfile)
          mm.add((ac, cdsfile), pairscdsfile, cmd)
          ksfile = wd + ".ks"
          cmd = "python -m jcvi.apps.ks calc {} -o {} --workdir {}".\
                  format(pairscdsfile, ksfile, wd)
          mm.add(pairscdsfile, ksfile, cmd)
      mm.write()
docs: %prog batch all.cds *.anchors
  
      Compute Ks values for a set of anchors file. This will generate a bunch of
      work directories for each comparisons. The anchorsfile should be in the form
      of specie1.species2.anchors.