let merge_bams
?(delete_input_on_success = true)
?(attach_rg_tag = false)
?(uncompressed_bam_output = false)
?(compress_level_one = false)
?(combine_rg_headers = false)
?(combine_pg_headers = false) bam_list =
match AF.get_file bam_list with
| List [ one_bam ] ->
one_bam |> AF.with_provenance "merge-bams"
["pass-through", AF.get_provenance bam_list]
| List bam_files ->
let bams = List.map bam_files ~f:get_bam in
let output_path =
Name_file.in_directory ~readable_suffix:"samtoolsmerge.bam"
Config.work_dir
(List.map bams ~f:(fun bam -> bam#product#path))
in
Bam (Tools.Samtools.merge_bams
~delete_input_on_success
~attach_rg_tag
~uncompressed_bam_output
~compress_level_one
~combine_rg_headers
~combine_pg_headers
~run_with
bams output_path)
|> AF.with_provenance "merge-bams"
["bam-list", AF.get_provenance bam_list]
~string_arguments:[
"delete-input-on-success", string_of_bool delete_input_on_success;
"attach-rg-tag", string_of_bool attach_rg_tag;
"uncompressed-bam-output", string_of_bool uncompressed_bam_output;
"compress-level-one", string_of_bool compress_level_one;
"combine-rg-headers", string_of_bool combine_rg_headers;
"combine-pg-headers", string_of_bool combine_pg_headers;
]
| other ->
fail_get other "To_workflow.merge_bams: not a list of bams?"