Skip to content

Instantly share code, notes, and snippets.

View wasade's full-sized avatar

Daniel McDonald wasade

View GitHub Profile
@wasade
wasade / subsample.c
Created March 25, 2014 15:19
Rapid subsampling
#include <gsl/gsl_rng.h>
#include <math.h>
#include "subsample.h"
/* subsample_col
*
* desc: subsample an array of COO objects, of length size, to a sum of (n)
*
* inputs: COO* list - an array of COO objects
* COO* ss_result - store the subsampled result
@wasade
wasade / pre-commit
Created March 18, 2014 01:17
PEP8 git pre-commit hook, adapted from https://gist.github.com/lentil/810399. The specific change was to stash any uncommited changed prior to executing pep8.
#!/usr/bin/env python
from __future__ import with_statement
import os
import re
import shutil
import subprocess
import sys
import tempfile
@wasade
wasade / symbol_table.c
Created January 28, 2014 22:29
Symbol table based off of Sedgewick (http://www.amazon.com/Algorithms-Parts-1-4-Fundamentals-Structures/dp/0201314525). This code can be considered to be BSD.
#include <stdlib.h>
#include "symbol_table.h"
typedef struct STNode* stlink;
struct STNode {
int index, d;
stlink l, m, r; // left, middle, right
};
static stlink head;
@wasade
wasade / illumina_overview_tutorial.ipynb
Last active January 3, 2016 00:28
QIIME 1.8 Illumina tutorial for the Workshop on Genomics 2014
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wasade
wasade / python_tutorial.ipynb
Last active December 5, 2017 20:24
Python programming tutorial for the Workshop on Genomics 2014.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wasade
wasade / github_workflow.txt
Last active December 27, 2015 02:29
Mini github workflow example
# on github, go the your favorite repository, such as pyqi:
# https://github.com/bipy/pyqi
# click fork, this will create a copy of the forked repository (and branch, generally its master by default)
# on the command line, this will create a ./pyqi directory
$ git clone https://github.com/wasade/pyqi
$ cd pyqi
# update your remotes, this allows you to get updates from the master "origin" repository (bipy/pyqi in this case)
# we're going to call this upstream as it is upstream of your fork since other people merge to it
@wasade
wasade / IPython cluster utilities example.ipynb
Created October 18, 2013 21:19
IPython cluster utilities example in an IPython notebook. This notebook can be viewed here: http://nbviewer.ipython.org/7048424
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wasade
wasade / cluster_utils.py
Last active December 25, 2015 22:09
IPython tools for submitting to and monitoring jobs on a Torque-based cluster. NOTE: this script is _not_ compatible with Python, and is only syntactically valid for IPython (git would not syntax highlight for Python if the file had a .ipy extension). An example of the use of these utilities can be found here: https://gist.github.com/wasade/7048424
__author__ = "Daniel McDonald"
__copyright__ = "Copyright 2013"
__credits__ = ["Daniel McDonald"]
__license__ = "BSD"
__version__ = "0.1"
__maintainer__ = "Daniel McDonald"
__email__ = "[email protected]"
usage = """%run cluster_utils.ipy
@wasade
wasade / buckets.py
Last active December 25, 2015 19:48
Easy hash buckets. The specific use is in situations where you have a giant single dictionary (e.g., 10s of millions of keys). The motivation is to break up a giant hash table into smaller ones in order to reduce the amount of memory required.
#!/usr/bin/env python27
from random import shuffle
from unittest import TestCase, main
__author__ = "Daniel McDonald"
__credits__ = ["Daniel McDonald"]
__license__ = "CC0 1.0, http://creativecommons.org/publicdomain/zero/1.0/"
__maintainer__ = "Daniel McDonald"
__url__ = "https://gist.github.com/wasade/7029970"
@wasade
wasade / testcfg.py
Created August 1, 2013 17:34
test, and incomplete filter samples from otu tables cli configuration
from qcli.interface.cli import CLOption, UsageExample, ParameterConversion
usage_examples = [
UsageExample(ShortDesc="Abundance filtering (low coverage)",
LongDesc="Filter samples with fewer than 150 observations from the otu table.",
Ex="%prog -i otu_table.biom -o otu_table_no_low_coverage_samples.biom -n 150"),
UsageExample(ShortDesc="Abundance filtering (high coverage)",
LongDesc="Filter samples with fewer than 150 observations from the otu table.",
Ex="%prog -i otu_table.biom -o otu_table_no_high_coverage_samples.biom -x 149")
]