let create_dict ~(run_with:Machine.t) fasta =
let open KEDSL in
let picard_create_dict =
Machine.get_tool run_with Machine.Tool.Default.picard in
let src = fasta#product#path in
let dest = sprintf "%s.%s" (Filename.chop_suffix src ".fasta") "dict" in
let program =
Program.(Machine.Tool.(init picard_create_dict) &&
shf "java -jar $PICARD_JAR CreateSequenceDictionary R= %s O= %s"
(Filename.quote src) (Filename.quote dest)) in
let name = sprintf "picard-create-dict-%s" Filename.(basename src) in
let make =
Machine.run_stream_processor run_with program ~name
~self_ids:["picard"; "create-dict"] in
let host = Machine.(as_host run_with) in
workflow_node (single_file dest ~host) ~name ~make
~edges:[
depends_on fasta; depends_on Machine.Tool.(ensure picard_create_dict);
on_failure_activate (Remove.file ~run_with dest);
]