Skip to content
Browse files

setup necessary structure and directories

  • Loading branch information...
0 parents commit 84136260afe0cf480e4985697e2ef2e4ebe376af @georgeG committed Jan 15, 2012
Showing with 201 additions and 0 deletions.
  1. +17 −0 .gitignore
  2. +4 −0 Gemfile
  3. +2 −0 Rakefile
  4. +8 −0 lib/scribl-rails.rb
  5. +5 −0 lib/scribl-rails/version.rb
  6. +19 −0 scribl-rails.gemspec
  7. +146 −0 vendor/assets/javascripts/scribl.js
17 .gitignore
@@ -0,0 +1,17 @@
+*.gem
+*.rbc
+.bundle
+.config
+.yardoc
+Gemfile.lock
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
4 Gemfile
@@ -0,0 +1,4 @@
+source 'http://rubygems.org'
+
+# Specify your gem's dependencies in scribl-rails.gemspec
+gemspec
2 Rakefile
@@ -0,0 +1,2 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
8 lib/scribl-rails.rb
@@ -0,0 +1,8 @@
+require "scribl-rails/version"
+
+module Scribl
+ module Rails
+ class Engine < ::Rails::Engine
+ end
+ end
+end
5 lib/scribl-rails/version.rb
@@ -0,0 +1,5 @@
+module Scribl
+ module Rails
+ VERSION = "1.1"
+ end
+end
19 scribl-rails.gemspec
@@ -0,0 +1,19 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/scribl-rails/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["George Githinji","Chase Miller"]
+ gem.email = ["georgkam@gmail.com"]
+ gem.description = %q{A gem to automate using Scribl bioinformatics graphics library with Rails 3}
+ gem.summary = %q{Scribl javascript for Rails 3 }
+ gem.homepage = "http://github.com/georgeG/scribl-rails"
+
+ #gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ gem.files = Dir["{lib,vendor}/**/*"] + ["MIT-LICENSE", "README.md"]
+ #gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ gem.add_dependency "railties","~ 3.1"
+
+ gem.name = "scribl-rails"
+ gem.require_paths = ["lib"]
+ gem.version = Scribl::Rails::VERSION
+end
146 vendor/assets/javascripts/scribl.js
@@ -0,0 +1,146 @@
+var BAM_MAGIC=21840194,BAI_MAGIC=21578050;function BamFile(){}function Vob(a,b){this.block=a;this.offset=b}Vob.prototype.toString=function(){return""+this.block+":"+this.offset};function Chunk(a,b){this.minv=a;this.maxv=b}
+function makeBam(a,b,c){var d=new BamFile;d.data=a;d.bai=b;d.data.fetch(function(a){if(!a)return alert("Couldn't access BAM");a=unbgzf(a);a=new Uint8Array(a);readInt(a,0);for(var b=readInt(a,4),h="",g=0;g<b;++g)h+=String.fromCharCode(a[g+8]);h=readInt(a,b+8);b+=12;d.chrToIndex={};d.indexToChr=[];for(g=0;g<h;++g){for(var i=readInt(a,b),j="",m=0;m<i-1;++m)j+=String.fromCharCode(a[b+4+m]);readInt(a,b+i+4);d.chrToIndex[j]=g;j.indexOf("chr")==0?d.chrToIndex[j.substring(3)]=g:d.chrToIndex["chr"+j]=g;d.indexToChr.push(j);
+b=b+8+i}if(d.indices)return c(d)});d.bai.fetch(function(a){if(!a)return alert("Couldn't access BAI");var b=new Uint8Array(a);if(readInt(b,0)!=BAI_MAGIC)return alert("Not a BAI file");var h=readInt(b,4);d.indices=[];for(var g=8,i=0;i<h;++i){var j=g,m=readInt(b,g);g+=4;for(var k=0;k<m;++k){readInt(b,g);var l=readInt(b,g+4);g+=8+l*16}k=readInt(b,g);g+=4;g+=k*8;m>0&&(d.indices[i]=new Uint8Array(a,j,g-j))}if(d.chrToIndex)return c(d)})}
+BamFile.prototype.blocksForRange=function(a,b,c){var d=this.indices[a];if(!d)return[];a=reg2bins(b,c);for(var e=[],f=0;f<a.length;++f)e[a[f]]=!0;a=[];var h=[];f=readInt(d,0);for(var g=4,i=0;i<f;++i){var j=readInt(d,g),m=readInt(d,g+4);g+=8;if(e[j])for(var k=0;k<m;++k){var l=readVob(d,g),n=readVob(d,g+8);(j<4681?h:a).push(new Chunk(l,n));g+=16}else g+=m*16}f=readInt(d,g);e=null;c=Math.min(c>>14,f-1);for(f=Math.min(b>>14,f-1);f<=c;++f)if((b=readVob(d,g+4+f*8))&&(!e||b.block<e.block||b.offset<e.offset))e=
+b;b=[];if(e!=null)for(f=0;f<h.length;++f)d=h[f],d.maxv.block>=e.block&&d.maxv.offset>=e.offset&&b.push(d);h=b;b=[];for(f=0;f<h.length;++f)b.push(h[f]);for(f=0;f<a.length;++f)b.push(a[f]);b.sort(function(a,b){var c=a.minv.block-b.minv.block;return c!=0?c:a.minv.offset-b.minv.offset});a=[];if(b.length>0){h=b[0];for(f=1;f<b.length;++f)d=b[f],d.minv.block==h.maxv.block?h=new Chunk(h.minv,d.maxv):(a.push(h),h=d);a.push(h)}return a};
+BamFile.prototype.fetch=function(a,b,c,d){function e(){if(j>=g.length)return d(i);else if(m){var a=new Uint8Array(m);f.readBamRecords(a,g[j].minv.offset,i,b,c,h);m=null;++j;return e()}else{var l=g[j];a=l.minv.block;f.data.slice(a,l.maxv.block+65536-a).fetch(function(a){m=unbgzf(a,l.maxv.block-l.minv.block+1);return e()})}}var f=this,h=this.chrToIndex[a],g;h===void 0?g=[]:(g=this.blocksForRange(h,b,c))||d(null,"Error in index fetch");var i=[],j=0,m;e()};
+var SEQRET_DECODER=["=","A","C","x","G","x","x","x","T","x","x","x","x","x","x","N"],CIGAR_DECODER=["M","I","D","N","S","H","P","=","X","?","?","?","?","?","?","?"];function BamRecord(){}
+BamFile.prototype.readBamRecords=function(a,b,c,d,e,f){for(;;){var h=readInt(a,b);h=b+h+4;if(h>=a.length)return c;var g=new BamRecord,i=readInt(a,b+4),j=readInt(a,b+8),m=readInt(a,b+12),k=(m&65280)>>8,l=m&255,n=readInt(a,b+16)&65535;m=readInt(a,b+20);readInt(a,b+24);readInt(a,b+28);readInt(a,b+32);for(var q="",o=0;o<l-1;++o)q+=String.fromCharCode(a[b+36+o]);b=b+36+l;o=0;l="";for(var s=0;s<n;++s){var u=readInt(a,b),p=u>>4;u=CIGAR_DECODER[u&15];if(u=="M"||u=="I"||u=="X")o+=p;l=l+p+u;b+=4}g.cigar=l;
+g.lengthOnRef=o;n="";l=m+1>>1;for(o=0;o<l;++o)s=a[b+o],n+=SEQRET_DECODER[(s&240)>>4],n+=SEQRET_DECODER[s&15];b+=l;g.seq=n;n="";for(o=0;o<m;++o)n+=String.fromCharCode(a[b+o]);b+=m;g.quals=n;g.pos=j;g.mq=k;g.readName=q;for(g.segment=this.indexToChr[i];b<h;){j=String.fromCharCode(a[b])+String.fromCharCode(a[b+1]);k=String.fromCharCode(a[b+2]);if(k=="A")k=String.fromCharCode(a[b+3]),b+=4;else if(k=="i"||k=="I")k=readInt(a,b+3),b+=7;else if(k=="c"||k=="C")k=a[b+3],b+=4;else if(k=="s"||k=="S")k=readShort(a,
+b+3),b+=5;else if(k=="f")throw"FIXME need floats";else if(k=="Z"){b+=3;for(k="";;)if(q=a[b++],q==0)break;else k+=String.fromCharCode(q)}else throw"Unknown type "+k;g[j]=k}if(!d||g.pos<=e&&g.pos+m>=d)(f===void 0||i==f)&&c.push(g);b=h}};function readInt(a,b){return a[b+3]<<24|a[b+2]<<16|a[b+1]<<8|a[b]}function readShort(a,b){return a[b+1]<<8|a[b]}
+function readVob(a,b){var c=(a[b+6]&255)*4294967296+(a[b+5]&255)*16777216+(a[b+4]&255)*65536+(a[b+3]&255)*256+(a[b+2]&255),d=a[b+1]<<8|a[b];return c==0&&d==0?null:new Vob(c,d)}
+function unbgzf(a,b){b=Math.min(b||1,a.byteLength-100);for(var c=[],d=[0],e=0;d[0]<b;){var f=new Uint8Array(a,d[0],100);f=f[11]<<8|f[10];f=jszlib_inflate_buffer(a,12+f+d[0],Math.min(65536,a.byteLength-12-f-d[0]),d);d[0]+=8;e+=f.byteLength;c.push(f)}if(c.length==1)return c[0];else{d=new Uint8Array(e);for(f=e=0;f<c.length;++f){var h=new Uint8Array(c[f]);arrayCopy(h,0,d,e,h.length);e+=h.length}return d.buffer}}
+function reg2bin(a,b){--b;if(a>>14==b>>14)return 4681+(a>>14);if(a>>17==b>>17)return 585+(a>>17);if(a>>20==b>>20)return 73+(a>>20);if(a>>23==b>>23)return 9+(a>>23);if(a>>26==b>>26)return 1+(a>>26);return 0}var MAX_BIN=37449;
+function reg2bins(a,b){var c,d=[];--b;d.push(0);for(c=1+(a>>26);c<=1+(b>>26);++c)d.push(c);for(c=9+(a>>23);c<=9+(b>>23);++c)d.push(c);for(c=73+(a>>20);c<=73+(b>>20);++c)d.push(c);for(c=585+(a>>17);c<=585+(b>>17);++c)d.push(c);for(c=4681+(a>>14);c<=4681+(b>>14);++c)d.push(c);return d};function BlobFetchable(a){this.blob=a}BlobFetchable.prototype.slice=function(a,b){var c;b?this.blob.webkitSlice?c=this.blob.webkitSlice(a,a+b):this.blob.mozSlice&&(c=this.blob.mozSlice(a,a+b)):this.blob.webkitSlice?c=this.blob.webkitSlice(a):this.blob.mozSlice&&(c=this.blob.mozSlice(a));return new BlobFetchable(c)};BlobFetchable.prototype.fetch=function(a){var b=new FileReader;b.onloadend=function(){a(bstringToBuffer(b.result))};b.readAsBinaryString(this.blob)};
+function URLFetchable(a,b,c,d){d||(typeof b==="object"?(d=b,b=void 0):d={});this.url=a;this.start=b||0;if(c)this.end=c;this.opts=d}URLFetchable.prototype.slice=function(a,b){var c=this.start,d=this.end;c&&a?c+=a:c=a||c;return new URLFetchable(this.url,c,b&&c?c+b-1:d||b-1,this.opts)};
+URLFetchable.prototype.fetch=function(a,b,c){var d=this;b=b||1;if(b>3)return a(null);var e=new XMLHttpRequest,f;e.open("GET",this.url,!0);e.overrideMimeType("text/plain; charset=x-user-defined");this.end&&(e.setRequestHeader("Range","bytes="+this.start+"-"+this.end),f=this.end-this.start+1);e.responseType="arraybuffer";e.onreadystatechange=function(){if(e.readyState==4)if(e.status==200||e.status==206)if(e.response)return a(e.response);else if(e.mozResponseArrayBuffer)return a(e.mozResponseArrayBuffer);
+else{var h=e.responseText;return f&&f!=h.length&&(!c||h.length!=c)?d.fetch(a,b+1,h.length):(alert(e.responseText),a(bstringToBuffer(e.responseText)))}else return d.fetch(a,b+1)};if(this.opts.credentials)e.withCredentials=!0;e.send("")};function bstringToBuffer(a){if(!a)return null;for(var b=new Uint8Array(a.length),c=0;c<b.length;++c)b[c]=a.charCodeAt(c);return b.buffer};var MAX_WBITS=15,DEF_WBITS=MAX_WBITS,MAX_MEM_LEVEL=9,MANY=1440,BMAX=15,PRESET_DICT=32,Z_NO_FLUSH=0,Z_PARTIAL_FLUSH=1,Z_SYNC_FLUSH=2,Z_FULL_FLUSH=3,Z_FINISH=4,Z_DEFLATED=8,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_ERRNO=-1,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR=-5,Z_VERSION_ERROR=-6,METHOD=0,FLAG=1,DICT4=2,DICT3=3,DICT2=4,DICT1=5,DICT0=6,BLOCKS=7,CHECK4=8,CHECK3=9,CHECK2=10,CHECK1=11,DONE=12,BAD=13,inflate_mask=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],
+IB_TYPE=0,IB_LENS=1,IB_STORED=2,IB_TABLE=3,IB_BTREE=4,IB_DTREE=5,IB_CODES=6,IB_DRY=7,IB_DONE=8,IB_BAD=9,fixed_bl=9,fixed_bd=5,fixed_tl=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,
+7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,
+9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,
+125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,
+82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,
+8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,
+0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,
+9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],fixed_td=[80,
+5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,112,112],cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,
+129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];function ZStream(){}ZStream.prototype.inflateInit=function(a,b){a||(a=DEF_WBITS);b&&(b=!1);this.istate=new Inflate;return this.istate.inflateInit(this,b?-a:a)};ZStream.prototype.inflate=function(a){if(this.istate==null)return Z_STREAM_ERROR;return this.istate.inflate(this,a)};
+ZStream.prototype.inflateEnd=function(){if(this.istate==null)return Z_STREAM_ERROR;var a=istate.inflateEnd(this);this.istate=null;return a};ZStream.prototype.inflateSync=function(){return istate.inflateSync(this)};ZStream.prototype.inflateSetDictionary=function(a,b){return istate.inflateSetDictionary(this,a,b)};function Inflate(){this.was=[0]}
+Inflate.prototype.inflateReset=function(a){if(a==null||a.istate==null)return Z_STREAM_ERROR;a.total_in=a.total_out=0;a.msg=null;a.istate.mode=a.istate.nowrap!=0?BLOCKS:METHOD;a.istate.blocks.reset(a,null);return Z_OK};Inflate.prototype.inflateEnd=function(a){this.blocks!=null&&this.blocks.free(a);this.blocks=null;return Z_OK};
+Inflate.prototype.inflateInit=function(a,b){this.blocks=a.msg=null;nowrap=0;b<0&&(b=-b,nowrap=1);if(b<8||b>15)return this.inflateEnd(a),Z_STREAM_ERROR;this.wbits=b;a.istate.blocks=new InfBlocks(a,a.istate.nowrap!=0?null:this,1<<b);this.inflateReset(a);return Z_OK};
+Inflate.prototype.inflate=function(a,b){var c,d;if(a==null||a.istate==null||a.next_in==null)return Z_STREAM_ERROR;b=b==Z_FINISH?Z_BUF_ERROR:Z_OK;for(c=Z_BUF_ERROR;;)switch(a.istate.mode){case METHOD:if(a.avail_in==0)return c;c=b;a.avail_in--;a.total_in++;if(((a.istate.method=a.next_in[a.next_in_index++])&15)!=Z_DEFLATED){a.istate.mode=BAD;a.msg="unknown compression method";a.istate.marker=5;break}if((a.istate.method>>4)+8>a.istate.wbits){a.istate.mode=BAD;a.msg="invalid window size";a.istate.marker=
+5;break}a.istate.mode=FLAG;case FLAG:if(a.avail_in==0)return c;c=b;a.avail_in--;a.total_in++;d=a.next_in[a.next_in_index++]&255;if(((a.istate.method<<8)+d)%31!=0){a.istate.mode=BAD;a.msg="incorrect header check";a.istate.marker=5;break}if((d&PRESET_DICT)==0){a.istate.mode=BLOCKS;break}a.istate.mode=DICT4;case DICT4:if(a.avail_in==0)return c;c=b;a.avail_in--;a.total_in++;a.istate.need=(a.next_in[a.next_in_index++]&255)<<24&4278190080;a.istate.mode=DICT3;case DICT3:if(a.avail_in==0)return c;c=b;a.avail_in--;
+a.total_in++;a.istate.need+=(a.next_in[a.next_in_index++]&255)<<16&16711680;a.istate.mode=DICT2;case DICT2:if(a.avail_in==0)return c;c=b;a.avail_in--;a.total_in++;a.istate.need+=(a.next_in[a.next_in_index++]&255)<<8&65280;a.istate.mode=DICT1;case DICT1:if(a.avail_in==0)return c;a.avail_in--;a.total_in++;a.istate.need+=a.next_in[a.next_in_index++]&255;a.adler=a.istate.need;a.istate.mode=DICT0;return Z_NEED_DICT;case DICT0:return a.istate.mode=BAD,a.msg="need dictionary",a.istate.marker=0,Z_STREAM_ERROR;
+case BLOCKS:c=a.istate.blocks.proc(a,c);if(c==Z_DATA_ERROR){a.istate.mode=BAD;a.istate.marker=0;break}c==Z_OK&&(c=b);if(c!=Z_STREAM_END)return c;c=b;a.istate.blocks.reset(a,a.istate.was);if(a.istate.nowrap!=0){a.istate.mode=DONE;break}a.istate.mode=CHECK4;case CHECK4:if(a.avail_in==0)return c;c=b;a.avail_in--;a.total_in++;a.istate.need=(a.next_in[a.next_in_index++]&255)<<24&4278190080;a.istate.mode=CHECK3;case CHECK3:if(a.avail_in==0)return c;c=b;a.avail_in--;a.total_in++;a.istate.need+=(a.next_in[a.next_in_index++]&
+255)<<16&16711680;a.istate.mode=CHECK2;case CHECK2:if(a.avail_in==0)return c;c=b;a.avail_in--;a.total_in++;a.istate.need+=(a.next_in[a.next_in_index++]&255)<<8&65280;a.istate.mode=CHECK1;case CHECK1:if(a.avail_in==0)return c;c=b;a.avail_in--;a.total_in++;a.istate.need+=a.next_in[a.next_in_index++]&255;if(a.istate.was[0]!=a.istate.need){a.istate.mode=BAD;a.msg="incorrect data check";a.istate.marker=5;break}a.istate.mode=DONE;case DONE:return Z_STREAM_END;case BAD:return Z_DATA_ERROR;default:return Z_STREAM_ERROR}};
+Inflate.prototype.inflateSetDictionary=function(a,b,c){var d=0,e=c;if(a==null||a.istate==null||a.istate.mode!=DICT0)return Z_STREAM_ERROR;if(a._adler.adler32(1,b,0,c)!=a.adler)return Z_DATA_ERROR;a.adler=a._adler.adler32(0,null,0,0);e>=1<<a.istate.wbits&&(e=(1<<a.istate.wbits)-1,d=c-e);a.istate.blocks.set_dictionary(b,d,e);a.istate.mode=BLOCKS;return Z_OK};var mark=[0,0,255,255];
+Inflate.prototype.inflateSync=function(a){var b,c,d;if(a==null||a.istate==null)return Z_STREAM_ERROR;if(a.istate.mode!=BAD)a.istate.mode=BAD,a.istate.marker=0;if((b=a.avail_in)==0)return Z_BUF_ERROR;c=a.next_in_index;for(d=a.istate.marker;b!=0&&d<4;)a.next_in[c]==mark[d]?d++:d=a.next_in[c]!=0?0:4-d,c++,b--;a.total_in+=c-a.next_in_index;a.next_in_index=c;a.avail_in=b;a.istate.marker=d;if(d!=4)return Z_DATA_ERROR;b=a.total_in;c=a.total_out;this.inflateReset(a);a.total_in=b;a.total_out=c;a.istate.mode=
+BLOCKS;return Z_OK};Inflate.prototype.inflateSyncPoint=function(a){if(a==null||a.istate==null||a.istate.blocks==null)return Z_STREAM_ERROR;return a.istate.blocks.sync_point()};var INFBLOCKS_BORDER=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];
+function InfBlocks(a,b,c){this.hufts=new Int32Array(MANY*3);this.window=new Uint8Array(c);this.end=c;this.checkfn=b;this.mode=IB_TYPE;this.reset(a,null);this.index=this.table=this.left=0;this.blens=null;this.bb=new Int32Array(1);this.tb=new Int32Array(1);this.codes=new InfCodes;this.check=this.write=this.read=this.bitb=this.bitk=this.last=0;this.inftree=new InfTree}
+InfBlocks.prototype.reset=function(a,b){if(b)b[0]=this.check;this.mode==IB_CODES&&this.codes.free(a);this.mode=IB_TYPE;this.read=this.write=this.bitb=this.bitk=0;if(this.checkfn)a.adler=this.check=a._adler.adler32(0,null,0,0)};
+InfBlocks.prototype.proc=function(a,b){var c,d,e,f,h,g,i;f=a.next_in_index;h=a.avail_in;d=this.bitb;e=this.bitk;g=this.write;for(i=g<this.read?this.read-g-1:this.end-g;;)switch(this.mode){case IB_TYPE:for(;e<3;){if(h!=0)b=Z_OK;else return this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);h--;d|=(a.next_in[f++]&255)<<e;e+=8}c=d&7;this.last=c&1;switch(c>>>1){case 0:d>>>=3;e-=3;c=e&7;d>>>=c;e-=c;this.mode=IB_LENS;break;case 1:var j=
+new Int32Array(1),m=new Int32Array(1),k=[],l=[];inflate_trees_fixed(j,m,k,l,a);this.codes.init(j[0],m[0],k[0],0,l[0],0,a);d>>>=3;e-=3;this.mode=IB_CODES;break;case 2:d>>>=3;e-=3;this.mode=IB_TABLE;break;case 3:return d>>>=3,e-=3,this.mode=BAD,a.msg="invalid block type",b=Z_DATA_ERROR,this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b)}break;case IB_LENS:for(;e<32;){if(h!=0)b=Z_OK;else return this.bitb=d,this.bitk=e,a.avail_in=h,
+a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);h--;d|=(a.next_in[f++]&255)<<e;e+=8}if((~d>>>16&65535)!=(d&65535))return this.mode=BAD,a.msg="invalid stored block lengths",b=Z_DATA_ERROR,this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);this.left=d&65535;d=e=0;this.mode=left!=0?IB_STORED:this.last!=0?IB_DRY:IB_TYPE;break;case IB_STORED:if(h==0)return this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=
+f-a.next_in_index,a.next_in_index=f,write=g,this.inflate_flush(a,b);if(i==0&&(g==end&&read!=0&&(g=0,i=g<this.read?this.read-g-1:this.end-g),i==0&&(this.write=g,b=this.inflate_flush(a,b),g=this.write,i=g<this.read?this.read-g-1:this.end-g,g==this.end&&this.read!=0&&(g=0,i=g<this.read?this.read-g-1:this.end-g),i==0)))return this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);b=Z_OK;c=this.left;c>h&&(c=h);c>i&&(c=i);arrayCopy(a.next_in,
+f,window,g,c);f+=c;h-=c;g+=c;i-=c;if((this.left-=c)!=0)break;this.mode=this.last!=0?IB_DRY:IB_TYPE;break;case IB_TABLE:for(;e<14;){if(h!=0)b=Z_OK;else return this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);h--;d|=(a.next_in[f++]&255)<<e;e+=8}this.table=c=d&16383;if((c&31)>29||(c>>5&31)>29)return this.mode=IB_BAD,a.msg="too many length or distance symbols",b=Z_DATA_ERROR,this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,
+a.next_in_index=f,this.write=g,this.inflate_flush(a,b);c=258+(c&31)+(c>>5&31);if(this.blens==null||this.blens.length<c)this.blens=new Int32Array(c);else for(i=0;i<c;i++)this.blens[i]=0;d>>>=14;e-=14;this.index=0;mode=IB_BTREE;case IB_BTREE:for(;this.index<4+(this.table>>>10);){for(;e<3;){if(h!=0)b=Z_OK;else return this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);h--;d|=(a.next_in[f++]&255)<<e;e+=8}this.blens[INFBLOCKS_BORDER[this.index++]]=
+d&7;d>>>=3;e-=3}for(;this.index<19;)this.blens[INFBLOCKS_BORDER[this.index++]]=0;this.bb[0]=7;c=this.inftree.inflate_trees_bits(this.blens,this.bb,this.tb,this.hufts,a);if(c!=Z_OK){b=c;if(b==Z_DATA_ERROR)this.blens=null,this.mode=IB_BAD;this.bitb=d;this.bitk=e;a.avail_in=h;a.total_in+=f-a.next_in_index;a.next_in_index=f;write=g;return this.inflate_flush(a,b)}this.index=0;this.mode=IB_DTREE;case IB_DTREE:for(;;){c=this.table;if(!(this.index<258+(c&31)+(c>>5&31)))break;for(c=this.bb[0];e<c;){if(h!=
+0)b=Z_OK;else return this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);h--;d|=(a.next_in[f++]&255)<<e;e+=8}c=this.hufts[(this.tb[0]+(d&inflate_mask[c]))*3+1];m=this.hufts[(this.tb[0]+(d&inflate_mask[c]))*3+2];if(m<16)d>>>=c,e-=c,this.blens[this.index++]=m;else{i=m==18?7:m-14;for(j=m==18?11:3;e<c+i;){if(h!=0)b=Z_OK;else return this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,
+b);h--;d|=(a.next_in[f++]&255)<<e;e+=8}d>>>=c;e-=c;j+=d&inflate_mask[i];d>>>=i;e-=i;i=this.index;c=this.table;if(i+j>258+(c&31)+(c>>5&31)||m==16&&i<1)return this.blens=null,this.mode=IB_BAD,a.msg="invalid bit length repeat",b=Z_DATA_ERROR,this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);m=m==16?this.blens[i-1]:0;do this.blens[i++]=m;while(--j!=0);this.index=i}}this.tb[0]=-1;j=new Int32Array(1);m=new Int32Array(1);k=new Int32Array(1);
+l=new Int32Array(1);j[0]=9;m[0]=6;c=this.table;c=this.inftree.inflate_trees_dynamic(257+(c&31),1+(c>>5&31),this.blens,j,m,k,l,this.hufts,a);if(c!=Z_OK){if(c==Z_DATA_ERROR)this.blens=null,this.mode=BAD;b=c;this.bitb=d;this.bitk=e;a.avail_in=h;a.total_in+=f-a.next_in_index;a.next_in_index=f;this.write=g;return this.inflate_flush(a,b)}this.codes.init(j[0],m[0],this.hufts,k[0],this.hufts,l[0],a);this.mode=IB_CODES;case IB_CODES:this.bitb=d;this.bitk=e;a.avail_in=h;a.total_in+=f-a.next_in_index;a.next_in_index=
+f;this.write=g;if((b=this.codes.proc(this,a,b))!=Z_STREAM_END)return this.inflate_flush(a,b);b=Z_OK;this.codes.free(a);f=a.next_in_index;h=a.avail_in;d=this.bitb;e=this.bitk;g=this.write;i=g<this.read?this.read-g-1:this.end-g;if(this.last==0){this.mode=IB_TYPE;break}this.mode=IB_DRY;case IB_DRY:this.write=g;b=this.inflate_flush(a,b);g=this.write;if(this.read!=this.write)return this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);
+mode=DONE;case IB_DONE:return b=Z_STREAM_END,this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);case IB_BAD:return b=Z_DATA_ERROR,this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b);default:return b=Z_STREAM_ERROR,this.bitb=d,this.bitk=e,a.avail_in=h,a.total_in+=f-a.next_in_index,a.next_in_index=f,this.write=g,this.inflate_flush(a,b)}};
+InfBlocks.prototype.free=function(a){this.reset(a,null);this.hufts=this.window=null};InfBlocks.prototype.set_dictionary=function(a,b,c){arrayCopy(a,b,window,0,c);this.read=this.write=c};InfBlocks.prototype.sync_point=function(){return this.mode==IB_LENS};
+InfBlocks.prototype.inflate_flush=function(a,b){var c,d,e;d=a.next_out_index;e=this.read;c=(e<=this.write?this.write:this.end)-e;if(c>a.avail_out)c=a.avail_out;c!=0&&b==Z_BUF_ERROR&&(b=Z_OK);a.avail_out-=c;a.total_out+=c;if(this.checkfn!=null)a.adler=this.check=a._adler.adler32(this.check,this.window,e,c);arrayCopy(this.window,e,a.next_out,d,c);d+=c;e+=c;if(e==this.end){e=0;if(this.write==this.end)this.write=0;c=this.write-e;if(c>a.avail_out)c=a.avail_out;c!=0&&b==Z_BUF_ERROR&&(b=Z_OK);a.avail_out-=
+c;a.total_out+=c;if(this.checkfn!=null)a.adler=this.check=a._adler.adler32(this.check,this.window,e,c);arrayCopy(this.window,e,a.next_out,d,c);d+=c;e+=c}a.next_out_index=d;this.read=e;return b};var IC_START=0,IC_LEN=1,IC_LENEXT=2,IC_DIST=3,IC_DISTEXT=4,IC_COPY=5,IC_LIT=6,IC_WASH=7,IC_END=8,IC_BADCODE=9;function InfCodes(){}InfCodes.prototype.init=function(a,b,c,d,e,f){this.mode=IC_START;this.lbits=a;this.dbits=b;this.ltree=c;this.ltree_index=d;this.dtree=e;this.dtree_index=f;this.tree=null};
+InfCodes.prototype.proc=function(a,b,c){var d,e,f=0,h=0,g=0,i,j,m;g=b.next_in_index;i=b.avail_in;f=a.bitb;h=a.bitk;j=a.write;for(m=j<a.read?a.read-j-1:a.end-j;;)switch(this.mode){case IC_START:if(m>=258&&i>=10&&(a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,c=this.inflate_fast(this.lbits,this.dbits,this.ltree,this.ltree_index,this.dtree,this.dtree_index,a,b),g=b.next_in_index,i=b.avail_in,f=a.bitb,h=a.bitk,j=a.write,m=j<a.read?a.read-j-1:a.end-j,c!=Z_OK)){this.mode=
+c==Z_STREAM_END?IC_WASH:IC_BADCODE;break}this.need=this.lbits;this.tree=this.ltree;this.tree_index=this.ltree_index;this.mode=IC_LEN;case IC_LEN:for(d=this.need;h<d;){if(i!=0)c=Z_OK;else return a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,c);i--;f|=(b.next_in[g++]&255)<<h;h+=8}d=(this.tree_index+(f&inflate_mask[d]))*3;f>>>=this.tree[d+1];h-=this.tree[d+1];e=this.tree[d];if(e==0){this.lit=this.tree[d+2];this.mode=IC_LIT;break}if((e&16)!=
+0){this.get=e&15;this.len=this.tree[d+2];this.mode=IC_LENEXT;break}if((e&64)==0){this.need=e;this.tree_index=d/3+this.tree[d+2];break}if((e&32)!=0){this.mode=IC_WASH;break}this.mode=IC_BADCODE;b.msg="invalid literal/length code";c=Z_DATA_ERROR;a.bitb=f;a.bitk=h;b.avail_in=i;b.total_in+=g-b.next_in_index;b.next_in_index=g;a.write=j;return a.inflate_flush(b,c);case IC_LENEXT:for(d=this.get;h<d;){if(i!=0)c=Z_OK;else return a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=
+g,a.write=j,a.inflate_flush(b,c);i--;f|=(b.next_in[g++]&255)<<h;h+=8}this.len+=f&inflate_mask[d];f>>=d;h-=d;this.need=this.dbits;this.tree=this.dtree;this.tree_index=this.dtree_index;this.mode=IC_DIST;case IC_DIST:for(d=this.need;h<d;){if(i!=0)c=Z_OK;else return a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,c);i--;f|=(b.next_in[g++]&255)<<h;h+=8}d=(this.tree_index+(f&inflate_mask[d]))*3;f>>=this.tree[d+1];h-=this.tree[d+1];e=this.tree[d];
+if((e&16)!=0){this.get=e&15;this.dist=this.tree[d+2];this.mode=IC_DISTEXT;break}if((e&64)==0){this.need=e;this.tree_index=d/3+this.tree[d+2];break}this.mode=IC_BADCODE;b.msg="invalid distance code";c=Z_DATA_ERROR;a.bitb=f;a.bitk=h;b.avail_in=i;b.total_in+=g-b.next_in_index;b.next_in_index=g;a.write=j;return a.inflate_flush(b,c);case IC_DISTEXT:for(d=this.get;h<d;){if(i!=0)c=Z_OK;else return a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,
+c);i--;f|=(b.next_in[g++]&255)<<h;h+=8}this.dist+=f&inflate_mask[d];f>>=d;h-=d;this.mode=IC_COPY;case IC_COPY:for(d=j-this.dist;d<0;)d+=a.end;for(;this.len!=0;){if(m==0&&(j==a.end&&a.read!=0&&(j=0,m=j<a.read?a.read-j-1:a.end-j),m==0&&(a.write=j,c=a.inflate_flush(b,c),j=a.write,m=j<a.read?a.read-j-1:a.end-j,j==a.end&&a.read!=0&&(j=0,m=j<a.read?a.read-j-1:a.end-j),m==0)))return a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,c);a.window[j++]=
+a.window[d++];m--;d==a.end&&(d=0);this.len--}this.mode=IC_START;break;case IC_LIT:if(m==0&&(j==a.end&&a.read!=0&&(j=0,m=j<a.read?a.read-j-1:a.end-j),m==0&&(a.write=j,c=a.inflate_flush(b,c),j=a.write,m=j<a.read?a.read-j-1:a.end-j,j==a.end&&a.read!=0&&(j=0,m=j<a.read?a.read-j-1:a.end-j),m==0)))return a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,c);c=Z_OK;a.window[j++]=this.lit;m--;this.mode=IC_START;break;case IC_WASH:h>7&&(h-=8,i++,g--);
+a.write=j;c=a.inflate_flush(b,c);j=a.write;if(a.read!=a.write)return a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,c);this.mode=IC_END;case IC_END:return c=Z_STREAM_END,a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,c);case IC_BADCODE:return c=Z_DATA_ERROR,a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,c);default:return c=
+Z_STREAM_ERROR,a.bitb=f,a.bitk=h,b.avail_in=i,b.total_in+=g-b.next_in_index,b.next_in_index=g,a.write=j,a.inflate_flush(b,c)}};InfCodes.prototype.free=function(){};
+InfCodes.prototype.inflate_fast=function(a,b,c,d,e,f,h,g){var i,j,m,k,l,n,q,o,s,u,p,r;n=g.next_in_index;q=g.avail_in;k=h.bitb;l=h.bitk;o=h.write;s=o<h.read?h.read-o-1:h.end-o;a=inflate_mask[a];u=inflate_mask[b];do{for(;l<20;)q--,k|=(g.next_in[n++]&255)<<l,l+=8;i=k&a;j=c;m=d;r=(m+i)*3;if((b=j[r])==0)k>>=j[r+1],l-=j[r+1],h.window[o++]=j[r+2],s--;else{do{k>>=j[r+1];l-=j[r+1];if((b&16)!=0){b&=15;p=j[r+2]+(k&inflate_mask[b]);k>>=b;for(l-=b;l<15;)q--,k|=(g.next_in[n++]&255)<<l,l+=8;i=k&u;j=e;m=f;r=(m+i)*
+3;b=j[r];do if(k>>=j[r+1],l-=j[r+1],(b&16)!=0){for(b&=15;l<b;)q--,k|=(g.next_in[n++]&255)<<l,l+=8;i=j[r+2]+(k&inflate_mask[b]);k>>=b;l-=b;s-=p;if(o>=i)i=o-i,h.window[o++]=h.window[i++],h.window[o++]=h.window[i++],p-=2;else{i=o-i;do i+=h.end;while(i<0);b=h.end-i;if(p>b){p-=b;if(o-i>0&&b>o-i){do h.window[o++]=h.window[i++];while(--b!=0)}else arrayCopy(h.window,i,h.window,o,b),o+=b;i=0}}do h.window[o++]=h.window[i++];while(--p!=0);break}else if((b&64)==0)i+=j[r+2],i+=k&inflate_mask[b],r=(m+i)*3,b=j[r];
+else return g.msg="invalid distance code",p=g.avail_in-q,p=l>>3<p?l>>3:p,q+=p,n-=p,l-=p<<3,h.bitb=k,h.bitk=l,g.avail_in=q,g.total_in+=n-g.next_in_index,g.next_in_index=n,h.write=o,Z_DATA_ERROR;while(1);break}if((b&64)==0){if(i+=j[r+2],i+=k&inflate_mask[b],r=(m+i)*3,(b=j[r])==0){k>>=j[r+1];l-=j[r+1];h.window[o++]=j[r+2];s--;break}}else return(b&32)!=0?(p=g.avail_in-q,p=l>>3<p?l>>3:p,q+=p,n-=p,l-=p<<3,h.bitb=k,h.bitk=l,g.avail_in=q,g.total_in+=n-g.next_in_index,g.next_in_index=n,h.write=o,Z_STREAM_END):
+(g.msg="invalid literal/length code",p=g.avail_in-q,p=l>>3<p?l>>3:p,q+=p,n-=p,l-=p<<3,h.bitb=k,h.bitk=l,g.avail_in=q,g.total_in+=n-g.next_in_index,g.next_in_index=n,h.write=o,Z_DATA_ERROR)}while(1)}}while(s>=258&&q>=10);p=g.avail_in-q;p=l>>3<p?l>>3:p;q+=p;n-=p;l-=p<<3;h.bitb=k;h.bitk=l;g.avail_in=q;g.total_in+=n-g.next_in_index;g.next_in_index=n;h.write=o;return Z_OK};function InfTree(){}
+InfTree.prototype.huft_build=function(a,b,c,d,e,f,h,g,i,j,m){var k,l,n,q,o,s,u,p,r;s=0;l=c;do this.c[a[b+s]]++,s++,l--;while(l!=0);if(this.c[0]==c)return h[0]=-1,g[0]=0,Z_OK;o=g[0];for(n=1;n<=BMAX;n++)if(this.c[n]!=0)break;q=n;o<n&&(o=n);for(l=BMAX;l!=0;l--)if(this.c[l]!=0)break;j=l;o>l&&(o=l);g[0]=o;for(g=1<<n;n<l;n++,g<<=1)if((g-=this.c[n])<0)return Z_DATA_ERROR;if((g-=this.c[l])<0)return Z_DATA_ERROR;this.c[l]+=g;this.x[1]=n=0;s=1;for(u=2;--l!=0;)this.x[u]=n+=this.c[s],u++,s++;s=l=0;do{if((n=a[b+
+s])!=0)this.v[this.x[n]++]=l;s++}while(++l<c);c=this.x[j];s=this.x[0]=l=0;b=-1;p=-o;for(r=u=this.u[0]=0;q<=j;q++)for(a=this.c[q];a--!=0;){for(;q>p+o;){b++;p+=o;r=j-p;r=r>o?o:r;if((k=1<<(n=q-p))>a+1)if(k-=a+1,u=q,n<r)for(;++n<r;){if((k<<=1)<=this.c[++u])break;k-=this.c[u]}r=1<<n;if(this.hn[0]+r>MANY)return Z_DATA_ERROR;this.u[b]=u=this.hn[0];this.hn[0]+=r;b!=0?(this.x[b]=l,this.r[0]=n,this.r[1]=o,n=l>>>p-o,this.r[2]=u-this.u[b-1]-n,arrayCopy(this.r,0,i,(this.u[b-1]+n)*3,3)):h[0]=u}this.r[1]=q-p;s>=
+c?this.r[0]=192:m[s]<d?(this.r[0]=this.v[s]<256?0:96,this.r[2]=this.v[s++]):(this.r[0]=f[this.v[s]-d]+16+64,this.r[2]=e[this.v[s++]-d]);k=1<<q-p;for(n=l>>>p;n<r;n+=k)arrayCopy(this.r,0,i,(u+n)*3,3);for(n=1<<q-1;(l&n)!=0;n>>>=1)l^=n;l^=n;for(n=(1<<p)-1;(l&n)!=this.x[b];)b--,p-=o,n=(1<<p)-1}return g!=0&&j!=1?Z_BUF_ERROR:Z_OK};
+InfTree.prototype.inflate_trees_bits=function(a,b,c,d,e){this.initWorkArea(19);this.hn[0]=0;a=this.huft_build(a,0,19,19,null,null,c,b,d,this.hn,this.v);if(a==Z_DATA_ERROR)e.msg="oversubscribed dynamic bit lengths tree";else if(a==Z_BUF_ERROR||b[0]==0)e.msg="incomplete dynamic bit lengths tree",a=Z_DATA_ERROR;return a};
+InfTree.prototype.inflate_trees_dynamic=function(a,b,c,d,e,f,h,g,i){this.initWorkArea(288);this.hn[0]=0;f=this.huft_build(c,0,a,257,cplens,cplext,f,d,g,this.hn,this.v);if(f!=Z_OK||d[0]==0){if(f==Z_DATA_ERROR)i.msg="oversubscribed literal/length tree";else if(f!=Z_MEM_ERROR)i.msg="incomplete literal/length tree",f=Z_DATA_ERROR;return f}this.initWorkArea(288);f=this.huft_build(c,a,b,0,cpdist,cpdext,h,e,g,this.hn,this.v);if(f!=Z_OK||e[0]==0&&a>257){if(f==Z_DATA_ERROR)i.msg="oversubscribed distance tree";
+else if(f==Z_BUF_ERROR)i.msg="incomplete distance tree",f=Z_DATA_ERROR;else if(f!=Z_MEM_ERROR)i.msg="empty distance tree with lengths",f=Z_DATA_ERROR;return f}return Z_OK};function inflate_trees_fixed(a,b,c,d){a[0]=fixed_bl;b[0]=fixed_bd;c[0]=fixed_tl;d[0]=fixed_td;return Z_OK}
+InfTree.prototype.initWorkArea=function(a){if(this.hn==null)this.hn=new Int32Array(1),this.v=new Int32Array(a),this.c=new Int32Array(BMAX+1),this.r=new Int32Array(3),this.u=new Int32Array(BMAX),this.x=new Int32Array(BMAX+1);if(this.v.length<a)this.v=new Int32Array(a);for(var b=0;b<a;b++)this.v[b]=0;for(b=0;b<BMAX+1;b++)this.c[b]=0;for(b=0;b<3;b++)this.r[b]=0;arrayCopy(this.c,0,this.u,0,BMAX);arrayCopy(this.c,0,this.x,0,BMAX+1)};
+var testArray=new Uint8Array(1),hasSubarray=typeof testArray.subarray==="function",hasSlice=!1;function arrayCopy(a,b,c,d,e){if(e!=0){if(a){if(!c)throw"Undef dest";}else throw"Undef src";b==0&&e==a.length?arrayCopy_fast(a,c,d):hasSubarray?arrayCopy_fast(a.subarray(b,b+e),c,d):a.BYTES_PER_ELEMENT==1&&e>100?arrayCopy_fast(new Uint8Array(a.buffer,a.byteOffset+b,e),c,d):arrayCopy_slow(a,b,c,d,e)}}function arrayCopy_slow(a,b,c,d,e){for(var f=0;f<e;++f)c[d+f]=a[b+f]}
+function arrayCopy_fast(a,b,c){b.set(a,c)}var ADLER_BASE=65521,ADLER_NMAX=5552;
+function adler32(a,b,c,d){if(b==null)return 1;var e=a&65535;a=a>>16&65535;for(var f;d>0;){f=d<ADLER_NMAX?d:ADLER_NMAX;for(d-=f;f>=16;)e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,e+=b[c++]&255,a+=e,f-=16;if(f!=0){do e+=b[c++]&255,a+=e;while(--f!=0)}e%=ADLER_BASE;
+a%=ADLER_BASE}return a<<16|e}
+function jszlib_inflate_buffer(a,b,c,d){a=b?new Uint8Array(a,b,c):new Uint8Array(a);c=new ZStream;c.inflateInit(DEF_WBITS,!0);c.next_in=a;c.next_in_index=0;c.avail_in=a.length;a=[];for(var e=0;;){var f=new Uint8Array(32E3);c.next_out=f;c.next_out_index=0;c.avail_out=f.length;var h=c.inflate(Z_NO_FLUSH);if(h!=Z_OK&&h!=Z_STREAM_END)throw c.msg;if(c.avail_out!=0){var g=new Uint8Array(f.length-c.avail_out);arrayCopy(f,0,g,0,f.length-c.avail_out);f=g}a.push(f);e+=f.length;if(h==Z_STREAM_END)break}d&&(d[0]=
+(b||0)+c.next_in_index);if(a.length==1)return a[0].buffer;else{b=new Uint8Array(e);for(c=d=0;c<a.length;++c)e=a[c],arrayCopy(e,0,b,d,e.length),d+=e.length;return b.buffer}};(function(){var a=!1,b=/xyz/.test(function(){})?/\b_super\b/:/.*/;this.Class=function(){};Class.extend=function(c){function d(){!a&&this.init&&this.init.apply(this,arguments)}var e=this.prototype;a=!0;var f=new this;a=!1;for(var h in c)f[h]=typeof c[h]=="function"&&typeof e[h]=="function"&&b.test(c[h])?function(a,b){return function(){var c=this._super;this._super=e[a];var d=b.apply(this,arguments);this._super=c;return d}}(h,c[h]):c[h];d.prototype=f;d.constructor=d;d.extend=arguments.callee;return d}})();var SCRIBL={};SCRIBL.chars={};SCRIBL.chars.nt_color="white";SCRIBL.chars.nt_A_bg="red";SCRIBL.chars.nt_G_bg="blue";SCRIBL.chars.nt_C_bg="green";SCRIBL.chars.nt_T_bg="black";SCRIBL.chars.nt_N_bg="purple";SCRIBL.chars.nt_dash_bg="rgb(120,120,120)";SCRIBL.chars.heights=[];SCRIBL.chars.canvasHolder=document.createElement("canvas");
+var Scribl=Class.extend({init:function(a,b){this.scrolled=!1;var c=a.getContext("2d");this.width=b;this.uid=_uniqueId("chart");this.laneSizes=50;this.laneBuffer=5;this.trackBuffer=25;this.offset=void 0;this.canvas=a;this.ctx=c;this.scale={};this.scale.pretty=!0;this.scale.max=void 0;this.scale.min=void 0;this.scale.auto=!0;this.scale.userControlled=!1;this.scale.positions=[0];this.scale.off=!1;this.scale.size=15;this.scale.font={};this.scale.font.size=15;this.scale.font.color="black";this.scale.font.buffer=
+10;this.glyph={};this.glyph.roundness=6;this.glyph.borderWidth=1;this.glyph.color=["#99CCFF","rgb(63, 128, 205)"];this.glyph.text={};this.glyph.text.color="black";this.glyph.text.size="13";this.glyph.text.font="arial";this.glyph.text.align="center";this.gene={};this.gene.text={};this.protein={};this.protein.text={};this.events={};this.events.hasClick=!1;this.events.hasMouseover=!1;this.events.clicks=[];this.events.mouseovers=[];this.events.added=!1;this.tick={};this.tick.auto=!0;this.tick.major={};
+this.tick.major.size=10;this.tick.major.color="black";this.tick.minor={};this.tick.minor.size=1;this.tick.minor.color="rgb(55,55,55)";this.tick.halfColor="rgb(10,10,10)";this.tooltips={};this.tooltips.text={};this.tooltips.text.font="arial";this.tooltips.text.size=12;this.tooltips.borderWidth=1;this.tooltips.roundness=5;this.tooltips.fade=!1;this.tooltips.style="light";this.lastToolTips=[];this.scrollable=!1;this.scrollValues=[0,void 0];this.chars={};this.chars.drawOnBuild=[];this.drawStyle="expand";
+this.myMouseEventHandler=new MouseEventHandler(this);this.tracks=[]},getScaleHeight:function(){return this.scale.font.size+this.scale.size},getHeight:function(){var a=0;this.scale.off||(a+=this.getScaleHeight());for(var b=this.tracks.length,c=0;c<b;c++)a+=this.trackBuffer,a+=this.tracks[c].getHeight();return a},addScale:function(){this.scale.userControlled?this.scale.positions.push(this.tracks.length):(this.scale.positions=[this.tracks.length],this.scale.userControlled=!0)},addTrack:function(){var a=
+new Track(this.ctx);a.chart=this;if(this.tracks.length==1&&this.tracks[0]==void 0)this.tracks=[];this.tracks.push(a);return a},removeTrack:function(a){for(var b=0;b<this.tracks.length;b++)a.uid==this.tracks[b].uid&&this.tracks.splice(b,1);delete a},loadGenbank:function(a){genbank(a,this)},loadBed:function(a){bed(a,this)},loadBam:function(a,b,c,d,e){var f=this,h=f.addTrack();h.status="waiting";makeBam(new BlobFetchable(a),new BlobFetchable(b),function(a){f.file=a;a.fetch(c,d,e,function(a,b){if(a){for(var c=
+0;c<a.length;c+=1)h.addFeature(new BlockArrow("bam",a[c].pos,a[c].lengthOnRef,"+",{seq:a[c].seq}));h.status="received";h.drawOnResponse&&f.redraw()}b&&alert("error: "+b)})});return h},loadFeatures:function(a){for(var b=0;b<a.length;b++)this.addFeature(a[b])},addGene:function(a,b,c,d){return this.addFeature(new BlockArrow("gene",a,b,c,d))},addProtein:function(a,b,c,d){return this.addFeature(new BlockArrow("protein",a,b,c,d))},addFeature:function(a){(this.tracks[0]||this.addTrack()).addFeature(a);return a},
+slice:function(a,b,c){c=c||"inclusive";for(var d=this.tracks.length,e=new Scribl(this.canvas,this.width),f=0;f<d;f++){var h=this.tracks[f],g=e.addTrack();g.drawStyle=h.drawStyle;for(var i=h.lanes.length,j=0;j<i;j++){newLane=g.addLane();for(var m=h.lanes[j].features,k=0;k<m.length;k++){var l=m[k].position+m[k].length,n=m[k].position;if(c=="inclusive")n>=a&&n<=b?newLane.addFeature(m[k].clone()):l>a&&l<b?newLane.addFeature(m[k].clone()):n<a&&l>b?newLane.addFeature(m[k].clone()):n>a&&l<b&&newLane.addFeature(m[k].clone());
+else if(c=="strict")if(n>=a&&n<=b)if(l>a&&l<b)newLane.addFeature(m[k].clone());else{var q=m[k].clone();q.length=Math.abs(b-n);newLane.addFeature(q)}else if(l>a&&l<b)q=m[k].clone(),q.position=a,q.length=Math.abs(l-a),newLane.addFeature(q);else{if(n<a&&l>b)q=m[k].clone(),q.position=a,q.length=Math.abs(b-a),newLane.addFeature(q)}else c=="exclusive"&&n>=a&&n<=b&&l>a&&l<b&&newLane.addFeature(m[k].clone())}}}e.scale.min=this.scale.min;e.scale.max=this.scale.max;e.offset=this.offset;e.scale.off=this.scale.off;
+e.scale.pretty=this.scale.pretty;e.laneSizes=this.laneSizes;e.drawStyle=this.drawStyle;e.glyph=this.glyph;return e},draw:function(){var a=this.ctx,b=this.tracks;this.scrollable==!0&&this.initScrollable();a.save();if(this.scale.pretty){if(this.tick.auto)this.tick.major.size=this.determineMajorTick(),this.tick.minor.size=Math.round(this.tick.major.size/10);if(this.scale.auto)this.scale.min-=this.scale.min%this.tick.major.size,this.scale.max=Math.round(this.scale.max/this.tick.major.size+0.4)*this.tick.major.size}if(this.offset==
+void 0)this.offset=Math.ceil(a.measureText("0").width/2+10);a.save();for(var c=0;c<b.length;c++)!this.scale.off&&this.scale.positions.indexOf(c)!=-1&&this.drawScale(),b[c].draw();!this.scale.off&&this.scale.positions.indexOf(b.length)!=-1&&this.drawScale();a.restore();a.restore();this.events.added||this.registerEventListeners()},redraw:function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.tracks.length>0&&this.draw()},drawScale:function(){var a=this.ctx,b=a.fillStyle,c=this.scale.font.size+
+this.scale.size,d=this.scale.font.size+2,e=this.scale.font.size+this.scale.size*0.66,f=this.scale.font.size+this.scale.size*0.33;a.font=this.scale.font.size+"px arial";a.textBaseline="top";a.fillStyle=this.scale.font.color;for(var h=this.scale.min%this.tick.minor.size==0?this.scale.min:this.scale.min-this.scale.min%this.tick.minor.size+this.tick.minor.size;h<=this.scale.max;h+=this.tick.minor.size){a.beginPath();var g=this.pixelsToNts(h-this.scale.min)+this.offset;if(h%this.tick.major.size==0){var i=
+this.getTickText(h);a.textAlign="center";a.fillText(i,g,0);a.moveTo(g,c);a.lineTo(g,d);a.strokeStyle=this.tick.major.color}else a.moveTo(g,c),h%(this.tick.major.size/2)==0?(a.strokeStyle=this.tick.halfColor,a.lineTo(g,f)):(a.strokeStyle=this.tick.minor.color,a.lineTo(g,e));a.stroke()}a.fillStyle=b;a.translate(0,this.getScaleHeight()+this.laneBuffer)},pixelsToNts:function(a){return a==void 0?this.width/(this.scale.max-this.scale.min):this.width/(this.scale.max-this.scale.min)*a},ntsToPixels:function(a){return a==
+void 0?1/this.pixelsToNts():a/this.width},initScrollable:function(){var a;if(!this.scrolled){a=document.createElement("div");var b=document.createElement("div"),c=document.createElement("div");c.id="scribl-zoom-slider";c.className="slider";c.style.cssFloat="left";c.style.height=new String(this.canvas.height*0.5)+"px";c.style.margin="30px auto auto -20px";a.style.cssText=this.canvas.style.cssText;this.canvas.style.cssText="";parentWidth=parseInt(this.canvas.width)+25;a.style.width=parentWidth+"px";
+b.style.width=this.canvas.width+"px";b.style.overflow="auto";b.id="scroll-wrapper";this.canvas.parentNode.replaceChild(a,this.canvas);a.appendChild(c);b.appendChild(this.canvas);a.appendChild(b);jQuery(b).dragscrollable({dragSelector:"canvas:first",acceptPropagatedEvent:!1})}b=this.scale.max-this.scale.min;var d=this.scrollValues[1]||this.scale.max-b*0.35;a=this.scrollValues[0]!=void 0?this.scrollValues[0]:this.scale.max+b*0.35;var e=(d-a)/document.getElementById("scroll-wrapper").style.width.split("px")[0];
+e=b/e||100;this.canvas.width=e;this.width=e-30;schart=this;d=(d-a)/(this.scale.max-this.scale.min)*100||1;jQuery(c).slider({orientation:"vertical",range:"min",min:1,max:100,value:d,slide:function(a,b){var c=schart.scale.max-schart.scale.min,d=b.value/100*schart.canvas.width,e=document.getElementById("scroll-wrapper");e=e.scrollLeft+parseInt(e.style.width.split("px")[0])/2;schart.scrollValues=[schart.scale.min+(e-d/2)/schart.canvas.width*c,schart.scale.min+(e+d/2)/schart.canvas.width*c];schart.ctx.clearRect(0,
+0,schart.canvas.width,schart.canvas.height);schart.draw()}});c=(a-this.scale.min)/b*this.canvas.width;document.getElementById("scroll-wrapper").scrollLeft=c;this.scrolled=!0},determineMajorTick:function(){this.ctx.font=this.scale.font.size+"px arial";var a=(this.scale.max-this.scale.min)/(this.width/(this.ctx.measureText(this.getTickTextDecimalPlaces(this.scale.max)).width+this.scale.font.buffer)),b=Math.pow(10,parseInt(a).toString().length-1);this.tick.major.size=Math.ceil(a/b)*b;a=Math.pow(10,(this.tick.major.size+
+"").length);b=this.tick.major.size/a;b>0.1&&b<=0.5?b=0.5:b>0.5&&(b=1);return b*a},getTickText:function(a){if(!this.tick.auto)return a;var b=a;a>=1E6?(a=Math.pow(10,5),b=Math.round(b/1E6*a)/a+"m"):a>=1E3&&(a=Math.pow(10,2),b=Math.round(b/1E3*a)/a+"k");return b},getTickTextDecimalPlaces:function(a){if(!this.tick.auto)return a;var b=a;a>=1E6?b=Math.round(b/(1E6/Math.pow(10,5)))+"m":a>=1E3&&(b=Math.round(b/(1E3/Math.pow(10,2)))+"k");return b},handleMouseEvent:function(a,b){this.myMouseEventHandler.setMousePosition(a);
+for(var c=this.myMouseEventHandler.mouseY,d,e=0;e<this.tracks.length;e++)for(var f=0;f<this.tracks[e].lanes.length;f++){var h=this.tracks[e].lanes[f].getPixelPositionY(),g=h+this.tracks[e].lanes[f].getHeight();if(c>=h&&c<=g){d=this.tracks[e].lanes[f];break}}if(d){e=d.track.getDrawStyle();if(e=="collapse")this.redraw();else if(e!="line"){this.ctx.save();d.erase();this.ctx.translate(0,d.getPixelPositionY());for(d.draw();e=this.lastToolTips.pop();)this.ctx.putImageData(e.pixels,e.x,e.y);this.ctx.restore()}d=
+b=="click"?this.events.clicks:this.events.mouseovers;for(e=0;e<d.length;e++)d[e](this);this.myMouseEventHandler.reset(this)}},addClickEventListener:function(a){this.events.clicks.push(a)},addMouseoverEventListener:function(a){this.events.mouseovers.push(a)},removeEventListeners:function(a){a=="mouseover"?this.canvas.removeEventListener("mousemove",this.mouseHandler):a=="click"&&this.canvas.removeEventListener("click",this.clickHandler)},registerEventListeners:function(){var a=this;a.mouseHandler=
+function(b){a.handleMouseEvent(b,"mouseover")};a.clickHandler=function(b){a.handleMouseEvent(b,"click")};this.events.mouseovers.length>0&&(this.canvas.removeEventListener("mousemove",a.mouseHandler),this.canvas.addEventListener("mousemove",a.mouseHandler,!1));this.events.clicks.length>0&&this.canvas.addEventListener("click",a.clickHandler,!1);this.events.added=!0}});var Track=Class.extend({init:function(a){this.lanes=[];this.ctx=a;this.uid=_uniqueId("track");this.drawStyle=void 0;this.hide=!1;this.coverageData=[];this.maxDepth=0},addLane:function(){var a=new Lane(this.ctx,this);this.lanes.push(a);return a},addGene:function(a,b,c,d){return this.addFeature(new BlockArrow("gene",a,b,c,d))},addProtein:function(a,b,c,d){return this.addFeature(new BlockArrow("protein",a,b,c,d))},addFeature:function(a){for(var b,c=!0,d=0;d<this.lanes.length;d++){var e=this.lanes[d].features[this.lanes[d].features.length-
+1];if(e!=void 0&&a.position-3/this.chart.pixelsToNts()>e.position+e.length){c=!1;b=this.lanes[d];break}}c&&(b=this.addLane());b.addFeature(a);return a},hide:function(){this.hide=!0},unhide:function(){this.hide=!1},getDrawStyle:function(){return this.drawStyle?this.drawStyle:this.chart.drawStyle},getHeight:function(){var a=0,b=this.lanes.length,c=this.chart.laneBuffer,d=this.getDrawStyle();if(d=="line"||d=="collapse")b=1;for(d=0;d<b;d++)a+=c,a+=this.lanes[d].getHeight();a-=c;return a},getPixelPositionY:function(){var a;
+a=this.chart.scale.off?0:this.chart.getScaleHeight()+this.chart.laneBuffer;for(var b=0;b<this.chart.tracks.length;b++){if(this.uid==this.chart.tracks[b].uid)break;a+=this.chart.trackBuffer;a+=this.chart.tracks[b].getHeight()}return a},calcCoverageData:function(){for(var a=this.lanes,b=0;b<a.length;b++)for(var c=0;c<a[b].features.length;c++){var d=a[b].features[c],e=Math.round(d.getPixelPositionX());for(d=Math.round(e+d.getPixelLength());e<=d;e++)this.coverageData[e]=this.coverageData[e]+1||1,this.maxDepth=
+Math.max(this.coverageData[e],this.maxDepth)}},erase:function(){this.chart.ctx.clearRect(0,this.getPixelPositionY(),this.chart.width,this.getHeight())},draw:function(){if(this.status=="waiting")this.drawOnResponse=!0;else if(!this.hide){var a=this.getDrawStyle(),b=this.chart.laneSizes,c=this.lanes,d=this.chart.laneBuffer,e=this.chart.trackBuffer,f=b+e,h=this.ctx;if(a==void 0||a=="expand")for(a=0;a<c.length;a++)c[a].y=f,c[a].draw(),b=c[a].getHeight(),h.translate(0,b+d),f=f+b+d;else if(a=="collapse"){b=
+[];for(a=0;a<c.length;a++)b=b.concat(c[a].features);b.sort(function(a,b){return a.position-b.position});for(f=0;f<b.length;f++){a=b[f].length;var g=b[f].name,i=void 0;for(i=f+1;i<b.length;i++)if(b[f].getEnd()>=b[i].position)b[f].length=Math.max(b[f].getEnd(),b[i].getEnd())-b[f].position,b[f].name="";else break;b[f].draw();b[f].length=a;b[f].name=g;f=i-1}c.length>0&&h.translate(0,c[0].getHeight()+d)}else if(a=="line"){this.coverageData.length==0&&this.calcCoverageData();f=this.maxDepth;h.beginPath();
+for(a=this.chart.offset;a<=this.chart.width+this.chart.offset;a++)g=this.coverageData[a]/f*b||0,g=b-g,h.lineTo(a,g);h.lineTo(this.chart.width+this.chart.offset,b);h.stroke();h.translate(0,c[0].getHeight()+d)}h.translate(0,e-d)}}});var Lane=Class.extend({init:function(a,b){this.height=void 0;this.features=[];this.ctx=a;this.track=b;this.chart=b.chart;this.uid=_uniqueId("lane")},addGene:function(a,b,c,d){return this.addFeature(new BlockArrow("gene",a,b,c,d))},addProtein:function(a,b,c,d){return this.addFeature(new BlockArrow("protein",a,b,c,d))},addFeature:function(a){a.lane=this;this.features.push(a);this.chart[a.type]||(this.chart[a.type]={text:{}});if(a.length+a.position>this.chart.scale.max||!this.chart.scale.max)this.chart.scale.max=
+a.length+a.position;if(a.position<this.chart.scale.min||!this.chart.scale.min)this.chart.scale.min=a.position;return a},loadFeatures:function(a){for(var b=a.length,c=0;c<b;c++)this.addFeature(a[c])},getHeight:function(){return this.height!=void 0?this.height:this.chart.laneSizes},getPixelPositionY:function(){for(var a=this.track.getPixelPositionY(),b=this.getHeight(),c=0;c<this.track.lanes.length;c++){if(this.uid==this.track.lanes[c].uid)break;a+=this.track.chart.laneBuffer;a+=b}return a},erase:function(){this.chart.ctx.clearRect(0,
+this.getPixelPositionY(),this.track.chart.canvas.width,this.getHeight())},draw:function(){for(var a=0;a<this.features.length;a++)this.features[a].draw()}});var Tooltip=Class.extend({init:function(a,b,c,d){this.text=a;this.placement=b||"above";this.verticalOffset=c||0;for(var e in d)this[e]=d[e];this.horizontalOffset=this.horizontalOffset||0;this.ntOffset=this.ntOffset||0},fire:function(a){a=a||this.feature;this.chart=a.lane.track.chart;this.ctx=this.chart.ctx;this.draw(a,1)},draw:function(a,b){this.ctx.globalAlpha=b;var c=this.chart.tooltips.roundness,d=this.chart.tooltips.text.font,e=this.chart.tooltips.text.size,f=this.text||a.onMouseover;this.ctx.save();
+this.ctx.font=e+"px "+d;d=this.ctx.measureText(f);var h=[f],g=e+10,i=d.width+10,j,m;d=0;a.seq&&(d=this.ntOffset*(a.getPixelLength()/a.length));d=a.getPixelPositionX()+this.horizontalOffset+d;var k;k=this.placement=="below"?a.getPixelPositionY()+a.getHeight()-this.verticalOffset:a.getPixelPositionY()-g-this.verticalOffset;a.getPixelLength();if(i>200)h=this.ctx.measureText("s").width,h=parseInt(200/h),f=ScriblWrapLines(h,f),i=210,g=f[1]*e+10,h=f[0];i+d>this.chart.width&&(d=this.chart.width-i);if(this.chart.tooltips.style==
+"light")j=this.chart.ctx.createLinearGradient(d+i/2,k,d+i/2,k+g),j.addColorStop(0,"rgb(253, 248, 196)"),j.addColorStop(0.75,"rgb(253, 248, 196)"),j.addColorStop(1,"white"),m=this.chart.ctx.createLinearGradient(d+i/2,k,d+i/2,k+g),m.addColorStop(0,"black"),m.addColorStop(1,"rgb(64, 64, 64)"),this.chart.tooltips.text.color="black";else if(this.chart.tooltips.style=="dark")j=this.chart.ctx.createLinearGradient(d+i/2,k,d+i/2,k+g),j.addColorStop(0,"rgb(64, 64, 64)"),j.addColorStop(1,"rgb(121, 121, 121)"),
+m="white",this.chart.tooltips.text.color="white";this.chart.lastToolTips.push({pixels:this.ctx.getImageData(d-1,k-1,i+2,g+2),x:d-1,y:k-1});this.ctx.fillStyle=j;this.ctx.beginPath();tlc_ctrl_x=d;tlc_ctrl_y=k;tlc_lgth_x=d+c;tlc_lgth_y=k;tlc_wdth_x=d;tlc_wdth_y=k+c;blc_ctrl_x=d;blc_ctrl_y=k+g;blc_lgth_x=d+c;blc_lgth_y=k+g;blc_wdth_x=d;blc_wdth_y=k+g-c;brc_ctrl_x=d+i;brc_ctrl_y=k+g;brc_lgth_x=d+i-c;brc_lgth_y=k+g;brc_wdth_x=d+i;brc_wdth_y=k+g-c;trc_ctrl_x=d+i;trc_ctrl_y=k;trc_lgth_x=d+i-c;trc_lgth_y=
+k;trc_wdth_x=d+i;trc_wdth_y=k+c;this.ctx.moveTo(tlc_lgth_x,tlc_lgth_y);this.ctx.quadraticCurveTo(tlc_ctrl_x,tlc_ctrl_y,tlc_wdth_x,tlc_wdth_y);this.ctx.lineTo(blc_wdth_x,blc_wdth_y);this.ctx.quadraticCurveTo(blc_ctrl_x,blc_ctrl_y,blc_lgth_x,blc_lgth_y);this.ctx.lineTo(brc_lgth_x,brc_lgth_y);this.ctx.quadraticCurveTo(brc_ctrl_x,brc_ctrl_y,brc_wdth_x,brc_wdth_y);this.ctx.lineTo(trc_wdth_x,trc_wdth_y);this.ctx.quadraticCurveTo(trc_ctrl_x,trc_ctrl_y,trc_lgth_x,trc_lgth_y);this.ctx.lineTo(tlc_lgth_x,tlc_lgth_y);
+this.ctx.fill();this.ctx.lineWidth=this.chart.tooltips.borderWidth;this.ctx.strokeStyle=m;this.ctx.stroke();this.ctx.textBaseline="middle";this.ctx.fillStyle=this.chart.tooltips.text.color;for(c=0;c<h.length;c++)this.ctx.measureText(h[c]),this.ctx.fillText(h[c],d+5,k+e*(c+1));this.ctx.restore()}});var MouseEventHandler=Class.extend({init:function(a){this.chart=a;this.mouseY=this.mouseX=null;this.eventElement=void 0;this.isEventDetected=!1;this.tooltip=new Tooltip("","above",-4)},addEvents:function(a){var b=this.chart,c=b.ctx,d=b.myMouseEventHandler;if(a.onMouseover&&!b.events.hasMouseover)b.addMouseoverEventListener(b.myMouseEventHandler.handleMouseover),b.events.hasMouseover=!0;else if(a.tooltips.length>0&&!b.events.hasMouseover)b.addMouseoverEventListener(b.myMouseEventHandler.handleMouseover),
+b.events.hasMouseover=!0;else if(a.parent&&a.parent.tooltips.length>0&&!b.events.hasMouseover)b.addMouseoverEventListener(b.myMouseEventHandler.handleMouseover),b.events.hasMouseover=!0;else if(a.parent&&a.parent.onMouseover&&!b.events.hasMouseover)b.addMouseoverEventListener(b.myMouseEventHandler.handleMouseover),b.events.hasMouseover=!0;if(a.onClick&&!b.events.hasClick)b.addClickEventListener(b.myMouseEventHandler.handleClick),b.addMouseoverEventListener(b.myMouseEventHandler.handleMouseStyle),
+b.events.hasClick=!0;else if(a.parent&&a.parent.onClick&&!b.events.hasClick)b.addClickEventListener(b.myMouseEventHandler.handleClick),b.addMouseoverEventListener(b.myMouseEventHandler.handleMouseStyle),b.events.hasClick=!0;if(!d.isEventDetected&&c.isPointInPath_mozilla(d.mouseX,d.mouseY))d.eventElement=a,d.isEventDetected=!0},setMousePosition:function(a){if(a!=null){var b=this.chart.canvas.getBoundingClientRect();this.mouseX=a.clientX-b.left;this.mouseY=a.clientY-b.top}},handleClick:function(a){a=
+a.myMouseEventHandler.eventElement;var b;if(a!=void 0&&a.onClick!=void 0)b=a.onClick;else if(a&&a.parent&&a.parent.onClick)b=a.parent.onClick;b&&(typeof b=="string"?window.open(b):typeof b=="function"&&b(a))},handleMouseover:function(a){a=a.myMouseEventHandler;var b=a.eventElement;if(b!=void 0&&b.onMouseover!=void 0)a.tooltip.fire(b);else if(b&&b.parent&&b.parent.onMouseover)b.onMouseover=b.parent.onMouseover,a.tooltip.fire(b);b&&b.tooltips.length>0&&b.fireTooltips()},handleMouseStyle:function(a){var b=
+a.myMouseEventHandler.eventElement;a.ctx.canvas.style.cursor=b&&b.onClick!=void 0?"pointer":b&&b.parent&&b.parent.onClick!=void 0?"pointer":"auto"},reset:function(a){a=a.myMouseEventHandler;a.mouseX=null;a.mouseY=null;a.eventElement=void 0;a.isEventDetected=null;a.elementIndexCounter=0}});
+CanvasRenderingContext2D.prototype.isPointInPath_mozilla=function(a,b){if(navigator.userAgent.indexOf("Firefox")!=-1){this.save();this.setTransform(1,0,0,1,0,0);var c=this.isPointInPath(a,b);this.restore()}else c=this.isPointInPath(a,b);return c};function ScriblWrapLines(a,b){for(var c=[],d="",e=0,f=(""+b).split(" "),h=0;h<f.length;h++)f[h].length+d.length<=a?d+=" "+f[h]:d==""?(trunc1=f[h].slice(0,a-1),d+=" "+trunc1+"-",trunc2=f[h].slice(a,f[h].length),f.splice(h+1,0,trunc2),c.push(d),d="",e++):(h--,c.push(d),e++,d="");e++;c.push(d);return[c,e]}var idCounter=0;_uniqueId=function(a){var b=idCounter++;return a?a+b:b};
+if(!Array.prototype.indexOf)Array.prototype.indexOf=function(a){if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(c===0)return-1;var d=0;arguments.length>0&&(d=Number(arguments[1]),d!==d?d=0:d!==0&&d!==Infinity&&d!==-Infinity&&(d=(d>0||-1)*Math.floor(Math.abs(d))));if(d>=c)return-1;for(d=d>=0?d:Math.max(c-Math.abs(d),0);d<c;d++)if(d in b&&b[d]===a)return d;return-1};var CanvasToSVG={idCounter:0,convert:function(a,b,c,d){var e=a.toDataURL(),f=document.createElementNS("http://www.w3.org/2000/svg","image");f.setAttribute("id","importedCanvas_"+this.idCounter++);f.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",e);f.setAttribute("x",c?c:0);f.setAttribute("y",d?d:0);f.setAttribute("width",a.width);f.setAttribute("height",a.height);f.imageData=a.toDataURL();b.appendChild(f)}},toXml=function(a){return $("<p/>").text(a).html()},svgToString=function(a){for(;removeUnusedDefElems()>
+0;);pathActions.clear(!0);$.each(a.childNodes,function(b,c){b&&c.nodeType==8&&c.data.indexOf("Created with")>=0&&a.insertBefore(c,a.firstChild)});current_group&&(leaveContext(),selectOnly([current_group]));var b=[];$(a).find("g:data(gsvg)").each(function(){for(var a=this.attributes,c=a.length,f=0;f<c;f++)(a[f].nodeName=="id"||a[f].nodeName=="style")&&c--;if(c<=0)a=this.firstChild,b.push(a),$(this).replaceWith(a)});var c=svgToString(a,0);b.length&&$(b).each(function(){groupSvgElem(this)});return c};
+svgToString=function(a,b){var c=[];if(a){var d=a.attributes,e,f,h=a.childNodes;for(f=0;f<b;f++)c.push(" ");c.push("<");c.push(a.nodeName);if(a.id=="svgcontent"){f=getResolution();c.push(' width="'+f.w+'" height="'+f.h+'" xmlns="'+svgns+'"');var g={};$(a).find("*").andSelf().each(function(){$.each(this.attributes,function(a,b){var d=b.namespaceURI;d&&!g[d]&&nsMap[d]!=="xmlns"&&nsMap[d]!=="xml"&&(g[d]=!0,c.push(" xmlns:"+nsMap[d]+'="'+d+'"'))})});for(f=d.length;f--;){e=d.item(f);var i=toXml(e.nodeValue);
+if(e.nodeName.indexOf("xmlns:")!==0&&i!=""&&["width","height","xmlns","x","y","viewBox","id","overflow"].indexOf(e.localName)==-1&&(!e.namespaceURI||nsMap[e.namespaceURI]))c.push(" "),c.push(e.nodeName),c.push('="'),c.push(i),c.push('"')}}else for(f=d.length-1;f>=0;f--)e=d.item(f),i=toXml(e.nodeValue),!(["-moz-math-font-style","_moz-math-font-style"].indexOf(e.localName)>=0)&&i!=""&&i.indexOf("pointer-events")!==0&&!(e.localName==="class"&&i.indexOf("se_")===0)&&(c.push(" "),e.localName==="d"&&(i=
+pathActions.convertPath(a,!0)),c.push(e.nodeName),c.push('="'),c.push(i),c.push('"'));if(a.hasChildNodes()){c.push(">");b++;d=!1;for(f=0;f<h.length;f++)switch(e=h.item(f),e.nodeType){case 1:c.push("\n");c.push(svgToString(h.item(f),b));break;case 3:e=e.nodeValue.replace(/^\s+|\s+$/g,"");e!=""&&(d=!0,c.push(toXml(e)+""));break;case 8:c.push("\n"),c.push(Array(b+1).join(" ")),c.push("<\!--"),c.push(e.data),c.push("--\>")}b--;if(!d){c.push("\n");for(f=0;f<b;f++)c.push(" ")}c.push("</");c.push(a.nodeName);
+c.push(">")}else c.push("/>")}return c.join("")};var Glyph=Class.extend({init:function(a,b,c,d,e){this.uid=_uniqueId("feature");this.position=b;this.length=c;this.strand=d;this.type=a;this.opts={};this.name="";this.borderColor="none";this.borderWidth=void 0;this.ntLevel=4;this.tooltips=[];this.hooks={};this.addDrawHook(function(a){if(a.ntLevel!=void 0&&a.seq&&a.lane.chart.ntsToPixels()<a.ntLevel){var b=new Seq(a.type,a.position,a.length,a.seq,a.opts);b.lane=a.lane;b.ctx=a.ctx;b._draw();return!0}return!1},"ntHook");this.text={};this.text.font=void 0;
+this.text.size=void 0;this.text.color=void 0;this.onMouseover=this.onClick=this.text.align=void 0;for(var f in e)this[f]=e[f],this.opts[f]=e[f]},setColorGradient:function(){if(arguments.length==1)this.color=arguments[0];else{for(var a=this.lane.ctx.createLinearGradient(this.length/2,0,this.length/2,this.getHeight()),b,c=0;b=arguments[c],c<arguments.length;c++)a.addColorStop(c/(arguments.length-1),b);this.color=a}},getPixelLength:function(){return this.lane.chart.pixelsToNts(this.length)||1},getPixelPositionX:function(){var a=
+parseInt(this.lane.track.chart.offset)||0;return this.lane.track.chart.pixelsToNts(this.parent?this.position+this.parent.position-this.lane.track.chart.scale.min:this.position-this.lane.track.chart.scale.min)+a},getPixelPositionY:function(){return this.lane.getPixelPositionY()},getEnd:function(){return this.position+this.length},clone:function(){var a;a=this.strand?"new "+this.glyphType+'("'+this.type+'",'+this.position+","+this.length+',"'+this.strand+'",'+JSON.stringify(this.opts)+")":"new "+this.glyphType+
+'("'+this.type+'",'+this.position+","+this.length+","+JSON.stringify(this.opts)+")";a=eval(a);a.tooltips=this.tooltips;a.hooks=this.hooks;return a},getAttr:function(a){a=a.split("-");for(var b=this,c=0;c<a.length;c++)b=b[a[c]];if(b)return b;if(this.parent){b=this.parent;for(c=0;c<a.length;c++)b=b[a[c]];if(b)return b}if(b=this.lane.chart[this.type]){for(c=0;c<a.length;c++)b=b[a[c]];if(b)return b}b=this.lane.chart.glyph;for(c=0;c<a.length;c++)b=b[a[c]];if(b)return b},drawText:function(a){var b=this.lane.chart.ctx,
+c=this.getPixelLength(),d=this.getHeight(),e=this.getAttr("text-size"),f=this.getAttr("text-style");b.font=e+"px "+f;b.textBaseline="middle";b.fillStyle=this.getAttr("text-color");var h=void 0,g=this.getAttr("text-align");g=="start"?g=this.strand=="+"?"left":"right":g=="end"&&(g=this.strand=="+"?"right":"left");b.textAlign=g;g=="left"?h=5:g=="center"?h=c/2:g=="right"&&(h=c-5);var i=b.measureText(a);if(a&&a!=""){for(;c-i.width<4;)if(e=/^\d+/.exec(b.font),e--,i=b.measureText(a),b.font=e+"px "+f,e<=
+8){a="";break}this.glyphType=="Complex"&&(c=0,e=/^\d+/.exec(b.font),g=="center"&&(c=-(b.measureText(a).width/2+2.5)),b.clearRect(h+c,d/2-e/2,b.measureText(a).width+5,e));b.fillText(a,h,d/2)}},calcRoundness:function(){return this.getHeight()*this.getAttr("roundness")/100},isContainedWithinRect:function(a,b,c,d){var e=this.getPixelPositionY(),f=this.getPixelPositionX(),h=this.getPixelPositionX()+this.getPixelLength(),g=e+this.getHeight();return f>=a&&h<=c&&e>=b&&g<=d},getHeight:function(){return this.lane.getHeight()},
+getFillStyle:function(){var a=this.getAttr("color");if(a instanceof Array){for(var b=this.lane.ctx.createLinearGradient(this.length/2,0,this.length/2,this.getHeight()),c,d=0;c=a[d],d<a.length;d++)b.addColorStop(d/(a.length-1),c);return b}else return a instanceof Function?(b=this.lane.ctx.createLinearGradient(this.length/2,0,this.length/2,this.getHeight()),a(b)):a},getStrokeStyle:function(){var a=this.getAttr("borderColor");if(typeof a=="object"){for(var b=this.lane.ctx.createLinearGradient(this.length/
+2,0,this.length/2,this.getHeight()),c,d=0;c=a[d],d<a.length;d++)b.addColorStop(d/(a.length-1),c);return b}else return a},isSubFeature:function(){return this.parent!=void 0},erase:function(){this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.clearRect(this.getPixelPositionX(),this.getPixelPositionY(),this.getPixelLength(),this.getHeight());this.ctx.restore()},addDrawHook:function(a,b){var c=b||_uniqueId("drawHook");this.hooks[c]=a;return c},removeDrawHook:function(a){delete this.hooks[a]},
+addTooltip:function(a,b,c,d){a=new Tooltip(a,b,c,d);a.feature=this;this.tooltips.push(a)},fireTooltips:function(){for(var a=0;a<this.tooltips.length;a++)this.tooltips[a].fire()},draw:function(){this.ctx=this.lane.chart.ctx;this.ctx.beginPath();/^\d+/.exec(this.ctx.font);var a=/\S+$/.exec(this.ctx.font);this.onClick=this.getAttr("onClick");this.onMouseover=this.getAttr("onMouseover");this.ctx.fillStyle=this.getFillStyle();var b=this.ctx.fillStyle,c=this.getPixelPositionX(),d=this.getHeight();d<10?
+this.ctx.font="10px "+a:this.ctx.font=d*0.9+"px "+a;this.ctx.translate(c,0);this.strand=="-"&&!this.isSubFeature()&&this.ctx.transform(-1,0,0,1,this.getPixelLength(),0);a=!1;for(var e in this.hooks)a=this.hooks[e](this)||a;a||this._draw();if(this.borderColor!="none")this.color=="none"&&this.parent.glyphType=="Complex"&&this.erase(),e=this.ctx.strokeStyle,a=this.ctx.lineWidth,this.ctx.strokeStyle=this.getStrokeStyle(),this.ctx.lineWidth=this.getAttr("borderWidth"),this.ctx.stroke(),this.ctx.strokeStyle=
+e,this.ctx.lineWidth=a;this.color!="none"&&this.ctx.fill();this.strand=="-"&&!this.isSubFeature()&&this.ctx.transform(-1,0,0,1,this.getPixelLength(),0);this.drawText(this.getAttr("name"));this.ctx.translate(-c,0);this.ctx.fillStyle=b;this.lane.chart.myMouseEventHandler.addEvents(this)}});var BlockArrow=Glyph.extend({init:function(a,b,c,d,e){this._super(a,b,c,d,e);this.slope=1;this.glyphType="BlockArrow"},_draw:function(a,b,c,d){a=a||this.ctx;b=b||this.getPixelLength();c=c||this.getHeight();d=d+1||this.calcRoundness();d!=void 0&&(d-=1);tc_ctrl_y=tc_ctrl_x=x=y=0;tc_lgth_x=x+d;tc_lgth_y=y;tc_wdth_x=x;tc_wdth_y=y+d;bc_ctrl_x=x;bc_ctrl_y=y+c;bc_lgth_x=x+d;bc_lgth_y=y+c;bc_wdth_x=x;bc_wdth_y=y+c-d;a_b_x=x+b-d;a_t_x=x+b-d;a_max_x=x+b;t=0.5;a_ctrl_x=(a_max_x-(1-t)*(1-t)*a_b_x-t*t*a_t_x)/
+(2*(1-t)*t);a_ctrl_y=y+c/2;bs_slope=this.slope;bs_intercept=-a_ctrl_y-bs_slope*a_ctrl_x;ts_slope=-this.slope;ts_intercept=-a_ctrl_y-ts_slope*a_ctrl_x;a_b_y=-(bs_slope*a_b_x+bs_intercept);a_t_y=-(ts_slope*a_t_x+ts_intercept);bs_ctrl_y=y+c;bs_ctrl_x=(-bs_ctrl_y-bs_intercept)/this.slope;bs_ctrl_x<x?(new Rect(this.type,0,b))._draw(a,b,c,d):(bs_lgth_y=y+c,bs_lgth_x=bs_ctrl_x-d,bs_slpe_x=bs_ctrl_x+d,bs_slpe_y=-(bs_slope*bs_slpe_x+bs_intercept),ts_ctrl_y=y,ts_ctrl_x=(ts_ctrl_y+ts_intercept)/this.slope,ts_lgth_y=
+y,ts_lgth_x=ts_ctrl_x-d,ts_slpe_x=ts_ctrl_x+d,ts_slpe_y=-(ts_slope*ts_slpe_x+ts_intercept),a.beginPath(),a.moveTo(tc_lgth_x,tc_lgth_y),a.quadraticCurveTo(tc_ctrl_x,tc_ctrl_y,tc_wdth_x,tc_wdth_y),a.lineTo(bc_wdth_x,bc_wdth_y),a.quadraticCurveTo(bc_ctrl_x,bc_ctrl_y,bc_lgth_x,bc_lgth_y),a.lineTo(bs_lgth_x,bs_lgth_y),a.quadraticCurveTo(bs_ctrl_x,bs_ctrl_y,bs_slpe_x,bs_slpe_y),a.lineTo(a_b_x,a_b_y),a.quadraticCurveTo(a_ctrl_x,a_ctrl_y,a_t_x,a_t_y),a.lineTo(ts_slpe_x,ts_slpe_y),a.quadraticCurveTo(ts_ctrl_x,
+ts_ctrl_y,ts_lgth_x,ts_lgth_y),a.lineTo(tc_lgth_x,tc_lgth_y))}});var Rect=Glyph.extend({init:function(a,b,c,d){this._super(a,b,c,void 0,d);this.glyphType="Rect"},_draw:function(a,b,c,d){a=a||this.ctx;b=b||this.getPixelLength();c=c||this.getHeight();d=d+1||this.calcRoundness();d!=void 0&&(d-=1);x=y=0;a.beginPath();tlc_ctrl_x=x;tlc_ctrl_y=y;tlc_lgth_x=x+d;tlc_lgth_y=y;tlc_wdth_x=x;tlc_wdth_y=y+d;blc_ctrl_x=x;blc_ctrl_y=y+c;blc_lgth_x=x+d;blc_lgth_y=y+c;blc_wdth_x=x;blc_wdth_y=y+c-d;brc_ctrl_x=x+b;brc_ctrl_y=y+c;brc_lgth_x=x+b-d;brc_lgth_y=y+c;brc_wdth_x=x+b;brc_wdth_y=
+y+c-d;trc_ctrl_x=x+b;trc_ctrl_y=y;trc_lgth_x=x+b-d;trc_lgth_y=y;trc_wdth_x=x+b;trc_wdth_y=y+d;a.moveTo(tlc_lgth_x,tlc_lgth_y);a.quadraticCurveTo(tlc_ctrl_x,tlc_ctrl_y,tlc_wdth_x,tlc_wdth_y);a.lineTo(blc_wdth_x,blc_wdth_y);a.quadraticCurveTo(blc_ctrl_x,blc_ctrl_y,blc_lgth_x,blc_lgth_y);a.lineTo(brc_lgth_x,brc_lgth_y);a.quadraticCurveTo(brc_ctrl_x,brc_ctrl_y,brc_wdth_x,brc_wdth_y);a.lineTo(trc_wdth_x,trc_wdth_y);a.quadraticCurveTo(trc_ctrl_x,trc_ctrl_y,trc_lgth_x,trc_lgth_y);a.lineTo(tlc_lgth_x,tlc_lgth_y)}});var Seq=Glyph.extend({init:function(a,b,c,d,e){this.seq=d;this.insertions=[];this.fraction=1;this.fractionLevel=0.3;this.glyphType="Seq";this.font="8px courier";this.chars={};this.chars.width=void 0;this.chars.height=void 0;this.chars.list=["A","G","T","C","N","-"];this._super(a,b,c,void 0,e)},_draw:function(a,b,c){var d=1;if(this.lane.chart.ntsToPixels()<=this.fractionLevel)d=this.fraction;a=a||this.ctx;b=b||this.getPixelLength();c=c||this.getHeight();var e=this.getPixelPositionX(),f=this.getPixelPositionY(),
+h=SCRIBL.chars;if(!h.heights[c]){h.heights[c]=[];for(var g=0;g<this.chars.list.length;g++){var i=this.chars.list[g],j=i;i=="-"&&(j="dash");this.createChar(i,h.nt_color,h["nt_"+j+"_bg"],c)}}x=y=0;if(this.imgCanvas)a.drawImage(this.imgCanvas,e,f-c*d,b,c*d);else{a.save();a.beginPath();a.textBaseline="middle";d=a.font;g=/[\d+px]/.exec(d)+"px";a.font=g+" courier";a.fillStyle="black";a.textAlign="left";g=this.seq.length*h.heights[c].width;this.imgCanvas=document.createElement("canvas");this.imgCanvas.width=
+g;this.imgCanvas.height=c;e=this.imgCanvas.getContext("2d");for(g=i=f=0;g<this.seq.length;g++)h.heights[c][this.seq[g]]||this.createChar(this.seq[g],"black","white",c),j=this.seq[g],this.insertions[i]&&this.insertions[i].pos!=void 0&&(this.insertions[i].pos-1==g?j+="rightInsert":this.insertions[i]&&this.insertions[i].pos==g&&(j+="leftInsert",i++)),e.drawImage(h.heights[c][j],f,y),f+=h.heights[c].width;a.drawImage(this.imgCanvas,x,y,b,c);a.font=d;a.restore()}a.beginPath();a.moveTo(0,0);a.lineTo(b,
+y);a.lineTo(b,y+c);a.lineTo(x,y+c);a.lineTo(x,y);a.fillStyle="rgba(0,0,0,0)";a.strokeStyle=this.lane.chart.ntsToPixels()<=this.fractionLevel?"rgba(0,0,0,1)":"rgba(0,0,0,0)";a.stroke();a.closePath()},createChar:function(a,b,c,d){var e=document.createElement("canvas"),f=e.getContext("2d"),h=d-2;f.font=h+"px courier";var g=f.measureText(a).width+2;e.height=d;e.width=g;SCRIBL.chars.heights[d].width=g;e=document.createElement("canvas");f=e.getContext("2d");f.font=h+"px courier";e.height=d;e.width=g;var i=
+f.fillStyle;f.fillStyle=c;f.fillRect(0,0,g,d);f.fillStyle=b;f.textAlign="center";f.textBaseline="middle";f.fillText(a,g/2,d/2);SCRIBL.chars.heights[d][a]=e;f.fillStyle=i;e=document.createElement("canvas");f=e.getContext("2d");f.font=h+"px courier";e.height=d;e.width=g;i=f.fillStyle;f.fillStyle=c;f.fillRect(0,0,g,d);f.fillStyle="yellow";f.beginPath();f.moveTo(0,d);f.arcTo(g,d,g,0,d/2);f.lineTo(g,d);f.lineTo(0,d);f.closePath();f.fill();f.fillStyle=b;f.textAlign="center";f.textBaseline="middle";f.fillText(a,
+g/2,d/2);SCRIBL.chars.heights[d][a+"rightInsert"]=e;f.fillStyle=i;e=document.createElement("canvas");f=e.getContext("2d");f.font=h+"px courier";e.height=d;e.width=g;i=f.fillStyle;f.fillStyle=c;f.fillRect(0,0,g,d);f.fillStyle="yellow";f.beginPath();f.moveTo(g,d);f.arcTo(0,d,0,0,d/2);f.lineTo(0,d);f.lineTo(g,d);f.closePath();f.fill();f.fillStyle=b;f.textAlign="center";f.textBaseline="middle";f.fillText(a,g/2,d/2);SCRIBL.chars.heights[d][a+"leftInsert"]=e;f.fillStyle=i}});var Line=Glyph.extend({init:function(a,b,c,d){this.thickness=2;this._super(a,b,c,void 0,d);this.glyphType="Line"},_draw:function(a,b,c){a=a||this.ctx;b=b||this.getPixelLength();c=c||this.getHeight();x=y=0;a.beginPath();a.moveTo(x,c/2-this.thickness/2);a.lineTo(x,c/2+this.thickness/2);a.lineTo(x+b,c/2+this.thickness/2);a.lineTo(x+b,c/2-this.thickness/2)}});var Complex=Glyph.extend({init:function(a,b,c,d,e,f){this._super(a,b,c,d,f);this.slope=1;this.glyphType="Complex";this.subFeatures=e;this.line=new Line(a,0,c);this.line.parent=this;this.line.color="black";this.line.thickness=2},addSubFeature:function(a){this.subFeatures.push(a)},_draw:function(a,b,c,d){a=a||this.ctx;b||this.getPixelLength();c||this.getHeight();d+1||this.calcRoundness();x=y=0;a.translate(-this.getPixelPositionX(),0);this.line.lane=this.lane;this.line.draw();b=this.subFeatures.length;
+for(c=0;c<b;c++)this.subFeatures[c].parent=this,this.subFeatures[c].lane=this.lane,this.subFeatures[c].draw();a.translate(this.getPixelPositionX(),0);a.beginPath()}});var Arrow=Glyph.extend({init:function(a,b,c,d){this._super(a,b,0,c,d);this.slope=1;this.glyphType="Arrow";this.thickness=4.6},getPixelThickness:function(){return this.thickness/10*(this.getHeight()/2/Math.tan(Math.atan(this.slope)))},erase:function(){var a=this.getPixelThickness();this.ctx.clearRect(-a,0,a,this.getHeight())},_draw:function(a,b,c,d){a=a||this.ctx;c=c||this.getHeight();d=d+1||this.calcRoundness();d!=void 0&&(d-=1);b=this.getPixelThickness();x=y=0;a_b_x=x-0-d;a_t_x=x-0-d;a_max_x=x-0;
+t=0.5;a_ctrl_x=(a_max_x-(1-t)*(1-t)*a_b_x-t*t*a_t_x)/(2*(1-t)*t);a_ctrl_y=y+c/2;bs_slope=this.slope;bs_intercept=-a_ctrl_y-bs_slope*a_ctrl_x;ts_slope=-this.slope;ts_intercept=-a_ctrl_y-ts_slope*a_ctrl_x;a_b_y=-(bs_slope*a_b_x+bs_intercept);a_t_y=-(ts_slope*a_t_x+ts_intercept);a.beginPath();bs_ctrl_y=y+c;bs_ctrl_x=(-bs_ctrl_y-bs_intercept)/this.slope;bs_slpe_x=bs_ctrl_x+d+d;bs_slpe_y=-(bs_slope*bs_slpe_x+bs_intercept);a.moveTo(bs_slpe_x,bs_slpe_y);a.lineTo(a_b_x,a_b_y);a.quadraticCurveTo(a_ctrl_x,
+a_ctrl_y,a_t_x,a_t_y);ts_ctrl_y=y;ts_ctrl_x=(ts_ctrl_y+ts_intercept)/this.slope;ts_slpe_x=ts_ctrl_x+d+d;ts_slpe_y=-(ts_slope*ts_slpe_x+ts_intercept);a.lineTo(ts_slpe_x,ts_slpe_y);var e=Math.PI-Math.abs(Math.atan(this.slope))-Math.PI/2;d=Math.sin(e)*b;e=Math.cos(e)*b;a.bezierCurveTo(ts_ctrl_x,ts_ctrl_y,ts_ctrl_x-d,ts_ctrl_y+e,ts_slpe_x-d,ts_slpe_y+e);a.lineTo(a_max_x-b,y+c/2);a.lineTo(bs_slpe_x-d,bs_slpe_y-e);a.bezierCurveTo(bs_ctrl_x-d,bs_ctrl_y-e,bs_ctrl_x,bs_ctrl_y,bs_slpe_x,bs_slpe_y)}});function genbank(a,b){for(var c=a.split("\n"),d=RegExp(/\s+gene\s+([a-z]*)\(?(\d+)\.\.(\d+)/),e=[],f=void 0,h=void 0,g=0;g<c.length;g++){var i;if(i=c[g].match(d)){i.shift();e.push(i);var j=i[2];if(f==void 0||f>j)f=j;i=i[1];if(h==void 0||h<i)h=i}}b.scale.max=f;b.scale.min=h;for(c=0;c<e.length;c++)d="+",e[c][0]=="complement"&&(d="-"),i=e[c][1],j=e[c][2],i=i-1+1,b.addGene(i,j-i,d)};function bed(a,b){var c=a.split("\n");numFeatures=c.length;for(var d=1;d<numFeatures;d++){if(c[d]=="")break;var e=c[d].split(" "),f=parseInt(e[1]),h=parseInt(e[2]),g=e[0]+": "+e[3],i=e[5],j=e[8],m=e[10].split(",");e=e[11].split(",");f=b.addFeature(new Complex("complex",f,h,i,[],{color:j,name:g}));for(h=0;h<m.length;h++){if(m[h]=="")break;f.addSubFeature(new BlockArrow("complex",parseInt(e[h]),parseInt(m[h]),i))}}};

0 comments on commit 8413626

Please sign in to comment.
Something went wrong with that request. Please try again.