scribl-rails 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Scribl
2
2
  module Rails
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.3"
4
4
  end
5
5
  end
@@ -1,149 +1,70 @@
1
- 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}
2
- 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);
3
- 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)})}
4
- 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=
5
- 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};
6
- 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()};
7
- 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(){}
8
- 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;
9
- 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,
10
- 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]}
11
- 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)}
12
- 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}}
13
- 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;
14
- 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)};
15
- 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)};
16
- 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);
17
- 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],
18
- 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,
19
- 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,
20
- 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,
21
- 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,
22
- 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,
23
- 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,
24
- 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,
25
- 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,
26
- 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,
27
- 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)};
28
- 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]}
29
- 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};
30
- 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};
31
- 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=
32
- 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--;
33
- 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;
34
- 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++]&
35
- 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}};
36
- 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];
37
- 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=
38
- 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];
39
- 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}
40
- 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)};
41
- 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=
42
- 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,
43
- 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+=
44
- 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,
45
- 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,
46
- 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++]]=
47
- 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!=
48
- 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,
49
- 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);
50
- 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=
51
- 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);
52
- 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)}};
53
- 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};
54
- 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-=
55
- 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};
56
- 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=
57
- 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)!=
58
- 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=
59
- 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];
60
- 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,
61
- 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++]=
62
- 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--);
63
- 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=
64
- 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(){};
65
- 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)*
66
- 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];
67
- 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):
68
- (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(){}
69
- 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+
70
- 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>=
71
- 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};
72
- 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};
73
- 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";
74
- 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}
75
- 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)};
76
- 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]}
77
- function arrayCopy_fast(a,b,c){b.set(a,c)}var ADLER_BASE=65521,ADLER_NMAX=5552;
78
- 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;
79
- a%=ADLER_BASE}return a<<16|e}
80
- 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]=
81
- (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");
82
- var Scribl=Class.extend({init:function(a,b){this.scrolled=!1;var c=a.getContext("2d"),d=this;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=
83
- 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.mouseHandler=function(a){d.handleMouseEvent(a,
1
+ (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 g in c)f[g]=typeof c[g]=="function"&&typeof e[g]=="function"&&b.test(c[g])?function(a,b){return function(){var c=this._super;this._super=e[a];var d=b.apply(this,arguments);this._super=c;return d}}(g,c[g]):c[g];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");
2
+ var Scribl=Class.extend({init:function(a,b){this.scrolled=!1;var c;a&&(c=a.getContext("2d"));var d=this;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";
3
+ 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.mouseHandler=function(a){d.handleMouseEvent(a,
84
4
  "mouseover")};this.clickHandler=function(a){d.handleMouseEvent(a,"click")};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=
85
- [];this.scrollable=!1;this.scrollValues=[0,void 0];this.chars={};this.chars.drawOnBuild=[];this.drawStyle="expand";this.glyphHooks=[];this.trackHooks=[];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?
86
- this.scale.positions.push(this.tracks.length):(this.scale.positions=[this.tracks.length],this.scale.userControlled=!0)},addTrack:function(){var a=new Track(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();
87
- 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,
88
- 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";var d=this.tracks.length,e=new Scribl(this.canvas,this.width);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;e.glyphHooks=this.glyphHooks;e.trackHooks=this.trackHooks;
89
- e.mouseHandler=this.mouseHandler;e.clickHandler=this.clickHandler;e.previousDrawStyle=this.previousDrawStyle;for(var 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++)for(var m=g.addLane(),k=h.lanes[j].features,l=0;l<k.length;l++){var n=k[l].position+k[l].length,q=k[l].position;if(c=="inclusive")q>=a&&q<=b?m.addFeature(k[l].clone()):n>a&&n<b?m.addFeature(k[l].clone()):q<a&&n>b?m.addFeature(k[l].clone()):q>a&&n<b&&m.addFeature(k[l].clone());
90
- else if(c=="strict")if(q>=a&&q<=b)if(n>a&&n<b)m.addFeature(k[l].clone());else{var o=k[l].glyphType=="BlockArrow"&&k[l].strand=="+"?k[l].clone("Rect"):k[l].clone();o.length=Math.abs(b-q);m.addFeature(o)}else if(n>a&&n<b)o=k[l].glyphType=="BlockArrow"&&k[l].strand=="-"?k[l].clone("Rect"):k[l].clone(),o.position=a,o.length=Math.abs(n-a),m.addFeature(o);else{if(q<a&&n>b)o=k[l].glyphType=="BlockArrow"?k[l].clone("Rect"):k[l].clone(),o.position=a,o.length=Math.abs(b-a),m.addFeature(o)}else c=="exclusive"&&
91
- q>=a&&q<=b&&n>a&&n<b&&m.addFeature(k[l].clone())}}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/
92
- 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+
93
- 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";
94
- 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():
95
- 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+
96
- "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=
97
- 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,
98
- 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);
99
- 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);
100
- 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=
101
- 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(){this.events.mouseovers.length>
102
- 0&&(this.canvas.removeEventListener("mousemove",this.mouseHandler),this.canvas.addEventListener("mousemove",this.mouseHandler,!1));this.events.clicks.length>0&&(this.canvas.removeEventListener("click",this.clickHandler),this.canvas.addEventListener("click",this.clickHandler,!1));this.events.added=!0}});var Track=Class.extend({init:function(a){this.chart=a;this.lanes=[];this.ctx=a.ctx;this.uid=_uniqueId("track");this.drawStyle=void 0;this.hide=!1;this.hooks={};for(var b=0;b<a.trackHooks.length;b++)this.addDrawHook(a.trackHooks[b]);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",
103
- 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,
104
- 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=
105
- 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(){var a=!1,b;for(b in this.hooks)a=this.hooks[b](this)||a;if(this.status=="waiting")this.drawOnResponse=!0;else if(!this.hide){b=this.getDrawStyle();var c=this.chart.laneSizes,
106
- d=this.lanes,e=this.chart.laneBuffer,f=this.chart.trackBuffer,h=c+f,g=this.chart.ctx;if(!a)if(b==void 0||b=="expand")for(b=0;b<d.length;b++)d[b].y=h,d[b].draw(),c=d[b].getHeight(),g.translate(0,c+e),h=h+c+e;else if(b=="collapse"){c=[];for(b=0;b<d.length;b++)c=c.concat(d[b].features);c.sort(function(a,b){return a.position-b.position});for(h=0;h<c.length;h++){a=c[h].length;b=c[h].name;var i=void 0;for(i=h+1;i<c.length;i++)if(c[h].getEnd()>=c[i].position)c[h].length=Math.max(c[h].getEnd(),c[i].getEnd())-
107
- c[h].position,c[h].name="";else break;c[h].draw();c[h].length=a;c[h].name=b;h=i-1}d.length>0&&g.translate(0,d[0].getHeight()+e)}else if(b=="line"){this.coverageData.length==0&&this.calcCoverageData();h=this.maxDepth;g.beginPath();for(a=this.chart.offset;a<=this.chart.width+this.chart.offset;a++)b=this.coverageData[a]/h*c||0,b=c-b,g.lineTo(a,b);g.lineTo(this.chart.width+this.chart.offset,c);g.stroke();g.translate(0,d[0].getHeight()+e)}g.translate(0,f-e)}},addDrawHook:function(a,b){var c=b||_uniqueId("drawHook");
5
+ [];this.scrollable=!1;this.scrollValues=[0,void 0];this.chars={};this.chars.drawOnBuild=[];this.drawStyle="expand";this.glyphHooks=[];this.trackHooks=[];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},getFeatures:function(){for(var a=[],
6
+ b=0;b<this.tracks.length;b++)for(var c=0;c<this.tracks[b].lanes.length;c++)a=a.concat(this.tracks[b].lanes[c].features);return a},setCanvas:function(a){this.canvas=a;this.ctx=a.getContext("2d")},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);if(this.tracks.length==1&&this.tracks[0]==void 0)this.tracks=[];this.tracks.push(a);return a},removeTrack:function(a){for(var b=
7
+ 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,g=f.addTrack();g.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)g.addFeature(new BlockArrow("bam",a[c].pos,a[c].lengthOnRef,"+",{seq:a[c].seq}));g.status="received";g.drawOnResponse&&f.redraw()}b&&
8
+ alert("error: "+b)})});return g},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";var d=this.tracks.length,e=new Scribl(this.canvas,this.width);e.scale.min=this.scale.min;e.scale.max=this.scale.max;
9
+ 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;e.glyphHooks=this.glyphHooks;e.trackHooks=this.trackHooks;e.previousDrawStyle=this.previousDrawStyle;for(var f=0;f<d;f++){var g=this.tracks[f],h=e.addTrack();h.drawStyle=g.drawStyle;for(var i=g.lanes.length,k=0;k<i;k++)for(var l=h.addLane(),j=g.lanes[k].features,m=0;m<j.length;m++){var n=j[m].position+j[m].length,o=j[m].position;if(c=="inclusive")o>=
10
+ a&&o<=b?l.addFeature(j[m].clone()):n>a&&n<b?l.addFeature(j[m].clone()):o<a&&n>b?l.addFeature(j[m].clone()):o>a&&n<b&&l.addFeature(j[m].clone());else if(c=="strict")if(o>=a&&o<=b)if(n>a&&n<b)l.addFeature(j[m].clone());else{var p=j[m].glyphType=="BlockArrow"&&j[m].strand=="+"?j[m].clone("Rect"):j[m].clone();p.length=Math.abs(b-o);l.addFeature(p)}else if(n>a&&n<b)p=j[m].glyphType=="BlockArrow"&&j[m].strand=="-"?j[m].clone("Rect"):j[m].clone(),p.position=a,p.length=Math.abs(n-a),l.addFeature(p);else{if(o<
11
+ a&&n>b)p=j[m].glyphType=="BlockArrow"?j[m].clone("Rect"):j[m].clone(),p.position=a,p.length=Math.abs(b-a),l.addFeature(p)}else c=="exclusive"&&o>=a&&o<=b&&n>a&&n<b&&l.addFeature(j[m].clone())}}return e},draw:function(){var a=this.ctx,b=this.tracks;this.scrollable==!0&&this.initScrollable();a.save();this.initScale();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();
12
+ !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()},initScale:function(){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,
13
+ this.scale.max=Math.round(this.scale.max/this.tick.major.size+0.4)*this.tick.major.size}},drawScale:function(a){var b=this.ctx,c=b.fillStyle;a&&a.init&&this.initScale();a=this.scale.font.size+this.scale.size;var 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;b.font=this.scale.font.size+"px arial";b.textBaseline="top";b.fillStyle=this.scale.font.color;if(this.offset==void 0)this.offset=Math.ceil(b.measureText("0").width/2+10);for(var g=
14
+ 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;g<=this.scale.max;g+=this.tick.minor.size){b.beginPath();var h=this.pixelsToNts(g-this.scale.min)+this.offset;if(g%this.tick.major.size==0){var i=this.getTickText(g);b.textAlign="center";b.fillText(i,h,0);b.moveTo(h,a);b.lineTo(h,d);b.strokeStyle=this.tick.major.color}else b.moveTo(h,a),g%(this.tick.major.size/2)==0?(b.strokeStyle=this.tick.halfColor,b.lineTo(h,f)):(b.strokeStyle=
15
+ this.tick.minor.color,b.lineTo(h,e));b.stroke()}b.fillStyle=c;b.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=
16
+ "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",
17
+ 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:6,max:100,value:d,slide:function(a,b){var c=schart.scale.max-schart.scale.min,
18
+ 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+
19
+ "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,
20
+ 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 g=this.tracks[e].lanes[f].getPixelPositionY(),h=g+this.tracks[e].lanes[f].getHeight();
21
+ if(c>=g&&c<=h){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)},
22
+ removeEventListeners:function(a){a=="mouseover"?this.canvas.removeEventListener("mousemove",this.mouseHandler):a=="click"&&this.canvas.removeEventListener("click",this.clickHandler)},registerEventListeners:function(){var a=this;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).unbind("click"),$(this.canvas).bind("click",function(b){a.handleMouseEvent(b,
23
+ "click")}));this.events.added=!0}});var Track=Class.extend({init:function(a){this.chart=a;this.lanes=[];this.ctx=a.ctx;this.uid=_uniqueId("track");this.drawStyle=void 0;this.hide=!1;this.hooks={};for(var b=0;b<a.trackHooks.length;b++)this.addDrawHook(a.trackHooks[b]);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",
24
+ 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],f=3/this.chart.pixelsToNts()||3;if(e!=void 0&&a.position-f>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,
25
+ 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=this.chart.scale.min,c=this.chart.scale.max,d=0;d<a.length;d++)for(var e=
26
+ 0;e<a[d].features.length;e++){var f=a[d].features[e],g=f.position,h=f.getEnd();if(g>=b&&g<=c||h>=b&&h<=c){g=Math.round(f.getPixelPositionX());for(f=Math.round(g+f.getPixelLength());g<=f;g++)this.coverageData[g]=this.coverageData[g]+1||1,this.maxDepth=Math.max(this.coverageData[g],this.maxDepth)}}},erase:function(){this.chart.ctx.clearRect(0,this.getPixelPositionY(),this.chart.width,this.getHeight())},draw:function(){var a=!1,b;for(b in this.hooks)a=this.hooks[b](this)||a;if(this.status=="waiting")this.drawOnResponse=
27
+ !0;else if(!this.hide){var c=this.getDrawStyle();b=this.chart.laneSizes;var d=this.lanes,e=this.chart.laneBuffer,f=this.chart.trackBuffer,g=b+f,h=this.chart.ctx;if(!a)if(c==void 0||c=="expand")for(b=0;b<d.length;b++)d[b].y=g,d[b].draw()&&(a=d[b].getHeight(),h.translate(0,a+e),g=g+a+e);else if(c=="collapse"){g=[];for(b=0;b<d.length;b++)g=g.concat(d[b].filterFeaturesByPosition(this.chart.scale.min,this.chart.scale.max));g.sort(function(a,b){return a.position-b.position});for(b=0;b<g.length;b++)a=g[b].length,
28
+ c=g[b].name,g[b].draw(),g[b].length=a,g[b].name=c;d.length>0&&h.translate(0,d[0].getHeight()+e)}else if(c=="line"){this.coverageData=[];this.coverageData.length==0&&this.calcCoverageData();g=this.maxDepth;h.beginPath();for(a=this.chart.offset;a<=this.chart.width+this.chart.offset;a++)c=this.coverageData[a]/g*b||0,c=b-c,h.lineTo(a,c);h.lineTo(this.chart.width+this.chart.offset,b);h.stroke();h.translate(0,d[0].getHeight()+e)}h.translate(0,f-e)}},addDrawHook:function(a,b){var c=b||_uniqueId("drawHook");
108
29
  this.hooks[c]=a;return c},removeDrawHook:function(a){delete this.hooks[a]}});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=
