scribl-rails 1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/scribl-rails/version.rb +1 -1
- data/vendor/assets/javascripts/scribl.js +41 -38
- metadata +6 -6
data/lib/scribl-rails/version.rb
CHANGED
@@ -79,31 +79,33 @@ function adler32(a,b,c,d){if(b==null)return 1;var e=a&65535;a=a>>16&65535;for(va
|
|
79
79
|
a%=ADLER_BASE}return a<<16|e}
|
80
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
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");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.
|
84
|
-
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.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
|
-
|
87
|
-
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
|
-
slice:function(a,b,c){c=c||"inclusive";
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
this.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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,
|
84
|
+
"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);
|
99
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=
|
100
|
-
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(){
|
101
|
-
|
102
|
-
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,
|
103
|
-
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=
|
104
|
-
Math.max(this.coverageData[e],this.maxDepth)}},erase:function(){this.chart.ctx.clearRect(0,this.getPixelPositionY(),this.chart.width,this.getHeight())},draw:function(){if(this.status=="waiting")this.drawOnResponse=!0;else if(!this.hide){
|
105
|
-
|
106
|
-
for(a=this.chart.offset;a<=this.chart.width+this.chart.offset;a++)
|
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");
|
108
|
+
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=
|
107
109
|
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,
|
108
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();
|
109
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==
|
@@ -123,24 +125,25 @@ if(e.nodeName.indexOf("xmlns:")!==0&&i!=""&&["width","height","xmlns","x","y","v
|
|
123
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);
|
124
126
|
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;
|
125
127
|
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=
|
126
|
-
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(){
|
127
|
-
'("'+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},
|
128
|
-
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),
|
129
|
-
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&&
|
130
|
-
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==
|
131
|
-
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]=
|
132
|
-
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,
|
133
|
-
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"),
|
134
|
-
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)/
|
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)/
|
135
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=
|
136
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,
|
137
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=
|
138
140
|
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(),
|
139
|
-
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";
|
140
|
-
g;this.imgCanvas.height=c;
|
141
|
-
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=
|
142
|
-
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";
|
143
|
-
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;
|
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;
|
144
146
|
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;
|
145
147
|
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,
|
146
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
|
+
|
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:
|
4
|
+
version: 1.1.2
|
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-
|
13
|
+
date: 2012-02-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153541100 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,9 +22,9 @@ dependencies:
|
|
22
22
|
version: '3.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153541100
|
26
26
|
description: ! 'A gem to automate using the Scribl bioinformatics graphics library
|
27
|
-
with Rails 3
|
27
|
+
with Rails 3 asset pipeline '
|
28
28
|
email:
|
29
29
|
- georgkam@gmail.com
|
30
30
|
executables: []
|
@@ -59,6 +59,6 @@ rubyforge_project:
|
|
59
59
|
rubygems_version: 1.8.12
|
60
60
|
signing_key:
|
61
61
|
specification_version: 3
|
62
|
-
summary: Provides a Scribl javascript driver for Rails 3
|
62
|
+
summary: Provides a Scribl javascript driver for Rails 3 applications
|
63
63
|
test_files: []
|
64
64
|
has_rdoc:
|