pipeline.ml 18.9 KB
Newer Older
Philippe Veber's avatar
Philippe Veber committed
1
open Core
Philippe Veber's avatar
Philippe Veber committed
2
open Bistro_utils
LANORE Vincent's avatar
LANORE Vincent committed
3
open Bistro.EDSL
Carine Rey's avatar
typing  
Carine Rey committed
4
open Bistro.Std
5
open File_formats
Philippe Veber's avatar
Philippe Veber committed
6
open Defs
Carine Rey's avatar
Carine Rey committed
7
open Convergence_detection
8
open Profile
9

10 11 12
let parse_input_data indir =
  let datasets = Array.to_list @@ Sys.readdir indir in
  List.map datasets ~f:(fun dataset_prefix ->
LANORE Vincent's avatar
LANORE Vincent committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
      let files = Array.to_list @@ Sys.readdir (Filename.concat indir dataset_prefix ) in
      if List.length files = 2 then
        let h_file = List.hd files in
        let h_file = match h_file with
          | Some s -> s
          | None -> ""
        in
        let h_file_ext = Filename.split_extension h_file in
        let t_file = List.nth files 1 in
        let t_file = match t_file with
          | Some s -> s
          | None -> ""
        in
        let t_file_ext = Filename.split_extension t_file in
        let fna, input_tree = match (h_file_ext, t_file_ext) with
          | ( _ , Some "fna") ,  ( _ , Some "nhx") -> h_file, t_file
          | ( _ , Some "nhx"), ( _ , Some "fna") -> t_file, h_file
          | _ -> failwith ({|Syntax error: extension errors in |} ^ (Filename.concat indir dataset_prefix ) ^ " nhx: " ^ (h_file) ^ " fna: " ^ (t_file))
        in
        let tree_prefix = Filename.chop_extension input_tree in
        let input_tree = input (Filename.concat indir (Filename.concat dataset_prefix input_tree)) in
        let fna = input (Filename.concat indir (Filename.concat dataset_prefix fna)) in
        let fna_infos = None in
        let raw_dataset =  Raw_dataset.{input_tree; fna; fna_infos} in
        let dataset = {Dataset.model_prefix = tree_prefix;
                       is_real = true;
                       tree_prefix = dataset_prefix;
                       dataset = Ready_dataset.of_raw raw_dataset
                      } in
        [dataset]
      else
44
        failwith ({|More than 2 files in |} ^ (Filename.concat indir dataset_prefix ))
45 46 47
    )
  |> List.concat

48
let derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile ~preview ~ns =
49
  let model_prefix = Convergence_hypothesis.string_of_model model in
50
  let nb_sites = ns in
51
  let nodes = Tree_dataset.nodes tree_dataset model in
