Commit 3bc3ae31 authored by Philippe Veber's avatar Philippe Veber
Browse files

changed ocamlformat configuration

parent b6a50ad7
profile = ocamlformat
break-cases = fit
margin = 77
parse-docstrings = true
wrap-comments = true
\ No newline at end of file
profile = conventional
type-decl = sparse
margin = 75
sequence-style = separator
\ No newline at end of file
......@@ -39,12 +39,13 @@ 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
......@@ -75,7 +76,11 @@ 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
......@@ -93,7 +98,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 +107,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 =
......@@ -116,12 +121,13 @@ module Result_file = struct
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)
Option.map (f pval_parser) ~f:(fun i ->
fields.(i) |> Float.of_string)
in
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,10 +138,9 @@ 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 =
......@@ -147,7 +152,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
......@@ -163,7 +168,9 @@ module Result_file = struct
| Ok table -> (
range_find 0 103 ~f:(fun i ->
not @@ List.exists table ~f:(fun item -> item.index = i))
|> function None -> true | Some i -> failwithf "%d is missing" i () )
|> function
| None -> true
| Some i -> failwithf "%d is missing" i () )
let%test "gemma output aggregation" =
match of_file "../../tests/data/gemma_output.tsv" with
......
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