This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Extends Wang, et al, 2007 Fig 1 (pmid 17600086) to show detection threshold at higher coverage | |
## | |
library(lattice) | |
## mu = error rate | |
mu_hp <- 0.0044 | |
mu_nhp <- 0.0007 | |
thresh <- function(N, mu, p=0.001){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Use mutual information to define a value separating two | |
## distributions. | |
entropy <- function(x,y){ | |
## shannon entropy of x or joint entropy of x and y | |
if(missing(y)){ | |
freqs <- table(x)/length(x) | |
}else{ | |
stopifnot(length(x) == length(y)) | |
freqs <- table(paste(x,y))/length(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; gist.el | |
;; https://github.com/defunkt/gist.el | |
;; added as a submodule: | |
;; % git submodule add https://github.com/defunkt/gist.el.git | |
;; now, to clone .emacs.d elsewhere: | |
;; % git clone [email protected]:nhoffman/.emacs.d.git | |
;; % cd .emacs.d | |
;; % git submodule init && git submodule update | |
(condition-case nil | |
(require 'gist "~/.emacs.d/gist.el/gist.el") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
from openpyxl.reader.excel import load_workbook | |
def getrows(sheet, cols): | |
headers = [c.value for c in sheet.rows[0] if c.value] | |
for row in sheet.rows[1:]: | |
d = dict(zip(headers, [c.value for c in row])) | |
yield dict((k2, d[k1]) for k1,k2 in cols) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
# CREATE block and create them in separate commands _after_ all the INSERTs. | |
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
# The mysqldump file is traversed only once. | |
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gist () { | |
gid=${1:-2968328} | |
curl -s https://api.github.com/gists/$gid | python3 -c 'import json, sys; print(next(iter(json.load(sys.stdin)["files"].items()))[1]["content"])' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""A simple python script template. | |
""" | |
import os | |
import sys | |
import argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################### | |
## Set prompt, iTerm2 window and tabs ## | |
######################################### | |
# Color constants used in the prompt | |
BLACK="%{[0m%}" | |
BOLD_BLACK="%{[1;30m%}" | |
RED="%{[0;31m%}" | |
BOLD_RED="%{[1;31m%}" | |
GREEN="%{[0;32m%}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# try me out: | |
# two processors | |
# $ echo {1..9} | xargs -n1 -P2 ./ps.sh | |
# four processors | |
# $ echo {1..9} | xargs -n1 -P4 ./ps.sh | |
# sleeptime set to a random integer between 2 and 5 | |
sleeptime=$(shuf -i 2-5 -n 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import re | |
import sys | |
rexp = re.compile(r'|'.join([ | |
r'\bactinomycete\b', | |
r'\bcrenarchaeote\b', | |
r'\bculture\b', | |
r'\bchimeric\b', |
OlderNewer