pipeline.ml 1.31 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
Philippe Veber's avatar
Philippe Veber committed
4

LANORE Vincent's avatar
LANORE Vincent committed
5 6 7 8 9 10
let derive_from_tree ~tree_dir ~tree ~preview =
  let tree = input (Filename.concat tree_dir tree) in
  let nb_sites = if preview then 10 else 100 in
  let fna = Bppsuite.bppseqgen ~tree ~nb_sites in
  Repo.[
    item ["simulated_sequences.fna"] fna ;
Philippe Veber's avatar
Philippe Veber committed
11
  ]
Philippe Veber's avatar
Philippe Veber committed
12

LANORE Vincent's avatar
LANORE Vincent committed
13 14 15 16 17 18 19 20 21 22
let derive ~tree_dir ~trees ~preview =
  List.map trees ~f:(fun tree ->
      let id = Filename.chop_extension tree in
      Repo.shift id (derive_from_tree ~tree_dir ~tree ~preview))
  |> List.concat

let main ~outdir ?(np = 2) ?(mem = 2) ~tree_dir ~preview () =
  let trees = Array.to_list @@ Sys.readdir tree_dir in
  let repo = derive ~tree_dir ~trees ~preview in
  Repo.build ~outdir ~np ~mem:(`GB mem) repo
Philippe Veber's avatar
Philippe Veber committed
23 24 25 26 27 28 29

let command =
  let open Command.Let_syntax in
  Command.basic
    ~summary:"Run simulation pipeline"
    [%map_open
      let outdir =
LANORE Vincent's avatar
LANORE Vincent committed
30 31 32
        flag "--outdir" (required string) ~doc:"PATH Output directory"
      and preview =
        flag "--preview-mode" no_arg ~doc:" Preview mode"
Philippe Veber's avatar
Philippe Veber committed
33 34 35 36
      and np =
        flag "--np" (optional int) ~doc:"INT Number of available processors"
      and mem =
        flag "--mem" (optional int) ~doc:"INT Available memory (in GB)"
LANORE Vincent's avatar
LANORE Vincent committed
37 38
      and tree_dir =
        flag "--tree-dir" (required string) ~doc:"PATH Path to tree directory"
Philippe Veber's avatar
Philippe Veber committed
39
      in
LANORE Vincent's avatar
LANORE Vincent committed
40
      main ~outdir ?np ?mem ~tree_dir ~preview
Philippe Veber's avatar
Philippe Veber committed
41
    ]