code: def infer(args):
      
      from jcvi.apps.grid import WriteJobs
      from jcvi.formats.bed import sort
  
      p = OptionParser(infer.__doc__)
      p.set_cpus()
      opts, args = p.parse_args(args)
  
      if len(args) != 2:
          sys.exit(not p.print_help())
  
      scaffoldsf, genomef = args
      inferbed = "infer-components.bed"
      if need_update((scaffoldsf, genomef), inferbed):
          scaffolds = Fasta(scaffoldsf, lazy=True)
          genome = Fasta(genomef)
          genome = genome.tostring()
          args = [(scaffold_name, scaffold, genome) \
                  for scaffold_name, scaffold in scaffolds.iteritems_ordered()]
  
          pool = WriteJobs(map_one_scaffold, args, inferbed, cpus=opts.cpus)
          pool.run()
  
      sort([inferbed, "-i"])
      bed = Bed(inferbed)
      inferagpbed = "infer.bed"
      fw = open(inferagpbed, "w")
      seen = []
      for b in bed:
          r = (b.seqid, b.start, b.end)
          if check_seen(r, seen):
              continue
          print("\t".join(str(x) for x in \
                      (b.accn, 0, b.span, b.seqid, b.score, b.strand)), file=fw)
          seen.append(r)
      fw.close()
  
      frombed([inferagpbed])
docs: %prog infer scaffolds.fasta genome.fasta
  
      Infer where the components are in the genome. This function is rarely used,
      but can be useful when distributor does not ship an AGP file.