-
Thou shall use version control.
-
Thou shall comment thy code.
-
Thou shall use existing libraries whenever possible.
-
Thou shall try to unit test.
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
# hmmerfix.py - fix terrible output format (fixed width) of HMMER | |
# We make a simple assumption about the data: any non-delimiter spaces | |
# are in the last column. Under this assumption, we build a regular | |
# expression programmatically with strict types. Strict typing and the | |
# number of grouped elements ensure some safety. | |
import re | |
import sys | |
from collections import OrderedDict |
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
/* | |
(c) Vince Buffalo, 2012; License: GPL. | |
I compile this on my system (OS X with samtools installed via Homebrew) with: | |
clang -g -lz -L/usr/local/Cellar/samtools/0.1.18/lib/ -lbam -I/usr/local/Cellar/samtools/0.1.18/include/bam/ -o mapqcov mapqcov.c | |
But you'll likely need to compile differently for you libraries. This code works and is consistent with the slower results from mpileup. This is just a standalone beta; it will likely be incorporated into something else. | |
*/ | |
#include <stdio.h> |
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
tail -f your_mapping.sam | bioawk -csam 'BEGIN{total=0;mapped=0} {total = total + 1; mapped = mapped + !and($flag, 4); if (total % 100 == 0) { printf "\tmapping rate: %f\r",mapped/total }}' |
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
""" | |
Generate a IUPAC nucleotide table. The order is a modification of Heng | |
Li's. I have added '-' to mean gap. X means non-IUPAC character and | |
can be a useful warning. | |
""" | |
import sys | |
rev_iupac = "XACMGRSVTWYHKDBN-" | |
rev_iupac_alt = "xacmgrsvtwyhkdbn." |
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 | |
# trim.sh - generic, slightly insane paired end quality trimming script | |
# Vince Buffalo <[email protected]> (sans poly-A) | |
set -e | |
set -u | |
## pre-config | |
ADAPTERS=illumina_adapters.fa | |
SAMPLE_NAME=some_sample_name | |
IN1=in1.fastq |
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 GNU screen's C-a binding, since it's programmed in my brain | |
set-option -g prefix C-a | |
unbind C-b | |
# use GNU screen's C-a C-a for last window | |
bind-key C-a last-window | |
# use 1-based indexing, since 1 is close | |
set -g base-index 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
import numpy as np | |
from itertools import combinations | |
from collections import Counter | |
import datetime as dt | |
np.random.seed(0) | |
def repeat_mutation_sim(G, N, L, mu=3e-8): | |
""" | |
Generate N repeats of length L mutating at rate |
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
""" | |
entropy.py | |
Calculate entropy of a given list. | |
""" | |
from math import log, log10 | |
from collections import Counter | |
import pdb | |
def entropy(x, logfun=lambda x: log(x, 2)): |