Skip to content

Instantly share code, notes, and snippets.

View bicycle1885's full-sized avatar

Kenta Sato bicycle1885

  • Karolinska Institute
  • Stockholm, Sweden
View GitHub Profile
using Bio.Seq
# Utils for Benchmark
# -------------------
function random_seq(n, nts, probs)
cumprobs = cumsum(probs)
x = Array(Char, n)
for i in 1:n
@bicycle1885
bicycle1885 / benchhash.jl
Created March 11, 2016 10:38
MurmurHash3
using Bio.Seq
let
str = "ACGT"^10000
seq = DNASequence(str)
seq′ = DNASequence("AAA" * str)[4:end]
@assert hash(seq) === hash(seq′)
println("ASCIIString")
hash(str)
@bicycle1885
bicycle1885 / re.jl
Last active April 3, 2016 05:02
Toy Regular Expression Engine Written in Julia
# Toy Regular Expression Engine Written in Julia
# ==============================================
# Example
# -------
#
# julia> include("re.jl")
# run (generic function with 1 method)
#
# julia> ast = parse("foo*|ba*r")
type PhyNode{I,T<:Tuple}
id::I
metadata::T
children::Vector{PhyNode{I,T}}
parent::PhyNode{I,T}
# root
function PhyNode(id, metadata, children)
node = new(id, metadata, children)
node.parent = node
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bicycle1885
bicycle1885 / RNA-Seq Coverage.ipynb
Created September 9, 2016 06:46
Visualize RNA-Seq coverage with Bio.jl and PlotlyJS.jl
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bicycle1885
bicycle1885 / nclist.jl
Created September 14, 2016 04:23
Nested Containment List
# Nested Containment List
# =======================
#
# Alekseyenko, A. V., & Lee, C. J. (2007). "Nested Containment List (NCList): A
# new algorithm for accelerating interval query of genome alignment and interval
# databases." Bioinformatics, 23(11), 1386–1393.
# doi:10.1093/bioinformatics/btl647
# An interval type (inclusive).
immutable Interval{T}
@bicycle1885
bicycle1885 / HMC and NUTS Samplers with Dual Averaging.ipynb
Last active September 30, 2016 11:31
HMC and NUTS Samplers with Dual Averaging
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bicycle1885
bicycle1885 / newick.jl
Last active January 10, 2017 19:14
Simple NEWICK tokenizer using Automa.jl
using Automa
using Automa.RegExp
const re = Automa.RegExp
length = re"[0-9]+\.[0-9]+"
name = re.rep1(re"[!-~]" \ re"[,:;()[\]]")
spaces = re" +"
const newick = compile(
re"\(" => :(emit(:lparen)),
@bicycle1885
bicycle1885 / vcf.jl
Created January 16, 2017 05:32
[WIP] VCF parser
import Automa
import Automa.RegExp: @re_str
const re = Automa.RegExp
# VCF v4.2
const vcf_machine = (function ()
delim(x, sep) = re.opt(re.cat(x, re.rep(re.cat(sep, x))))
nl = re"\n"
newline = re"\r?" * nl