Skip to content

Instantly share code, notes, and snippets.

View leipzig's full-sized avatar

Jeremy Leipzig leipzig

View GitHub Profile
@leipzig
leipzig / Makefile
Created December 6, 2011 21:04
makefile for a mirna deep sequencing project
#Directories
SOURCEDIR := sources
FASTQDIR := fastq
DECODEDDIR := decoded
BAMDIR := bam
SCRIPTDIR := scripts
TRIMMEDDIR := trimmed
#Parameters
MIN_LENGTH := 15
@leipzig
leipzig / microarray.R
Created January 19, 2012 02:19
When can we expect the last damn microarray?
library("plyr")
library("XML")
library("ggplot2")
#Concatenate SQL-style
concat<-function(...,sep="",collapse=NULL){
strings<-list(...)
#NULL, NA
if(
all(unlist(llply(strings,length))>0)
@leipzig
leipzig / mycd.sh
Created January 21, 2012 03:36
directory based history bash profile
function mycd()
{
#if this directory is writable then write to directory-based history file
#otherwise write history in the usual home-based history file
tmpDir=$PWD
echo "#"`date '+%s'` >> $HISTFILE
echo $USER' has exited '$PWD' for '$@ >> $HISTFILE
builtin cd "$@" # do actual cd
if [ -w $PWD ]; then export HISTFILE="$PWD/.dir_bash_history"; touch $HISTFILE; chmod --silent 777 $HISTFILE;
else export HISTFILE="$HOME/.bash_history";
@leipzig
leipzig / array2snp.pl
Created August 14, 2012 18:28
This program converts Affy mitoSNP array samples into either HaploGrep or Mitomaster SNV format
#!/usr/bin/perl
use strict;
use Carp;
use Carp::Assert;
use Getopt::Std;
use File::Slurp;
my %opt;
my $opt_string = 'o:d:rh';
@leipzig
leipzig / seq2haplogrep.pl
Created September 18, 2012 02:45
This program converts mutations in mitochondrial sequences into HaploGrep format using the Mitomaster web service.
#!/usr/bin/perl
use strict;
use Getopt::Std;
use LWP::UserAgent;
use HTTP::Request::Common;
my %opt;
my $opt_string = 'hcms';
getopts( "$opt_string", \%opt ) or &usage();
@leipzig
leipzig / autopass.sh
Created May 14, 2013 16:55
Expect script for Aspera uploads for use when the server chokes on wildcards
#!/usr/bin/expect -f
#Upload a file to an Aspera server, filling in the passphrase field
#Usage: ./autopass.sh mybigassfile
set arg1 [lindex $argv 0]
set timeout -1
spawn ascp -i sra-rsakey-putty.ppk -k 1 -Qr -l300M $arg1 user@asperadomain.ncbi.nlm.nih.gov:protected/
expect "Passphrase for key \"rsa-key-blahblah\":"
send "mypassword\r"
expect "Completed"
#add the file you successfully uploaded to a log
@leipzig
leipzig / hg19gaps
Created July 31, 2013 16:35
hg19 gaps
#bin chrom chromStart chromEnd ix n size type bridge
0 chr1 124535434 142535434 1271 N 18000000 heterochromatin no
23 chr1 121535434 124535434 1270 N 3000000 centromere no
76 chr1 3845268 3995268 47 N 150000 contig no
85 chr1 13219912 13319912 154 N 100000 contig no
89 chr1 17125658 17175658 196 N 50000 clone yes
101 chr1 29878082 30028082 337 N 150000 contig no
188 chr1 120697156 120747156 1263 N 50000 clone yes
188 chr1 120936695 121086695 1265 N 150000 contig no
188 chr1 121485434 121535434 1269 N 50000 clone no
@leipzig
leipzig / Makefile
Last active December 28, 2015 05:49
extract from a VCF known disease loci obtained from Gene Cards
default: vcffilesdone
clean:
rm disease_loci/*/*vcf
rm vcffilesdone
#gene cards list of known disease loci
diseaseloci.html:
curl http://www.genecards.org/cgi-bin/listdiseasecards.pl?type=full > diseaseloci.html
#scrape loci
@leipzig
leipzig / gb_client.pl
Last active August 29, 2015 14:05
access Haplogrep compatible input from a Genbank id
#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
my $userAgent = LWP::UserAgent->new(timeout => 1800); #a half-hour
my $request = POST 'http://mitomaster.mitomap.org/cgi-bin/websrvc.cgi', [
gb => $ARGV[0],
fileType => 'id',
output => 'hsd'

title: "Template for writing scientific papers in R markdown" author: "Petr Keil, pkeil@seznam.cz" date: "11/1/2015" output: pdf_document: fig_caption: yes keep_tex: yes number_sections: yes html_document: