Skip to content

Instantly share code, notes, and snippets.

<script src="require.js"></script>
// uses https://github.com/alexkalderimis/imjs
<script>
require(['js/im'], function(im) {
console.log(im);
var flymine = new im.Service({root: 'www.flymine.org/query'});
var query = {
from: 'Gene',
select: [
'exons.symbol',
@cmdcolin
cmdcolin / rasterize.js
Last active September 8, 2015 15:40
phantomjs rasterize.js with viewport modification
var page = require('webpage').create(),
system = require('system'),
address, output, size;
if (system.args.length < 3 || system.args.length > 5) {
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
console.log(' image (png/jpg output) examples: "1920px" entire page, window width 1920px');
console.log(' "800px*600px" window, clipped to 800x600');
phantom.exit(1);
@cmdcolin
cmdcolin / convert_bam_to_bigwig.sh
Last active September 25, 2015 22:20
Convert BAM to bigwig (parallel)
#!/bin/bash
samtools faidx reference_genome.fa
cut -f1,2 reference_genome.fa.fai > chrom.sizes
parallel "bedtools genomecov -ibam {} -g chrom.sizes -bg -split > {.}.bg" ::: *.bam;
parallel "bedGraphToBigWig {} chrom.sizes {.}.bw" ::: *.bg

Procedure for compiling HTSLIB under emscripten

  • Get emscripten, e.g. brew install emscripten
  • Get zlib source distribution from zlib.org
  • zlib - “emconfigure ./configure” in zlib
  • zlib - comment out AR and ARFLAGS in Makefile (default libtool breaks things, at least on Mac)
  • zlib - Run “emmake make”
  • Get htslib source distribution from htslib.org
  • htslib - Don’t run emconfigure ./configure as it gets confused by lack of zlib (not sure how to point to it?)
  • htslib - Delete the AR = ar line from Makefile
<html>
<head>
<title>JBrowse feature rendering outside of browser</title>
<link rel="stylesheet" type="text/css" href="css/genome.css">
<script type="text/javascript" src="src/dojo/dojo.js" data-dojo-config="async: 1, baseUrl: './src'"></script>
<script type="text/javascript" src="src/JBrowse/init.js"></script>
<script>
@cmdcolin
cmdcolin / tlengraph.R
Created January 28, 2016 16:03
template length graph
#!/usr/bin/env Rscript
# usage:
# samtools view your_file.bam | cut -f3,4,9 > pre_bedgraph.txt
# tlengraph pre_bedgraph.txt output.bg
# bedGraphToBigWig output.bg chrom.sizes output.bw
library("ggplot2")
@cmdcolin
cmdcolin / x11sudo.sh
Created January 28, 2016 20:44
X11 as sudo
#!/bin/bash
# usage: x11sudo.sh username
su - $1 -c 'xauth list' | grep `echo $DISPLAY | cut -d ':' -f 2| cut -d '.' -f 1 | sed -e 's/^/:/'`|xargs -n 3 xauth add
@cmdcolin
cmdcolin / tumblrAPI
Last active January 31, 2016 21:11
Tumblr community analysis
#!/usr/bin/env Rscript
require(jsonlite)
require(reshape2)
api_key='your_api_key'
get_reblogs<-function(blogname,apikey,total=100) {
@cmdcolin
cmdcolin / genrand.cpp
Last active February 5, 2016 14:15
Programming challenge v1 - find max contiguous product of integers in an array
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
if(argc < 3) {
cout << "Usage: " << argv[0] << " <n> <m> <s>" << endl;
cout << "Generates <n> random numbers to stdout max value <m> using seed <s>" << endl;
return -1;
}
@cmdcolin
cmdcolin / aprs.js
Created February 9, 2016 02:47
aprs.fi query
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
// call the api and update
for(var i=0; i<5; i++) {
setTimeout(function() {