Commit 08949d34 authored by Louis Duchemin's avatar Louis Duchemin
Browse files

Autoformat

parent edd6f630
......@@ -2,40 +2,39 @@ open Core_kernel
let tree_from_file ?(alpha = 1.) fn =
match Phylogenetics.Newick.from_file fn with
| Branch (Branch { tip = t ; _ })
| Tree t ->
Phylogenetics.Tree.map t ~node:Fn.id ~leaf:Fn.id ~branch:Phylogenetics.Newick.(fun b ->
let length = Option.value_exn b.length *. alpha in
let condition =
match List.Assoc.find ~equal:String.equal b.tags "Condition" with
| Some s -> Int.of_string s
| None -> failwith "Missing Condition tag"
in
length, condition
)
| Branch (Branch {tip= t; _}) | Tree t ->
Phylogenetics.Tree.map t ~node:Fn.id ~leaf:Fn.id
~branch:
Phylogenetics.Newick.(
fun b ->
let length = Option.value_exn b.length *. alpha in
let condition =
match
List.Assoc.find ~equal:String.equal b.tags "Condition"
with
| Some s -> Int.of_string s
| None -> failwith "Missing Condition tag"
in
(length, condition))
let range_iter a b ~f =
let rec loop i=
let rec loop i =
if i < b then (
f i ;
loop (i + 1)
)
in
f i ;
loop (i + 1) )
in
loop a
let int_fold a b ~init ~f =
let rec loop acc i =
if i >= b then acc else loop (f acc i) (i + 1)
in
let rec loop acc i = if i >= b then acc else loop (f acc i) (i + 1) in
loop init a
let int_for_all a b ~f =
let rec loop i =
i >= b && f i && loop (i + 1)
in
let rec loop i = i >= b && f i && loop (i + 1) in
loop a
let translate_nucleotide_sequence_whatever_it_takes ?(unknown_char = '-') seq =
let translate_nucleotide_sequence_whatever_it_takes ?(unknown_char = '-') seq
=
let open Phylogenetics in
let has_some_gaps s = String.exists s ~f:(Char.( = ) '-') in
let n = String.length seq in
......@@ -43,11 +42,7 @@ let translate_nucleotide_sequence_whatever_it_takes ?(unknown_char = '-') seq =
let subseq = String.sub seq ~pos:(i * 3) ~len:3 in
match Codon.of_string subseq with
| Some codon -> (
match Codon.Universal_genetic_code.aa_of_codon codon with
| Some aa -> Amino_acid.to_char aa
| None -> unknown_char
)
| None ->
if has_some_gaps subseq then '-'
else unknown_char
)
match Codon.Universal_genetic_code.aa_of_codon codon with
| Some aa -> Amino_acid.to_char aa
| None -> unknown_char )
| None -> if has_some_gaps subseq then '-' else unknown_char)
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