Skip to content

Instantly share code, notes, and snippets.

View taoliu's full-sized avatar
🌎
Working from the earth

Tao Liu (τν) taoliu

🌎
Working from the earth
  • Roswell Park Comprehensive Cancer Center
  • Buffalo NY
View GitHub Profile
@taoliu
taoliu / pyprofile
Created June 19, 2011 20:06 — forked from anonymous/pyprofile
pyrprofile: profile Python script
#!/usr/bin/env bash
## pyprofile: profile Python script
## $Revision$
## Copyright 2011 Michael M. Hoffman <mmh1@uw.edu>
## Modified by Tao Liu: Correctly get the command name.
set -o nounset
set -o pipefail
@taoliu
taoliu / prockmon
Created January 6, 2012 21:15
Monitor user time and memory usage of a process
#!/bin/bash
if [[ $# < 2 ]];then
echo 'need two parameters: $0 <interval> <pid>'
exit 1;
fi
INTERVAL=$1
PID=$2
@taoliu
taoliu / wrapToSGE
Created January 6, 2012 21:20
SGE script wrapper
#!/usr/bin/env python
import subprocess
import sys
import os
import time
#time_stamp=time.strftime("%y-%m-%d_%H-%M-%S")
time_stamp=str(time.time())
@taoliu
taoliu / ma2cWigToBedGraph.py
Created March 8, 2012 17:20
ma2cWigToBedGraph fix MA2C wig output
#!/usr/bin/env python
# Time-stamp: <2012-01-10 17:21:24 Tao Liu>
# in the wiggle file from MA2C, the 1st column -- position is actually
# the center of each probe. Some probes may overlap. In order to
# convert them to appropriate bigwig, I need to create bedGraph file
# with above two problems fixed.
import os
import sys
@taoliu
taoliu / gist:2038683
Created March 14, 2012 19:01
Monte Carlo for Pi
python -c 'import math;import random;n=1000000L;print float( n - reduce( lambda x, y: x//1+y//1, map( lambda x: math.hypot( random.random(), random.random() ), range(n) ) ) )/n*4'
@taoliu
taoliu / convertModENCODERnaSeqToBW.sh
Created March 28, 2012 20:09
Convert modENCODE PET RNA-seq SAM to pileup bigWig
#!/bin/bash
if [ $# -lt 1 ]; then
echo `basename $0` "<PET RNAseq SAM filename>"
exit
fi
F=$1
# chromosome length file
@taoliu
taoliu / ediff.pl
Created April 6, 2012 05:20
find unique or common lines between two files
#!/usr/bin/perl -w
# Time-stamp: <2004-04-02 14:37:41 Tao Liu>
use strict;
if (@ARGV>0 and $ARGV[0] eq "-h") {
print "ediff : compute two sets with \'or diff and\'. \nUsage:\tediff [-h] : help, this info\n\tediff A or B : union of two sets\n\tediff A diff B : elements in
A but not in B\n\tediff A and B : intersection of two sets\n";
exit;
}
@taoliu
taoliu / pyrprofile_stat
Created April 12, 2012 16:14
print stats of Python profile
#!/usr/bin/env python
# Time-stamp: <2012-04-12 12:12:53 Tao Liu>
import sys
import pstats
# ------------------------------------
# Main function
# ------------------------------------
def main():
if len(sys.argv) < 3:
@taoliu
taoliu / bdg2bw
Last active March 22, 2024 21:00
bedGraph to bigWig
#!/bin/bash
# check commands: slopBed, bedGraphToBigWig and bedClip
which bedtools &>/dev/null || { echo "bedtools not found! Download bedTools: <http://code.google.com/p/bedtools/>"; exit 1; }
which bedGraphToBigWig &>/dev/null || { echo "bedGraphToBigWig not found! Download: <http://hgdownload.cse.ucsc.edu/admin/exe/>"; exit 1; }
which bedClip &>/dev/null || { echo "bedClip not found! Download: <http://hgdownload.cse.ucsc.edu/admin/exe/>"; exit 1; }
# end of checking
@taoliu
taoliu / prockreport
Last active October 3, 2015 18:17
Check total CPU time and maximum memory usage of a process.
#!/bin/bash
# modified from prockmon
unset LD_LIBRARY_PATH
if [[ $# < 2 ]];then
echo 'Check total CPU time and maximum memory usage of a process.'
echo 'need two parameters: $0 <interval> <pid>'
exit 1;
fi