Skip to content

Instantly share code, notes, and snippets.

View davmlaw's full-sized avatar

Dave Lawrence davmlaw

View GitHub Profile
#!/bin/bash
set -e # Fail on error
# We can wipe this once we move this to public servers
if [ -z ${GITHUB_USER} ]; then
echo "Please set the variable GITHUB_USER used to download variantgrid and bioinformatics projects"
exit 1;
fi
if [ -z ${GITHUB_PASSWORD} ]; then
@davmlaw
davmlaw / future_of_humanity.py
Created July 4, 2014 14:18
Future Of Humanity Plot
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
LATEX_BASELINE = 0.1
FUNDIES = 20
BIRTH_CONTROL_INVENTION=0.1
FUNDIE_ARROW_OFFSET = 0.1
#!/usr/bin/env python
import os
import sys
if len(sys.argv) != 2:
print "Usage %s: samtools_index" % os.path.basename(sys.argv[0])
sys.exit(1)
samtools_index = sys.argv[1]
@davmlaw
davmlaw / gist:aa2629c59a1b3e179d89
Created June 2, 2014 08:12
Sam or bam has chromosomes
def sam_or_bam_has_chrom(sam_or_bam_filename):
''' return true if sam or bam has chr in header reference names
warning: this will die if you have BOTH chr and NO chr
'''
sf = pysam.Samfile(sam_or_bam_filename, "rb")
header_dict = sf.header
sq = header_dict['SQ']
has_chr = 0
no_chr = 0
@davmlaw
davmlaw / gist:10017021
Last active August 29, 2015 13:58
All the 4 letter nucleotide combinations
import itertools
print [''.join(s) for s in itertools.permutations("ACGT")]