Philippe Veber's avatar
Philippe Veber committed
52
  let tree = Tree_dataset.tree tree_dataset `Simulation in
53
  let descr = "."^model_prefix^"."^tree_prefix in
Carine Rey's avatar
Carine Rey committed
54
  (* only 1 profile or 1 couple of profiles*)
LANORE Vincent's avatar
LANORE Vincent committed
55
  (*let config = Convergence_hypothesis.bpp_config nodes model in
Carine Rey's avatar
Carine Rey committed
56
    let fna = Bppsuite.bppseqgen ~descr ~nb_sites ~tree ~config in
LANORE Vincent's avatar
LANORE Vincent committed
57
  *)
Carine Rey's avatar
Carine Rey committed
58 59
  (* with several profiles or couples of profiles *)
  let config_p = Convergence_hypothesis.bpp_config_F nodes model in
60
  let ne_c = match model with
Carine Rey's avatar
Carine Rey committed
61
    | H0_NeVerySmall -> 0.001
62 63 64 65 66 67
    | H0_NeSmall -> 0.1
    | HaPCOC_NeSmall -> 0.1
    | HaPC_NeSmall -> 0.1
    | H0_NeBig -> 10.
    | HaPC_NeBig -> 10.
    | HaPCOC_NeBig -> 10.
68 69
    | H0_BigNeInSmallNe -> 10.
    | H0_SmallNeInBigNe -> 0.1
70 71
    | HaPC_BigNeInSmallNe -> 10.
    | HaPC_SmallNeInBigNe -> 0.1
72 73
    | _ -> 1.
  in
74 75 76
  let ne_a = match model with
    | H0_BigNeInSmallNe -> 0.1
    | H0_SmallNeInBigNe -> 10.
77 78
    | HaPC_BigNeInSmallNe -> 0.1
    | HaPC_SmallNeInBigNe -> 10.
79 80
    | _ -> 1.
  in
81 82 83
  let profile_f = profile.profile_f in
  let profile_c = profile.profile_c in
  let run_fna = Bppsuite.bppseqgen_multi_profiles ~descr ~nb_sites ~tree ~config:config_p ~profile_f ~profile_c ~ne_c ~ne_a in
Carine Rey's avatar
Carine Rey committed
84 85
  let fna = Bppsuite.bppseqgen_multi_profiles_get_fa run_fna in
  let fna_infos = Some (Bppsuite.bppseqgen_multi_profiles_get_info run_fna) in
Carine Rey's avatar
Carine Rey committed
86

87
  let faa = Bppsuite.fna2faa ~fna in
Carine Rey's avatar
Carine Rey committed
88 89
  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 }
Carine Rey's avatar
Carine Rey committed
90

91
let derive_from_tree ~tree_dir ~tree ~profile ~preview ~use_concat ~ns ~no_Ne ~no_HaPC ~ne_test =
Carine Rey's avatar
Carine Rey committed
92
  let tree_prefix = Filename.chop_extension tree in
93 94
  let input_tree = input (Filename.concat tree_dir tree) in
  let tree_dataset = Tree_dataset.prepare input_tree in
Carine Rey's avatar
Carine Rey committed
95 96
  let models = Convergence_hypothesis.[
      [
LANORE Vincent's avatar
LANORE Vincent committed
97 98
        H0              ;
        HaPCOC          ;
Carine Rey's avatar
Carine Rey committed
99
      ];
Carine Rey's avatar
Carine Rey committed
100 101
      if preview then
        []
Carine Rey's avatar
Carine Rey committed
102
      else
Carine Rey's avatar
Carine Rey committed
103 104 105 106 107 108 109 110 111 112 113
        [(
          if no_HaPC then
            []
          else
            [HaPC           ;
            ]
        )
         ;
         (if no_Ne then
            []
          else
114
            [H0_NeSmall      ;
Carine Rey's avatar
Carine Rey committed
115 116 117
             HaPC_NeSmall    ;
             H0_NeBig        ;
             HaPC_NeBig      ;
Carine Rey's avatar
Carine Rey committed
118 119 120
            ]
         );
         (if ne_test then
121
            [
Carine Rey's avatar
Carine Rey committed
122 123 124 125
              H0_BigNeInSmallNe;
              H0_SmallNeInBigNe;
              HaPC_BigNeInSmallNe;
              HaPC_SmallNeInBigNe;
Carine Rey's avatar
Carine Rey committed
126
            ]
Carine Rey's avatar
Carine Rey committed
127 128
          else
            []
Carine Rey's avatar
Carine Rey committed
129 130
         )
        ] |> List.concat
Carine Rey's avatar
Carine Rey committed
131
    ] |> List.concat
Carine Rey's avatar
Carine Rey committed
132
  in
Carine Rey's avatar
Carine Rey committed
133
  let dataset_per_hypo = List.map models ~f:(fun model ->
134
      derive_from_model ~model ~input_tree ~tree_dataset ~tree_prefix ~profile ~preview ~ns
LANORE Vincent's avatar
LANORE Vincent committed
135
    ) in
136 137
  let ready_dataset_H0 = (derive_from_model ~model:H0 ~input_tree ~tree_dataset ~tree_prefix ~profile ~preview ~ns).dataset in
  let ready_dataset_HaPCOC = (derive_from_model ~model:HaPCOC ~input_tree ~tree_dataset ~tree_prefix ~profile ~preview ~ns).dataset in
138 139 140 141
  let ready_dataset_HaPC = (derive_from_model ~model:HaPC ~input_tree ~tree_dataset ~tree_prefix ~profile ~preview ~ns).dataset in
  let concat_H0HaPCOC = {Dataset.model_prefix="H0+HaPCOC"; tree_prefix; is_real = false; dataset = Ready_dataset.paste ready_dataset_H0 ready_dataset_HaPCOC} in
  let concat_H0HaPC = {Dataset.model_prefix="H0+HaPC"; tree_prefix; is_real = false; dataset = Ready_dataset.paste ready_dataset_H0 ready_dataset_HaPC} in
  let dataset_concat_hypos = if use_concat then [concat_H0HaPC;] else [] in
Carine Rey's avatar
Carine Rey committed
142
  List.concat [ dataset_per_hypo ; dataset_concat_hypos ]
143

144
let derive_sim ~tree_dir ~trees ~profile ~preview ~use_concat ~ns ~no_Ne ~no_HaPC ~ne_test =
LANORE Vincent's avatar
LANORE Vincent committed
145
  List.map trees ~f:(fun tree ->
146
      derive_from_tree ~tree_dir ~tree ~profile ~preview ~use_concat ~ns ~no_Ne ~no_HaPC ~ne_test)
LANORE Vincent's avatar
LANORE Vincent committed
147 148
  |> List.concat

Carine Rey's avatar
Carine Rey committed
149

Philippe Veber's avatar
Philippe Veber committed
150 151 152
let repo_of_detection_result res =
  let det_meth_prefix = Convergence_detection.meth_string_of_result res in
  Repo.[
153
    [ match res with
Philippe Veber's avatar
Philippe Veber committed
154 155
      | `Pcoc w -> item ["pcoc.results.tsv"] (Pcoc.results w)
      | `Pcoc_gamma w -> item ["pcoc_gamma.results.tsv"] (Pcoc.results w)
Carine Rey's avatar
Carine Rey committed
156
      | `Pcoc_C60 w -> item ["pcoc_C60.results.tsv"] (Pcoc.results w)
