code: def mem(args, opts):
      
      dbfile, read1file = args[:2]
      readtype = opts.readtype
      pl = readtype or "illumina"
  
      pf = op.basename(read1file).split(".")[0]
      rg = opts.rg or r"@RG\tID:{0}\tSM:sm\tLB:lb\tPL:{1}".format(pf, pl)
      dbfile = check_index(dbfile)
      args[0] = dbfile
      samfile, _, unmapped = get_samfile(read1file, dbfile,
                                         bam=opts.bam, unmapped=opts.unmapped)
      if not need_update(read1file, samfile):
          logging.error("`{0}` exists. `bwa mem` already run.".format(samfile))
          return "", samfile
  
      cmd = "{} mem".format(opts.bwa)
      '''
      -M Mark shorter split hits as secondary (for Picard compatibility).
      '''
      cmd += " -M -t {0}".format(opts.cpus)
      cmd += ' -R "{0}"'.format(rg)
      if readtype:
          cmd += " -x {0}".format(readtype)
      cmd += " " + opts.extra
      cmd += " ".join(args)
  
      return cmd, samfile
docs: %prog mem database.fasta read1.fq [read2.fq]
  
      Wrapper for `bwa mem`. Output will be read1.sam.