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

tk: moved pair_tree generation to Convergence_tree

parent 09144976
......@@ -237,3 +237,15 @@ let alignment_counts_map tree alignment f =
let site i = f (counts seqs0 i) (counts seqs1 i) in
let n = Alignment.ncols alignment in
List.init n ~f:site
let pair_tree ~node_info ~leaf_info ~branch_length1 ~branch_length2 ~npairs =
let leaf i cond = Tree.Leaf (leaf_info i cond) in
let branch length condition tip = Tree.branch { length ; condition } tip in
let tree = Tree.binary_node node_info in
let make_pair i =
tree
(branch branch_length2 `Ancestral (leaf (2 * i) `Ancestral))
(branch branch_length2 `Convergent (leaf (2 * i + 1) `Convergent))
|> branch branch_length1 `Ancestral
in
Tree.node node_info (List1.init npairs ~f:make_pair)
......@@ -41,3 +41,11 @@ val alignment_counts_map :
Alignment.t ->
(int Amino_acid.table -> int Amino_acid.table -> 'a) ->
'a list
val pair_tree :
node_info:'n ->
leaf_info:(int -> condition -> 'l) ->
branch_length1:float ->
branch_length2:float ->
npairs:int ->
('n, 'l, branch_info) Phylogenetics.Tree.t
......@@ -442,17 +442,10 @@ module Pack = struct
Owl.Stats.dirichlet_rvs ~alpha:(Array.create ~len:Amino_acid.card alpha)
|> Amino_acid.Vector.of_array_exn
let pair_tree ~branch_length1 ~branch_length2 ~npairs =
let leaf i cond = Tree.Leaf (i, cond) in
let branch length condition tip = Tree.branch { Convergence_tree.length ; condition } tip in
let tree = Tree.binary_node () in
let make_pair i =
tree
(branch branch_length2 `Ancestral (leaf (2 * i) `Ancestral))
(branch branch_length2 `Convergent (leaf (2 * i + 1) `Convergent))
|> branch branch_length1 `Ancestral
in
Tree.node () (List1.init npairs ~f:make_pair)
let pair_tree =
let leaf_info i cond = (i, cond) in
let node_info = () in
Convergence_tree.pair_tree ~leaf_info ~node_info
end
module Implementation_check = struct
......
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