let run ~(run_with:Machine.t)
?(edges=[])
~(hla_result:hla_result)
~output_path ~extract_alleles ()
=
let open KEDSL in
let open Ketrew_pure.Target.Volume in
let hlarp = Machine.get_tool run_with Machine.Tool.Default.hlarp in
let subcommand, hla_result_directory, hla_result_dep =
match hla_result with
| `Optitype v -> "optitype", v#product#path, depends_on v
| `Seq2hla v -> "seq2HLA", v#product#work_dir_path, depends_on v
in
let name = sprintf "Hlarp on %s @ %s" subcommand hla_result_directory in
let make = Machine.quick_run_program run_with
~name
~requirements:[`Self_identification ["hlarp"]]
Program.(
Machine.Tool.init hlarp
&& shf "hlarp %s %s > %s" subcommand hla_result_directory output_path
&& sh
(if extract_alleles
then sprintf
"awk -F , '{ gsub(/^[ \t]+|[ \t]+$/,\"\", $2); print $2}' %s | tail -n +2 | sed \"s/'//\" > %s.tmp && mv %s.tmp %s"
output_path output_path output_path output_path
else "")) in
let edges = hla_result_dep :: edges @ [
depends_on (Machine.Tool.ensure hlarp);
on_failure_activate
(Workflow_utilities.Remove.file ~run_with output_path);
] in
workflow_node ~name ~make
(single_file output_path ~host:(Machine.as_host run_with))
~edges