Commit ddc1b8c7 authored by Louis Duchemin's avatar Louis Duchemin
Browse files

Autoformat

parent cb7dd15a
......@@ -18,9 +18,9 @@ let column_of_alignment al col =
let aa_of_column col = List.dedup_and_sort ~compare:Char.compare col
let write_genotype_line oc locus_id column aa =
fprintf oc "%s_%c, 0, 1" locus_id aa;
fprintf oc "%s_%c, 0, 1" locus_id aa ;
List.iter column ~f:(fun indiv_aa ->
fprintf oc ", %d" (if Char.(indiv_aa = aa) then 1 else 0));
fprintf oc ", %d" (if Char.(indiv_aa = aa) then 1 else 0)) ;
Out_channel.newline oc
let write_column_alignment_genotype oc al col =
......@@ -39,13 +39,12 @@ let write_genotypes ~alignment ~output =
module Result_file = struct
(* invariant : at least one pval is not none *)
type item = {
index : int;
residue : char;
pval_lrt : float option;
pval_score : float option;
pval_wald : float option;
}
type item =
{ index: int
; residue: char
; pval_lrt: float option
; pval_score: float option
; pval_wald: float option }
let maybe_binop ~f x y =
match (x, y) with
......@@ -76,7 +75,7 @@ module Result_file = struct
val wald_field : t -> int option
end = struct
type t = { lrt : int option; wald : int option; score : int option }
type t = {lrt: int option; wald: int option; score: int option}
let lrt_field x = x.lrt
......@@ -85,7 +84,8 @@ module Result_file = struct
let score_field x = x.score
let index_of_column header colname =
List.findi header ~f:(fun _ -> String.equal colname) |> Option.map ~f:fst
List.findi header ~f:(fun _ -> String.equal colname)
|> Option.map ~f:fst
let of_header header =
let lrt = index_of_column header "p_lrt" in
......@@ -93,7 +93,7 @@ module Result_file = struct
let score = index_of_column header "p_score" in
match (lrt, wald, score) with
| None, None, None -> Error "invalid header: no pvalue field"
| _ -> Ok { lrt; wald; score }
| _ -> Ok {lrt; wald; score}
let max_field pvp =
let f = maybe_binop ~f:Int.max in
......@@ -102,7 +102,7 @@ module Result_file = struct
let parse_locus_id locus_id =
match String.split ~on:'_' locus_id with
| [ _; index; residue ] -> (Int.of_string index, Char.of_string residue)
| [_; index; residue] -> (Int.of_string index, Char.of_string residue)
| _ -> failwith "Locus ID parsing failed"
let parse_line pval_parser fields =
......@@ -113,7 +113,7 @@ module Result_file = struct
if
Array.length fields
< fields_upper_bound 2 (Pval_decoder.max_field pval_parser)
then failwith "parse_line: not enough fields";
then failwith "parse_line: not enough fields" ;
let index, residue = parse_locus_id fields.(1) in
let get_pval f =
Option.map (f pval_parser) ~f:(fun i -> fields.(i) |> Float.of_string)
......@@ -121,7 +121,7 @@ module Result_file = struct
let pval_wald = get_pval Pval_decoder.wald_field in
let pval_score = get_pval Pval_decoder.score_field in
let pval_lrt = get_pval Pval_decoder.lrt_field in
{ index; residue; pval_lrt; pval_score; pval_wald }
{index; residue; pval_lrt; pval_score; pval_wald}
let parse_header = function
| [] -> Error "Result file is empty"
......@@ -132,9 +132,10 @@ module Result_file = struct
let lines =
In_channel.read_lines filename |> List.map ~f:(String.split ~on:'\t')
in
parse_header lines >>= fun (header, lines) ->
Pval_decoder.of_header header >>| fun pvp ->
List.map lines ~f:(parse_line pvp)
parse_header lines
>>= fun (header, lines) ->
Pval_decoder.of_header header
>>| fun pvp -> List.map lines ~f:(parse_line pvp)
let to_result_table results ~site_aggregator =
let scores =
......@@ -146,7 +147,7 @@ module Result_file = struct
| h :: t -> site_aggregator (List1.cons h t) |> Option.some)
|> Array.of_list
in
{ Result_table.oracle = None; scores_per_meth = [ ("Gemma", scores) ] }
{Result_table.oracle= None; scores_per_meth= [("Gemma", scores)]}
let min_pvalue_aggregator xs =
List1.to_list xs
......
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