Skip to content

Instantly share code, notes, and snippets.

View astatham's full-sized avatar

Aaron Statham astatham

  • Garvan Institute of Medical Research
  • Sydney, Australia
View GitHub Profile
@astatham
astatham / download_SRA.R
Created March 25, 2014 03:03
Example to download an SRA study wholly within R on wolfpack (our internal cluster)
# wolfpack modules required: hugfre/R/3.0.2 fabbus/aspera/3.1.1.70290
ascpCMD <- "ascp -QT -l1000M -i /share/ClusterShare/software/contrib/fabbus/aspera/3.1.1.70290/asperaweb_id_dsa.putty"
library(SRAdb)
if (!file.exists("../SRAmetadb.sqlite")) db <- getSRAdbFile("../") else db <- "../SRAmetadb.sqlite"
con <- dbConnect(dbDriver("SQLite"), db) # load the SRA database
accession <- "SRP026604"
@astatham
astatham / 0_reuse_code.js
Created July 22, 2014 07:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@astatham
astatham / logging.schema
Created August 6, 2014 07:11
logging qstat (DIRRTTY)
CREATE TABLE log(
time TEXT TEXT,
account TEXT TEXT,
env_list TEXT,
gid TEXT,
grp TEXT,
job_name TEXT,
job_number TEXT,
jobshare TEXT,
mail_list TEXT,
library(rjson)
options(scipen=10000)
if (file.exists("IAMA.db")) file.remove("IAMA.db")
system("sqlite3 IAMA.db < IAMA_scraper.schema;")
while (TRUE) {
bigTab <- NULL
after <- ""
baseURL <- "http://www.reddit.com/r/iama/.json?sort=new&limit=100"
imguRupload <- function(filename, title=NULL, caption=NULL, name=basename(filename), apikey="4feb29d00face5bc1b9dae536e15c373") {
require(RCurl)
require(RJSONIO)
if (length(filename)>1) stop("'filename' must be length 1.")
if (!file.exists(filename)) stop(filename, "does not exist!")
params <- list(key=apikey, image=fileUpload(filename), name=filename)
if (!is.null(title)) params[["title"]] <- title
if (!is.null(caption)) params[["caption"]] <- caption
fromJSON(rawToChar(postForm("http://api.imgur.com/2/upload.json", .params=params)))$upload
}
imguRupload <- function(filename, title=NULL, caption=NULL, name=basename(filename), apikey="4feb29d00face5bc1b9dae536e15c373") {
require(RCurl)
require(RJSONIO)
if (length(filename)>1) stop("'filename' must be length 1.")
if (!file.exists(filename)) stop(filename, "does not exist!")
params <- list(key=apikey, image=fileUpload(filename), name=filename)
if (!is.null(title)) params[["title"]] <- title
if (!is.null(caption)) params[["caption"]] <- caption
fromJSON(rawToChar(postForm("http://api.imgur.com/2/upload.json", .params=params)))$upload
}
#!/usr/local/bin/Rscript
library(twitteR)
library(imguR)
sess <- initSession("clark_lab_linux", "password")
rstats <- searchTwitter("#rstats", sess, n=1000)
#filter out junk
rstats <- rstats[sapply(sapply(rstats, screenName), length)>0]
#make graph
posters <- sort(table(sapply(rstats, screenName)), decreasing=TRUE)
@astatham
astatham / hg19_to_b37d5.sh
Last active September 9, 2015 01:22
Convert a hg19 vcf to a b37d5 vcf - only handles chr1-22, X, Y & M
#!/bin/bash -e
if [[ ! -f "${1}" ]] ; then
echo "File $1 does not exist, aborting."
exit 1
fi
# Replace double digit chromosomes first
cmd="sed"
for i in `seq 10 22` `seq 1 9` X Y; do
cmd="$cmd -e 's/chr$i/$i/g'"
@astatham
astatham / gist:631691
Created October 18, 2010 04:05
send_jabber
#!/usr/bin/perl -w
#
# script for nagios notify via Jabber / Google Talk Instant Messaging
# using XMPP protocol and SASL PLAIN authentication.
#
# author: Andrew Elwell <A.Elwell@physics.gla.ac.uk>
# based on work by Thus0 <Thus0@free.fr> and David Cox
#
# released under the terms of the GNU General Public License v2
# Copyright 2007 Andrew Elwell.
@astatham
astatham / gist:667271
Created November 8, 2010 01:31
not %in%
> 2:3 %in% 1:5
[1] TRUE TRUE
> !2:3 %in% 1:5
[1] FALSE FALSE