Skip to content

Instantly share code, notes, and snippets.

View jrherr's full-sized avatar
💭
Probably working

Josh Herr jrherr

💭
Probably working
View GitHub Profile
@jrherr
jrherr / quick random sample of a fasta file
Last active December 16, 2015 02:09
I use this quick shell script (Mac OS X shell tools -- I don't have the linux 'shuf' installed) to take a smaller random sample of a fasta file. This can be modified for FASTQ files too.
cat name.fasta |\ # identify file name
awk '/^>/ { if(i>0) printf("\n"); i++; printf("%s\t",$0); next;} {printf("%s",$0);} END { printf("\n");}' |\ # read data
perl -MList::Util -e 'print List::Util::shuffle <>' |\ # random sample of sequences with shuffle
head -n 50000 |\ # break fasta file into sections of 50000 sequences in length
awk '{printf("%s\n%s\n",$1,$2)}' > name_1.fasta # write sequence output
@jrherr
jrherr / installed python module update
Created November 11, 2013 04:47
Update all the python modules already installed on my system
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
@jrherr
jrherr / batch_rename_FASTA
Last active December 31, 2015 11:49
batch rename of FASTA files - I had to recently use this one-liner to rename a large number of sequence reads which were sent to me. I'm just posting this here so I can remember it.
awk ‘/^>/{$0=”>”++i}1′ test.fna > test1.fna
@jrherr
jrherr / zany.R
Created December 18, 2013 02:18 — forked from johnmyleswhite/zany.R
M <- matrix(c(1, 0, 0, 1), byrow = 1, nrow = 2)
df <- data.frame(A = 1)
df$B <- list(M)
df
# A B
# 1 1, 0, 0, 1

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@jrherr
jrherr / khmer-mac-osx-install-error
Last active August 29, 2015 14:04
khmer Mac OSX gcc installation compile error
Here's the error I am getting with khmer install on Mac OSX Mavericks (OS X 10.9.4 (13E28)) install
```
./setup.py build_ext --inplace
running build_ext
bash -c cd third-party/zlib && ( test Makefile -nt configure || bash ./configure --static ) && make -f Makefile.pic PIC
make[1]: Nothing to be done for `PIC'.
bash -c cd third-party/bzip2 && make -f Makefile-libbz2_so all
#gcc -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.6 blocksort.o huffman.o crctable.o randtable.o compress.o decompress.o bzlib.o
#gcc -fpic -fPIC -Wall -Winline -O2 -g -D_FILE_OFFSET_BITS=64 -o bzip2-shared bzip2.c libbz2.so.1.0.6
@jrherr
jrherr / missing.R
Created August 23, 2014 18:33 — forked from vsbuffalo/missing.R
# A quick function to save a PBM (http://en.wikipedia.org/wiki/Netpbm_format)
# visualize *a lot* of missing data pretty quickly (outside of R).
writeMissingPBM <- function(x, file) {
dims <- dim(x)
x[] <- as.integer(is.na(x))
con <- file(file, open="wt")
writeLines(sprintf("P1\n%d %d", ncol(x), nrow(x)), con)
write.table(x, file=con, sep=" ", col.names=FALSE, row.names=FALSE, quote=FALSE)
close(con)
@jrherr
jrherr / homebrew gcc488 installation error log
Last active August 29, 2015 14:07
homebrew gcc48 installation error log
This file has been truncated, but you can view the full file.
Last login: Fri Oct 10 13:26:02 on ttys000
➜ ~ brew install gcc48 -dv
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/gcc48.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/gmp4.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/libmpc08.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/mpfr2.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/cloog018.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Formula/pkg-config.rb
/usr/local/Library/brew.rb (Formulary::StandardLoader): loading /usr/local/Library/Taps/homebrew/homebrew-versions/isl011.rb
/usr/local/Library/Homebrew/build.rb (Formul
@jrherr
jrherr / gist:2c5fed226a1a63f5643a
Created February 8, 2015 16:55
Rename SPAdes output fasta headers line for pipeline
sed -r "s/>NODE(_[0-9]+)_(.*)/>${input.name}\1 \2/g" $input > $output