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
# LICENSE: Public Domain
import requests
def panther(species, genelist, ontology='biological_process',
correction='fdr', format='html', resource='PANTHER', timeout=15):
"""Post a over/under-representation test request to PANTHER."""
# NOTE: The species parameter seems to be different from conventional
@bicycle1885
bicycle1885 / setup-system.jl
Last active January 30, 2020 04:29
Set up Julia packages for system
# Install packages in system
# ==========================
# License: Public Domain
# Usage: julia setup-system.jl package1 package2 ...
# Also, don't forget to add '@system' to your LOAD_PATH like this way:
# $ env JULIA_LOAD_PATH='@:@v#.#:@system:@stdlib' julia
using Pkg
@bicycle1885
bicycle1885 / load_alevin.jl
Created January 14, 2020 08:53
Utilities to read output files of Alevin.
# Utilities to read output files of Alevin.
# -----------------------------------------
#
# Copyright 2020 Kenta Sato
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@bicycle1885
bicycle1885 / noptime.cpp
Last active December 16, 2019 02:41
Measure throughput of nops' sequence using Xbyak
#include <iostream>
#include <chrono>
#include <cmath>
#include <xbyak/xbyak.h>
const size_t INIT_CODE_BUF_SIZE = 1 >> 10;
struct Code : Xbyak::CodeGenerator
{
Code(size_t n) : CodeGenerator(INIT_CODE_BUF_SIZE, Xbyak::AutoGrow)
using LinearAlgebra: qr
function equilibrium(Q::AbstractMatrix)
@assert size(Q, 1) == size(Q, 2)
R = qr(Q').R
n = size(Q, 1)
v = zeros(eltype(Q), n)
v[end] = 1
for i in n-1:-1:1
s = zero(eltype(Q))
@bicycle1885
bicycle1885 / par.jl
Created June 5, 2019 00:31
Parallel execution
macro par(expr)
thunk = esc(:(()->($expr)))
quote
local task = Task($thunk)
task.sticky = false
schedule(task)
task
end
end
@bicycle1885
bicycle1885 / array1.jl
Created June 4, 2019 03:30
Constant folding
const a = (1, 2, 3, 4)
function func(b)
sum = 0
for i in 1:4
sum += a[i] * b[i]
end
return sum
end
@bicycle1885
bicycle1885 / safenan.py
Created February 17, 2019 13:08
safenan.py
import types
class SafeNaN(types.ModuleType):
def __setattr__(self, attr, value):
if attr == "nan":
raise RuntimeError("cannot reassign 'nan'")
super().__setattr__(attr, value)
import sys
import numpy
@bicycle1885
bicycle1885 / callstack.jl
Created February 13, 2019 02:14
A macro to show the callstack inside a function call.
module CallStack
export @callstack
using Cassette
mutable struct CallState
depth::Int
end
@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>