Skip to content

Instantly share code, notes, and snippets.

View brentp's full-sized avatar

Brent Pedersen brentp

View GitHub Profile
sudo apt-get install libtool
git clone git://dnaa.git.sourceforge.net/gitroot/dnaa/dnaa dnaa-git
cd dnaa-git
# bfast required. see above gist
cp -r ../bfast-git ./bfast
# samtools require. see above gist.
cp -r ../samtools-svn/ ./samtools
sh autogen.sh && ./configure && make && sudo make install
@aurora
aurora / class.lua
Created November 11, 2010 10:51
class implementation for lua
function clone(object)
local dict = {}
local function clone(object)
if (type(object) ~= "table") then
return object
elseif (dict[object]) then
return dict[object]
end
@brentp
brentp / script-skeleton.py
Created March 9, 2011 21:11
skeleton python script
"""
%prog [options] files
"""
import optparse
import sys
import gzip
from itertools import izip
def nopen(f, mode="rb"):
@brentp
brentp / ucsc.simple.sh
Created May 23, 2011 17:50
mirror essential tables from UCSC to a local mysql database. (change $ORG to mm8/hg18/dm3 or your organism of choice.)
ORG=hg19
USER=brentp
# from: http://nsaunders.wordpress.com/2011/05/18/how-to-create-a-partial-ucsc-genome-mysql-database/
# create database
mysql -u $USER -e "CREATE DATABASE $ORG";
mkdir -p ucsc-data/$ORG
cd ucsc-data/$ORG
for table in knownGene refGene ensGene kgXref chromInfo cpgIslandExt cytoBand
@brentp
brentp / gist:1049884
Created June 27, 2011 21:28
incantation to build vim in such a way that pyflakes works
# NOTE the /Modules/
./configure --prefix=/vol1/home/brentp/installed/ \
--with-python-config-dir=/vol1/home/brentp/src/python/Python-2.7.2/Modules/ \
--enable-pythoninterp=yes --with-features=huge
@ogrisel
ogrisel / emi_out.txt
Created October 23, 2011 09:05
Expected Mutual Information profiling
Line # Hits Time Per Hit % Time Line Contents
==============================================================
627 def expected_mutual_information(contingency, n_samples):
628 """Calculate the expected mutual information for two labelings."""
629 25 82 3.3 0.0 R, C = contingency.shape
630 25 53 2.1 0.0 N = n_samples
631 25 1059 42.4 0.0 a = np.sum(contingency, axis=1, dtype='int')
632 25 932 37.3 0.0 b = np.sum(contingency, axis=0, dtype='int')
633 25 58 2.3 0.0 emi = 0
634 1839 4005 2.2 0.0 for i in range(R):
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@brantfaircloth
brantfaircloth / cool_argparse_stuff.py
Created December 7, 2011 16:47
Some cool argparse stuff
class FullPaths(argparse.Action):
"""Expand user- and relative-paths"""
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, os.path.abspath(os.path.expanduser(values)))
def is_dir(dirname):
"""Checks if a path is an actual directory"""
if not os.path.isdir(dirname):
msg = "{0} is not a directory".format(dirname)
raise argparse.ArgumentTypeError(msg)
@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())
@drio
drio / README.md
Created January 22, 2012 14:53
Playing with pthreads

What's this?

I was/am in the process of adding multithreading capabilities to a tool I am working on (more on that soon). The tool is written in C/C++. My first option was using POSIX threads (pthreads) before going into higher level options like boost.

I first read this