Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmdstan #485

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions src/bfx_tools/cmdstan.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
(* Wraps make from cmdstan, i.e. compiles a .stan file *)

open Biokepi_run_environment
open Common

(*let run_program = Machine.run_program biokepi_machine*)

let compile_model ~stan_model ~(run_with : Machine.t) =
let open KEDSL in
let cmdstan = Machine.get_tool run_with Machine.Tool.Default.cmdstan in
workflow_node (single_file ~host:Machine.(as_host run_with) stan_model)
~name:"Compile .stan file"
~edges: [
depends_on Machine.Tool.(ensure cmdstan);
]
~make:(Machine.run_program run_with
Program.(
Machine.Tool.init cmdstan
(* && shf "cd %s" cmdstan_dir *)
&& shf "make %s" stan_model
)
)

let fit_model ~stan_model ~fit_method
~data_file
~output_file
~(run_with : Machine.t) =
let open KEDSL in (* when is this necessary? *)
workflow_node
(single_file output_file ~host:(Machine.as_host run_with))
~name:(sprintf "Fitting %s" stan_model)
~make:(
Machine.run_program run_with
Program.(
shf "%s \
%s \
data file=%s \
output file=%s" stan_model fit_method data_file output_file
)
)
~edges:[
depends_on (compile_model ~stan_model:stan_model ~run_with);
]

let stan_summary_node ~model_output_csv ~summary_csv
~(run_with : Machine.t)
=
let open KEDSL in
let cmdstan = Machine.get_tool run_with Machine.Tool.Default.cmdstan in
workflow_node (single_file summary_csv ~host:(Machine.as_host run_with))
~name:("stansummary " ^ model_output_csv ^ " to " ^ summary_csv)
~edges: [
depends_on Machine.Tool.(ensure cmdstan);
]
~make:(Machine.run_program run_with
Program.(
Machine.Tool.init cmdstan
&& shf "bin/stansummary %s --csv_file=%s" model_output_csv summary_csv
)
)

(* sticking the simplest possible Configuration in here for now *)
module Configuration = struct

type t = {
name: string;
parameters: (string * string) list
}

let default = {
name = "default";
parameters = []
}

end
25 changes: 21 additions & 4 deletions src/environment_setup/tool_providers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ end

let add_to_dollar_path ~path = KEDSL.Program.shf "export PATH=%s:$PATH" path

let make_and_copy_dir dir =
fun ~path -> KEDSL.Program.(
shf "echo %s" path
&& sh "make"
&& sh "cd .."
&& shf "cp -r %s %s" dir path)
let make_and_copy_contents =
fun ~path -> KEDSL.Program.(
shf "echo %s" path
&& sh "make build"
&& shf "cp -r * %s" path)
let make_and_copy_bin bin =
fun ~path -> KEDSL.Program.(
sh "make" && shf "cp %s %s" bin path)
Expand All @@ -192,6 +203,14 @@ let witness_list l =
KEDSL.list_of_files ~host (List.map l ~f:(fun bin -> path // bin))
|> fun p -> object method is_done = p#is_done end

let cmdstan =
Installable_tool.make
Machine.Tool.Default.cmdstan
~url:"https://github.com/stan-dev/cmdstan/releases/download/v2.15.0/cmdstan-2.15.0.zip"
~install_program:(make_and_copy_contents)
~init_program:(fun ~path -> KEDSL.Program.(shf "cd %s" path))
~witness:(witness_file "bin/stanc")

let bwa =
Installable_tool.make
Machine.Tool.Default.bwa
Expand Down Expand Up @@ -508,10 +527,7 @@ let fastqc =
~init_program:add_to_dollar_path
~witness:(witness_file binary)

let default_tool_location
msg
(): Workflow_utilities.Download.tool_file_location
=
let default_tool_location msg (): Workflow_utilities.Download.tool_file_location =
`Fail (sprintf "No location provided for %s" msg)

let default_netmhc_config () = Netmhc.(
Expand Down Expand Up @@ -562,6 +578,7 @@ let default_toolkit
install samblaster;
install_git freebayes;
install delly2;
install cmdstan;
];
Biopam.default ~run_program ~host
~install_path:(install_tools_path // "biopam-kit") ();
Expand Down
1 change: 1 addition & 0 deletions src/run_environment/machine.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ module Tool = struct
let topiary = create "topiary" ~version:"1.2.1"
let vaxrank = create "vaxrank" ~version:"0.6.0"
let isovar = create "isovar" ~version:"0.7.0"
let cmdstan = create "cmdstan" ~version:"2.15.0"
end

type t = {
Expand Down