109
30
  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,
110
- 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();
111
- 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==
112
- "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)"),
113
- 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=
114
- 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);
115
- 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),
31
+ this.getPixelPositionY(),this.track.chart.canvas.width,this.getHeight())},draw:function(){for(var a=this.track.chart.scale.min,b=this.track.chart.scale.max,c=!1,d=0;d<this.features.length;d++){var e=this.features[d].position,f=this.features[d].getEnd();if(e>=a&&e<=b||f>=a&&f<=b)this.features[d].draw(),c=!0}return c},filterFeaturesByPosition:function(a,b){for(var c=[],d=this.features.length,e=0;e<d;e++){var f=this.features[e].position,g=this.features[e].getEnd();(f>=a&&f<=b||g>=a&&g<=b)&&c.push(this.features[e])}return c}});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();
32
+ this.ctx.font=e+"px "+d;d=this.ctx.measureText(f);var g=[f],h=e+10,i=d.width+10,k,l;d=0;a.seq&&(d=this.ntOffset*(a.getPixelLength()/a.length));d=a.getPixelPositionX()+this.horizontalOffset+d;var j;j=this.placement=="below"?a.getPixelPositionY()+a.getHeight()-this.verticalOffset:a.getPixelPositionY()-h-this.verticalOffset;a.getPixelLength();if(i>200)g=this.ctx.measureText("s").width,g=parseInt(200/g),f=ScriblWrapLines(g,f),i=210,h=f[1]*e+10,g=f[0];i+d>this.chart.width&&(d=this.chart.width-i);if(this.chart.tooltips.style==
33
+ "light")k=this.chart.ctx.createLinearGradient(d+i/2,j,d+i/2,j+h),k.addColorStop(0,"rgb(253, 248, 196)"),k.addColorStop(0.75,"rgb(253, 248, 196)"),k.addColorStop(1,"white"),l=this.chart.ctx.createLinearGradient(d+i/2,j,d+i/2,j+h),l.addColorStop(0,"black"),l.addColorStop(1,"rgb(64, 64, 64)"),this.chart.tooltips.text.color="black";else if(this.chart.tooltips.style=="dark")k=this.chart.ctx.createLinearGradient(d+i/2,j,d+i/2,j+h),k.addColorStop(0,"rgb(64, 64, 64)"),k.addColorStop(1,"rgb(121, 121, 121)"),
34
+ l="white",this.chart.tooltips.text.color="white";this.chart.lastToolTips.push({pixels:this.ctx.getImageData(d-1,j-1,i+2,h+2),x:d-1,y:j-1});this.ctx.fillStyle=k;this.ctx.beginPath();tlc_ctrl_x=d;tlc_ctrl_y=j;tlc_lgth_x=d+c;tlc_lgth_y=j;tlc_wdth_x=d;tlc_wdth_y=j+c;blc_ctrl_x=d;blc_ctrl_y=j+h;blc_lgth_x=d+c;blc_lgth_y=j+h;blc_wdth_x=d;blc_wdth_y=j+h-c;brc_ctrl_x=d+i;brc_ctrl_y=j+h;brc_lgth_x=d+i-c;brc_lgth_y=j+h;brc_wdth_x=d+i;brc_wdth_y=j+h-c;trc_ctrl_x=d+i;trc_ctrl_y=j;trc_lgth_x=d+i-c;trc_lgth_y=
35
+ j;trc_wdth_x=d+i;trc_wdth_y=j+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);
36
+ this.ctx.fill();this.ctx.lineWidth=this.chart.tooltips.borderWidth;this.ctx.strokeStyle=l;this.ctx.stroke();this.ctx.textBaseline="middle";this.ctx.fillStyle=this.chart.tooltips.text.color;for(c=0;c<g.length;c++)this.ctx.measureText(g[c]),this.ctx.fillText(g[c],d+5,j+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),
116
37
  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),
