Skip to content

Instantly share code, notes, and snippets.

View wasade's full-sized avatar

Daniel McDonald wasade

View GitHub Profile
@wasade
wasade / version_update.sh
Created May 1, 2012 23:59
version updater for biom-format
#!/bin/bash
OLD_VERSION=$1
NEW_VERSION=$2
cd trunk/examples
sed -ie "s/Biological Observation Matrix $OLD_VERSION/Biological Observation Matrix $NEW_VERSION/" *.biom
cd ../scripts
sed -ie "s/^__version__ = \"$OLD_VERSION\"/__version__ = \"$NEW_VERSION\"/" *.py
@wasade
wasade / sub
Last active September 7, 2017 22:01
Light weight mechanism to submit a job to torque based cluster. Logging is implicit, and all logs and standard out/err automatically placed in the current working directory.
#!/usr/bin/env python
r"""Cluster submission
Light helper script for submitting jobs to a cluster. For instance, to submit
a job that calls the command hostname, just use:
$ sub hostname
Additionally, you can specify the name of the job:
@wasade
wasade / sub_get.sh
Created January 31, 2013 23:39
Quickly get back notes from https://gist.github.com/4686113
#!/bin/sh
# get notes by ID
if [ ! -e SUB.notes ]
then
echo "Cannot find SUB.notes!"
exit 1
fi
@wasade
wasade / cluster_jobs.py
Created February 19, 2013 20:56
Updated cluster_jobs.py for use on some Torque based clusters
#!/bin/env python
#cluster_jobs.py
"""
Simple helper script to make pbs jobs and submit to the cluster
Will only work if run on bmf or hemisphere
Can run from command line or import into python code.
Author: Micah Hamady
@wasade
wasade / Gamma_distributions.ipynb
Created July 14, 2013 23:43
Gamma distributions for your viewing pleasure. This can be viewed using the IPython notebook viewer: http://nbviewer.ipython.org/5996597
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wasade
wasade / Beta_distributions.ipynb
Created July 14, 2013 23:46
Beta distributions for your viewing pleasure. This notebook can be viewed using the IPython Notebook Viewer: http://nbviewer.ipython.org/5996603
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wasade
wasade / qiime_containers.py
Last active December 20, 2015 11:29
Prototype delayed IO generalized containers
#!/usr/bin/env python
__author__ = "Daniel McDonald"
__copyright__ = "Copyright 2013, The QIIME Project"
__credits__ = ["Daniel McDonald", "Greg Caporaso", "Doug Wendel",
"Jai Ram Rideout"]
__license__ = "GPL"
__version__ = "0.1.0-dev"
__maintainer__ = "Daniel McDonald"
__email__ = "[email protected]"
@wasade
wasade / dynamic CLI creation
Created August 1, 2013 00:51
this works. general purpose interface factory functions are possible, and maybe even down to a single interface factory function. all the usage example, param conv, etc, can be described in an external file. what this means is that we describe commands as objects, but the interfaces are created dynamically.
#!/usr/bin/env python
from qcli.command import CLInterface, Command, \
FilterSamplesFromOTUTable, CLOption
usage_examples = [("Abundance filtering (low coverage)","Filter samples with fewer than 150 observations from the otu table.","%prog -i otu_table.biom -o otu_table_no_low_coverage_samples.biom -n 150"),
("Abundance filtering (high coverage)","Filter samples with greater than 149 observations from the otu table.","%prog -i otu_table.biom -o otu_table_no_high_coverage_samples.biom -x 149"),
("Metadata-based filtering (positive)","Filter samples from the table, keeping samples where the value for 'Treatment' in the mapping file is 'Control'","%prog -i otu_table.biom -o otu_table_control_only.biom -m map.txt -s 'Treatment:Control'"),
("Metadata-based filtering (negative)","Filter samples from the table, keeping samples where the value for 'Treatment' in the mapping file is not 'Control'","%prog -i otu_table.biom -o otu_table_not_control.biom -m map.tx
@wasade
wasade / dynamic CLI creation
Created August 1, 2013 00:51
this works. general purpose interface factory functions are possible, and maybe even down to a single interface factory function. all the usage example, param conv, etc, can be described in an external file. what this means is that we describe commands as objects, but the interfaces are created dynamically.
#!/usr/bin/env python
from qcli.command import CLInterface, Command, \
FilterSamplesFromOTUTable, CLOption
usage_examples = [("Abundance filtering (low coverage)","Filter samples with fewer than 150 observations from the otu table.","%prog -i otu_table.biom -o otu_table_no_low_coverage_samples.biom -n 150"),
("Abundance filtering (high coverage)","Filter samples with greater than 149 observations from the otu table.","%prog -i otu_table.biom -o otu_table_no_high_coverage_samples.biom -x 149"),
("Metadata-based filtering (positive)","Filter samples from the table, keeping samples where the value for 'Treatment' in the mapping file is 'Control'","%prog -i otu_table.biom -o otu_table_control_only.biom -m map.txt -s 'Treatment:Control'"),
("Metadata-based filtering (negative)","Filter samples from the table, keeping samples where the value for 'Treatment' in the mapping file is not 'Control'","%prog -i otu_table.biom -o otu_table_not_control.biom -m map.tx
@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")
]