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

import Profile_tsv and drop dep on phylogenetics.convergence

parent 317e7ede
......@@ -48,7 +48,7 @@ let nucleotide_fasta_gc ?pos fa =
let nucleotide_fasta_gc_ac ?pos tree fa =
let open Codepitk in
let module BI = Phylogenetics_convergence.Simulator.Branch_info in
let module BI = Convergence_tree.Branch_info in
let tree =
Convergence_tree.from_file tree
|> Rresult.R.failwith_error_msg
......
......@@ -2,8 +2,7 @@
(name codepi)
(public_name codepi)
(libraries core biotk bistro-bio bistro.utils codepitk containers gsl
ocaml-r.graphics ocaml-r.grDevices phylogenetics.convergence
prc)
ocaml-r.graphics ocaml-r.grDevices phylogenetics prc)
(preprocess
(pps ppx_jane ppx_csv_conv bistro.ppx ppx_here)))
......
......@@ -19,6 +19,7 @@ let genotype_of_fasta fasta =
let phenotype_of_tree nhx =
let f = fun%workflow dest ->
let open Phylogenetics in
let open Codepitk in
let module U = Codepitk.Utils in
let collect_leaves t =
let rec node condition t acc =
......@@ -27,7 +28,7 @@ let phenotype_of_tree nhx =
| Leaf _ -> condition :: acc
and branch (Tree.Branch b) acc =
node
(Phylogenetics_convergence.Simulator.Branch_info.condition b.data)
(Convergence_tree.Branch_info.condition b.data)
b.tip acc
in
node `Ancestral t []
......
......@@ -17,7 +17,7 @@ let simulation ?branch_scale ?seed ~n_h0 ~n_ha ~ne_s:(ne_s0, ne_s1) ~gBGC:(gBGC0
|> Rresult.R.get_ok
in
let fitness_profiles =
Phylogenetics_convergence.Profile_tsv.(
Codepitk.Profile_tsv.(
read [%path fitness_profiles]
|> to_fitness
|> Array.map ~f: Amino_acid.Vector.of_array_exn
......
......@@ -8,6 +8,12 @@ type branch_info = {
length : float ;
}
module Branch_info = struct
type t = branch_info
let length (bi : t) = bi.length
let condition (bi : t) = bi.condition
end
type t = (unit, string, branch_info) Tree.t
module Tags = struct
......@@ -83,7 +89,6 @@ let to_newick_tree t =
Tree.map t ~node ~leaf ~branch
let from_file fn =
let module BI = Phylogenetics_convergence.Simulator.Branch_info in
Newick.from_file fn
|> Newick.with_inner_tree ~f:of_newick_tree
......
......@@ -8,6 +8,12 @@ type branch_info = {
length : float ;
}
module Branch_info : sig
type t = branch_info
val length : t -> float
val condition : t -> condition
end
type t = (unit, string, branch_info) Tree.t
val of_newick_tree : Newick.tree -> (t, [> `Msg of string]) result
......
(library
(name codepitk)
(public_name codepi.tk)
(libraries biotk biocaml.ez ocaml-r.graphics ocaml-r.grDevices phylogenetics
phylogenetics.convergence)
(libraries biotk biocaml.ez ocaml-r.graphics ocaml-r.grDevices phylogenetics)
(inline_tests
(deps ../../tests/data/gemma_output.tsv
../../tests/data/gemma_alignment.fa
......
open Core_kernel
let read fn =
In_channel.read_lines fn
|> List.map ~f:(String.split ~on:'\t')
|> List.map ~f:(List.map ~f:Float.of_string)
|> List.map ~f:Array.of_list
|> Array.of_list
|> Array.transpose_exn
let to_fitness ?(beta = 1.) =
Array.map ~f:(Array.map ~f:(fun x -> beta *. Float.log x))
open Core_kernel
open Phylogenetics
module Branch_info = struct
type t = Convergence_tree.branch_info
let length (bi : t) = bi.length
let condition (bi : t) = bi.condition
end
module Branch_info = Convergence_tree.Branch_info
let tree_rescale_branch_length t ~scale =
Tree.map t ~node:Fn.id ~leaf:Fn.id ~branch:(fun (bi : Branch_info.t) ->
......
open Phylogenetics
module Site_independent_mutsel : sig
type simulation = {
sequences : Dna.t list ;
fitness_profiles : Amino_acid.vector array ;
......
......@@ -2,7 +2,7 @@ open Core_kernel
let tree_from_file ?(alpha = 1.) fn =
let open Phylogenetics in
let module BI = Phylogenetics_convergence.Simulator.Branch_info in
let module BI = Convergence_tree.Branch_info in
Newick.from_file fn
|> Newick.with_inner_tree ~f:(fun t ->
Tree.map t ~node:Fn.id ~leaf:Fn.id ~branch:Phylogenetics.Newick.(fun b ->
......@@ -17,7 +17,7 @@ let tree_from_file ?(alpha = 1.) fn =
)
| None -> failwith "Missing Condition tag"
in
{ BI.length ; condition }
{ Convergence_tree.length ; condition }
)
)
......
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