Philippe Veber's avatar
Philippe Veber committed
157
      | `Diffsel w -> item ["diffsel.results.tsv"] (Diffsel.selector w)
Carine Rey's avatar
Carine Rey committed
158 159
      | `Identical_LG w -> item ["Identical_LG.results.tsv"] (Identical.results w)
      | `Identical_WAG w -> item ["Identical_WAG.results.tsv"] (Identical.results w)
160 161 162
      | `Topological_LG w -> item ["Topological_LG.results.tsv"] (Topological.results w)
      | `Topological_WAG w -> item ["Topological_WAG.results.tsv"] (Topological.results w)
      | `Tdg09 w -> item ["Tdg09.results.tsv"] (Tamuri.results w)
163
      | `Multinomial w -> item ["Multinomial.results.tsv"] (Multinomial.results w)
164
      | `Msd w -> item ["Msd.results.tsv"] (Msd.results w)
165 166
    ] ;
    [
Philippe Veber's avatar
Philippe Veber committed
167 168 169
      match res with
      | `Pcoc w -> item ["raw_results"]  w
      | `Pcoc_gamma w -> item ["raw_results"] w
Carine Rey's avatar
Carine Rey committed
170
      | `Pcoc_C60 w -> item ["raw_results"] w
Philippe Veber's avatar
Philippe Veber committed
171
      | `Diffsel w -> item ["raw_results"] w
Carine Rey's avatar
Carine Rey committed
172 173
      | `Identical_LG w -> item ["raw_results"] w
      | `Identical_WAG w -> item ["raw_results"] w
174 175 176
      | `Topological_LG w -> item ["raw_results"] w
      | `Topological_WAG w -> item ["raw_results"] w
      | `Tdg09 w -> item ["raw_results"] w
177
      | `Multinomial w -> item ["raw_results"] w
178
      | `Msd w -> item ["raw_results"] w
179
    ] ;
180 181 182
    match res with
    | `Diffsel w -> [item ["chain_convergence_checking.html"] ((Diffsel.check_conv w) / selector ["out.html"])]
    | _ -> []
183
  ] |> List.concat
