code: def tobam_cl(data, out_file, is_paired=False):
      do_dedup = _check_dedup(data)
      umi_consensus = dd.get_umi_consensus(data)
      with file_transaction(data, out_file) as tx_out_file:
          if not do_dedup:
              yield (sam_to_sortbam_cl(data, tx_out_file), tx_out_file)
          elif umi_consensus:
              yield (_sam_to_grouped_umi_cl(data, umi_consensus, tx_out_file), tx_out_file)
          elif is_paired and _need_sr_disc_reads(data) and not _too_many_contigs(dd.get_ref_file(data)):
              sr_file = "%s-sr.bam" % os.path.splitext(out_file)[0]
              disc_file = "%s-disc.bam" % os.path.splitext(out_file)[0]
              with file_transaction(data, sr_file) as tx_sr_file:
                  with file_transaction(data, disc_file) as tx_disc_file:
                      yield (samblaster_dedup_sort(data, tx_out_file, tx_sr_file, tx_disc_file),
                             tx_out_file)
          else:
              yield (_biobambam_dedup_sort(data, tx_out_file), tx_out_file)