Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

topological.ml 2.68 KB
Newer Older
1
open Core
Philippe Veber's avatar
Philippe Veber committed
2 3
open Bistro
open Bistro.Shell_dsl
4 5 6 7 8 9 10
open File_formats

let assign k v =
  seq ~sep:"=" [ string k ; v ]

let conf_file_bppml ~tree ~faa ~out ~config =
  seq ~sep:"\n" (
11
    [
12 13 14
      assign "OUT" (out) ;
      assign "input.sequence.file" (dep faa) ;
      assign "alphabet" (string "Protein") ;
15 16
      assign "input.sequence.remove_stop_codons" (string "no") ;
      assign "input.sequence.sites_to_use" (string "all") ;
Carine Rey's avatar
Carine Rey committed
17 18
      assign "input.sequence.remove_saturated_sites" (string "yes") ;

19 20 21 22

      assign "input.tree.file"  (dep tree) ;
      assign "init.tree" (string "user") ;
      assign "input.tree.format" (string "Nhx") ;
23

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
      assign "optimization.topology" (string "false") ;

      assign "output.tree.file" (string "$(OUT)/tree.nhx") ;
      assign "output.tree.format" (string "Nhx") ;


      assign "output.infos" (string "$(OUT)/infos.tsv") ;
      assign "output.estimates" (string "$(OUT)/estimates.tsv") ;
    ]
    @ config
  )

let bppml ?(descr="") ~faa ~tree ~config : _ workflow =
  let config_f = dest // "config_bppml.bpp" in
  let out = ident dest in
Philippe Veber's avatar
Philippe Veber committed
39 40
  Workflow.shell ~descr:("bppsuite.bppml" ^ descr) [
    within_container Env.env_bppsuite (
41 42 43 44
      and_list [
        mkdir_p dest;
        cmd "cat" ~stdout:config_f [(file_dump (conf_file_bppml ~tree ~faa ~out ~config ))];
        cmd "bppml" [
45 46
          assign "param"  config_f;
        ]
47 48 49 50
      ]
    )
  ]

51
let topological ?(descr="") ~(tree:_ pworkflow) ~(tree_conv:_ pworkflow) ~(faa:aminoacid_fasta pworkflow) ~prot_model () : [`topological] dworkflow =
52 53 54
  let config = [assign "model" (string prot_model)] in
  let run_bppml = bppml ~descr:"" ~tree ~config ~faa in
  let run_bppml_conv = bppml ~descr:".conv" ~tree:tree_conv ~config ~faa in
Philippe Veber's avatar
Philippe Veber committed
55 56 57 58
  let bppml_config = Workflow.select run_bppml ["config_bppml.bpp"] in
  let bppml_config_conv = Workflow.select run_bppml_conv ["config_bppml.bpp"] in
  let bppml_out = Workflow.select run_bppml ["infos.tsv"] in
  let bppml_out_conv = Workflow.select run_bppml_conv ["infos.tsv"] in
59
  let out = dest // "out.tsv" in
Carine Rey's avatar
Carine Rey committed
60
  Workflow.shell ~descr:("topological.parse_"^prot_model^"."^descr) [
61 62 63 64 65
    mkdir dest ;
    cmd "cp" [dep bppml_out ; dest // "estimates.bppml_out.tsv" ];
    cmd "cp" [dep bppml_out_conv ; dest // "estimates.bppml_out_conv.tsv" ];
    cmd "cp" [dep bppml_config ; dest // "estimates.bppml_config" ];
    cmd "cp" [dep bppml_config_conv ; dest // "estimates.bppml_config_conv" ];
66
    cmd "python" ~img:Env.env_pcoc [
67 68 69 70
      file_dump (string Scripts.calc_topological) ;
      opt "-bppml_non_conv" dep bppml_out ;
      opt "-bppml_conv" dep bppml_out_conv ;
      opt "-o"  ident out ;
71 72 73
    ]
  ]

Philippe Veber's avatar
Philippe Veber committed
74 75
let results run_topological : text_file pworkflow =
  Workflow.select run_topological ["out.tsv"]