117
38
  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=
118
- 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=
119
- 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}});
120
- 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};
39
+ 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&&b.onMouseover==void 0&&b.parent&&b.parent.onMouseover)b.onMouseover=b.parent.onMouseover;if(b&&b.onMouseover)if(typeof b.onMouseover=="string")a.tooltip.fire(b);else if(typeof b.onMouseover=="function")b.onMouseover(b);
40
+ 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}});
41
+ 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(" "),g=0;g<f.length;g++)f[g].length+d.length<=a?d+=" "+f[g]:d==""?(trunc1=f[g].slice(0,a-1),d+=" "+trunc1+"-",trunc2=f[g].slice(a,f[g].length),f.splice(g+1,0,trunc2),c.push(d),d="",e++):(g--,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};Object.keys=Object.keys||function(a,b,c){c=[];for(b in a)c.hasOwnProperty.call(a,b)&&c.push(b);return c};
121
42
  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()>
122
43
  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};
123
- 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);
44
+ svgToString=function(a,b){var c=[];if(a){var d=a.attributes,e,f,g=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 h={};$(a).find("*").andSelf().each(function(){$.each(this.attributes,function(a,b){var d=b.namespaceURI;d&&!h[d]&&nsMap[d]!=="xmlns"&&nsMap[d]!=="xml"&&(h[d]=!0,c.push(" xmlns:"+nsMap[d]+'="'+d+'"'))})});for(f=d.length;f--;){e=d.item(f);var i=toXml(e.nodeValue);
124
45
  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=
125
- 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);
46
+ 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<g.length;f++)switch(e=g.item(f),e.nodeType){case 1:c.push("\n");c.push(svgToString(g.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);
126
47
  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;
127
48
  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=
128
- 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(a){a=a||this.glyphType;if(a=="Rect"||a=="Line")this.strand=void 0;a=this.strand?"new "+a+'("'+this.type+'",'+this.position+","+this.length+',"'+this.strand+
129
- '",'+JSON.stringify(this.opts)+")":"new "+a+'("'+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},
130
- 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),
131
- 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&&
132
- 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==
133
- "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]=
134
- 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,
135
- 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"),
136
- 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)/
137
- (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=
138
- 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,
139
- 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=
49
+ 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(a){a=a||this.glyphType;if(a=="Rect"||a=="Line")this.strand=void 0;if(this.strand){a="new "+a+'("'+this.type+'",'+this.position+","+this.length+',"'+this.strand+
50
+ '",'+JSON.stringify(this.opts)+")";a=eval(a);var b=Object.keys(this),c=0}else a="new "+a+'("'+this.type+'",'+this.position+","+this.length+","+JSON.stringify(this.opts)+")",a=eval(a),b=Object.keys(this),c=0;for(;c<b.length;c++)a[b[c]]=this[b[c]];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=
51
+ 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 g=void 0,h=this.getAttr("text-align");h=="start"?h=this.strand=="+"?"left":"right":h=="end"&&(h=this.strand=="+"?"right":"left");b.textAlign=h;h=="left"?g=5:
52
+ h=="center"?g=c/2:h=="right"&&(g=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),h=="center"&&(c=-(b.measureText(a).width/2+2.5)),b.clearRect(g+c,d/2-e/2,b.measureText(a).width+5,e));b.fillText(a,g,d/2)}},calcRoundness:function(){var a=this.getHeight()*this.getAttr("roundness")/100;return a=(a*10%5>=2.5?parseInt(a*10/5)*5+5:parseInt(a*10/5)*5)/10},isContainedWithinRect:function(a,
53
+ b,c,d){var e=this.getPixelPositionY(),f=this.getPixelPositionX(),g=this.getPixelPositionX()+this.getPixelLength(),h=e+this.getHeight();return f>=a&&g<=c&&e>=b&&h<=d},getHeight:function(){return this.lane.getHeight()},getFillStyle:function(){var a=this.getAttr("color");if(a instanceof Array){for(var b=this.lane.track.chart.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?
54
+ (b=this.lane.track.chart.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(),
55
+ 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);
56
+ 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==
57
+ "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)},redraw:function(){this.lane.ctx.save();
58
+ this.lane.ctx.translate(0,this.getPixelPositionY());this.draw();this.lane.ctx.restore()}});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=Math.round((a_max_x-(1-t)*(1-t)*a_b_x-
59
+ t*t*a_t_x)/(2*(1-t)*t)*10)/10;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=-(Math.round((bs_slope*a_b_x+bs_intercept)*10)/10);a_t_y=-(Math.round((ts_slope*a_t_x+ts_intercept)*10)/10);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=-(Math.round((bs_slope*bs_slpe_x+bs_intercept)*
60
+ 10)/10),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=-(Math.round((ts_slope*ts_slpe_x+ts_intercept)*10)/10),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,
61
+ 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=
140
62
  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(),
