text
stringlengths
0
601k
let execution_parameters_of_dir = let f path = let + dir = nearest_dir path and + ep = Execution_parameters . default in Dune_project . update_execution_parameters ( Dir0 . project dir ) ep in let memo = Memo . create " execution - parameters - of - dir " ~ input ( : module Path . Source ) ~ cutoff : Execution_paramete...
let nearest_vcs path = let * dir = nearest_dir path in match Dir0 . vcs dir with | This vcs -> Memo . return ( Some vcs ) | Ancestor_vcs -> Memo . Lazy . force ancestor_vcs
let files_of path = find_dir path >>| function | None -> Path . Source . Set . empty | Some dir -> Dir0 . files dir |> String . Set . to_list |> Path . Source . Set . of_list_map ~ f ( : Path . Source . relative path )
let file_exists path = find_dir ( Path . Source . parent_exn path ) >>| function | None -> false | Some dir -> String . Set . mem ( Dir0 . files dir ) ( Path . Source . basename path )
let dir_exists path = find_dir path >>| Option . is_some
module Dir = struct include Dir0 module Make_map_reduce ( M : Memo . S ) ( Outcome : Monoid ) = struct open M . O let rec map_reduce t ~ traverse ~ f = let must_traverse = Sub_dirs . Status . Map . find traverse t . status in match must_traverse with | false -> M . return Outcome . empty | true -> let + here = f t and ...
module Make_map_reduce_with_progress ( M : Memo . S ) ( Outcome : Monoid ) = struct open M . O include Dir . Make_map_reduce ( M ) ( Outcome ) let map_reduce ~ traverse ~ f = let * root = M . of_memo ( root ( ) ) in let nb_path_visited = ref 0 in let overlay = Console . Status_line . add_overlay ( Live ( fun ( ) -> Pp ...
let find_dir_specified_on_command_line ~ dir = find_dir dir >>| function | Some dir -> dir | None -> User_error . raise [ Pp . textf " Don ' t know about directory % s specified on the command line " ! ( Path . Source . to_string_maybe_quoted dir ) ]
let is_vendored dir = find_dir dir >>| function | None -> false | Some d -> Dir . status d = Vendored
let enabled = spacetime_enabled ( )
let if_spacetime_enabled f = if enabled then f ( ) else ( )
module Series = struct type t = { channel : out_channel ; mutable closed : bool ; } external write_magic_number : out_channel -> unit = " caml_spacetime_only_works_for_native_code " " caml_spacetime_write_magic_number " external register_channel_for_spacetime : out_channel -> unit = " caml_register_channel_for_spacetim...
module Snapshot = struct external take : ? time : float -> out_channel -> unit = " caml_spacetime_only_works_for_native_code " " caml_spacetime_take_snapshot " let take ? time { Series . closed ; channel } = if_spacetime_enabled ( fun ( ) -> if closed then failwith " Series is closed " ; Gc . minor ( ) ; take ? time ch...
let save_event_for_automatic_snapshots ~ event_name = if_spacetime_enabled ( fun ( ) -> save_event_for_automatic_snapshots ~ event_name )
let index_within_node = ref node_num_header_words
let spacetime_node = ref ( lazy ( Cmm . Cvar ( V . create_local " dummy " ) ) )
let spacetime_node_ident = ref ( lazy ( V . create_local " dummy " ) )
let current_function_label = ref None
let direct_tail_call_point_indexes = ref [ ]
let reverse_shape = ref ( [ ] : Mach . spacetime_shape )
let cconst_int i = Cmm . Cconst_int ( i , Debuginfo . none )
let cconst_natint i = Cmm . Cconst_natint ( i , Debuginfo . none )
let cconst_symbol s = Cmm . Cconst_symbol ( s , Debuginfo . none )
let something_was_instrumented ( ) = ! index_within_node > node_num_header_words
let next_index_within_node ~ part_of_shape ~ label = let index = ! index_within_node in begin match part_of_shape with | Mach . Direct_call_point _ -> incr index_within_node ; if Config . enable_call_counts then begin incr index_within_node end | Mach . Indirect_call_point -> incr index_within_node | Mach . Allocation_...
let reset ~ spacetime_node_ident : ident ~ function_label = index_within_node := node_num_header_words ; spacetime_node := lazy ( Cmm . Cvar ident ) ; spacetime_node_ident := lazy ident ; direct_tail_call_point_indexes := [ ] ; current_function_label := Some function_label ; reverse_shape := [ ]
let code_for_function_prologue ~ function_name ~ fun_dbg : dbg ~ node_hole = let node = V . create_local " node " in let new_node = V . create_local " new_node " in let must_allocate_node = V . create_local " must_allocate_node " in let is_new_node = V . create_local " is_new_node " in let no_tail_calls = List . length...
let code_for_blockheader ~ value ' s_header ~ node ~ dbg = let num_words = Nativeint . shift_right_logical value ' s_header 10 in let existing_profinfo = V . create_local " existing_profinfo " in let existing_count = V . create_local " existing_count " in let profinfo = V . create_local " profinfo " in let address_of_p...
type callee = | Direct of string | Indirect of Cmm . expression
let code_for_call ~ node ~ callee ~ is_tail ~ label dbg = let is_self_recursive_call = match callee with | Direct callee -> begin match ! current_function_label with | None -> Misc . fatal_error " [ current_function_label ] not set " | Some label -> String . equal callee label end | Indirect _ -> false in let is_tail =...
type ' a t = { value : ' a ; children : ' a t Int . Map . t }
module Cursor = struct type t = int list [ @@ deriving equal , sexp ] end
let create init = { value = init ; children = Int . Map . empty } , [ ]
let rec append tree cursor to_insert = match cursor with | [ ] -> let new_leaf = { value = to_insert ; children = Int . Map . empty } in let new_cursor_pos = Map . length tree . children in let children = Map . add_exn tree . children ~ key : new_cursor_pos ~ data : new_leaf in { tree with children } , [ new_cursor_pos...
let find tree cursor = let go tree x = Map . find_exn tree . children x in ( List . fold cursor ~ init : tree ~ f : go ) . value ; ;
let rec width tree = 1 + ( tree . children |> Map . data |> List . map ~ f : width |> List . fold ~ init : 0 ~ f : Int . max ) ; ;
let rec height tree = if Map . is_empty tree . children then 1 else tree . children |> Map . data |> List . sum ( module Int ) ~ f : height ; ;
let traverse tree ~ f = let rec traverse_impl { value ; children } ~ cursor ~ f = if Map . is_empty children then f ~ data : value ~ cursor ~ children [ ] : else ( let ret = Map . fold children ~ init [ ] : ~ f ( : fun ~ key : i ~ data : child res -> let cursor = List . append cursor [ i ] in let ret = traverse_impl ch...
let img = [ docker_image ~ account " : pveber " ~ name " : spades " ~ tag " : 3 . 14 . 0 " ( ) ]
module Yaml = struct module T = Template_dsl let string x = T . quote ~ using ' " ' : ( T . string x ) let list xs = T . seq ~ sep " : " [ T . string " [ " ; T . seq ~ sep " , " : xs ; T . string " ] " ] let obj dict = T . seq ~ sep " : " [ T . string " { " ; List . map dict ~ f ( : fun ( k , v ) -> T . seq ~ sep " : "...
let string_of_orientation = function | ` rf -> " rf " | ` fr -> " fr "
let strandness x = string ( string_of_orientation x )
let alias se_or_pe compression i = let se_or_pe_suffix = match se_or_pe with | ` SE -> " " | ` PE_1 -> " _1 " | ` PE_2 -> " _2 " in let compression_suffix = match compression with | ` Plain -> " " | ` Compressed -> " . gz " in seq ~ sep " " :/ [ tmp ; string ( sprintf " sample_ % d % s . fq % s " i se_or_pe_suffix comp...
let yaml_se_entry i compression = Yaml . ( obj [ " type " , string " single " ; " single reads " , list [ alias ` SE compression i ] ; ] )
let yaml_pe_entry ? orientation compression i = let maybe_add_orientation xs = match orientation with | None -> xs | Some o -> xs @ [ " orientation " , string ( string_of_orientation o ) ] in Yaml . ( [ " type " , string " paired - end " ; " left reads " , list [ alias ` PE_1 compression i ] ; " right reads " , list [ ...
let yaml_entry ? orientation i fq_sample = match ( fq_sample : Fastq_sample . t ) with | Fq ( Single_end _ ) -> yaml_se_entry i ` Plain | Fq_gz ( Single_end _ ) -> yaml_se_entry i ` Compressed | Fq ( Paired_end _ ) -> yaml_pe_entry ? orientation ` Plain i | Fq_gz ( Paired_end _ ) -> yaml_pe_entry ? orientation ` Compre...
let yaml_file ? orientation fq_samples = List . mapi fq_samples ~ f ( : yaml_entry ? orientation ) |> Yaml . list
let renaming_command_of_fastq_sample i fq_sample = let ln src dst = cmd " ln " [ string " - s " ; dep src ; dst ] in match ( fq_sample : Fastq_sample . t ) with | Fq ( Single_end fq ) -> [ ln fq ( alias ` SE ` Plain i ) ] | Fq_gz ( Single_end fq_gz ) -> [ ln fq_gz ( alias ` SE ` Compressed i ) ] | Fq ( Paired_end ( fq1...
let renaming_commands_of_fastq_samples fq_samples = List . concat_mapi fq_samples ~ f : renaming_command_of_fastq_sample
let spades ? single_cell ? iontorrent ( ? threads = 4 ) ( ? memory = 10 ) samples = let yaml_file = yaml_file samples in let ln_commands = renaming_commands_of_fastq_samples samples in Workflow . shell ~ np : threads ~ img ~ mem ( : Workflow . int ( memory * 1024 ) ) ~ descr " : spades " [ mkdir_p tmp ; mkdir_p dest ; ...
let contigs x = Workflow . select x [ " contigs . fasta " ]
let scaffolds x = Workflow . select x [ " scaffolds . fasta " ]
let rnaspades ( ? threads = 4 ) ( ? memory = 10 ) ? ss samples = let yaml_file = yaml_file ? orientation : ss samples in let ln_commands = renaming_commands_of_fastq_samples samples in Workflow . shell ~ np : threads ~ img ~ mem ( : Workflow . int ( memory * 1024 ) ) ~ descr " : rnaspades " [ mkdir_p tmp ; mkdir_p dest...
let transcripts x = Workflow . select x [ " transcripts . fasta " ]
let hard_filtered_transcripts x = Workflow . select x [ " hard_filtered_transcripts . fasta " ]
let soft_filtered_transcripts x = Workflow . select x [ " soft_filtered_transcripts . fasta " ]
module SimpleServer : sig val echo_server : string -> int -> unit val server : string -> int -> ( in_channel -> out_channel -> unit ) -> unit end ; ;
module SimpleServer = struct let server_setup ip portnum = let s = Unix . socket Unix . PF_INET Unix . SOCK_STREAM 0 in let sockad = Unix . ADDR_INET ( ( Unix . inet_addr_of_string ip ) , portnum ) in ( ignore ( Unix . bind s sockad ) ; ignore ( Unix . listen s 10 ) ; ignore ( Unix . setsockopt s Unix . SO_REUSEADDR tr...
let b = Unix . open_connection ( Unix . ADDR_INET ( ( Unix . inet_addr_of_string " 192 . 168 . 1 . 101 " ) , 8889 ) ) ; ;
let b = Unix . open_connection ( Unix . ADDR_INET ( ( Unix . inet_addr_of_string " 192 . 168 . 1 . 101 " ) , 8889 ) ) ; ;
module SelectServer = struct type token_type = Spam of string * int | Query of string | Ham of string * int type connection = { fd : Unix . file_descr ; addr : Unix . sockaddr ; mutable input_buffer : string ; output_queue : token_type Queue . t } ; ; let add_string conn = let strbuf = String . create 32 in let res = U...
type ' a graph_term = { nodes : ' a list ; edges : ( ' a * ' a ) list }
let get_reached_nodes edges = let add_to nodes new_node = if List . exists ( fun node -> node = new_node ) nodes then nodes else new_node :: nodes in List . fold_left ( fun nodes edge -> let nodes = add_to nodes ( fst edge ) in add_to nodes ( snd edge ) ) [ ] edges
let s_tree graph = let num_nodes = List . length graph . nodes in let rec select edges selected = let continue = match edges with | [ ] -> [ ] | edge :: rest -> let sel = select rest ( edge :: selected ) in let unsel = select rest selected in sel @ unsel in if List . length selected = num_nodes - 1 then let nodes_reach...
let graph = { nodes = [ ' a ' ; ' b ' ; ' c ' ; ' d ' ; ' e ' ; ' f ' ; ' g ' ; ' h ' ] ; edges = [ ( ' a ' , ' b ' ) ; ( ' a ' , ' d ' ) ; ( ' b ' , ' c ' ) ; ( ' b ' , ' e ' ) ; ( ' c ' , ' e ' ) ; ( ' d ' , ' e ' ) ; ( ' d ' , ' f ' ) ; ( ' d ' , ' g ' ) ; ( ' e ' , ' h ' ) ; ( ' f ' , ' g ' ) ; ( ' g ' , ' h ' ) ] ...
let ( ) = assert ( List . length ( s_tree graph ) = 178 )
module Stable = struct module V1 = struct module Parts = struct type t = { sign : Sign . t ; hr : int ; min : int ; sec : int ; ms : int ; us : int ; ns : int } [ @@ deriving compare , sexp ] end module type Like_a_float = sig type t [ @@ deriving bin_io , hash , quickcheck , typerep ] include Comparable . S_common wit...
let to_string_hum ( ? delimiter = ' _ ' ) ( ? decimals = 3 ) ( ? align_decimal = false ) ? unit_of_time t = let float , suffix = match Option . value unit_of_time ~ default ( : to_unit_of_time t ) with | Day -> to_day t , " d " | Hour -> to_hr t , " h " | Minute -> to_min t , " m " | Second -> to_sec t , " s " | Millis...
let gen_incl lo hi = Float . gen_incl ( to_sec lo ) ( to_sec hi ) |> Quickcheck . Generator . map ~ f : of_sec ; ;
let gen_uniform_incl lo hi = Float . gen_uniform_excl ( to_sec lo ) ( to_sec hi ) |> Quickcheck . Generator . map ~ f : of_sec ; ; type nonrec t = t let to_string = to_string let module_name = " Core_kernel . Time . Span " end ) type nonrec t = t [ @@ deriving bin_io , compare , hash , sexp_of ] let t_of_sexp sexp = ma...
module C = struct type t = T . t [ @@ deriving bin_io ] type comparator_witness = T . comparator_witness let comparator = T . comparator let sexp_of_t = sexp_of_t let t_of_sexp sexp = match Option . try_with ( fun ( ) -> T . of_float ( Float . t_of_sexp sexp ) ) with | Some t -> t | None -> t_of_sexp sexp ; ; end
module Map = Map . Make_binable_using_comparator ( C )
module Set = Set . Make_binable_using_comparator ( C )
module Private = struct let suffix_of_unit_of_time = suffix_of_unit_of_time let parse_suffix = Stable . V3 . Of_string . parse_suffix end
let randomize span ~ percent ~ scale = let mult = Percent . to_mult percent in if Float . ( < ) mult 0 . || Float . ( > ) mult 1 . then raise_s [ % message " Span . randomize : percent is out of range [ 0x , 1x ] " ( percent : Percent . t ) ] ; let factor = Random . float_range ( 1 . . - mult ) ( Float . one_ulp ` Up (...
let format_decimal n tenths units = assert ( tenths >= 0 && tenths < 10 ) ; if n < 10 && tenths <> 0 then sprintf " % d . % d % s " n tenths units else sprintf " % d % s " n units ; ;
let short_string ~ sign ~ hr ~ min ~ sec ~ ms ~ us ~ ns = let s = if hr >= 24 then format_decimal ( hr / 24 ) ( Int . of_float ( Float . of_int ( hr % 24 ) . / 2 . 4 ) ) " d " else if hr > 0 then format_decimal hr ( min / 6 ) " h " else if min > 0 then format_decimal min ( sec / 6 ) " m " else if sec > 0 then format_de...
module type Parts = sig type t = private { sign : Sign . t ; hr : int ; min : int ; sec : int ; ms : int ; us : int ; ns : int } [ @@ deriving compare , sexp ] end
module type S = sig type underlying type t = private underlying [ @@ deriving bin_io , hash , sexp , typerep ] module Parts : Parts include Comparable_binable with type t := t include Comparable . With_zero with type t := t include Hashable_binable with type t := t include Pretty_printer . S with type t := t include Ro...
let arch_sixtyfour = Int . equal Sys . word_size 64
let float x = Int63 . to_float x
module T = struct type t = Int63 . t [ @@ deriving hash , bin_io , quickcheck , typerep ] module Replace_polymorphic_compare = Int63 . Replace_polymorphic_compare let zero = Int63 . zero end
module Parts = struct type t = { sign : Sign . t ; hr : int ; min : int ; sec : int ; ms : int ; us : int ; ns : int } [ @@ deriving compare , sexp ] end
let next t = Int63 . succ t
let prev t = Int63 . pred t
let nanosecond = Int63 . of_int 1
let microsecond = Int63 . ( of_int 1000 * nanosecond )
let millisecond = Int63 . ( of_int 1000 * microsecond )
let second = Int63 . ( of_int 1000 * millisecond )
let minute = Int63 . ( of_int 60 * second )
let hour = Int63 . ( of_int 60 * minute )
let day = Int63 . ( of_int 24 * hour )
let max_value_for_1us_rounding = Int63 . ( of_int 135 * of_int 365 * day )
let min_value_for_1us_rounding = Int63 . neg max_value_for_1us_rounding
let create ? sign ( : sign_ = Sign . Pos ) ? day ( : days = 0 ) ( ? hr = 0 ) ? min ( : minutes = 0 ) ( ? sec = 0 ) ( ? ms = 0 ) ( ? us = 0 ) ( ? ns = 0 ) ( ) = let open Int63 in let t = ( of_int days * day ) + ( of_int hr * hour ) + ( of_int minutes * minute ) + ( of_int sec * second ) + ( of_int ms * millisecond ) + (...
let to_parts t = let open Int63 in let mag = abs t in { Parts . sign = ( if t < zero then Neg else if t > zero then Pos else Zero ) ; hr = to_int_exn ( mag / hour ) ; min = to_int_exn ( rem mag hour / minute ) ; sec = to_int_exn ( rem mag minute / second ) ; ms = to_int_exn ( rem mag second / millisecond ) ; us = to_in...
let of_parts { Parts . sign ; hr ; min ; sec ; ms ; us ; ns } = create ~ sign ~ hr ~ min ~ sec ~ ms ~ us ~ ns ( ) ; ;
let of_ns f = round_nearest f
let of_int63_ns i = i
let of_int_us i = Int63 . ( of_int i * microsecond )