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 / vimrc
Last active July 22, 2020 02:37
My vimrc
" General
syntax enable
set nocompatible
set noswapfile
if executable("rg")
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
autocmd QuickFixCmdPost * copen
nnoremap <silent> <C-n> :cn<CR>
@bicycle1885
bicycle1885 / rsvd.jl
Created May 20, 2018 15:14
Randomized SVD
# Randomized SVD
# --------------
#
# H. Li, G. C. Linderman, et al. "Algorithm 971: An Implementation of a
# Randomized Algorithm for Principal Component Analysis", ACM Transactions on
# Mathematical Software (TOMS), 2017
# DOI: https://doi.org/10.1145/3004053
#
# N. Halko, P. G. Martinsson, and J. A. Tropp, "Finding Structure with
# Randomness: Probabilistic Algorithms for Constructing Approximate Matrix
@bicycle1885
bicycle1885 / gencode.jl
Created December 3, 2017 06:13
Generated code from numbers.jl
quote
if p > p_end
@goto exit
end
##667 = (Automa.SizedMemory)(data)
if cs == 1
@goto state_case_1
else
if cs == 2
@goto state_case_2
@bicycle1885
bicycle1885 / base64.jl
Created October 21, 2017 13:41
Base64 Encoder
# License: MIT
module Base64
export
Base64EncodePipe,
base64encode
# Data buffer for pipes.
mutable struct Buffer
@bicycle1885
bicycle1885 / structure.jl
Created June 24, 2017 21:59
Biomolecular structure
import NamedTuples: NamedTuples, @NT
# Atom
# ----
# NOTE: This must be synchronized with `AtomCoords`.
struct Atom
id::Int32
x::Float32
y::Float32
using CodecZlib
using BioSequences
function readfasta(filepath)
open(GzipDecompressionStream, filepath) do stream
reader = FASTA.Reader(stream)
for record in reader
id = FASTA.identifier(record)
seq = FASTA.sequence(record)
@show id, seq
@bicycle1885
bicycle1885 / kmerminhash.jl
Created March 16, 2017 06:21
K-mer MinHash
using Bio.Seq
import DataStructures: SortedSet
immutable MinHashSketch
sketch::Vector{UInt64}
kmersize::Int
function MinHashSketch(sketch::Vector, kmersize::Int)
length(sketch) > 0 || error("Sketch cannot be empty")
kmersize > 0 || error("Kmersize must be greater than 0")
import Automa
import Automa.RegExp: @re_str
import BufferedStreams
import BufferedStreams: BufferedInputStream
import Bio
const fastq_machine = (function ()
re = Automa.RegExp
cat = re.cat
rep = re.rep
@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
@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)),