141
- 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";e=a.font;g=/[\d+px]/.exec(e)+"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=
142
- g;this.imgCanvas.height=c;f=this.imgCanvas.getContext("2d");for(g=j=i=0;g<this.seq.length;g++){h.heights[c][this.seq[g]]||this.createChar(this.seq[g],"black","white",c);var m=this.seq[g];this.insertions[j]&&this.insertions[j].pos!=void 0&&(this.insertions[j].pos-1==g?m+="rightInsert":this.insertions[j]&&this.insertions[j].pos==g&&(m+="leftInsert",j++));f.drawImage(h.heights[c][m],i,y);i+=h.heights[c].width}a.drawImage(this.imgCanvas,x,c-c*d,b,c*d);a.font=e;a.restore()}a.beginPath();a.moveTo(0,0);
143
- 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=
144
- 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";
145
- 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;
63
+ g=SCRIBL.chars;if(!g.heights[c]){g.heights[c]=[];for(var h=0;h<this.chars.list.length;h++){var i=this.chars.list[h],k=i;i=="-"&&(k="dash");this.createChar(i,g.nt_color,g["nt_"+k+"_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";e=a.font;h=/[\d+px]/.exec(e)+"px";a.font=h+" courier";a.fillStyle="black";a.textAlign="left";h=this.seq.length*g.heights[c].width;this.imgCanvas=document.createElement("canvas");this.imgCanvas.width=
64
+ h;this.imgCanvas.height=c;f=this.imgCanvas.getContext("2d");for(h=k=i=0;h<this.seq.length;h++){g.heights[c][this.seq[h]]||this.createChar(this.seq[h],"black","white",c);var l=this.seq[h];this.insertions[k]&&this.insertions[k].pos!=void 0&&(this.insertions[k].pos-1==h?l+="rightInsert":this.insertions[k]&&this.insertions[k].pos==h&&(l+="leftInsert",k++));f.drawImage(g.heights[c][l],i,y);i+=g.heights[c].width}a.drawImage(this.imgCanvas,x,c-c*d,b,c*d);a.font=e;a.restore()}a.beginPath();a.moveTo(0,0);
65
+ 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"),g=d-2;f.font=g+"px courier";var h=f.measureText(a).width+2;e.height=d;e.width=h;SCRIBL.chars.heights[d].width=h;e=document.createElement("canvas");f=e.getContext("2d");f.font=g+"px courier";e.height=d;e.width=
66
+ h;var i=f.fillStyle;f.fillStyle=c;f.fillRect(0,0,h,d);f.fillStyle=b;f.textAlign="center";f.textBaseline="middle";f.fillText(a,h/2,d/2);SCRIBL.chars.heights[d][a]=e;f.fillStyle=i;e=document.createElement("canvas");f=e.getContext("2d");f.font=g+"px courier";e.height=d;e.width=h;i=f.fillStyle;f.fillStyle=c;f.fillRect(0,0,h,d);f.fillStyle="yellow";f.beginPath();f.moveTo(0,d);f.arcTo(h,d,h,0,d/2);f.lineTo(h,d);f.lineTo(0,d);f.closePath();f.fill();f.fillStyle=b;f.textAlign="center";f.textBaseline="middle";
67
+ f.fillText(a,h/2,d/2);SCRIBL.chars.heights[d][a+"rightInsert"]=e;f.fillStyle=i;e=document.createElement("canvas");f=e.getContext("2d");f.font=g+"px courier";e.height=d;e.width=h;i=f.fillStyle;f.fillStyle=c;f.fillRect(0,0,h,d);f.fillStyle="yellow";f.beginPath();f.moveTo(h,d);f.arcTo(0,d,0,0,d/2);f.lineTo(0,d);f.lineTo(h,d);f.closePath();f.fill();f.fillStyle=b;f.textAlign="center";f.textBaseline="middle";f.fillText(a,h/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;
146
68
  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;
147
69
  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,
148
- 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))}}};
149
-
70
+ 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,g=void 0,h=0;h<c.length;h++){var i;if(i=c[h].match(d)){i.shift();e.push(i);var k=i[2];if(f==void 0||f>k)f=k;i=i[1];if(g==void 0||g<i)g=i}}b.scale.max=f;b.scale.min=g;for(c=0;c<e.length;c++)d="+",e[c][0]=="complement"&&(d="-"),i=e[c][1],k=e[c][2],i=i-1+1,b.addGene(i,k-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]),g=parseInt(e[2]),h=e[0]+": "+e[3],i=e[5],k=e[8],l=e[10].split(",");e=e[11].split(",");f=b.addFeature(new Complex("complex",f,g,i,[],{color:k,name:h}));for(g=0;g<l.length;g++){if(l[g]=="")break;f.addSubFeature(new BlockArrow("complex",parseInt(e[g]),parseInt(l[g]),i))}}};
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scribl-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-19 00:00:00.000000000 Z
13
+ date: 2013-02-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
17
- requirement: &2153541100 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,7 +22,12 @@ dependencies:
22
22
  version: '3.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2153541100
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '3.1'
26
31
  description: ! 'A gem to automate using the Scribl bioinformatics graphics library
27
32
  with Rails 3 asset pipeline '
28
33
  email:
@@ -56,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
61
  version: '0'
57
62
  requirements: []
58
63
  rubyforge_project:
59
- rubygems_version: 1.8.12
64
+ rubygems_version: 1.8.24
60
65
  signing_key:
61
66
  specification_version: 3
62
67
  summary: Provides a Scribl javascript driver for Rails 3 applications