Skip to content

Instantly share code, notes, and snippets.

View kdiverson's full-sized avatar

Kathryn Iverson kdiverson

View GitHub Profile
Verifying my Blockstack ID is secured with the address 1KFPYC3FE9BhSKfwy5KYfThJbcZaxEDUm3
@kdiverson
kdiverson / multimerge.R
Created July 14, 2015 12:44
multimerge
multmerge = function(mypath){
filenames=list.files(path=mypath, full.names=TRUE)
datalist = lapply(filenames, function(x){read.delim(file=x,header=T)})
}
multmerge = function(mypath){
filenames=list.files(path=mypath, full.names=TRUE)
datalist = lapply(filenames, function(x){read.table(pipe("cut -f1,2,3,4,5,6 myFile.txt"))})
Reduce(function(x,y) {merge(x,y)}, datalist)
@kdiverson
kdiverson / .bash_profile
Created May 12, 2015 21:31
My .bash_profile from axiom
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
# Set colors
export CLICOLOR=1
@kdiverson
kdiverson / parse_human.bash
Last active August 29, 2015 14:20
run LMAT
hit_total=`awk '{total += $3} END {print total}' *fastsummary.species`
nohit_total=`awk '{total += $2} END {print total}' *nomatchsum`
total=(($hit_total + $nohit_total))
human=`awk '{if ($4==9606) {print $3} }' *fastsummary.species`
echo (($human / $total))
hit_total=`awk '{total += $3} END {print total}' *fastsummary.species`; nohit_total=`awk '{total += $2} END {print total}' *nomatchsum`; total=(($hit_total + $nohit_total)); human=`awk '{if ($4==9606) {print $3} }' *fastsummary.species`; echo (($human / $total))
import argparse
import logging
parser = argparse.ArgumentParser()
parser.add_argument('-d','--debug',
help='Print lots of debugging statements',
action="store_const",dest="loglevel",const=logging.DEBUG,
default=logging.WARNING
)
parser.add_argument('-v','--verbose',
@kdiverson
kdiverson / gist:c2419d467c436fecee31
Last active August 29, 2015 14:11
mock data iterative assembly stats
132585322 (100.00%) were unpaired; of these:
4790404 (3.61%) aligned 0 times
98633353 (74.39%) aligned exactly 1 time
29161565 (21.99%) aligned >1 times
N50: 10038
N90: 100
total contigs: 2097980
average length: 282 bp
trimmed average length: 281 bp
greater than or equal to 100: 1437022
#!/usr/bin/python2.7
'''USAGE: quicksubmit.py "command -l parameter" [options]
This script submits your one line command as a job to the pbs job scheduler.
'''
import subprocess as s
import sys
import argparse
def submitjob(job_name, command, subtype = "qsub", walltime = "10:00:00", cput = "10:00:00", pm = "nodes=1:ppn=1:mem=2gb", mailto = "", afterok = "", verbose = False):
'''USAGE: submitjob('my_job', 'echo "hello world!"')
import sys
def get_next_fasta (fileObject):
'''usage: for header, seq in get_next_fasta(fileObject):
'''
header = ''
seq = ''
#The following for loop gets the header of the first fasta
#record. Skips any leading junk in the file
for line in fileObject:
#multi k velvet
seq_file=$1
fq=$(basename $seq_file .trimmed.fq.keep.abundfilt)
for k in {19..51..2};
do
quicksubmit "velveth && velvetg"
name=$(basename $i .pe.fq.gz);
@kdiverson
kdiverson / diginorm.sh
Last active August 29, 2015 14:08
Shell script for running the digital normalization part of khmer
#!/bin/sh
#script to run digital normalization
#####
#files
R1=$1 #"R1_001" forward fastq reads
R2=$2 #"R2_001" reversed fastq reads
COM=$3 #"combined_001" interleaved reads
#paths