diffsel.ml 3.6 KB
Newer Older
Philippe Veber's avatar
Philippe Veber committed
1 2 3 4 5
open Core_kernel
open Bistro.Std
open Bistro.EDSL
open File_formats

6 7
let diffsel ~(phy_n:nucleotide_phylip workflow) ~(tree: _ workflow) ~(w_every:int) ~(n_cycles: int) ~(id: int) ~tag : [`diffsel] directory workflow =
  let env = docker_image ~account:"vlanore" ~name:"diffsel" ~tag () in
Philippe Veber's avatar
Philippe Veber committed
8 9 10 11 12 13
  let tmp_tree = tmp // "myrun.tree" in
  let tmp_ali = tmp // "myrun.ali" in
  let dest_tree = dest // "myrun.tree" in
  let dest_ali = dest // "myrun.ali" in
  let chainname = dest // "myrun" in
  (*_build/diffsel -t data/samhd1.tree -d data/samhd1.ali -ncond 3 -x 1 10000 myrun*)
14
  workflow ~descr:("convergence_detection.run_diffsel." ^ tag ^ "." ^(string_of_int id))  [
Philippe Veber's avatar
Philippe Veber committed
15 16 17
    docker env (
      and_list [
        mkdir_p dest;
Carine Rey's avatar
Carine Rey committed
18
        cmd "echo" [string "Run chain:"; int id];
Philippe Veber's avatar
Philippe Veber committed
19 20 21 22 23
        cmd "cp" [dep phy_n; dest_ali]; (* required dep to link the file in the env *)
        cmd "cp" [dep tree; dest_tree]; (* required dep to link the file in the env *)
        cmd "cp" [dep phy_n; tmp_ali]; (* required dep to link the file in the env *)
        cmd "cp" [dep tree; tmp_tree]; (* required dep to link the file in the env *)
        cmd "/diffsel/_build/diffsel" [
24 25 26 27 28
          opt "-t" ident tmp_tree;
          opt "-d" ident tmp_ali ;
          opt "-ncond"  int 2 ;
          opt "-x" seq [ int w_every; string " "; int n_cycles];
          ident chainname ;
Philippe Veber's avatar
Philippe Veber committed
29 30 31 32 33
        ];
      ]
    )
  ]

34
let check_conv run_diffsel : text_file directory workflow =
35
  let env = docker_image ~account:"carinerey" ~name:"r_basics" ~tag:"07232018" () in
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
  let script = tmp // "DiffselMCMCConvergenceAnalysis.Rmd" in
  let trace = run_diffsel / selector["myrun.trace"] in
  let out = dest // "out.html" in
  let nb_new_iterations = dest // "new_iterations.txt.txt" in
  workflow ~descr:"convergence_detection.DiffselMCMCConvergenceAnalysis" [
    docker env (
      and_list [
        mkdir_p tmp ;
        mkdir_p dest ;
        cd tmp ;
        cmd "cp" [ file_dump (string Scripts.diffselMCMCConvergenceAnalysis) ; script] ;
        cmd "Rscript" [
          string "-e" ;
          string {|"rmarkdown::render(\"DiffselMCMCConvergenceAnalysis.Rmd\",|} ;
          string {|params=list(set_trace1=\"|} ;
          dep trace ;
          string {|\"))"|};
        ] ;
        cmd "cp" [string "DiffselMCMCConvergenceAnalysis.html" ; ident out] ;
        cmd "cp" [string "new_iterations.txt" ; ident nb_new_iterations]
        ]
    )
  ]

Philippe Veber's avatar
Philippe Veber committed
60
let selector run_diffsel : text_file workflow =
61
  let env = docker_image ~account:"vlanore" ~name:"diffsel" ~tag:"master_2304" () in
Philippe Veber's avatar
Philippe Veber committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
  let package = tmp // "diffsel_script_utils.py" in
  let script = tmp // "diffsel_analyze_result.py" in
  let tmp_tree = tmp // "myrun.tree" in
  let tmp_ali = tmp // "myrun.ali" in
  let dep_tree = (dep run_diffsel) // "myrun.tree" in
  let dep_ali = (dep run_diffsel) // "myrun.ali" in
  let chainname = (dep run_diffsel) // "myrun" in
  let out = dest in
  workflow ~descr:"convergence_detection.parse_diffsel" [
    docker env (
      and_list [
        mkdir_p tmp ;
        cd tmp ;

        cmd "cp" [dep_ali; tmp_ali]; (* required dep to link the file in the env *)
        cmd "cp" [dep_tree; tmp_tree]; (* required dep to link the file in the env *)

        (*python diffsel_analyze_result.py [-r /path/to/readdiffsel] [-o output_file] chainname *)
        cmd "cp"  [ file_dump (string Scripts.diffsel_script_utils) ; package] ;
        cmd "cp" [ file_dump (string Scripts.diffsel_analyze_result) ; script] ;

        cmd "python" [
          string "diffsel_analyze_result.py" ;
          opt "-r" string "/diffsel/_build/readdiffsel" ;
          opt "-o" ident out ;
          ident chainname ;
        ]
      ]
    )
  ]