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

refactoring

parent ebc348d9
...@@ -52,5 +52,5 @@ type ('a,'b) w_dataset = ...@@ -52,5 +52,5 @@ type ('a,'b) w_dataset =
type dataset = { type dataset = {
model_prefix: string ; model_prefix: string ;
tree_prefix : string ; tree_prefix : string ;
dataset : (raw_dataset,ready_dataset) w_dataset ready_dataset : ready_dataset
} }
...@@ -11,6 +11,11 @@ let ready_dataset_of_raw_dataset raw_dataset = ...@@ -11,6 +11,11 @@ let ready_dataset_of_raw_dataset raw_dataset =
let faa = Bppsuite.fna2faa ~fna in let faa = Bppsuite.fna2faa ~fna in
{ input_tree; tree_dataset ; fna; faa} { input_tree; tree_dataset ; fna; faa}
let raw_dataset_of_ready_dataset ready_dataset =
let input_tree = ready_dataset.input_tree in
let fna = ready_dataset.fna in
{ input_tree; fna}
let repo_of_ready_dataset (rd : ready_dataset) = let repo_of_ready_dataset (rd : ready_dataset) =
Repo.[ Repo.[
item ["input_tree.nhx"] rd.input_tree ; item ["input_tree.nhx"] rd.input_tree ;
...@@ -32,11 +37,14 @@ let repo_of_raw_dataset (raw_dataset:raw_dataset) = ...@@ -32,11 +37,14 @@ let repo_of_raw_dataset (raw_dataset:raw_dataset) =
|> Repo.shift "raw_dataset" |> Repo.shift "raw_dataset"
let repo_of_dataset_l dataset_l = let repo_of_dataset_l ~preview dataset_l =
List.map dataset_l ~f:(fun dataset -> List.map dataset_l ~f:(fun dataset ->
let model_prefix = dataset.model_prefix in let model_prefix = dataset.model_prefix in
let tree_prefix = dataset.tree_prefix in let tree_prefix = dataset.tree_prefix in
let w_dataset = dataset.dataset in let w_dataset =
if preview then
Ready_dataset dataset.ready_dataset
else Raw_dataset (raw_dataset_of_ready_dataset dataset.ready_dataset) in
let repo_d = match w_dataset with let repo_d = match w_dataset with
| Ready_dataset d -> repo_of_ready_dataset d | Ready_dataset d -> repo_of_ready_dataset d
| Raw_dataset d -> repo_of_raw_dataset d | Raw_dataset d -> repo_of_raw_dataset d
...@@ -53,14 +61,9 @@ let derive_from_model ~model ~tree ~tree_dataset ~tree_prefix ~preview = ...@@ -53,14 +61,9 @@ let derive_from_model ~model ~tree ~tree_dataset ~tree_prefix ~preview =
let tree = Tree_dataset.tree tree_dataset `Simulation in let tree = Tree_dataset.tree tree_dataset `Simulation in
let fna = Bppsuite.bppseqgen ~nb_sites ~tree ~config in let fna = Bppsuite.bppseqgen ~nb_sites ~tree ~config in
let faa = Bppsuite.fna2faa ~fna in let faa = Bppsuite.fna2faa ~fna in
let raw_dataset = { input_tree = tree ; fna} in
let ready_dataset = { input_tree = tree ; tree_dataset ; fna; faa} in let ready_dataset = { input_tree = tree ; tree_dataset ; fna; faa} in
let model_prefix = Convergence_hypothesis.string_of_model model in let model_prefix = Convergence_hypothesis.string_of_model model in
if preview then { model_prefix; tree_prefix; ready_dataset }
{ model_prefix; tree_prefix; dataset = Ready_dataset ready_dataset }
else
{ model_prefix; tree_prefix; dataset = Raw_dataset raw_dataset }
let derive_from_tree ~tree_dir ~tree ~preview = let derive_from_tree ~tree_dir ~tree ~preview =
let tree_prefix = Filename.chop_extension tree in let tree_prefix = Filename.chop_extension tree in
...@@ -84,7 +87,7 @@ let main ~outdir ?(np = 2) ?(mem = 2) ~tree_dir ~preview () = ...@@ -84,7 +87,7 @@ let main ~outdir ?(np = 2) ?(mem = 2) ~tree_dir ~preview () =
] in ] in
let trees = Array.to_list @@ Sys.readdir tree_dir in let trees = Array.to_list @@ Sys.readdir tree_dir in
let dataset_l = derive ~tree_dir ~trees ~preview in let dataset_l = derive ~tree_dir ~trees ~preview in
let repo = repo_of_dataset_l dataset_l in let repo = repo_of_dataset_l dataset_l ~preview in
Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo Repo.build ~outdir ~np ~mem:(`GB mem) ~logger repo
let command = let command =
......
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