bppsuite.ml 2 KB
Newer Older
LANORE Vincent's avatar
LANORE Vincent committed
1
open Core
2 3 4
open Bistro.Std
open Bistro.EDSL
open Bistro_bioinfo.Std
Carine Rey's avatar
Carine Rey committed
5
open File_formats
LANORE Vincent's avatar
LANORE Vincent committed
6 7


8
let env = docker_image ~account:"carinerey" ~name:"bppsuite" ~tag:"06182018" ()
LANORE Vincent's avatar
LANORE Vincent committed
9 10 11 12

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

13

Carine Rey's avatar
Carine Rey committed
14
let conf_file_bppseqgen ~tree ~out ~nb_sites ~config ~profile_f =
15 16 17
  seq ~sep:"\n" (
    [
      assign "input.tree.file" (dep tree) ;
18
      assign "output.sequence.file" out ;
19
      assign "number_of_sites" (int nb_sites) ;
Carine Rey's avatar
Carine Rey committed
20
      assign "PROFILE_F" (dep profile_f);
21 22 23
    ]
    @ config
  )
LANORE Vincent's avatar
LANORE Vincent committed
24

Carine Rey's avatar
Carine Rey committed
25
let bppseqgen ?(descr="") ~profile_f ~nb_sites ~tree ~config : nucleotide_fasta workflow =
26 27 28 29 30 31
  let config_f = dest // "config.bpp" in
  let out = dest // "seq.fa" in
  workflow ~descr:("bppsuite.bppseqgen" ^ descr) [
    docker env (
      and_list [
        mkdir_p dest;
Carine Rey's avatar
Carine Rey committed
32 33
        cmd "cat" ~stdout:config_f [(file_dump (conf_file_bppseqgen ~tree ~out ~nb_sites ~config ~profile_f))];
        cmd "bppseqgen" [
34 35 36 37 38
         assign "param"  config_f;
         ]
      ]
    )
  ] / selector ["seq.fa"]
Carine Rey's avatar
Carine Rey committed
39 40


Carine Rey's avatar
Carine Rey committed
41
let conf_file_bppseqman_fna2faa ~fna =
Carine Rey's avatar
Carine Rey committed
42 43 44 45 46 47 48 49 50 51 52 53 54
  seq ~sep:"\n" [
    assign "input.sequence.file" (dep fna) ;
    assign "output.sequence.file" dest ;
    string {|alphabet=Codon(letter=DNA)
             genetic_code = Standard
             input.alignment = true
             sequence.manip = Translate
           |}
  ]

let fna2faa ~(fna:nucleotide_fasta workflow) : aminoacid_fasta workflow =
  workflow ~descr:"bppsuite.fna2faa" [
    cmd "bppseqman" ~env [
Carine Rey's avatar
Carine Rey committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
      assign "param" (file_dump (conf_file_bppseqman_fna2faa ~fna)) ;
    ]
  ]

let conf_file_bppseqman_fa2phy ~fna =
  seq ~sep:"\n" [
    assign "input.sequence.file" (dep fna) ;
    assign "output.sequence.file" dest ;
    assign "output.sequence.format" (string "Phylip") ;
    string {| input.alignment = true
             sequence.manip =
           |}
  ]

let fa2phy ~(fna: nucleotide_fasta workflow) : nucleotide_phylip workflow =
  workflow ~descr:"bppsuite.fa2phy" [
    cmd "bppseqman" ~env [
      assign "param" (file_dump (conf_file_bppseqman_fa2phy ~fna)) ;
LANORE Vincent's avatar
LANORE Vincent committed
73 74
    ]
  ]