let bam_to_fastq ?fragment_id how bam =
let input_bam = get_bam (AF.get_file bam) in
let sample_type = match how with `SE -> `Single_end | `PE -> `Paired_end in
let sample_type_str = match how with `PE -> "PE" | `SE -> "SE" in
let output_prefix =
Config.work_dir
// sprintf "%s-b2fq-%s"
Filename.(chop_extension (basename input_bam#product#path))
sample_type_str
in
Fastq (
Tools.Picard.bam_to_fastq ~run_with ~sample_type
~output_prefix input_bam
) |> AF.with_provenance "bam-to-fastq" ["bam", AF.get_provenance bam]
~string_arguments:(("sample-type", sample_type_str)
:: Option.value_map ~default:[] fragment_id
~f:(fun fi -> ["fragment-id", fi]))