code: def rmdup(args):
      
      p = OptionParser(rmdup.__doc__)
      p.add_option("-S", default=False, action="store_true",
                   help="Treat PE reads as SE in rmdup")
      opts, args = p.parse_args(args)
  
      if len(args) < 1:
          sys.exit(not p.print_help())
  
      bams = args
      cmd = "samtools rmdup"
      if opts.S:
          cmd += " -S"
      for b in bams:
          if "rmdup" in b:
              continue
          rb = b.rsplit(".", 1)[0] + ".rmdup.bam"
          if not need_update(b, rb):
              continue
          print(" ".join((cmd, b, rb)))
docs: %prog rmdup *.bam > rmdup.cmds
  
      Remove PCR duplicates from BAM files, generate a list of commands.