let fastq_of_input u =
let open Input in
match u with
| Bam {bam_sample_name; path; how; sorting; reference_build} ->
let f = Bfx.input_url path in
let bam =
Bfx.bam ~sample_name:bam_sample_name ?sorting ~reference_build f in
Bfx.list [Bfx.bam_to_fastq how bam]
| Fastq {fastq_sample_name; files} ->
let sample_name = fastq_sample_name in
List.map files ~f:(fun (fragment_id, source) ->
match source with
| PE (r1, r2) ->
fastq_of_files ~sample_name ?fragment_id ~r1 ~r2 ()
| SE r ->
fastq_of_files ~sample_name ?fragment_id ~r1:r ()
| Of_bam (how, sorting, reference_build, path) ->
let f = Bfx.input_url path in
let bam = Bfx.bam ~sample_name ?sorting ~reference_build f in
Bfx.bam_to_fastq ?fragment_id how bam
) |> Bfx.list