code: def _biobambam_dedup_sort(data, tx_out_file):
      
      samtools = config_utils.get_program("samtools", data["config"])
      cores, mem = _get_cores_memory(data, downscale=2)
      tmp_file = "%s-sorttmp" % utils.splitext_plus(tx_out_file)[0]
      if data.get("align_split"):
          sort_opt = "-n" if data.get("align_split") and _check_dedup(data) else ""
          cmd = "{samtools} sort %s -@ {cores} -m {mem} -O bam -T {tmp_file}-namesort -o {tx_out_file} -" % sort_opt
      else:
          # scale core usage to avoid memory issues with larger WGS samples
          cores = max(1, int(math.ceil(cores * 0.75)))
          ds_cmd = bam.get_maxcov_downsample_cl(data, "bamsormadup")
          bamsormadup = config_utils.get_program("bamsormadup", data)
          cmd = ("{bamsormadup} inputformat=sam threads={cores} tmpfile={tmp_file}-markdup "
                 "SO=coordinate %s > {tx_out_file}" % ds_cmd)
      return cmd.format(**locals())
docs: Perform streaming deduplication and sorting with biobambam's bamsormadup