let default_netmhc_install
~(run_program : Machine.Make_fun.t) ~host ~install_path
~tool_file_loc ~binary_name ~example_data_file ~env_setup
?(depends=[])
?(data_folder_name="data")
?(data_folder_dest=".")
() =
let open KEDSL in
let tool_name = binary_name in
let downloaded_file =
Workflow_utilities.Download.get_tool_file
~identifier:tool_name
~run_program ~host ~install_path
tool_file_loc
in
let folder_name = guess_folder_name tool_file_loc in
let cap_name = String.set folder_name 0 'N' in
let folder_in_url = match cap_name with Some s -> s | None -> folder_name in
let data_url =
sprintf
"http://www.cbs.dtu.dk/services/%s/%s.tar.gz"
folder_in_url
data_folder_name
in
let (one_data_file, with_data) =
match example_data_file with
| Some df -> (data_folder_name // df, true)
| None -> ("", false)
in
let downloaded_data_file =
Workflow_utilities.Download.wget_untar
~run_program ~host
~destination_folder:(install_path // folder_name // data_folder_dest)
~tar_contains:one_data_file data_url
in
let tool_path = install_path // folder_name in
let runner_folder = netmhc_runner_path install_path in
let runner_path = runner_folder // binary_name in
let binary_path = tool_path // binary_name in
let fix_script replacement =
match replacement with
| `ENV (e, v) -> replace_env_value binary_name e v
| `GENERIC (o, n) -> replace_value binary_name o n
in
let conda_env = netmhc_conda_env install_path in
let ensure =
workflow_node (single_file ~host binary_path)
~name:("Install NetMHC tool: " ^ tool_name)
~edges:(
[ depends_on downloaded_file;
depends_on Conda.(configured ~run_program ~host ~conda_env);
on_failure_activate (rm_path ~host install_path); ]
@ (if with_data then [ depends_on downloaded_data_file; ] else [])
@ (List.map depends ~f:(fun d -> depends_on d))
)
~make:(run_program
~requirements:[
`Self_identification ["netmhc"; tool_name; "installation"];
]
Program.(
shf "cd %s" install_path &&
shf "tar zxf %s" downloaded_file#product#path &&
shf "cd %s" tool_path &&
chain (List.map ~f:fix_script env_setup) &&
shf "chmod +x %s" binary_path &&
shf "mkdir -p %s" (tmp_dir install_path) &&
shf "mkdir -p %s" runner_folder &&
create_netmhc_runner_cmd
~binary_name ~binary_path ~conda_env runner_path &&
shf "chmod +x %s" runner_path
)
)
in
let init =
Program.(
shf "export PATH=%s:$PATH" runner_folder &&
shf "export TMPDIR=%s" (tmp_dir install_path)
)
in
(Machine.Tool.create
Machine.Tool.Definition.(create binary_name)
~ensure ~init, binary_path, ensure)