let concat : type a. a list t -> a t =
fun l ->
let l = get_list l in
begin match l with
| Fastq first_fastq :: _ as lfq ->
let fqs = List.map lfq ~f:get_fastq in
let r1s = List.map fqs ~f:(fun f -> f#product#r1) in
let r2s = List.filter_map fqs ~f:(fun f -> f#product#r2) in
let concat_files ~read l =
let result_path =
Config.work_dir //
sprintf "%s-Read%d-Concat.fastq"
first_fastq#product#escaped_sample_name read in
Workflow_utilities.Cat.concat ~run_with l ~result_path in
let read_1 = concat_files r1s ~read:1 in
let read_2 =
match r2s with [] -> None | more -> Some (concat_files more ~read:2)
in
Fastq (
KEDSL.fastq_node_of_single_file_nodes ~host
~name:first_fastq#product#sample_name
~fragment_id:"edsl-concat"
read_1 read_2
)
| other ->
ksprintf failwith "To_workflow.concat: not implemented"
end