Skip to content

Instantly share code, notes, and snippets.

@jfear
jfear / run_rail_parallel.py
Created April 21, 2016 19:50
starting point for wrapping rail-rna
#!/usr/bin/env python
import os
import sys
import subprocess
import time
import logging
import ipyparallel
TEMPLATE="""#!/bin/sh
@jfear
jfear / emr_simulator.patch
Created April 21, 2016 19:57
patch of rail-rna to avoid race condition
1064,1068d1063
< retries = 0
< while not os.path.isfile(file_or_archive):
< time.sleep(5)
< if retries > 5: break
< retries += 1
1426,1430d1420
< retries = 0
< while not os.path.isfile(file_or_archive):
< time.sleep(5)
c = get_config()
### If you want to auto-save .html and .py versions of your notebook:
# modified from: https://github.com/ipython/ipython/issues/8009
import os
from subprocess import check_call
def post_save(model, os_path, contents_manager):
"""post-save hook for converting notebooks to .py scripts"""
if model['type'] != 'notebook':
return # only do this for notebooks
@jfear
jfear / download_sra_xsd.sh
Created June 23, 2016 21:32
Download SRA XSDs for use with biopython
#!/bin/bash
# Trying to get biopython to parse SRA xml output. I think I need these XSDs produced by SRA to do this.
if [ ! -e ~/.biopython/Bio/Entrez/XSDs ]; then mkdir -p ~/.biopython/Bio/Entrez/XSDs; fi
cd ~/.biopython/Bio/Entrez/XSDs
wget -O SRA.common.xsd "http://www.ncbi.nlm.nih.gov/viewvc/v1/trunk/sra/doc/SRA_1-5/SRA.common.xsd?view=co"
wget -O SRA.submission.xsd "http://www.ncbi.nlm.nih.gov/viewvc/v1/trunk/sra/doc/SRA_1-5/SRA.submission.xsd?view=co"
wget -O SRA.study.xsd "http://www.ncbi.nlm.nih.gov/viewvc/v1/trunk/sra/doc/SRA_1-5/SRA.study.xsd?view=co"
wget -O SRA.sample.xsd "http://www.ncbi.nlm.nih.gov/viewvc/v1/trunk/sra/doc/SRA_1-5/SRA.sample.xsd?view=co"
@jfear
jfear / reference-markdown-metadata-from-jinja-template.py
Created July 27, 2016 21:02 — forked from glombard/reference-markdown-metadata-from-jinja-template.py
How to use Markdown as a filter in a Jinja2 template, and then extract the Markdown Meta property directly from the template. Assuming you want to use the Meta-data value before rendering the converted Markdown content (e.g. in the html head), the trick is to render the markdown first, save it to a variable (html_content in this example) using a…
from pprint import pprint
import jinja2
import markdown
HTML_TEMPLATE = """{% macro get_html() %}
{{ content | markdown }}
{% endmacro %}
{% set html_content = get_html() %}
Title from Markdown meta-data: {{ get_title() }}
@jfear
jfear / jupyterTunnel
Last active September 12, 2017 18:55
A helper script for creating an ssh tunnel between machines for running jupyter notebook.
#!/bin/bash
# This is a little bash script to create a tunnel for running jupyter
# notebooks.
#
# You can run the script like so:
#
# $ jupyterTunnel start remote1
#
# This will create an ssh tunnel on port 7000 to remote 1, and create a control
# socket 'jupyter-ctrl-socket' in the current working direcotry. To stop the
# see https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/
# core
brew install coreutils
# key commands
brew install binutils
brew install diffutils
brew install ed --default-names
brew install findutils --with-default-names
@jfear
jfear / workflowy.css
Created January 26, 2017 22:36
workflowy dark simple
@namespace url(http://www.w3.org/1999/xhtml);
/* minimal page background */
#pageContainer {
margin-top: 24px;
}
.page {
max-width: 100% !important;
border: none !important;
margin-bottom: 0 !important;
/* fix for dynamic positioning of the .page div */
# vim: set ft=snakemake:
shell.prefix("""set -euo pipefail;
if [ -e /lscratch/$SLURM_JOBID ]; then
export TMPDIR=/lscratch/$SLURM_JOBID
else
export TMPDIR=/tmp
fi;
""")
workdir: '.'
@jfear
jfear / test_minimal.snake
Last active February 21, 2017 22:44
Minimal test file for conda error
#/usr/bin/env python
import os
from lcdblib.snakemake import helpers
from lcdblib.utils import utils
URI = '../lcdb-wrapper-tests'
TMPDIR='/mnt/threeTB/centos_scratch'
references = {
'dmel': {