Skip to content

Instantly share code, notes, and snippets.

@hliang
hliang / convert.py
Last active December 16, 2020 22:00
anki cloze卡片生成器-中文生字-拼音-词语
filepath_zi = "grd3_b_cn_zi"
filepath_pinyin = "grd3_b_cn_pinyin"
filepath_ciyu = "grd3_b_cn_ciyu"
lst_zi = []
lst_pinyin = []
lst_ciyu = []
with open(filepath_zi) as f:
lst_zi = f.readlines()
@hliang
hliang / gnomad_graphQL
Last active September 18, 2023 21:10
gnomad API graphQL query
# API URL: https://gnomad.broadinstitute.org/api/
# Document: https://github.com/macarthur-lab/gnomadjs/blob/master/projects/gnomad-api/README.md
## gene ######################
{
gene(gene_name: "NLRP3") {
symbol
name
full_gene_name
hgnc_id
@hliang
hliang / abp_filter.txt
Last active November 25, 2019 17:39
Customize Adblock Plus filters
v2ex.com##img[class="avatar"]
import { connect } form 'react-redux';
const SAVE_WEATHER = "SAVE_WEATHER";
export default function saveWeather(response) {
return {
type: SAVE_WEATHER,
data: response
}
}
@hliang
hliang / collectl_parsing.R
Last active June 6, 2018 02:12
misc R scripts
library(zoo)
# library("lubridate")
collectl_fn = list.files("D:/tmp/abruijn/", patter=".*.p.txt", full.names = TRUE); collectl_fn
zcolall = list()
slurmout_all = list()
for (i in seq_along(collectl_fn)) {
jobid = gsub(".*mon_(\\d+)-(cn\\d+).*.p.txt", "\\1", collectl_fn[i])
nodeid = gsub(".*mon_(\\d+)-(cn\\d+).*.p.txt", "\\2", collectl_fn[i])
@hliang
hliang / lyricSim.Rmd
Created June 6, 2018 01:54
NLP toys: analysis of song lyrics
---
title: "NLP toys"
author: "hliang"
date: "8/24/2016"
output: html_document
---
Use NLP tools to analyze song lyrics.
load packages required:
@hliang
hliang / ts.R
Created June 6, 2018 01:52
time series analysis - demo script
# king death
kings <- scan("http://robjhyndman.com/tsdldata/misc/kings.dat",skip=3)
kings
# store the data in a time series object
kingstimeseries <- ts(kings)
kingstimeseries
# the number of births per month in New York city, from January 1946 to December 1959 (originally collected by Newton)
births <- scan("http://robjhyndman.com/tsdldata/data/nybirths.dat")
birthstimeseries <- ts(births, frequency=12, start=c(1946,1))
@hliang
hliang / build-gcc.sh
Last active January 19, 2018 06:55 — forked from jeetsukumaran/build-gcc.sh
Build and Install GCC Suite from Scratch
#! /bin/bash
GCC_VERSION="6.4.0"
WORKDIR="$HOME/gcc"
INSTALLDIR="/BIGDATA/app/gcc/6.4.0"
# get the source code
cd $WORKDIR
wget http://www.netgull.com/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz
tar -xf gcc-${GCC_VERSION}.tar.xz
#! /usr/bin/env python
'''
==================
ucsc_snapshots
==================
retrieve pictures from the UCSC Genome Browser based on coordinates
specified from BED3+ file and a session ID (hgsid).
# Assumes you've already run coverageBed -hist, and grep'd '^all'. E.g. something like:
# find *.bam | parallel 'bedtools -abam {} -b capture.bed -hist | grep ^all > {}.all.txt'
setwd("./qc/")
# Get a list of the bedtools output files you'd like to read in
bedcov_dir = "./bedcov_cds_canol/"
print(files <- list.files(path=bedcov_dir, recursive=TRUE, pattern="samp.*all.txt$", full.names=TRUE))
# This regular expression leaves me with "samp01", "samp02", and "samp03" in the legend.