let gunzip: Annotated_file.t -> Annotated_file.t = fun gz ->
let inside = get_gz (AF.get_file gz) in
begin match inside with
| Fastq f ->
let make_result_path read =
let base = Filename.basename read in
Config.work_dir //
(match base with
| fastqgz when Filename.check_suffix base ".fastq.gz" ->
Filename.chop_suffix base ".gz"
| fqz when Filename.check_suffix base ".fqz" ->
Filename.chop_suffix base ".fqz" ^ ".fastq"
| other ->
ksprintf failwith "To_workflow.gunzip: cannot recognize Gz-Fastq extension: %S" other)
in
let gunzip read =
let result_path = make_result_path read#product#path in
Workflow_utilities.Gunzip.concat
~run_with [read] ~result_path in
let fastq_r1 = gunzip (KEDSL.read_1_file_node f) in
let fastq_r2 = Option.map (KEDSL.read_2_file_node f) ~f:gunzip in
Fastq (
KEDSL.fastq_node_of_single_file_nodes ~host
~name:f#product#sample_name
?fragment_id:f#product#fragment_id
fastq_r1 fastq_r2
)
|> AF.with_provenance "gunzip" ["fastq-gz", AF.get_provenance gz]
| other ->
ksprintf failwith "To_workflow.gunzip: non-FASTQ input not implemented"
end