text stringlengths 0 601k |
|---|
let test_prefix _ = let check_prefix prefix reference = Reference . is_prefix ~ prefix ( : Reference . create prefix ) ( Reference . create reference ) in assert_true ( check_prefix " " " a " ) ; assert_true ( check_prefix " a " " a . b " ) ; assert_true ( check_prefix " a . b " " a . b " ) ; assert_false ( check_prefi... |
let test_map_last _ = let assert_mapped ~ f given expected = assert_equal ~ cmp : Reference . equal ~ printer : Reference . show ( Reference . map_last ~ f ( Reference . create given ) ) ( Reference . create expected ) in assert_mapped ~ f ( : fun s -> s ^ " _suffix " ) " " " " ; assert_mapped ~ f ( : fun s -> s ^ " _s... |
let test_possible_qualifiers _ = let assert_prefixes reference expected = let actual = Reference . possible_qualifiers ( Reference . create reference ) in let expected_references = List . map ~ f : Reference . create expected in assert_equal ~ cmp ( : List . equal Reference . equal ) ~ printer ( : fun references -> [ %... |
let ( ) = " reference " >::: [ " create " >:: test_create ; " expression " >:: test_expression ; " name " >:: test_name ; " delocalize " >:: test_delocalize ; " prefix " >:: test_prefix ; " map_last " >:: test_map_last ; " possible_qualifiers " >:: test_possible_qualifiers ; ] |> Test . run |
module Specification = struct module Location = struct type t = [ | ` Url of string | ` Vcf_concat of ( string * t ) list | ` Concat of t list | ` Gunzip of t | ` Bunzip2 of t | ` Untar of t ] let url u = ` Url u let vcf_concat l = ` Vcf_concat l let concat l = ` Concat l let gunzip l = ` Gunzip l let bunzip2 l = ` Bun... |
module Default = struct let major_contigs_b37 = List . init 22 ( fun i -> sprintf " % d " ( i + 1 ) ) @ [ " X " ; " Y " ; " MT " ; ] let major_contigs_hg_family = List . init 22 ( fun i -> sprintf " chr % d " ( i + 1 ) ) @ [ " chrX " ; " chrY " ; " chrM " ; ] let major_contigs_mm10 = List . init 19 ( fun i -> sprintf "... |
type t = { specification : Specification . t ; location : KEDSL . file_workflow ; cosmic : KEDSL . file_workflow option ; dbsnp : KEDSL . file_workflow option ; known_indels : KEDSL . file_workflow option ; gtf : KEDSL . file_workflow option ; cdna : KEDSL . file_workflow option ; whess : KEDSL . file_workflow option ;... |
let create ? cosmic ? dbsnp ? known_indels ? gtf ? cdna ? whess specification location = { specification ; location ; cosmic ; dbsnp ; known_indels ; gtf ; cdna ; whess } |
let name t = t . specification . Specification . name |
let ensembl t = t . specification . Specification . ensembl |
let species t = t . specification . Specification . species |
let snpeff_name_exn t = Option . value_exn ~ msg ( : sprintf " % s : no snpEff name " ( name t ) ) t . specification . Specification . snpeff_name |
let path t = t . location # product # path |
let cosmic_path_exn t = let msg = sprintf " cosmic_path_exn of % s " ( name t ) in let cosmic = Option . value_exn ~ msg t . cosmic in cosmic # product # path |
let dbsnp_path_exn t = let msg = sprintf " dbsnp_path_exn of % s " ( name t ) in let trgt = Option . value_exn ~ msg t . dbsnp in trgt # product # path |
let known_indels_path_exn t = let msg = sprintf " known_indels_path_exn of % s " ( name t ) in let trgt = Option . value_exn ~ msg t . known_indels in trgt # product # path |
let gtf_path_exn t = let msg = sprintf " gtf_path_exn of % s " ( name t ) in let trgt = Option . value_exn ~ msg t . gtf in trgt # product # path |
let cdna_path_exn t = let msg = sprintf " cdna_path_exn of % s " ( name t ) in let target = Option . value_exn ~ msg t . cdna in target # product # path |
let whess_path_exn t = let msg = sprintf " whess_path_exn of % s " ( name t ) in let target = Option . value_exn ~ msg t . whess in target # product # path |
let fasta : t -> KEDSL . file_workflow = fun t -> t . location |
let cosmic_exn t = Option . value_exn ~ msg ( : sprintf " % s : no COSMIC " ( name t ) ) t . cosmic |
let dbsnp_exn t = Option . value_exn ~ msg ( : sprintf " % s : no DBSNP " ( name t ) ) t . dbsnp |
let known_indels_exn t = Option . value_exn ~ msg ( : sprintf " % s : no Known Indels " ( name t ) ) t . known_indels |
let gtf_exn t = Option . value_exn ~ msg ( : sprintf " % s : no GTF " ( name t ) ) t . gtf |
let gtf t = t . gtf |
let cdna_exn t = Option . value_exn ~ msg ( : sprintf " % s : no cDNA fasta file " ( name t ) ) t . cdna |
let whess_exn t = Option . value_exn ~ msg ( : sprintf " % s : no WHESS file " ( name t ) ) t . whess |
let major_contigs t : Region . t list = match t . specification . Specification . major_contigs with | None -> failwithf " Reference % S does have major - contigs / chromosomes defined " ( name t ) | Some l -> List . map l ~ f ( : fun s -> ` Chromosome s ) |
module type DECOMPOSABLE = sig type t val is_empty : t -> bool val compare_minimum : t -> t -> int val sorted_union : t list -> t val extract_unique_prefix : t -> t -> t * t val extract_shared_prefix : t -> t -> t * ( t * t ) end |
module type S = sig type t val partition : t list -> t list val annotated_partition : ( t * ' a ) list -> ( t * ' a list ) list val partition_and_total : t list -> t list * t end |
module Make ( Set : DECOMPOSABLE ) : S with type t := Set . t = struct type leftist = | Leaf | Node of leftist * Set . t * IntSet . t * leftist * int let singleton k v = Node ( Leaf , k , v , Leaf , 1 ) let rank = function Leaf -> 0 | Node ( _ , _ , _ , _ , r ) -> r let rec merge t1 t2 = match t1 , t2 with | Leaf , t |... |
let error msg = raise ( Error msg ) |
type result = Term | Formula |
module LocalEnv = struct try name end |
module FnEnv = struct end |
let builtins = List . fold_left else |
let uninterpreted = List . fold_left else |
let translate_builtin_and_uninterpreted fn_name translated_arg_list = |
let declare_var name ty = |
let var_name_map = Hashtbl . create 5 |
let declare_new_var ty = in in var_name |
let assert_true translated_expr = Smt . write ( " ( assert " ^ translated_expr ^ " ) " ) |
let assert_false translated_expr = Smt . write ( " ( assert ( not " ^ translated_expr ^ " ) ) " ) |
let assert_eq translated_expr1 translated_expr2 = |
let rec check_contract if_clause fn_env local_env contract_expr = in in in new_closure_local_env in in in end ) in in in in var_name end in in var_name end ( ) in in var_name end translated_expr in in param_list in in |
let global_fn_env = Infer . Env . fold fn_env else |
let declare_uninterpreted_function fn_name fn_ty = List . map ( function else param_r_ty_list in Smt . write translated_param_list ) in Smt . write end |
let already_started = ref false |
let start ( ) = StringSet . iter StringSet . iter end |
let check_expr expr = Smt . push_pop else end ) |
module StringMap = Map . Make ( String ) |
module Cell = struct type ' a t = { contents : ' a ; ident : Ident . t } let make nm c = { contents = c ; ident = nm } let ident cell = cell . ident let contents cell = cell . contents end |
type cell = ( D . tp * D . con ) Cell . t |
type t = { veil : Veil . t ; locals : cell bwd ; cof_thy : CofThy . Disj . t ; pp : Pp . env ; location : LexingUtil . span option ; } |
let init = { veil = Veil . const ` Translucent ; locals = Emp ; cof_thy = CofThy . Disj . empty ; pp = Pp . Env . emp ; location = None } |
let globally env = { veil = env . veil ; locals = Emp ; cof_thy = CofThy . Disj . empty ; pp = Pp . Env . emp ; location = env . location } |
let get_veil env = env . veil |
let set_veil v env = { env with veil = v } |
let locals env = env . locals |
let size env = BwdLabels . length env . locals |
let get_local_tp ix env = let cell = BwdLabels . nth env . locals ix in let tp , _ = Cell . contents cell in tp |
let get_local ix env = let cell = BwdLabels . nth env . locals ix in let _ , con = Cell . contents cell in con |
let resolve_local ( ident : Ident . t ) env = let exception E in let rec go i = function | Emp -> raise E | Snoc ( xs , cell ) -> begin match ident , Cell . ident cell with | ` User parts_x , ` User parts_y when List . equal String . equal parts_x parts_y -> i | _ -> go ( i + 1 ) xs end in match go 0 @@ env . locals wi... |
let rec dump_locals fmt : ( D . tp * D . con ) Cell . t list -> unit = function | [ ] -> ( ) | ( cell :: cells ) -> Format . fprintf fmt " % a : % a := [ @< hov 2 >% a ] ; @@% a " Ident . pp cell . ident D . pp_tp ( fst cell . contents ) D . pp_con ( snd cell . contents ) dump_locals cells |
let local_cof_thy env = env . cof_thy |
let pp_env env = env . pp |
let sem_env ( env : t ) : D . env = { tpenv = Emp ; conenv = BwdLabels . map env . locals ~ f ( : fun cell -> let _ , con = Cell . contents cell in con ) } |
let restrict phis env = { env with cof_thy = CofThy . Disj . assume env . cof_thy phis } |
let append_con ident con tp env = { env with pp = snd @@ Pp . Env . bind env . pp ( Ident . to_string_opt ident ) ; locals = env . locals #< ( Cell . make ident ( tp , con ) ) ; cof_thy = match tp with | D . TpPrf phi -> CofThy . Disj . assume env . cof_thy [ phi ] | _ -> env . cof_thy } |
let location env = env . location |
let set_location loc env = match loc with | Some _ -> { env with location = loc } | _ -> env |
let dump fmt : t -> unit = fun env -> Format . fprintf fmt " Locals : [ @< v >% a ] " @ dump_locals ( BwdLabels . to_list env . locals ) |
let pp_connective fmt = function | ` Cof -> Format . fprintf fmt " cof " | ` Dim -> Format . fprintf fmt " dim " | ` Pi -> Format . fprintf fmt " pi " | ` Sg -> Format . fprintf fmt " sg " | ` Signature -> Format . fprintf fmt " sig " | ` Univ -> Format . fprintf fmt " univ " | ` Nat -> Format . fprintf fmt " nat " | `... |
let pp fmt = function | UnboundVariable id -> Fmt . fprintf fmt " Unbound variable % a " Ident . pp id | ExpectedEqual ( ppenv , tp , tm0 , tm1 , _ ) -> Fmt . fprintf fmt " Expected [ @< hv >% a ; =@% a ; @: % a ] " @ ( S . pp ppenv ) tm0 ( S . pp ppenv ) tm1 ( S . pp_tp ppenv ) tp | ExpectedEqualTypes ( ppenv , tp0 , ... |
let _ = PpExn . install_printer @@ fun fmt -> function | RefineError ( err , _loc ) -> pp fmt err | _ -> raise PpExn . Unrecognized |
module MapLattice = struct module type MapSignature = sig type key type ' data t val empty : ' data t val mem : ' data t -> key -> bool val set : ' data t -> key : key -> data ' : data -> ' data t val find : ' data t -> key -> ' data option val remove : ' data t -> key -> ' data t val fold : ' data t -> init ' : a -> f... |
module IdentifierMap = MapLattice . Make ( struct include Identifier . Map . Tree type key = Identifier . t end ) |
module ReferenceMap = MapLattice . Make ( struct include Reference . Map type key = Reference . t end ) |
module Unit = struct type t = { base : Annotation . t option ; attributes : t Identifier . Map . Tree . t ; } [ @@ deriving eq ] let empty = { base = None ; attributes = IdentifierMap . empty } let create base = { empty with base = Some base } let create_mutable type_ = create ( Annotation . create_mutable type_ ) let ... |
module Store = struct type t = { annotations : Unit . t Reference . Map . t ; temporary_annotations : Unit . t Reference . Map . t ; } [ @@ deriving eq ] let empty = { annotations = ReferenceMap . empty ; temporary_annotations = ReferenceMap . empty } let pp format { annotations ; temporary_annotations } = let show_ann... |
module Unit = struct open Refinement . Unit let test_create _ = let assert_create ~ refinement_unit ~ expected = assert_equal ~ cmp ( : Option . equal Annotation . equal ) ( base refinement_unit ) expected in assert_create ~ refinement_unit : empty ~ expected : None ; assert_create ~ refinement_unit ( : create ( Annota... |
let ( ) = " Refinement . Unit " >::: Unit . suite |> Test . run |
let refine_err err = let * env = read in Debug . print " Refiner failed , dumping environment . . . ; @ % a " Env . dump env ; throw @@ Err . RefineError ( err , Env . location env ) |
let resolve id = let * env = read in match Env . resolve_local id env with | Some ix -> ret @@ ` Local ix | None -> let * st = get in match St . resolve_global id st with | Some sym -> ret @@ ` Global sym | None -> ret ` Unbound |
let get_num_holes = let + st = get in St . get_num_holes st |
let inc_num_holes = modify St . inc_num_holes |
let throw_namespace_errors : ( ' a , ' error ) Namespace . result -> ' a m = function | Result . Ok x -> ret x | Result . Error ( ` BindingNotFound path ) -> refine_err @@ BindingNotFound ( ` User path ) | Result . Error ( ` Shadowing path ) -> refine_err @@ UnexpectedShadowing ( ` User path ) |
let with_ ~ begin_ ~ end_ m = let * st = get in let * a = trap @@ let * ( ) = begin_ st |>> set in let * m in let * st ' = get in let * ( ) = end_ ~ parent : st ~ child : st ' |>> set in ret m in match a with | Ok a -> ret a | Error exn -> let * ( ) = set st in throw exn |
let add_global ~ shadowing id tp con = let * st = get in let * sym , st ' = throw_namespace_errors @@ St . add_global ~ shadowing id tp con st in let + ( ) = set st ' in sym |
let get_global sym : ( D . tp * D . con option ) m = let * st = get in match St . get_global sym st with | tp , con -> ret ( tp , con ) | exception exn -> throw exn |
let get_local_tp ix = let * env = read in match Env . get_local_tp ix env with | tp -> ret tp | exception exn -> throw exn |
let get_local ix = let * env = read in match Env . get_local ix env with | tp -> ret tp | exception exn -> throw exn |
let get_lib = St . get_lib <@> get |
let with_unit lib unit_id ( action : ' a m ) = with_ ~ begin_ ( : fun st -> ret @@ St . begin_unit lib unit_id st ) ~ end_ ( : fun ~ parent ~ child -> ret @@ St . end_unit ~ parent ~ child ) ( let * ans = action in let * ( ) = let * num_holes = get_num_holes in if num_holes > 0 then emit ~ lvl ` : Warn None Err . pp @@... |
let import ~ shadowing pat unit_id = set @<< throw_namespace_errors @<< ( St . import ~ shadowing pat unit_id <@> get ) |
let loading_status id = St . loading_status id <@> get |
let view ~ shadowing pat = set @<< throw_namespace_errors @<< ( St . transform_view ~ shadowing pat <@> get ) |
let repack ~ shadowing pat = set @<< throw_namespace_errors @<< ( St . transform_export ~ shadowing pat <@> get ) |
let export ~ shadowing pat = set @<< throw_namespace_errors @<< ( St . export_view ~ shadowing pat <@> get ) |
let with_section ~ shadowing ~ prefix ( action : ' a m ) = with_ ~ begin_ ( : fun st -> ret @@ St . begin_section st ) ~ end_ ( : fun ~ parent : _ ~ child -> throw_namespace_errors @@ St . end_section ~ shadowing ~ prefix child ) action |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.