Commit bfeb4be8 authored by Carine Rey's avatar Carine Rey
Browse files

add a optional option "--ns" to change the number of sites to simulate

parent f27431c6
......@@ -44,9 +44,9 @@ let parse_input_data indir =
)
|> List.concat
let derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview =
let derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview ~ns =
let model_prefix = Convergence_hypothesis.string_of_model model in
let nb_sites = if preview then 20 else 50 in
let nb_sites = if ns = 0 then (if preview then 20 else 50) else ns in
let nodes = Tree_dataset.nodes tree_dataset model in
let tree = Tree_dataset.tree tree_dataset `Simulation in
let descr = "."^model_prefix^"."^tree_prefix in
......@@ -73,7 +73,7 @@ let derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~
let ready_dataset = { Ready_dataset.input_tree = input_tree ; tree_dataset ; fna; faa; fna_infos} in
{ Dataset.model_prefix; is_real= false; tree_prefix; dataset = ready_dataset }
let derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat =
let derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat ~ns =
let tree_prefix = Filename.chop_extension tree in
let input_tree = input (Filename.concat tree_dir tree) in
let tree_dataset = Tree_dataset.prepare input_tree in
......@@ -95,18 +95,18 @@ let derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat =
HaPC_NeBig ;
] in
let dataset_per_hypo = List.map models ~f:(fun model ->
derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview
derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview ~ns
) in
let ready_dataset_H0 = (derive_from_model ~model:H0 ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview).dataset in
let ready_dataset_HaPCOC = (derive_from_model ~model:HaPCOC ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview).dataset in
let ready_dataset_H0 = (derive_from_model ~model:H0 ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview ~ns).dataset in
let ready_dataset_HaPCOC = (derive_from_model ~model:HaPCOC ~input_tree ~tree_dataset ~tree_prefix ~profile_f ~preview ~ns).dataset in
let concat_H0Ha = {Dataset.model_prefix="H0+HaPCOC"; tree_prefix; is_real = false; dataset = Ready_dataset.paste ready_dataset_H0 ready_dataset_HaPCOC} in
let dataset_concat_hypos = if use_concat then [concat_H0Ha;] else [] in
List.concat [ dataset_per_hypo ; dataset_concat_hypos ]
let derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat =
let derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat ~ns =
let profile_f = input profile_fn in
List.map trees ~f:(fun tree ->
derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat)
derive_from_tree ~tree_dir ~tree ~profile_f ~preview ~use_concat ~ns)
|> List.concat
......@@ -236,19 +236,19 @@ let detection_main ~outdir ~indir ?(np = 2) ?(mem = 2) ~preview ~no_diffsel () =
let repo = repo_of_dataset_results_l ~dataset_results_l in
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo
let simulation_main ~outdir ?(np = 2) ?(mem = 2) ~tree_dir ~profile_fn ~preview ~use_concat () =
let simulation_main ~outdir ?(ns = 0) ?(np = 2) ?(mem = 2) ~tree_dir ~profile_fn ~preview ~use_concat () =
let trees = Array.to_list @@ Sys.readdir tree_dir in
let dataset_l = derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat in
let dataset_l = derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat ~ns in
let repo = Dataset.repo dataset_l ~preview in
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo
let validation_main ~outdir ~indir ?(np = 2) ?(mem = 2) ~preview ~no_diffsel ~tree_dir ~profile_fn ~use_concat () =
let validation_main ~outdir ~indir ?(ns = 0) ?(np = 2) ?(mem = 2) ~preview ~no_diffsel ~tree_dir ~profile_fn ~use_concat () =
let trees = Array.to_list @@ Sys.readdir tree_dir in
let repo = List.map trees ~f:(fun tree ->
let trees = [tree] in
let tree_prefix = Filename.chop_extension tree in
let dataset_l =
derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat
derive_sim ~tree_dir ~trees ~profile_fn ~preview ~use_concat ~ns
@ parse_input_data indir in
let dataset_results_l = derive_det ~dataset_l ~preview ~no_diffsel in
let post_analyses = Post_analyses.post_analyses_of_dataset_results_l ~dataset_results_l in
......@@ -273,6 +273,8 @@ let simulation_command =
flag "--outdir" (required string) ~doc:"PATH Output directory"
and preview =
flag "--preview-mode" no_arg ~doc:" Preview mode"
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 =
......@@ -284,7 +286,7 @@ let simulation_command =
and profile_fn =
flag "--profile-fn" (required string) ~doc:"PATH Path to profile file"
in
simulation_main ~outdir ?np ?mem ~tree_dir ~profile_fn ~preview ~use_concat
simulation_main ~outdir ?ns ?np ?mem ~tree_dir ~profile_fn ~preview ~use_concat
]
let detection_command =
......@@ -323,6 +325,8 @@ let validation_command =
flag "--no-diffsel" no_arg ~doc:" No diffsel mode"
and use_concat =
flag "--use-concat" no_arg ~doc:" Use concatenation H0+Ha_pcoc"
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 =
......@@ -332,5 +336,5 @@ let validation_command =
and profile_fn =
flag "--profile-fn" (required string) ~doc:"PATH Path to profile file"
in
validation_main ~outdir ~indir ?np ?mem ~preview ~no_diffsel ~tree_dir ~profile_fn ~use_concat
validation_main ~outdir ~indir ?ns ?np ?mem ~preview ~no_diffsel ~tree_dir ~profile_fn ~use_concat
]
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