text stringlengths 12 786k |
|---|
type vcf_info_meta = Info of vcf_number * vcf_info_type * vcf_description |
type vcf_filter_meta = Filter of vcf_description |
type vcf_format_meta = Format of vcf_number * vcf_format_type * vcf_description |
type vcf_alt_meta = Alt of vcf_description |
type vcf_meta = { vcfm_version : string ; vcfm_id_cache : vcf_id Set . Poly . t ; vcfm_info : ( vcf_id , vcf_info_meta ) vcf_info_meta Hashtbl . t ; vcfm_filters : ( vcf_id * vcf_filter_meta ) vcf_filter_meta list ; vcfm_format : ( vcf_id , vcf_format_meta ) vcf_format_meta Hashtb... |
type vcf_format = [ ` integer of int | ` float of float | ` character of char | ` string of string | ` missing ] |
type vcf_info = [ vcf_format | ` flag of string ] |
type vcf_row = { vcfr_chrom : string ; vcfr_pos : int ; vcfr_ids : string list ; vcfr_ref : string ; vcfr_alts : string list ; vcfr_qual : float option ; vcfr_filter : vcf_id list ; vcfr_info : ( vcf_id , vcf_info list ) list Hashtbl . t ; vcfr_samples : ( vcf_id , ( vcf_id * ... |
type vcf_parse_row_error = [ Safe . error | ` info_type_coersion_failure of vcf_info_type * string | ` format_type_coersion_failure of vcf_format_type * string | ` invalid_dna of string | ` unknown_info of vcf_id | ` unknown_filter of vcf_id | ` unknown_alt of string | ` duplicate_ids of vcf_... |
type vcf_parse_error = [ ` malformed_meta of Pos . t * string | ` malformed_row of Pos . t * vcf_parse_row_error * string | ` malformed_header of Pos . t * string | ` incomplete_input of Pos . t * string list * string option | ` not_ready ] |
let string_to_vcf_number = function | " A " -> OnePerAllele | " G " -> OnePerGenotype | " . " -> Unknown | arity -> Number ( int_of_string arity ) arity |
let string_to_vcf_format_type s = match String . lowercase s with | " integer " -> ` integer_value | " float " -> ` float_value | " character " -> ` character_value | " string " -> ` string_value | v -> failwith ( " string_to_vcf_format_type : invalid format : " ^ v ) v |
let vcf_format_type_to_string = function | ` integer_value -> " integer " | ` float_value -> " float " | ` character_value -> " character " | ` string_value -> " string " |
let coerce_to_vcf_format_type t s = if String . equal s " . " then Ok ` missing else match t with | ` integer_value -> Result . map ( Safe . int_of_string s ) s ~ f ( : fun x -> ` integer x ) x | ` float_value -> Result . map ( Safe . float_of_string s ) s ~ f ( : fun x -> ` ... |
let coerce_n ~ f key n s = let open Result . Monad_infix in let res = lazy ( Result . all ( List . map ~ f ( String . split ~ on : ' , ' s ) s ) s ) s in match n with | Number n -> Lazy . force res >>= fun values -> if List . length values = n then Ok values else Error ( ` inva... |
let string_to_vcf_info_type s = match String . lowercase s with | " flag " -> ` flag_value | s -> string_to_vcf_format_type s |
let vcf_info_type_to_string = function | ` flag_value -> " flag " | # vcf_format_type as t -> vcf_format_type_to_string t |
let coerce_to_vcf_info_type t s = let res = match t with | ` flag_value -> Ok ( ` flag s ) s | # vcf_format_type -> coerce_to_vcf_format_type t s in Result . map_error res ~ f ( : fun _exn -> ` info_type_coersion_failure ( t , s ) s ) s |
let parse_row_error_to_string = function | ` invalid_int s -> sprintf " invalid_integer ( % s ) s " s | ` invalid_float s -> sprintf " invalid_float ( % s ) s " s | ` info_type_coersion_failure ( t , s ) s -> sprintf " info_type_coersion_failure ( % s , % S ) S " ( vcf... |
let parse_error_to_string = let pos ( ) a = Pos . to_string a in function | ` malformed_meta ( p , s ) s -> sprintf " malformed_meta ( % a , % S ) S " pos p s | ` malformed_row ( p , err , s ) s -> sprintf " malformed_row ( % s , % a , % S ) S " ( parse_row_erro... |
let reserved_info = Hashtbl . Poly . of_alist_exn [ ( " AA " , ` string_value ) string_value ; ( " AC " , ` integer_value ) integer_value ; ( " AF " , ` float_value ) float_value ; ( " AN " , ` integer_value ) integer_value ; ( " BQ " , ` float_value ) float... |
let default_meta = { vcfm_version = " < unknown " ; > vcfm_id_cache = Set . Poly . empty ; vcfm_info = Hashtbl . Poly . create ( ) ; vcfm_filters = [ ] ; vcfm_format = Hashtbl . Poly . create ( ) ; vcfm_alt = reserved_alt ; vcfm_arbitrary = Hashtbl . Poly . create ( ) ; vc... |
let string_to_vcfr_ref s = let s = String . uppercase s in if is_valid_dna s then Ok s else Error ( ` invalid_dna s ) s |
let string_to_vcfr_info { vcfm_info ; _ } s = let go values = List . map ( String . split ~ on : ' ; ' s ) s ~ f ( : fun chunk -> let ( key , raw_value ) raw_value = Option . value ~ default ( : chunk , ) " " ( String . lsplit2 ~ on : ' = ' chunk ) chunk in le... |
let string_to_vcfr_filter { vcfm_filters ; _ } s = match String . split ~ on : ' ; ' s with | [ " PASS ] " -> Ok [ ] | chunks -> match List . find chunks ~ f ( : fun chunk -> not ( List . Assoc . mem ~ equal : String . equal vcfm_filters chunk ) chunk ) chunk with |... |
let string_to_vcfr_ids { vcfm_id_cache ; _ } s = match String . split ~ on : ' ; ' s with | [ ] " . " -> Ok [ ] | chunks -> let duplicate_ids = List . filter chunks ~ f ( : Set . mem vcfm_id_cache ) vcfm_id_cache in if List . is_empty duplicate_ids then Ok chunks else Error ( ... |
let string_to_vcfr_alts { vcfm_alt ; _ } s = match String . split ~ on : ' , ' s with | [ ] " . " -> Ok [ ] | chunks -> let res = List . map chunks ~ f ( : fun chunk -> let n = String . length chunk in match Char ( . chunk [ . 0 ] 0 = ' < ' && chunk [ . n ... |
let list_to_vcfr_samples { vcfm_format ; vcfm_samples ; _ } chunks = let open Result . Monad_infix in let samples = Hashtbl . Poly . create ( ) in let go sample_keys id raw_sample = let sample_chunks = String . split ~ on : ' : ' raw_sample in if List ( . length sample_keys <> length sam... |
let list_to_vcf_row meta chunks = let open Result . Monad_infix in let n_chunks = List . length chunks and n_columns = List ( . length meta . vcfm_header + length meta . vcfm_samples ) vcfm_samples in match chunks with | vcfr_chrom :: raw_pos :: raw_id :: raw_ref :: raw_alt :: raw_qual :: raw_filt... |
module Transform = struct let next_vcf_header meta p = let open Lines . Buffer in let { vcfm_info ; vcfm_format ; _ } = meta in let l = Option . value_exn ( next_line p :> string option ) option in let chunks = List . filter ~ f : String ( . fun s -> s <> ) " " ( String . split ~ ... |
module type Cohttp_IO_S = sig type + ' a t val ( ) >>= : ' a t -> ( ' a -> ' b t ) t -> ' b t val return : ' a -> ' a t type ic type oc val iter : ( ' a -> unit t ) t -> ' a list -> unit t val read_line : ic -> string option t val read : ic -> int -> string t val read_exactly : i... |
module IO = struct type ' a t = ' a Lwt . t let ( >>= ) = Lwt ( . >>= ) let return = Lwt . return type ic = Lwt_io . input_channel type oc = Lwt_io . output_channel let iter = Lwt_list . iter_s let read_line = Lwt_io . read_line_opt let read ic count = Lwt . catch ( fun ( ) -> Lwt_i... |
let reader t = let frag = ref ( Cstruct . create 0 ) 0 in let rec aux buf ofs len = if len = 0 then return 0 else let available = Cstruct . length ! frag in if available = 0 then begin M . read t >>= function | Ok ` Eof -> return 0 | Ok ( ` Data b ) b -> frag := b ; aux buf ofs len ... |
let writer t ( buf : Lwt_bytes . t ) t ( ofs : int ) int ( len : int ) int = let b = Cstruct . sub ( Cstruct . of_bigarray buf ) buf ofs len in M . write t b >>= function | Ok ( ) -> return len | Error ` Closed -> return 0 | Error e -> Fmt . kstr Lwt . fail_with " % a " M .... |
let open_client ~ domid ~ port ( ? buffer_size = 1024 ) 1024 ( ) = M . client ~ domid ~ port ( ) >>= fun t -> let close ( ) = M . close t in let in_buffer = Lwt_bytes . create buffer_size in let ic = Lwt_io . make ~ buffer : in_buffer ~ mode : Lwt_io . input ~ close ( reader t... |
let open_server ~ domid ~ port ( ? buffer_size = 1024 ) 1024 ( ) = M . server ~ domid ~ port ~ read_size : buffer_size ~ write_size : buffer_size ( ) >>= fun t -> let close ( ) = M . close t in let in_buffer = Lwt_bytes . create buffer_size in let ic = Lwt_io . make ~ buffer : in... |
module Kind = struct type t = | Git | Hg let of_dir_contents files = if String . Set . mem files " . git " then Some Git else if String . Set . mem files " . hg " then Some Hg else None let to_dyn t = Dyn . Variant ( ( match t with | Git -> " Git " | Hg -> " Hg " ) , [ ... |
module T = struct type t = { root : Path . t ; kind : Kind . t } let to_dyn { root ; kind } = Dyn . record [ ( " root " , Path . to_dyn root ) ; ( " kind " , Kind . to_dyn kind ) ] let equal { root = ra ; kind = ka } { root = rb ; kind = kb } = Path ... |
let git , hg = let get prog = lazy ( match Bin . which ~ path ( : Env . path Env . initial ) prog with | Some x -> x | None -> Utils . program_not_found prog ~ loc : None ) in ( get " git " , get " hg " ) |
let select git hg t = Memo . of_non_reproducible_fiber ( match t . kind with | Git -> git t | Hg -> hg t ) |
let prog t = Lazy . force ( match t . kind with | Git -> git | Hg -> hg ) |
let run t args = let open Fiber . O in let + s = Process . run_capture Strict ( prog t ) args ~ dir : t . root ~ env : Env . initial in String . trim s |
let git_accept ( ) = Process . Accept ( Predicate_lang . union [ Element 0 ; Element 128 ] ) |
let run_git t args = let res = Process . run_capture ( git_accept ( ) ) ( prog t ) args ~ dir : t . root ~ env : Env . initial ~ stderr_to ( : Process . Io . file Config . dev_null Out ) in let open Fiber . O in let + res = res in match res with | Ok s -> Some ( String . tr... |
let hg_describe t = let open Fiber . O in let * s = run t [ " log " ; " -- rev " ; " . " ; " - T " ; " { latesttag } { latesttagdistance } " ] in let + id = run t [ " id " ; " - i " ] in let id , dirty_suffix = match String . drop_suffix id ~ suffi... |
let make_fun name ~ git ~ hg = let memo = Memo . create name ~ input ( : module T ) ( select git hg ) in Staged . stage ( Memo . exec memo ) |
let describe = Staged . unstage @@ make_fun " vcs - describe " ~ git ( : fun t -> run_git t [ " describe " ; " -- always " ; " -- dirty " ; " -- abbrev = 7 " ] ) ~ hg ( : fun x -> let open Fiber . O in let + res = hg_describe x in Some res ) |
let commit_id = Staged . unstage @@ make_fun " vcs - commit - id " ~ git ( : fun t -> run_git t [ " rev - parse " ; " HEAD " ] ) ~ hg ( : fun t -> let open Fiber . O in let + res = run t [ " id " ; " - i " ] in Some res ) |
let files = let run_zero_separated_hg t args = Process . run_capture_zero_separated Strict ( prog t ) args ~ dir : t . root ~ env : Env . initial in let run_zero_separated_git t args = let open Fiber . O in let + res = Process . run_capture_zero_separated ( git_accept ( ) ) ( prog t ) ... |
let ( ) = init ( ) |
let temp_dir = lazy ( Path . of_string " vcs - tests " ) |
let ( ) = at_exit ( fun ( ) -> Path . rm_rf ( Lazy . force temp_dir ) ) |
let has_hg = match Lazy . force Vcs . hg with | ( _ : Path . t ) -> true | exception _ -> false |
let run ( vcs : Vcs . t ) args = let prog , prog_str , real_args = match vcs . kind with | Git -> ( Vcs . git , " git " , args ) | Hg -> ( if has_hg then ( Vcs . hg , " hg " , args ) else ( Vcs . git , " hg " , match args with | [ " tag " ; s ; " ... |
type action = | Init | Add of string | Write of string * string | Commit | Tag of string | Describe of string |
let run_action ( vcs : Vcs . t ) action = match action with | Init -> run vcs [ " init " ; " - q " ] | Add fn -> run vcs [ " add " ; fn ] | Commit -> ( match vcs . kind with | Git -> run vcs [ " commit " ; " - m " ; " commit message " ] | Hg -> run vcs... |
let run kind script = let ( lazy temp_dir ) = temp_dir in Path . rm_rf temp_dir ; Path . mkdir_p temp_dir ; let vcs = { Vcs . kind ; root = temp_dir } in let config = { Scheduler . Config . concurrency = 1 ; display = { verbosity = Short ; status_line = false } ; rpc = Non... |
let script = [ Init ; Write ( " a " , " " ) - ; Add " a " ; Commit ; Describe " < commit - id " > ; Write ( " b " , " " ) - ; Add " b " ; Describe " < commit - id >- dirty " ; Commit ; Describe " < commit - id " > ; Tag " 1 . 0 " ... |
type ' msg applicationCallbacks = { enqueue : ' msg -> unit ; } |
type ' msg eventHandler = | EventHandlerCallback of string * ( Web . Node . event -> ' msg option ) | EventHandlerMsg of ' msg |
type ' msg eventCache = { handler : Web . Node . event_cb ; cb : ( Web . Node . event -> ' msg option ) ref } |
type ' msg property = | NoProp | RawProp of string * string | Attribute of string * string * string | Data of string * string | Event of string * ' msg eventHandler * ' msg eventCache option ref | Style of ( string * string ) list |
type ' msg properties = ' msg property list |
type ' msg t = | CommentNode of string | Text of string | Node of string * string * string * string * ' msg properties * ' msg t list | LazyGen of string * ( unit -> ' msg t ) * ' msg t ref | Tagger of ( ' msg applicationCallbacks ref -> ' msg applicationCallbacks ref ) * ' msg t |
let noNode = CommentNode " " |
let comment s = CommentNode s |
let text s = Text s |
let fullnode namespace tagName key unique props vdoms = Node ( namespace , tagName , key , unique , props , vdoms ) |
let node ( ? namespace " " ) = tagName ( ? key " " ) = ( ? unique " " ) = props vdoms = fullnode namespace tagName key unique props vdoms |
let lazyGen key fn = LazyGen ( key , fn , ref noNode ) |
let prop key value = RawProp ( key , value ) |
let onCB name key cb = Event ( name , EventHandlerCallback ( key , cb ) , ref None ) |
let onMsg name msg = Event ( name , EventHandlerMsg msg , ref None ) |
let attribute namespace key value = Attribute ( namespace , key , value ) |
let data key value = Data ( key , value ) |
let style key value = Style [ ( key , value ) ] |
let styles s = Style s |
let rec renderToHtmlString = function | CommentNode s -> " <!-- " ^ s ^ " " --> | Text s -> s | Node ( namespace , tagName , _key , _unique , props , vdoms ) -> let renderProp = function | NoProp -> " " | RawProp ( k , v ) -> String . concat " " [ " " ; k ... |
let emptyEventHandler : Web . Node . event_cb = fun [ @ bs ] _ev -> ( ) |
let emptyEventCB = fun _ev -> None |
let eventHandler callbacks cb : Web . Node . event_cb = fun [ @ bs ] ev -> match ! cb ev with | None -> ( ) | Some msg -> ! callbacks . enqueue msg |
let eventHandler_GetCB = function | EventHandlerCallback ( _ , cb ) -> cb | EventHandlerMsg msg -> fun _ev -> Some msg |
let compareEventHandlerTypes left = function | EventHandlerCallback ( cb , _ ) -> ( match left with | EventHandlerCallback ( lcb , _ ) when cb = lcb -> true | _ -> false ) | EventHandlerMsg msg -> ( match left with | EventHandlerMsg lmsg when msg = lmsg -> true | _ -> false ) |
let eventHandler_Register callbacks elem name handlerType = let cb = ref ( eventHandler_GetCB handlerType ) in let handler = eventHandler callbacks cb in let ( ) = Web . Node . addEventListener elem name handler false in Some { handler ; cb } |
let eventHandler_Unregister elem name = function | None -> None | Some cache -> let ( ) = Web . Node . removeEventListener elem name cache . handler false in None |
let eventHandler_Mutate callbacks elem ( oldName : string ) ( newName : string ) oldHandlerType newHandlerType oldCache newCache = match ! oldCache with | None -> newCache := eventHandler_Register callbacks elem newName newHandlerType | Some oldcache -> if oldName = newName then let ( ) = newCach... |
let patchVNodesOnElems_PropertiesApply_Add callbacks elem _idx = function | NoProp -> ( ) | RawProp ( k , v ) -> Web . Node . setProp elem k v | Attribute ( namespace , k , v ) -> Web . Node . setAttributeNsOptional elem namespace k v | Data ( k , v ) -> Js . log ( " TODO... |
let patchVNodesOnElems_PropertiesApply_Remove _callbacks elem _idx = function | NoProp -> ( ) | RawProp ( k , _v ) -> Web . Node . setProp elem k Js . Undefined . empty | Attribute ( namespace , k , _v ) -> Web . Node . removeAttributeNsOptional elem namespace k | Data ( k , ... |
let patchVNodesOnElems_PropertiesApply_RemoveAdd callbacks elem idx oldProp newProp = let ( ) = patchVNodesOnElems_PropertiesApply_Remove callbacks elem idx oldProp in let ( ) = patchVNodesOnElems_PropertiesApply_Add callbacks elem idx newProp in ( ) |
let patchVNodesOnElems_PropertiesApply_Mutate _callbacks elem _idx oldProp = function | NoProp as _newProp -> failwith " This should never be called as all entries through NoProp are gated . " | RawProp ( k , v ) as _newProp -> Web . Node . setProp elem k v | Attribute ( namespace , k , ... |
let rec patchVNodesOnElems_PropertiesApply callbacks elem idx oldProperties newProperties = match [ @ ocaml . warning " - 4 " ] oldProperties , newProperties with | [ ] , [ ] -> true | [ ] , _newProp :: _newRest -> false | _oldProp :: _oldRest , [ ] -> false | NoProp ... |
let patchVNodesOnElems_Properties callbacks elem oldProperties newProperties = patchVNodesOnElems_PropertiesApply callbacks elem 0 oldProperties newProperties |
let genEmptyProps length = let rec aux lst = function | 0 -> lst | len -> aux ( noProp :: lst ) ( len - 1 ) in aux [ ] length |
let mapEmptyProps props = List . map ( fun _ -> noProp ) props |
let rec patchVNodesOnElems_ReplaceNode callbacks elem elems idx = function [ @ ocaml . warning " - 4 " ] | ( Node ( newNamespace , newTagName , _newKey , _newUnique , newProperties , newChildren ) ) -> let oldChild = elems . ( idx ) in let newChild = Web . Document . crea... |
let patchVNodesIntoElement callbacks elem oldVNodes newVNodes = let elems = Web . Node . childNodes elem in let ( ) = patchVNodesOnElems callbacks elem elems 0 oldVNodes newVNodes in newVNodes |
let patchVNodeIntoElement callbacks elem oldVNode newVNode = patchVNodesIntoElement callbacks elem [ oldVNode ] [ newVNode ] |
let wrapCallbacks func callbacks = ref { enqueue = ( fun msg -> ! callbacks . enqueue ( func msg ) ) } |
let map : ( ' a -> ' b ) -> ' a t -> ' b t = fun func vdom -> let tagger callbacks = ref { enqueue = ( fun msg -> ! callbacks . enqueue ( func msg ) ) } in Tagger ( Obj . magic tagger , Obj . magic vdom ) |
module Cmd = struct type ' msg ctx = { send_msg : ( ' msg -> unit ) unit ; } let send_msg ctx = ctx . send_msg type handler = { f : ' msg . ' msg ctx -> ' msg Vdom . Cmd . t -> bool } bool let rec run : type t . handler list -> ( t -> unit ) unit -> t Cmd . t -> unit = fun h ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.