commit/galaxy-central: jgoecks: Pack scripts.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/2edf7a8d376e/ changeset: 2edf7a8d376e user: jgoecks date: 2012-01-31 21:58:47 summary: Pack scripts. affected #: 1 file diff -r 55a4070a62e73ddd3ff387cb46a27410a2847110 -r 2edf7a8d376ea6521f7fa20045e57ca58275ce8b static/scripts/packed/trackster.js --- a/static/scripts/packed/trackster.js +++ b/static/scripts/packed/trackster.js @@ -1,1 +1,1 @@ -var class_module=function(b,a){var c=function(){var f=arguments[0];for(var e=1;e<arguments.length;e++){var d=arguments[e];for(key in d){f[key]=d[key]}}return f};a.extend=c};var requestAnimationFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(b,a){window.setTimeout(b,1000/60)}})();var BEFORE=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005,AFTER=1006;var compute_overlap=function(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=BEFORE}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=AFTER}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a};var is_overlap=function(c,b){var a=compute_overlap(c,b);return(a!==BEFORE&&a!==AFTER)};var is_deferred=function(a){return("isResolved" in a)};var get_random_color=function(a){if(!a){a="#ffffff"}if(typeof(a)==="string"){a=[a]}for(var j=0;j<a.length;j++){a[j]=parseInt(a[j].slice(1),16)}var n=function(t,s,i){return((t*299)+(s*587)+(i*114))/1000};var e=function(v,u,w,s,i,t){return(Math.max(v,s)-Math.min(v,s))+(Math.max(u,i)-Math.min(u,i))+(Math.max(w,t)-Math.min(w,t))};var g,o,f,k,q,h,r,c,d,b,p,m=false,l=0;do{g=Math.round(Math.random()*16777215);o=(g&16711680)>>16;f=(g&65280)>>8;k=g&255;d=n(o,f,k);m=true;for(var j=0;j<a.length;j++){q=a[j];h=(q&16711680)>>16;r=(q&65280)>>8;c=q&255;b=n(h,r,c);p=e(o,f,k,h,r,c);if((Math.abs(d-b)<40)||(p<200)){m=false;break}}l++}while(!m&&l<=10);return"#"+(16777216+g).toString(16).substr(1,6)};var create_action_icon=function(c,b,a){return $("<a/>").attr("href","javascript:void(0);").attr("title",c).addClass("icon-button").addClass(b).tipsy({gravity:"s"}).click(a)};var trackster_module=function(e,W){var p=e("class").extend,s=e("slotting"),L=e("painters");var ad=function(ae,af){this.document=ae;this.default_font=af!==undefined?af:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};p(ad.prototype,{load_pattern:function(ae,ai){var af=this.patterns,ag=this.dummy_context,ah=new Image();ah.src=image_path+ai;ah.onload=function(){af[ae]=ag.createPattern(ah,"repeat")}},get_pattern:function(ae){return this.patterns[ae]},new_canvas:function(){var ae=this.document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(ae)}ae.manager=this;return ae}});var n={};var l=function(ae,af){n[ae.attr("id")]=af};var m=function(ae,ag,ai,ah){ai=".group";var af={};n[ae.attr("id")]=ah;ae.bind("drag",{handle:"."+ag,relative:true},function(aq,ar){var ap=$(this);var av=$(this).parent(),am=av.children(),ao=n[$(this).attr("id")],al,ak,at,aj,an;ak=$(this).parents(ai);if(ak.length!==0){at=ak.position().top;aj=at+ak.outerHeight();if(ar.offsetY<at){$(this).insertBefore(ak);var au=n[ak.attr("id")];au.remove_drawable(ao);au.container.add_drawable_before(ao,au);return}else{if(ar.offsetY>aj){$(this).insertAfter(ak);var au=n[ak.attr("id")];au.remove_drawable(ao);au.container.add_drawable(ao);return}}}ak=null;for(an=0;an<am.length;an++){al=$(am.get(an));at=al.position().top;aj=at+al.outerHeight();if(al.is(ai)&&this!==al.get(0)&&ar.offsetY>=at&&ar.offsetY<=aj){if(ar.offsetY-at<aj-ar.offsetY){al.find(".content-div").prepend(this)}else{al.find(".content-div").append(this)}if(ao.container){ao.container.remove_drawable(ao)}n[al.attr("id")].add_drawable(ao);return}}for(an=0;an<am.length;an++){if(ar.offsetY<$(am.get(an)).position().top){break}}if(an===am.length){if(this!==am.get(an-1)){av.append(this);n[av.attr("id")].move_drawable(ao,an)}}else{if(this!==am.get(an)){$(this).insertBefore(am.get(an));n[av.attr("id")].move_drawable(ao,(ar.deltaY>0?an-1:an))}}}).bind("dragstart",function(){af["border-top"]=ae.css("border-top");af["border-bottom"]=ae.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(af)})};W.moveable=m;var ac=16,F=9,C=20,y=100,I=12000,Q=200,A=5,u=10,K=5000,v=100,o="There was an error in indexing this dataset. ",J="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",D="No data for this chrom/contig.",t="Currently indexing... please wait",w="Tool cannot be rerun: ",a="Loading data...",X="Ready for display",R=10,H=20;function Y(af,ae){if(!ae){ae=0}var ag=Math.pow(10,ae);return Math.round(af*ag)/ag}var c=function(ae){this.num_elements=ae;this.clear()};p(c.prototype,{get:function(af){var ae=this.key_ary.indexOf(af);if(ae!==-1){if(this.obj_cache[af].stale){this.key_ary.splice(ae,1);delete this.obj_cache[af]}else{this.move_key_to_end(af,ae)}}return this.obj_cache[af]},set:function(af,ag){if(!this.obj_cache[af]){if(this.key_ary.length>=this.num_elements){var ae=this.key_ary.shift();delete this.obj_cache[ae]}this.key_ary.push(af)}this.obj_cache[af]=ag;return ag},move_key_to_end:function(af,ae){this.key_ary.splice(ae,1);this.key_ary.push(af)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var S=function(af,ae,ag){c.call(this,af);this.track=ae;this.subset=(ag!==undefined?ag:true)};p(S.prototype,c.prototype,{load_data:function(an,ai,al,af,ak){var am=this.track.view.chrom,ah={chrom:am,low:an,high:ai,mode:al,resolution:af,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(ah,ak);if(this.track.filters_manager){var ao=[];var ae=this.track.filters_manager.filters;for(var aj=0;aj<ae.length;aj++){ao.push(ae[aj].name)}ah.filter_cols=JSON.stringify(ao)}var ag=this;return $.getJSON(this.track.data_url,ah,function(ap){ag.set_data(an,ai,ap)})},get_data:function(ae,ai,aj,af,ah){var ag=this.get(ae,ai);if(ag&&(is_deferred(ag)||this.track.data_and_mode_compatible(ag,aj))){return ag}ag=this.load_data(ae,ai,aj,af,ah);this.set_data(ae,ai,ag);return ag},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(am,ah,al,ag,ak,ai){var an=this.get(am,ah);if(!(an&&this.track.data_and_mode_compatible(an,al))){console.log("ERROR: no current data for: ",this.track,am,ah,al,ag,ak);return}an.stale=true;var af=am;if(ai===this.DEEP_DATA_REQ){$.extend(ak,{start_val:an.data.length+1})}else{if(ai===this.BROAD_DATA_REQ){af=(an.max_high?an.max_high:an.data[an.data.length-1][2])+1}}var ae=this,aj=this.load_data(af,ah,al,ag,ak);new_data_available=$.Deferred();this.set_data(am,ah,new_data_available);$.when(aj).then(function(ao){if(ao.data){ao.data=an.data.concat(ao.data);if(ao.max_low){ao.max_low=an.max_low}if(ao.message){ao.message=ao.message.replace(/[0-9]+/,ao.data.length)}}ae.set_data(am,ah,ao);new_data_available.resolve(ao)});return new_data_available},get:function(ae,af){return c.prototype.get.call(this,this.gen_key(ae,af))},set_data:function(af,ag,ae){return this.set(this.gen_key(af,ag),ae)},gen_key:function(ae,ag){var af=ae+"_"+ag;return af},split_key:function(ae){return ae.split("_")}});var G=function(af,ae,ag){S.call(this,af,ae,ag)};p(G.prototype,S.prototype,c.prototype,{get:S.prototype.get,load_data:function(ae,ah,ai,af,ag){if(af>1){return{data:null}}return S.prototype.load_data.call(this,ae,ah,ai,af,ag)}});var q=function(ah,af,ae,ag,aj){if(!q.id_counter){q.id_counter=0}this.id=q.id_counter++;this.name=ah;this.view=af;this.container=ae;this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ah}],saved_values:ag,onchange:function(){this.track.set_name(this.track.config.values.name)}});this.prefs=this.config.values;this.drag_handle_class=aj;this.is_overview=false;this.action_icons={};this.content_visible=true;this.container_div=this.build_container_div();this.header_div=this.build_header_div();if(this.header_div){this.container_div.append(this.header_div);this.icons_div=$("<div/>").css("float","left").hide().appendTo(this.header_div);this.build_action_icons(this.action_icons_def);this.header_div.append($("<div style='clear: both'/>"));this.header_div.dblclick(function(ak){ak.stopPropagation()});var ai=this;this.container_div.hover(function(){ai.icons_div.show()},function(){ai.icons_div.hide()});$("<div style='clear: both'/>").appendTo(this.container_div)}};q.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(ae){if(ae.content_visible){ae.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");ae.hide_contents();ae.content_visible=false}else{ae.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");ae.content_visible=true;ae.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"settings-icon",on_click_fn:function(af){var ah=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},ae=function(){af.config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ag=function(ai){if((ai.keyCode||ai.which)===27){ah()}else{if((ai.keyCode||ai.which)===13){ae()}}};$(window).bind("keypress.check_enter_esc",ag);show_modal("Configure",af.config.build_form(),{Cancel:ah,OK:ae})}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(ae){$(".tipsy").remove();ae.remove()}}];p(q.prototype,{init:function(){},can_draw:function(){if(this.enabled&&this.content_visible){return true}return false},request_draw:function(){},_draw:function(){},to_dict:function(){},from_dict:function(ae){},update_icons:function(){},set_name:function(ae){this.old_name=this.name;this.name=ae;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)},remove:function(){this.container.remove_drawable(this);this.container_div.hide(0,function(){$(this).remove();view.update_intro_div();view.has_changes=true})},build_container_div:function(){},build_header_div:function(){},add_action_icon:function(af,aj,ai,ah,ae){var ag=this;this.action_icons[af]=$("<a/>").attr("href","javascript:void(0);").attr("title",aj).addClass("icon-button").addClass(ai).tipsy({gravity:"s"}).click(function(){ah(ag)}).appendTo(this.icons_div)},build_action_icons:function(ae){var ag;for(var af=0;af<ae.length;af++){ag=ae[af];this.add_action_icon(ag.name,ag.title,ag.css_class,ag.on_click_fn,ag.prepend)}},update_icons:function(){},hide_contents:function(){},show_contents:function(){}});var x=function(ai,ah,af,ae,ag,aj){q.call(this,ah,af,ae,ag,aj);this.obj_type=ai;this.drawables=[]};p(x.prototype,q.prototype,{init:function(){for(var ae=0;ae<this.drawables.length;ae++){this.drawables[ae].init()}},_draw:function(){for(var ae=0;ae<this.drawables.length;ae++){this.drawables[ae]._draw()}},to_dict:function(){var af=[];for(var ae=0;ae<this.drawables.length;ae++){af.push(this.drawables[ae].to_dict())}return{name:this.name,prefs:this.prefs,obj_type:this.obj_type,drawables:af}},from_dict:function(ak,ae){var aj=new this.constructor(ak.name,view,ae,ak.prefs,view.viewport_container,view);var af,ai,ah;for(var ag=0;ag<ak.drawables.length;ag++){af=ak.drawables[ag];ai=af.obj_type;if(!ai){ai=af.track_type}ah=addable_objects[ai].prototype.from_dict(af,aj);aj.add_drawable(ah)}return aj},add_drawable:function(ae){this.drawables.push(ae);ae.container=this},add_drawable_before:function(ag,ae){var af=this.drawables.indexOf(ae);if(af!=-1){this.drawables.splice(af,0,ag);return true}return false},replace_drawable:function(ag,ae,af){var ah=this.drawables.indexOf(ag);if(ah!==-1){this.drawables[ah]=ae;if(af){ag.container_div.replaceWith(ae.container_div)}}return ah},remove_drawable:function(af){var ae=this.drawables.indexOf(af);if(ae!=-1){this.drawables.splice(ae,1);af.container=null;return true}return false},move_drawable:function(af,ag){var ae=this.drawables.indexOf(af);if(ae!=-1){this.drawables.splice(ae,1);this.drawables.splice(ag,0,af);return true}return false}});var P=function(ah,af,ae,ag){x.call(this,"DrawableGroup",ah,af,ae,ag,"group-handle");this.content_div=$("<div/>").addClass("content-div").attr("id","group_"+this.id+"_content_div").appendTo(this.container_div);l(this.container_div,this);l(this.content_div,this);m(this.container_div,this.drag_handle_class,".group",this);this.filters_manager=new Z(this);this.filters_div=this.filters_manager.parent_div;this.header_div.after(this.filters_div);this.saved_filters_managers=null};p(P.prototype,q.prototype,x.prototype,{action_icons_def:[q.prototype.action_icons_def[0],q.prototype.action_icons_def[1],{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(ae){$(".tipsy").remove();ae.show_composite_track()}},{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(af){if(af.filters_div.is(":visible")){af.filters_manager.clear_filters();for(var ae=0;ae<af.drawables.length;ae++){af.drawables[ae].filters_manager=af.saved_filters_managers[ae]}af.saved_filters_managers=null}else{if(af.filters_manager.filters.length>0){af.saved_filters_managers=[];for(var ae=0;ae<af.drawables.length;ae++){drawable=af.drawables[ae];af.saved_filters_managers.push(drawable.filters_manager);drawable.filters_manager=af.filters_manager}}af.filters_manager.init_filters();af.request_draw(true)}af.filters_div.toggle()}},q.prototype.action_icons_def[2]],build_container_div:function(){var ae=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(ae)}return ae},build_header_div:function(){var ae=$("<div/>").addClass("track-header");ae.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("track-name").text(this.name).appendTo(ae);return ae},hide_contents:function(){this.content_div.hide()},show_contents:function(){this.content_div.show();this.request_draw()},update_icons:function(){var ag=this.drawables.length;if(ag===0){this.action_icons.composite_icon.hide();this.action_icons.filters_icon.hide()}else{if(ag===1){if(this.drawables[0] instanceof h){this.action_icons.composite_icon.show()}this.action_icons.filters_icon.hide()}else{var ak,aq=true,ai=this.drawables[0].get_type(),ae=0;for(var an=0;an<ag;an++){ak=this.drawables[an];if(ak.get_type()!==ai){can_composite=false;break}if(ak instanceof d){ae++}}if(aq||ae===1){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tipsy").remove()}if(ae>1&&ae===this.drawables.length){var ar={},af;ak=this.drawables[0];for(var am=0;am<ak.filters_manager.filters.length;am++){af=ak.filters_manager.filters[am];ar[af.name]=[af]}for(var an=1;an<this.drawables.length;an++){ak=this.drawables[an];for(var am=0;am<ak.filters_manager.filters.length;am++){af=ak.filters_manager.filters[am];if(af.name in ar){ar[af.name].push(af)}}}this.filters_manager.remove_all();var ah,aj,al,ao;for(var ap in ar){ah=ar[ap];if(ah.length===ae){aj=new U(ah[0].name,ah[0].index);this.filters_manager.add_filter(aj)}}if(this.filters_manager.filters.length>0){this.action_icons.filters_icon.show()}else{this.action_icons.filters_icon.hide()}}else{this.action_icons.filters_icon.hide()}}}},show_composite_track:function(){var ai=[];for(var af=0;af<this.drawables.length;af++){ai.push(this.drawables[af].name)}var ag="Composite Track of "+this.drawables.length+" tracks ("+ai.join(", ")+")";var ah=new h(ag,this.view,this.view,this.drawables);var ae=this.container.replace_drawable(this,ah,true);ah.request_draw()},add_drawable:function(ae){x.prototype.add_drawable.call(this,ae);this.update_icons()},remove_drawable:function(ae){x.prototype.remove_drawable.call(this,ae);this.update_icons()},from_dict:function(ah,ae){var ag=x.prototype.from_dict.call(this,ah,ae);for(var af=0;af<ag.drawables.length;af++){ag.content_div.append(ag.drawables[af].container_div)}return ag},request_draw:function(ae,ag){for(var af=0;af<this.drawables.length;af++){this.drawables[af].request_draw(ae,ag)}}});var ab=function(ae,ah,ag,af){x.call(this,"View");this.container=ae;this.chrom=null;this.vis_id=ag;this.dbkey=af;this.title=ah;this.label_tracks=[];this.tracks_to_be_redrawn=[];this.max_low=0;this.max_high=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.load_chroms_deferred=null;this.init();this.canvas_manager=new ad(ae.get(0).ownerDocument);this.reset()};p(ab.prototype,x.prototype,{init:function(){var ag=this.container,ae=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ag);this.browser_content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ag);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ag);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.browser_content_div);this.content_div=this.viewport_container;l(this.viewport_container,ae);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container).hide();var ah=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){add_tracks()});this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a/>").attr("href","javascript:void(0);").attr("title","Close overview").addClass("icon-button overview-close tooltip").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var af=function(ai){if(ai.type==="focusout"||(ai.keyCode||ai.which)===13||(ai.keyCode||ai.which)===27){if((ai.keyCode||ai.which)!==27){ae.go_to($(this).val())}$(this).hide();$(this).val("");ae.location_span.show();ae.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",af).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").attr("original-title","Click to change location").tipsy({gravity:"n"}).appendTo(this.nav_controls);this.location_span.click(function(){ae.location_span.hide();ae.chrom_select.hide();ae.nav_input.val(ae.chrom+":"+ae.low+"-"+ae.high);ae.nav_input.css("display","inline-block");ae.nav_input.select();ae.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.nav_controls)}this.zo_link=$("<a/>").attr("id","zoom-out").attr("title","Zoom out").tipsy({gravity:"n"}).click(function(){ae.zoom_out();ae.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tipsy({gravity:"n"}).click(function(){ae.zoom_in();ae.request_redraw()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){ae.change_chrom(ae.chrom_select.val())});this.browser_content_div.click(function(ai){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(ai){ae.zoom_in(ai.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ai,aj){this.current_x=aj.offsetX}).bind("drag",function(ai,ak){var al=ak.offsetX-this.current_x;this.current_x=ak.offsetX;var aj=Math.round(al/ae.viewport_container.width()*(ae.max_high-ae.max_low));ae.move_delta(-aj)});this.overview_close.click(function(){ae.reset_overview()});this.viewport_container.bind("draginit",function(ai,aj){if(ai.clientX>ae.viewport_container.width()-16){return false}}).bind("dragstart",function(ai,aj){aj.original_low=ae.low;aj.current_height=ai.clientY;aj.current_x=aj.offsetX}).bind("drag",function(ak,am){var ai=$(this);var an=am.offsetX-am.current_x;var aj=ai.scrollTop()-(ak.clientY-am.current_height);ai.scrollTop(aj);am.current_height=ak.clientY;am.current_x=am.offsetX;var al=Math.round(an/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(al)}).bind("mousewheel",function(ak,am,aj,ai){if(aj){aj*=50;var al=Math.round(-aj/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(al)}});this.top_labeltrack.bind("dragstart",function(ai,aj){return $("<div />").css({height:ae.browser_content_div.height()+ae.top_labeltrack.height()+ae.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(am,an){$(an.proxy).css({left:Math.min(am.pageX,an.startX),width:Math.abs(am.pageX-an.startX)});var aj=Math.min(am.pageX,an.startX)-ae.container.offset().left,ai=Math.max(am.pageX,an.startX)-ae.container.offset().left,al=(ae.high-ae.low),ak=ae.viewport_container.width();ae.update_location(Math.round(aj/ak*al)+ae.low,Math.round(ai/ak*al)+ae.low)}).bind("dragend",function(an,ao){var aj=Math.min(an.pageX,ao.startX),ai=Math.max(an.pageX,ao.startX),al=(ae.high-ae.low),ak=ae.viewport_container.width(),am=ae.low;ae.low=Math.round(aj/ak*al)+am;ae.high=Math.round(ai/ak*al)+am;$(ao.proxy).remove();ae.request_redraw()});this.add_label_track(new aa(this,{content_div:this.top_labeltrack}));this.add_label_track(new aa(this,{content_div:this.nav_labeltrack}));$(window).bind("resize",function(){ae.resize_window()});$(document).bind("redraw",function(){ae.redraw()});this.reset();$(window).trigger("resize")},update_intro_div:function(){if(this.drawables.length===0){this.intro_div.show()}else{this.intro_div.hide()}},update_location:function(ae,af){this.location_span.text(commatize(ae)+" - "+commatize(af));this.nav_input.val(this.chrom+":"+commatize(ae)+"-"+commatize(af))},load_chroms:function(ag){ag.num=v;ag.dbkey=this.dbkey;var ae=this,af=$.Deferred();$.ajax({url:chrom_url,data:ag,dataType:"json",success:function(ai){if(ai.chrom_info.length===0){alert("Invalid chromosome: "+ag.chrom);return}if(ai.reference){ae.add_label_track(new z(ae))}ae.chrom_data=ai.chrom_info;var al='<option value="">Select Chrom/Contig</option>';for(var ak=0,ah=ae.chrom_data.length;ak<ah;ak++){var aj=ae.chrom_data[ak].chrom;al+='<option value="'+aj+'">'+aj+"</option>"}if(ai.prev_chroms){al+='<option value="previous">Previous '+v+"</option>"}if(ai.next_chroms){al+='<option value="next">Next '+v+"</option>"}ae.chrom_select.html(al);ae.chrom_start_index=ai.start_index;af.resolve(ai)},error:function(){alert("Could not load chroms for this dbkey:",ae.dbkey)}});return af},change_chrom:function(aj,af,al){if(!aj||aj==="None"){return}var ag=this;if(aj==="previous"){ag.load_chroms({low:this.chrom_start_index-v});return}if(aj==="next"){ag.load_chroms({low:this.chrom_start_index+v});return}var ak=$.grep(ag.chrom_data,function(am,an){return am.chrom===aj})[0];if(ak===undefined){ag.load_chroms({chrom:aj},function(){ag.change_chrom(aj,af,al)});return}else{if(aj!==ag.chrom){ag.chrom=aj;ag.chrom_select.val(ag.chrom);ag.max_high=ak.len-1;ag.reset();ag.request_redraw(true);for(var ai=0,ae=ag.drawables.length;ai<ae;ai++){var ah=ag.drawables[ai];if(ah.init){ah.init()}}if(ag.reference_track){ag.reference_track.init()}}if(af!==undefined&&al!==undefined){ag.low=Math.max(af,0);ag.high=Math.min(al,ag.max_high)}ag.reset_overview();ag.request_redraw()}},go_to:function(ai){ai=ai.replace(/ |,/g,"");var am=this,ae,ah,af=ai.split(":"),ak=af[0],al=af[1];if(al!==undefined){try{var aj=al.split("-");ae=parseInt(aj[0],10);ah=parseInt(aj[1],10)}catch(ag){return false}}am.change_chrom(ak,ae,ah)},move_fraction:function(ag){var ae=this;var af=ae.high-ae.low;this.move_delta(ag*af)},move_delta:function(ag){var ae=this;var af=ae.high-ae.low;if(ae.low-ag<ae.max_low){ae.low=ae.max_low;ae.high=ae.max_low+af}else{if(ae.high-ag>ae.max_high){ae.high=ae.max_high;ae.low=ae.max_high-af}else{ae.high-=ag;ae.low-=ag}}ae.request_redraw()},add_drawable:function(ae){x.prototype.add_drawable.call(this,ae);ae.init();this.has_changes=true;this.update_intro_div()},add_label_track:function(ae){ae.view=this;ae.init();this.label_tracks.push(ae)},remove_drawable:function(ag,af){x.prototype.remove_drawable.call(this,ag);if(af){var ae=this;ag.container_div.hide(0,function(){$(this).remove();ae.update_intro_div()});this.has_changes=true}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(am,ae,al,af){var ak=this,ai=(af?[af]:ak.drawables),ag;var af;for(var aj=0;aj<ai.length;aj++){af=ai[aj];ag=-1;for(var ah=0;ah<ak.tracks_to_be_redrawn.length;ah++){if(ak.tracks_to_be_redrawn[ah][0]===af){ag=ah;break}}if(ag<0){ak.tracks_to_be_redrawn.push([af,ae,al])}else{ak.tracks_to_be_redrawn[aj][1]=ae;ak.tracks_to_be_redrawn[aj][2]=al}}requestAnimationFrame(function(){ak._redraw(am)})},_redraw:function(ao){var al=this.low,ah=this.high;if(al<this.max_low){al=this.max_low}if(ah>this.max_high){ah=this.max_high}var an=this.high-this.low;if(this.high!==0&&an<this.min_separation){ah=al+this.min_separation}this.low=Math.floor(al);this.high=Math.ceil(ah);this.resolution=Math.pow(A,Math.ceil(Math.log((this.high-this.low)/Q)/Math.log(A)));this.zoom_res=Math.pow(u,Math.max(0,Math.ceil(Math.log(this.resolution,u)/Math.log(u))));var ae=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ak=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ap=13;this.overview_box.css({left:ae,width:Math.max(ap,ak)}).show();if(ak<ap){this.overview_box.css("left",ae-(ap-ak)/2)}if(this.overview_highlight){this.overview_highlight.css({left:ae,width:ak})}this.update_location(this.low,this.high);if(!ao){var ag,af,am;for(var ai=0,aj=this.tracks_to_be_redrawn.length;ai<aj;ai++){ag=this.tracks_to_be_redrawn[ai][0];af=this.tracks_to_be_redrawn[ai][1];am=this.tracks_to_be_redrawn[ai][2];if(ag){ag._draw(af,am)}}this.tracks_to_be_redrawn=[];for(ai=0,aj=this.label_tracks.length;ai<aj;ai++){this.label_tracks[ai]._draw()}}},zoom_in:function(af,ag){if(this.max_high===0||this.high-this.low<this.min_separation){return}var ah=this.high-this.low,ai=ah/2+this.low,ae=(ah/this.zoom_factor)/2;if(af){ai=af/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ai-ae);this.high=Math.round(ai+ae);this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var af=this.high-this.low,ag=af/2+this.low,ae=(af*this.zoom_factor)/2;this.low=Math.round(ag-ae);this.high=Math.round(ag+ae);this.request_redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.request_redraw()},set_overview:function(ag){if(this.overview_drawable){if(this.overview_drawable.dataset_id===ag.dataset_id){return}this.overview_viewport.find(".track").remove()}var af=ag.copy({content_div:this.overview_viewport}),ae=this;af.header_div.hide();af.is_overview=true;ae.overview_drawable=af;this.overview_drawable.postdraw_actions=function(){ae.overview_highlight.show().height(ae.overview_drawable.content_div.height());ae.overview_viewport.height(ae.overview_drawable.content_div.height()+ae.overview_box.outerHeight());ae.overview_close.show();ae.resize_window()};ae.overview_drawable.request_draw();ae.has_changes=true},reset_overview:function(){$(".tipsy").remove();this.overview_viewport.find(".track-tile").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide();view.resize_window();view.overview_drawable=null}});var r=function(ag,ak){this.track=ag;this.name=ak.name;this.params=[];var ar=ak.params;for(var ah=0;ah<ar.length;ah++){var am=ar[ah],af=am.name,aq=am.label,ai=unescape(am.html),at=am.value,ao=am.type;if(ao==="number"){this.params[this.params.length]=new f(af,aq,ai,at,am.min,am.max)}else{if(ao=="select"){this.params[this.params.length]=new N(af,aq,ai,at)}else{console.log("WARNING: unrecognized tool parameter type:",af,ao)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(av){av.stopPropagation()}).click(function(av){av.stopPropagation()}).bind("dblclick",function(av){av.stopPropagation()});var ap=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var an=this.params;var al=this;$.each(this.params,function(aw,az){var ay=$("<div>").addClass("param-row").appendTo(al.parent_div);var av=$("<div>").addClass("param-label").text(az.label).appendTo(ay);var ax=$("<div/>").addClass("param-input").html(az.html).appendTo(ay);ax.find(":input").val(az.value);$("<div style='clear: both;'/>").appendTo(ay)});this.parent_div.find("input").click(function(){$(this).select()});var au=$("<div>").addClass("param-row").appendTo(this.parent_div);var aj=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(au);var ae=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(au);var al=this;ae.click(function(){al.run_on_region()});aj.click(function(){al.run_on_dataset()})};p(r.prototype,{get_param_values_dict:function(){var ae={};this.parent_div.find(":input").each(function(){var af=$(this).attr("name"),ag=$(this).val();ae[af]=JSON.stringify(ag)});return ae},get_param_values:function(){var af=[];var ae={};this.parent_div.find(":input").each(function(){var ag=$(this).attr("name"),ah=$(this).val();if(ag){af[af.length]=ah}});return af},run_on_dataset:function(){var ae=this;ae.run({dataset_id:this.track.original_dataset_id,tool_id:ae.name},null,function(af){show_modal(ae.name+" is Running",ae.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var af={dataset_id:this.track.original_dataset_id,chrom:this.track.view.chrom,low:this.track.view.low,high:this.track.view.high,tool_id:this.name},aj=this.track,ag=af.tool_id+aj.tool_region_and_parameters_str(af.chrom,af.low,af.high),ae;if(aj.container===view){var ai=new P(this.name,this.track.view);var ah=aj.container.replace_drawable(aj,ai,false);ai.container_div.insertBefore(aj.view.content_div.children()[ah]);ai.add_drawable(aj);aj.container_div.appendTo(ai.content_div);ae=ai}else{ae=aj.container}var ak=new aj.constructor(ag,view,ae,"hda");ak.init_for_tool_data();ak.change_mode(aj.mode);ae.add_drawable(ak);ak.content_div.text("Starting job.");this.run(af,ak,function(al){ak.dataset_id=al.dataset_id;ak.content_div.text("Running job.");ak.init()})},run:function(af,ag,ah){$.extend(af,this.get_param_values_dict());var ae=function(){$.getJSON(rerun_tool_url,af,function(ai){if(ai==="no converter"){ag.container_div.addClass("error");ag.content_div.text(J)}else{if(ai.error){ag.container_div.addClass("error");ag.content_div.text(w+ai.message)}else{if(ai==="pending"){ag.container_div.addClass("pending");ag.content_div.text("Converting input data so that it can be used quickly with tool.");setTimeout(ae,2000)}else{ah(ai)}}}})};ae()}});var N=function(af,ae,ag,ah){this.name=af;this.label=ae;this.html=ag;this.value=ah};var f=function(ag,af,ai,aj,ah,ae){N.call(this,ag,af,ai,aj);this.min=ah;this.max=ae};var g=function(af,ae,ag,ah){this.manager=null;this.name=af;this.index=ae;this.tool_id=ag;this.tool_exp_name=ah};var U=function(af,am,at,ai){g.call(this,af,am,at,ai);this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.min=Number.MAX_VALUE;this.max=-Number.MAX_VALUE;this.container=null;this.slider=null;this.slider_label=null;var an=function(au,av,aw){au.click(function(){var aB=av.text(),az=parseFloat(aw.slider("option","max")),ay=(az<=1?4:az<=1000000?az.toString().length:6),aA=false,ax=$(this).parents(".slider-row");ax.addClass("input");if(aw.slider("option","values")){ay=2*ay+1;aA=true}av.text("");$("<input type='text'/>").attr("size",ay).attr("maxlength",ay).attr("value",aB).appendTo(av).focus().select().click(function(aC){aC.stopPropagation()}).blur(function(){$(this).remove();av.text(aB);ax.removeClass("input")}).keyup(function(aG){if(aG.keyCode===27){$(this).trigger("blur")}else{if(aG.keyCode===13){var aE=aw.slider("option","min"),aC=aw.slider("option","max"),aF=function(aH){return(isNaN(aH)||aH>aC||aH<aE)},aD=$(this).val();if(!aA){aD=parseFloat(aD);if(aF(aD)){alert("Parameter value must be in the range ["+aE+"-"+aC+"]");return $(this)}}else{aD=aD.split("-");aD=[parseFloat(aD[0]),parseFloat(aD[1])];if(aF(aD[0])||aF(aD[1])){alert("Parameter value must be in the range ["+aE+"-"+aC+"]");return $(this)}}aw.slider((aA?"values":"value"),aD);ax.removeClass("input")}}})})};var ag=this;ag.parent_div=$("<div/>").addClass("filter-row slider-row");var ae=$("<div/>").addClass("elt-label").appendTo(ag.parent_div),aq=$("<span/>").addClass("slider-name").text(ag.name+" ").appendTo(ae),ah=$("<span/>"),aj=$("<span/>").addClass("slider-value").appendTo(ae).append("[").append(ah).append("]");ag.values_span=ah;var ap=$("<div/>").addClass("slider").appendTo(ag.parent_div);ag.control_element=$("<div/>").attr("id",ag.name+"-filter-control").appendTo(ap);var ak=[0,0];ag.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(au,av){ag.slide(au,av)},change:function(au,av){ag.control_element.slider("option","slide").call(ag.control_element,au,av)}});ag.slider=ag.control_element;ag.slider_label=ah;an(aj,ah,ag.control_element);var ar=$("<div/>").addClass("display-controls").appendTo(ag.parent_div),al=create_action_icon("Use filter for data transparency","layer-transparent",function(){if(ag.manager.alpha_filter!==ag){ag.manager.alpha_filter=ag;ag.manager.parent_div.find(".layer-transparent").removeClass("active").hide();al.addClass("active").show()}else{ag.manager.alpha_filter=null;al.removeClass("active")}ag.manager.track.request_draw(true,true)}).appendTo(ar).hide(),ao=create_action_icon("Use filter for data height","arrow-resize-090",function(){if(ag.manager.height_filter!==ag){ag.manager.height_filter=ag;ag.manager.parent_div.find(".arrow-resize-090").removeClass("active").hide();ao.addClass("active").show()}else{ag.manager.height_filter=null;ao.removeClass("active")}ag.manager.track.request_draw(true,true)}).appendTo(ar).hide();ag.parent_div.hover(function(){al.show();ao.show()},function(){if(ag.manager.alpha_filter!==ag){al.hide()}if(ag.manager.height_filter!==ag){ao.hide()}});$("<div style='clear: both;'/>").appendTo(ag.parent_div)};p(U.prototype,{get_slider_step:function(ag,ae){var af=ae-ag;return(af<=2?0.01:1)},slide:function(af,ag){var ae=ag.values;this.values_span.text(ae[0]+"-"+ae[1]);this.low=ae[0];this.high=ae[1];this.manager.track.request_draw(true,true)},applies_to:function(ae){if(ae.length>this.index){return true}return false},keep:function(ae){if(!this.applies_to(ae)){return true}var af=ae[this.index];return(isNaN(af)||(af>=this.low&&af<=this.high))},update_attrs:function(af){var ae=false;if(!this.applies_to(af)){return ae}if(af[this.index]<this.min){this.min=Math.floor(af[this.index]);ae=true}if(af[this.index]>this.max){this.max=Math.ceil(af[this.index]);ae=true}return ae},update_ui_elt:function(){if(this.min!=this.max){this.parent_div.show()}else{this.parent_div.hide()}var af=this.slider.slider("option","min"),ae=this.slider.slider("option","max");if(this.min<af||this.max>ae){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",this.get_slider_step(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var Z=function(ag,aj){this.track=ag;this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(aq){aq.stopPropagation()}).click(function(aq){aq.stopPropagation()}).bind("dblclick",function(aq){aq.stopPropagation()}).bind("keydown",function(aq){aq.stopPropagation()});this.filters=[];if(aj){for(var ak=0;ak<aj.length;ak++){var ae=aj[ak],af=ae.name,an=ae.type,am=ae.index,ap=ae.tool_id,ah=ae.tool_exp_name;if(an==="int"||an==="float"){this.add_filter(new U(af,am,ap,ah))}else{console.log("ERROR: unsupported filter: ",af,an)}}}if(this.filters.length!==0){var ao=$("<div/>").addClass("param-row").appendTo(this.parent_div);var al=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(ao);var ai=this;al.click(function(){ai.run_on_dataset()})}};p(Z.prototype,{add_filter:function(ae){ae.manager=this;this.parent_div.append(ae.parent_div);this.filters.push(ae)},remove_all:function(){this.filters=[];this.parent_div.children().remove()},init_filters:function(){for(var ae=0;ae<this.filters.length;ae++){var af=this.filters[ae];af.update_ui_elt()}},clear_filters:function(){for(var ae=0;ae<this.filters.length;ae++){var af=this.filters[ae];af.slider.slider("option","values",[af.min,af.max])}this.alpha_filter=null;this.height_filter=null;this.parent_div.find(".icon-button").hide()},run_on_dataset:function(){var am=function(aq,ao,ap){if(!(ao in aq)){aq[ao]=ap}return aq[ao]};var ag={},ae,af,ah;for(var ai=0;ai<this.filters.length;ai++){ae=this.filters[ai];if(ae.tool_id){if(ae.min!=ae.low){af=am(ag,ae.tool_id,[]);af[af.length]=ae.tool_exp_name+" >= "+ae.low}if(ae.max!=ae.high){af=am(ag,ae.tool_id,[]);af[af.length]=ae.tool_exp_name+" <= "+ae.high}}}var ak=[];for(var an in ag){ak[ak.length]=[an,ag[an]]}var al=ak.length;(function aj(av,ar){var ap=ar[0],aq=ap[0],au=ap[1],at="("+au.join(") and (")+")",ao={cond:at,input:av,target_dataset_id:av,tool_id:aq},ar=ar.slice(1);$.getJSON(run_tool_url,ao,function(aw){if(aw.error){show_modal("Filter Dataset","Error running tool "+aq,{Close:hide_modal})}else{if(ar.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{aj(aw.dataset_id,ar)}}})})(this.track.dataset_id,ak)}});var B=function(ae,af){L.Scaler.call(this,af);this.filter=ae};B.prototype.gen_val=function(ae){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_val}return((parseFloat(ae[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var E=function(ae){this.track=ae.track;this.params=ae.params;this.values={};this.restore_values((ae.saved_values?ae.saved_values:{}));this.onchange=ae.onchange};p(E.prototype,{restore_values:function(ae){var af=this;$.each(this.params,function(ag,ah){if(ae[ah.key]!==undefined){af.values[ah.key]=ae[ah.key]}else{af.values[ah.key]=ah.default_value}})},build_form:function(){var ah=this;var ae=$("<div />");var ag;function af(al,ai){for(var ap=0;ap<al.length;ap++){ag=al[ap];if(ag.hidden){continue}var aj="param_"+ap;var au=ah.values[ag.key];var ax=$("<div class='form-row' />").appendTo(ai);ax.append($("<label />").attr("for",aj).text(ag.label+":"));if(ag.type==="bool"){ax.append($('<input type="checkbox" />').attr("id",aj).attr("name",aj).attr("checked",au))}else{if(ag.type==="text"){ax.append($('<input type="text"/>').attr("id",aj).val(au).click(function(){$(this).select()}))}else{if(ag.type=="select"){var ar=$("<select />").attr("id",aj);for(var an=0;an<ag.options.length;an++){$("<option/>").text(ag.options[an].label).attr("value",ag.options[an].value).appendTo(ar)}ar.val(au);ax.append(ar)}else{if(ag.type==="color"){var aw=$("<div/>").appendTo(ax),aq=$("<input />").attr("id",aj).attr("name",aj).val(au).css("float","left").appendTo(aw).click(function(az){$(".tipsy").hide();var ay=$(this).siblings(".tipsy");ay.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top-($(ay).height()/2)+($(this).height()/2)}).show();ay.click(function(aA){aA.stopPropagation()});$(document).bind("click.color-picker",function(){ay.hide();$(document).unbind("click.color-picker")});az.stopPropagation()}),ao=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(aw).attr("title","Set new random color").tipsy({gravity:"s"}),at=$("<div class='tipsy tipsy-west' style='position: absolute;' />").appendTo(aw).hide(),ak=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(at),av=$("<div/>").appendTo(ak),am=$.farbtastic(av,{width:100,height:100,callback:aq,color:au});aw.append($("<div/>").css("clear","both"));(function(ay){ao.click(function(){ay.setColor(get_random_color())})})(am)}else{ax.append($("<input />").attr("id",aj).attr("name",aj).val(au))}}}}if(ag.help){ax.append($("<div class='help'/>").text(ag.help))}}}af(this.params,ae);return ae},update_from_form:function(ae){var ag=this;var af=false;$.each(this.params,function(ah,aj){if(!aj.hidden){var ak="param_"+ah;var ai=ae.find("#"+ak).val();if(aj.type==="float"){ai=parseFloat(ai)}else{if(aj.type==="int"){ai=parseInt(ai)}else{if(aj.type==="bool"){ai=ae.find("#"+ak).is(":checked")}}}if(ai!==ag.values[aj.key]){ag.values[aj.key]=ai;af=true}}});if(af){this.onchange()}}});var b=function(ae,ah,ag,af,ai){this.track=ae;this.index=ah;this.low=ah*Q*ag;this.high=(ah+1)*Q*ag;this.resolution=ag;this.html_elt=$("<div class='track-tile'/>").append(af);this.data=ai;this.stale=false};b.prototype.predisplay_actions=function(){};var k=function(ae,ah,ag,af,ai,aj){b.call(this,ae,ah,ag,af,ai);this.max_val=aj};p(k.prototype,b.prototype);var O=function(ah,am,ai,ag,ak,ar,al,at,af,ap){b.call(this,ah,am,ai,ag,ak);this.mode=al;this.feature_mapper=ap;this.has_icons=false;if(at||!af){this.has_icons=true;var an=this;ag=this.html_elt.children()[0],message_div=$("<div/>").addClass("tile-message").css({height:C-1,width:ag.width}).prependTo(this.html_elt);if(!af){var ao=$("<a href='javascript:void(0);'/>").addClass("icon exclamation").attr("title","To minimize track height, not all features in this region are displayed. Click to display more.").tipsy({gravity:"s"}).appendTo(message_div).click(function(){$(".tipsy").hide();an.track.slotters[ar].max_rows*=2;an.track.request_draw(true)})}if(at){var aq=ak.length,aj=$("<a href='javascript:void(0);'/>").addClass("icon more-down").attr("title","For speed, only the first "+aq+" features in this region were obtained from server. Click to get more data including depth").tipsy({gravity:"s"}).appendTo(message_div),ae=$("<a href='javascript:void(0);'/>").addClass("icon more-across").attr("title","For speed, only the first "+aq+" features in this region were obtained from server. Click to get more data excluding depth").tipsy({gravity:"s"}).appendTo(message_div);aj.click(function(){an.stale=true;ah.data_manager.get_more_data(an.low,an.high,ah.mode,an.resolution,{},ah.data_manager.DEEP_DATA_REQ);$(".tipsy").hide();ah.request_draw()}).dblclick(function(au){au.stopPropagation()});ae.click(function(){an.stale=true;ah.data_manager.get_more_data(an.low,an.high,ah.mode,an.resolution,{},ah.data_manager.BROAD_DATA_REQ);$(".tipsy").hide();ah.request_draw()}).dblclick(function(au){au.stopPropagation()})}}};p(O.prototype,b.prototype);O.prototype.predisplay_actions=function(){var af=this,ae={};if(af.mode!=="Pack"){return}$(this.html_elt).hover(function(){this.hovered=true;$(this).mousemove()},function(){this.hovered=false;$(this).siblings(".feature-popup").remove()}).mousemove(function(aq){if(!this.hovered){return}var al=$(this).offset(),ap=aq.pageX-al.left,ao=aq.pageY-al.top,av=af.feature_mapper.get_feature_data(ap,ao),am=(av?av[0]:null);$(this).siblings(".feature-popup").each(function(){if(!am||$(this).attr("id")!==am.toString()){$(this).remove()}});if(av){var ah=ae[am];if(!ah){var am=av[0],ar={name:av[3],start:av[1],end:av[2],strand:av[4]},ak=af.track.filters_manager.filters,aj;for(var an=0;an<ak.length;an++){aj=ak[an];ar[aj.name]=av[aj.index]}var ah=$("<div/>").attr("id",am).addClass("feature-popup"),aw=$("<table/>"),au,at,ax;for(au in ar){at=ar[au];ax=$("<tr/>").appendTo(aw);$("<th/>").appendTo(ax).text(au);$("<td/>").attr("align","left").appendTo(ax).text(typeof(at)=="number"?Y(at,2):at)}ah.append($("<div class='feature-popup-inner'>").append(aw));ae[am]=ah}ah.appendTo($(af.html_elt).parent());var ai=ap+parseInt(af.html_elt.css("left"))-ah.width()/2,ag=ao+parseInt(af.html_elt.css("top"))+7;ah.css("left",ai+"px").css("top",ag+"px")}else{if(!aq.isPropagationStopped()){aq.stopPropagation();$(this).siblings().each(function(){$(this).trigger(aq)})}}}).mouseleave(function(){$(this).siblings(".feature-popup").remove()})};var i=function(ah,af,ae,ag,aj,ai,ak){q.call(this,ah,af,ae,{},"draghandle");this.data_url=(ai?ai:default_data_url);this.data_url_extra_params={};this.data_query_wait=(ak?ak:K);this.dataset_check_url=converted_datasets_state_url;this.data_manager=(aj?aj:new S(H,this));this.content_div=$("<div class='track-content'>").appendTo(this.container_div);if(this.container){this.container.content_div.append(this.container_div)}};p(i.prototype,q.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},q.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"overview-icon",on_click_fn:function(ae){ae.view.set_overview(ae)}},q.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(ae){if(ae.filters_div.is(":visible")){ae.filters_manager.clear_filters()}else{ae.filters_manager.init_filters()}ae.filters_div.toggle()}},{name:"tools_icon",title:"Tools",css_class:"tools-icon",on_click_fn:function(ae){ae.dynamic_tool_div.toggle();if(ae.dynamic_tool_div.is(":visible")){ae.set_name(ae.name+ae.tool_region_and_parameters_str())}else{ae.revert_name()}$(".tipsy").remove()}},q.prototype.action_icons_def[2]],can_draw:function(){if(this.dataset_id&&q.prototype.can_draw.call(this)){return true}return false},build_container_div:function(){return $("<div/>").addClass("track").attr("id","track_"+this.id).css("position","relative")},build_header_div:function(){var ae=$("<div class='track-header'/>");if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(ae)}this.name_div=$("<div/>").addClass("track-name").appendTo(ae).text(this.name).attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase());return ae},set_display_modes:function(ah,ak){this.display_modes=ah;this.mode=(ak?ak:(this.config&&this.config.values.mode?this.config.values.mode:this.display_modes[0]));this.action_icons.mode_icon.attr("title","Set display mode (now: "+this.mode+")");var af=this,ai={};for(var ag=0,ae=af.display_modes.length;ag<ae;ag++){var aj=af.display_modes[ag];ai[aj]=function(al){return function(){af.change_mode(al);af.icons_div.show();af.container_div.mouseleave(function(){af.icons_div.hide()})}}(aj)}make_popupmenu(this.action_icons.mode_icon,ai)},build_action_icons:function(){q.prototype.build_action_icons.call(this,this.action_icons_def);if(this.display_modes!==undefined){this.set_display_modes(this.display_modes)}},hide_contents:function(){this.content_div.children().remove();this.content_div.hide();this.container_div.find(".yaxislabel, .track-resize").hide()},show_contents:function(){this.content_div.show();this.container_div.find(".yaxislabel, .track-resize").show();this.request_draw()},get_type:function(){if(this instanceof aa){return"LabelTrack"}else{if(this instanceof z){return"ReferenceTrack"}else{if(this instanceof j){return"LineTrack"}else{if(this instanceof V){return"ReadTrack"}else{if(this instanceof T){return"VcfTrack"}else{if(this instanceof h){return"CompositeTrack"}else{if(this instanceof d){return"FeatureTrack"}}}}}}}return""},init:function(){var af=this;af.enabled=false;af.tile_cache.clear();af.data_manager.clear();af.content_div.css("height","auto");af.content_div.children().remove();af.container_div.removeClass("nodata error pending");if(!af.dataset_id){return}var ae=$.Deferred();$.getJSON(converted_datasets_state_url,{hda_ldda:af.hda_ldda,dataset_id:af.dataset_id,chrom:af.view.chrom},function(ag){if(!ag||ag==="error"||ag.kind==="error"){af.container_div.addClass("error");af.content_div.text(o);if(ag.message){var ah=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+ag.message+"</pre>",{Close:hide_modal})});af.content_div.append(ah)}}else{if(ag==="no converter"){af.container_div.addClass("error");af.content_div.text(J)}else{if(ag==="no data"||(ag.data!==undefined&&(ag.data===null||ag.data.length===0))){af.container_div.addClass("nodata");af.content_div.text(D)}else{if(ag==="pending"){af.container_div.addClass("pending");af.content_div.text(t);setTimeout(function(){af.init()},af.data_query_wait)}else{if(ag.status==="data"){if(ag.valid_chroms){af.valid_chroms=ag.valid_chroms;af.update_icons()}af.content_div.text(X);if(af.view.chrom){af.content_div.text("");af.content_div.css("height",af.height_px+"px");af.enabled=true;$.when(af.predraw_init()).done(function(){ae.resolve();af.container_div.removeClass("nodata error pending");af.request_draw()})}else{ae.resolve()}}}}}}});this.update_icons();return ae},predraw_init:function(){}});var M=function(aj,ah,ag,ai,af,al,ak){i.call(this,aj,ah,ag,ai,ak);var ae=this,ah=ae.view;m(ae.container_div,ae.drag_handle_class,".group",ae);this.filters_manager=new Z(this,af);this.filters_available=false;this.tool=(al!==undefined&&obj_length(al)>0?new r(this,al):undefined);this.tile_cache=new c(R);if(this.header_div){if(this.filters_manager){this.filters_div=this.filters_manager.parent_div;this.header_div.after(this.filters_div)}if(this.tool){this.dynamic_tool_div=this.tool.parent_div;this.header_div.after(this.dynamic_tool_div)}}};p(M.prototype,q.prototype,i.prototype,{copy:function(ae){var af=new this.constructor(this.name,this.view,ae,this.hda_ldda,this.dataset_id,this.prefs,this.filters,this.tool,this.data_manager);af.change_mode(this.mode);af.enabled=this.enabled;return af},to_dict:function(){return{track_type:this.get_type(),name:this.name,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,prefs:this.prefs,mode:this.mode,}},from_dict:function(ag,af){var ae=new this.constructor(ag.name,view,af,ag.hda_ldda,ag.dataset_id,ag.prefs,ag.filters,ag.tool);if(ag.mode){ae.change_mode(ag.mode)}return ae},change_mode:function(af){var ae=this;ae.mode=af;ae.config.values.mode=af;ae.tile_cache.clear();ae.request_draw();this.action_icons.mode_icon.attr("title","Set display mode (now: "+ae.mode+")");return ae},update_icons:function(){var ae=this;if(ae.filters_available){ae.action_icons.filters_icon.show()}else{ae.action_icons.filters_icon.hide()}if(ae.tool){ae.action_icons.tools_icon.show()}else{ae.action_icons.tools_icon.hide()}},_gen_tile_cache_key:function(af,ag,ae){return af+"_"+ag+"_"+ae},request_draw:function(af,ae){this.view.request_redraw(false,af,ae,this)},_draw:function(ag,aq){if(!this.can_draw()){return}var ao=this.view.low,ak=this.view.high,am=ak-ao,ah=this.view.container.width(),au=ah/am,aj=this.view.resolution,at=this.content_div;if(this.is_overview){ao=this.view.max_low;ak=this.view.max_high;aj=Math.pow(A,Math.ceil(Math.log((view.max_high-view.max_low)/Q)/Math.log(A)));au=ah/(view.max_high-view.max_low)}this.content_div.children().addClass("remove");this.max_height=0;var af=Math.floor(ao/aj/Q);var an=true;var ar=[];var ae=0;var al=function(av){return(av&&"track" in av)};while((af*Q*aj)<ak){var ap=this.draw_helper(ag,ah,af,aj,at,au);if(al(ap)){ar.push(ap)}else{an=false}af+=1;ae++}if(!aq){this.content_div.children(".remove").remove()}var ai=this;if(an){this.content_div.children(".remove").remove();ai.postdraw_actions(ar,ah,au,aq)}},postdraw_actions:function(ah,ai,ak,ae){var ag=this;var aj=false;for(var af=0;af<ah.length;af++){if(ah[af].has_icons){aj=true;break}}if(aj){for(var af=0;af<ah.length;af++){tile=ah[af];if(!tile.has_icons){tile.html_elt.css("padding-top",C)}}}},draw_helper:function(ae,aq,aw,au,aj,ak,ar){var ap=this,az=this._gen_tile_cache_key(aq,ak,aw),ax=aw*Q*au,af=ax+Q*au;if(!ar){ar={}}var ay=(ae?undefined:ap.tile_cache.get(az));if(ay){ap.show_tile(ay,aj,ak);return ay}var an=true;var av=ap.data_manager.get_data(ax,af,ap.mode,au,ap.data_url_extra_params);if(is_deferred(av)){an=false}var al;if(view.reference_track&&ak>view.canvas_manager.char_width_px){al=view.reference_track.data_manager.get_data(ax,af,ap.mode,au,view.reference_track.data_url_extra_params);if(is_deferred(al)){an=false}}if(an){p(av,ar.more_tile_data);var am=ap.mode;if(am==="Auto"){am=ap.get_mode(av);ap.update_auto_mode(am)}var ag=ap.view.canvas_manager.new_canvas(),ah=ap._get_tile_bounds(aw,au),ax=ah[0],af=ah[1],aq=Math.ceil((af-ax)*ak)+ap.left_offset,ao=ap.get_canvas_height(av,am,ak,aq);ag.width=aq;ag.height=ao;var at=ag.getContext("2d");at.translate(this.left_offset,0);var ay=ap.draw_tile(av,at,am,au,aw,ak,al);if(ay!==undefined){ap.tile_cache.set(az,ay);ap.show_tile(ay,aj,ak)}return ay}var ai=$.Deferred();$.when(av,al).then(function(){view.request_redraw(false,false,false,ap);ai.resolve()});return ai},get_canvas_height:function(ae,ag,ah,af){return this.height_px},draw_tile:function(ae,ag,aj,ai,af,ak,ah){console.log("Warning: TiledTrack.draw_tile() not implemented.")},show_tile:function(ag,ai,aj){var af=this,ae=ag.html_elt;ag.predisplay_actions();var ah=(ag.low-(this.is_overview?this.view.max_low:this.view.low))*aj;if(this.left_offset){ah-=this.left_offset}ae.css({position:"absolute",top:0,left:ah,height:""});if(ae.hasClass("remove")){ae.removeClass("remove")}else{ai.append(ae)}af.max_height=Math.max(af.max_height,ae.height());af.content_div.css("height",af.max_height+"px");ai.children().css("height",af.max_height+"px")},_get_tile_bounds:function(ae,af){var ah=ae*Q*af,ai=Q*af,ag=(ah+ai<=this.view.max_high?ah+ai:this.view.max_high);return[ah,ag]},tool_region_and_parameters_str:function(ag,ae,ah){var af=this,ai=(ag!==undefined&&ae!==undefined&&ah!==undefined?ag+":"+ae+"-"+ah:"all");return" - region=["+ai+"], parameters=["+af.tool.get_param_values().join(", ")+"]"},data_and_mode_compatible:function(ae,af){return true},init_for_tool_data:function(){this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url;this.predraw_init=function(){var af=this;var ae=function(){if(af.data_manager.size()===0){setTimeout(ae,300)}else{af.data_url=default_data_url;af.data_query_wait=K;af.dataset_state_url=converted_datasets_state_url;$.getJSON(af.dataset_state_url,{dataset_id:af.dataset_id,hda_ldda:af.hda_ldda},function(ag){})}};ae()}}});var aa=function(af,ae){i.call(this,"label",af,ae,false,{});this.container_div.addClass("label-track")};p(aa.prototype,i.prototype,{build_header_div:function(){},init:function(){this.enabled=true},_draw:function(){var ag=this.view,ah=ag.high-ag.low,ak=Math.floor(Math.pow(10,Math.floor(Math.log(ah)/Math.log(10)))),ae=Math.floor(ag.low/ak)*ak,ai=this.view.container.width(),af=$("<div style='position: relative; height: 1.3em;'></div>");while(ae<ag.high){var aj=(ae-ag.low)/ah*ai;af.append($("<div class='label'>"+commatize(ae)+"</div>").css({position:"absolute",left:aj-1}));ae+=ak}this.content_div.children(":first").remove();this.content_div.append(af)}});var h=function(ah,ag,af,ae){M.call(this,ah,ag,af);this.drawables=[];this.left_offset=0;if(ae){var ak=[],aj;for(var ai=0;ai<ae.length;ai++){aj=ae[ai];ak.push(aj.dataset_id);this.drawables[ai]=aj.copy();if(aj.left_offset>this.left_offset){this.left_offset=aj.left_offset}}this.enabled=true}if(this.drawables.length!==0){this.set_display_modes(this.drawables[0].display_modes,this.drawables[0].mode)}this.update_icons();this.obj_type="CompositeTrack"};p(h.prototype,M.prototype,{action_icons_def:[{name:"composite_icon",title:"Show individual tracks",css_class:"layers-stack",on_click_fn:function(ae){$(".tipsy").remove();ae.show_group()}}].concat(M.prototype.action_icons_def),to_dict:x.prototype.to_dict,add_drawable:x.prototype.add_drawable,from_dict:function(ak,ae){var aj=new this.constructor(ak.name,view,ae,ak.prefs,view.viewport_container,view);var af,ai,ah;for(var ag=0;ag<ak.drawables.length;ag++){af=ak.drawables[ag];ai=af.obj_type;if(!ai){ai=af.track_type}ah=addable_objects[ai].prototype.from_dict(af);aj.add_drawable(ah)}aj.set_display_modes(aj.drawables[0].display_modes,aj.drawables[0].mode);return aj},change_mode:function(ae){M.prototype.change_mode.call(this,ae);for(var af=0;af<this.drawables.length;af++){this.drawables[af].change_mode(ae)}},init:function(){var ag=[];for(var af=0;af<this.drawables.length;af++){ag.push(this.drawables[af].init())}var ae=this;$.when.apply($,ag).then(function(){ae.enabled=true;ae.request_draw()})},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide()},can_draw:q.prototype.can_draw,draw_helper:function(af,au,aA,ax,al,an,av){var at=this,aE=this._gen_tile_cache_key(au,an,aA),aB=aA*Q*ax,ag=aB+Q*ax;if(!av){av={}}var aD=(af?undefined:at.tile_cache.get(aE));if(aD){at.show_tile(aD,al,an);return aD}var am=[],at,aq=true,ay,ao;for(var az=0;az<this.drawables.length;az++){at=this.drawables[az];ay=at.data_manager.get_data(aB,ag,at.mode,ax,at.data_url_extra_params);if(is_deferred(ay)){aq=false}am.push(ay);ao=null;if(view.reference_track&&an>view.canvas_manager.char_width_px){ao=view.reference_track.data_manager.get_data(aB,ag,at.mode,ax,view.reference_track.data_url_extra_params);if(is_deferred(ao)){aq=false}}am.push(ao)}if(aq){p(ay,av.more_tile_data);this.tile_predraw_init();var ai=at.view.canvas_manager.new_canvas(),aj=at._get_tile_bounds(aA,ax),aB=aj[0],ag=aj[1],aC=0,au=Math.ceil((ag-aB)*an)+this.left_offset,ar=0,ah=[];var ae=0;for(var az=0;az<this.drawables.length;az++,aC+=2){at=this.drawables[az];ay=am[aC];var ap=at.mode;if(ap==="Auto"){ap=at.get_mode(ay);at.update_auto_mode(ap)}ah.push(ap);ae=at.get_canvas_height(ay,ap,an,au);if(ae>ar){ar=ae}}ai.width=au;ai.height=(av.height?av.height:ar);aC=0;var aw=ai.getContext("2d");aw.translate(this.left_offset,0);aw.globalAlpha=0.5;aw.globalCompositeOperation="source-over";for(var az=0;az<this.drawables.length;az++,aC+=2){at=this.drawables[az];ay=am[aC];ao=am[aC+1];aD=at.draw_tile(ay,aw,ah[az],ax,aA,an,ao)}this.tile_cache.set(aE,aD);this.show_tile(aD,al,an);return aD}var ak=$.Deferred(),at=this;$.when.apply($,am).then(function(){view.request_redraw(false,false,false,at);ak.resolve()});return ak},show_group:function(){var ah=new P(this.name,this.view,this.container),ae;for(var ag=0;ag<this.drawables.length;ag++){ae=this.drawables[ag];ah.add_drawable(ae);ae.container=ah;ah.content_div.append(ae.container_div)}var af=this.container.replace_drawable(this,ah,true);ah.request_draw()},tile_predraw_init:function(){var ah=Number.MAX_VALUE,ae=-ah,af;for(var ag=0;ag<this.drawables.length;ag++){af=this.drawables[ag];if(af instanceof j){if(af.prefs.min_value<ah){ah=af.prefs.min_value}if(af.prefs.max_value>ae){ae=af.prefs.max_value}}}for(var ag=0;ag<this.drawables.length;ag++){af=this.drawables[ag];af.prefs.min_value=ah;af.prefs.max_value=ae}},postdraw_actions:function(ag,aj,al,af){M.prototype.postdraw_actions.call(this,ag,aj,al,af);var ai=-1;for(var ah=0;ah<ag.length;ah++){var ae=ag[ah].html_elt.find("canvas").height();if(ae>ai){ai=ae}}for(var ah=0;ah<ag.length;ah++){var ak=ag[ah];if(ak.html_elt.find("canvas").height()!==ai){this.draw_helper(true,aj,ak.index,ak.resolution,ak.html_elt.parent(),al,{height:ai});ak.html_elt.remove()}}}});var z=function(ae){M.call(this,"reference",ae,{content_div:ae.top_labeltrack},{});ae.reference_track=this;this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_url=reference_url;this.data_url_extra_params={dbkey:ae.dbkey};this.data_manager=new G(H,this,false)};p(z.prototype,q.prototype,M.prototype,{build_header_div:function(){},init:function(){this.data_manager.clear();this.enabled=true},can_draw:q.prototype.can_draw,draw_tile:function(am,an,aj,ai,af,ao){var ah=this;if(ao>this.view.canvas_manager.char_width_px){if(am.data===null){ah.content_div.css("height","0px");return}var ag=an.canvas;an.font=an.canvas.manager.default_font;an.textAlign="center";am=am.data;for(var ak=0,al=am.length;ak<al;ak++){var ae=Math.round(ak*ao);an.fillText(am[ak],ae,10)}return new b(ah,af,ai,ag,am)}this.content_div.css("height","0px")}});var j=function(ae,al,af,ak,an,am,ai,aj,ag){var ah=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";M.call(this,ae,al,af,am,ai,aj,ag);this.min_height_px=16;this.max_height_px=400;this.height_px=32;this.hda_ldda=ak;this.dataset_id=an;this.original_dataset_id=an;this.left_offset=0;this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"color",label:"Color",type:"color",default_value:get_random_color()},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:this.height_px,hidden:true}],saved_values:am,onchange:function(){ah.set_name(ah.prefs.name);ah.vertical_range=ah.prefs.max_value-ah.prefs.min_value;$("#linetrack_"+ah.dataset_id+"_minval").text(ah.prefs.min_value);$("#linetrack_"+ah.dataset_id+"_maxval").text(ah.prefs.max_value);ah.tile_cache.clear();ah.request_draw()}});this.prefs=this.config.values;this.height_px=this.config.values.height;this.vertical_range=this.config.values.max_value-this.config.values.min_value;this.add_resize_handle()};p(j.prototype,q.prototype,M.prototype,{add_resize_handle:function(){var ae=this;var ah=false;var ag=false;var af=$("<div class='track-resize'>");$(ae.container_div).hover(function(){if(ae.content_visible){ah=true;af.show()}},function(){ah=false;if(!ag){af.hide()}});af.hide().bind("dragstart",function(ai,aj){ag=true;aj.original_height=$(ae.content_div).height()}).bind("drag",function(aj,ak){var ai=Math.min(Math.max(ak.original_height+ak.deltaY,ae.min_height_px),ae.max_height_px);$(ae.content_div).css("height",ai);ae.height_px=ai;ae.request_draw(true)}).bind("dragend",function(ai,aj){ae.tile_cache.clear();ag=false;if(!ah){af.hide()}ae.config.values.height=ae.height_px}).appendTo(ae.container_div)},predraw_init:function(){var ae=this;ae.vertical_range=undefined;return $.getJSON(ae.data_url,{stats:true,chrom:ae.view.chrom,low:null,high:null,hda_ldda:ae.hda_ldda,dataset_id:ae.dataset_id},function(af){ae.container_div.addClass("line-track");var ai=af.data;if(isNaN(parseFloat(ae.prefs.min_value))||isNaN(parseFloat(ae.prefs.max_value))){var ag=ai.min;var ak=ai.max;ag=Math.floor(Math.min(0,Math.max(ag,ai.mean-2*ai.sd)));ak=Math.ceil(Math.max(0,Math.min(ak,ai.mean+2*ai.sd)));ae.prefs.min_value=ag;ae.prefs.max_value=ak;$("#track_"+ae.dataset_id+"_minval").val(ae.prefs.min_value);$("#track_"+ae.dataset_id+"_maxval").val(ae.prefs.max_value)}ae.vertical_range=ae.prefs.max_value-ae.prefs.min_value;ae.total_frequency=ai.total_frequency;ae.container_div.find(".yaxislabel").remove();var aj=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+ae.dataset_id+"_minval").text(Y(ae.prefs.min_value,3));var ah=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+ae.dataset_id+"_maxval").text(Y(ae.prefs.max_value,3));ah.css({position:"absolute",top:"24px",left:"10px"});ah.prependTo(ae.container_div);aj.css({position:"absolute",bottom:"2px",left:"10px"});aj.prependTo(ae.container_div)})},draw_tile:function(ao,am,aj,ah,af,an){var ag=am.canvas,ae=this._get_tile_bounds(af,ah),ai=ae[0],al=ae[1],ak=new L.LinePainter(ao.data,ai,al,this.prefs,aj);ak.draw(am,ag.width,ag.height,an);return new b(this.track,af,ah,ag,ao.data)}});var d=function(ae,al,af,ak,an,am,ai,aj,ag){var ah=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];M.call(this,ae,al,af,am,ai,aj,ag);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"block_color",label:"Block color",type:"color",default_value:get_random_color()},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true,help:"Show the number of items in each bin when drawing summary histogram"},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"connector_style",label:"Connector style",type:"select",default_value:"fishbones",options:[{label:"Line with arrows",value:"fishbone"},{label:"Arcs",value:"arcs"}]},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:am,onchange:function(){ah.set_name(ah.prefs.name);ah.tile_cache.clear();ah.set_painter_from_config();ah.request_draw()}});this.prefs=this.config.values;this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=ak;this.dataset_id=an;this.original_dataset_id=an;this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.slotters={};this.start_end_dct={};this.left_offset=200;this.set_painter_from_config()};p(d.prototype,q.prototype,M.prototype,{set_painter_from_config:function(){if(this.config.values.connector_style=="arcs"){this.painter=L.ArcLinkedFeaturePainter}else{this.painter=L.LinkedFeaturePainter}},postdraw_actions:function(at,ag,av,ar){M.prototype.postdraw_actions.call(this,at,ar);var ai=this;if(ai.mode=="Histogram"){var am=-1;for(var aj=0;aj<at.length;aj++){var aq=at[aj].max_val;if(aq>am){am=aq}}for(var aj=0;aj<at.length;aj++){var ao=at[aj];if(ao.max_val!==am){ao.html_elt.remove();ai.draw_helper(true,ag,ao.index,ao.resolution,ao.html_elt.parent(),av,{more_tile_data:{max:am}})}}}if(ai.filters_manager){var ah=ai.filters_manager.filters;for(var al=0;al<ah.length;al++){ah[al].update_ui_elt()}var ak=false,an,af;for(var aj=0;aj<at.length;aj++){if(at[aj].data.length){an=at[aj].data[0];for(var al=0;al<ah.length;al++){af=ah[al];if(af.applies_to(an)&&af.min!==af.max){ak=true;break}}}}if(ai.filters_available!==ak){ai.filters_available=ak;if(!ai.filters_available){ai.filters_div.hide()}ai.update_icons()}}this.container_div.find(".yaxislabel").remove();var ae=at[0];if(ae instanceof k){var au=(this.prefs.histogram_max?this.prefs.histogram_max:ae.max_val),ap=get_editable_text_elt(au,false,12,0,function(aw){var aw=parseFloat(aw);ai.prefs.histogram_max=(!isNaN(aw)?aw:null);ai.tile_cache.clear();ai.request_draw()}).addClass("yaxislabel histogram-max").css("color",this.prefs.label_color);this.container_div.prepend(ap)}},update_auto_mode:function(ae){var ae;if(this.mode=="Auto"){if(ae=="no_detail"){ae="feature spans"}else{if(ae=="summary_tree"){ae="coverage histogram"}}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+ae+")")}},incremental_slots:function(ai,ae,ah){var af=this.view.canvas_manager.dummy_context,ag=this.slotters[ai];if(!ag||(ag.mode!==ah)){ag=new (s.FeatureSlotter)(ai,ah,y,function(aj){return af.measureText(aj)});this.slotters[ai]=ag}return ag.slot_features(ae)},get_summary_tree_data:function(ai,al,ag,au){if(au>ag-al){au=ag-al}var ap=Math.floor((ag-al)/au),at=[],ah=0;var aj=0,ak=0,ao,ar=0,am=[],aq,an;var af=function(ax,aw,ay,av){ax[0]=aw+ay*av;ax[1]=aw+(ay+1)*av};while(ar<au&&aj!==ai.length){var ae=false;for(;ar<au&&!ae;ar++){af(am,al,ar,ap);for(ak=aj;ak<ai.length;ak++){ao=ai[ak].slice(1,3);if(is_overlap(ao,am)){ae=true;break}}if(ae){break}}data_start_index=ak;at[at.length]=aq=[am[0],0];for(;ak<ai.length;ak++){ao=ai[ak].slice(1,3);if(is_overlap(ao,am)){aq[1]++}else{break}}if(aq[1]>ah){ah=aq[1]}ar++}return{max:ah,delta:ap,data:at}},get_mode:function(ae){if(ae.dataset_type==="summary_tree"){mode="summary_tree"}else{if(ae.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>I){mode="Squish"}else{mode="Pack"}}}return mode},get_canvas_height:function(ae,ai,aj,af){if(ai==="summary_tree"||ai==="Histogram"){return this.summary_draw_height}else{var ah=this.incremental_slots(aj,ae.data,ai);var ag=new (this.painter)(null,null,null,this.prefs,ai);return Math.max(ac,ag.get_required_height(ah,af))}},draw_tile:function(ap,au,ar,av,az,al,ag){var at=this,af=au.canvas,ai=this._get_tile_bounds(az,av),aC=ai[0],ae=ai[1],aH=25,ah=this.left_offset;if(ar==="summary_tree"||ar==="Histogram"){if(ap.dataset_type!="summary_tree"){var am=this.get_summary_tree_data(ap.data,aC,ae,200);if(ap.max){am.max=ap.max}ap=am}var aE=new L.SummaryTreePainter(ap,aC,ae,this.prefs);aE.draw(au,af.width,af.height,al);return new k(at,az,av,af,ap.data,ap.max)}var ak=[],aq=this.slotters[al].slots;all_slotted=true;if(ap.data){var an=this.filters_manager.filters;for(var aw=0,ay=ap.data.length;aw<ay;aw++){var aj=ap.data[aw];var ax=false;var ao;for(var aB=0,aG=an.length;aB<aG;aB++){ao=an[aB];ao.update_attrs(aj);if(!ao.keep(aj)){ax=true;break}}if(!ax){ak.push(aj);if(!(aj[0] in aq)){all_slotted=false}}}}var aF=(this.filters_manager.alpha_filter?new B(this.filters_manager.alpha_filter):null);var aD=(this.filters_manager.height_filter?new B(this.filters_manager.height_filter):null);var aE=new (this.painter)(ak,aC,ae,this.prefs,ar,aF,aD,ag);var aA=null;au.fillStyle=this.prefs.block_color;au.font=au.canvas.manager.default_font;au.textAlign="right";if(ap.data){aA=aE.draw(au,af.width,af.height,al,aq);aA.translation=-ah}return new O(at,az,av,af,ap.data,al,ar,ap.message,all_slotted,aA)},data_and_mode_compatible:function(ae,af){if(af==="Auto"){return true}else{if(ae.extra_info==="no_detail"||ae.dataset_type==="summary_tree"){return false}else{return true}}},});var T=function(ae,ak,af,aj,am,al,ah,ai,ag){d.call(this,ae,ak,af,aj,am,al,ah,ai,ag);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"block_color",label:"Block color",type:"color",default_value:get_random_color()},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:al,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.config.values;this.painter=L.ReadPainter};p(T.prototype,q.prototype,M.prototype,d.prototype);var V=function(ae,ak,af,aj,an,am,ah,ag){d.call(this,ae,ak,af,aj,an,am,ah,ag);var ai=get_random_color(),al=get_random_color([ai,"#ffffff"]);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"block_color",label:"Block and sense strand color",type:"color",default_value:ai},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:al},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"Clear value to set automatically"},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:am,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.config.values;this.painter=L.ReadPainter;this.update_icons()};p(V.prototype,q.prototype,M.prototype,d.prototype);W.View=ab;W.DrawableGroup=P;W.LineTrack=j;W.FeatureTrack=d;W.ReadTrack=V;W.VcfTrack=T;W.CompositeTrack=h};var slotting_module=function(c,b){var e=c("class").extend;var d=2,a=5;b.FeatureSlotter=function(i,h,f,g){this.slots={};this.start_end_dct={};this.w_scale=i;this.mode=h;this.include_label=(h==="Pack");this.max_rows=f;this.measureText=g};e(b.FeatureSlotter.prototype,{slot_features:function(m){var p=this.w_scale,h=this.start_end_dct,x=[],z=[],n=0,y=this.max_rows;for(var v=0,w=m.length;v<w;v++){var k=m[v],o=k[0];if(this.slots[o]!==undefined){n=Math.max(n,this.slots[o]);z.push(this.slots[o])}else{x.push(v)}}var q=function(E,F){for(var D=0;D<=y;D++){var B=false,G=h[D];if(G!==undefined){for(var A=0,C=G.length;A<C;A++){var i=G[A];if(F>i[0]&&E<i[1]){B=true;break}}}if(!B){return D}}return -1};for(var v=0,w=x.length;v<w;v++){var k=m[x[v]],o=k[0],t=k[1],f=k[2],r=k[3],g=Math.floor(t*p),l=Math.ceil(f*p),u=this.measureText(r).width,j;if(r!==undefined&&this.include_label){u+=(d+a);if(g-u>=0){g-=u;j="left"}else{l+=u;j="right"}}var s=q(g,l);if(s>=0){if(h[s]===undefined){h[s]=[]}h[s].push([g,l]);this.slots[o]=s;n=Math.max(n,s)}else{}}return n+1}})};var painters_module=function(i,x){var u=i("class").extend;var p=function(I,A,G,z,F,D){if(D===undefined){D=4}var C=z-A;var B=F-G;var E=Math.floor(Math.sqrt(C*C+B*B)/D);var J=C/E;var H=B/E;var y;for(y=0;y<E;y++,A+=J,G+=H){if(y%2!==0){continue}I.fillRect(A,G,D,1)}};var q=function(B,A,z,E){var D=A-E/2,C=A+E/2,F=z-Math.sqrt(E*3/2);B.beginPath();B.moveTo(D,F);B.lineTo(C,F);B.lineTo(A,z);B.lineTo(D,F);B.strokeStyle=this.fillStyle;B.fill();B.stroke();B.closePath()};var d=function(y){this.default_val=(y?y:1)};d.prototype.gen_val=function(y){return this.default_val};var l=function(A,C,y,z,B){this.data=A;this.view_start=C;this.view_end=y;this.prefs=u({},this.default_prefs,z);this.mode=B};l.prototype.default_prefs={};l.prototype.draw=function(z,A,y,B){};var v=function(A,C,y,z,B){l.call(this,A,C,y,z,B)};v.prototype.default_prefs={show_counts:false};v.prototype.draw=function(L,z,K,M){var E=this.view_start,N=this.view_end-this.view_start,I=this.data.data,G=(this.prefs.histogram_max?this.prefs.histogram_max:this.data.max),B=K;delta_x_px=Math.ceil(this.data.delta*M);L.save();for(var C=0,D=I.length;C<D;C++){var H=Math.floor((I[C][0]-E)*M);var F=I[C][1];if(!F){continue}var J=F/G*K;if(F!==0&&J<1){J=1}L.fillStyle=this.prefs.block_color;L.fillRect(H,B-J,delta_x_px,J);var A=4;if(this.prefs.show_counts&&(L.measureText(F).width+A)<delta_x_px){L.fillStyle=this.prefs.label_color;L.textAlign="center";L.fillText(F,H+(delta_x_px/2),10)}}L.restore()};var b=function(y,C,E,F,A){l.call(this,y,C,E,F,A);if(this.prefs.min_value===undefined){var G=Infinity;for(var z=0,B=this.data.length;z<B;z++){G=Math.min(G,this.data[z][1])}this.prefs.min_value=G}if(this.prefs.max_value===undefined){var D=-Infinity;for(var z=0,B=this.data.length;z<B;z++){D=Math.max(D,this.data[z][1])}this.prefs.max_value=D}};b.prototype.default_prefs={min_value:undefined,max_value:undefined,mode:"Histogram",color:"#000",overflow_color:"#F66"};b.prototype.draw=function(S,Q,N,D){var I=false,K=this.prefs.min_value,F=this.prefs.max_value,M=F-K,B=N,C=this.view_start,P=this.view_end-this.view_start,L=this.mode,aa=this.data;S.save();var ac=Math.round(N+K/M*N);if(L!=="Intensity"){S.fillStyle="#aaa";S.fillRect(0,ac,Q,1)}S.beginPath();var Y,G,E;if(aa.length>1){E=Math.ceil((aa[1][0]-aa[0][0])*D)}else{E=10}var A=parseInt(this.prefs.color.slice(1),16),H=(A&16711680)>>16,R=(A&65280)>>8,V=A&255;for(var T=0,U=aa.length;T<U;T++){S.fillStyle=S.strokeStyle=this.prefs.color;Y=Math.round((aa[T][0]-C)*D);G=aa[T][1];var W=false,J=false;if(G===null){if(I&&L==="Filled"){S.lineTo(Y,B)}I=false;continue}if(G<K){J=true;G=K}else{if(G>F){W=true;G=F}}if(L==="Histogram"){G=Math.round(G/M*B);S.fillRect(Y,ac,E,-G)}else{if(L==="Intensity"){var z=(G-K)/M,O=Math.round(H+(255-H)*(1-z)),X=Math.round(R+(255-R)*(1-z)),ab=Math.round(V+(255-V)*(1-z));S.fillStyle="rgb("+O+","+X+","+ab+")";S.fillRect(Y,0,E,B)}else{G=Math.round(B-(G-K)/M*B);if(I){S.lineTo(Y,G)}else{I=true;if(L==="Filled"){S.moveTo(Y,B);S.lineTo(Y,G)}else{S.moveTo(Y,G)}}}}S.fillStyle=this.prefs.overflow_color;if(W||J){var Z;if(L==="Histogram"||L==="Intensity"){Z=E}else{Y-=2;Z=4}if(W){S.fillRect(Y,0,Z,3)}if(J){S.fillRect(Y,B-3,Z,3)}}S.fillStyle=this.prefs.color}if(L==="Filled"){if(I){S.lineTo(Y,ac);S.lineTo(0,ac)}S.fill()}else{S.stroke()}S.restore()};var m=function(y){this.feature_positions={};this.slot_height=y;this.translation=0;this.y_translation=0};m.prototype.map_feature_data=function(z,B,y,A){if(!this.feature_positions[B]){this.feature_positions[B]=[]}this.feature_positions[B].push({data:z,x_start:y,x_end:A})};m.prototype.get_feature_data=function(z,D){var C=Math.floor((D-this.y_translation)/this.slot_height),B;if(!this.feature_positions[C]){return null}z+=this.translation;for(var A=0;A<this.feature_positions[C].length;A++){B=this.feature_positions[C][A];if(z>=B.x_start&&z<=B.x_end){return B.data}}};var o=function(A,D,y,z,C,E,B){l.call(this,A,D,y,z,C);this.alpha_scaler=(E?E:new d());this.height_scaler=(B?B:new d())};o.prototype.default_prefs={block_color:"#FFF",connector_color:"#FFF"};u(o.prototype,{get_required_height:function(A,z){var y=y_scale=this.get_row_height(),B=this.mode;if(B==="no_detail"||B==="Squish"||B==="Pack"){y=A*y_scale}return y+this.get_top_padding(z)+this.get_bottom_padding(z)},get_top_padding:function(y){return 0},get_bottom_padding:function(y){return Math.max(Math.round(this.get_row_height()/2),5)},draw:function(K,I,G,E,F){var Q=this.data,D=this.view_start,M=this.view_end;K.save();K.fillStyle=this.prefs.block_color;K.textAlign="right";var H=this.view_end-this.view_start,L=this.get_row_height(),P=new m(L),B;for(var N=0,O=Q.length;N<O;N++){var A=Q[N],C=A[0],J=A[1],y=A[2],z=(F&&F[C]!==undefined?F[C]:null);if((J<M&&y>D)&&(this.mode=="Dense"||z!==null)){B=this.draw_element(K,this.mode,A,z,D,M,E,L,I);P.map_feature_data(A,z,B[0],B[1])}}K.restore();P.y_translation=this.get_top_padding(I);return P},draw_element:function(E,A,G,C,B,D,F,z,y){console.log("WARNING: Unimplemented function.");return[0,0]}});var c=10,h=3,k=5,w=10,f=1,s=9,e=3,a=9,j=2,g="#ccc";var r=function(A,D,y,z,C,E,B){o.call(this,A,D,y,z,C,E,B);this.draw_background_connector=true;this.draw_individual_connectors=false};u(r.prototype,o.prototype,{get_row_height:function(){var z=this.mode,y;if(z==="Dense"){y=c}else{if(z==="no_detail"){y=h}else{if(z==="Squish"){y=k}else{y=w}}}return y},draw_element:function(M,D,X,H,O,aj,an,ap,y){var T=X[0],al=X[1],ad=X[2]-1,Q=X[3],ae=Math.floor(Math.max(0,(al-O)*an)),N=Math.ceil(Math.min(y,Math.max(0,(ad-O)*an))),ac=ae,ao=N,aa=(D==="Dense"?0:(0+H))*ap+this.get_top_padding(y),L,ah,R=null,ar=null,B=this.prefs.block_color,ag=this.prefs.label_color;M.globalAlpha=this.alpha_scaler.gen_val(X);if(D==="Dense"){H=1}if(D==="no_detail"){M.fillStyle=B;M.fillRect(ae,aa+5,N-ae,f)}else{var K=X[4],Z=X[5],af=X[6],C=X[7],V=true;if(Z&&af){R=Math.floor(Math.max(0,(Z-O)*an));ar=Math.ceil(Math.min(y,Math.max(0,(af-O)*an)))}var am,U;if(D==="Squish"){am=1;U=e;V=false}else{if(D==="Dense"){am=5;U=s}else{am=5;U=a}}if(!C){M.fillStyle=B;M.fillRect(ae,aa+1,N-ae,U);if(K&&V){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand_inv")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand_inv")}}M.fillRect(ae,aa+1,N-ae,U)}}else{var J,W;if(D==="Squish"||D==="Dense"){J=aa+Math.floor(e/2)+1;W=1}else{if(K){J=aa;W=U}else{J+=(e/2)+1;W=1}}if(this.draw_background_connector){if(D==="Squish"||D==="Dense"){M.fillStyle=g}else{if(K){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand")}}}else{M.fillStyle=g}}M.fillRect(ae,J,N-ae,W)}var E;for(var ak=0,A=C.length;ak<A;ak++){var F=C[ak],z=Math.floor(Math.max(0,(F[0]-O)*an)),Y=Math.ceil(Math.min(y,Math.max((F[1]-1-O)*an))),S,ab;if(z>Y){continue}M.fillStyle=B;M.fillRect(z,aa+(U-am)/2+1,Y-z,am);if(R!==undefined&&af>Z&&!(z>ar||Y<R)){var ai=Math.max(z,R),I=Math.min(Y,ar);M.fillRect(ai,aa+1,I-ai,U);if(C.length==1&&D=="Pack"){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand_inv")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand_inv")}}if(ai+14<I){ai+=2;I-=2}M.fillRect(ai,aa+1,I-ai,U)}}if(this.draw_individual_connectors&&S){this.draw_connector(M,S,ab,z,Y,aa)}S=z;ab=Y}if(D==="Pack"){M.globalAlpha=1;M.fillStyle="white";var G=this.height_scaler.gen_val(X),P=Math.ceil(U*G),aq=Math.round((U-P)/2);if(G!==1){M.fillRect(ae,J+1,N-ae,aq);M.fillRect(ae,J+U-aq+1,N-ae,aq)}}}M.globalAlpha=1;if(D==="Pack"&&al>O){M.fillStyle=ag;if(O===0&&ae-M.measureText(Q).width<0){M.textAlign="left";M.fillText(Q,N+j,aa+8);ao+=M.measureText(Q).width+j}else{M.textAlign="right";M.fillText(Q,ae-j,aa+8);ac-=M.measureText(Q).width+j}}}M.globalAlpha=1;return[ac,ao]}});var t=function(B,E,y,A,D,F,C,z){o.call(this,B,E,y,A,D,F,C);this.ref_seq=(z?z.data:null)};u(t.prototype,o.prototype,{get_row_height:function(){var y,z=this.mode;if(z==="Dense"){y=c}else{if(z==="Squish"){y=k}else{y=w;if(this.prefs.show_insertions){y*=2}}}return y},draw_read:function(K,A,ag,V,L,aa,ad,C,B,M){K.textAlign="center";var J=this,R=[L,aa],Z=0,W=0,D=0,F=K.canvas.manager.char_width_px,y=(B==="+"?this.prefs.block_color:this.prefs.reverse_strand_color);var O=[];if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){D=Math.round(ag/2)}if(!C){C=[[0,M.length]]}for(var G=0,I=C.length;G<I;G++){var z=C[G],E="MIDNSHP=X"[z[0]],S=z[1];if(E==="H"||E==="S"){Z-=S}var U=ad+Z,Y=Math.floor(Math.max(0,(U-L)*ag)),ab=Math.floor(Math.max(0,(U+S-L)*ag));if(Y===ab){ab+=1}switch(E){case"H":break;case"S":case"M":case"=":if(is_overlap([U,U+S],R)){var N=M.slice(W,W+S);if(D>0){K.fillStyle=y;K.fillRect(Y-D,V+1,ab-Y,9);K.fillStyle=g;for(var af=0,H=N.length;af<H;af++){if(this.prefs.show_differences){if(this.ref_seq){var P=this.ref_seq[U-L+af];if(!P||P.toLowerCase()===N[af].toLowerCase()){continue}}else{continue}}if(U+af>=L&&U+af<=aa){var X=Math.floor(Math.max(0,(U+af-L)*ag));K.fillText(N[af],X,V+9)}}}else{K.fillStyle=y;K.fillRect(Y,V+4,ab-Y,e)}}W+=S;Z+=S;break;case"N":K.fillStyle=g;K.fillRect(Y-D,V+5,ab-Y,1);Z+=S;break;case"D":K.fillStyle="red";K.fillRect(Y-D,V+4,ab-Y,3);Z+=S;break;case"P":break;case"I":var ah=Y-D;if(is_overlap([U,U+S],R)){var N=M.slice(W,W+S);if(this.prefs.show_insertions){var T=Y-(ab-Y)/2;if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){K.fillStyle="yellow";K.fillRect(T-D,V-9,ab-Y,9);O[O.length]={type:"triangle",data:[ah,V+4,5]};K.fillStyle=g;switch(compute_overlap([U,U+S],R)){case (OVERLAP_START):N=N.slice(L-U);break;case (OVERLAP_END):N=N.slice(0,U-aa);break;case (CONTAINED_BY):break;case (CONTAINS):N=N.slice(L-U,U-aa);break}for(var af=0,H=N.length;af<H;af++){var X=Math.floor(Math.max(0,(U+af-L)*ag));K.fillText(N[af],X-(ab-Y)/2,V)}}else{K.fillStyle="yellow";K.fillRect(T,V+(this.mode!=="Dense"?2:5),ab-Y,(A!=="Dense"?e:s))}}else{if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){O.push({type:"text",data:[N.length,ah,V+9]})}else{}}}W+=S;break;case"X":W+=S;break}}K.fillStyle="yellow";var Q,ai,ae;for(var ac=0;ac<O.length;ac++){Q=O[ac];ai=Q.type;ae=Q.data;if(ai==="text"){K.save();K.font="bold "+K.font;K.fillText(ae[0],ae[1],ae[2]);K.restore()}else{if(ai=="triangle"){q(K,ae[0],ae[1],ae[2])}}}},draw_element:function(R,M,E,B,U,z,I,S,P){var H=E[0],Q=E[1],A=E[2],J=E[3],D=Math.floor(Math.max(0,(Q-U)*I)),F=Math.ceil(Math.min(P,Math.max(0,(A-U)*I))),C=(M==="Dense"?0:(0+B))*S,G=this.prefs.label_color,O=0;if((M==="Pack"||this.mode==="Auto")&&I>R.canvas.manager.char_width_px){var O=Math.round(I/2)}if(E[5] instanceof Array){var N=Math.floor(Math.max(0,(E[4][0]-U)*I)),L=Math.ceil(Math.min(P,Math.max(0,(E[4][1]-U)*I))),K=Math.floor(Math.max(0,(E[5][0]-U)*I)),y=Math.ceil(Math.min(P,Math.max(0,(E[5][1]-U)*I)));if(E[4][1]>=U&&E[4][0]<=z&&E[4][2]){this.draw_read(R,M,I,C,U,z,E[4][0],E[4][2],E[4][3],E[4][4])}if(E[5][1]>=U&&E[5][0]<=z&&E[5][2]){this.draw_read(R,M,I,C,U,z,E[5][0],E[5][2],E[5][3],E[5][4])}if(K>L){R.fillStyle=g;p(R,L-O,C+5,K-O,C+5)}}else{this.draw_read(R,M,I,C,U,z,Q,E[4],E[5],E[6])}if(M==="Pack"&&Q>U&&J!=="."){R.fillStyle=this.prefs.label_color;var T=1;if(T===0&&D-R.measureText(J).width<0){R.textAlign="left";R.fillText(J,F+j-O,C+8)}else{R.textAlign="right";R.fillText(J,D-j-O,C+8)}}return[0,0]}});var n=function(A,D,y,z,C,E,B){r.call(this,A,D,y,z,C,E,B);this.longest_feature_length=this.calculate_longest_feature_length();this.draw_background_connector=false;this.draw_individual_connectors=true};u(n.prototype,o.prototype,r.prototype,{calculate_longest_feature_length:function(){var z=0;for(var C=0,y=this.data.length;C<y;C++){var B=this.data[C],A=B[1],D=B[2];z=Math.max(z,D-A)}return z},get_top_padding:function(z){var y=this.view_end-this.view_start,A=z/y;return Math.min(128,Math.ceil((this.longest_feature_length/2)*A))},draw_connector:function(G,B,F,H,E,D){var y=(F+H)/2,C=H-y;var A=Math.PI,z=0;if(C>0){G.beginPath();G.arc(y,D,H-y,Math.PI,0);G.stroke()}}});x.Scaler=d;x.SummaryTreePainter=v;x.LinePainter=b;x.LinkedFeaturePainter=r;x.ReadPainter=t;x.ArcLinkedFeaturePainter=n};(function(d){var c={};var b=function(e){return c[e]};var a=function(f,g){var e={};g(b,e);c[f]=e};a("class",class_module);a("slotting",slotting_module);a("painters",painters_module);a("trackster",trackster_module);for(key in c.trackster){d[key]=c.trackster[key]}})(window); \ No newline at end of file +var class_module=function(b,a){var c=function(){var f=arguments[0];for(var e=1;e<arguments.length;e++){var d=arguments[e];for(key in d){f[key]=d[key]}}return f};a.extend=c};var requestAnimationFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(b,a){window.setTimeout(b,1000/60)}})();var BEFORE=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005,AFTER=1006;var compute_overlap=function(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=BEFORE}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=AFTER}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a};var is_overlap=function(c,b){var a=compute_overlap(c,b);return(a!==BEFORE&&a!==AFTER)};var is_deferred=function(a){return("isResolved" in a)};var get_random_color=function(a){if(!a){a="#ffffff"}if(typeof(a)==="string"){a=[a]}for(var j=0;j<a.length;j++){a[j]=parseInt(a[j].slice(1),16)}var n=function(t,s,i){return((t*299)+(s*587)+(i*114))/1000};var e=function(v,u,w,s,i,t){return(Math.max(v,s)-Math.min(v,s))+(Math.max(u,i)-Math.min(u,i))+(Math.max(w,t)-Math.min(w,t))};var g,o,f,k,q,h,r,c,d,b,p,m=false,l=0;do{g=Math.round(Math.random()*16777215);o=(g&16711680)>>16;f=(g&65280)>>8;k=g&255;d=n(o,f,k);m=true;for(var j=0;j<a.length;j++){q=a[j];h=(q&16711680)>>16;r=(q&65280)>>8;c=q&255;b=n(h,r,c);p=e(o,f,k,h,r,c);if((Math.abs(d-b)<40)||(p<200)){m=false;break}}l++}while(!m&&l<=10);return"#"+(16777216+g).toString(16).substr(1,6)};var create_action_icon=function(c,b,a){return $("<a/>").attr("href","javascript:void(0);").attr("title",c).addClass("icon-button").addClass(b).tipsy({gravity:"s"}).click(a)};var trackster_module=function(e,W){var p=e("class").extend,s=e("slotting"),L=e("painters");var ad=function(ae,af){this.document=ae;this.default_font=af!==undefined?af:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};p(ad.prototype,{load_pattern:function(ae,ai){var af=this.patterns,ag=this.dummy_context,ah=new Image();ah.src=image_path+ai;ah.onload=function(){af[ae]=ag.createPattern(ah,"repeat")}},get_pattern:function(ae){return this.patterns[ae]},new_canvas:function(){var ae=this.document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(ae)}ae.manager=this;return ae}});var n={};var l=function(ae,af){n[ae.attr("id")]=af};var m=function(ae,ag,ai,ah){ai=".group";var af={};n[ae.attr("id")]=ah;ae.bind("drag",{handle:"."+ag,relative:true},function(aq,ar){var ap=$(this);var av=$(this).parent(),am=av.children(),ao=n[$(this).attr("id")],al,ak,at,aj,an;ak=$(this).parents(ai);if(ak.length!==0){at=ak.position().top;aj=at+ak.outerHeight();if(ar.offsetY<at){$(this).insertBefore(ak);var au=n[ak.attr("id")];au.remove_drawable(ao);au.container.add_drawable_before(ao,au);return}else{if(ar.offsetY>aj){$(this).insertAfter(ak);var au=n[ak.attr("id")];au.remove_drawable(ao);au.container.add_drawable(ao);return}}}ak=null;for(an=0;an<am.length;an++){al=$(am.get(an));at=al.position().top;aj=at+al.outerHeight();if(al.is(ai)&&this!==al.get(0)&&ar.offsetY>=at&&ar.offsetY<=aj){if(ar.offsetY-at<aj-ar.offsetY){al.find(".content-div").prepend(this)}else{al.find(".content-div").append(this)}if(ao.container){ao.container.remove_drawable(ao)}n[al.attr("id")].add_drawable(ao);return}}for(an=0;an<am.length;an++){if(ar.offsetY<$(am.get(an)).position().top){break}}if(an===am.length){if(this!==am.get(an-1)){av.append(this);n[av.attr("id")].move_drawable(ao,an)}}else{if(this!==am.get(an)){$(this).insertBefore(am.get(an));n[av.attr("id")].move_drawable(ao,(ar.deltaY>0?an-1:an))}}}).bind("dragstart",function(){af["border-top"]=ae.css("border-top");af["border-bottom"]=ae.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(af)})};W.moveable=m;var ac=16,F=9,C=20,y=100,I=12000,Q=200,A=5,u=10,K=5000,v=100,o="There was an error in indexing this dataset. ",J="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",D="No data for this chrom/contig.",t="Currently indexing... please wait",w="Tool cannot be rerun: ",a="Loading data...",X="Ready for display",R=10,H=20;function Y(af,ae){if(!ae){ae=0}var ag=Math.pow(10,ae);return Math.round(af*ag)/ag}var c=function(ae){this.num_elements=ae;this.clear()};p(c.prototype,{get:function(af){var ae=this.key_ary.indexOf(af);if(ae!==-1){if(this.obj_cache[af].stale){this.key_ary.splice(ae,1);delete this.obj_cache[af]}else{this.move_key_to_end(af,ae)}}return this.obj_cache[af]},set:function(af,ag){if(!this.obj_cache[af]){if(this.key_ary.length>=this.num_elements){var ae=this.key_ary.shift();delete this.obj_cache[ae]}this.key_ary.push(af)}this.obj_cache[af]=ag;return ag},move_key_to_end:function(af,ae){this.key_ary.splice(ae,1);this.key_ary.push(af)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var S=function(af,ae,ag){c.call(this,af);this.track=ae;this.subset=(ag!==undefined?ag:true)};p(S.prototype,c.prototype,{load_data:function(an,ai,al,af,ak){var am=this.track.view.chrom,ah={chrom:am,low:an,high:ai,mode:al,resolution:af,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(ah,ak);if(this.track.filters_manager){var ao=[];var ae=this.track.filters_manager.filters;for(var aj=0;aj<ae.length;aj++){ao.push(ae[aj].name)}ah.filter_cols=JSON.stringify(ao)}var ag=this;return $.getJSON(this.track.data_url,ah,function(ap){ag.set_data(an,ai,ap)})},get_data:function(ae,ai,aj,af,ah){var ag=this.get(ae,ai);if(ag&&(is_deferred(ag)||this.track.data_and_mode_compatible(ag,aj))){return ag}ag=this.load_data(ae,ai,aj,af,ah);this.set_data(ae,ai,ag);return ag},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(am,ah,al,ag,ak,ai){var an=this.get(am,ah);if(!(an&&this.track.data_and_mode_compatible(an,al))){console.log("ERROR: no current data for: ",this.track,am,ah,al,ag,ak);return}an.stale=true;var af=am;if(ai===this.DEEP_DATA_REQ){$.extend(ak,{start_val:an.data.length+1})}else{if(ai===this.BROAD_DATA_REQ){af=(an.max_high?an.max_high:an.data[an.data.length-1][2])+1}}var ae=this,aj=this.load_data(af,ah,al,ag,ak);new_data_available=$.Deferred();this.set_data(am,ah,new_data_available);$.when(aj).then(function(ao){if(ao.data){ao.data=an.data.concat(ao.data);if(ao.max_low){ao.max_low=an.max_low}if(ao.message){ao.message=ao.message.replace(/[0-9]+/,ao.data.length)}}ae.set_data(am,ah,ao);new_data_available.resolve(ao)});return new_data_available},get:function(ae,af){return c.prototype.get.call(this,this.gen_key(ae,af))},set_data:function(af,ag,ae){return this.set(this.gen_key(af,ag),ae)},gen_key:function(ae,ag){var af=ae+"_"+ag;return af},split_key:function(ae){return ae.split("_")}});var G=function(af,ae,ag){S.call(this,af,ae,ag)};p(G.prototype,S.prototype,c.prototype,{get:S.prototype.get,load_data:function(ae,ah,ai,af,ag){if(af>1){return{data:null}}return S.prototype.load_data.call(this,ae,ah,ai,af,ag)}});var q=function(ah,af,ae,ag,aj){if(!q.id_counter){q.id_counter=0}this.id=q.id_counter++;this.name=ah;this.view=af;this.container=ae;this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ah}],saved_values:ag,onchange:function(){this.track.set_name(this.track.config.values.name)}});this.prefs=this.config.values;this.drag_handle_class=aj;this.is_overview=false;this.action_icons={};this.content_visible=true;this.container_div=this.build_container_div();this.header_div=this.build_header_div();if(this.header_div){this.container_div.append(this.header_div);this.icons_div=$("<div/>").css("float","left").hide().appendTo(this.header_div);this.build_action_icons(this.action_icons_def);this.header_div.append($("<div style='clear: both'/>"));this.header_div.dblclick(function(ak){ak.stopPropagation()});var ai=this;this.container_div.hover(function(){ai.icons_div.show()},function(){ai.icons_div.hide()});$("<div style='clear: both'/>").appendTo(this.container_div)}};q.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(ae){if(ae.content_visible){ae.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");ae.hide_contents();ae.content_visible=false}else{ae.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");ae.content_visible=true;ae.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"settings-icon",on_click_fn:function(af){var ah=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},ae=function(){af.config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ag=function(ai){if((ai.keyCode||ai.which)===27){ah()}else{if((ai.keyCode||ai.which)===13){ae()}}};$(window).bind("keypress.check_enter_esc",ag);show_modal("Configure",af.config.build_form(),{Cancel:ah,OK:ae})}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(ae){$(".tipsy").remove();ae.remove()}}];p(q.prototype,{init:function(){},can_draw:function(){if(this.enabled&&this.content_visible){return true}return false},request_draw:function(){},_draw:function(){},to_dict:function(){},from_dict:function(ae){},update_icons:function(){},set_name:function(ae){this.old_name=this.name;this.name=ae;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)},remove:function(){this.container.remove_drawable(this);this.container_div.hide(0,function(){$(this).remove();view.update_intro_div();view.has_changes=true})},build_container_div:function(){},build_header_div:function(){},add_action_icon:function(af,aj,ai,ah,ae){var ag=this;this.action_icons[af]=$("<a/>").attr("href","javascript:void(0);").attr("title",aj).addClass("icon-button").addClass(ai).tipsy({gravity:"s"}).click(function(){ah(ag)}).appendTo(this.icons_div)},build_action_icons:function(ae){var ag;for(var af=0;af<ae.length;af++){ag=ae[af];this.add_action_icon(ag.name,ag.title,ag.css_class,ag.on_click_fn,ag.prepend)}},update_icons:function(){},hide_contents:function(){},show_contents:function(){}});var x=function(ai,ah,af,ae,ag,aj){q.call(this,ah,af,ae,ag,aj);this.obj_type=ai;this.drawables=[]};p(x.prototype,q.prototype,{init:function(){for(var ae=0;ae<this.drawables.length;ae++){this.drawables[ae].init()}},_draw:function(){for(var ae=0;ae<this.drawables.length;ae++){this.drawables[ae]._draw()}},to_dict:function(){var af=[];for(var ae=0;ae<this.drawables.length;ae++){af.push(this.drawables[ae].to_dict())}return{name:this.name,prefs:this.prefs,obj_type:this.obj_type,drawables:af}},from_dict:function(ak,ae){var aj=new this.constructor(ak.name,view,ae,ak.prefs,view.viewport_container,view);var af,ai,ah;for(var ag=0;ag<ak.drawables.length;ag++){af=ak.drawables[ag];ai=af.obj_type;if(!ai){ai=af.track_type}ah=addable_objects[ai].prototype.from_dict(af,aj);aj.add_drawable(ah)}return aj},add_drawable:function(ae){this.drawables.push(ae);ae.container=this},add_drawable_before:function(ag,ae){var af=this.drawables.indexOf(ae);if(af!==-1){this.drawables.splice(af,0,ag);return true}return false},replace_drawable:function(ag,ae,af){var ah=this.drawables.indexOf(ag);if(ah!==-1){this.drawables[ah]=ae;if(af){ag.container_div.replaceWith(ae.container_div)}}return ah},remove_drawable:function(af){var ae=this.drawables.indexOf(af);if(ae!==-1){this.drawables.splice(ae,1);af.container=null;return true}return false},move_drawable:function(af,ag){var ae=this.drawables.indexOf(af);if(ae!==-1){this.drawables.splice(ae,1);this.drawables.splice(ag,0,af);return true}return false}});var P=function(ah,af,ae,ag){x.call(this,"DrawableGroup",ah,af,ae,ag,"group-handle");this.content_div=$("<div/>").addClass("content-div").attr("id","group_"+this.id+"_content_div").appendTo(this.container_div);l(this.container_div,this);l(this.content_div,this);m(this.container_div,this.drag_handle_class,".group",this);this.filters_manager=new Z(this);this.filters_div=this.filters_manager.parent_div;this.header_div.after(this.filters_div);this.saved_filters_managers=null};p(P.prototype,q.prototype,x.prototype,{action_icons_def:[q.prototype.action_icons_def[0],q.prototype.action_icons_def[1],{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(ae){$(".tipsy").remove();ae.show_composite_track()}},{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(af){if(af.filters_div.is(":visible")){af.filters_manager.clear_filters();for(var ae=0;ae<af.drawables.length;ae++){af.drawables[ae].filters_manager=af.saved_filters_managers[ae]}af.saved_filters_managers=null}else{if(af.filters_manager.filters.length>0){af.saved_filters_managers=[];for(var ae=0;ae<af.drawables.length;ae++){drawable=af.drawables[ae];af.saved_filters_managers.push(drawable.filters_manager);drawable.filters_manager=af.filters_manager}}af.filters_manager.init_filters();af.request_draw(true)}af.filters_div.toggle()}},q.prototype.action_icons_def[2]],build_container_div:function(){var ae=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(ae)}return ae},build_header_div:function(){var ae=$("<div/>").addClass("track-header");ae.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("track-name").text(this.name).appendTo(ae);return ae},hide_contents:function(){this.content_div.hide()},show_contents:function(){this.content_div.show();this.request_draw()},update_icons:function(){var ag=this.drawables.length;if(ag===0){this.action_icons.composite_icon.hide();this.action_icons.filters_icon.hide()}else{if(ag===1){if(this.drawables[0] instanceof h){this.action_icons.composite_icon.show()}this.action_icons.filters_icon.hide()}else{var ak,aq=true,ai=this.drawables[0].get_type(),ae=0;for(var an=0;an<ag;an++){ak=this.drawables[an];if(ak.get_type()!==ai){can_composite=false;break}if(ak instanceof d){ae++}}if(aq||ae===1){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tipsy").remove()}if(ae>1&&ae===this.drawables.length){var ar={},af;ak=this.drawables[0];for(var am=0;am<ak.filters_manager.filters.length;am++){af=ak.filters_manager.filters[am];ar[af.name]=[af]}for(var an=1;an<this.drawables.length;an++){ak=this.drawables[an];for(var am=0;am<ak.filters_manager.filters.length;am++){af=ak.filters_manager.filters[am];if(af.name in ar){ar[af.name].push(af)}}}this.filters_manager.remove_all();var ah,aj,al,ao;for(var ap in ar){ah=ar[ap];if(ah.length===ae){aj=new U(ah[0].name,ah[0].index);this.filters_manager.add_filter(aj)}}if(this.filters_manager.filters.length>0){this.action_icons.filters_icon.show()}else{this.action_icons.filters_icon.hide()}}else{this.action_icons.filters_icon.hide()}}}},show_composite_track:function(){var ai=[];for(var af=0;af<this.drawables.length;af++){ai.push(this.drawables[af].name)}var ag="Composite Track of "+this.drawables.length+" tracks ("+ai.join(", ")+")";var ah=new h(ag,this.view,this.view,this.drawables);var ae=this.container.replace_drawable(this,ah,true);ah.request_draw()},add_drawable:function(ae){x.prototype.add_drawable.call(this,ae);this.update_icons()},remove_drawable:function(ae){x.prototype.remove_drawable.call(this,ae);this.update_icons()},from_dict:function(ah,ae){var ag=x.prototype.from_dict.call(this,ah,ae);for(var af=0;af<ag.drawables.length;af++){ag.content_div.append(ag.drawables[af].container_div)}return ag},request_draw:function(ae,ag){for(var af=0;af<this.drawables.length;af++){this.drawables[af].request_draw(ae,ag)}}});var ab=function(ae,ah,ag,af){x.call(this,"View");this.container=ae;this.chrom=null;this.vis_id=ag;this.dbkey=af;this.title=ah;this.label_tracks=[];this.tracks_to_be_redrawn=[];this.max_low=0;this.max_high=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.load_chroms_deferred=null;this.init();this.canvas_manager=new ad(ae.get(0).ownerDocument);this.reset()};p(ab.prototype,x.prototype,{init:function(){var ag=this.container,ae=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ag);this.browser_content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ag);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ag);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.browser_content_div);this.content_div=this.viewport_container;l(this.viewport_container,ae);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container).hide();var ah=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){add_tracks()});this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a/>").attr("href","javascript:void(0);").attr("title","Close overview").addClass("icon-button overview-close tooltip").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var af=function(ai){if(ai.type==="focusout"||(ai.keyCode||ai.which)===13||(ai.keyCode||ai.which)===27){if((ai.keyCode||ai.which)!==27){ae.go_to($(this).val())}$(this).hide();$(this).val("");ae.location_span.show();ae.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",af).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").attr("original-title","Click to change location").tipsy({gravity:"n"}).appendTo(this.nav_controls);this.location_span.click(function(){ae.location_span.hide();ae.chrom_select.hide();ae.nav_input.val(ae.chrom+":"+ae.low+"-"+ae.high);ae.nav_input.css("display","inline-block");ae.nav_input.select();ae.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.nav_controls)}this.zo_link=$("<a/>").attr("id","zoom-out").attr("title","Zoom out").tipsy({gravity:"n"}).click(function(){ae.zoom_out();ae.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tipsy({gravity:"n"}).click(function(){ae.zoom_in();ae.request_redraw()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){ae.change_chrom(ae.chrom_select.val())});this.browser_content_div.click(function(ai){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(ai){ae.zoom_in(ai.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ai,aj){this.current_x=aj.offsetX}).bind("drag",function(ai,ak){var al=ak.offsetX-this.current_x;this.current_x=ak.offsetX;var aj=Math.round(al/ae.viewport_container.width()*(ae.max_high-ae.max_low));ae.move_delta(-aj)});this.overview_close.click(function(){ae.reset_overview()});this.viewport_container.bind("draginit",function(ai,aj){if(ai.clientX>ae.viewport_container.width()-16){return false}}).bind("dragstart",function(ai,aj){aj.original_low=ae.low;aj.current_height=ai.clientY;aj.current_x=aj.offsetX}).bind("drag",function(ak,am){var ai=$(this);var an=am.offsetX-am.current_x;var aj=ai.scrollTop()-(ak.clientY-am.current_height);ai.scrollTop(aj);am.current_height=ak.clientY;am.current_x=am.offsetX;var al=Math.round(an/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(al)}).bind("mousewheel",function(ak,am,aj,ai){if(aj){aj*=50;var al=Math.round(-aj/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(al)}});this.top_labeltrack.bind("dragstart",function(ai,aj){return $("<div />").css({height:ae.browser_content_div.height()+ae.top_labeltrack.height()+ae.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(am,an){$(an.proxy).css({left:Math.min(am.pageX,an.startX),width:Math.abs(am.pageX-an.startX)});var aj=Math.min(am.pageX,an.startX)-ae.container.offset().left,ai=Math.max(am.pageX,an.startX)-ae.container.offset().left,al=(ae.high-ae.low),ak=ae.viewport_container.width();ae.update_location(Math.round(aj/ak*al)+ae.low,Math.round(ai/ak*al)+ae.low)}).bind("dragend",function(an,ao){var aj=Math.min(an.pageX,ao.startX),ai=Math.max(an.pageX,ao.startX),al=(ae.high-ae.low),ak=ae.viewport_container.width(),am=ae.low;ae.low=Math.round(aj/ak*al)+am;ae.high=Math.round(ai/ak*al)+am;$(ao.proxy).remove();ae.request_redraw()});this.add_label_track(new aa(this,{content_div:this.top_labeltrack}));this.add_label_track(new aa(this,{content_div:this.nav_labeltrack}));$(window).bind("resize",function(){ae.resize_window()});$(document).bind("redraw",function(){ae.redraw()});this.reset();$(window).trigger("resize")},update_intro_div:function(){if(this.drawables.length===0){this.intro_div.show()}else{this.intro_div.hide()}},update_location:function(ae,af){this.location_span.text(commatize(ae)+" - "+commatize(af));this.nav_input.val(this.chrom+":"+commatize(ae)+"-"+commatize(af))},load_chroms:function(ag){ag.num=v;ag.dbkey=this.dbkey;var ae=this,af=$.Deferred();$.ajax({url:chrom_url,data:ag,dataType:"json",success:function(ai){if(ai.chrom_info.length===0){alert("Invalid chromosome: "+ag.chrom);return}if(ai.reference){ae.add_label_track(new z(ae))}ae.chrom_data=ai.chrom_info;var al='<option value="">Select Chrom/Contig</option>';for(var ak=0,ah=ae.chrom_data.length;ak<ah;ak++){var aj=ae.chrom_data[ak].chrom;al+='<option value="'+aj+'">'+aj+"</option>"}if(ai.prev_chroms){al+='<option value="previous">Previous '+v+"</option>"}if(ai.next_chroms){al+='<option value="next">Next '+v+"</option>"}ae.chrom_select.html(al);ae.chrom_start_index=ai.start_index;af.resolve(ai)},error:function(){alert("Could not load chroms for this dbkey:",ae.dbkey)}});return af},change_chrom:function(aj,af,al){if(!aj||aj==="None"){return}var ag=this;if(aj==="previous"){ag.load_chroms({low:this.chrom_start_index-v});return}if(aj==="next"){ag.load_chroms({low:this.chrom_start_index+v});return}var ak=$.grep(ag.chrom_data,function(am,an){return am.chrom===aj})[0];if(ak===undefined){ag.load_chroms({chrom:aj},function(){ag.change_chrom(aj,af,al)});return}else{if(aj!==ag.chrom){ag.chrom=aj;ag.chrom_select.val(ag.chrom);ag.max_high=ak.len-1;ag.reset();ag.request_redraw(true);for(var ai=0,ae=ag.drawables.length;ai<ae;ai++){var ah=ag.drawables[ai];if(ah.init){ah.init()}}if(ag.reference_track){ag.reference_track.init()}}if(af!==undefined&&al!==undefined){ag.low=Math.max(af,0);ag.high=Math.min(al,ag.max_high)}ag.reset_overview();ag.request_redraw()}},go_to:function(ai){ai=ai.replace(/ |,/g,"");var am=this,ae,ah,af=ai.split(":"),ak=af[0],al=af[1];if(al!==undefined){try{var aj=al.split("-");ae=parseInt(aj[0],10);ah=parseInt(aj[1],10)}catch(ag){return false}}am.change_chrom(ak,ae,ah)},move_fraction:function(ag){var ae=this;var af=ae.high-ae.low;this.move_delta(ag*af)},move_delta:function(ag){var ae=this;var af=ae.high-ae.low;if(ae.low-ag<ae.max_low){ae.low=ae.max_low;ae.high=ae.max_low+af}else{if(ae.high-ag>ae.max_high){ae.high=ae.max_high;ae.low=ae.max_high-af}else{ae.high-=ag;ae.low-=ag}}ae.request_redraw()},add_drawable:function(ae){x.prototype.add_drawable.call(this,ae);ae.init();this.has_changes=true;this.update_intro_div()},add_label_track:function(ae){ae.view=this;ae.init();this.label_tracks.push(ae)},remove_drawable:function(ag,af){x.prototype.remove_drawable.call(this,ag);if(af){var ae=this;ag.container_div.hide(0,function(){$(this).remove();ae.update_intro_div()});this.has_changes=true}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(am,ae,al,af){var ak=this,ai=(af?[af]:ak.drawables),ag;var af;for(var aj=0;aj<ai.length;aj++){af=ai[aj];ag=-1;for(var ah=0;ah<ak.tracks_to_be_redrawn.length;ah++){if(ak.tracks_to_be_redrawn[ah][0]===af){ag=ah;break}}if(ag<0){ak.tracks_to_be_redrawn.push([af,ae,al])}else{ak.tracks_to_be_redrawn[aj][1]=ae;ak.tracks_to_be_redrawn[aj][2]=al}}requestAnimationFrame(function(){ak._redraw(am)})},_redraw:function(ao){var al=this.low,ah=this.high;if(al<this.max_low){al=this.max_low}if(ah>this.max_high){ah=this.max_high}var an=this.high-this.low;if(this.high!==0&&an<this.min_separation){ah=al+this.min_separation}this.low=Math.floor(al);this.high=Math.ceil(ah);this.resolution=Math.pow(A,Math.ceil(Math.log((this.high-this.low)/Q)/Math.log(A)));this.zoom_res=Math.pow(u,Math.max(0,Math.ceil(Math.log(this.resolution,u)/Math.log(u))));var ae=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ak=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ap=13;this.overview_box.css({left:ae,width:Math.max(ap,ak)}).show();if(ak<ap){this.overview_box.css("left",ae-(ap-ak)/2)}if(this.overview_highlight){this.overview_highlight.css({left:ae,width:ak})}this.update_location(this.low,this.high);if(!ao){var ag,af,am;for(var ai=0,aj=this.tracks_to_be_redrawn.length;ai<aj;ai++){ag=this.tracks_to_be_redrawn[ai][0];af=this.tracks_to_be_redrawn[ai][1];am=this.tracks_to_be_redrawn[ai][2];if(ag){ag._draw(af,am)}}this.tracks_to_be_redrawn=[];for(ai=0,aj=this.label_tracks.length;ai<aj;ai++){this.label_tracks[ai]._draw()}}},zoom_in:function(af,ag){if(this.max_high===0||this.high-this.low<this.min_separation){return}var ah=this.high-this.low,ai=ah/2+this.low,ae=(ah/this.zoom_factor)/2;if(af){ai=af/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ai-ae);this.high=Math.round(ai+ae);this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var af=this.high-this.low,ag=af/2+this.low,ae=(af*this.zoom_factor)/2;this.low=Math.round(ag-ae);this.high=Math.round(ag+ae);this.request_redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.request_redraw()},set_overview:function(ag){if(this.overview_drawable){if(this.overview_drawable.dataset_id===ag.dataset_id){return}this.overview_viewport.find(".track").remove()}var af=ag.copy({content_div:this.overview_viewport}),ae=this;af.header_div.hide();af.is_overview=true;ae.overview_drawable=af;this.overview_drawable.postdraw_actions=function(){ae.overview_highlight.show().height(ae.overview_drawable.content_div.height());ae.overview_viewport.height(ae.overview_drawable.content_div.height()+ae.overview_box.outerHeight());ae.overview_close.show();ae.resize_window()};ae.overview_drawable.request_draw();ae.has_changes=true},reset_overview:function(){$(".tipsy").remove();this.overview_viewport.find(".track-tile").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide();view.resize_window();view.overview_drawable=null}});var r=function(ag,ak){this.track=ag;this.name=ak.name;this.params=[];var ar=ak.params;for(var ah=0;ah<ar.length;ah++){var am=ar[ah],af=am.name,aq=am.label,ai=unescape(am.html),at=am.value,ao=am.type;if(ao==="number"){this.params[this.params.length]=new f(af,aq,ai,at,am.min,am.max)}else{if(ao==="select"){this.params[this.params.length]=new N(af,aq,ai,at)}else{console.log("WARNING: unrecognized tool parameter type:",af,ao)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(av){av.stopPropagation()}).click(function(av){av.stopPropagation()}).bind("dblclick",function(av){av.stopPropagation()});var ap=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var an=this.params;var al=this;$.each(this.params,function(aw,az){var ay=$("<div>").addClass("param-row").appendTo(al.parent_div);var av=$("<div>").addClass("param-label").text(az.label).appendTo(ay);var ax=$("<div/>").addClass("param-input").html(az.html).appendTo(ay);ax.find(":input").val(az.value);$("<div style='clear: both;'/>").appendTo(ay)});this.parent_div.find("input").click(function(){$(this).select()});var au=$("<div>").addClass("param-row").appendTo(this.parent_div);var aj=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(au);var ae=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(au);var al=this;ae.click(function(){al.run_on_region()});aj.click(function(){al.run_on_dataset()})};p(r.prototype,{get_param_values_dict:function(){var ae={};this.parent_div.find(":input").each(function(){var af=$(this).attr("name"),ag=$(this).val();ae[af]=JSON.stringify(ag)});return ae},get_param_values:function(){var af=[];var ae={};this.parent_div.find(":input").each(function(){var ag=$(this).attr("name"),ah=$(this).val();if(ag){af[af.length]=ah}});return af},run_on_dataset:function(){var ae=this;ae.run({dataset_id:this.track.original_dataset_id,tool_id:ae.name},null,function(af){show_modal(ae.name+" is Running",ae.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var af={dataset_id:this.track.original_dataset_id,chrom:this.track.view.chrom,low:this.track.view.low,high:this.track.view.high,tool_id:this.name},aj=this.track,ag=af.tool_id+aj.tool_region_and_parameters_str(af.chrom,af.low,af.high),ae;if(aj.container===view){var ai=new P(this.name,this.track.view);var ah=aj.container.replace_drawable(aj,ai,false);ai.container_div.insertBefore(aj.view.content_div.children()[ah]);ai.add_drawable(aj);aj.container_div.appendTo(ai.content_div);ae=ai}else{ae=aj.container}var ak=new aj.constructor(ag,view,ae,"hda");ak.init_for_tool_data();ak.change_mode(aj.mode);ae.add_drawable(ak);ak.content_div.text("Starting job.");this.run(af,ak,function(al){ak.dataset_id=al.dataset_id;ak.content_div.text("Running job.");ak.init()})},run:function(af,ag,ah){$.extend(af,this.get_param_values_dict());var ae=function(){$.getJSON(rerun_tool_url,af,function(ai){if(ai==="no converter"){ag.container_div.addClass("error");ag.content_div.text(J)}else{if(ai.error){ag.container_div.addClass("error");ag.content_div.text(w+ai.message)}else{if(ai==="pending"){ag.container_div.addClass("pending");ag.content_div.text("Converting input data so that it can be used quickly with tool.");setTimeout(ae,2000)}else{ah(ai)}}}})};ae()}});var N=function(af,ae,ag,ah){this.name=af;this.label=ae;this.html=ag;this.value=ah};var f=function(ag,af,ai,aj,ah,ae){N.call(this,ag,af,ai,aj);this.min=ah;this.max=ae};var g=function(af,ae,ag,ah){this.manager=null;this.name=af;this.index=ae;this.tool_id=ag;this.tool_exp_name=ah};var U=function(af,am,at,ai){g.call(this,af,am,at,ai);this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.min=Number.MAX_VALUE;this.max=-Number.MAX_VALUE;this.container=null;this.slider=null;this.slider_label=null;var an=function(au,av,aw){au.click(function(){var aB=av.text(),az=parseFloat(aw.slider("option","max")),ay=(az<=1?4:az<=1000000?az.toString().length:6),aA=false,ax=$(this).parents(".slider-row");ax.addClass("input");if(aw.slider("option","values")){ay=2*ay+1;aA=true}av.text("");$("<input type='text'/>").attr("size",ay).attr("maxlength",ay).attr("value",aB).appendTo(av).focus().select().click(function(aC){aC.stopPropagation()}).blur(function(){$(this).remove();av.text(aB);ax.removeClass("input")}).keyup(function(aG){if(aG.keyCode===27){$(this).trigger("blur")}else{if(aG.keyCode===13){var aE=aw.slider("option","min"),aC=aw.slider("option","max"),aF=function(aH){return(isNaN(aH)||aH>aC||aH<aE)},aD=$(this).val();if(!aA){aD=parseFloat(aD);if(aF(aD)){alert("Parameter value must be in the range ["+aE+"-"+aC+"]");return $(this)}}else{aD=aD.split("-");aD=[parseFloat(aD[0]),parseFloat(aD[1])];if(aF(aD[0])||aF(aD[1])){alert("Parameter value must be in the range ["+aE+"-"+aC+"]");return $(this)}}aw.slider((aA?"values":"value"),aD);ax.removeClass("input")}}})})};var ag=this;ag.parent_div=$("<div/>").addClass("filter-row slider-row");var ae=$("<div/>").addClass("elt-label").appendTo(ag.parent_div),aq=$("<span/>").addClass("slider-name").text(ag.name+" ").appendTo(ae),ah=$("<span/>"),aj=$("<span/>").addClass("slider-value").appendTo(ae).append("[").append(ah).append("]");ag.values_span=ah;var ap=$("<div/>").addClass("slider").appendTo(ag.parent_div);ag.control_element=$("<div/>").attr("id",ag.name+"-filter-control").appendTo(ap);var ak=[0,0];ag.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(au,av){ag.slide(au,av)},change:function(au,av){ag.control_element.slider("option","slide").call(ag.control_element,au,av)}});ag.slider=ag.control_element;ag.slider_label=ah;an(aj,ah,ag.control_element);var ar=$("<div/>").addClass("display-controls").appendTo(ag.parent_div),al=create_action_icon("Use filter for data transparency","layer-transparent",function(){if(ag.manager.alpha_filter!==ag){ag.manager.alpha_filter=ag;ag.manager.parent_div.find(".layer-transparent").removeClass("active").hide();al.addClass("active").show()}else{ag.manager.alpha_filter=null;al.removeClass("active")}ag.manager.track.request_draw(true,true)}).appendTo(ar).hide(),ao=create_action_icon("Use filter for data height","arrow-resize-090",function(){if(ag.manager.height_filter!==ag){ag.manager.height_filter=ag;ag.manager.parent_div.find(".arrow-resize-090").removeClass("active").hide();ao.addClass("active").show()}else{ag.manager.height_filter=null;ao.removeClass("active")}ag.manager.track.request_draw(true,true)}).appendTo(ar).hide();ag.parent_div.hover(function(){al.show();ao.show()},function(){if(ag.manager.alpha_filter!==ag){al.hide()}if(ag.manager.height_filter!==ag){ao.hide()}});$("<div style='clear: both;'/>").appendTo(ag.parent_div)};p(U.prototype,{get_slider_step:function(ag,ae){var af=ae-ag;return(af<=2?0.01:1)},slide:function(af,ag){var ae=ag.values;this.values_span.text(ae[0]+"-"+ae[1]);this.low=ae[0];this.high=ae[1];this.manager.track.request_draw(true,true)},applies_to:function(ae){if(ae.length>this.index){return true}return false},keep:function(ae){if(!this.applies_to(ae)){return true}var af=ae[this.index];return(isNaN(af)||(af>=this.low&&af<=this.high))},update_attrs:function(af){var ae=false;if(!this.applies_to(af)){return ae}if(af[this.index]<this.min){this.min=Math.floor(af[this.index]);ae=true}if(af[this.index]>this.max){this.max=Math.ceil(af[this.index]);ae=true}return ae},update_ui_elt:function(){if(this.min!==this.max){this.parent_div.show()}else{this.parent_div.hide()}var af=this.slider.slider("option","min"),ae=this.slider.slider("option","max");if(this.min<af||this.max>ae){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",this.get_slider_step(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var Z=function(ag,aj){this.track=ag;this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(aq){aq.stopPropagation()}).click(function(aq){aq.stopPropagation()}).bind("dblclick",function(aq){aq.stopPropagation()}).bind("keydown",function(aq){aq.stopPropagation()});this.filters=[];if(aj){for(var ak=0;ak<aj.length;ak++){var ae=aj[ak],af=ae.name,an=ae.type,am=ae.index,ap=ae.tool_id,ah=ae.tool_exp_name;if(an==="int"||an==="float"){this.add_filter(new U(af,am,ap,ah))}else{console.log("ERROR: unsupported filter: ",af,an)}}}if(this.filters.length!==0){var ao=$("<div/>").addClass("param-row").appendTo(this.parent_div);var al=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(ao);var ai=this;al.click(function(){ai.run_on_dataset()})}};p(Z.prototype,{add_filter:function(ae){ae.manager=this;this.parent_div.append(ae.parent_div);this.filters.push(ae)},remove_all:function(){this.filters=[];this.parent_div.children().remove()},init_filters:function(){for(var ae=0;ae<this.filters.length;ae++){var af=this.filters[ae];af.update_ui_elt()}},clear_filters:function(){for(var ae=0;ae<this.filters.length;ae++){var af=this.filters[ae];af.slider.slider("option","values",[af.min,af.max])}this.alpha_filter=null;this.height_filter=null;this.parent_div.find(".icon-button").hide()},run_on_dataset:function(){var am=function(aq,ao,ap){if(!(ao in aq)){aq[ao]=ap}return aq[ao]};var ag={},ae,af,ah;for(var ai=0;ai<this.filters.length;ai++){ae=this.filters[ai];if(ae.tool_id){if(ae.min!==ae.low){af=am(ag,ae.tool_id,[]);af[af.length]=ae.tool_exp_name+" >= "+ae.low}if(ae.max!==ae.high){af=am(ag,ae.tool_id,[]);af[af.length]=ae.tool_exp_name+" <= "+ae.high}}}var ak=[];for(var an in ag){ak[ak.length]=[an,ag[an]]}var al=ak.length;(function aj(av,ar){var ap=ar[0],aq=ap[0],au=ap[1],at="("+au.join(") and (")+")",ao={cond:at,input:av,target_dataset_id:av,tool_id:aq},ar=ar.slice(1);$.getJSON(run_tool_url,ao,function(aw){if(aw.error){show_modal("Filter Dataset","Error running tool "+aq,{Close:hide_modal})}else{if(ar.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{aj(aw.dataset_id,ar)}}})})(this.track.dataset_id,ak)}});var B=function(ae,af){L.Scaler.call(this,af);this.filter=ae};B.prototype.gen_val=function(ae){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_val}return((parseFloat(ae[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var E=function(ae){this.track=ae.track;this.params=ae.params;this.values={};this.restore_values((ae.saved_values?ae.saved_values:{}));this.onchange=ae.onchange};p(E.prototype,{restore_values:function(ae){var af=this;$.each(this.params,function(ag,ah){if(ae[ah.key]!==undefined){af.values[ah.key]=ae[ah.key]}else{af.values[ah.key]=ah.default_value}})},build_form:function(){var ah=this;var ae=$("<div />");var ag;function af(al,ai){for(var ap=0;ap<al.length;ap++){ag=al[ap];if(ag.hidden){continue}var aj="param_"+ap;var au=ah.values[ag.key];var ax=$("<div class='form-row' />").appendTo(ai);ax.append($("<label />").attr("for",aj).text(ag.label+":"));if(ag.type==="bool"){ax.append($('<input type="checkbox" />').attr("id",aj).attr("name",aj).attr("checked",au))}else{if(ag.type==="text"){ax.append($('<input type="text"/>').attr("id",aj).val(au).click(function(){$(this).select()}))}else{if(ag.type==="select"){var ar=$("<select />").attr("id",aj);for(var an=0;an<ag.options.length;an++){$("<option/>").text(ag.options[an].label).attr("value",ag.options[an].value).appendTo(ar)}ar.val(au);ax.append(ar)}else{if(ag.type==="color"){var aw=$("<div/>").appendTo(ax),aq=$("<input />").attr("id",aj).attr("name",aj).val(au).css("float","left").appendTo(aw).click(function(az){$(".tipsy").hide();var ay=$(this).siblings(".tipsy");ay.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top-($(ay).height()/2)+($(this).height()/2)}).show();ay.click(function(aA){aA.stopPropagation()});$(document).bind("click.color-picker",function(){ay.hide();$(document).unbind("click.color-picker")});az.stopPropagation()}),ao=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(aw).attr("title","Set new random color").tipsy({gravity:"s"}),at=$("<div class='tipsy tipsy-west' style='position: absolute;' />").appendTo(aw).hide(),ak=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(at),av=$("<div/>").appendTo(ak),am=$.farbtastic(av,{width:100,height:100,callback:aq,color:au});aw.append($("<div/>").css("clear","both"));(function(ay){ao.click(function(){ay.setColor(get_random_color())})})(am)}else{ax.append($("<input />").attr("id",aj).attr("name",aj).val(au))}}}}if(ag.help){ax.append($("<div class='help'/>").text(ag.help))}}}af(this.params,ae);return ae},update_from_form:function(ae){var ag=this;var af=false;$.each(this.params,function(ah,aj){if(!aj.hidden){var ak="param_"+ah;var ai=ae.find("#"+ak).val();if(aj.type==="float"){ai=parseFloat(ai)}else{if(aj.type==="int"){ai=parseInt(ai)}else{if(aj.type==="bool"){ai=ae.find("#"+ak).is(":checked")}}}if(ai!==ag.values[aj.key]){ag.values[aj.key]=ai;af=true}}});if(af){this.onchange()}}});var b=function(ae,ah,ag,af,ai){this.track=ae;this.index=ah;this.low=ah*Q*ag;this.high=(ah+1)*Q*ag;this.resolution=ag;this.html_elt=$("<div class='track-tile'/>").append(af);this.data=ai;this.stale=false};b.prototype.predisplay_actions=function(){};var k=function(ae,ah,ag,af,ai,aj){b.call(this,ae,ah,ag,af,ai);this.max_val=aj};p(k.prototype,b.prototype);var O=function(ah,am,ai,ag,ak,ar,al,at,af,ap){b.call(this,ah,am,ai,ag,ak);this.mode=al;this.feature_mapper=ap;this.has_icons=false;if(at||!af){this.has_icons=true;var an=this;ag=this.html_elt.children()[0],message_div=$("<div/>").addClass("tile-message").css({height:C-1,width:ag.width}).prependTo(this.html_elt);if(!af){var ao=$("<a href='javascript:void(0);'/>").addClass("icon exclamation").attr("title","To minimize track height, not all features in this region are displayed. Click to display more.").tipsy({gravity:"s"}).appendTo(message_div).click(function(){$(".tipsy").hide();an.track.slotters[ar].max_rows*=2;an.track.request_draw(true)})}if(at){var aq=ak.length,aj=$("<a href='javascript:void(0);'/>").addClass("icon more-down").attr("title","For speed, only the first "+aq+" features in this region were obtained from server. Click to get more data including depth").tipsy({gravity:"s"}).appendTo(message_div),ae=$("<a href='javascript:void(0);'/>").addClass("icon more-across").attr("title","For speed, only the first "+aq+" features in this region were obtained from server. Click to get more data excluding depth").tipsy({gravity:"s"}).appendTo(message_div);aj.click(function(){an.stale=true;ah.data_manager.get_more_data(an.low,an.high,ah.mode,an.resolution,{},ah.data_manager.DEEP_DATA_REQ);$(".tipsy").hide();ah.request_draw()}).dblclick(function(au){au.stopPropagation()});ae.click(function(){an.stale=true;ah.data_manager.get_more_data(an.low,an.high,ah.mode,an.resolution,{},ah.data_manager.BROAD_DATA_REQ);$(".tipsy").hide();ah.request_draw()}).dblclick(function(au){au.stopPropagation()})}}};p(O.prototype,b.prototype);O.prototype.predisplay_actions=function(){var af=this,ae={};if(af.mode!=="Pack"){return}$(this.html_elt).hover(function(){this.hovered=true;$(this).mousemove()},function(){this.hovered=false;$(this).siblings(".feature-popup").remove()}).mousemove(function(aq){if(!this.hovered){return}var al=$(this).offset(),ap=aq.pageX-al.left,ao=aq.pageY-al.top,av=af.feature_mapper.get_feature_data(ap,ao),am=(av?av[0]:null);$(this).siblings(".feature-popup").each(function(){if(!am||$(this).attr("id")!==am.toString()){$(this).remove()}});if(av){var ah=ae[am];if(!ah){var am=av[0],ar={name:av[3],start:av[1],end:av[2],strand:av[4]},ak=af.track.filters_manager.filters,aj;for(var an=0;an<ak.length;an++){aj=ak[an];ar[aj.name]=av[aj.index]}var ah=$("<div/>").attr("id",am).addClass("feature-popup"),aw=$("<table/>"),au,at,ax;for(au in ar){at=ar[au];ax=$("<tr/>").appendTo(aw);$("<th/>").appendTo(ax).text(au);$("<td/>").attr("align","left").appendTo(ax).text(typeof(at)==="number"?Y(at,2):at)}ah.append($("<div class='feature-popup-inner'>").append(aw));ae[am]=ah}ah.appendTo($(af.html_elt).parent());var ai=ap+parseInt(af.html_elt.css("left"))-ah.width()/2,ag=ao+parseInt(af.html_elt.css("top"))+7;ah.css("left",ai+"px").css("top",ag+"px")}else{if(!aq.isPropagationStopped()){aq.stopPropagation();$(this).siblings().each(function(){$(this).trigger(aq)})}}}).mouseleave(function(){$(this).siblings(".feature-popup").remove()})};var i=function(ah,af,ae,ag,aj,ai,ak){q.call(this,ah,af,ae,{},"draghandle");this.data_url=(ai?ai:default_data_url);this.data_url_extra_params={};this.data_query_wait=(ak?ak:K);this.dataset_check_url=converted_datasets_state_url;this.data_manager=(aj?aj:new S(H,this));this.content_div=$("<div class='track-content'>").appendTo(this.container_div);if(this.container){this.container.content_div.append(this.container_div)}};p(i.prototype,q.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},q.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"overview-icon",on_click_fn:function(ae){ae.view.set_overview(ae)}},q.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(ae){if(ae.filters_div.is(":visible")){ae.filters_manager.clear_filters()}else{ae.filters_manager.init_filters()}ae.filters_div.toggle()}},{name:"tools_icon",title:"Tools",css_class:"tools-icon",on_click_fn:function(ae){ae.dynamic_tool_div.toggle();if(ae.dynamic_tool_div.is(":visible")){ae.set_name(ae.name+ae.tool_region_and_parameters_str())}else{ae.revert_name()}$(".tipsy").remove()}},q.prototype.action_icons_def[2]],can_draw:function(){if(this.dataset_id&&q.prototype.can_draw.call(this)){return true}return false},build_container_div:function(){return $("<div/>").addClass("track").attr("id","track_"+this.id).css("position","relative")},build_header_div:function(){var ae=$("<div class='track-header'/>");if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(ae)}this.name_div=$("<div/>").addClass("track-name").appendTo(ae).text(this.name).attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase());return ae},set_display_modes:function(ah,ak){this.display_modes=ah;this.mode=(ak?ak:(this.config&&this.config.values.mode?this.config.values.mode:this.display_modes[0]));this.action_icons.mode_icon.attr("title","Set display mode (now: "+this.mode+")");var af=this,ai={};for(var ag=0,ae=af.display_modes.length;ag<ae;ag++){var aj=af.display_modes[ag];ai[aj]=function(al){return function(){af.change_mode(al);af.icons_div.show();af.container_div.mouseleave(function(){af.icons_div.hide()})}}(aj)}make_popupmenu(this.action_icons.mode_icon,ai)},build_action_icons:function(){q.prototype.build_action_icons.call(this,this.action_icons_def);if(this.display_modes!==undefined){this.set_display_modes(this.display_modes)}},hide_contents:function(){this.content_div.children().remove();this.content_div.hide();this.container_div.find(".yaxislabel, .track-resize").hide()},show_contents:function(){this.content_div.show();this.container_div.find(".yaxislabel, .track-resize").show();this.request_draw()},get_type:function(){if(this instanceof aa){return"LabelTrack"}else{if(this instanceof z){return"ReferenceTrack"}else{if(this instanceof j){return"LineTrack"}else{if(this instanceof V){return"ReadTrack"}else{if(this instanceof T){return"VcfTrack"}else{if(this instanceof h){return"CompositeTrack"}else{if(this instanceof d){return"FeatureTrack"}}}}}}}return""},init:function(){var af=this;af.enabled=false;af.tile_cache.clear();af.data_manager.clear();af.content_div.css("height","auto");af.content_div.children().remove();af.container_div.removeClass("nodata error pending");if(!af.dataset_id){return}var ae=$.Deferred();$.getJSON(converted_datasets_state_url,{hda_ldda:af.hda_ldda,dataset_id:af.dataset_id,chrom:af.view.chrom},function(ag){if(!ag||ag==="error"||ag.kind==="error"){af.container_div.addClass("error");af.content_div.text(o);if(ag.message){var ah=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+ag.message+"</pre>",{Close:hide_modal})});af.content_div.append(ah)}}else{if(ag==="no converter"){af.container_div.addClass("error");af.content_div.text(J)}else{if(ag==="no data"||(ag.data!==undefined&&(ag.data===null||ag.data.length===0))){af.container_div.addClass("nodata");af.content_div.text(D)}else{if(ag==="pending"){af.container_div.addClass("pending");af.content_div.text(t);setTimeout(function(){af.init()},af.data_query_wait)}else{if(ag.status==="data"){if(ag.valid_chroms){af.valid_chroms=ag.valid_chroms;af.update_icons()}af.content_div.text(X);if(af.view.chrom){af.content_div.text("");af.content_div.css("height",af.height_px+"px");af.enabled=true;$.when(af.predraw_init()).done(function(){ae.resolve();af.container_div.removeClass("nodata error pending");af.request_draw()})}else{ae.resolve()}}}}}}});this.update_icons();return ae},predraw_init:function(){}});var M=function(aj,ah,ag,ai,af,al,ak){i.call(this,aj,ah,ag,ai,ak);var ae=this,ah=ae.view;m(ae.container_div,ae.drag_handle_class,".group",ae);this.filters_manager=new Z(this,af);this.filters_available=false;this.tool=(al!==undefined&&obj_length(al)>0?new r(this,al):undefined);this.tile_cache=new c(R);if(this.header_div){if(this.filters_manager){this.filters_div=this.filters_manager.parent_div;this.header_div.after(this.filters_div)}if(this.tool){this.dynamic_tool_div=this.tool.parent_div;this.header_div.after(this.dynamic_tool_div)}}};p(M.prototype,q.prototype,i.prototype,{copy:function(ae){var af=new this.constructor(this.name,this.view,ae,this.hda_ldda,this.dataset_id,this.prefs,this.filters,this.tool,this.data_manager);af.change_mode(this.mode);af.enabled=this.enabled;return af},to_dict:function(){return{track_type:this.get_type(),name:this.name,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,prefs:this.prefs,mode:this.mode,}},from_dict:function(ag,af){var ae=new this.constructor(ag.name,view,af,ag.hda_ldda,ag.dataset_id,ag.prefs,ag.filters,ag.tool);if(ag.mode){ae.change_mode(ag.mode)}return ae},change_mode:function(af){var ae=this;ae.mode=af;ae.config.values.mode=af;ae.tile_cache.clear();ae.request_draw();this.action_icons.mode_icon.attr("title","Set display mode (now: "+ae.mode+")");return ae},update_icons:function(){var ae=this;if(ae.filters_available){ae.action_icons.filters_icon.show()}else{ae.action_icons.filters_icon.hide()}if(ae.tool){ae.action_icons.tools_icon.show()}else{ae.action_icons.tools_icon.hide()}},_gen_tile_cache_key:function(af,ag,ae){return af+"_"+ag+"_"+ae},request_draw:function(af,ae){this.view.request_redraw(false,af,ae,this)},_draw:function(ag,aq){if(!this.can_draw()){return}var ao=this.view.low,ak=this.view.high,am=ak-ao,ah=this.view.container.width(),au=ah/am,aj=this.view.resolution,at=this.content_div;if(this.is_overview){ao=this.view.max_low;ak=this.view.max_high;aj=Math.pow(A,Math.ceil(Math.log((view.max_high-view.max_low)/Q)/Math.log(A)));au=ah/(view.max_high-view.max_low)}this.content_div.children().addClass("remove");this.max_height=0;var af=Math.floor(ao/aj/Q);var an=true;var ar=[];var ae=0;var al=function(av){return(av&&"track" in av)};while((af*Q*aj)<ak){var ap=this.draw_helper(ag,ah,af,aj,at,au);if(al(ap)){ar.push(ap)}else{an=false}af+=1;ae++}if(!aq){this.content_div.children(".remove").remove()}var ai=this;if(an){this.content_div.children(".remove").remove();ai.postdraw_actions(ar,ah,au,aq)}},postdraw_actions:function(ah,ai,ak,ae){var ag=this;var aj=false;for(var af=0;af<ah.length;af++){if(ah[af].has_icons){aj=true;break}}if(aj){for(var af=0;af<ah.length;af++){tile=ah[af];if(!tile.has_icons){tile.html_elt.css("padding-top",C)}}}},draw_helper:function(ae,aq,aw,au,aj,ak,ar){var ap=this,az=this._gen_tile_cache_key(aq,ak,aw),ax=aw*Q*au,af=ax+Q*au;if(!ar){ar={}}var ay=(ae?undefined:ap.tile_cache.get(az));if(ay){ap.show_tile(ay,aj,ak);return ay}var an=true;var av=ap.data_manager.get_data(ax,af,ap.mode,au,ap.data_url_extra_params);if(is_deferred(av)){an=false}var al;if(view.reference_track&&ak>view.canvas_manager.char_width_px){al=view.reference_track.data_manager.get_data(ax,af,ap.mode,au,view.reference_track.data_url_extra_params);if(is_deferred(al)){an=false}}if(an){p(av,ar.more_tile_data);var am=ap.mode;if(am==="Auto"){am=ap.get_mode(av);ap.update_auto_mode(am)}var ag=ap.view.canvas_manager.new_canvas(),ah=ap._get_tile_bounds(aw,au),ax=ah[0],af=ah[1],aq=Math.ceil((af-ax)*ak)+ap.left_offset,ao=ap.get_canvas_height(av,am,ak,aq);ag.width=aq;ag.height=ao;var at=ag.getContext("2d");at.translate(this.left_offset,0);var ay=ap.draw_tile(av,at,am,au,aw,ak,al);if(ay!==undefined){ap.tile_cache.set(az,ay);ap.show_tile(ay,aj,ak)}return ay}var ai=$.Deferred();$.when(av,al).then(function(){view.request_redraw(false,false,false,ap);ai.resolve()});return ai},get_canvas_height:function(ae,ag,ah,af){return this.height_px},draw_tile:function(ae,ag,aj,ai,af,ak,ah){console.log("Warning: TiledTrack.draw_tile() not implemented.")},show_tile:function(ag,ai,aj){var af=this,ae=ag.html_elt;ag.predisplay_actions();var ah=(ag.low-(this.is_overview?this.view.max_low:this.view.low))*aj;if(this.left_offset){ah-=this.left_offset}ae.css({position:"absolute",top:0,left:ah,height:""});if(ae.hasClass("remove")){ae.removeClass("remove")}else{ai.append(ae)}af.max_height=Math.max(af.max_height,ae.height());af.content_div.css("height",af.max_height+"px");ai.children().css("height",af.max_height+"px")},_get_tile_bounds:function(ae,af){var ah=ae*Q*af,ai=Q*af,ag=(ah+ai<=this.view.max_high?ah+ai:this.view.max_high);return[ah,ag]},tool_region_and_parameters_str:function(ag,ae,ah){var af=this,ai=(ag!==undefined&&ae!==undefined&&ah!==undefined?ag+":"+ae+"-"+ah:"all");return" - region=["+ai+"], parameters=["+af.tool.get_param_values().join(", ")+"]"},data_and_mode_compatible:function(ae,af){return true},init_for_tool_data:function(){this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url;this.predraw_init=function(){var af=this;var ae=function(){if(af.data_manager.size()===0){setTimeout(ae,300)}else{af.data_url=default_data_url;af.data_query_wait=K;af.dataset_state_url=converted_datasets_state_url;$.getJSON(af.dataset_state_url,{dataset_id:af.dataset_id,hda_ldda:af.hda_ldda},function(ag){})}};ae()}}});var aa=function(af,ae){i.call(this,"label",af,ae,false,{});this.container_div.addClass("label-track")};p(aa.prototype,i.prototype,{build_header_div:function(){},init:function(){this.enabled=true},_draw:function(){var ag=this.view,ah=ag.high-ag.low,ak=Math.floor(Math.pow(10,Math.floor(Math.log(ah)/Math.log(10)))),ae=Math.floor(ag.low/ak)*ak,ai=this.view.container.width(),af=$("<div style='position: relative; height: 1.3em;'></div>");while(ae<ag.high){var aj=(ae-ag.low)/ah*ai;af.append($("<div class='label'>"+commatize(ae)+"</div>").css({position:"absolute",left:aj-1}));ae+=ak}this.content_div.children(":first").remove();this.content_div.append(af)}});var h=function(ah,ag,af,ae){M.call(this,ah,ag,af);this.drawables=[];this.left_offset=0;if(ae){var ak=[],aj;for(var ai=0;ai<ae.length;ai++){aj=ae[ai];ak.push(aj.dataset_id);this.drawables[ai]=aj.copy();if(aj.left_offset>this.left_offset){this.left_offset=aj.left_offset}}this.enabled=true}if(this.drawables.length!==0){this.set_display_modes(this.drawables[0].display_modes,this.drawables[0].mode)}this.update_icons();this.obj_type="CompositeTrack"};p(h.prototype,M.prototype,{action_icons_def:[{name:"composite_icon",title:"Show individual tracks",css_class:"layers-stack",on_click_fn:function(ae){$(".tipsy").remove();ae.show_group()}}].concat(M.prototype.action_icons_def),to_dict:x.prototype.to_dict,add_drawable:x.prototype.add_drawable,from_dict:function(ak,ae){var aj=new this.constructor(ak.name,view,ae,ak.prefs,view.viewport_container,view);var af,ai,ah;for(var ag=0;ag<ak.drawables.length;ag++){af=ak.drawables[ag];ai=af.obj_type;if(!ai){ai=af.track_type}ah=addable_objects[ai].prototype.from_dict(af);aj.add_drawable(ah)}aj.set_display_modes(aj.drawables[0].display_modes,aj.drawables[0].mode);return aj},change_mode:function(ae){M.prototype.change_mode.call(this,ae);for(var af=0;af<this.drawables.length;af++){this.drawables[af].change_mode(ae)}},init:function(){var ag=[];for(var af=0;af<this.drawables.length;af++){ag.push(this.drawables[af].init())}var ae=this;$.when.apply($,ag).then(function(){ae.enabled=true;ae.request_draw()})},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide()},can_draw:q.prototype.can_draw,draw_helper:function(af,au,aA,ax,al,an,av){var at=this,aE=this._gen_tile_cache_key(au,an,aA),aB=aA*Q*ax,ag=aB+Q*ax;if(!av){av={}}var aD=(af?undefined:at.tile_cache.get(aE));if(aD){at.show_tile(aD,al,an);return aD}var am=[],at,aq=true,ay,ao;for(var az=0;az<this.drawables.length;az++){at=this.drawables[az];ay=at.data_manager.get_data(aB,ag,at.mode,ax,at.data_url_extra_params);if(is_deferred(ay)){aq=false}am.push(ay);ao=null;if(view.reference_track&&an>view.canvas_manager.char_width_px){ao=view.reference_track.data_manager.get_data(aB,ag,at.mode,ax,view.reference_track.data_url_extra_params);if(is_deferred(ao)){aq=false}}am.push(ao)}if(aq){p(ay,av.more_tile_data);this.tile_predraw_init();var ai=at.view.canvas_manager.new_canvas(),aj=at._get_tile_bounds(aA,ax),aB=aj[0],ag=aj[1],aC=0,au=Math.ceil((ag-aB)*an)+this.left_offset,ar=0,ah=[];var ae=0;for(var az=0;az<this.drawables.length;az++,aC+=2){at=this.drawables[az];ay=am[aC];var ap=at.mode;if(ap==="Auto"){ap=at.get_mode(ay);at.update_auto_mode(ap)}ah.push(ap);ae=at.get_canvas_height(ay,ap,an,au);if(ae>ar){ar=ae}}ai.width=au;ai.height=(av.height?av.height:ar);aC=0;var aw=ai.getContext("2d");aw.translate(this.left_offset,0);aw.globalAlpha=0.5;aw.globalCompositeOperation="source-over";for(var az=0;az<this.drawables.length;az++,aC+=2){at=this.drawables[az];ay=am[aC];ao=am[aC+1];aD=at.draw_tile(ay,aw,ah[az],ax,aA,an,ao)}this.tile_cache.set(aE,aD);this.show_tile(aD,al,an);return aD}var ak=$.Deferred(),at=this;$.when.apply($,am).then(function(){view.request_redraw(false,false,false,at);ak.resolve()});return ak},show_group:function(){var ah=new P(this.name,this.view,this.container),ae;for(var ag=0;ag<this.drawables.length;ag++){ae=this.drawables[ag];ah.add_drawable(ae);ae.container=ah;ah.content_div.append(ae.container_div)}var af=this.container.replace_drawable(this,ah,true);ah.request_draw()},tile_predraw_init:function(){var ah=Number.MAX_VALUE,ae=-ah,af;for(var ag=0;ag<this.drawables.length;ag++){af=this.drawables[ag];if(af instanceof j){if(af.prefs.min_value<ah){ah=af.prefs.min_value}if(af.prefs.max_value>ae){ae=af.prefs.max_value}}}for(var ag=0;ag<this.drawables.length;ag++){af=this.drawables[ag];af.prefs.min_value=ah;af.prefs.max_value=ae}},postdraw_actions:function(ag,aj,al,af){M.prototype.postdraw_actions.call(this,ag,aj,al,af);var ai=-1;for(var ah=0;ah<ag.length;ah++){var ae=ag[ah].html_elt.find("canvas").height();if(ae>ai){ai=ae}}for(var ah=0;ah<ag.length;ah++){var ak=ag[ah];if(ak.html_elt.find("canvas").height()!==ai){this.draw_helper(true,aj,ak.index,ak.resolution,ak.html_elt.parent(),al,{height:ai});ak.html_elt.remove()}}}});var z=function(ae){M.call(this,"reference",ae,{content_div:ae.top_labeltrack},{});ae.reference_track=this;this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_url=reference_url;this.data_url_extra_params={dbkey:ae.dbkey};this.data_manager=new G(H,this,false)};p(z.prototype,q.prototype,M.prototype,{build_header_div:function(){},init:function(){this.data_manager.clear();this.enabled=true},can_draw:q.prototype.can_draw,draw_tile:function(am,an,aj,ai,af,ao){var ah=this;if(ao>this.view.canvas_manager.char_width_px){if(am.data===null){ah.content_div.css("height","0px");return}var ag=an.canvas;an.font=an.canvas.manager.default_font;an.textAlign="center";am=am.data;for(var ak=0,al=am.length;ak<al;ak++){var ae=Math.round(ak*ao);an.fillText(am[ak],ae,10)}return new b(ah,af,ai,ag,am)}this.content_div.css("height","0px")}});var j=function(ae,al,af,ak,an,am,ai,aj,ag){var ah=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";M.call(this,ae,al,af,am,ai,aj,ag);this.min_height_px=16;this.max_height_px=400;this.height_px=32;this.hda_ldda=ak;this.dataset_id=an;this.original_dataset_id=an;this.left_offset=0;this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"color",label:"Color",type:"color",default_value:get_random_color()},{key:"min_value",label:"Min Value",type:"float",default_value:undefined},{key:"max_value",label:"Max Value",type:"float",default_value:undefined},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:this.height_px,hidden:true}],saved_values:am,onchange:function(){ah.set_name(ah.prefs.name);ah.vertical_range=ah.prefs.max_value-ah.prefs.min_value;ah.set_min_value(ah.prefs.min_value);ah.set_max_value(ah.prefs.max_value)}});this.prefs=this.config.values;this.height_px=this.config.values.height;this.vertical_range=this.config.values.max_value-this.config.values.min_value;this.add_resize_handle()};p(j.prototype,q.prototype,M.prototype,{set_min_value:function(ae){this.prefs.min_value=ae;$("#linetrack_"+this.dataset_id+"_minval").text(this.prefs.min_value);this.tile_cache.clear();this.request_draw()},set_max_value:function(ae){this.prefs.max_value=ae;$("#linetrack_"+this.dataset_id+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.request_draw()},add_resize_handle:function(){var ae=this;var ah=false;var ag=false;var af=$("<div class='track-resize'>");$(ae.container_div).hover(function(){if(ae.content_visible){ah=true;af.show()}},function(){ah=false;if(!ag){af.hide()}});af.hide().bind("dragstart",function(ai,aj){ag=true;aj.original_height=$(ae.content_div).height()}).bind("drag",function(aj,ak){var ai=Math.min(Math.max(ak.original_height+ak.deltaY,ae.min_height_px),ae.max_height_px);$(ae.content_div).css("height",ai);ae.height_px=ai;ae.request_draw(true)}).bind("dragend",function(ai,aj){ae.tile_cache.clear();ag=false;if(!ah){af.hide()}ae.config.values.height=ae.height_px}).appendTo(ae.container_div)},predraw_init:function(){var ae=this;ae.vertical_range=undefined;return $.getJSON(ae.data_url,{stats:true,chrom:ae.view.chrom,low:null,high:null,hda_ldda:ae.hda_ldda,dataset_id:ae.dataset_id},function(af){ae.container_div.addClass("line-track");var ai=af.data;if(isNaN(parseFloat(ae.prefs.min_value))||isNaN(parseFloat(ae.prefs.max_value))){var ag=ai.min;var ak=ai.max;ag=Math.floor(Math.min(0,Math.max(ag,ai.mean-2*ai.sd)));ak=Math.ceil(Math.max(0,Math.min(ak,ai.mean+2*ai.sd)));ae.prefs.min_value=ag;ae.prefs.max_value=ak;$("#track_"+ae.dataset_id+"_minval").val(ae.prefs.min_value);$("#track_"+ae.dataset_id+"_maxval").val(ae.prefs.max_value)}ae.vertical_range=ae.prefs.max_value-ae.prefs.min_value;ae.total_frequency=ai.total_frequency;ae.container_div.find(".yaxislabel").remove();var aj=get_editable_text_elt(Y(ae.prefs.min_value,3),false,6,null,function(al){var al=parseFloat(al);if(!isNaN(al)){ae.set_min_value(al)}}).addClass("yaxislabel bottom").attr("id","linetrack_"+ae.dataset_id+"_minval").prependTo(ae.container_div),ah=get_editable_text_elt(Y(ae.prefs.max_value,3),false,6,null,function(al){var al=parseFloat(al);if(!isNaN(al)){ae.set_max_value(al)}}).addClass("yaxislabel top").attr("id","linetrack_"+ae.dataset_id+"_maxval").prependTo(ae.container_div)})},draw_tile:function(ao,am,aj,ah,af,an){var ag=am.canvas,ae=this._get_tile_bounds(af,ah),ai=ae[0],al=ae[1],ak=new L.LinePainter(ao.data,ai,al,this.prefs,aj);ak.draw(am,ag.width,ag.height,an);return new b(this.track,af,ah,ag,ao.data)}});var d=function(ae,al,af,ak,an,am,ai,aj,ag){var ah=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];M.call(this,ae,al,af,am,ai,aj,ag);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"block_color",label:"Block color",type:"color",default_value:get_random_color()},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true,help:"Show the number of items in each bin when drawing summary histogram"},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"connector_style",label:"Connector style",type:"select",default_value:"fishbones",options:[{label:"Line with arrows",value:"fishbone"},{label:"Arcs",value:"arcs"}]},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:am,onchange:function(){ah.set_name(ah.prefs.name);ah.tile_cache.clear();ah.set_painter_from_config();ah.request_draw()}});this.prefs=this.config.values;this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=ak;this.dataset_id=an;this.original_dataset_id=an;this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.slotters={};this.start_end_dct={};this.left_offset=200;this.set_painter_from_config()};p(d.prototype,q.prototype,M.prototype,{set_painter_from_config:function(){if(this.config.values.connector_style==="arcs"){this.painter=L.ArcLinkedFeaturePainter}else{this.painter=L.LinkedFeaturePainter}},postdraw_actions:function(at,ag,av,ar){M.prototype.postdraw_actions.call(this,at,ar);var ai=this;if(ai.mode==="Histogram"){var am=-1;for(var aj=0;aj<at.length;aj++){var aq=at[aj].max_val;if(aq>am){am=aq}}for(var aj=0;aj<at.length;aj++){var ao=at[aj];if(ao.max_val!==am){ao.html_elt.remove();ai.draw_helper(true,ag,ao.index,ao.resolution,ao.html_elt.parent(),av,{more_tile_data:{max:am}})}}}if(ai.filters_manager){var ah=ai.filters_manager.filters;for(var al=0;al<ah.length;al++){ah[al].update_ui_elt()}var ak=false,an,af;for(var aj=0;aj<at.length;aj++){if(at[aj].data.length){an=at[aj].data[0];for(var al=0;al<ah.length;al++){af=ah[al];if(af.applies_to(an)&&af.min!==af.max){ak=true;break}}}}if(ai.filters_available!==ak){ai.filters_available=ak;if(!ai.filters_available){ai.filters_div.hide()}ai.update_icons()}}this.container_div.find(".yaxislabel").remove();var ae=at[0];if(ae instanceof k){var au=(this.prefs.histogram_max?this.prefs.histogram_max:ae.max_val),ap=get_editable_text_elt(au,false,12,0,function(aw){var aw=parseFloat(aw);ai.prefs.histogram_max=(!isNaN(aw)?aw:null);ai.tile_cache.clear();ai.request_draw()}).addClass("yaxislabel top").css("color",this.prefs.label_color);this.container_div.prepend(ap)}},update_auto_mode:function(ae){var ae;if(this.mode==="Auto"){if(ae==="no_detail"){ae="feature spans"}else{if(ae==="summary_tree"){ae="coverage histogram"}}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+ae+")")}},incremental_slots:function(ai,ae,ah){var af=this.view.canvas_manager.dummy_context,ag=this.slotters[ai];if(!ag||(ag.mode!==ah)){ag=new (s.FeatureSlotter)(ai,ah,y,function(aj){return af.measureText(aj)});this.slotters[ai]=ag}return ag.slot_features(ae)},get_summary_tree_data:function(ai,al,ag,au){if(au>ag-al){au=ag-al}var ap=Math.floor((ag-al)/au),at=[],ah=0;var aj=0,ak=0,ao,ar=0,am=[],aq,an;var af=function(ax,aw,ay,av){ax[0]=aw+ay*av;ax[1]=aw+(ay+1)*av};while(ar<au&&aj!==ai.length){var ae=false;for(;ar<au&&!ae;ar++){af(am,al,ar,ap);for(ak=aj;ak<ai.length;ak++){ao=ai[ak].slice(1,3);if(is_overlap(ao,am)){ae=true;break}}if(ae){break}}data_start_index=ak;at[at.length]=aq=[am[0],0];for(;ak<ai.length;ak++){ao=ai[ak].slice(1,3);if(is_overlap(ao,am)){aq[1]++}else{break}}if(aq[1]>ah){ah=aq[1]}ar++}return{max:ah,delta:ap,data:at}},get_mode:function(ae){if(ae.dataset_type==="summary_tree"){mode="summary_tree"}else{if(ae.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>I){mode="Squish"}else{mode="Pack"}}}return mode},get_canvas_height:function(ae,ai,aj,af){if(ai==="summary_tree"||ai==="Histogram"){return this.summary_draw_height}else{var ah=this.incremental_slots(aj,ae.data,ai);var ag=new (this.painter)(null,null,null,this.prefs,ai);return Math.max(ac,ag.get_required_height(ah,af))}},draw_tile:function(ap,au,ar,av,az,al,ag){var at=this,af=au.canvas,ai=this._get_tile_bounds(az,av),aC=ai[0],ae=ai[1],aH=25,ah=this.left_offset;if(ar==="summary_tree"||ar==="Histogram"){if(ap.dataset_type!=="summary_tree"){var am=this.get_summary_tree_data(ap.data,aC,ae,200);if(ap.max){am.max=ap.max}ap=am}var aE=new L.SummaryTreePainter(ap,aC,ae,this.prefs);aE.draw(au,af.width,af.height,al);return new k(at,az,av,af,ap.data,ap.max)}var ak=[],aq=this.slotters[al].slots;all_slotted=true;if(ap.data){var an=this.filters_manager.filters;for(var aw=0,ay=ap.data.length;aw<ay;aw++){var aj=ap.data[aw];var ax=false;var ao;for(var aB=0,aG=an.length;aB<aG;aB++){ao=an[aB];ao.update_attrs(aj);if(!ao.keep(aj)){ax=true;break}}if(!ax){ak.push(aj);if(!(aj[0] in aq)){all_slotted=false}}}}var aF=(this.filters_manager.alpha_filter?new B(this.filters_manager.alpha_filter):null);var aD=(this.filters_manager.height_filter?new B(this.filters_manager.height_filter):null);var aE=new (this.painter)(ak,aC,ae,this.prefs,ar,aF,aD,ag);var aA=null;au.fillStyle=this.prefs.block_color;au.font=au.canvas.manager.default_font;au.textAlign="right";if(ap.data){aA=aE.draw(au,af.width,af.height,al,aq);aA.translation=-ah}return new O(at,az,av,af,ap.data,al,ar,ap.message,all_slotted,aA)},data_and_mode_compatible:function(ae,af){if(af==="Auto"){return true}else{if(ae.extra_info==="no_detail"||ae.dataset_type==="summary_tree"){return false}else{return true}}},});var T=function(ae,ak,af,aj,am,al,ah,ai,ag){d.call(this,ae,ak,af,aj,am,al,ah,ai,ag);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"block_color",label:"Block color",type:"color",default_value:get_random_color()},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:al,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.config.values;this.painter=L.ReadPainter};p(T.prototype,q.prototype,M.prototype,d.prototype);var V=function(ae,ak,af,aj,an,am,ah,ag){d.call(this,ae,ak,af,aj,an,am,ah,ag);var ai=get_random_color(),al=get_random_color([ai,"#ffffff"]);this.config=new E({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"block_color",label:"Block and sense strand color",type:"color",default_value:ai},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:al},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"histogram_max",label:"Histogram maximum",type:"float",default_value:null,help:"Clear value to set automatically"},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:am,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.config.values;this.painter=L.ReadPainter;this.update_icons()};p(V.prototype,q.prototype,M.prototype,d.prototype);W.View=ab;W.DrawableGroup=P;W.LineTrack=j;W.FeatureTrack=d;W.ReadTrack=V;W.VcfTrack=T;W.CompositeTrack=h};var slotting_module=function(c,b){var e=c("class").extend;var d=2,a=5;b.FeatureSlotter=function(i,h,f,g){this.slots={};this.start_end_dct={};this.w_scale=i;this.mode=h;this.include_label=(h==="Pack");this.max_rows=f;this.measureText=g};e(b.FeatureSlotter.prototype,{slot_features:function(m){var p=this.w_scale,h=this.start_end_dct,x=[],z=[],n=0,y=this.max_rows;for(var v=0,w=m.length;v<w;v++){var k=m[v],o=k[0];if(this.slots[o]!==undefined){n=Math.max(n,this.slots[o]);z.push(this.slots[o])}else{x.push(v)}}var q=function(E,F){for(var D=0;D<=y;D++){var B=false,G=h[D];if(G!==undefined){for(var A=0,C=G.length;A<C;A++){var i=G[A];if(F>i[0]&&E<i[1]){B=true;break}}}if(!B){return D}}return -1};for(var v=0,w=x.length;v<w;v++){var k=m[x[v]],o=k[0],t=k[1],f=k[2],r=k[3],g=Math.floor(t*p),l=Math.ceil(f*p),u=this.measureText(r).width,j;if(r!==undefined&&this.include_label){u+=(d+a);if(g-u>=0){g-=u;j="left"}else{l+=u;j="right"}}var s=q(g,l);if(s>=0){if(h[s]===undefined){h[s]=[]}h[s].push([g,l]);this.slots[o]=s;n=Math.max(n,s)}else{}}return n+1}})};var painters_module=function(i,x){var u=i("class").extend;var p=function(I,A,G,z,F,D){if(D===undefined){D=4}var C=z-A;var B=F-G;var E=Math.floor(Math.sqrt(C*C+B*B)/D);var J=C/E;var H=B/E;var y;for(y=0;y<E;y++,A+=J,G+=H){if(y%2!==0){continue}I.fillRect(A,G,D,1)}};var q=function(B,A,z,E){var D=A-E/2,C=A+E/2,F=z-Math.sqrt(E*3/2);B.beginPath();B.moveTo(D,F);B.lineTo(C,F);B.lineTo(A,z);B.lineTo(D,F);B.strokeStyle=this.fillStyle;B.fill();B.stroke();B.closePath()};var d=function(y){this.default_val=(y?y:1)};d.prototype.gen_val=function(y){return this.default_val};var l=function(A,C,y,z,B){this.data=A;this.view_start=C;this.view_end=y;this.prefs=u({},this.default_prefs,z);this.mode=B};l.prototype.default_prefs={};l.prototype.draw=function(z,A,y,B){};var v=function(A,C,y,z,B){l.call(this,A,C,y,z,B)};v.prototype.default_prefs={show_counts:false};v.prototype.draw=function(L,z,K,M){var E=this.view_start,N=this.view_end-this.view_start,I=this.data.data,G=(this.prefs.histogram_max?this.prefs.histogram_max:this.data.max),B=K;delta_x_px=Math.ceil(this.data.delta*M);L.save();for(var C=0,D=I.length;C<D;C++){var H=Math.floor((I[C][0]-E)*M);var F=I[C][1];if(!F){continue}var J=F/G*K;if(F!==0&&J<1){J=1}L.fillStyle=this.prefs.block_color;L.fillRect(H,B-J,delta_x_px,J);var A=4;if(this.prefs.show_counts&&(L.measureText(F).width+A)<delta_x_px){L.fillStyle=this.prefs.label_color;L.textAlign="center";L.fillText(F,H+(delta_x_px/2),10)}}L.restore()};var b=function(y,C,E,F,A){l.call(this,y,C,E,F,A);if(this.prefs.min_value===undefined){var G=Infinity;for(var z=0,B=this.data.length;z<B;z++){G=Math.min(G,this.data[z][1])}this.prefs.min_value=G}if(this.prefs.max_value===undefined){var D=-Infinity;for(var z=0,B=this.data.length;z<B;z++){D=Math.max(D,this.data[z][1])}this.prefs.max_value=D}};b.prototype.default_prefs={min_value:undefined,max_value:undefined,mode:"Histogram",color:"#000",overflow_color:"#F66"};b.prototype.draw=function(S,Q,N,D){var I=false,K=this.prefs.min_value,F=this.prefs.max_value,M=F-K,B=N,C=this.view_start,P=this.view_end-this.view_start,L=this.mode,aa=this.data;S.save();var ac=Math.round(N+K/M*N);if(L!=="Intensity"){S.fillStyle="#aaa";S.fillRect(0,ac,Q,1)}S.beginPath();var Y,G,E;if(aa.length>1){E=Math.ceil((aa[1][0]-aa[0][0])*D)}else{E=10}var A=parseInt(this.prefs.color.slice(1),16),H=(A&16711680)>>16,R=(A&65280)>>8,V=A&255;for(var T=0,U=aa.length;T<U;T++){S.fillStyle=S.strokeStyle=this.prefs.color;Y=Math.round((aa[T][0]-C)*D);G=aa[T][1];var W=false,J=false;if(G===null){if(I&&L==="Filled"){S.lineTo(Y,B)}I=false;continue}if(G<K){J=true;G=K}else{if(G>F){W=true;G=F}}if(L==="Histogram"){G=Math.round(G/M*B);S.fillRect(Y,ac,E,-G)}else{if(L==="Intensity"){var z=(G-K)/M,O=Math.round(H+(255-H)*(1-z)),X=Math.round(R+(255-R)*(1-z)),ab=Math.round(V+(255-V)*(1-z));S.fillStyle="rgb("+O+","+X+","+ab+")";S.fillRect(Y,0,E,B)}else{G=Math.round(B-(G-K)/M*B);if(I){S.lineTo(Y,G)}else{I=true;if(L==="Filled"){S.moveTo(Y,B);S.lineTo(Y,G)}else{S.moveTo(Y,G)}}}}S.fillStyle=this.prefs.overflow_color;if(W||J){var Z;if(L==="Histogram"||L==="Intensity"){Z=E}else{Y-=2;Z=4}if(W){S.fillRect(Y,0,Z,3)}if(J){S.fillRect(Y,B-3,Z,3)}}S.fillStyle=this.prefs.color}if(L==="Filled"){if(I){S.lineTo(Y,ac);S.lineTo(0,ac)}S.fill()}else{S.stroke()}S.restore()};var m=function(y){this.feature_positions={};this.slot_height=y;this.translation=0;this.y_translation=0};m.prototype.map_feature_data=function(z,B,y,A){if(!this.feature_positions[B]){this.feature_positions[B]=[]}this.feature_positions[B].push({data:z,x_start:y,x_end:A})};m.prototype.get_feature_data=function(z,D){var C=Math.floor((D-this.y_translation)/this.slot_height),B;if(!this.feature_positions[C]){return null}z+=this.translation;for(var A=0;A<this.feature_positions[C].length;A++){B=this.feature_positions[C][A];if(z>=B.x_start&&z<=B.x_end){return B.data}}};var o=function(A,D,y,z,C,E,B){l.call(this,A,D,y,z,C);this.alpha_scaler=(E?E:new d());this.height_scaler=(B?B:new d())};o.prototype.default_prefs={block_color:"#FFF",connector_color:"#FFF"};u(o.prototype,{get_required_height:function(A,z){var y=y_scale=this.get_row_height(),B=this.mode;if(B==="no_detail"||B==="Squish"||B==="Pack"){y=A*y_scale}return y+this.get_top_padding(z)+this.get_bottom_padding(z)},get_top_padding:function(y){return 0},get_bottom_padding:function(y){return Math.max(Math.round(this.get_row_height()/2),5)},draw:function(K,I,G,E,F){var Q=this.data,D=this.view_start,M=this.view_end;K.save();K.fillStyle=this.prefs.block_color;K.textAlign="right";var H=this.view_end-this.view_start,L=this.get_row_height(),P=new m(L),B;for(var N=0,O=Q.length;N<O;N++){var A=Q[N],C=A[0],J=A[1],y=A[2],z=(F&&F[C]!==undefined?F[C]:null);if((J<M&&y>D)&&(this.mode==="Dense"||z!==null)){B=this.draw_element(K,this.mode,A,z,D,M,E,L,I);P.map_feature_data(A,z,B[0],B[1])}}K.restore();P.y_translation=this.get_top_padding(I);return P},draw_element:function(E,A,G,C,B,D,F,z,y){console.log("WARNING: Unimplemented function.");return[0,0]}});var c=10,h=3,k=5,w=10,f=1,s=9,e=3,a=9,j=2,g="#ccc";var r=function(A,D,y,z,C,E,B){o.call(this,A,D,y,z,C,E,B);this.draw_background_connector=true;this.draw_individual_connectors=false};u(r.prototype,o.prototype,{get_row_height:function(){var z=this.mode,y;if(z==="Dense"){y=c}else{if(z==="no_detail"){y=h}else{if(z==="Squish"){y=k}else{y=w}}}return y},draw_element:function(M,D,X,H,O,aj,an,ap,y){var T=X[0],al=X[1],ad=X[2]-1,Q=X[3],ae=Math.floor(Math.max(0,(al-O)*an)),N=Math.ceil(Math.min(y,Math.max(0,(ad-O)*an))),ac=ae,ao=N,aa=(D==="Dense"?0:(0+H))*ap+this.get_top_padding(y),L,ah,R=null,ar=null,B=this.prefs.block_color,ag=this.prefs.label_color;M.globalAlpha=this.alpha_scaler.gen_val(X);if(D==="Dense"){H=1}if(D==="no_detail"){M.fillStyle=B;M.fillRect(ae,aa+5,N-ae,f)}else{var K=X[4],Z=X[5],af=X[6],C=X[7],V=true;if(Z&&af){R=Math.floor(Math.max(0,(Z-O)*an));ar=Math.ceil(Math.min(y,Math.max(0,(af-O)*an)))}var am,U;if(D==="Squish"){am=1;U=e;V=false}else{if(D==="Dense"){am=5;U=s}else{am=5;U=a}}if(!C){M.fillStyle=B;M.fillRect(ae,aa+1,N-ae,U);if(K&&V){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand_inv")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand_inv")}}M.fillRect(ae,aa+1,N-ae,U)}}else{var J,W;if(D==="Squish"||D==="Dense"){J=aa+Math.floor(e/2)+1;W=1}else{if(K){J=aa;W=U}else{J+=(e/2)+1;W=1}}if(this.draw_background_connector){if(D==="Squish"||D==="Dense"){M.fillStyle=g}else{if(K){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand")}}}else{M.fillStyle=g}}M.fillRect(ae,J,N-ae,W)}var E;for(var ak=0,A=C.length;ak<A;ak++){var F=C[ak],z=Math.floor(Math.max(0,(F[0]-O)*an)),Y=Math.ceil(Math.min(y,Math.max((F[1]-1-O)*an))),S,ab;if(z>Y){continue}M.fillStyle=B;M.fillRect(z,aa+(U-am)/2+1,Y-z,am);if(R!==undefined&&af>Z&&!(z>ar||Y<R)){var ai=Math.max(z,R),I=Math.min(Y,ar);M.fillRect(ai,aa+1,I-ai,U);if(C.length===1&&D==="Pack"){if(K==="+"){M.fillStyle=M.canvas.manager.get_pattern("right_strand_inv")}else{if(K==="-"){M.fillStyle=M.canvas.manager.get_pattern("left_strand_inv")}}if(ai+14<I){ai+=2;I-=2}M.fillRect(ai,aa+1,I-ai,U)}}if(this.draw_individual_connectors&&S){this.draw_connector(M,S,ab,z,Y,aa)}S=z;ab=Y}if(D==="Pack"){M.globalAlpha=1;M.fillStyle="white";var G=this.height_scaler.gen_val(X),P=Math.ceil(U*G),aq=Math.round((U-P)/2);if(G!==1){M.fillRect(ae,J+1,N-ae,aq);M.fillRect(ae,J+U-aq+1,N-ae,aq)}}}M.globalAlpha=1;if(D==="Pack"&&al>O){M.fillStyle=ag;if(O===0&&ae-M.measureText(Q).width<0){M.textAlign="left";M.fillText(Q,N+j,aa+8);ao+=M.measureText(Q).width+j}else{M.textAlign="right";M.fillText(Q,ae-j,aa+8);ac-=M.measureText(Q).width+j}}}M.globalAlpha=1;return[ac,ao]}});var t=function(B,E,y,A,D,F,C,z){o.call(this,B,E,y,A,D,F,C);this.ref_seq=(z?z.data:null)};u(t.prototype,o.prototype,{get_row_height:function(){var y,z=this.mode;if(z==="Dense"){y=c}else{if(z==="Squish"){y=k}else{y=w;if(this.prefs.show_insertions){y*=2}}}return y},draw_read:function(K,A,ag,V,L,aa,ad,C,B,M){K.textAlign="center";var J=this,R=[L,aa],Z=0,W=0,D=0,F=K.canvas.manager.char_width_px,y=(B==="+"?this.prefs.block_color:this.prefs.reverse_strand_color);var O=[];if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){D=Math.round(ag/2)}if(!C){C=[[0,M.length]]}for(var G=0,I=C.length;G<I;G++){var z=C[G],E="MIDNSHP=X"[z[0]],S=z[1];if(E==="H"||E==="S"){Z-=S}var U=ad+Z,Y=Math.floor(Math.max(0,(U-L)*ag)),ab=Math.floor(Math.max(0,(U+S-L)*ag));if(Y===ab){ab+=1}switch(E){case"H":break;case"S":case"M":case"=":if(is_overlap([U,U+S],R)){var N=M.slice(W,W+S);if(D>0){K.fillStyle=y;K.fillRect(Y-D,V+1,ab-Y,9);K.fillStyle=g;for(var af=0,H=N.length;af<H;af++){if(this.prefs.show_differences){if(this.ref_seq){var P=this.ref_seq[U-L+af];if(!P||P.toLowerCase()===N[af].toLowerCase()){continue}}else{continue}}if(U+af>=L&&U+af<=aa){var X=Math.floor(Math.max(0,(U+af-L)*ag));K.fillText(N[af],X,V+9)}}}else{K.fillStyle=y;K.fillRect(Y,V+4,ab-Y,e)}}W+=S;Z+=S;break;case"N":K.fillStyle=g;K.fillRect(Y-D,V+5,ab-Y,1);Z+=S;break;case"D":K.fillStyle="red";K.fillRect(Y-D,V+4,ab-Y,3);Z+=S;break;case"P":break;case"I":var ah=Y-D;if(is_overlap([U,U+S],R)){var N=M.slice(W,W+S);if(this.prefs.show_insertions){var T=Y-(ab-Y)/2;if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){K.fillStyle="yellow";K.fillRect(T-D,V-9,ab-Y,9);O[O.length]={type:"triangle",data:[ah,V+4,5]};K.fillStyle=g;switch(compute_overlap([U,U+S],R)){case (OVERLAP_START):N=N.slice(L-U);break;case (OVERLAP_END):N=N.slice(0,U-aa);break;case (CONTAINED_BY):break;case (CONTAINS):N=N.slice(L-U,U-aa);break}for(var af=0,H=N.length;af<H;af++){var X=Math.floor(Math.max(0,(U+af-L)*ag));K.fillText(N[af],X-(ab-Y)/2,V)}}else{K.fillStyle="yellow";K.fillRect(T,V+(this.mode!=="Dense"?2:5),ab-Y,(A!=="Dense"?e:s))}}else{if((A==="Pack"||this.mode==="Auto")&&M!==undefined&&ag>F){O.push({type:"text",data:[N.length,ah,V+9]})}else{}}}W+=S;break;case"X":W+=S;break}}K.fillStyle="yellow";var Q,ai,ae;for(var ac=0;ac<O.length;ac++){Q=O[ac];ai=Q.type;ae=Q.data;if(ai==="text"){K.save();K.font="bold "+K.font;K.fillText(ae[0],ae[1],ae[2]);K.restore()}else{if(ai==="triangle"){q(K,ae[0],ae[1],ae[2])}}}},draw_element:function(R,M,E,B,U,z,I,S,P){var H=E[0],Q=E[1],A=E[2],J=E[3],D=Math.floor(Math.max(0,(Q-U)*I)),F=Math.ceil(Math.min(P,Math.max(0,(A-U)*I))),C=(M==="Dense"?0:(0+B))*S,G=this.prefs.label_color,O=0;if((M==="Pack"||this.mode==="Auto")&&I>R.canvas.manager.char_width_px){var O=Math.round(I/2)}if(E[5] instanceof Array){var N=Math.floor(Math.max(0,(E[4][0]-U)*I)),L=Math.ceil(Math.min(P,Math.max(0,(E[4][1]-U)*I))),K=Math.floor(Math.max(0,(E[5][0]-U)*I)),y=Math.ceil(Math.min(P,Math.max(0,(E[5][1]-U)*I)));if(E[4][1]>=U&&E[4][0]<=z&&E[4][2]){this.draw_read(R,M,I,C,U,z,E[4][0],E[4][2],E[4][3],E[4][4])}if(E[5][1]>=U&&E[5][0]<=z&&E[5][2]){this.draw_read(R,M,I,C,U,z,E[5][0],E[5][2],E[5][3],E[5][4])}if(K>L){R.fillStyle=g;p(R,L-O,C+5,K-O,C+5)}}else{this.draw_read(R,M,I,C,U,z,Q,E[4],E[5],E[6])}if(M==="Pack"&&Q>U&&J!=="."){R.fillStyle=this.prefs.label_color;var T=1;if(T===0&&D-R.measureText(J).width<0){R.textAlign="left";R.fillText(J,F+j-O,C+8)}else{R.textAlign="right";R.fillText(J,D-j-O,C+8)}}return[0,0]}});var n=function(A,D,y,z,C,E,B){r.call(this,A,D,y,z,C,E,B);this.longest_feature_length=this.calculate_longest_feature_length();this.draw_background_connector=false;this.draw_individual_connectors=true};u(n.prototype,o.prototype,r.prototype,{calculate_longest_feature_length:function(){var z=0;for(var C=0,y=this.data.length;C<y;C++){var B=this.data[C],A=B[1],D=B[2];z=Math.max(z,D-A)}return z},get_top_padding:function(z){var y=this.view_end-this.view_start,A=z/y;return Math.min(128,Math.ceil((this.longest_feature_length/2)*A))},draw_connector:function(G,B,F,H,E,D){var y=(F+H)/2,C=H-y;var A=Math.PI,z=0;if(C>0){G.beginPath();G.arc(y,D,H-y,Math.PI,0);G.stroke()}}});x.Scaler=d;x.SummaryTreePainter=v;x.LinePainter=b;x.LinkedFeaturePainter=r;x.ReadPainter=t;x.ArcLinkedFeaturePainter=n};(function(d){var c={};var b=function(e){return c[e]};var a=function(f,g){var e={};g(b,e);c[f]=e};a("class",class_module);a("slotting",slotting_module);a("painters",painters_module);a("trackster",trackster_module);for(key in c.trackster){d[key]=c.trackster[key]}})(window); \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket