let fastq_of_files ~sample_name ?fragment_id ~r1 ?r2 () =
let is_gz r =
Filename.check_suffix r ".gz" || Filename.check_suffix r ".fqz"
in
match is_gz r1, Option.map ~f:is_gz r2 with
| true, None
| true, Some true ->
let r1 = Bfx.input_url r1 in
let r2 = Option.map ~f:Bfx.input_url r2 in
Bfx.(fastq_gz ~sample_name ?fragment_id ~r1 ?r2 () |> gunzip)
| false, None
| false, Some false ->
let r1 = Bfx.input_url r1 in
let r2 = Option.map ~f:Bfx.input_url r2 in
Bfx.(fastq ~sample_name ?fragment_id ~r1 ?r2 ())
| _ ->
failwithf "fastq_of_files: cannot handle mixed gzipped and non-gzipped fastq pairs (for a given same fragment)"