let merge_bams: [ `Bam ] list t -> [ `Bam ] t =
function
| List [ one_bam ] -> one_bam
| List bam_files ->
let bams = List.map bam_files ~f:get_bam in
let output_path =
let one = List.hd_exn bams in
Filename.chop_extension one#product#path
^ sprintf "-merged-%s.bam"
(List.map bams ~f:(fun bam -> bam#product#path)
|> String.concat ""
|> Digest.string |> Digest.to_hex)
in
Bam (Tools.Samtools.merge_bams ~run_with bams output_path)
| other ->
fail_get other "To_workflow.merge_bams: not a list of bams?"