Skip to content

Instantly share code, notes, and snippets.

View dmckean's full-sized avatar

Dave McKean dmckean

View GitHub Profile
@dmckean
dmckean / tabulate.c
Created May 9, 2018 21:58
bcftools plugin for binning and tabulating integer FORMAT data
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <getopt.h>
#include <unistd.h>
#include <inttypes.h>
#include <htslib/vcf.h>
#include "bcftools.h"
#include "version.c"
@dmckean
dmckean / tabulate_fmt.nim
Created May 9, 2018 21:57
Tool for binning and tabulating integer FORMAT data from VCF
import hts
import docopt
from sequtils import toSeq
from strutils import parseInt, join
let doc = """
Bin and tabulate FORMAT data for each VCF record.
Usage:
tabulate_fmt (-h | --help)
@dmckean
dmckean / parse_samstats.R
Created November 14, 2017 17:16
Parses output from `samtools stats` into a list of lists and data.frames (good for samtools/htslib 1.4-1.6 at least)
parse_samstats <- function(file) {
max.col <- max(count.fields(file, sep = "\t"))
stats.prefixes <- read.table(file, col.names = seq(max.col),
colClasses=c("character", rep("NULL", max.col-1)),
fill=TRUE)
stats.nrows <- table(stats.prefixes)[unique(stats.prefixes)[,1]]
stopifnot(unlist(
@dmckean
dmckean / kinstapaper.py
Created April 8, 2016 05:47
A simple HTTP server for downloading MOBI files from Instapaper, suitable for use from a Kindle browser.
#! /usr/bin/env python
"""
A simple HTTP server for downloading MOBI files from Instapaper
In addition to username, password, a list of folder names and ids
must be provided to access Instapaper folders. These IDs may be
found in instapaper folder URLs, e.g.
https://www.instapaper.com/u/folder/(id)/(name)
Leave the id to `None` to reach the home Instapaper folder
USAGE: kinstapaper.py [-h] USERNAME PASSWORD ...
"""
@dmckean
dmckean / tmux-panes.sh
Last active December 23, 2021 04:35
A combination of the tmux commands: list-sessions list-windows and list-panes
#! /usr/bin/env bash
hi_color=$(tput setaf 4) #blue
bold=$(tput bold)
underline=$(tput smul)
normal=$(tput sgr0)
read -r -d '' usage << DOC
Prints out a table of tmux sessons, windows, and panels.
@dmckean
dmckean / bwt.py
Last active August 7, 2023 04:45
A simple Burrows-Wheeler transform function in python
#! /usr/bin/env python
"""
A simple Burrows-Wheeler transform function in python.
Algorithm presented in:
Burrows M, Wheeler DJ: A Block Sorting Lossless Data Compression Algorithm.
Technical Report 124. Palo Alto, CA: Digital Equipment Corporation; 1994.
USAGE: bwt.py [-h] [-i INDEX] STRING
"""