<commit_before>/*

 HMM logo
 http://github.com/url/here
 Copyright 2013, <NAME>.
 Licensed under the MIT License.
 http://url/to/license
*/
(function(d){function k(){if(!b){var a=document.createElement("canvas");b=!(!a.getContext||!a.getContext("2d"))}return b}function g(a,b){b=b||{};this.value=a;this.width=parseInt(b.width,10)||100;"W"===this.value&&(this.width+=30*this.width/100);this.height=parseInt(b.height,10)||100;this.color=b.color||"#000000";this.fontSize=b.fontSize||138;this.scaled=function(){};this.draw=function(a,b,c,u,x){var d=a.font;a.transform(c/this.width,0,0,b/this.height,u,x);a.fillStyle=this.color;a.textAlign="center";
a.font="bold "+this.fontSize+"px Arial";a.fillText(this.value,0,0);a.setTransform(1,0,0,1,0,0);a.fillStyle="#000000";a.font=d}}function m(a){function b(c,a,u){c.beginPath();c.moveTo(0,a);c.lineTo(u,a);c.lineWidth=1;c.strokeStyle="#999999";c.stroke()}function f(c,a,b,u,f){f=f||"#999999";c.beginPath();c.moveTo(a,b);c.lineTo(a,b+u);c.lineWidth=1;c.strokeStyle=f;c.stroke()}function e(c,a,b,u,f,d,e,l){c.font=f+"px Arial";c.fillStyle=e;c.fillRect(a,b-10,d,14);c.textAlign="center";c.fillStyle=l;c.fillText(u,
a+d/2,b)}a=a||{};this.column_width=a.column_width||34;this.height=a.height||300;this.data=a.data||null;this.debug=a.debug||null;this.scale_height_enabled=a.height_toggle||null;this.zoom_enabled=a.zoom_buttons&&"disabled"===a.zoom_buttons?null:!0;this.alphabet=a.data.alphabet||"dna";this.dom_element=a.dom_element||d("body");this.called_on=a.called_on||null;this.start=a.start||1;this.end=a.end||this.data.height_arr.length;this.default_zoom=this.zoom=parseFloat(a.zoom)||0.4;this.data.max_height=a.scaled_max?
a.data.max_height_obs||this.data.max_height||2:a.data.max_height_theory||this.data.max_height||2;this.dna_colors={A:"#cbf751",C:"#5ec0cc",G:"#ffdf59",T:"#b51f16",U:"#b51f16"};this.aa_colors={A:"#FF9966",C:"#009999",D:"#FF0000",E:"#CC0033",F:"#00FF00",G:"#f2f20c",H:"#660033",I:"#CC9933",K:"#663300",L:"#FF9933",M:"#CC99CC",N:"#336666",P:"#0099FF",Q:"#6666CC",R:"#990000",S:"#0000FF",T:"#00FFFF",V:"#FFCC33",W:"#66CC66",Y:"#006600"};this.colors=this.dna_colors;"aa"===this.alphabet&&(this.colors=this.aa_colors);
this.canvas_width=5E3;this.letters={};a=null;for(a in this.colors)this.letters[a]=new g(a,{color:this.colors[a]});this.scrollme=null;this.previous_target=0;this.rendered=[];this.previous_zoom=0;this.render=function(c){if(this.data){c=c||{};var a=c.zoom||this.zoom,b=c.target||1,u=d(this.dom_element).parent().width(),f=1,e=0;if(b!==this.previous_target){this.previous_target=b;c.start&&(this.start=c.start);c.end&&(this.end=c.end);0.1>=a?a=0.1:1<=a&&(a=1);this.zoom=a;c=this.end||this.data.height_arr.length;
var h=this.start||1;c=c>this.data.height_arr.length?this.data.height_arr.length:c;c=c<h?h:c;h=h>c?c:h;h=1<h?h:1;this.y=this.height-20;this.max_width=this.column_width*(c-h+1);u>this.max_width&&(a=1,this.zoom_enabled=!1);this.zoom=a;this.zoomed_column=this.column_width*a;this.total_width=this.zoomed_column*(c-h+1);if(1>a)for(;this.total_width<u&&!(this.zoom+=0.1,this.zoomed_column=this.column_width*this.zoom,this.total_width=this.zoomed_column*(c-h+1),this.zoom_enabled=!1,1<=a););b>this.total_width&&
(b=this.total_width);d(this.dom_element).attr({width:this.total_width+"px"}).css({width:this.total_width+"px"});u=Math.ceil(this.total_width/this.canvas_width);this.columns_per_canvas=Math.ceil(this.canvas_width/this.zoomed_column);this.previous_zoom!==this.zoom&&(d(this.dom_element).find("canvas").remove(),this.previous_zoom=this.zoom,this.rendered=[]);this.canvases=[];this.contexts=[];for(e=0;e<u;e++){var l=this.columns_per_canvas*e+h,g=l+this.columns_per_canvas-1;g>c&&(g=c);var s=(g-l+1)*this.zoomed_column;
s>f&&(f=s);var n=f*e,w=n+s;if(b<w+w/2&&b>n-n/2&&1!==this.rendered[e]){var n=this.canvases,B=e,v=this.dom_element,t=this.height,m=s,C=e,D=f,y=d(v).find("#canv_"+C);y.length||(d(v).append('<canvas class="canvas_logo" id="canv_'+C+'"  height="'+t+'" width="'+m+'" style="left:'+D*C+'px"></canvas>'),y=d(v).find("#canv_"+C));d(y).attr("width",m).attr("height",t);k()||(y[0]=G_vmlCanvasManager.initElement(y[0]));n[B]=y[0];this.contexts[e]=this.canvases[e].getContext("2d");this.contexts[e].setTransform(1,
0,0,1,0,0);this.contexts[e].clearRect(0,0,s,this.height);this.contexts[e].fillStyle="#ffffff";this.contexts[e].fillRect(0,0,w,this.height);12<this.zoomed_column?(s=parseInt(10*a,10),s=10<s?10:s,this.debug&&this.render_with_rects(l,g,e,1),this.render_with_text(l,g,e,s)):this.render_with_rects(l,g,e);this.rendered[e]=1}}!this.scrollme&&k()&&(this.scrollme=new EasyScroller(d(this.dom_element)[0],{scrollingX:1,scrollingY:0,eventTarget:this.called_on}));1!==b&&k()&&this.scrollme.reflow()}}};this.render_x_axis_label=
function(){d(this.dom_element).parent().before('<div class="logo_xaxis" class="centered" style="margin-left:40px"><p class="xaxis_text" style="width:10em;margin:1em auto">Model Position</p></div>')};this.render_y_axis_label=function(){d(this.dom_element).parent().before('<canvas class="logo_yaxis" height="300" width="55"></canvas>');var c=d(this.called_on).find(".logo_yaxis");Math.abs(this.data.max_height);isNaN(this.data.min_height_obs)||parseInt(this.data.min_height_obs,10);k()||(c[0]=G_vmlCanvasManager.initElement(c[0]));
c=c[0].getContext("2d");c.beginPath();c.moveTo(55,1);c.lineTo(40,1);c.moveTo(55,256);c.lineTo(40,256);c.moveTo(55,128);c.lineTo(40,128);c.lineWidth=1;c.strokeStyle="#666666";c.stroke();c.fillStyle="#666666";c.textAlign="right";c.font="bold 10px Arial";c.textBaseline="top";c.fillText(this.data.max_height.toFixed(1),38,0);c.textBaseline="middle";c.fillText(parseFloat(this.data.max_height/2).toFixed(1),38,128);c.fillText("0",38,256);c.save();c.translate(5,this.height/2-20);c.rotate(-Math.PI/2);c.textAlign=
"center";c.font="normal 12px Arial";c.fillText("Information Content (bits)",1,0);c.restore();c.fillText("occupancy",55,263);c.fillText("ins. prob.",50,280);c.fillText("ins. len.",46,296)};this.render_x_axis_label();this.render_y_axis_label();this.render_with_text=function(c,a,d,q){var g=0,p=c,h=0,h=Math.abs(this.data.max_height),l=isNaN(this.data.min_height_obs)?0:parseInt(this.data.min_height_obs,10),h=h+Math.abs(l),h=Math.round(100*Math.abs(this.data.max_height)/h);Math.round(256*h/100);a+3<=this.end&&
(a+=3);for(h=c;h<=a;h++){if(this.data.mmline&&1===this.data.mmline[h-1])this.contexts[d].fillStyle="#cccccc",this.contexts[d].fillRect(g,10,this.zoomed_column,this.height-40);else if(c=this.data.height_arr[h-1],l=[],c){for(var r=0,s=c.length,n=0,n=0;n<s;n++){var w=c[n].split(":",2),m=g+this.zoomed_column/2,v=null;if(0.01<w[1]){var v=parseFloat(w[1])/this.data.max_height,w=255-r,t=255*v;k()||(w+=t*(v/2));l[n]=[t,this.zoomed_column,m,w];r+=t}}for(n=s;0<=n;n--)l[n]&&this.letters[c[n][0]]&&this.letters[c[n][0]].draw(this.contexts[d],
l[n][0],l[n][1],l[n][2],l[n][3])}f(this.contexts[d],g,this.height-15,5);f(this.contexts[d],g,this.height-30,5);f(this.contexts[d],g,this.height-45,5);0.7>this.zoom?0===h%5&&this.draw_column_divider({context_num:d,x:g,fontsize:10,column_num:p,ralign:!0}):this.draw_column_divider({context_num:d,x:g,fontsize:q,column_num:p});c=this.data.delete_probs[h-1]/100;l=this.height-35;r="#ffffff";s="#555555";0.25<c?(r="#2171b5",s="#ffffff"):0.15<c?r="#6baed6":0.05<c&&(r="#bdd7e7");e(this.contexts[d],g,l,c,q,this.zoomed_column,
r,s);c=this.contexts[d];l=g;r=this.height;s=this.zoomed_column;n=this.data.insert_probs[h-1]/100;m=r-20;v="#ffffff";w="#555555";0.1<n?(v="#d7301f",w="#ffffff"):0.05<n?v="#fc8d59":0.03<n&&(v="#fdcc8a");e(c,l,m,n,q,s,v,w);0.03<n&&f(c,l+s,r-30,-30-r,v);c=this.data.insert_lengths[h-1];l="#ffffff";r="#555555";9<c?(l="#d7301f",r="#ffffff"):7<c?l="#fc8d59":4<c&&(l="#fdcc8a");e(this.contexts[d],g,this.height-5,c,q,this.zoomed_column,l,r);g+=this.zoomed_column;p++}b(this.contexts[d],this.height-15,this.total_width);
b(this.contexts[d],this.height-30,this.total_width);b(this.contexts[d],this.height-45,this.total_width);b(this.contexts[d],0,this.total_width)};this.draw_column_divider=function(c){var a=c.ralign?c.x+this.zoomed_column:c.x,b=c.ralign?c.x+2:c.x;f(this.contexts[c.context_num],a,this.height-30,-30-this.height,"#dddddd");f(this.contexts[c.context_num],a,0,5);var a=this.contexts[c.context_num],u=this.zoomed_column,e=c.column_num,d=c.ralign;a.font=c.fontsize+"px Arial";a.textAlign=d?"right":"center";a.fillStyle=
"#666666";a.fillText(e,b+u/2,10)};this.render_with_rects=function(c,a,e,d){var g=0,p=c,h=0,h=Math.abs(this.data.max_height),l=Math.abs(this.data.min_height_obs),h=h+l,h=Math.round(100*Math.abs(this.data.max_height)/h);Math.round(256*h/100);l=10;for(h=c;h<=a;h++){if(this.data.mmline&&1===this.data.mmline[h-1])this.contexts[e].fillStyle="#cccccc",this.contexts[e].fillRect(g,10,this.zoomed_column,this.height-40);else{c=this.data.height_arr[h-1];for(var r=0,s=c.length,n=0,n=0;n<s;n++){var k=c[n].split(":",
2);if(0.01<k[1]){var m=parseFloat(k[1])/this.data.max_height,v=g,m=256*m,t=256-r-m;d?(this.contexts[e].strokeStyle=this.colors[k[0]],this.contexts[e].strokeRect(v,t,this.zoomed_column,m)):(this.contexts[e].fillStyle=this.colors[k[0]],this.contexts[e].fillRect(v,t,this.zoomed_column,m));r+=m}}}0.2>this.zoom?l=20:0.3>this.zoom&&(l=10);0===h%l&&(f(this.contexts[e],g+this.zoomed_column,this.height-30,parseFloat(this.height),"#dddddd"),f(this.contexts[e],g+this.zoomed_column,0,5),c=this.contexts[e],r=
g-2,s=this.zoomed_column,n=p,c.font="10px Arial",c.textAlign="right",c.fillStyle="#666666",c.fillText(n,r+s/2,10));c=this.contexts[e];r=g;s=this.height-42;n=this.zoomed_column;k=this.data.insert_probs[h-1]/100;v=this.data.insert_lengths[h-1];m=this.data.delete_probs[h-1]/100;t="#ffffff";0.1<k?t="#d7301f":0.05<k?t="#fc8d59":0.03<k&&(t="#fdcc8a");c.fillStyle=t;c.fillRect(r,s+12,n,10);t="#ffffff";9<v?t="#d7301f":7<v?t="#fc8d59":4<v&&(t="#fdcc8a");c.fillStyle=t;c.fillRect(r,s+24,n,10);t="#ffffff";0.25<
m?t="#2171b5":0.15<m?t="#6baed6":0.05<m&&(t="#bdd7e7");c.fillStyle=t;c.fillRect(r,s,n,10);b(this.contexts[e],this.height-45,this.total_width);b(this.contexts[e],0,this.total_width);g+=this.zoomed_column;p++}};this.toggle_scale=function(){var c=this.current_column();this.data.max_height=this.data.max_height===this.data.max_height_obs?this.data.max_height_theory:this.data.max_height_obs;this.rendered=[];d(this.called_on).find(".logo_yaxis").remove();this.render_y_axis_label();this.scrollme.reflow();
this.scrollToColumn(c+1);this.scrollToColumn(c)};this.current_column=function(){var c=this.scrollme.scroller.getValues().left,a=this.column_width*this.zoom,c=c/a,a=d(this.called_on).find(".logo_container").width()/a/2;return Math.ceil(c+a)};this.change_zoom=function(c){var a=0.3;c.target?a=c.target:c.distance&&(a=(parseFloat(this.zoom)-parseFloat(c.distance)).toFixed(1),"+"===c.direction&&(a=(parseFloat(this.zoom)+parseFloat(c.distance)).toFixed(1)));1<a?a=1:0.1>a&&(a=0.1);d(this.called_on).find(".logo_graphic").width()*
a/this.zoom>d(this.called_on).find(".logo_container").width()&&(c.column?(this.zoom=a,this.render({zoom:this.zoom}),this.scrollme.reflow(),a=this.coordinatesFromColumn(c.column),this.scrollme.scroller.scrollTo(a-c.offset)):(c=this.current_column(),this.zoom=a,this.render({zoom:this.zoom}),this.scrollme.reflow(),this.scrollToColumn(c)));return this.zoom};this.columnFromCoordinates=function(a){return Math.ceil(a/(this.column_width*this.zoom))};this.coordinatesFromColumn=function(a){return(a-1)*this.column_width*
this.zoom+this.column_width*this.zoom/2};this.scrollToColumn=function(a,b){var e=d(this.called_on).find(".logo_container").width()/2,u=this.coordinatesFromColumn(a);this.scrollme.scroller.scrollTo(u-e,0,b)}}var b=null;d.fn.hmm_logo=function(a){var b=null,f=d('<div class="logo_graphic">');if(k()){a=a||{};d(this).append(d('<div class="logo_container">').append(f).append('<div class="logo_divider">'));a.data=d(this).data("logo");if(null===a.data)return;a.dom_element=f;a.called_on=this;var e=d('<form class="logo_form"><fieldset><label for="position">Column number</label><input type="text" name="position" class="logo_position"></input><button class="button logo_change">Go</button></fieldset></form>'),
b=new m(a);b.render(a);b.scale_height_enabled&&b.data.max_height_obs<b.data.max_height_theory&&e.append('<button class="logo_scale button">Toggle Scale</button><br/>');b.zoom_enabled&&e.append('<button class="logo_zoomout button">-</button><button class="logo_zoomin button">+</button>');d(this).append(e);d(this).find(".logo_reset").bind("click",function(a){a.preventDefault();a=b;a.change_zoom({target:a.default_zoom})});d(this).find(".logo_change").bind("click",function(a){a.preventDefault()});d(this).find(".logo_zoomin").bind("click",
function(a){a.preventDefault();b.change_zoom({distance:0.1,direction:"+"})});d(this).find(".logo_zoomout").bind("click",function(a){a.preventDefault();b.change_zoom({distance:0.1,direction:"-"})});d(this).find(".logo_scale").bind("click",function(a){a.preventDefault();b.toggle_scale()});d(this).find(".logo_position").bind("change",function(){var a=b;this.value.match(/^\d+$/m)&&a.scrollToColumn(this.value,1)});f.bind("dblclick",function(a){var e=b,f=d(this).offset(),f=parseInt(a.pageX-f.left,10);a=
a.pageX-d(this).parent().offset().left;f=e.columnFromCoordinates(f);1>e.zoom?e.change_zoom({target:1,offset:a,column:f}):e.change_zoom({target:0.3,offset:a,column:f})});a.column_info&&f.bind("click",function(c){var e=b,f=d('<table class="logo_col_info"></table>'),g="<tr>",k="",p=d(this).offset();c=parseInt(c.pageX-p.left,10);d(this).parent().offset();e=e.columnFromCoordinates(c);c=[];var h=p=0,l=0,l="Probability";b.data.height_calc&&"score"===b.data.height_calc?(l="Score",c=b.data.height_arr[e-1].slice(0).reverse()):
c=b.data.probs_arr[e-1].slice(0).reverse();p=Math.ceil(c.length/5);for(h=0;h<p;h++)g=1<p&&h<p-1?g+('<th>Residue</th><th class="odd">'+l+"</th>"):g+("<th>Residue</th><th>"+l+"</th>");f.append(d(g+"</tr>"));for(h=0;5>h;h++){k+="<tr>";for(l=h;c[l];)g=c[l].split(":",2),k=1<p&&15>l?k+('<td class="'+b.alphabet+"_"+g[0]+'"><div></div>'+g[0]+'</td><td class="odd">'+g[1]+"</td>"):k+('<td class="'+b.alphabet+"_"+g[0]+'"><div></div>'+g[0]+"</td><td>"+g[1]+"</td>"),l+=5;k+="</tr>"}f.append(d(k));d(a.column_info).empty().append(d("<p> Column:"+
e+"</p>")).append(f).show()});d(document).bind(this.attr("id")+".scrolledTo",function(a,e,f,d){b.render({target:e})});d(document).keydown(function(a){a.ctrlKey||(61!==a.which&&107!==a.which||b.change_zoom({distance:0.1,direction:"+"}),109!==a.which&&0!==a.which||b.change_zoom({distance:0.1,direction:"-"}))})}else d("#logo").replaceWith(d("#no_canvas").html());return b}})(jQuery);/*

 Scroller
 http://github.com/zynga/scroller

 Copyright 2011, Zynga Inc.
 Licensed under the MIT License.
 https://raw.github.com/zynga/scroller/master/MIT-LICENSE.txt

 Based on the work of: Unify Project (unify-project.org)
 http://unify-project.org<commit_msg>Changed delete_prob. to occupancy in javascript.<commit_after>/*

 HMM logo
 http://github.com/url/here
 Copyright 2013, <NAME>.
 Licensed under the MIT License.
 http://url/to/license
*/
(function(d){function k(){if(!b){var a=document.createElement("canvas");b=!(!a.getContext||!a.getContext("2d"))}return b}function g(a,b){b=b||{};this.value=a;this.width=parseInt(b.width,10)||100;"W"===this.value&&(this.width+=30*this.width/100);this.height=parseInt(b.height,10)||100;this.color=b.color||"#000000";this.fontSize=b.fontSize||138;this.scaled=function(){};this.draw=function(a,b,c,u,x){var d=a.font;a.transform(c/this.width,0,0,b/this.height,u,x);a.fillStyle=this.color;a.textAlign="center";
a.font="bold "+this.fontSize+"px Arial";a.fillText(this.value,0,0);a.setTransform(1,0,0,1,0,0);a.fillStyle="#000000";a.font=d}}function m(a){function b(c,a,u){c.beginPath();c.moveTo(0,a);c.lineTo(u,a);c.lineWidth=1;c.strokeStyle="#999999";c.stroke()}function f(c,a,b,u,f){f=f||"#999999";c.beginPath();c.moveTo(a,b);c.lineTo(a,b+u);c.lineWidth=1;c.strokeStyle=f;c.stroke()}function e(c,a,b,u,f,d,e,l){c.font=f+"px Arial";c.fillStyle=e;c.fillRect(a,b-10,d,14);c.textAlign="center";c.fillStyle=l;c.fillText(u,
a+d/2,b)}a=a||{};this.column_width=a.column_width||34;this.height=a.height||300;this.data=a.data||null;this.debug=a.debug||null;this.scale_height_enabled=a.height_toggle||null;this.zoom_enabled=a.zoom_buttons&&"disabled"===a.zoom_buttons?null:!0;this.alphabet=a.data.alphabet||"dna";this.dom_element=a.dom_element||d("body");this.called_on=a.called_on||null;this.start=a.start||1;this.end=a.end||this.data.height_arr.length;this.default_zoom=this.zoom=parseFloat(a.zoom)||0.4;this.data.max_height=a.scaled_max?
a.data.max_height_obs||this.data.max_height||2:a.data.max_height_theory||this.data.max_height||2;this.dna_colors={A:"#cbf751",C:"#5ec0cc",G:"#ffdf59",T:"#b51f16",U:"#b51f16"};this.aa_colors={A:"#FF9966",C:"#009999",D:"#FF0000",E:"#CC0033",F:"#00FF00",G:"#f2f20c",H:"#660033",I:"#CC9933",K:"#663300",L:"#FF9933",M:"#CC99CC",N:"#336666",P:"#0099FF",Q:"#6666CC",R:"#990000",S:"#0000FF",T:"#00FFFF",V:"#FFCC33",W:"#66CC66",Y:"#006600"};this.colors=this.dna_colors;"aa"===this.alphabet&&(this.colors=this.aa_colors);
this.canvas_width=5E3;this.letters={};a=null;for(a in this.colors)this.letters[a]=new g(a,{color:this.colors[a]});this.scrollme=null;this.previous_target=0;this.rendered=[];this.previous_zoom=0;this.render=function(c){if(this.data){c=c||{};var a=c.zoom||this.zoom,b=c.target||1,u=d(this.dom_element).parent().width(),f=1,e=0;if(b!==this.previous_target){this.previous_target=b;c.start&&(this.start=c.start);c.end&&(this.end=c.end);0.1>=a?a=0.1:1<=a&&(a=1);this.zoom=a;c=this.end||this.data.height_arr.length;
var h=this.start||1;c=c>this.data.height_arr.length?this.data.height_arr.length:c;c=c<h?h:c;h=h>c?c:h;h=1<h?h:1;this.y=this.height-20;this.max_width=this.column_width*(c-h+1);u>this.max_width&&(a=1,this.zoom_enabled=!1);this.zoom=a;this.zoomed_column=this.column_width*a;this.total_width=this.zoomed_column*(c-h+1);if(1>a)for(;this.total_width<u&&!(this.zoom+=0.1,this.zoomed_column=this.column_width*this.zoom,this.total_width=this.zoomed_column*(c-h+1),this.zoom_enabled=!1,1<=a););b>this.total_width&&
(b=this.total_width);d(this.dom_element).attr({width:this.total_width+"px"}).css({width:this.total_width+"px"});u=Math.ceil(this.total_width/this.canvas_width);this.columns_per_canvas=Math.ceil(this.canvas_width/this.zoomed_column);this.previous_zoom!==this.zoom&&(d(this.dom_element).find("canvas").remove(),this.previous_zoom=this.zoom,this.rendered=[]);this.canvases=[];this.contexts=[];for(e=0;e<u;e++){var l=this.columns_per_canvas*e+h,g=l+this.columns_per_canvas-1;g>c&&(g=c);var s=(g-l+1)*this.zoomed_column;
s>f&&(f=s);var n=f*e,w=n+s;if(b<w+w/2&&b>n-n/2&&1!==this.rendered[e]){var n=this.canvases,B=e,v=this.dom_element,t=this.height,m=s,C=e,D=f,y=d(v).find("#canv_"+C);y.length||(d(v).append('<canvas class="canvas_logo" id="canv_'+C+'"  height="'+t+'" width="'+m+'" style="left:'+D*C+'px"></canvas>'),y=d(v).find("#canv_"+C));d(y).attr("width",m).attr("height",t);k()||(y[0]=G_vmlCanvasManager.initElement(y[0]));n[B]=y[0];this.contexts[e]=this.canvases[e].getContext("2d");this.contexts[e].setTransform(1,
0,0,1,0,0);this.contexts[e].clearRect(0,0,s,this.height);this.contexts[e].fillStyle="#ffffff";this.contexts[e].fillRect(0,0,w,this.height);12<this.zoomed_column?(s=parseInt(10*a,10),s=10<s?10:s,this.debug&&this.render_with_rects(l,g,e,1),this.render_with_text(l,g,e,s)):this.render_with_rects(l,g,e);this.rendered[e]=1}}!this.scrollme&&k()&&(this.scrollme=new EasyScroller(d(this.dom_element)[0],{scrollingX:1,scrollingY:0,eventTarget:this.called_on}));1!==b&&k()&&this.scrollme.reflow()}}};this.render_x_axis_label=
function(){d(this.dom_element).parent().before('<div class="logo_xaxis" class="centered" style="margin-left:40px"><p class="xaxis_text" style="width:10em;margin:1em auto">Model Position</p></div>')};this.render_y_axis_label=function(){d(this.dom_element).parent().before('<canvas class="logo_yaxis" height="300" width="55"></canvas>');var c=d(this.called_on).find(".logo_yaxis");Math.abs(this.data.max_height);isNaN(this.data.min_height_obs)||parseInt(this.data.min_height_obs,10);k()||(c[0]=G_vmlCanvasManager.initElement(c[0]));
c=c[0].getContext("2d");c.beginPath();c.moveTo(55,1);c.lineTo(40,1);c.moveTo(55,256);c.lineTo(40,256);c.moveTo(55,128);c.lineTo(40,128);c.lineWidth=1;c.strokeStyle="#666666";c.stroke();c.fillStyle="#666666";c.textAlign="right";c.font="bold 10px Arial";c.textBaseline="top";c.fillText(this.data.max_height.toFixed(1),38,0);c.textBaseline="middle";c.fillText(parseFloat(this.data.max_height/2).toFixed(1),38,128);c.fillText("0",38,256);c.save();c.translate(5,this.height/2-20);c.rotate(-Math.PI/2);c.textAlign=
"center";c.font="normal 12px Arial";c.fillText("Information Content (bits)",1,0);c.restore();c.fillText("occupancy",55,263);c.fillText("ins. prob.",50,280);c.fillText("ins. len.",46,296)};this.render_x_axis_label();this.render_y_axis_label();this.render_with_text=function(c,a,d,q){var g=0,p=c,h=0,h=Math.abs(this.data.max_height),l=isNaN(this.data.min_height_obs)?0:parseInt(this.data.min_height_obs,10),h=h+Math.abs(l),h=Math.round(100*Math.abs(this.data.max_height)/h);Math.round(256*h/100);a+3<=this.end&&
(a+=3);for(h=c;h<=a;h++){if(this.data.mmline&&1===this.data.mmline[h-1])this.contexts[d].fillStyle="#cccccc",this.contexts[d].fillRect(g,10,this.zoomed_column,this.height-40);else if(c=this.data.height_arr[h-1],l=[],c){for(var r=0,s=c.length,n=0,n=0;n<s;n++){var w=c[n].split(":",2),m=g+this.zoomed_column/2,v=null;if(0.01<w[1]){var v=parseFloat(w[1])/this.data.max_height,w=255-r,t=255*v;k()||(w+=t*(v/2));l[n]=[t,this.zoomed_column,m,w];r+=t}}for(n=s;0<=n;n--)l[n]&&this.letters[c[n][0]]&&this.letters[c[n][0]].draw(this.contexts[d],
l[n][0],l[n][1],l[n][2],l[n][3])}f(this.contexts[d],g,this.height-15,5);f(this.contexts[d],g,this.height-30,5);f(this.contexts[d],g,this.height-45,5);0.7>this.zoom?0===h%5&&this.draw_column_divider({context_num:d,x:g,fontsize:10,column_num:p,ralign:!0}):this.draw_column_divider({context_num:d,x:g,fontsize:q,column_num:p});c=this.data.delete_probs[h-1];l=this.height-35;r="#ffffff";s="#555555";0.75>c?(r="#2171b5",s="#ffffff"):0.85>c?r="#6baed6":0.95>c&&(r="#bdd7e7");e(this.contexts[d],g,l,c,q,this.zoomed_column,
r,s);c=this.contexts[d];l=g;r=this.height;s=this.zoomed_column;n=this.data.insert_probs[h-1];m=r-20;v="#ffffff";w="#555555";0.1<n?(v="#d7301f",w="#ffffff"):0.05<n?v="#fc8d59":0.03<n&&(v="#fdcc8a");e(c,l,m,n,q,s,v,w);0.03<n&&f(c,l+s,r-30,-30-r,v);c=this.data.insert_lengths[h-1];l="#ffffff";r="#555555";9<c?(l="#d7301f",r="#ffffff"):7<c?l="#fc8d59":4<c&&(l="#fdcc8a");e(this.contexts[d],g,this.height-5,c,q,this.zoomed_column,l,r);g+=this.zoomed_column;p++}b(this.contexts[d],this.height-15,this.total_width);
b(this.contexts[d],this.height-30,this.total_width);b(this.contexts[d],this.height-45,this.total_width);b(this.contexts[d],0,this.total_width)};this.draw_column_divider=function(c){var a=c.ralign?c.x+this.zoomed_column:c.x,b=c.ralign?c.x+2:c.x;f(this.contexts[c.context_num],a,this.height-30,-30-this.height,"#dddddd");f(this.contexts[c.context_num],a,0,5);var a=this.contexts[c.context_num],u=this.zoomed_column,e=c.column_num,d=c.ralign;a.font=c.fontsize+"px Arial";a.textAlign=d?"right":"center";a.fillStyle=
"#666666";a.fillText(e,b+u/2,10)};this.render_with_rects=function(c,a,e,d){var g=0,p=c,h=0,h=Math.abs(this.data.max_height),l=Math.abs(this.data.min_height_obs),h=h+l,h=Math.round(100*Math.abs(this.data.max_height)/h);Math.round(256*h/100);l=10;for(h=c;h<=a;h++){if(this.data.mmline&&1===this.data.mmline[h-1])this.contexts[e].fillStyle="#cccccc",this.contexts[e].fillRect(g,10,this.zoomed_column,this.height-40);else{c=this.data.height_arr[h-1];for(var r=0,s=c.length,n=0,n=0;n<s;n++){var k=c[n].split(":",
2);if(0.01<k[1]){var m=parseFloat(k[1])/this.data.max_height,v=g,m=256*m,t=256-r-m;d?(this.contexts[e].strokeStyle=this.colors[k[0]],this.contexts[e].strokeRect(v,t,this.zoomed_column,m)):(this.contexts[e].fillStyle=this.colors[k[0]],this.contexts[e].fillRect(v,t,this.zoomed_column,m));r+=m}}}0.2>this.zoom?l=20:0.3>this.zoom&&(l=10);0===h%l&&(f(this.contexts[e],g+this.zoomed_column,this.height-30,parseFloat(this.height),"#dddddd"),f(this.contexts[e],g+this.zoomed_column,0,5),c=this.contexts[e],r=
g-2,s=this.zoomed_column,n=p,c.font="10px Arial",c.textAlign="right",c.fillStyle="#666666",c.fillText(n,r+s/2,10));c=this.contexts[e];r=g;s=this.height-42;n=this.zoomed_column;k=this.data.insert_probs[h-1]/100;v=this.data.insert_lengths[h-1];m=this.data.delete_probs[h-1]/100;t="#ffffff";0.1<k?t="#d7301f":0.05<k?t="#fc8d59":0.03<k&&(t="#fdcc8a");c.fillStyle=t;c.fillRect(r,s+12,n,10);t="#ffffff";9<v?t="#d7301f":7<v?t="#fc8d59":4<v&&(t="#fdcc8a");c.fillStyle=t;c.fillRect(r,s+24,n,10);t="#ffffff";0.25<
m?t="#2171b5":0.15<m?t="#6baed6":0.05<m&&(t="#bdd7e7");c.fillStyle=t;c.fillRect(r,s,n,10);b(this.contexts[e],this.height-45,this.total_width);b(this.contexts[e],0,this.total_width);g+=this.zoomed_column;p++}};this.toggle_scale=function(){var c=this.current_column();this.data.max_height=this.data.max_height===this.data.max_height_obs?this.data.max_height_theory:this.data.max_height_obs;this.rendered=[];d(this.called_on).find(".logo_yaxis").remove();this.render_y_axis_label();this.scrollme.reflow();
this.scrollToColumn(c+1);this.scrollToColumn(c)};this.current_column=function(){var c=this.scrollme.scroller.getValues().left,a=this.column_width*this.zoom,c=c/a,a=d(this.called_on).find(".logo_container").width()/a/2;return Math.ceil(c+a)};this.change_zoom=function(c){var a=0.3;c.target?a=c.target:c.distance&&(a=(parseFloat(this.zoom)-parseFloat(c.distance)).toFixed(1),"+"===c.direction&&(a=(parseFloat(this.zoom)+parseFloat(c.distance)).toFixed(1)));1<a?a=1:0.1>a&&(a=0.1);d(this.called_on).find(".logo_graphic").width()*
a/this.zoom>d(this.called_on).find(".logo_container").width()&&(c.column?(this.zoom=a,this.render({zoom:this.zoom}),this.scrollme.reflow(),a=this.coordinatesFromColumn(c.column),this.scrollme.scroller.scrollTo(a-c.offset)):(c=this.current_column(),this.zoom=a,this.render({zoom:this.zoom}),this.scrollme.reflow(),this.scrollToColumn(c)));return this.zoom};this.columnFromCoordinates=function(a){return Math.ceil(a/(this.column_width*this.zoom))};this.coordinatesFromColumn=function(a){return(a-1)*this.column_width*
this.zoom+this.column_width*this.zoom/2};this.scrollToColumn=function(a,b){var e=d(this.called_on).find(".logo_container").width()/2,u=this.coordinatesFromColumn(a);this.scrollme.scroller.scrollTo(u-e,0,b)}}var b=null;d.fn.hmm_logo=function(a){var b=null,f=d('<div class="logo_graphic">');if(k()){a=a||{};d(this).append(d('<div class="logo_container">').append(f).append('<div class="logo_divider">'));a.data=d(this).data("logo");if(null===a.data)return;a.dom_element=f;a.called_on=this;var e=d('<form class="logo_form"><fieldset><label for="position">Column number</label><input type="text" name="position" class="logo_position"></input><button class="button logo_change">Go</button></fieldset></form>'),
b=new m(a);b.render(a);b.scale_height_enabled&&b.data.max_height_obs<b.data.max_height_theory&&e.append('<button class="logo_scale button">Toggle Scale</button><br/>');b.zoom_enabled&&e.append('<button class="logo_zoomout button">-</button><button class="logo_zoomin button">+</button>');d(this).append(e);d(this).find(".logo_reset").bind("click",function(a){a.preventDefault();a=b;a.change_zoom({target:a.default_zoom})});d(this).find(".logo_change").bind("click",function(a){a.preventDefault()});d(this).find(".logo_zoomin").bind("click",
function(a){a.preventDefault();b.change_zoom({distance:0.1,direction:"+"})});d(this).find(".logo_zoomout").bind("click",function(a){a.preventDefault();b.change_zoom({distance:0.1,direction:"-"})});d(this).find(".logo_scale").bind("click",function(a){a.preventDefault();b.toggle_scale()});d(this).find(".logo_position").bind("change",function(){var a=b;this.value.match(/^\d+$/m)&&a.scrollToColumn(this.value,1)});f.bind("dblclick",function(a){var e=b,f=d(this).offset(),f=parseInt(a.pageX-f.left,10);a=
a.pageX-d(this).parent().offset().left;f=e.columnFromCoordinates(f);1>e.zoom?e.change_zoom({target:1,offset:a,column:f}):e.change_zoom({target:0.3,offset:a,column:f})});a.column_info&&f.bind("click",function(c){var e=b,f=d('<table class="logo_col_info"></table>'),g="<tr>",k="",p=d(this).offset();c=parseInt(c.pageX-p.left,10);d(this).parent().offset();e=e.columnFromCoordinates(c);c=[];var h=p=0,l=0,l="Probability";b.data.height_calc&&"score"===b.data.height_calc?(l="Score",c=b.data.height_arr[e-1].slice(0).reverse()):
c=b.data.probs_arr[e-1].slice(0).reverse();p=Math.ceil(c.length/5);for(h=0;h<p;h++)g=1<p&&h<p-1?g+('<th>Residue</th><th class="odd">'+l+"</th>"):g+("<th>Residue</th><th>"+l+"</th>");f.append(d(g+"</tr>"));for(h=0;5>h;h++){k+="<tr>";for(l=h;c[l];)g=c[l].split(":",2),k=1<p&&15>l?k+('<td class="'+b.alphabet+"_"+g[0]+'"><div></div>'+g[0]+'</td><td class="odd">'+g[1]+"</td>"):k+('<td class="'+b.alphabet+"_"+g[0]+'"><div></div>'+g[0]+"</td><td>"+g[1]+"</td>"),l+=5;k+="</tr>"}f.append(d(k));d(a.column_info).empty().append(d("<p> Column:"+
e+"</p>")).append(f).show()});d(document).bind(this.attr("id")+".scrolledTo",function(a,e,f,d){b.render({target:e})});d(document).keydown(function(a){a.ctrlKey||(61!==a.which&&107!==a.which||b.change_zoom({distance:0.1,direction:"+"}),109!==a.which&&0!==a.which||b.change_zoom({distance:0.1,direction:"-"}))})}else d("#logo").replaceWith(d("#no_canvas").html());return b}})(jQuery);/*

 Scroller
 http://github.com/zynga/scroller

 Copyright 2011, Zynga Inc.
 Licensed under the MIT License.
 https://raw.github.com/zynga/scroller/master/MIT-LICENSE.txt

 Based on the work of: Unify Project (unify-project.org)
 http://unify-project.org
{'fraction_non_alphanumeric': 0.2775109976829309, 'fraction_numerical': 0.04734880284764431, 'mean_word_length': 13.541015625, 'pattern_counts': {'":': 26, '<': 198, '<?xml version=': 0, '>': 154, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7634983', 'n_tokens_mistral': 13760, 'n_tokens_neox': 13198, 'n_words': 328}