Philippe Veber's avatar
Philippe Veber committed
184 185 186
  |> Repo.shift det_meth_prefix
  |> Repo.shift "Detection_tools"

187
let repo_of_dataset_results_l ~dataset_results_l =
Carine Rey's avatar
Carine Rey committed
188
  List.map dataset_results_l ~f:(fun dataset_results ->
LANORE Vincent's avatar
LANORE Vincent committed
189 190 191
      let det_results_l = dataset_results.res_by_tools in
      let merged_results = dataset_results.merged_results in
      let plot_merge_results = dataset_results.plot_merged_results in
192 193
      let model_prefix = dataset_results.model_prefix in
      let tree_prefix = dataset_results.tree_prefix in
Carine Rey's avatar
Carine Rey committed
194
      let merged_results_item = Repo.item [tree_prefix ^"."^model_prefix^".merged_results.tsv"] merged_results in
195
      let plot_merged_results_item = Repo.item [tree_prefix ^"."^model_prefix^".plot_merged_results.svg"] plot_merge_results in
LANORE Vincent's avatar
LANORE Vincent committed
196 197 198 199 200 201 202 203
      let repo =
        merged_results_item ::
        plot_merged_results_item ::
        (List.map det_results_l ~f:repo_of_detection_result |> List.concat)
      in
      repo
      |> Repo.shift dataset_results.model_prefix
    )
Carine Rey's avatar
Carine Rey committed
204 205
  |> List.concat

206 207 208
let derive_from_det_meth ~det_meth ~(dataset : Dataset.t) ~preview =
  let faa = dataset.dataset.faa in
  let fna = dataset.dataset.fna in
Carine Rey's avatar
Carine Rey committed
209
  let phy_n = Bppsuite.fa2phy ~fna in
Carine Rey's avatar
Carine Rey committed
210 211
  let tree_sc = Tree_dataset.tree dataset.dataset.tree_dataset `Detection in
  let tree_id = Tree_dataset.tree dataset.dataset.tree_dataset `Simulation in
212
  let diffsel_tree = Tree_dataset.diffsel_tree dataset.dataset.tree_dataset in
213
  let tree_conv = Tree_dataset.topological_tree dataset.dataset.tree_dataset in
214 215
  let w_every = if preview then 1 else 1 in
  let n_cycles = if preview then 10 else 2000 in
Philippe Veber's avatar
Philippe Veber committed
216
  match det_meth with
LANORE Vincent's avatar
LANORE Vincent committed
217 218
  | `Pcoc -> `Pcoc (Pcoc.pcoc ~catx_est:10 ~plot_complete:true ~gamma:false ~faa ~tree:tree_sc)
  | `Pcoc_gamma -> `Pcoc_gamma (Pcoc.pcoc ~catx_est:10 ~plot_complete: true ~gamma:true ~faa ~tree:tree_sc)
Carine Rey's avatar
Carine Rey committed
219
  | `Pcoc_C60 -> `Pcoc_C60 (Pcoc.pcoc ~catx_est:60 ~plot_complete: true ~gamma:false ~faa ~tree:tree_sc)
LANORE Vincent's avatar
LANORE Vincent committed
220
  | `Tdg09 -> `Tdg09 (Tamuri.tdg09 ~faa ~tree:tree_sc)
221
  | `Diffsel -> `Diffsel (Diffsel.diffsel ~phy_n ~tree:diffsel_tree ~w_every ~n_cycles ~id:1 ~tag:"master_2304" )
LANORE Vincent's avatar
LANORE Vincent committed
222 223 224 225
  | `Identical_LG -> `Identical_LG (Identical.identical ~faa ~tree_id ~tree_sc ~prot_model:"LG08")
  | `Identical_WAG -> `Identical_WAG (Identical.identical ~faa ~tree_id ~tree_sc ~prot_model:"WAG01")
  | `Topological_LG -> `Topological_LG (Topological.topological ~faa ~tree:tree_id ~tree_conv ~prot_model:"LG08")
  | `Topological_WAG -> `Topological_WAG (Topological.topological ~faa ~tree:tree_id ~tree_conv ~prot_model:"WAG01")
