Commit 1b83c56f authored by Carine Rey's avatar Carine Rey
Browse files

refactoring in profile.ml

parent 708615e3
......@@ -375,7 +375,7 @@ let detection_main ~outdir ~indir ?(np = 2) ?(mem = 2) ~preview ~fast_mode ?(see
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:1 ~nb_sites profile_fn ~seed:(Random.int Int.max_value) 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
......@@ -388,7 +388,7 @@ let validation_main ~outdir ?(indir = "") ?(ns = 0) ?(np = 2) ?(mem = 2) ~previe
(* 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:3 ~nb_sites profile_fn ~seed:(Random.int Int.max_value) in
let profile = Profile.profile_l_of_splitted_profile ~nb_cat:Dist ~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
(* real trees *)
let indir_dataset_l = if indir = "" then [] else parse_input_data ~seed indir in
......
......@@ -47,24 +47,31 @@ let cat_file ~(f_l: text_file workflow list) : text_file workflow =
])
]
type profile_choice =
| All
| Dist
| Unif_3
let profile_l_of_splitted_profile ~nb_cat ~nb_sites profile_fn ~seed =
let profile_f = input profile_fn in
let prefix = Filename.chop_extension (Filename.basename profile_fn) in
let dist_bins = match nb_cat with
| 3 -> "[0.01,0.4],[0.4,0.6],[0.6,2]"
| 1 -> "[0.01,0.7]"
| _ -> failwith {| nbcat must be 1 or 3 |}
| Unif_3 -> "[0.01,0.4],[0.4,0.6],[0.6,2]"
| Dist -> "[0.6,2]"
| All -> "[0.01,2]"
in
let splitted_profile = split_profile ~nb_sites ~dist_bins profile_f ~seed in
match nb_cat with
| 3 -> (
let _p0 = splitted_profile / selector ["profile_0.tsv"] in
let _p1 = splitted_profile / selector ["profile_1.tsv"] in
| Unif_3 -> (
let p0 = splitted_profile / selector ["profile_0.tsv"] in
let p1 = splitted_profile / selector ["profile_1.tsv"] in
let p2 = splitted_profile / selector ["profile_2.tsv"] in
(*{profile_c=cat_file [p0;p1;p2] ; profile_n=prefix ^ "_3categories" ; profile_f}*)
{profile_c=p2 ; profile_n=prefix ^ "_1categorie_max_dist" ; profile_f};
{profile_c=cat_file [p0;p1;p2] ; profile_n=prefix ^ "_3categories" ; profile_f}
)
| Dist -> (
let p0 = splitted_profile / selector ["profile_0.tsv"] in
{profile_c=p0 ; profile_n=prefix ^ "_1categorie_max_dist" ; profile_f};
)
| 1 -> (let p0 = splitted_profile / selector ["profile_0.tsv"] in
| All -> (let p0 = splitted_profile / selector ["profile_0.tsv"] in
{profile_c=p0; profile_n=prefix ; profile_f})
| _ -> failwith {| nbcat must be 1 or 3 |}
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