text stringlengths 0 601k |
|---|
let next str ofs = if ofs < 0 || ofs >= String . length str then raise Out_of_bounds else unsafe_next str ofs |
let extract_next str ofs = if ofs < 0 || ofs >= String . length str then raise Out_of_bounds else unsafe_extract_next str ofs |
let prev str ofs = if ofs <= 0 || ofs > String . length str then raise Out_of_bounds else unsafe_prev str ofs |
let extract_prev str ofs = if ofs <= 0 || ofs > String . length str then raise Out_of_bounds else unsafe_extract_prev str ofs |
let alphabetic = UCharInfo . load_property_tbl ` Alphabetic |
let escaped_char ch = match UChar . code ch with | 7 -> " \\ a " | 8 -> " \\ b " | 9 -> " \\ t " | 10 -> " \\ n " | 11 -> " \\ v " | 12 -> " \\ f " | 13 -> " \\ r " | 27 -> " \\ e " | 92 -> " " \\\\ | code when code >= 32 && code <= 126 -> String . make 1 ( Char . chr code ) code | _ when UCharTbl . Bool . get alphabet... |
let add_escaped_char buf ch = match UChar . code ch with | 7 -> Buffer . add_string buf " \\ a " | 8 -> Buffer . add_string buf " \\ b " | 9 -> Buffer . add_string buf " \\ t " | 10 -> Buffer . add_string buf " \\ n " | 11 -> Buffer . add_string buf " \\ v " | 12 -> Buffer . add_string buf " \\ f " | 13 -> Buffer . add... |
let escaped str = let buf = Buffer . create ( String . length str ) str in iter ( add_escaped_char buf ) buf str ; Buffer . contents buf |
let add_escaped buf str = iter ( add_escaped_char buf ) buf str |
let add_escaped_string buf enc str = match try Some ( CharEncoding . recode_string ~ in_enc : enc ~ out_enc : CharEncoding . utf8 str ) str with CharEncoding . Malformed_code -> None with | Some str -> add_escaped buf str | None -> String . iter ( function | ' \ x20 ' . . ' \ x7e ' as ch -> Buffer . add_char buf ch | c... |
let escaped_string enc str = let buf = Buffer . create ( String . length str ) str in add_escaped_string buf enc str ; Buffer . contents buf |
module Convert ( ConvertUS : UnicodeString . Type ) Type = struct let of_list l = let buf = US . Buf . create 0 in let rec convert l = match l with | [ ] -> ( ) | c :: tl -> US . Buf . add_char buf c ; convert tl in convert l ; US . Buf . contents buf let of_array a = let buf = US . Buf . create 0 in for i = 0 to Array... |
let array_rev a = let len = Array . length a - 1 in Array . init len ( fun i -> a ( . len - i ) i ) i |
let rec list_compare ( ? compare = compare ) compare l1 l2 = match l1 , l2 with | [ ] , [ ] -> 0 | [ ] , _ -> - 1 | _ , [ ] -> 1 | h1 :: t1 , h2 :: t2 -> match compare h1 h2 with | 0 -> list_compare ~ compare t1 t2 | _ as r -> r |
let array_compare ( ? compare = compare ) compare a1 a2 = let len1 = Array . length a1 and len2 = Array . length a2 in let rec compare_aux pos = let remain1 = len1 - pos and remain2 = len2 - pos in if remain1 <= 0 && remain2 <= 0 then 0 else if remain1 <= 0 && remain2 > 0 then - 1 else if remain1 > 0 && remain2 <= 0 th... |
let compile file = Modules . clear ( ) ; if ! no_stdlib then set_no_stdlib ( ) ; if Filename . check_suffix file " . zls " || Filename . check_suffix file " . zlus " then let filename = Filename . chop_extension file in let modname = String . capitalize_ascii ( Filename . basename filename ) in compile modname filename... |
let build file = Deps_tools . add_to_load_path Filename . current_dir_name ; let rec _build acc file = let deps = match ( Filename . extension file ) with | " . zls " -> Deps_tools . zls_dependencies file | " . zli " -> Deps_tools . zli_dependencies file | _ -> raise ( Arg . Bad ( " don ' t know what to do with " ^ fil... |
let doc_verbose = " \ t Set verbose mode " |
let doc_vverbose = " \ t Set even more verbose mode " " < node > \ t Simulates the node < node > and generates a file < out . > ml \ n \ \ t \ t where < out > is equal to the argument of - o if the flag \ n \ \ t \ t has been set , or < node > otherwise " " \ t Use lablgtk2 interface . " |
let errmsg = " Options are " : |
let set_verbose ( ) = verbose := true ; Printexc . record_backtrace true |
let set_vverbose ( ) = vverbose := true ; set_verbose ( ) |
let add_include d = Deps_tools . add_to_load_path d ; load_path := d :: ! load_path |
let set_gtk ( ) = use_gtk := true ; match ! load_path with | [ stdlib ] -> add_include ( stdlib ^ " - gtk " ) | _ -> ( ) |
let main ( ) = try Arg . parse ( Arg . align [ " - v " , Arg . Unit set_verbose , doc_verbose ; " - vv " , Arg . Unit set_vverbose , doc_vverbose ; " - version " , Arg . Unit show_version , doc_version ; " - o " , Arg . String set_outname , doc_outname ; " - I " , Arg . String add_include , doc_include ; " - i " , Arg ... |
type kind = S | A | C | D | AD | AS | P |
type ' a localized = { desc : ' a ; loc : Zlocation . location } |
type type_expression = type_expression_desc localized | Etypevar of string | Etypeconstr of Lident . t * type_expression list | Etypetuple of type_expression list | Etypevec of type_expression * size | Etypefun of kind * Zident . t option * type_expression * type_expression | Sconst of int | Sglobal of Lident . t | Sna... |
type interface = interface_desc localized | Einter_open of name | Einter_typedecl of name * name list * type_decl | Einter_constdecl of name * type_expression | Eabstract_type | Eabbrev of type_expression | Evariant_type of constr_decl list | Erecord_type of ( name * type_expression ) list | Econstr0decl of name | Econ... |
let matmult_complex = kern cva cvb cvc n -> let mul = fun c d -> { re = c . re . * d . re . - c . im . * d . im ; im = c . im . * d . re . + c . re . * d . im ; } in let add = fun c d -> { re = c . re . + d . re ; im = c . im . + d . im ; } in let open Std in let row = thread_idx_y + block_dim_y * block_idx_y in let co... |
let devid = try int_of_string Sys . argv . ( 1 ) with _ -> 1 |
let cpt = ref 0 |
let tot_time = ref 0 . |
let measure_time f s = let t0 = Unix . gettimeofday ( ) in let a = f ( ) in let t1 = Unix . gettimeofday ( ) in Printf . printf " % s : time % d : % Fs \ n " %! s ! cpt ( t1 . - t0 ) ; tot_time := ! tot_time . + ( t1 . - t0 ) ; incr cpt ; a ; ; |
let mul = fun c d -> { re = c . re . * d . re . - c . im . * d . im ; im = c . im . * d . re . + c . re . * d . im ; } |
let add = fun c d -> { re = c . re . + d . re ; im = c . im . + d . im ; } |
type lol = mutable xim : float ; mutable yre : float ; mutable yim : float ; } |
let cpu_compute xc yc zc ( ) = let sum = ref { re = 0 . ; im = 0 . } in for row = 0 to n - 1 do for col = 0 to n - 1 do sum := { re = 0 . ; im = 0 . } ; for i = 0 to n - 1 do let l = { xre = xc . ( row * n + i ) . re ; xim = xc . ( row * n + i ) . im ; yre = yc . ( i * n + col ) . re ; yim = yc . ( i * n + col ) . im ;... |
let _ = let devs = Devices . init ( ) in let dev = devs . ( devid ) in let block_size = 4 in Printf . printf " Dev is % s \ n " devs . ( devid ) . Devices . general_info . Devices . name ; let x = Vector . create ( Vector . Custom customComplex ) ( n * n ) and y = Vector . create ( Vector . Custom customComplex ) ( n *... |
let input_bigstring ic buf off len = let tmp = Bytes . create len in let res = input ic tmp 0 len in Bigstringaf . blit_from_bytes tmp ~ src_off : 0 buf ~ dst_off : off ~ len : res ; res |
let output_bigstring oc buf off len = let res = Bigstringaf . substring buf ~ off ~ len in output_string oc res |
module N : sig type encoder type dst = [ ` Channel of out_channel | ` Buffer of Buffer . t | ` Manual ] type ret = [ ` Flush of encoder | ` End ] val dst_rem : encoder -> int val dst : encoder -> Zl . bigstring -> int -> int -> encoder val encode : encoder -> ret val encoder : i : Zl . bigstring -> q : De . Queue . t -... |
module M : sig type decoder type src = [ ` Channel of in_channel | ` String of string | ` Manual ] type decode = [ ` Await of decoder | ` Header of int * int * decoder | ` End of decoder | ` Malformed of string ] val src_len : decoder -> int val dst_len : decoder -> int val src_rem : decoder -> int val dst_rem : decode... |
type chIP_sample = [ | ` ChIP_Pho4_noPi | ` ChIP_Pho4_highPi | ` ChIP_Cbf1_noPi | ` ChIP_Mock_noPi ] |
type input_sample = [ | ` Input_Pho4_noPi | ` Input_Pho4_highPi | ` Input_Cbf1_noPi | ` Input_Mock_noPi ] |
type sample = [ | chIP_sample | input_sample ] |
type factor = [ | ` Pho4 | ` Cbf1 | ` Mock ] |
type condition = [ | ` noPi | ` highPi ] |
let factor = function | ` ChIP_Pho4_highPi | ` ChIP_Pho4_noPi -> ` Pho4 | ` ChIP_Cbf1_highPi | ` ChIP_Cbf1_noPi -> ` Cbf1 | ` ChIP_Mock_highPi | ` ChIP_Mock_noPi -> ` Mock |
let condition = function | ` ChIP_Mock_highPi | ` ChIP_Pho4_highPi | ` ChIP_Cbf1_highPi -> ` highPi | ` ChIP_Pho4_noPi | ` ChIP_Cbf1_noPi | ` ChIP_Mock_noPi -> ` noPi |
let control_sample = function | ` ChIP_Cbf1_noPi -> ` Input_Cbf1_noPi | ` ChIP_Pho4_noPi -> ` Input_Pho4_noPi | ` ChIP_Pho4_highPi -> ` Input_Pho4_highPi | ` ChIP_Mock_noPi -> ` Input_Mock_noPi |
let genome = Ucsc_gb . genome_sequence ` sacCer2 |
let genome_2bit = Ucsc_gb . genome_2bit_sequence ` sacCer2 |
let srr_id = function | ` ChIP_Pho4_noPi -> [ " SRR217304 " ; " SRR217305 " ] | ` ChIP_Pho4_highPi -> [ " SRR217306 " ] | ` ChIP_Cbf1_noPi -> [ " SRR217310 " ] | ` ChIP_Mock_noPi -> [ " SRR217312 " ] | ` Input_WT_noPi -> [ " SRR217324 " ] | ` Input_Pho4_noPi -> [ " SRR217319 " ] | ` Input_Pho4_highPi -> [ " SRR217320 "... |
let fastq x = srr_id x |> List1 . of_list_exn |> List1 . map ~ f ( : fun id -> Sra_toolkit . ( fastq_dump fastq_gz ) ( ` id id ) |> Fastq_sample . compressed_se ) |
let ecoli_genome : fasta file = Bistro_unix . wget " ftp :// ftp . ncbi . nlm . nih . gov / genomes / all / GCF / 000 / 005 / 845 / GCF_000005845 . 2_ASM584v2 / GCF_000005845 . 2_ASM584v2_genomic . fna . gz " |> Bistro_unix . gunzip |
let fastq_screen x = Fastq_screen . fastq_screen ( List1 . hd ( fastq x ) ) [ " E_coli " , ecoli_genome ] |
let bowtie_index = Bowtie . bowtie_build genome |
let mapped_reads x = let Cons ( fq , additional_samples ) = fastq x in Bowtie . bowtie ~ v : 1 bowtie_index ~ additional_samples fq |
let mapped_reads_bam x = Samtools . indexed_bam_of_sam ( mapped_reads x ) |
let tf_peaks ? qvalue treatment_sample = let control_sample = control_sample treatment_sample in let treatment = mapped_reads treatment_sample in let control = mapped_reads control_sample in Macs2 . callpeak ~ mfold ( : 1 , 100 ) ? qvalue Macs2 . sam ~ control [ : control ] [ treatment ] |
let centered_tf_peaks ? qvalue ~ radius treatment_sample = let summits = Macs2 . peak_summits ( tf_peaks ? qvalue treatment_sample ) in let chrom_sizes = Ucsc_gb . fetchChromSizes ` sacCer2 in Bedtools . ( slop ~ mode ( ` : both radius ) bed summits chrom_sizes ) |
let best_macs_summits ? qvalue ~ n sample = let summits = Macs2 . peak_summits ( tf_peaks ? qvalue sample ) in let open Bistro . Shell_dsl in Bistro . Workflow . shell ~ descr " : best_macs_summits " [ pipe [ cmd " sort " [ string " - r - g - k 5 " ; dep summits ; ] ; cmd " head " ~ stdout : dest [ opt " - n " int n ; ... |
let best_peak_sequences ( ? nseqs = Int . max_value ) ? qvalue ~ radius treatment_sample = let summits = best_macs_summits ? qvalue ~ n : nseqs treatment_sample in let chrom_sizes = Ucsc_gb . fetchChromSizes ` sacCer2 in let regions = Bedtools . ( slop ~ mode ( ` : both radius ) bed summits chrom_sizes ) in Ucsc_gb . t... |
let meme ( ? nseqs = 500 ) treatment_sample = best_peak_sequences ~ nseqs ~ qvalue : 1e - 10 ~ radius : 50 treatment_sample |> Meme_suite . meme ~ nmotifs : 3 ~ minw : 5 ~ maxw : 8 ~ revcomp : true ~ alphabet ` : dna ~ maxsize : 1_000_000 |
let meme_motifs treatment_sample = Bistro . Workflow . select ( meme treatment_sample ) [ " meme . txt " ] |
let meme_chip treatment_sample = best_peak_sequences ~ qvalue : 1e - 10 ~ radius : 50 treatment_sample |> Meme_suite . meme_chip ~ meme_nmotifs : 3 ~ meme_minw : 5 ~ meme_maxw : 8 |
let chipqc = let samples = List . map all_of_chIP_sample ~ f ( : fun x -> { ChIPQC . id = show_chIP_sample x ; tissue = " yeast " ; factor = show_factor ( factor x ) ; replicate = " 1 " ; bam = mapped_reads_bam x ; peaks = Macs2 . narrow_peaks ( tf_peaks x ) ; } ) in ChIPQC . run samples |
let occdist_vs_peak_score treatment_sample : svg file = let open Bistro . Shell_dsl in let peaks = centered_tf_peaks ~ radius : 500 treatment_sample in let sequences = Ucsc_gb . twoBitToFa genome_2bit ( Bed . keep4 peaks ) in let occ = dep @@ Meme_suite . fimo ( meme_motifs treatment_sample ) sequences in let peaks = d... |
let report = [ % include_script " lib / bio / examples / zhou2011 . md " ] |> Report . Md . to_html |
let repo = Repo . [ item [ " report . html " ] report ; ] |
let run ( ) = Repo . build_main ~ np ~ mem ( ` : GB 4 ) ~ outdir " : res " ~ loggers [ : Console_logger . create ( ) ] repo |
module Dataset = struct type t = [ ` SongD1 ] let to_string = function | ` SongD1 -> " SongD1 " let alignments d = Bistro_unix . wget " https :// ndownloader . figshare . com / files / 9473962 " |> Bistro_unix . tar_xfj |> Fn . flip Workflow . select [ " single - gene_alignments " ; to_string d ] |> Workflow . glob ~ p... |
module Raxml = struct let img = [ docker_image ~ account " : pveber " ~ name " : raxml " ~ tag " : 8 . 2 . 9 " ( ) ] let hpc alignment = Workflow . shell ~ descr " : raxmlhpc " ~ np : 4 [ within_container img ( and_list [ cd tmp ; cmd " raxmlHPC " [ opt " - T " ident np ; string " - p 1 - m GTRGAMMA -- no - bfgs " ; op... |
module Fasttree = struct let img = [ docker_image ~ account " : pveber " ~ name " : fasttree " ~ tag " : 2 . 1 . 10 " ( ) ] let fasttree fa = Workflow . shell ~ descr " : fasttree " [ cmd ~ img " / usr / local / bin / FastTree " ~ stdout : dest [ string " - nt - gtr - gamma - spr 4 - mlacc 2 - slownni " ; dep fa ; ] ] ... |
module IQTree = struct let img = [ docker_image ~ account " : pveber " ~ name " : iqtree " ~ tag " : 1 . 4 . 2 " ( ) ] let iqtree fa = let tmp_ali_fn = " data . fa " in let tmp_ali = tmp // tmp_ali_fn in Workflow . shell ~ descr " : iqtree " [ within_container img ( and_list [ cmd " ln " [ string " - s " ; dep fa ; tmp... |
module PhyML = struct let img = [ docker_image ~ account " : pveber " ~ name " : phyml " ~ tag " : 3 . 3 . 20180129 " ( ) ] let phyml alignment = let tmp_ali_fn = " alignment " in let tmp_ali = tmp // tmp_ali_fn in Workflow . shell ~ descr " : phyml " [ within_container img ( and_list [ cd tmp ; cmd " ln " [ string " -... |
module Goalign = struct let img = [ docker_image ~ account " : pveber " ~ name " : goalign " ~ tag " : 0 . 2 . 9 " ( ) ] let phylip_of_fasta fa = Workflow . shell ~ descr " : goalign . reformat " [ cmd " goalign " ~ img [ string " reformat phylip " ; opt " - i " dep fa ; opt " - o " ident dest ; ] ] end |
module Gotree = struct let img = [ docker_image ~ account " : pveber " ~ name " : gotree " ~ tag " : 0 . 2 . 10 " ( ) ] let compare_trees ~ input ~ reference = Workflow . shell ~ descr " : gotree . compare " [ cmd " / usr / local / bin / gotree " ~ stdout : dest ~ img [ string " compare trees -- binary " ; opt " - i " ... |
let tree_inference meth fa = match meth with | ` Fasttree -> Fasttree . fasttree fa | ` RAXML -> Raxml . hpc fa | ` IQTree -> IQTree . iqtree fa | ` PhyML -> PhyML . phyml ( Goalign . phylip_of_fasta fa ) |
let inferred_trees d meth = Workflow . spawn ( Dataset . alignments d ) ~ f ( : tree_inference meth ) |
let comparisons d meth = Workflow . spawn2 ( inferred_trees d meth ) ( Dataset . best_trees d ) ~ f ( : fun input reference -> Gotree . compare_trees ~ input ~ reference ) List . map [ % eval Workflow . ( spawn results ~ f : eval_path ) ] ~ f ( : fun fn -> In_channel . read_lines fn |> Fn . flip List . nth_exn 1 ) |> O... |
let repo = Repo . [ item [ " concatenated_comps_fasttree " ] ( concat ( comparisons ` SongD1 ` Fasttree ) ) ; items [ " comps_fasttree " ] ~ prefix " : tree " ( comparisons ` SongD1 ` Fasttree ) ; ] |
let ( ) = Repo . build_main ~ loggers [ : Console_logger . create ( ) ] ~ np : 4 ~ mem ( ` : GB 4 ) ~ outdir " : res " repo |
type t = { num : int ; source : string ; } { arrnm : string ; index : t ; } |
let compare id1 id2 = compare id1 . num id2 . num |
let name id = id . source ^ " _ " ^ ( string_of_int id . num ) |
let source id = id . source |
let num = ref 0 |
let fresh s = num := ! num + 1 ; { num = ! num ; source = s } |
let fprint_t ff id = Format . fprintf ff " % s " ( name id ) |
module M = struct type t = t_alias let compare = compare let fprint = fprint_t end |
module Env = struct include ( Map . Make ( M ) ) let singleton i tentry = add i tentry empty let fprint_t fprint_v ff s = Format . fprintf ff " [ @< hov { >@ " ; iter ( fun k v -> Format . fprintf ff " [ @% a : % a ] " @ M . fprint k fprint_v v ) s ; Format . fprintf ff " } ] " @ let fprint_3ident ff s = let fprint_v f... |
module S = struct include ( Set . Make ( M ) ) let fprint_t ff s = Format . fprintf ff " [ @< hov { >@ " ; iter ( fun e -> Format . fprintf ff " % a @ " M . fprint e ) s ; Format . fprintf ff " } ] " @ let fresh s ss = let add_fresh id m = Env . add id ( fresh s ) m in fold add_fresh ss Env . empty let domain acc env =... |
let bpw = dbits / 8 |
let asft = Int . ceil_log2 bpw |
let reg_spec = Reg_spec . create ( ) ~ clock ~ clear |
module Memory = struct module I = struct type ' a t = { memory_data_in : ' a [ @ bits dbits ] ; memory_ready : ' a } [ @@ deriving sexp_of , hardcaml ] end module O = struct type ' a t = { memory_request : ' a ; memory_read_write : ' a ; memory_address : ' a [ @ bits dbits ] ; memory_data_out : ' a [ @ bits dbits ] } [... |
let memory_if ~ e ~ stack_o ~ bc_o ~ mem_o ~ ext_i = let open Memory . I in let open Memory . O in let open Always in let ( -- ) s n = s -- ( " memory_if_ " ^ n ) in let module States = struct type t = | Request | Ready [ @@ deriving enumerate , compare , sexp_of ] end in let { State_machine . is ; switch = sm ; set_ne... |
module Decode = struct type ' a t = { acc : ' a ; acc_op : ' a ; push : ' a ; pushacc : ' a ; push_op : ' a ; pop : ' a ; assign : ' a ; envacc : ' a ; envacc_op : ' a ; pushenvacc : ' a ; pushenvacc_op : ' a ; push_retaddr : ' a ; apply : ' a ; apply_op : ' a ; appterm : ' a ; appterm_op : ' a ; closure : ' a ; closur... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.