Commit d0d2d6e3 authored by LANORE Vincent's avatar LANORE Vincent
Browse files

Added options --diffsel and --c60 to toggle diffsel and c60 (off by default) +...

Added options --diffsel and --c60 to toggle diffsel and c60 (off by default) + removed simulation and detection subcommands.
parent 0b973e9b
......@@ -3,8 +3,6 @@ open Reviewphiltrans
let () =
Command.group ~summary:"Reviewphiltrans" [
"simulation", Pipeline.simulation_command ;
"detection", Pipeline.detection_command ;
"validation", Pipeline.validation_command ;
"alistats", Alistats.command ;
]
......
......@@ -301,7 +301,7 @@ let derive_from_det_meth ~det_meth ~(dataset : Dataset.t) ~preview =
| `Msd e -> `Msd (Msd.msd ~e ~faa ~tree_sc, e)
let derive_from_dataset ~dataset ~preview ~fast_mode=
let derive_from_dataset ~dataset ~preview ~use_diffsel ~use_c60=
let det_meths = [
([
`Identical_LG;
......@@ -318,10 +318,14 @@ let derive_from_dataset ~dataset ~preview ~fast_mode=
`Topological_WAG;
]
;
if fast_mode then
[]
if use_diffsel then
[`Diffsel]
else
[] ;
if use_c60 then
[`Pcoc_C60]
else
[`Diffsel; `Pcoc_C60] ;
[] ;
]
|> List.concat in
let res_by_tools = List.map det_meths ~f:(fun det_meth ->
......@@ -338,11 +342,11 @@ let derive_from_dataset ~dataset ~preview ~fast_mode=
let tree_prefix = dataset.tree_prefix in
{model_prefix; tree_prefix; dataset; res_by_tools ; merged_results ; plot_merged_results}
let derive_det ~dataset_l ~preview ~fast_mode =
let derive_det ~dataset_l ~preview ~use_diffsel ~use_c60 =
List.map dataset_l ~f:(fun dataset ->
derive_from_dataset ~preview ~dataset ~fast_mode)
derive_from_dataset ~preview ~dataset ~use_diffsel ~use_c60)
let derive_profile ?(indir = "") ?(ns = 0) ~preview ~fast_mode ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile ~use_concat ~add_indels ~only_simu ~seed () =
let derive_profile ?(indir = "") ?(ns = 0) ~preview ~use_diffsel ~use_c60 ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile ~use_concat ~add_indels ~only_simu ~seed () =
let trees = Array.to_list @@ Sys.readdir tree_dir in
let repo_and_post_analyses_per_tree_simu = List.map trees ~f:(fun tree -> (*to keep together all models per tree*)
let trees = [tree] in
......@@ -353,7 +357,7 @@ let derive_profile ?(indir = "") ?(ns = 0) ~preview ~fast_mode ~no_Ne ~ne_test ~
if only_simu then
[]
else
derive_det ~dataset_l ~preview ~fast_mode
derive_det ~dataset_l ~preview ~use_diffsel ~use_c60
in
let post_analyses_res = Post_analyses.post_analyses_res_of_dataset_results_l ~tree_prefix ~dataset_results_l in
let repo_per_tree = [
......@@ -401,29 +405,14 @@ let logger =
time_logger#logger ;
]
let detection_main ~outdir ~indir ?(np = 2) ?(mem = 2) ~preview ~fast_mode ?(seed = Random.int Int.max_value) () =
let dataset_l = parse_input_data ~seed indir in
let dataset_results_l = derive_det ~dataset_l ~preview ~fast_mode in
let repo = repo_of_dataset_results_l ~dataset_results_l in
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo
let simulation_main ~outdir ?(ns = 0) ?(np = 2) ?(mem = 2) ~tree_dir ~profile_fn ~preview ~use_concat ~no_Ne ~no_HaPC ~add_indels ?(seed = Random.int Int.max_value) () =
let nb_sites = if ns = 0 then (if preview then 20 else 50) else ns in
let profile = Profile.profile_l_of_splitted_profile ~nb_cat:All ~nb_sites profile_fn ~seed:(Random.int Int.max_value) in
let trees = Array.to_list @@ Sys.readdir tree_dir in
let dataset_l = derive_sim ~tree_dir ~trees ~profile ~preview ~use_concat ~ns ~no_Ne ~no_HaPC ~ne_test:false ~add_indels ~seed in
let repo = Dataset.repo dataset_l ~preview in
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo
let validation_main ~outdir ?(indir = "") ?(ns = 0) ?(np = 2) ?(mem = 2) ~preview ~fast_mode ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile_fn ~use_concat ~add_indels ~only_simu ?(seed = Random.int Int.max_value) () =
let validation_main ~outdir ?(indir = "") ?(ns = 0) ?(np = 2) ?(mem = 2) ~preview ~use_diffsel ~use_c60 ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile_fn ~use_concat ~add_indels ~only_simu ?(seed = Random.int Int.max_value) () =
printf "Global seed: %i\n" seed;
Out_channel.write_all "global.seed" ~data:(string_of_int seed);
(* simulated trees *)
Random.init seed ;
let nb_sites = if ns = 0 then (if preview then 20 else 50) else ns in
let profile = Profile.profile_l_of_splitted_profile ~nb_cat:All ~nb_sites profile_fn ~seed:(Random.int Int.max_value) in
let sim_repo_l = derive_profile ~indir ~ns ~preview ~fast_mode ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile ~use_concat ~add_indels ~only_simu ~seed () in
let sim_repo_l = derive_profile ~indir ~ns ~preview ~use_diffsel ~use_c60 ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile ~use_concat ~add_indels ~only_simu ~seed () in
(* real trees *)
let indir_dataset_l = if indir = "" then [] else parse_input_data ~seed indir in
let dataset_l = indir_dataset_l in
......@@ -431,7 +420,7 @@ let validation_main ~outdir ?(indir = "") ?(ns = 0) ?(np = 2) ?(mem = 2) ~previe
if only_simu then
[]
else
derive_det ~dataset_l ~preview ~fast_mode
derive_det ~dataset_l ~preview ~use_diffsel ~use_c60
in
let repo_real_trees = [
Dataset.repo dataset_l ~preview ;
......@@ -442,62 +431,6 @@ let validation_main ~outdir ?(indir = "") ?(ns = 0) ?(np = 2) ?(mem = 2) ~previe
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo ;
time_logger#report sim_repo_l#dataset_results (Filename.concat outdir ("elapsed_time_" ^ (Unix.time () |> int_of_float |> string_of_int) ^ ".tsv"))
let simulation_command =
let open Command.Let_syntax in
Command.basic
~summary:"Run simulation pipeline"
[%map_open
let outdir =
flag "--outdir" (required string) ~doc:"PATH Output directory"
and preview =
flag "--preview-mode" no_arg ~doc:" Preview mode"
and no_Ne =
flag "--no-ne" no_arg ~doc:" mode without hypothesis including different Ne"
and no_HaPC =
flag "--no-hapc" no_arg ~doc:" mode without ~HaPC hypothesis"
and ns =
flag "--ns" (optional int) ~doc:"INT Number of sites to simulate"
and np =
flag "--np" (optional int) ~doc:"INT Number of available processors"
and mem =
flag "--mem" (optional int) ~doc:"INT Available memory (in GB)"
and use_concat =
flag "--use-concat" no_arg ~doc:" Use concatenation H0+Ha_pcoc"
and add_indels =
flag "--add-indels" no_arg ~doc:" add indels in H*NeG5"
and tree_dir =
flag "--tree-dir" (required string) ~doc:"PATH Path to tree directory"
and profile_fn =
flag "--profile-fn" (required string) ~doc:"PATH Path to profile file"
and seed =
flag "--seed" (optional int) ~doc:"INT Global seed"
in
simulation_main ~outdir ?ns ?np ?mem ~no_Ne ~no_HaPC ~tree_dir ~profile_fn ~preview ~use_concat ~add_indels ?seed
]
let detection_command =
let open Command.Let_syntax in
Command.basic
~summary:"Run simulation pipeline"
[%map_open
let outdir =
flag "--outdir" (required string) ~doc:"PATH Output directory"
and indir =
flag "--indir" (required string) ~doc:"PATH Input directory"
and preview =
flag "--preview-mode" no_arg ~doc:" Preview mode"
and fast_mode =
flag "--fast" no_arg ~doc:" 'Fast' mode without the most costly methods"
and np =
flag "--np" (optional int) ~doc:"INT Number of available processors"
and mem =
flag "--mem" (optional int) ~doc:"INT Available memory (in GB)"
and seed =
flag "--seed" (optional int) ~doc:"INT Global seed"
in
detection_main ~outdir ~indir ?np ?mem ~preview ~fast_mode ?seed
]
let validation_command =
let _ = Random.self_init() in
let open Command.Let_syntax in
......@@ -510,8 +443,10 @@ let validation_command =
flag "--indir" (optional string) ~doc:"PATH Input directory"
and preview =
flag "--preview-mode" no_arg ~doc:" Preview mode"
and fast_mode =
flag "--fast" no_arg ~doc:" 'Fast' mode without the most costly methods"
and use_diffsel =
flag "--diffsel" no_arg ~doc:" use the diffsel method (very slow)."
and use_c60 =
flag "--c60" no_arg ~doc:" use the pcoc c60 method (slow)."
and ne_test =
flag "--ne-test" no_arg ~doc:" mode with hypothesis in test including different Ne"
and no_Ne =
......@@ -537,5 +472,5 @@ let validation_command =
and seed =
flag "--seed" (optional int) ~doc:"INT Global seed"
in
validation_main ~outdir ?indir ?ns ?np ?mem ~preview ~fast_mode ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile_fn ~use_concat ~only_simu ~add_indels ?seed
validation_main ~outdir ?indir ?ns ?np ?mem ~preview ~use_diffsel ~use_c60 ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile_fn ~use_concat ~only_simu ~add_indels ?seed
]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment