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
@bicycle1885
bicycle1885 / nelder_mead.jl
Created December 19, 2015 02:59
JuliaTokyo#5 Nelder-Meadアルゴリズム
"""
Nelder-Mead algorithm
nelder_mead(f, x0, n)
Arguments
---------
* `f`: target function to optimize
* `x0`: initial value
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 / approx_search.jl
Created March 30, 2016 20:04
Myers' Approximate String Search Algorithm
# Approximate String Search
# =========================
#
# Myers, Gene. "A fast bit-vector algorithm for approximate string matching
# based on dynamic programming." Journal of the ACM (JACM) 46.3 (1999): 395-415.
#
"""
approx_search(text, query, k)
@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
Loading
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
Loading
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.