text stringlengths 12 786k |
|---|
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 ) ... |
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 ... |
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 :... |
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 ... |
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_P... |
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 ; ] ; cm... |
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 sum... |
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 ) ; } ) i... |
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 ) s... |
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_alignm... |
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 " ... |
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 " - ... |
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 ... |
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_contai... |
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 " ... |
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 : de... |
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... |
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 ... |
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... |
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 d... |
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 { ... |
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 ; app... |
module I = struct type ' a t = { start : ' a ; bytecode_start_address : ' a [ @ bits dbits ] ; atom_table_address : ' a [ @ bits dbits ] ; globals_start_address : ' a [ @ bits dbits ] ; heap_start_address : ' a [ @ bits dbits ] ; stack_start_address : ' a [ @ bit... |
module O = struct type ' a t = { state : ' a ; pc : ' a [ @ bits dbits ] ; sp : ' a [ @ bits dbits ] ; accu : ' a [ @ bits dbits ] ; env : ' a [ @ bits dbits ] ; extra_args : ' a [ @ bits dbits ] ; instruction : ' a [ @ bits 8 ] ; error : ' a ; ... |
type decinstr = { lte : t ; gte : t ; eq : t ; range : t } |
let decode instr = let constins i = consti ~ width : 8 ( Opcode . to_int i ) in let ins = Opcode . all in let sel = let sel = Array . of_list @@ List . map ins ~ f ( : fun i -> let i = constins i in { lte = instr <=: i ; gte = instr >=: i ; eq = instr ==: i ; range = instr -: ... |
let alu_int op a b = let a , b , z = msbs a , msbs b , zero ( dbits - 1 ) in mux op [ z ; a +: b ; a -: b ; ( a *+ b ) . [ : dbits - 2 , 0 ] ; z ; z ; a &: b ; a |: b ; a ^: b ; log_shift sll a b . [ : 5 , 0 ] ; log_shift srl a b . [ : 5 , 0... |
let comp_int op a b = let a , b = msbs a , msbs b in zero ( dbits - 2 ) @: mux op [ a ==: b ; a <>: b ; a <+ b ; a <=+ b ; a >+ b ; a >=+ b ] @: vdd ; ; |
let ucomp_int op a b = let a , b = msbs a , msbs b in zero ( dbits - 2 ) @: mux op [ a <: b ; a >: b ] @: vdd ; ; |
module States = struct type t = [ ` init | ` fetch | ` decode | ` acc_set | ` acc_offset | ` pushacc | ` envacc | ` pop | ` constint | ` branch | ` c_call0 | ` c_call1 | ` c_call2 | ` c_call3 | ` alu | ` comp | ` ucomp | ` bcomp | ` bucomp | ` bcomp_setpc ... |
let state_str = List . map States . all ~ f ( : fun s -> Sexp . to_string_hum ( States . sexp_of_t s ) ) |
module M = Mlvalues . Make ( struct include Signal let ( /: ) _ _ = failwith " " /: let ( %: ) _ _ = failwith " " %: let const = consti ~ width : dbits let zero = const 0 let one = const 1 let log_shift f a b = if Signal . is_const b then f a ( to_int b ) else log_shift f a ... |
let zinc i = let open Memory . O in let open Memory . I in let open Decode in let open I in let open O in let open Always in let e = vdd in let ures x = uresize x dbits in let sres x = sresize x dbits in let val_int x = uresize x ( dbits - 1 ) @: vdd in let val_unit = val_int ( zero dbits ) in let ... |
module Z = Cyclesim . With_interface ( Zinc . I ) ( Zinc . O ) |
type cfg = { waves : bool ; instr_trace : bool ; state_trace : bool ; mem_trace : bool } |
let make cfg exe = let mem_size_words = 1024 * 1024 in let _show_instr = let ins = Base . List . map Opcode . all ~ f : Opcode . to_string |> Base . Array . of_list in fun x -> let i = Bits . to_int x in try ins . ( i ) with | _ -> " " in let sim = Z . create Zinc . zinc in ... |
let read2 ic = let lb = read1 ic in let hb = read1 ic in lb lor ( hb lsl 8 ) 8 |
let read4 ic = let lw = read2 ic in let hw = read2 ic in Int32 . logor ( Int32 . of_int lw ) lw ( Int32 . shift_left ( Int32 . of_int hw ) hw 16 ) 16 |
let read4_int ic = let lw = read2 ic in let hw = read2 ic in if hw > max_int lsr 16 then raise ( Error ( Error " " , " " , " 32 - bit data too large ) ) " ; lw lor ( hw lsl 16 ) 16 |
let readstring ic n = let s = Bytes . create n in really_input ic s 0 n ; Bytes . to_string s |
let write2 oc n = write1 oc n ; write1 oc ( n lsr 8 ) 8 |
let write4 oc n = write2 oc ( Int32 . to_int n ) n ; write2 oc ( Int32 . to_int ( Int32 . shift_right_logical n 16 ) 16 ) 16 |
let write4_int oc n = write2 oc n ; write2 oc ( n lsr 16 ) 16 |
let writestring oc s = output oc ( Bytes . of_string s ) s 0 ( String . length s ) s |
let writebytes oc s = output oc s 0 ( Bytes . length s ) s |
type compression_method = Stored | Deflated |
type entry = { filename : string ; extra : string ; comment : string ; methd : compression_method ; mtime : float ; crc : int32 ; uncompressed_size : int ; compressed_size : int ; is_directory : bool ; file_offset : int64 } |
type in_file = { if_filename : string ; if_channel : Pervasives . in_channel ; if_entries : entry list ; if_directory : ( string , entry ) entry Hashtbl . t ; if_comment : string } |
let entries ifile = ifile . if_entries |
let comment ifile = ifile . if_comment |
type out_file = { of_filename : string ; of_channel : Pervasives . out_channel ; mutable of_entries : entry list ; of_comment : string } |
let strrstr pattern buf ofs len = let rec search i j = if i < ofs then - 1 else if j >= String . length pattern then i else if pattern [ . j ] j = buf [ . i + j ] j then search i ( j + 1 ) 1 else search ( i - 1 ) 1 0 in search ( ofs + len - String . length pattern ) pattern 0 |
let filename_is_directory name = String . length name > 0 && name [ . String . length name - 1 ] 1 = ' / ' |
let unixtime_of_dostime time date = fst ( fstUnix . mktime { Unix . tm_sec = ( time lsl 1 ) 1 land 0x3e ; Unix . tm_min = ( time lsr 5 ) 5 land 0x3f ; Unix . tm_hour = ( time lsr 11 ) 11 land 0x1f ; Unix . tm_mday = date land 0x1f ; Unix . tm_mon = ( ( date lsr 5 ) ... |
let dostime_of_unixtime t = let tm = Unix . localtime t in ( tm . Unix . tm_sec lsr 1 + ( tm . Unix . tm_min lsl 5 ) 5 + ( tm . Unix . tm_hour lsl 11 ) 11 , tm . Unix . tm_mday + ( tm . Unix . tm_mon + 1 ) 1 lsl 5 + ( tm . Unix . tm_year - 80 ) 80 lsl 9 ) 9... |
let read_ecd filename ic = let buf = Bytes . create 256 in let filelen = in_channel_length ic in let rec find_ecd pos len = if pos <= 0 || filelen - pos >= 0x10000 then raise ( Error ( Errorfilename , " " , " end of central directory not found , not a ZIP file ) ) " ; let toread = min pos... |
let read_cd filename ic cd_entries cd_offset cd_bound = let cd_bound = Int64 . of_int32 cd_bound in try LargeFile . seek_in ic ( Int64 . of_int32 cd_offset ) cd_offset ; let e = ref [ ] in let entrycnt = ref 0 in while ( LargeFile . pos_in ic < cd_bound ) cd_bound do incr entrycnt ; let magi... |
let open_in filename = let ic = Pervasives . open_in_bin filename in let ( cd_entries , cd_size , cd_offset , cd_comment ) cd_comment = read_ecd filename ic in let entries = read_cd filename ic cd_entries cd_offset ( Int32 . add cd_offset cd_size ) cd_size in let dir = Hashtbl . create ( cd_ent... |
let close_in ifile = Pervasives . close_in ifile . if_channel |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.