text
stringlengths
0
601k
let rl_of_header h = let module C = Cohttp . Header in match C . get h " X - RateLimit - Limit " , C . get h " X - RateLimit - Remaining " , C . get h " X - RateLimit - Reset " with | Some lim , Some rem , Some re -> let limit = Int . of_string lim in let remaining = Int . of_string rem in let reset = Int . of_string r...
let default = { limit = 1 ; remaining = 1 ; reset = 0 ; }
let empty : t = RouteMap . empty
let find_exn m s = match find m s with | Some r -> r | None -> raise ( Not_found_s ( String . sexp_of_t s ) )
let get_rl meth path rl = let route = route_of_path meth path in match RouteMap . find rl route with | Some r -> r , rl | None -> let data = Mvar . create ( ) in Mvar . set data default ; let rl = RouteMap . add_exn rl ~ key : route ~ data in data , rl
module RlVertexBuffer = struct let % c uint_array_4 = array 4 uint type % c t = { element_count : int ; [ @ cname " elementCount " ] vertices : float ptr ; texcoords : float ptr ; colors : uchar ptr ; indices : uint ptr ; vao_id : uint ; [ @ cname " vaoId " ] vbo_id : uint_array_4 ; [ @ cname " vboId " ] } [ @@ cname "...
module RlDrawCall = struct type % c t = { mode : int ; vertex_count : int ; [ @ cname " vertexCount " ] vertex_alignment : int ; [ @ cname " vertexAlignment " ] texture_id : uint ; [ @ cname " textureId " ] } [ @@ cname " rlDrawCall " ] end
module RlRenderBatch = struct type % c t = { buffer_count : int ; [ @ cname " bufferCount " ] current_buffer : int ; [ @ cname " currentBuffer " ] vertex_buffer : RlVertexBuffer . t ptr ; [ @ cname " vertexBuffer " ] draws : RlDrawCall . t ptr ; draw_counter : int ; [ @ cname " drawCounter " ] current_depth : float ; [...
let lights_count = ref 0
type light_type = Directional | Point
let int_of_light_type = function Directional -> 0 | Point -> 1
type light = { typ : light_type ; position : Vector3 . t ; target : Vector3 . t ; color : Color . t ; enabled : bool ; loc_enabled : int ; loc_typ : int ; loc_pos : int ; loc_target : int ; loc_color : int ; }
let update_light_values shader light = let enabled = Ctypes . allocate Ctypes . bool light . enabled in set_shader_value shader light . loc_enabled ( to_voidp enabled ) ShaderUniformDataType . Int ; let typ = Ctypes . allocate Ctypes . int ( int_of_light_type light . typ ) in set_shader_value shader light . loc_typ ( t...
let create_light typ position target color shader = if ! lights_count > max_lights then failwith " Too many lights " else let enabled_name = Printf . sprintf " lights [ % i ] . enabled " ! lights_count in let typ_name = Printf . sprintf " lights [ % i ] . type " ! lights_count in let pos_name = Printf . sprintf " light...
type prompt = Always | Once | Never
let rm prompt recurse files = Printf . printf " prompt = % s \ nrecurse = % B \ nfiles = % s \ n " ( prompt_str prompt ) recurse ( String . concat " , " files )
let files = Arg . ( non_empty & pos_all file [ ] & info [ ] ~ docv " : FILE " )
let prompt = let always = let doc = " Prompt before every removal . " in Always , Arg . info [ " i " ] ~ doc in let never = let doc = " Ignore nonexistent files and never prompt . " in Never , Arg . info [ " f " ; " force " ] ~ doc in let once = let doc = " Prompt once before removing more than three files , or when re...
let recursive = let doc = " Remove directories and their contents recursively . " in Arg . ( value & flag & info [ " r " ; " R " ; " recursive " ] ~ doc )
let cmd = let doc = " Remove files or directories " in let man = [ ` S Manpage . s_description ; ` P " ( $ tname ) removes each specified ( $ i , FILE ) . By default it does not remove directories , to also remove them and their contents , use the option ( $ b , -- recursive ) ( ( $ b , - r ) or ( $ b , - R ) ) . " ; `...
let main ( ) = exit ( Cmd . eval cmd )
let ( ) = main ( )
let samples = [ ` WT_BHI_1 ; ` WT_BHI_2 ; ` WT_BHI_3 ; ` CodY_BHI_1 ; ` CodY_BHI_2 ; ` CodY_BHI_3 ; ]
let srr_id = function | ` WT_BHI_1 -> " SRR3033158 " | ` WT_BHI_2 -> " SRR3033159 " | ` WT_BHI_3 -> " SRR3033160 " | ` CodY_BHI_1 -> " SRR3033161 " | ` CodY_BHI_2 -> " SRR3033162 " | ` CodY_BHI_3 -> " SRR3033163 "
let genotype = function | ` WT_BHI_1 | ` WT_BHI_2 | ` WT_BHI_3 -> " WT " | ` CodY_BHI_1 | ` CodY_BHI_2 | ` CodY_BHI_3 -> " deltaCodY "
let fastq x = Sra_toolkit . fastq_dump_gz ( ` id ( srr_id x ) ) |> Bistro_unix . gunzip
let genome : fasta pworkflow = Bistro_unix . wget " ftp :// ftp . ensemblgenomes . org / pub / bacteria / release - 41 / fasta / bacteria_21_collection / listeria_monocytogenes_10403s / dna / Listeria_monocytogenes_10403s . ASM16869v2 . dna_rm . chromosome . Chromosome . fa . gz " |> Bistro_unix . gunzip
let bowtie2_index = Bowtie2 . bowtie2_build genome
let mapped_reads x = Bowtie2 . bowtie2 bowtie2_index ( SE_or_PE . Single_end [ fastq x ] )
let annotation : gff pworkflow = Bistro_unix . wget " ftp :// ftp . ensemblgenomes . org / pub / bacteria / release - 41 / gff3 / bacteria_21_collection / listeria_monocytogenes_10403s / Listeria_monocytogenes_10403s . ASM16869v2 . 41 . chromosome . Chromosome . gff3 . gz " |> Bistro_unix . gunzip
let counts x = Subread . featureCounts ~ feature_type " : gene " ~ attribute_type " : gene_id " ~ strandness ` : Unstranded ~ q : 5 annotation ( mapped_reads x ) |> Subread . featureCounts_htseq_tsv
let differential_analysis = DESeq2 . main_effects [ " genotype " ] ( List . map samples ~ f ( : fun x -> [ genotype x ] , counts x ) )
let ( ) = let open Bistro_utils . Repo in [ item [ " delme " ] ( counts ` WT_BHI_3 ) ; item [ " deseq2 " ] differential_analysis # directory ; ] |> build_main ~ np : 4 ~ mem ( ` : GB 4 ) ~ outdir " : res " ~ loggers [ : Bistro_utils . Console_logger . create ( ) ]
let ( ) = if Array . length Sys . argv <> 4 then begin fprintf stderr " Usage : rndo - add < prec > < x > < y >\ n " ; exit 1 end ; let prec = int_of_string Sys . argv . ( 1 ) in if prec < 2 then begin fprintf stderr " rndo - add : bad precision \ n " ; exit 1 end ; let pprec = prec - 1 in let x = M . make_from_str Sys...
module S = struct module type Generator = sig type g val block : int val create : unit -> g val generate : g : g -> int -> Cstruct . t val reseed : g : g -> Cstruct . t -> unit val accumulate : g : g -> [ ` Acc of source : int -> Cstruct . t -> unit ] val seeded : g : g -> bool end type ' a generator = ( module Generat...
let create ( type a ) ? g ? seed ( ? strict = false ) ( m : a S . generator ) = let module M = ( val m ) in let g = Option . get_or M . create ( ) g in seed |> Option . cond ~ f ( : M . reseed ~ g ) ; S . Generator ( g , strict , m )
let generator = ref ( create ( module Fortuna ) )
let get = function Some g -> g | None -> ! generator
let generate ( ? g = ! generator ) n = let S . Generator ( g , _ , m ) = g in let module M = ( val m ) in M . generate ~ g n
let reseed ( ? g = ! generator ) cs = let S . Generator ( g , _ , m ) = g in let module M = ( val m ) in M . reseed ~ g cs
let accumulate g = let S . Generator ( g , _ , m ) = get g in let module M = ( val m ) in M . accumulate ~ g
let seeded g = let S . Generator ( g , _ , m ) = get g in let module M = ( val m ) in M . seeded ~ g
let block g = let S . Generator ( _ , _ , m ) = get g in let module M = ( val m ) in M . block
let strict g = let S . Generator ( _ , s , _ ) = get g in s
module Make_N ( N : Numeric . S ) = struct type t = N . t let gen ? g n = if n < N . one then invalid_arg " Rng . gen : non - positive : % a " N . pp_print n ; let bs = block g in let bits = N . ( bits ( pred n ) ) in let octets = bits // 8 in let batch = if strict g then octets else 2 * octets // bs * bs in let rec at...
module Int = Make_N ( Numeric . Int )
module Int32 = Make_N ( Numeric . Int32 )
module Int64 = Make_N ( Numeric . Int64 )
module ZN = Make_N ( Numeric . Z )
let rec prime ? g ( ? msb = 1 ) bits = let p = Z . ( nextprime @@ ZN . gen_bits ? g ~ msb bits ) in if p < Z . ( one lsl bits ) then p else prime ? g ~ msb bits
let rec safe_prime ? g bits = let q = prime ? g ~ msb : 1 ( bits - 1 ) in let p = Z . ( q * ~$ 2 + ~$ 1 ) in if Numeric . pseudoprime p then ( q , p ) else safe_prime ? g bits
module Generators = struct module Fortuna = Fortuna module Hmac_drgb = Hmac_drgb module Null = struct type g = Cstruct . t ref let block = 1 let create ( ) = ref Cs . empty let generate ~ g n = try let ( a , b ) = Cstruct . split ! g n in ( g := b ; a ) with Invalid_argument _ -> raise Unseeded_generator let reseed ~ g...
let all_vars_with_names node = Var . get_all_vars [ Node . P node ] |> List . mapi ~ f ( : fun i var -> Printf . sprintf " V % d " i , var ) var
let train filename learning_rate = let dataset = Text_helper . create filename Float32 in let dim = Text_helper . dim dataset in let placeholder_x = Ops . placeholder ~ type_ : Float [ - 1 ; seq_len ] in let placeholder_y = Ops . placeholder ~ type_ : Float [ - 1 ] in let cross_entropy = let wy , by = Var . normalf [ s...
let ( ) = Random . init 42 ; let open Cmdliner in let train_cmd = let filename = let doc = " Data file to use for training / validation . " in Arg ( . value & opt file " data / text8 " & info [ " data - file " ] ~ docv " : FILE " ~ doc ) doc in let learning_rate = let doc = " Learning rate for the Adam optimizer " in A...
let gru ~ size_h ~ size_x ~ size_y x_and_ys = let wy , by = Var . normalf [ size_h ; size_y ] ~ stddev : 0 . 1 , Var . f [ size_y ] 0 . in let gru = Staged . unstage ( Cell . gru ~ size_h ~ size_x ) size_x in let one_gru ~ h ~ x = let h = gru ~ h ~ x in let y_bar = Ops ( ( . h *^ wy ) wy + by ) by in y_bar , h in let e...
let fit_1d fn = let x_and_ys = List . init steps ~ f ( : fun x -> let x = float x . * step_size in let xs = List . init train_size ~ f ( : fun i -> fn ( x . + float i ) i ) i in let ys = List . init train_size ~ f ( : fun i -> fn ( x . + step_size . + float i ) i ) i in let xs = Ops . const_float ~ type_ : Float ~ shap...
let ( ) = let open Gnuplot in let ys , ys ' = fit_1d sin in let xys = List . mapi ys ~ f ( : fun i y -> float i . * step_size , y ) y in let xys ' = List . mapi ys ' ~ f ( : fun i y -> float i . * step_size , y ) y in let gp = Gp . create ( ) in Gp . plot_many gp ~ output ( : Output . create ` Qt ) Qt [ Series . points...
let lstm ~ size_c ~ size_x ~ size_y x_and_ys = let wy , by = Var . normalf [ size_c ; size_y ] ~ stddev : 0 . 1 , Var . f [ size_y ] 0 . in let lstm = Staged . unstage ( Cell . lstm ~ size_c ~ size_x ) size_x in let one_lstm ~ h ~ x ~ c = let ` h h , ` c c = lstm ~ h ~ x ~ c in let y_bar = Ops ( ( . h *^ wy ) wy + by )...
let fit_1d fn = let x_and_ys = List . init steps ~ f ( : fun x -> let x = float x . * step_size in let xs = List . init train_size ~ f ( : fun i -> fn ( x . + float i ) i ) i in let ys = List . init train_size ~ f ( : fun i -> fn ( x . + step_size . + float i ) i ) i in let xs = Ops . const_float ~ type_ : Float ~ shap...
let ( ) = let open Gnuplot in let ys = fit_1d sin in let xys = List . mapi ys ~ f ( : fun i y -> float i . * step_size , y ) y in let gp = Gp . create ( ) in Gp . plot_many gp ~ output ( : Output . create ` Qt ) Qt [ Series . points_xy xys ] ; Gp . close gp
let usleep s = ignore ( Unix . select [ ] [ ] [ ] s )
let run conn = Sensor . set conn ` S1 ` Switch ` Bool ; let ultra = Sensor . Ultrasonic . make conn ` S4 in let set_speed b c = Motor . set conn Motor . b ( Motor . speed b ) ; Motor . set conn Motor . c ( Motor . speed c ) in let stop _ = set_speed 0 0 ; Mindstorm . NXT . close conn ; exit 0 in Sys . set_signal Sys . ...
let ( ) = let bt = if Array . length Sys . argv < 2 then ( printf " % s < bluetooth addr >\ n " Sys . argv . ( 0 ) ; exit 1 ; ) else Sys . argv . ( 1 ) in let conn = Mindstorm . NXT . connect_bluetooth bt in printf " Press the button on the robot to stop . \ n " ; %! run conn
let option_of_bool = function | true -> Some true | false -> None
let int_of_string i = Option . try_with ( fun ( ) -> Int . of_string i )
module Usermeta = struct type t = { key : string let create ~ k ~ v = { key = k ; value = v } let key t = t . key let value t = t . value let set_key s t = { t with key = s } let set_value so t = { t with value = so } let of_pb { Pb_robj . Pair . key ; value } = { key ; value } let to_pb { key ; value } = { Pb_robj . P...
module Index = struct type idx = | String of string type t = { key : string let create ~ k ~ v = { key = k ; value = v } let key t = t . key let value t = t . value let set_key s t = { t with key = s } let set_value idx t = { t with value = idx } let of_pb { Pb_robj . Pair . key ; value } = let value = Option . value ~...
module Link = struct type t = { bucket : string option let bucket t = t . bucket let key t = t . key let tag t = t . tag let set_bucket b t = { t with bucket = b } let set_key k t = { t with key = k } let set_tag tag t = { t with tag = tag } let of_pb l = let module L = Pb_robj . Link in { bucket = l . L . bucket ; key...
module Content = struct type t = { value : string let of_pb pb = let module C = Pb_robj . Content in { value = pb . C . value ; content_type = pb . C . content_type ; charset = pb . C . content_type ; content_encoding = pb . C . content_encoding ; vtag = pb . C . vtag ; links = List . map ~ f : Link . of_pb pb . C . li...
type ' a t = { contents : Content . t list
let of_pb contents vclock unchanged = let contents = List . map ~ f : Content . of_pb contents in { contents = contents ; vclock = vclock ; unchanged = Option . value ~ default : false unchanged }
let to_pb t = ( List . map ~ f : Content . to_pb t . contents , t . vclock )
let create c = { contents = [ c ] ; vclock = None ; unchanged = false }
let contents t = t . contents
let content t = List . hd_exn ( t . contents )
let vclock t = t . vclock
let unchanged t = t . unchanged
let set_contents cs t = { t with contents = cs }
let set_content c t = { t with contents = [ c ] }
let set_vclock v t = { t with vclock = v }
let shoulder = ref 0
let elbow = ref 0
let init ( ) = glClearColor 0 . 0 0 . 0 0 . 0 0 . 0 ; glShadeModel GL_FLAT ; ; ;
let display ( ) = glClear [ GL_COLOR_BUFFER_BIT ] ; glPushMatrix ( ) ; glTranslate ( - 1 . 0 ) 0 . 0 0 . 0 ; glRotate ( float ! shoulder ) 0 . 0 0 . 0 1 . 0 ; glTranslate 1 . 0 0 . 0 0 . 0 ; glPushMatrix ( ) ; glScale 2 . 0 0 . 4 1 . 0 ; glColor3 1 . 0 0 . 4 0 . 0 ; glutWireCube 1 . 0 ; glPopMatrix ( ) ; glTranslate 1 ...
let reshape ~ width : w ~ height : h = glViewport 0 0 w h ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; gluPerspective 65 . 0 ( ( float w ) . ( / float h ) ) 1 . 0 20 . 0 ; glMatrixMode GL_MODELVIEW ; glLoadIdentity ( ) ; glTranslate 0 . 0 0 . 0 ( - 5 . 0 ) ; ; ;
let keyboard ~ key ~ x ~ y = match key with | ' s ' -> shoulder := ( ! shoulder + 5 ) mod 360 ; glutPostRedisplay ( ) ; | ' S ' -> shoulder := ( ! shoulder - 5 ) mod 360 ; glutPostRedisplay ( ) ; | ' e ' -> elbow := ( ! elbow + 5 ) mod 360 ; glutPostRedisplay ( ) ; | ' E ' -> elbow := ( ! elbow - 5 ) mod 360 ; glutPost...
let ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_DOUBLE ; GLUT_RGB ] ; glutInitWindowSize 500 500 ; glutInitWindowPosition 100 100 ; ignore ( glutCreateWindow Sys . argv . ( 0 ) ) ; init ( ) ; glutDisplayFunc ~ display ; glutReshapeFunc ~ reshape ; glutKeyboardFunc ~ keyboard ; glutMainLoop ( ) ; ;...
module GPR1493 = struct type t1 = { x : int ; y : string ; } type t2 = { a : int ; b : string ; c : string list ; } type t = . . type t += C1 of t1 | C2 of t2 let f ( x : t ) = match x with | C1 { x ; y } -> ( ) | C2 { a ; b ; c } -> ( ) | _ -> ( ) end
module Coherence_illustration = struct type ab = A | B module M : sig type mab = A | B type _ t = AB : ab t | MAB : mab t end = struct type mab = ab = A | B type _ t = AB : ab t | MAB : mab t let f ( type x ) ( t1 : x t ) ( t2 : x t ) ( x : x ) = match t1 , t2 , x with | AB , AB , A -> ( ) | MAB , _ , A -> ( ) | _ , AB...
module M1 = struct type _ repr = R1 : int repr | R2 : string repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , 0 -> ( ) | _ , R2 , " coucou " -> ( ) end
module M2 = struct type c = A | B | C type _ repr = R1 : c repr | R2 : string repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , A -> ( ) | _ , R2 , " coucou " -> ( ) let g ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | _ , R2 , " coucou ...
module M3 = struct type c1 = A | B | C type c2 = X | Y | Z type _ repr = R1 : c1 repr | R2 : c2 repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , A -> ( ) | _ , R2 , X -> ( ) let g ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , ...
module M3_gadt = struct type c1 = A | B | C type _ c2 = X : int c2 | Y : char c2 | Z : char c2 type _ repr = R1 : c1 repr | R2 : int c2 repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , A -> ( ) | _ , R2 , X -> ( ) let g ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : ...
module M3_gadt_bis = struct type _ c1 = A : int c1 | B : int c1 | C : char c1 type _ c2 = X : int c2 | Y : char c2 | Z : char c2 type _ repr = R1 : int c1 repr | R2 : int c2 repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , A -> ( ) | _ , R2 , X -> ( ) let g ( type a ) ...
module M3_gadt_bis_harder = struct type _ c1 = A : int c1 | B : int c1 | C : char c1 type _ c2 = X : int c2 | Y : char c2 | Z : char c2 type _ repr = R1 : ' a c1 repr | R2 : ' a c2 repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , A -> ( ) | _ , R2 , X -> ( ) let g ( ty...
module M4 = struct type _ repr = R1 : int repr | R2 : int array repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | _ , R1 , 0 -> ( ) | R2 , _ , [ ] || -> ( ) | _ , R1 , 1 -> ( ) let g ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , _ -> ( ...
module M5 = struct type _ repr = R1 : char repr | R2 : string repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , ' c ' -> ( ) | _ , R2 , " coucou " -> ( ) end
module M6 = struct type _ repr = R1 : [ ` A | ` B ] repr | R2 : string repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , ` A -> ( ) | _ , R2 , " coucou " -> ( ) end
module M7 = struct type _ repr = R1 : ( int * string ) repr | R2 : ( int * string * char ) repr let f ( type a ) ( r1 : a repr ) ( r2 : a repr ) ( a : a ) = match r1 , r2 , a with | R1 , _ , ( 3 , " " ) -> ( ) | _ , R2 , ( 1 , " coucou " , ' a ' ) -> ( ) end