Skip to content

Instantly share code, notes, and snippets.

View cfriedline's full-sized avatar

Chris Friedline cfriedline

View GitHub Profile
@cfriedline
cfriedline / gist:7138580
Last active December 26, 2015 10:39
Poor man's IPython notebook manager, now that there's multidir. Put this into a new notebook, assumes that all notebooks are under a common directory, albeit in their own directories. Should help (me) with git.
manager_name = 'Manager.ipynb'
import os
from IPython.display import FileLink, FileLinks, display, HTML, display_html
notebooks = !find . | grep .ipynb$ | grep -v checkpoint
notebooks = sorted(notebooks)
root_dir = [os.path.dirname(os.path.abspath(x)) for x in notebooks if manager_name in x]
paths = []
for n in notebooks:
u = os.path.abspath(n).replace(root_dir[0], '/notebooks')
display_html(HTML('<li><a href=%s target=_new>%s' % (u, u)))
@cfriedline
cfriedline / gist:7202638
Created October 28, 2013 19:04
diginorm decorator
def run_diginorm_renamer(args):
from Bio.SeqIO.QualityIO import FastqGeneralIterator
infile, outfile = args
with open(outfile, "w") as o:
for i, (name, seq, qual) in enumerate(FastqGeneralIterator(open(infile))):
add = 1
if i % 2 != 0:
add = 2
o.write("@%s_%d\n%s\n+\n%s\n" % (name, add, seq, qual))
if i % 100000 == 0:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cfriedline
cfriedline / latexify.js
Created November 14, 2013 21:07
Create LaTeX table from selected text in Google Spreadsheet
function latexify() {
var app = UiApp.createApplication();
height = "400"
width = "500"
app.setHeight(height)
app.setWidth(width)
app.setTitle("LaTeXified!")
panel = app.createVerticalPanel()
panel.setHeight("350");
panel.setWidth(width);
{
"metadata": {
"name": "snp_sim"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
rTraitDisc2 <-
function(phy, model = "ER", k = if (is.matrix(model)) ncol(model) else 2,
rate = 0.1, states = LETTERS[1:k], freq = rep(1/k, k),
ancestor = FALSE, root.value = 1, ...)
{
if (is.null(phy$edge.length))
stop("tree has no branch length")
if (any(phy$edge.length < 0))
stop("at least one branch length negative")
@cfriedline
cfriedline / test_mp_rpy2.ipynb.json
Created June 4, 2014 05:08
testing multiprocessing and rpy2 (ape)
{
"metadata": {
"name": "",
"signature": "sha256:04f733fe38a12e7bbe8ee8d3f2900d3fecf0ae7a83ba728cd84650110e26b216"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"metadata": {
"name": "",
"signature": "sha256:24625e0326d219f8b77f0317e421df165d0adfb7925fac44e4f9cc5c35a28bd6"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"metadata": {
"name": "",
"signature": "sha256:5507a20bf985d7ff9c8b454bf414997a33b671d82b7ceaaf24f89a61d1397ce0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [