Skip to content

Instantly share code, notes, and snippets.

@indraniel
indraniel / vcf-filter.go
Created September 11, 2015 02:29
A golang VCF file filtering template
package main
import (
"fmt"
"log"
"os"
"os/signal"
"strings"
"syscall"
package main
import (
"fmt"
"log"
"math"
"os"
"os/signal"
"strconv"
"strings"
package main
import (
"fmt"
"log"
"math"
"os"
"os/signal"
"strconv"
"strings"
@indraniel
indraniel / sort-list-of-dictionaries.py
Created September 23, 2015 20:29
python: approaches to sort a list of dictionaries
#!/usr/bin/python
from __future__ import print_function
# from https://wiki.python.org/moin/SortingListsOfDictionaries
def multikeysort(items, columns):
from operator import itemgetter
comparers = [ ((itemgetter(col[1:].strip()), -1) if col.startswith('-') else (itemgetter(col.strip()), 1)) for col in columns]
def comparer(left, right):
for fn, mult in comparers:
@indraniel
indraniel / knit-latex.r
Created September 29, 2015 17:02
A very bare-bones way to knitr a TeX document
#!/usr/bin/env Rscript
args <- commandArgs(trailingOnly=TRUE)
file <- args[1]
cat(paste("Processing: ", file, "\n"))
library(knitr)
knit(file)
@indraniel
indraniel / analytics-project-layout.md
Created September 29, 2015 17:16
A WIP skeleton layout for analytics projects

A useful starter skeleton layout for analytics project.

project-dir 
├── README.md
├── bin
├── data
│   ├── derived
│   ├── original
│   └── test

├── docs

@indraniel
indraniel / transpose.awk
Created October 13, 2015 20:36
transpose a text table
#!/usr/bin/awk -f
# taken from: http://stackoverflow.com/questions/1729824/transpose-a-file-in-bash
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
#!/usr/bin/env python
# This is a script to merge multiple [GATK][0] Report (or [GATKReport][1])
# files into a single report file. This is useful when one is running multiple
# GATK commands on a partitioned [VCF][2] data set for performance reasons, and then
# afterwards assembling up the overall output.
#
# Currently this script supports the GATKReports for the following
# [VariantEval][3] Evaluation Module [outputs][4]:
#
@indraniel
indraniel / 1-fetch-na12878-pedigree-metadata.py
Created December 30, 2015 23:12
use lxml to fetch NA12878 Coriell Sample Info
#!/usr/bin/env python
from __future__ import print_function, division
import sys, os, pprint
from glob import glob
import requests
from lxml import html
from toolz.curried import *
@indraniel
indraniel / Makefile
Last active January 16, 2016 19:44
An example of a LaTeX/knitr report setup containing a git commit revision number
.PHONY: clean
PRJDIR := /path/to/project
DOCS := $(PRJDIR)/docs
RLIBS := /gscmnt/gc2801/analytics/idas/jira/BIO-1465/rpkgs
REPORTDIR := $(DOCS)/writeups
PDFLATEX := /home/archive/texlive-2015/2015/bin/x86_64-linux/pdflatex
writeup: $(REPORTDIR)/report.pdf