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

new tk/Multinomial module

parent 5ea7464a
open Core_kernel
open Phylogenetics
let site_loop tree alignment f =
let leaves =
Convergence_tree.leaves tree
|> ~f:(fun (n, cond) ->
match Alignment.find_sequence alignment n with
| None -> failwithf "Could not find %s in alignment" n ()
| Some seq -> seq, cond
let seqs0, seqs1 = List.partition_map leaves ~f:Either.(function
| (aa, `Ancestral) -> First aa
| (aa, `Convergent) -> Second aa
let counts seqs i =
Amino_acid.Table.init (fun aa ->
let aa = Amino_acid.to_char aa in
List.count seqs ~f:(fun s -> Char.equal s.[i] aa)
let site i =
let c0 = (counts seqs0 i :> int array) in
let c1 = (counts seqs1 i :> int array) in
f c0 c1
let n = Alignment.ncols alignment in
List.init n ~f:site
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