Commit a8a7d82a authored by Philippe Veber's avatar Philippe Veber
Browse files

moved pair_tree workflow definition to simulation dataset

parent aff077d9
...@@ -61,27 +61,3 @@ let fitness_histogram sim = ...@@ -61,27 +61,3 @@ let fitness_histogram sim =
OCamlR_grDevices.dev_off () OCamlR_grDevices.dev_off ()
in in
Workflow.path_plugin ~descr:"simulator.fitness_histogram" f Workflow.path_plugin ~descr:"simulator.fitness_histogram" f
let pair_tree ~branch_length1 ~branch_length2 ~npairs =
let f = fun%workflow dest ->
let open Phylogenetics in
let branch_length1, branch_length2, npairs = [%param branch_length1, branch_length2, npairs] in
let leaf name = Tree.leaf { Newick_ast.name = Some name } in
let branch ~length ~condition tip =
let tags = match condition with
| `Ancestral -> ["Condition", "0"]
| `Convergent -> ["Condition", "1" ; "Transition", "1"]
in
Tree.branch { Newick_ast.length = Some length ; tags } tip in
let make_pair i =
Tree.binary_node { Newick_ast.name = None }
(branch ~length:branch_length2 ~condition:`Ancestral (leaf (sprintf "A%d" i)))
(branch ~length:branch_length2 ~condition:`Convergent (leaf (sprintf "C%d" i)))
|> branch ~length:branch_length1 ~condition:`Ancestral
in
let tree =
Newick.Tree (Tree.node { Newick_ast.name = None } (List1.init npairs ~f:make_pair))
in
Newick.to_file tree dest
in
Workflow.path_plugin ~descr:"simulator.pair_tree" f
...@@ -21,8 +21,3 @@ val alignment_of_simulation : ...@@ -21,8 +21,3 @@ val alignment_of_simulation :
val fitness_histogram : val fitness_histogram :
Mutsel_simulator.Site_independent.simulation workflow -> Mutsel_simulator.Site_independent.simulation workflow ->
pdf file pdf file
val pair_tree :
branch_length1:float ->
branch_length2:float ->
npairs:int -> nhx file
...@@ -9,11 +9,7 @@ let calc_fixed_seed ~(str:string) (seed:int) : int = ...@@ -9,11 +9,7 @@ let calc_fixed_seed ~(str:string) (seed:int) : int =
type tree = type tree =
| NHX of nhx file | NHX of nhx file
| Pair_tree of { | Convergence_tree of Codepitk.Convergence_tree.t workflow
npairs : int ;
branch_length1 : float ;
branch_length2 : float ;
}
let nhx_of_convergence_tree tree = let nhx_of_convergence_tree tree =
let f = fun%workflow dest -> let f = fun%workflow dest ->
...@@ -36,6 +32,19 @@ let nhx_of_convergence_tree tree = ...@@ -36,6 +32,19 @@ let nhx_of_convergence_tree tree =
in in
Workflow.path_plugin ~descr:"nhx_of_convergence_tree" f Workflow.path_plugin ~descr:"nhx_of_convergence_tree" f
let pair_tree ~branch_length1 ~branch_length2 ~npairs =
let leaf_info i c =
sprintf "%c%d"
(match c with `Convergent -> 'C' | `Ancestral -> 'A')
i
in
Convergence_tree (
Codepitk.Convergence_tree.pair_tree
~leaf_info ~node_info:()
~branch_length1 ~branch_length2 ~npairs
|> Workflow.data
)
module type S = sig module type S = sig
type query type query
...@@ -47,10 +56,8 @@ end ...@@ -47,10 +56,8 @@ end
let tree_workflow = function let tree_workflow = function
| NHX w -> w | NHX w -> w
| Pair_tree { branch_length1 ; | Convergence_tree w ->
branch_length2 ; nhx_of_convergence_tree w
npairs } ->
Mutsel_simulator.pair_tree ~branch_length1 ~branch_length2 ~npairs
module Make(Q : Detection_pipeline.Query) = struct module Make(Q : Detection_pipeline.Query) = struct
include Detection_pipeline.Make(Q) include Detection_pipeline.Make(Q)
......
...@@ -3,16 +3,17 @@ open File_formats ...@@ -3,16 +3,17 @@ open File_formats
type tree = type tree =
| NHX of nhx file | NHX of nhx file
| Pair_tree of { | Convergence_tree of Codepitk.Convergence_tree.t workflow
npairs : int;
branch_length1 : float;
branch_length2 : float;
}
val nhx_of_convergence_tree : val nhx_of_convergence_tree :
Codepitk.Convergence_tree.t workflow -> Codepitk.Convergence_tree.t workflow ->
nhx file nhx file
val pair_tree :
branch_length1:float ->
branch_length2:float ->
npairs:int -> tree
module type S = sig module type S = sig
type query type query
......
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