226
  | `Multinomial -> `Multinomial (Multinomial.multinomial ~faa ~tree_id ~tree_sc)
227
  | `Msd -> `Msd (Msd.msd ~faa ~tree_sc)
Carine Rey's avatar
Carine Rey committed
228 229


230
let derive_from_dataset ~dataset ~preview ~fast_mode=
Carine Rey's avatar
Carine Rey committed
231
  let det_meths = [
LANORE Vincent's avatar
LANORE Vincent committed
232 233 234
    [`Pcoc;
     `Tdg09;
     `Identical_LG;
235
     `Topological_LG;
236 237
     `Multinomial;
     `Msd] ;
LANORE Vincent's avatar
LANORE Vincent committed
238 239 240
    if preview then
      []
    else
241
      [`Pcoc_gamma;
LANORE Vincent's avatar
LANORE Vincent committed
242 243 244 245
       `Identical_WAG;
       `Topological_WAG;
      ]
    ;
246
    if fast_mode then
LANORE Vincent's avatar
LANORE Vincent committed
247 248
      []
    else
249
      [`Diffsel; `Pcoc_C60;] ;
LANORE Vincent's avatar
LANORE Vincent committed
250 251
  ]
    |> List.concat in
252
  let res_by_tools = List.map det_meths ~f:(fun det_meth ->
LANORE Vincent's avatar
LANORE Vincent committed
253
      derive_from_det_meth ~det_meth ~dataset ~preview
254
    ) in
Carine Rey's avatar
Carine Rey committed
255 256
  let fna_infos = dataset.dataset.fna_infos in
  let merged_results = merge_results ~fna_infos ~res_by_tools () in
Carine Rey's avatar
Carine Rey committed
257
  let tsv = merged_results in
258 259
  let faa = dataset.dataset.faa in
  let tree = Tree_dataset.tree dataset.dataset.tree_dataset `Detection in
Carine Rey's avatar
Carine Rey committed
260
  let plot_all_sites = if dataset.is_real then false else true in
261
  let plot_merged_results = plot_merge_results ~plot_all_sites ~res_by_tools ~tsv ~faa ~tree () in
Carine Rey's avatar
Carine Rey committed
262 263
  let model_prefix = dataset.model_prefix in
  let tree_prefix = dataset.tree_prefix in
Carine Rey's avatar
Carine Rey committed
264
  {model_prefix; tree_prefix; dataset; res_by_tools ; merged_results ; plot_merged_results}
Carine Rey's avatar
Carine Rey committed
265

266
let derive_det ~dataset_l ~preview ~fast_mode =
Carine Rey's avatar
Carine Rey committed
267
  List.map dataset_l ~f:(fun dataset ->
268
      derive_from_dataset ~preview ~dataset ~fast_mode)
Carine Rey's avatar
Carine Rey committed
269

270
let derive_profile ?(indir = "") ?(ns = 0) ~preview ~fast_mode ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile ~use_concat ~only_simu () =
LANORE Vincent's avatar
LANORE Vincent committed
271
  let trees = Array.to_list @@ Sys.readdir tree_dir in
272
  let simu_dataset_l = derive_sim ~tree_dir ~trees ~profile ~preview ~use_concat ~ns ~no_Ne ~no_HaPC ~ne_test in
Carine Rey's avatar
Carine Rey committed
273 274
  let post_analyses_simu = Post_analyses.post_analyses_simu_of_simu_dataset_l ~simu_dataset_l in
  let repo_of_post_analyses_simu = Post_analyses.repo_of_post_analyses_simu ~post_analyses_simu in
Carine Rey's avatar
Carine Rey committed
275
  let repo_and_post_analyses_per_tree_simu = List.map trees ~f:(fun tree -> (*to keep together all models per tree*)
276 277 278
      let trees = [tree] in
      let tree_prefix = Filename.chop_extension tree in
      let dataset_l =
279
        derive_sim ~tree_dir ~trees ~profile ~preview ~use_concat ~ns ~no_Ne ~no_HaPC ~ne_test in
Carine Rey's avatar
Carine Rey committed
280
      let dataset_results_l =
281
        if only_simu then
Carine Rey's avatar
Carine Rey committed
282 283 284 285 286
          []
        else
          derive_det ~dataset_l ~preview ~fast_mode
      in
      let post_analyses_res = Post_analyses.post_analyses_res_of_dataset_results_l ~dataset_results_l in
287 288
      let repo_per_tree = [
        Dataset.repo dataset_l ~preview ;
Carine Rey's avatar
Carine Rey committed
289 290 291 292 293 294
        Repo.shift "Results_per_hypothesis" (repo_of_dataset_results_l ~dataset_results_l);
        Post_analyses.repo_of_post_analyses_res ~prefix:tree_prefix ~post_analyses_res;
      ]
        |> List.concat
        |> Repo.shift tree_prefix
        |> Repo.shift "Results_per_tree"
295
      in
Carine Rey's avatar
Carine Rey committed
296 297
      (repo_per_tree, post_analyses_res)
    )
298
  in
Carine Rey's avatar
Carine Rey committed
299 300
  let all_repo_per_tree_simu = List.map repo_and_post_analyses_per_tree_simu ~f:(fun (r,p) -> r) |> List.concat in
  let all_post_analyses_per_tree = List.map repo_and_post_analyses_per_tree_simu ~f:(fun (r,p) -> p) in
301 302
  let profile_prefix = profile.profile_n in
  let repo_post_analyses_all_trees = Post_analyses.repo_post_analyses_all_trees_of_all_post_analyses_per_tree ~all_post_analyses_per_tree ~profile_prefix in
303 304 305 306 307 308 309
  let repo_post_analyses_all_trees = if only_simu then
      []
    else
      repo_post_analyses_all_trees
  in
  let repo = repo_of_post_analyses_simu @ all_repo_per_tree_simu @ repo_post_analyses_all_trees in
  Repo.shift profile_prefix repo
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325


let logger =
  Logger.tee [
    Console_logger.create () ;
    Dot_output.create "dag.dot" ; (*dot -Tpdf example/dag.dot -o dag.pdf*)
    Bistro_utils.Html_logger.create "report.html" ;
  ]

let detection_main ~outdir ~indir ?(np = 2) ?(mem = 2) ~preview ~fast_mode () =
  let dataset_l = parse_input_data 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 () =
326 327
  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:1 ~nb_sites profile_fn in
328 329 330 331 332 333 334
  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 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 ~only_simu () =
  (* simulated trees *)
335 336 337
  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:3 ~nb_sites profile_fn in
  let sim_repo_l =  derive_profile ~indir ~ns ~preview ~fast_mode ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile ~use_concat ~only_simu () in
338 339 340 341
  (* real trees *)
  let indir_dataset_l = if indir = "" then [] else parse_input_data indir in
  let dataset_l = indir_dataset_l in
  let dataset_results_l =
342
    if only_simu then
343 344 345 346 347 348 349 350
      []
    else
      derive_det ~dataset_l ~preview ~fast_mode
  in
  let repo_real_trees = [
    Dataset.repo dataset_l ~preview ;
    repo_of_dataset_results_l ~dataset_results_l ;
  ] |> List.concat
Carine Rey's avatar
Carine Rey committed
351
  in
Carine Rey's avatar
Carine Rey committed
352
  let repo = (Repo.shift "Simulated_datasets" sim_repo_l) @ (Repo.shift "Real_datasets" repo_real_trees) in
Philippe Veber's avatar
Philippe Veber committed
353 354
  Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo

LANORE Vincent's avatar
LANORE Vincent committed
355
let simulation_command =
Philippe Veber's avatar
Philippe Veber committed
356 357 358 359 360
  let open Command.Let_syntax in
  Command.basic
    ~summary:"Run simulation pipeline"
    [%map_open
      let outdir =
LANORE Vincent's avatar
LANORE Vincent committed
361 362 363
        flag "--outdir" (required string) ~doc:"PATH Output directory"
      and preview =
        flag "--preview-mode" no_arg ~doc:" Preview mode"
Carine Rey's avatar
Carine Rey committed
364 365
      and no_Ne =
        flag "--no-ne" no_arg ~doc:" mode without hypothesis including different Ne"
Carine Rey's avatar
Carine Rey committed
366 367
      and no_HaPC =
        flag "--no-hapc" no_arg ~doc:" mode without ~HaPC hypothesis"
368 369
      and ns =
        flag "--ns" (optional int) ~doc:"INT Number of sites to simulate"
Philippe Veber's avatar
Philippe Veber committed
370 371 372 373
      and np =
        flag "--np" (optional int) ~doc:"INT Number of available processors"
      and mem =
        flag "--mem" (optional int) ~doc:"INT Available memory (in GB)"
374 375
      and use_concat =
        flag "--use-concat" no_arg ~doc:" Use concatenation H0+Ha_pcoc"
LANORE Vincent's avatar
LANORE Vincent committed
376 377
      and tree_dir =
        flag "--tree-dir" (required string) ~doc:"PATH Path to tree directory"
378 379
      and profile_fn =
        flag "--profile-fn" (required string) ~doc:"PATH Path to profile file"
Philippe Veber's avatar
Philippe Veber committed
380
      in
Carine Rey's avatar
Carine Rey committed
381
      simulation_main ~outdir ?ns ?np ?mem ~no_Ne ~no_HaPC ~tree_dir ~profile_fn ~preview ~use_concat
LANORE Vincent's avatar
LANORE Vincent committed
382 383 384 385 386 387 388 389 390 391 392 393 394
    ]

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"
395 396
      and fast_mode =
        flag "--fast" no_arg ~doc:" 'Fast' mode without the most costly methods"
LANORE Vincent's avatar
LANORE Vincent committed
397 398 399 400 401
      and np =
        flag "--np" (optional int) ~doc:"INT Number of available processors"
      and mem =
        flag "--mem" (optional int) ~doc:"INT Available memory (in GB)"
      in
402
      detection_main ~outdir ~indir ?np ?mem ~preview ~fast_mode
LANORE Vincent's avatar
LANORE Vincent committed
403 404
    ]

Philippe Veber's avatar
Philippe Veber committed
405 406 407 408 409 410 411 412
let validation_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 =
413
        flag "--indir" (optional string) ~doc:"PATH Input directory"
Philippe Veber's avatar
Philippe Veber committed
414 415
      and preview =
        flag "--preview-mode" no_arg ~doc:" Preview mode"
416 417
      and fast_mode =
        flag "--fast" no_arg ~doc:" 'Fast' mode without the most costly methods"
Carine Rey's avatar
Carine Rey committed
418 419
      and ne_test =
        flag "--ne-test" no_arg ~doc:" mode with hypothesis in test including different Ne"
Carine Rey's avatar
Carine Rey committed
420 421
      and no_Ne =
        flag "--no-ne" no_arg ~doc:" mode without hypothesis including different Ne"
Carine Rey's avatar
Carine Rey committed
422 423
      and no_HaPC =
        flag "--no-hapc" no_arg ~doc:" mode without ~HaPC hypothesis"
Carine Rey's avatar
Carine Rey committed
424 425
      and only_simu =
        flag "--only-simu" no_arg ~doc:" mode only simulation"
426 427
      and use_concat =
        flag "--use-concat" no_arg ~doc:" Use concatenation H0+Ha_pcoc"
428
      and ns =
429
        flag "--ns" (optional int) ~doc:"INT Number of sites to simulate (WARNING: will be multiplicated per 3)"
Philippe Veber's avatar
Philippe Veber committed
430 431 432 433 434 435 436 437 438
      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 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"
      in
Carine Rey's avatar
Carine Rey committed
439
      validation_main ~outdir ?indir ?ns ?np ?mem ~preview ~fast_mode ~no_Ne ~ne_test ~no_HaPC ~tree_dir ~profile_fn ~use_concat ~only_simu
Philippe Veber's avatar
Philippe Veber committed
440
    ]