Skip to content

Instantly share code, notes, and snippets.

View blahah's full-sized avatar

Rik blahah

View GitHub Profile
@blahah
blahah / index.html
Last active March 9, 2019 22:44
d3 simple scatter plots from nested data
<html>
<head>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/d3.min.js">
</script>
<style type="text/css">
body {
font: 10px sans-serif;
}
circle {
@blahah
blahah / ciliarisDAR.js
Last active March 9, 2019 22:43
LatticeXY chart
//Eragrostis ciliaris dry-after ripening germination data
var data = [{"temp":"30∞C","RH":20,"ddays":"0630∞/days","days":0,"germ":0},
{"temp":"30∞C","RH":20,"ddays":"0630∞/days","days":1,"germ":0},
{"temp":"30∞C","RH":20,"ddays":"0630∞/days","days":4,"germ":0},
{"temp":"30∞C","RH":20,"ddays":"0630∞/days","days":8,"germ":0},
{"temp":"30∞C","RH":20,"ddays":"0630∞/days","days":14,"germ":0},
{"temp":"30∞C","RH":20,"ddays":"0630∞/days","days":28,"germ":0},
{"temp":"30∞C","RH":20,"ddays":"1260∞/days","days":0,"germ":0},
{"temp":"30∞C","RH":20,"ddays":"1260∞/days","days":5,"germ":0},
{"temp":"30∞C","RH":20,"ddays":"1260∞/days","days":9,"germ":0},
@blahah
blahah / ciliarisDAR.js
Last active March 9, 2019 22:45 — forked from jasondavies/ciliarisDAR.js
LatticeXY chart
//Eragrostis ciliaris dry-after ripening germination data
var ddays = ["0630°/days","1260°/days","1890°/days","2520°/days"];
var RH = [20, 35, 50, 65];
var data = [{"temp":"30°C","RH":20,"ddays":"0630°/days","days":0,"germ":0},
{"temp":"30°C","RH":20,"ddays":"0630°/days","days":1,"germ":0},
{"temp":"30°C","RH":20,"ddays":"0630°/days","days":4,"germ":0},
{"temp":"30°C","RH":20,"ddays":"0630°/days","days":8,"germ":0},
{"temp":"30°C","RH":20,"ddays":"0630°/days","days":14,"germ":0},
{"temp":"30°C","RH":20,"ddays":"0630°/days","days":28,"germ":0},
<!-- forked to enable viewing in bl.ocks.org - filename changed to index.html -->
<!DOCTYPE html>
<html>
<body>
<canvas id="c" style="width:500px; height:500px; background-color: grey">
</canvas>
@blahah
blahah / process_sanger_reads.rb
Last active December 17, 2015 21:59
Snippet to extract consensus joined sequences from Sanger sequencing with forward and reverse primers (parsing data in the format provided by Source Bioscience), and some extra code to reconstruct the original fragment sequences for this specific case (virus protein sequencing with forward and revers primers from two overlapping fragments from e…
require 'rubygems'
require 'bio'
# load sequences, reverse-complement-align the pairs
seqs = {}
# get all .seq files
Dir.chdir('../raw') do
Dir['*.seq'].each do |file|
@blahah
blahah / cleanup_bibtex.rb
Last active December 17, 2015 22:09
Snippet to clean up bibtex/biblatex bibliographies exported from Zotero by removing troublesome characters and fields and replacing unicode characters with the escaped LaTeX versions. (updated with @Treblesteph's regex escaping)
#!/usr/bin/env ruby
# clean up bibtex files by removing unwanted fields,
# replacing troublesome strings and removing bad
# characters
removefields = ['copyright']
removeregexes = removefields.map { |x| Regexp.new("#{x} =") }
@blahah
blahah / stackexchange-style.csl
Last active June 27, 2016 02:36
a CSL style suitable for Zotero, Mendeley, etc. designed for use on StackExchange sites (especially biology.stackexchange.com)
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US">
<info>
<title>Biology.SE</title>
<id>http://phyta.org/biology-stackexchange-style</id>
<link href="https://gist.github.com/Blahah/5681588" rel="self"/>
<author>
<name>Richard Smith</name>
<email>[email protected]</email>
</author>
@blahah
blahah / bowtie_arguments.rb
Last active December 19, 2015 08:39
example of auto-detected arguments for bowtie1 using chain's program_parser.rb
{:arg=>["-q"], :desc=>"query input files are FASTQ .fq/.fastq (default)"}
{:arg=>["-f"], :desc=>"query input files are (multi-)FASTA .fa/.mfa"}
{:arg=>["-r"], :desc=>"query input files are raw one-sequence-per-line"}
{:arg=>["-c"], :desc=>"query sequences given on cmd line (as <mates>, <singles>)"}
{:arg=>["-C"], :desc=>"reads and index are in colorspace"}
{:arg=>["-Q", "--quals"], :type=>:string, :desc=>"QV file(s) corresponding to CSFASTA inputs; use with -f -C"}
{:arg=>["--Q1", "--Q2"], :type=>:string, :desc=>"same as -Q, but for mate files 1 and 2 respectively"}
{:arg=>["-s", "--skip"], :type=>:integer, :desc=>"skip the first <int> reads/pairs in the input"}
{:arg=>["-u", "--qupto"], :type=>:integer, :desc=>"stop after first <int> reads/pairs (excl. skipped reads)"}
{:arg=>["-5", "--trim5"], :type=>:integer, :desc=>"trim <int> bases from 5' (left) end of reads"}
@blahah
blahah / recursive_loops.rb
Created July 15, 2013 15:03
Recursively generate all possible combinations from a hash of ranges (e.g. doing a parameter sweep)
require 'pp'
$ranges = {
:k => (21..90).step(4).to_a,
:d => (1..10).to_a
}
def nested_loop(index, opts)
if index == $ranges.length
# run command
@blahah
blahah / index.html
Last active December 20, 2015 16:49 — forked from rduplain/responsive_d3_example.html
Responsive histogram in d3.js
<!DOCTYPE html>
<script src="http://mbostock.github.com/d3/d3.v2.js?2.8.1"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style>
body {
font: 10px sans-serif;
}
rect {