Commit 1be6cf2f authored by Philippe Veber's avatar Philippe Veber
Browse files

inhouse_tdg09: don't try to optimize constant sites

parent 75f7c5f3
......@@ -88,12 +88,42 @@ module Inhouse_implementation = struct
include Tdg09.Make(Convergence_tree.Branch_info)(Leaf_info)(Site)
let constant_site al j =
let open Alignment in
let m = nrows al in
let rec find_state i =
if i < m then
match al.sequences.(i).[j] with
| '-' -> find_state (i + 1)
| c -> find_other_state c (i + 1)
else true
and find_other_state c i =
if i < m then
match al.sequences.(i).[j] with
| '-' -> find_other_state c (i + 1)
| c' when Char.equal c c' -> find_other_state c (i + 1)
| _ -> false
else true
in
find_state 0
let constant_site_lrt = {
Codepitk.Tdg09.full_log_likelihood = 0. ;
reduced_log_likelihood = 0. ;
_D_ = 0. ;
df = 0. ;
pvalue = 1. ;
}
let run_on_alignment wag tree alignment =
let n = Alignment.ncols alignment in
let foreach_site j =
let site = alignment, j in
let _, _, lrt = Model3.lrt ~mode:`sparse wag tree site in
lrt
if constant_site alignment j then
constant_site_lrt
else
let site = alignment, j in
let _, _, lrt = Model3.lrt ~mode:`sparse wag tree site in
lrt
in
Array.init n ~f:foreach_site
end
......
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