Skip to content

Instantly share code, notes, and snippets.

@wilzbach
wilzbach / index.js
Last active August 29, 2015 14:05
Clustal example
// load the module
var Clustal = require("biojs-io-clustal");
// console
var current = document.createElement('p');
document.body.appendChild(current);
Clustal.read("http://dev.biojs-msa.org/v1/dummy/samples/p53.clustalo.clustal", function(seqs){
current.innerHTML = seqs.length + " seqs have been loaded";
})
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://wzrd.in/bundle/biojs-vis-chromosome@latest"></script>
<link rel="stylesheet" href="https://raw.githubusercontent.com/4ndr01d3/js-components/master/util-area_selector/css/area_selector.css">
<link rel="stylesheet" href="https://raw.githubusercontent.com/4ndr01d3/js-components/master/biojs-vis-chromosome/css/chromosome.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<div id='yourDiv'></div>
@wilzbach
wilzbach / index.js
Created September 18, 2014 00:58
requirebin sketch
var parser = require("biojs-io-newick").parse_nwk;
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
context.lineWidth = 5;
context.font="16px Arial";
@wilzbach
wilzbach / index.js
Last active August 29, 2015 14:08
requirebin sketch
var parser = require("biojs-io-snipspector");
var _ = require("underscore");
var vis = function(opts){
var divEl = opts.el;
var self = this; // save reference to itself (in callbacks this is different)
var el = divEl;
parser.read("http://files.biojs.net/chromosomes/manny", function(result){
for(var i=0; i < result.length; i++) {
@wilzbach
wilzbach / output
Last active June 29, 2016 14:34
Tricky enum bug with ranges
iv: -0x1p+0, -0x1.ccccccccccccdp-1
iv: -0x1p+0, -0x1.ccccccccccccdp-1
Interval!real(-1, -0.9, 2, 0, -nan, 0.118267, 2.00562, LinearFun!real(nan, nan, nan), LinearFun!real(nan, nan, nan))
---
iv.lx -1.0000000000 (-0x8p-3)
hat.a 0.1182672100 (0xf.23614391d01ffb5p-7)
hat.slope 1.1826721000 (0x9.761cca3b2214947p-3)
hat.y -0.9000000000 (-0xe.6666666666668p-4)
hat(p1) 0.0000000000 (0x0p+0)
hat(p2) 0.1182672100 (0xf.23614391d01ffb5p-7)
@wilzbach
wilzbach / output
Created June 29, 2016 17:59
Different floating point behavior
type: float
iv1: -0x1p+0, -0x1.ccccccp-1
Interval!float(-1, -0.9, 2, 0, -nan, 0.118267, 2.00563, LinearFun!float(nan, nan, nan), LinearFun!float(nan, nan, nan))
iv.lx -1.0000000000 (-0x1p+0)
hat.a 0.1182672605 (0x1.e46c36p-4)
hat.slope 1.1826723814 (0x1.2ec39ep+0)
hat.y -0.8999999762 (-0x1.ccccccp-1)
hat(p1) -0.0000000075 (-0x1p-27) //-0
hat(p2) 0.1182672605 (0x1.e46c36p-4)
---
@wilzbach
wilzbach / output
Created July 31, 2016 17:59
FP differences between 32 & 64-bit
> rdmd -unittest -main ele.d
-0x1.820d74p-3
-0x1.820d74p-3
> rdmd -unittest -main-m32 ele.d
-0x1.820d76p-3
-0x1.820d74p-3
@wilzbach
wilzbach / main.d
Created August 1, 2016 05:57
std.math.pow vs C pow
void main()
{
alias S = float;
S s1 = 0x1.24c92ep+5;
S s2 = -0x1.1c71c8p+0;
import std.math : std_pow = pow;
import core.stdc.stdio : printf;
import core.stdc.math: powf;
@wilzbach
wilzbach / main.d
Created August 1, 2016 06:50
FP magic with 32-bit
import std.stdio;
alias S = float;
float shL = 0x1.1b95eep-4; // -0.069235
float shR = 0x1.9c7cfep-7; // -0.012588
F fun(F)(F x)
{
return 1.0 + x * 2;
}
@wilzbach
wilzbach / main.d
Created August 1, 2016 15:08
FP magic fun on 32-bit
S fun(S)(in S x)
{
return -1 / x;
}
void main()
{
alias S = double; // same for float
S i = fun!S(3);
assert(i == S(-1) / 3); // this lines passes