1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/aa0e69109d1b/ changeset: aa0e69109d1b user: james_taylor date: 2011-09-19 13:22:23 summary: Pack trackster script affected #: 1 file (-1 bytes) --- a/static/scripts/packed/trackster.js Mon Sep 19 00:07:24 2011 -0400 +++ b/static/scripts/packed/trackster.js Mon Sep 19 07:22:23 2011 -0400 @@ -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 trackster_module=function(f,W){var p=f("class").extend,r=f("slotting"),K=f("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 m=function(ae,ag,ah){ah=".group";var af={};ae.bind("drag",{handle:"."+ag,relative:true},function(an,ao){var aq=$(this).parent(),al=aq.children(),ak,aj,ap,ai,am;aj=$(this).parents(ah);if(aj.length!==0){ap=aj.position().top;ai=ap+aj.outerHeight();if(ao.offsetY<ap){$(this).insertBefore(aj);return}else{if(ao.offsetY>ai){$(this).insertAfter(aj);return}}}aj=null;for(am=0;am<al.length;am++){ak=$(al.get(am));ap=ak.position().top;ai=ap+ak.outerHeight();if(ak.is(ah)&&this!==ak.get(0)&&ao.offsetY>=ap&&ao.offsetY<=ai){if(ao.offsetY-ap<ai-ao.offsetY){ak.find(".content-div").prepend(this)}else{ak.find(".content-div").append(this)}return}}for(am=0;am<al.length;am++){if(ao.offsetY<$(al.get(am)).position().top){break}}if(am===al.length){if(this!==al.get(am-1)){aq.append(this)}}else{if(this!==al.get(am)){$(this).insertBefore(al.get(am))}}}).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,D=20,R=F+2,z=100,H=12000,P=200,C=5,u=10,J=5000,v=100,n="There was an error in indexing this dataset. ",I="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",E="No data for this chrom/contig.",s="Currently indexing... please wait",x="Tool cannot be rerun: ",a="Loading data...",X="Ready for display",d=10,t=5,B=5;function w(ae){return Math.round(ae*1000)/1000}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 Q=function(af,ae,ag){c.call(this,af);this.track=ae;this.subset=(ag!==undefined?ag:true)};p(Q.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[ao.length]=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,al,ap)})},get_data:function(ae,ai,aj,af,ah){var ag=this.get_data_from_cache(ae,ai,aj);if(ag){return ag}ag=this.load_data(ae,ai,aj,af,ah);this.set_data(ae,ai,aj,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_data_from_cache(am,ah,al);if(!an){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.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,al,new_data_available);$.when(aj).then(function(ao){if(ao.data){ao.data=an.data.concat(ao.data);if(ao.message){ao.message=ao.message.replace(/[0-9]+/,ao.data.length)}}ae.set_data(am,ah,al,ao);new_data_available.resolve(ao)});return new_data_available},get_data_from_cache:function(ae,af,ag){return this.get(this.gen_key(ae,af,ag))},set_data:function(af,ag,ah,ae){return this.set(this.gen_key(af,ag,ah),ae)},gen_key:function(ae,ag,ah){var af=ae+"_"+ag+"_"+ah;return af},split_key:function(ae){return ae.split("_")}});var G=function(af,ae,ag){Q.call(this,af,ae,ag)};p(G.prototype,Q.prototype,c.prototype,{load_data:function(ag,ae,ai,aj,af,ah){if(af>1){return}return Q.prototype.load_data.call(this,ag,ae,ai,aj,af,ah)}});var ab=function(ae,ah,ag,af,ai){this.container=ae;this.chrom=null;this.vis_id=ag;this.dbkey=af;this.title=ah;this.tracks=[];this.label_tracks=[];this.tracks_to_be_redrawn=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(ai);this.canvas_manager=new ad(ae.get(0).ownerDocument);this.reset()};p(ab.prototype,{init:function(ai){var ag=this.container,ae=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ag);this.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").addClass("viewport-container").appendTo(this.content_div);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 href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").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(aj){if(aj.type==="focusout"||(aj.keyCode||aj.which)===13||(aj.keyCode||aj.which)===27){if((aj.keyCode||aj.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").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 id='zoom-out' />").click(function(){ae.zoom_out();ae.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){ae.zoom_in();ae.request_redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},ai);this.chrom_select.bind("change",function(){ae.change_chrom(ae.chrom_select.val())});this.content_div.click(function(aj){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(aj){ae.zoom_in(aj.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(aj,ak){this.current_x=ak.offsetX}).bind("drag",function(aj,al){var am=al.offsetX-this.current_x;this.current_x=al.offsetX;var ak=Math.round(am/ae.viewport_container.width()*(ae.max_high-ae.max_low));ae.move_delta(-ak)});this.overview_close.click(function(){ae.reset_overview()});this.viewport_container.bind("draginit",function(aj,ak){if(aj.clientX>ae.viewport_container.width()-16){return false}}).bind("dragstart",function(aj,ak){ak.original_low=ae.low;ak.current_height=aj.clientY;ak.current_x=ak.offsetX}).bind("drag",function(al,an){var aj=$(this);var ao=an.offsetX-an.current_x;var ak=aj.scrollTop()-(al.clientY-an.current_height);aj.scrollTop(ak);an.current_height=al.clientY;an.current_x=an.offsetX;var am=Math.round(ao/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(am)}).bind("mousewheel",function(al,an,ak,aj){if(ak){var am=Math.round(-ak/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(am)}});this.top_labeltrack.bind("dragstart",function(aj,ak){return $("<div />").css({height:ae.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(an,ao){$(ao.proxy).css({left:Math.min(an.pageX,ao.startX),width:Math.abs(an.pageX-ao.startX)});var ak=Math.min(an.pageX,ao.startX)-ae.container.offset().left,aj=Math.max(an.pageX,ao.startX)-ae.container.offset().left,am=(ae.high-ae.low),al=ae.viewport_container.width();ae.update_location(Math.round(ak/al*am)+ae.low,Math.round(aj/al*am)+ae.low)}).bind("dragend",function(ao,ap){var ak=Math.min(ao.pageX,ap.startX),aj=Math.max(ao.pageX,ap.startX),am=(ae.high-ae.low),al=ae.viewport_container.width(),an=ae.low;ae.low=Math.round(ak/al*am)+an;ae.high=Math.round(aj/al*am)+an;$(ap.proxy).remove();ae.request_redraw()});this.add_label_track(new aa(this,this.top_labeltrack));this.add_label_track(new aa(this,this.nav_labeltrack));$(window).bind("resize",function(){ae.resize_window()});$(document).bind("redraw",function(){ae.redraw()});this.reset();$(window).trigger("resize");this.update_intro_div()},update_intro_div:function(){if(this.num_tracks===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(af,ag){af.num=v;$.extend(af,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var ae=this;$.ajax({url:chrom_url,data:af,dataType:"json",success:function(ai){if(ai.chrom_info.length===0){alert("Invalid chromosome: "+af.chrom);return}if(ai.reference){ae.add_label_track(new A(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);if(ag){ag()}ae.chrom_start_index=ai.start_index},error:function(){alert("Could not load chroms for this dbkey:",ae.dbkey)}})},change_chrom:function(ai,af,ak){if(!ai||ai==="None"){return}var ah=this;if(ai==="previous"){ah.load_chroms({low:this.chrom_start_index-v});return}if(ai==="next"){ah.load_chroms({low:this.chrom_start_index+v});return}var aj=$.grep(ah.chrom_data,function(am,an){return am.chrom===ai})[0];if(aj===undefined){ah.load_chroms({chrom:ai},function(){ah.change_chrom(ai,af,ak)});return}else{if(ai!==ah.chrom){ah.chrom=ai;ah.chrom_select.val(ah.chrom);ah.max_high=aj.len-1;ah.reset();ah.request_redraw(true);for(var al=0,ae=ah.tracks.length;al<ae;al++){var ag=ah.tracks[al];if(ag.init){ag.init()}}}if(af!==undefined&&ak!==undefined){ah.low=Math.max(af,0);ah.high=Math.min(ak,ah.max_high)}ah.reset_overview();ah.request_redraw()}},go_to:function(ai){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].replace(/,/g,""),10);ah=parseInt(aj[1].replace(/,/g,""),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_track:function(ae){ae.view=this;ae.track_id=this.track_id_counter;this.tracks.push(ae);if(ae.init){ae.init()}ae.container_div.attr("id","track_"+ae.track_id);m(ae.container_div,ae.drag_handle_class);this.track_id_counter+=1;this.num_tracks+=1;this.has_changes=true;this.update_intro_div()},add_label_track:function(ae){ae.view=this;this.label_tracks.push(ae)},remove_track:function(af){this.has_changes=true;delete this.tracks[this.tracks.indexOf(af)];this.num_tracks-=1;var ae=this;af.container_div.fadeOut("slow",function(){$(this).remove();ae.update_intro_div()})},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.tracks),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(C,Math.ceil(Math.log((this.high-this.low)/P)/Math.log(C)));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.enabled){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.nav_container.width(this.container.width());this.request_redraw()},set_overview:function(ae){$.when(ae.get_overview_tile()).then(function(af){view.overview_viewport.find(".track-tile").remove();view.overview_close.show();view.overview_viewport.append(af.canvas);view.overview_highlight.show().height(af.canvas.height());view.overview_viewport.height(af.canvas.height()+view.overview_box.outerHeight());view.resize_window();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=ae;ae.set_is_overview(true)});view.has_changes=true},reset_overview:function(){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();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=null}});var q=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 g(af,aq,ai,at,am.min,am.max)}else{if(ao=="select"){this.params[this.params.length]=new M(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("slider").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(q.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 ae={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},ag=this.track,af=ae.tool_id+ag.tool_region_and_parameters_str(ae.chrom,ae.low,ae.high),ah;if(ag instanceof e){ah=new T(af,view,ag.hda_ldda,undefined,{},{},ag);ah.change_mode(ag.mode)}this.track.add_track(ah);ah.content_div.text("Starting job.");this.run(ae,ah,function(ai){ah.dataset_id=ai.dataset_id;ah.content_div.text("Running job.");ah.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(I)}else{if(ai.error){ag.container_div.addClass("error");ag.content_div.text(x+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 M=function(af,ae,ag,ah){this.name=af;this.label=ae;this.html=ag;this.value=ah};var g=function(ag,af,ai,aj,ah,ae){M.call(this,ag,af,ai,aj);this.min=ah;this.max=ae};var h=function(af,ae,ag,ah){this.name=af;this.index=ae;this.tool_id=ag;this.tool_exp_name=ah};var U=function(af,ae,ag,ah){h.call(this,af,ae,ag,ah);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};p(U.prototype,{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=parseFloat(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.container.show()}else{this.container.hide()}var ag=function(aj,ah){var ai=ah-aj;return(ai<=2?0.01:1)};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",ag(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var Z=function(ao,av){this.track=ao;this.filters=[];for(var ap=0;ap<av.length;ap++){var aq=av[ap],aw=aq.name,ae=aq.type,ah=aq.index,au=aq.tool_id,at=aq.tool_exp_name;if(ae==="int"||ae==="float"){this.filters[ap]=new U(aw,ah,au,at)}else{console.log("ERROR: unsupported filter: ",aw,ae)}}var ai=function(ax,ay,az){ax.click(function(){var aA=ay.text();max=parseFloat(az.slider("option","max")),input_size=(max<=1?4:max<=1000000?max.toString().length:6),multi_value=false;if(az.slider("option","values")){input_size=2*input_size+1;multi_value=true}ay.text("");$("<input type='text'/>").attr("size",input_size).attr("maxlength",input_size).attr("value",aA).appendTo(ay).focus().select().click(function(aB){aB.stopPropagation()}).blur(function(){$(this).remove();ay.text(aA)}).keyup(function(aF){if(aF.keyCode===27){$(this).trigger("blur")}else{if(aF.keyCode===13){var aD=az.slider("option","min"),aB=az.slider("option","max"),aE=function(aG){return(isNaN(aG)||aG>aB||aG<aD)},aC=$(this).val();if(!multi_value){aC=parseFloat(aC);if(aE(aC)){alert("Parameter value must be in the range ["+aD+"-"+aB+"]");return $(this)}}else{aC=aC.split("-");aC=[parseFloat(aC[0]),parseFloat(aC[1])];if(aE(aC[0])||aE(aC[1])){alert("Parameter value must be in the range ["+aD+"-"+aB+"]");return $(this)}}az.slider((multi_value?"values":"value"),aC)}}})})};this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(ax){ax.stopPropagation()}).click(function(ax){ax.stopPropagation()}).bind("dblclick",function(ax){ax.stopPropagation()}).bind("keydown",function(ax){ax.stopPropagation()});var ar=$("<div/>").addClass("sliders").appendTo(this.parent_div);var am=this;$.each(this.filters,function(aA,aC){aC.container=$("<div/>").addClass("slider-row").appendTo(ar);var aB=$("<div/>").addClass("elt-label").appendTo(aC.container);var az=$("<span/>").addClass("slider-name").text(aC.name+" ").appendTo(aB);var ay=$("<span/>");var aE=$("<span/>").addClass("slider-value").appendTo(aB).append("[").append(ay).append("]");var ax=$("<div/>").addClass("slider").appendTo(aC.container);aC.control_element=$("<div/>").attr("id",aC.name+"-filter-control").appendTo(ax);var aD=[0,0];aC.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(aG,aH){var aF=aH.values;ay.text(aF[0]+"-"+aF[1]);aC.low=aF[0];aC.high=aF[1];am.track.request_draw(true,true)},change:function(aF,aG){aC.control_element.slider("option","slide").call(aC.control_element,aF,aG)}});aC.slider=aC.control_element;aC.slider_label=ay;ai(aE,ay,aC.control_element);$("<div style='clear: both;'/>").appendTo(aC.container)});if(this.filters.length!==0){var aj=$("<div/>").addClass("param-row").appendTo(ar);var al=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(aj);var ag=this;al.click(function(){ag.run_on_dataset()})}var an=$("<div/>").addClass("display-controls").appendTo(this.parent_div),ak=$("<span/>").addClass("elt-label").text("Transparency:").appendTo(an),af=$("<select/>").attr("name","alpha_dropdown").appendTo(an);this.alpha_filter=null;$("<option/>").attr("value",-1).text("== None ==").appendTo(af);for(var ap=0;ap<this.filters.length;ap++){$("<option/>").attr("value",ap).text(this.filters[ap].name).appendTo(af)}af.change(function(){$(this).children("option:selected").each(function(){var ax=parseInt($(this).val());am.alpha_filter=(ax>=0?am.filters[ax]:null);am.track.request_draw(true,true)})});$("<div style='clear: both;'/>").appendTo(this.parent_div)};p(Z.prototype,{reset_filters:function(){for(var ae=0;ae<this.filters.length;ae++){filter=this.filters[ae];filter.slider.slider("option","values",[filter.min,filter.max])}this.alpha_filter=null},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 N=function(af,ae){K.AlphaGenerator.call(this,ae);this.filter=af};N.prototype.gen_alpha=function(ae){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_alpha}return((parseFloat(ae[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var Y=function(ae){this.track=ae.track;this.params=ae.params;this.values={};if(ae.saved_values){this.restore_values(ae.saved_values)}this.onchange=ae.onchange};p(Y.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 af=this;var ae=$("<div />");$.each(this.params,function(aj,ah){if(!ah.hidden){var ag="param_"+aj;var al=af.values[ah.key];var ao=$("<div class='form-row' />").appendTo(ae);ao.append($("<label />").attr("for",ag).text(ah.label+":"));if(ah.type==="bool"){ao.append($('<input type="checkbox" />').attr("id",ag).attr("name",ag).attr("checked",al))}else{if(ah.type==="text"){ao.append($('<input type="text"/>').attr("id",ag).val(al).click(function(){$(this).select()}))}else{if(ah.type==="color"){var ak=$("<input />").attr("id",ag).attr("name",ag).val(al);var am=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var ai=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(am);var an=$("<div/>").appendTo(ai).farbtastic({width:100,height:100,callback:ak,color:al});$("<div />").append(ak).append(am).appendTo(ao).bind("click",function(ap){am.css({left:$(this).position().left+($(ak).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){am.hide();$(document).unbind("click.color-picker")});ap.stopPropagation()})}else{ao.append($("<input />").attr("id",ag).attr("name",ag).val(al))}}}}});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(ag,af,ae,ah){this.index=ag;this.low=ag*P*af;this.high=(ag+1)*P*af;this.resolution=af;this.canvas=$("<div class='track-tile'/>").append(ae);this.data=ah;this.stale=false};var l=function(ag,af,ae,ah,ai){b.call(this,ag,af,ae,ah);this.max_val=ai};var O=function(ag,af,ae,ai,ah){b.call(this,ag,af,ae,ai);this.message=ah};var o=function(af,ae){this.name=af;this.view=ae;this.parent_element=ae.viewport_container};o.prototype.request_draw=function(){};o.prototype.draw=function(){};var y=function(af,ae){o.call(this,af,ae);this.members=[];this.drag_handle_class="group-handle";this.container_div=$("<div/>").addClass("group").appendTo(this.parent_element);this.container_div.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("group-name").text(this.name).appendTo(this.container_div);this.content_div=$("<div/>").addClass("content-div").appendTo(this.container_div)};p(y.prototype,o.prototype,{request_draw:function(af,ae){},draw:function(){}});var j=function(af,ae,ai,ag,ah){this.name=af;this.view=ae;this.parent_element=ai;this.data_url=(ag?ag:default_data_url);this.data_url_extra_params={};this.data_query_wait=(ah?ah:J);this.dataset_check_url=converted_datasets_state_url;this.drag_handle_class="draghandle";this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};p(j.prototype,{get_type:function(){if(this instanceof aa){return"LabelTrack"}else{if(this instanceof A){return"ReferenceTrack"}else{if(this instanceof k){return"LineTrack"}else{if(this instanceof V){return"ReadTrack"}else{if(this instanceof T){return"ToolDataFeatureTrack"}else{if(this instanceof S){return"VcfTrack"}else{if(this instanceof e){return"FeatureTrack"}}}}}}}return""},init:function(){var ae=this;ae.enabled=false;ae.tile_cache.clear();ae.data_manager.clear();ae.initial_canvas=undefined;ae.content_div.css("height","auto");ae.container_div.removeClass("nodata error pending");if(!ae.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:ae.hda_ldda,dataset_id:ae.dataset_id,chrom:ae.view.chrom},function(af){if(!af||af==="error"||af.kind==="error"){ae.container_div.addClass("error");ae.content_div.text(n);if(af.message){var ah=ae.view.tracks.indexOf(ae);var ag=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+af.message+"</pre>",{Close:hide_modal})});ae.content_div.append(ag)}}else{if(af==="no converter"){ae.container_div.addClass("error");ae.content_div.text(I)}else{if(af==="no data"||(af.data!==undefined&&(af.data===null||af.data.length===0))){ae.container_div.addClass("nodata");ae.content_div.text(E)}else{if(af==="pending"){ae.container_div.addClass("pending");ae.content_div.text(s);setTimeout(function(){ae.init()},ae.data_query_wait)}else{if(af.status==="data"){if(af.valid_chroms){ae.valid_chroms=af.valid_chroms;ae.make_name_popup_menu()}ae.content_div.text(X);if(ae.view.chrom){ae.content_div.text("");ae.content_div.css("height",ae.height_px+"px");ae.enabled=true;$.when(ae.predraw_init()).done(function(){ae.container_div.removeClass("nodata error pending");ae.request_draw()})}}}}}}})},predraw_init: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)}});var L=function(al,aj,am){var af=this,an=af.view;this.filters_manager=(al!==undefined?new Z(this,al):undefined);this.filters_available=false;this.filters_visible=false;this.tool=(aj!==undefined&&obj_length(aj)>0?new q(this,aj):undefined);this.is_overview=false;this.parent_track=am;this.child_tracks=[];if(af.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}af.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();af.container_div.append(af.child_tracks_container);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)}if(af.display_modes!==undefined){if(af.mode_div===undefined){af.mode_div=$("<div class='right-float menubutton popup' />").appendTo(af.header_div);var ag=(af.track_config&&af.track_config.values.mode?af.track_config.values.mode:af.display_modes[0]);af.mode=ag;af.mode_div.text(ag);var ae={};for(var ah=0,ak=af.display_modes.length;ah<ak;ah++){var ai=af.display_modes[ah];ae[ai]=function(ao){return function(){af.change_mode(ao)}}(ai)}make_popupmenu(af.mode_div,ae)}else{af.mode_div.hide()}}this.make_name_popup_menu()};p(L.prototype,j.prototype,{change_mode:function(af){var ae=this;ae.mode_div.text(af);ae.mode=af;ae.track_config.values.mode=af;ae.tile_cache.clear();ae.request_draw()},make_name_popup_menu:function(){var af=this;var ae={};ae[(this.is_overview?"Hide overview":"Set as overview")]=function(){if(af.is_overview){af.view.reset_overview()}else{af.view.set_overview(af)}};ae["Edit configuration"]=function(){var al=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},aj=function(){af.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ak=function(am){if((am.keyCode||am.which)===27){al()}else{if((am.keyCode||am.which)===13){aj()}}};$(window).bind("keypress.check_enter_esc",ak);show_modal("Configure Track",af.track_config.build_form(),{Cancel:al,OK:aj})};if(af.filters_available>0){var ai=(af.filters_div.is(":visible")?"Hide filters":"Show filters");ae[ai]=function(){af.filters_visible=(af.filters_div.is(":visible"));if(af.filters_visible){af.filters_manager.reset_filters()}af.filters_div.toggle();af.make_name_popup_menu()}}if(af.tool){var ai=(af.dynamic_tool_div.is(":visible")?"Hide tool":"Show tool");ae[ai]=function(){if(!af.dynamic_tool_div.is(":visible")){af.set_name(af.name+af.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";af.revert_name()}af.dynamic_tool_div.toggle();af.make_name_popup_menu()}}if(af.valid_chroms){ae["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+af.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}var ag=view;var ah=function(){$("#no-tracks").show()};if(this.parent_track){ag=this.parent_track;ah=function(){}}ae.Remove=function(){ag.remove_track(af);if(ag.num_tracks===0){ah()}};make_popupmenu(af.name_div,ae)},set_is_overview:function(ae){this.is_overview=ae;this.make_name_popup_menu()},get_overview_tile:function(){var ae=this;view=ae.view,resolution=Math.pow(C,Math.ceil(Math.log((view.max_high-view.max_low)/P)/Math.log(C))),view_width=view.container.width(),w_scale=view_width/(view.max_high-view.max_low),overview_tile=$.Deferred();$.when(ae.data_manager.get_data(view.max_low,view.max_high,"Auto",resolution,ae.data_url_extra_params)).then(function(af){var ah=ae._gen_tile_cache_key(view_width,w_scale,0),aj=ae.tile_cache.get(ah);if(!aj){aj=ae.draw_tile(af,"Auto",resolution,0,w_scale);ae.tile_cache.set(ah,aj)}var am=$(aj.canvas.find("canvas")),ai=am.clone(),al=am.get(0).getContext("2d"),ag=ai.get(0).getContext("2d"),ak=al.getImageData(0,0,al.canvas.width,al.canvas.height);ag.putImageData(ak,-ae.left_offset,(aj.data.dataset_type==="summary_tree"?R:0));new_tile=new b(-1,resolution,ai);overview_tile.resolve(new_tile)});return overview_tile},_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,ap){if(!this.dataset_id){return}var ao=this.view.low,ak=this.view.high,am=ak-ao,ah=this.view.container.width(),at=ah/am,aj=this.view.resolution,ar=$("<div style='position: relative;'></div>");if(!ap){this.content_div.children().remove()}this.content_div.append(ar);this.max_height=0;var af=Math.floor(ao/aj/P);var an=true;var aq=[];var ae=0;while((af*P*aj)<ak){tile=this.draw_helper(ag,ah,af,aj,ar,at);if(tile){aq.push(tile)}else{an=false}af+=1;ae++}var ai=this;if(an){ai.postdraw_actions(aq,ah,at,ap)}for(var al=0;al<this.child_tracks.length;al++){this.child_tracks[al].request_draw(ag,ap)}},postdraw_actions:function(ai,aj,ak,ae){var ag=this;var ah=false;for(var af=0;af<ai.length;af++){if(ai[af].message){ah=true;break}}if(ah){for(var af=0;af<ai.length;af++){tile=ai[af];if(!tile.message){tile.canvas.css("padding-top",D)}}}},draw_helper:function(af,ag,ah,ak,aq,av,ar,al){var ai=this,ap=this._gen_tile_cache_key(ag,av,ah),am=ah*P*ak,au=am+P*ak;var an=(af?undefined:ai.tile_cache.get(ap));if(an){ai.show_tile(an,aq,av);return an}var ao=function(aw){return("isResolved" in aw)};var aj=true;var ae=ai.data_manager.get_data(am,au,ai.mode,ak,ai.data_url_extra_params);if(ao(ae)){aj=false}var at;if(view.reference_track&&av>view.canvas_manager.char_width_px){at=view.reference_track.data_manager.get_data(am,au,ai.mode,ak,view.reference_track.data_url_extra_params);if(ao(at)){aj=false}}if(aj){p(ae,al);var an=ai.draw_tile(ae,ai.mode,ak,ah,av,at);ai.tile_cache.set(ap,an);if(an!==undefined){ai.show_tile(an,aq,av)}return an}$.when(ae,at).then(function(){view.request_redraw()});return null},show_tile:function(al,an,ao){var ag=this,af=al.canvas,ak=af;if(al.message){var ap=$("<div/>"),am=$("<div/>").addClass("tile-message").text(al.message).css({height:D-1,width:al.canvas.width}).appendTo(ap),ai=$("<a href='javascript:void(0);'/>").addClass("icon more-down").appendTo(am),ae=$("<a href='javascript:void(0);'/>").addClass("icon more-across").appendTo(am);ap.append(af);ak=ap;ai.click(function(){al.stale=true;ag.data_manager.get_more_data(al.low,al.high,ag.mode,al.resolution,{},ag.data_manager.DEEP_DATA_REQ);ag.request_draw()}).dblclick(function(aq){aq.stopPropagation()});ae.click(function(){al.stale=true;ag.data_manager.get_more_data(al.low,al.high,ag.mode,al.resolution,{},ag.data_manager.BROAD_DATA_REQ);ag.request_draw()}).dblclick(function(aq){aq.stopPropagation()})}var aj=this.view.high-this.view.low,ah=(al.low-this.view.low)*ao;if(this.left_offset){ah-=this.left_offset}ak.css({position:"absolute",top:0,left:ah,height:""});an.append(ak);ag.max_height=Math.max(ag.max_height,ak.height());ag.content_div.css("height",ag.max_height+"px");an.children().css("height",ag.max_height+"px")},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(", ")+"]"},add_track:function(ae){ae.track_id=this.track_id+"_"+this.child_tracks.length;ae.container_div.attr("id","track_"+ae.track_id);this.child_tracks_container.append(ae.container_div);m(ae.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(ae);this.view.has_changes=true},remove_track:function(ae){ae.container_div.fadeOut("slow",function(){$(this).remove()})}});var aa=function(ae,af){this.hidden=true;j.call(this,null,ae,af);this.container_div.addClass("label-track")};p(aa.prototype,j.prototype,{_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 A=function(ae){this.hidden=true;j.call(this,null,ae,ae.top_labeltrack);L.call(this);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(B,this,false);this.tile_cache=new c(t)};p(A.prototype,L.prototype,{draw_tile:function(ao,ak,aj,af,ap){var ai=this,ag=P*aj;if(ap>this.view.canvas_manager.char_width_px){if(ao===null){ai.content_div.css("height","0px");return}var ah=this.view.canvas_manager.new_canvas();var an=ah.getContext("2d");ah.width=Math.ceil(ag*ap+ai.left_offset);ah.height=ai.height_px;an.font=an.canvas.manager.default_font;an.textAlign="center";for(var al=0,am=ao.length;al<am;al++){var ae=Math.round(al*ap);an.fillText(ao[al],ae+ai.left_offset,10)}return new b(af,aj,ah,ao)}this.content_div.css("height","0px")}});var k=function(ai,ag,aj,ae,ah){var af=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";j.call(this,ai,ag,ag.viewport_container);L.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=aj;this.dataset_id=ae;this.original_dataset_id=ae;this.data_manager=new Q(B,this);this.tile_cache=new c(t);this.left_offset=0;this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ai},{key:"color",label:"Color",type:"color",default_value:"black"},{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:ah,onchange:function(){af.set_name(af.prefs.name);af.vertical_range=af.prefs.max_value-af.prefs.min_value;$("#linetrack_"+af.track_id+"_minval").text(af.prefs.min_value);$("#linetrack_"+af.track_id+"_maxval").text(af.prefs.max_value);af.tile_cache.clear();af.request_draw()}});this.prefs=this.track_config.values;this.height_px=this.track_config.values.height;this.vertical_range=this.track_config.values.max_value-this.track_config.values.min_value;this.add_resize_handle()};p(k.prototype,L.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(){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.track_config.values.height=ae.height_px}).appendTo(ae.container_div)},predraw_init:function(){var ae=this,af=ae.view.tracks.indexOf(ae);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(ag){ae.container_div.addClass("line-track");var ai=ag.data;if(isNaN(parseFloat(ae.prefs.min_value))||isNaN(parseFloat(ae.prefs.max_value))){ae.prefs.min_value=ai.min;ae.prefs.max_value=ai.max;$("#track_"+af+"_minval").val(ae.prefs.min_value);$("#track_"+af+"_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_"+af+"_minval").text(w(ae.prefs.min_value));var ah=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+af+"_maxval").text(w(ae.prefs.max_value));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(ap,aj,ai,af,ao){if(this.vertical_range===undefined){return}var ak=af*P*ai,ah=P*ai,ae=Math.ceil(ah*ao),am=this.height_px;var ag=this.view.canvas_manager.new_canvas();ag.width=ae,ag.height=am;var an=ag.getContext("2d");var al=new K.LinePainter(ap.data,ak,ak+ah,this.prefs,aj);al.draw(an,ae,am);return new b(af,ai,ag,ap.data)}});var e=function(ae,aj,ai,am,al,ag,ah,ak){var af=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{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(){af.set_name(af.prefs.name);af.tile_cache.clear();af.request_draw()}});this.prefs=this.track_config.values;j.call(this,ae,aj,aj.viewport_container);L.call(this,ag,ah,ak);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=ai;this.dataset_id=am;this.original_dataset_id=am;this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.inc_slots={};this.start_end_dct={};this.tile_cache=new c(d);this.data_manager=new Q(20,this);this.left_offset=200;this.painter=K.LinkedFeaturePainter};p(e.prototype,L.prototype,{postdraw_actions:function(au,ae,av,at){L.prototype.postdraw_actions.call(this,au,at);var ah=this;if(at){var aj=ah.content_div.children();var ak=false;for(var ai=aj.length-1,ao=0;ai>=ao;ai--){var ag=$(aj[ai]);if(ak){ag.remove()}else{if(ag.children().length!==0){ak=true}}}}if(ah.mode=="Histogram"){var an=-1;for(var ai=0;ai<au.length;ai++){var ar=au[ai].max_val;if(ar>an){an=ar}}for(var ai=0;ai<au.length;ai++){var aq=au[ai];if(aq.max_val!==an){aq.canvas.remove();ah.draw_helper(true,ae,aq.index,aq.resolution,aq.canvas.parent(),av,[],{max:an})}}}if(ah.filters_manager){var af=ah.filters_manager.filters;for(var am=0;am<af.length;am++){af[am].update_ui_elt()}var al=false,ap;for(var ai=0;ai<au.length;ai++){if(au[ai].data.length){ap=au[ai].data[0];for(var am=0;am<af.length;am++){if(af[am].applies_to(ap)){al=true;break}}}}if(ah.filters_available!==al){ah.filters_available=al;if(!ah.filters_available){ah.filters_div.hide()}ah.make_name_popup_menu()}}},update_auto_mode:function(ae){if(this.mode=="Auto"){if(ae=="no_detail"){ae="feature spans"}else{if(ae=="summary_tree"){ae="coverage histogram"}}this.mode_div.text("Auto ("+ae+")")}},incremental_slots:function(ai,af,ah){var ag=this.view.canvas_manager.dummy_context,ae=this.inc_slots[ai];if(!ae||(ae.mode!==ah)){ae=new (r.FeatureSlotter)(ai,ah==="Pack",z,function(aj){return ag.measureText(aj)});ae.mode=ah;this.inc_slots[ai]=ae}return ae.slot_features(af)},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}},draw_tile:function(ar,av,aA,aE,an,ah){var ax=this,aG=aE*P*aA,af=(aE+1)*P*aA,au=af-aG,ay=Math.ceil(au*an),aK=25,ai=this.left_offset,at,aj;if(av==="Auto"){if(ar.dataset_type==="summary_tree"){av=ar.dataset_type}else{if(ar.extra_info==="no_detail"){av="no_detail"}else{var aJ=ar.data;if(this.view.high-this.view.low>H){av="Squish"}else{av="Pack"}}}this.update_auto_mode(av)}if(av==="summary_tree"||av==="Histogram"){aj=this.summary_draw_height;this.container_div.find(".yaxislabel").remove();var ae=$("<div />").addClass("yaxislabel");ae.text(ar.max);ae.css({position:"absolute",top:"24px",left:"10px",color:this.prefs.label_color});ae.prependTo(this.container_div);var ag=this.view.canvas_manager.new_canvas();ag.width=ay+ai;ag.height=aj+R;if(ar.dataset_type!="summary_tree"){var ao=this.get_summary_tree_data(ar.data,aG,af,200);if(ar.max){ao.max=ar.max}ar=ao}var aH=new K.SummaryTreePainter(ar,aG,af,this.prefs);var az=ag.getContext("2d");az.translate(ai,R);aH.draw(az,ay,aj);return new l(aE,aA,ag,ar.data,ar.max)}var at,al=1;if(av==="no_detail"||av==="Squish"||av==="Pack"){al=this.incremental_slots(an,ar.data,av);at=this.inc_slots[an].slots}var am=[];if(ar.data){var ap=this.filters_manager.filters;for(var aB=0,aD=ar.data.length;aB<aD;aB++){var ak=ar.data[aB];var aC=false;var aq;for(var aF=0,aI=ap.length;aF<aI;aF++){aq=ap[aF];aq.update_attrs(ak);if(!aq.keep(ak)){aC=true;break}}if(!aC){am.push(ak)}}}var aw=(this.filters_manager.alpha_filter?new N(this.filters_manager.alpha_filter):null);var aH=new (this.painter)(am,aG,af,this.prefs,av,aw,ah);var aj=Math.max(ac,aH.get_required_height(al));var ag=this.view.canvas_manager.new_canvas();ag.width=ay+ai;ag.height=aj;var az=ag.getContext("2d");az.fillStyle=this.prefs.block_color;az.font=az.canvas.manager.default_font;az.textAlign="right";this.container_div.find(".yaxislabel").remove();if(ar.data){az.translate(ai,0);aH.draw(az,ay,aj,at)}return new O(aE,aA,ag,ar.data,ar.message)}});var S=function(ah,af,aj,ae,ag,ai){e.call(this,ah,af,aj,ae,ag,ai);this.painter=K.VariantPainter};p(S.prototype,L.prototype,e.prototype);var V=function(ah,af,aj,ae,ag,ai){e.call(this,ah,af,aj,ae,ag,ai);this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ah},{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{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:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:ag,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.track_config.values;this.painter=K.ReadPainter;this.make_name_popup_menu()};p(V.prototype,L.prototype,e.prototype);var T=function(ai,ag,ak,ae,ah,aj,af){e.call(this,ai,ag,ak,ae,ah,aj,{},af);this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};p(T.prototype,L.prototype,e.prototype,{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=J;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()}});W.View=ab;W.DrawableCollection=y;W.LineTrack=k;W.FeatureTrack=e;W.ReadTrack=V};var slotting_module=function(c,b){var e=c("class").extend;var d=2,a=5;b.FeatureSlotter=function(j,h,f,g){this.slots={};this.start_end_dct={};this.w_scale=j;this.include_label=h;this.max_rows=f;this.measureText=g};e(b.FeatureSlotter.prototype,{slot_features:function(m){var p=this.w_scale,s=this.slots,h=this.start_end_dct,y=[],A=[],n=0,z=this.max_rows;for(var w=0,x=m.length;w<x;w++){var l=m[w],o=l[0];if(s[o]!==undefined){n=Math.max(n,s[o]);A.push(s[o])}else{y.push(w)}}var q=function(G,H){for(var F=0;F<=z;F++){var D=false,I=h[F];if(I!==undefined){for(var C=0,E=I.length;C<E;C++){var B=I[C];if(H>B[0]&&G<B[1]){D=true;break}}}if(!D){return F}}return -1};for(var w=0,x=y.length;w<x;w++){var l=m[y[w]],o=l[0],u=l[1],f=l[2],r=l[3],g=Math.floor(u*p),k=Math.ceil(f*p),v=this.measureText(r).width,j;if(r!==undefined&&this.include_label){v+=(d+a);if(g-v>=0){g-=v;j="left"}else{k+=v;j="right"}}var t=q(g,k);if(t>=0){if(h[t]===undefined){h[t]=[]}h[t].push([g,k]);s[o]=t;n=Math.max(n,t)}else{}}return n+1}})};var painters_module=function(k,x){var u=k("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 g=function(y){this.default_alpha=(y?y:1)};g.prototype.gen_alpha=function(y){return this.default_alpha};var n=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};n.prototype.default_prefs={};var v=function(A,C,y,z,B){n.call(this,A,C,y,z,B)};v.prototype.default_prefs={show_counts:false};v.prototype.draw=function(M,z,L){var E=this.view_start,O=this.view_end-this.view_start,N=z/O;var J=this.data.data,I=this.data.delta,G=this.data.max,B=L;delta_x_px=Math.ceil(I*N);M.save();for(var C=0,D=J.length;C<D;C++){var H=Math.floor((J[C][0]-E)*N);var F=J[C][1];if(!F){continue}var K=F/G*L;if(F!==0&&K<1){K=1}M.fillStyle=this.prefs.block_color;M.fillRect(H,B-K,delta_x_px,K);var A=4;if(this.prefs.show_counts&&(M.measureText(F).width+A)<delta_x_px){M.fillStyle=this.prefs.label_color;M.textAlign="center";M.fillText(F,H+(delta_x_px/2),10)}}M.restore()};var c=function(y,C,E,F,A){n.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}};c.prototype.default_prefs={min_value:undefined,max_value:undefined,mode:"Histogram",color:"#000",overflow_color:"#F66"};c.prototype.draw=function(N,M,K){var F=false,H=this.prefs.min_value,D=this.prefs.max_value,J=D-H,z=K,A=this.view_start,L=this.view_end-this.view_start,B=M/L,I=this.mode,T=this.data;N.save();var U=Math.round(K+H/J*K);if(I!=="Intensity"){N.fillStyle="#aaa";N.fillRect(0,U,M,1)}N.beginPath();var R,E,C;if(T.length>1){C=Math.ceil((T[1][0]-T[0][0])*B)}else{C=10}for(var O=0,P=T.length;O<P;O++){N.fillStyle=this.prefs.color;R=Math.round((T[O][0]-A)*B);E=T[O][1];var Q=false,G=false;if(E===null){if(F&&I==="Filled"){N.lineTo(R,z)}F=false;continue}if(E<H){G=true;E=H}else{if(E>D){Q=true;E=D}}if(I==="Histogram"){E=Math.round(E/J*z);N.fillRect(R,U,C,-E)}else{if(I==="Intensity"){E=255-Math.floor((E-H)/J*255);N.fillStyle="rgb("+E+","+E+","+E+")";N.fillRect(R,0,C,z)}else{E=Math.round(z-(E-H)/J*z);if(F){N.lineTo(R,E)}else{F=true;if(I==="Filled"){N.moveTo(R,z);N.lineTo(R,E)}else{N.moveTo(R,E)}}}}N.fillStyle=this.prefs.overflow_color;if(Q||G){var S;if(I==="Histogram"||I==="Intensity"){S=C}else{R-=2;S=4}if(Q){N.fillRect(R,0,S,3)}if(G){N.fillRect(R,z-3,S,3)}}N.fillStyle=this.prefs.color}if(I==="Filled"){if(F){N.lineTo(R,U);N.lineTo(0,U)}N.fill()}else{N.stroke()}N.restore()};var o=function(B,D,y,A,C,z){n.call(this,B,D,y,A,C);this.alpha_generator=(z?z:new g())};o.prototype.default_prefs={block_color:"#FFF",connector_color:"#FFF"};u(o.prototype,{get_required_height:function(z){var y=y_scale=this.get_row_height(),A=this.mode;if(A==="no_detail"||A==="Squish"||A==="Pack"){y=z*y_scale}return y+Math.max(Math.round(y_scale/2),5)},draw:function(K,B,J,G){var E=this.data,H=this.view_start,L=this.view_end;K.save();K.fillStyle=this.prefs.block_color;K.textAlign="right";var O=this.view_end-this.view_start,N=B/O,A=this.get_row_height();for(var D=0,F=E.length;D<F;D++){var M=E[D],C=M[0],y=M[1],z=M[2],I=(G&&G[C]!==undefined?G[C]:null);if((y<L&&z>H)&&(this.mode=="Dense"||I!==null)){this.draw_element(K,this.mode,M,I,H,L,N,A,B)}}K.restore()},draw_element:function(E,A,G,C,B,D,F,z,y){console.log("WARNING: Unimplemented function.")}});var d=10,j=3,m=5,w=10,f=1,s=3,e=3,a=9,l=2,h="#ccc";var r=function(B,D,y,A,C,z){o.call(this,B,D,y,A,C,z)};u(r.prototype,o.prototype,{get_row_height:function(){var z=this.mode,y;if(z==="Dense"){y=d}else{if(z==="no_detail"){y=j}else{if(z==="Squish"){y=m}else{y=w}}}return y},draw_element:function(K,D,S,F,M,ac,ag,ah,y){var P=S[0],ae=S[1],W=S[2],N=S[3],X=Math.floor(Math.max(0,(ae-M)*ag)),L=Math.ceil(Math.min(y,Math.max(0,(W-M)*ag))),V=(D==="Dense"?0:(0+F))*ah,J,aa,O=null,ai=null,B=this.prefs.block_color,Z=this.prefs.label_color;K.globalAlpha=this.alpha_generator.gen_alpha(S);if(D=="Dense"){F=1}if(D==="no_detail"){K.fillStyle=B;K.fillRect(X,V+5,L-X,f)}else{var I=S[4],U=S[5],Y=S[6],C=S[7];if(U&&Y){O=Math.floor(Math.max(0,(U-M)*ag));ai=Math.ceil(Math.min(y,Math.max(0,(Y-M)*ag)))}var af,Q;if(D==="Squish"||D==="Dense"){af=1;Q=e}else{af=5;Q=a}if(!C){if(S.strand){if(S.strand==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand_inv")}else{if(S.strand==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand_inv")}}}else{K.fillStyle=B}K.fillRect(X,V,L-X,Q)}else{var H,R;if(D==="Squish"||D==="Dense"){K.fillStyle=h;H=V+Math.floor(e/2)+1;R=1}else{if(I){var H=V;var R=Q;if(I==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand")}else{if(I==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand")}}}else{K.fillStyle=h;H+=(e/2)+1;R=1}}K.fillRect(X,H,L-X,R);for(var ad=0,A=C.length;ad<A;ad++){var E=C[ad],z=Math.floor(Math.max(0,(E[0]-M)*ag)),T=Math.ceil(Math.min(y,Math.max((E[1]-M)*ag)));if(z>T){continue}K.fillStyle=B;K.fillRect(z,V+(Q-af)/2+1,T-z,af);if(O!==undefined&&Y>U&&!(z>ai||T<O)){var ab=Math.max(z,O),G=Math.min(T,ai);K.fillRect(ab,V+1,G-ab,Q);if(C.length==1&&D=="Pack"){if(I==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand_inv")}else{if(I==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand_inv")}}if(ab+14<G){ab+=2;G-=2}K.fillRect(ab,V+1,G-ab,Q)}}}}if(D==="Pack"&&ae>M){K.fillStyle=Z;if(M===0&&X-K.measureText(N).width<0){K.textAlign="left";K.fillText(N,L+l,V+8)}else{K.textAlign="right";K.fillText(N,X-l,V+8)}}}K.globalAlpha=1}});var b=function(B,D,y,A,C,z){o.call(this,B,D,y,A,C,z)};u(b.prototype,o.prototype,{draw_element:function(R,M,G,C,U,A,J,S,P){var G=data[i],I=G[0],Q=G[1],B=G[2],L=G[3],E=Math.floor(Math.max(0,(Q-U)*J)),H=Math.ceil(Math.min(P,Math.max(0,(B-U)*J))),D=(M==="Dense"?0:(0+C))*S,y,V,z=null,K=null;if(no_label){R.fillStyle=block_color;R.fillRect(E+left_offset,D+5,H-E,1)}else{var T=G[4],O=G[5],F=G[6];y=9;V=1;R.fillRect(E+left_offset,D,H-E,y);if(M!=="Dense"&&L!==undefined&&Q>U){R.fillStyle=label_color;if(U===0&&E-R.measureText(L).width<0){R.textAlign="left";R.fillText(L,H+2+left_offset,D+8)}else{R.textAlign="right";R.fillText(L,E-2+left_offset,D+8)}R.fillStyle=block_color}var N=T+" / "+O;if(Q>U&&R.measureText(N).width<(H-E)){R.fillStyle="white";R.textAlign="center";R.fillText(N,left_offset+E+(H-E)/2,D+8);R.fillStyle=block_color}}}});var t=function(C,E,y,B,D,z,A){o.call(this,C,E,y,B,D,z);this.ref_seq=A};t.prototype.default_prefs=u({},o.prototype.default_prefs,{show_insertions:false});u(t.prototype,o.prototype,{get_row_height:function(){var y,z=this.mode;if(z==="Dense"){y=d}else{if(z==="Squish"){y=m}else{y=w;if(this.prefs.show_insertions){y*=2}}}return y},draw_read:function(U,P,L,Z,A,T,I,F,E){U.textAlign="center";var S=this,z=[Z,A],O=0,V=0,R=0;ref_seq=this.ref_seq,char_width_px=U.canvas.manager.char_width_px;var ae=[];if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){R=Math.round(L/2)}if(!I){I=[[0,F.length]]}for(var M=0,X=I.length;M<X;M++){var J=I[M],B="MIDNSHP=X"[J[0]],N=J[1];if(B==="H"||B==="S"){O-=N}var G=T+O,ad=Math.floor(Math.max(0,(G-Z)*L)),H=Math.floor(Math.max(0,(G+N-Z)*L));if(ad===H){H+=1}switch(B){case"H":break;case"S":case"M":case"=":if(is_overlap([G,G+N],z)){var Q=F.slice(V,V+N);if(R>0){U.fillStyle=this.prefs.block_color;U.fillRect(ad-R,E+1,H-ad,9);U.fillStyle=h;for(var ab=0,y=Q.length;ab<y;ab++){if(this.prefs.show_differences&&ref_seq){var K=ref_seq[G-Z+ab];if(!K||K.toLowerCase()===Q[ab].toLowerCase()){continue}}if(G+ab>=Z&&G+ab<=A){var ac=Math.floor(Math.max(0,(G+ab-Z)*L));U.fillText(Q[ab],ac,E+9)}}}else{U.fillStyle=this.prefs.block_color;U.fillRect(ad,E+4,H-ad,e)}}V+=N;O+=N;break;case"N":U.fillStyle=h;U.fillRect(ad-R,E+5,H-ad,1);O+=N;break;case"D":U.fillStyle="red";U.fillRect(ad-R,E+4,H-ad,3);O+=N;break;case"P":break;case"I":var Y=ad-R;if(is_overlap([G,G+N],z)){var Q=F.slice(V,V+N);if(this.prefs.show_insertions){var D=ad-(H-ad)/2;if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){U.fillStyle="yellow";U.fillRect(D-R,E-9,H-ad,9);ae[ae.length]={type:"triangle",data:[Y,E+4,5]};U.fillStyle=h;switch(seq_tile_overlap){case (OVERLAP_START):Q=Q.slice(Z-G);break;case (OVERLAP_END):Q=Q.slice(0,G-A);break;case (CONTAINED_BY):break;case (CONTAINS):Q=Q.slice(Z-G,G-A);break}for(var ab=0,y=Q.length;ab<y;ab++){var ac=Math.floor(Math.max(0,(G+ab-Z)*L));U.fillText(Q[ab],ac-(H-ad)/2,E)}}else{U.fillStyle="yellow";U.fillRect(D,E+(this.mode!=="Dense"?2:5),H-ad,(P!=="Dense"?e:s))}}else{if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){ae[ae.length]={type:"text",data:[Q.length,Y,E+9]}}else{}}}V+=N;break;case"X":V+=N;break}}U.fillStyle="yellow";var aa,C,af;for(var W=0;W<ae.length;W++){aa=ae[W];C=aa.type;af=aa.data;if(C==="text"){U.save();U.font="bold "+U.font;U.fillText(af[0],af[1],af[2]);U.restore()}else{if(C=="triangle"){q(U,af[0],af[1],af[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,V=this.prefs.block_color,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)}R.fillStyle=V;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,U,z,E[4][0],E[4][2],E[4][3],C)}if(E[5][1]>=U&&E[5][0]<=z&&E[5][2]){this.draw_read(R,M,I,U,z,E[5][0],E[5][2],E[5][3],C)}if(K>L){R.fillStyle=h;p(R,L-O,C+5,K-O,C+5)}}else{R.fillStyle=V;this.draw_read(R,M,I,U,z,Q,E[4],E[5],C)}if(M==="Pack"&&Q>U){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+l-O,C+8)}else{R.textAlign="right";R.fillText(J,D-l-O,C+8)}R.fillStyle=V}}});x.AlphaGenerator=g;x.SummaryTreePainter=v;x.LinePainter=c;x.LinkedFeaturePainter=r;x.ReadPainter=t;x.VariantPainter=b};(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 trackster_module=function(f,W){var p=f("class").extend,r=f("slotting"),K=f("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 m=function(ae,ag,ah){ah=".group";var af={};ae.bind("drag",{handle:"."+ag,relative:true},function(an,ao){var aq=$(this).parent(),al=aq.children(),ak,aj,ap,ai,am;aj=$(this).parents(ah);if(aj.length!==0){ap=aj.position().top;ai=ap+aj.outerHeight();if(ao.offsetY<ap){$(this).insertBefore(aj);return}else{if(ao.offsetY>ai){$(this).insertAfter(aj);return}}}aj=null;for(am=0;am<al.length;am++){ak=$(al.get(am));ap=ak.position().top;ai=ap+ak.outerHeight();if(ak.is(ah)&&this!==ak.get(0)&&ao.offsetY>=ap&&ao.offsetY<=ai){if(ao.offsetY-ap<ai-ao.offsetY){ak.find(".content-div").prepend(this)}else{ak.find(".content-div").append(this)}return}}for(am=0;am<al.length;am++){if(ao.offsetY<$(al.get(am)).position().top){break}}if(am===al.length){if(this!==al.get(am-1)){aq.append(this)}}else{if(this!==al.get(am)){$(this).insertBefore(al.get(am))}}}).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,D=20,R=F+2,z=100,H=12000,P=200,C=5,u=10,J=5000,v=100,n="There was an error in indexing this dataset. ",I="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",E="No data for this chrom/contig.",s="Currently indexing... please wait",x="Tool cannot be rerun: ",a="Loading data...",X="Ready for display",d=10,t=5,B=5;function w(ae){return Math.round(ae*1000)/1000}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 Q=function(af,ae,ag){c.call(this,af);this.track=ae;this.subset=(ag!==undefined?ag:true)};p(Q.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[ao.length]=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,al,ap)})},get_data:function(ae,ai,aj,af,ah){var ag=this.get_data_from_cache(ae,ai,aj);if(ag){return ag}ag=this.load_data(ae,ai,aj,af,ah);this.set_data(ae,ai,aj,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_data_from_cache(am,ah,al);if(!an){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,al,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,al,ao);new_data_available.resolve(ao)});return new_data_available},get_data_from_cache:function(ae,af,ag){return this.get(this.gen_key(ae,af,ag))},set_data:function(af,ag,ah,ae){return this.set(this.gen_key(af,ag,ah),ae)},gen_key:function(ae,ag,ah){var af=ae+"_"+ag+"_"+ah;return af},split_key:function(ae){return ae.split("_")}});var G=function(af,ae,ag){Q.call(this,af,ae,ag)};p(G.prototype,Q.prototype,c.prototype,{load_data:function(ag,ae,ai,aj,af,ah){if(af>1){return}return Q.prototype.load_data.call(this,ag,ae,ai,aj,af,ah)}});var ab=function(ae,ah,ag,af,ai){this.container=ae;this.chrom=null;this.vis_id=ag;this.dbkey=af;this.title=ah;this.tracks=[];this.label_tracks=[];this.tracks_to_be_redrawn=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(ai);this.canvas_manager=new ad(ae.get(0).ownerDocument);this.reset()};p(ab.prototype,{init:function(ai){var ag=this.container,ae=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ag);this.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").addClass("viewport-container").appendTo(this.content_div);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 href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").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(aj){if(aj.type==="focusout"||(aj.keyCode||aj.which)===13||(aj.keyCode||aj.which)===27){if((aj.keyCode||aj.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").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 id='zoom-out' />").click(function(){ae.zoom_out();ae.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){ae.zoom_in();ae.request_redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},ai);this.chrom_select.bind("change",function(){ae.change_chrom(ae.chrom_select.val())});this.content_div.click(function(aj){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(aj){ae.zoom_in(aj.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(aj,ak){this.current_x=ak.offsetX}).bind("drag",function(aj,al){var am=al.offsetX-this.current_x;this.current_x=al.offsetX;var ak=Math.round(am/ae.viewport_container.width()*(ae.max_high-ae.max_low));ae.move_delta(-ak)});this.overview_close.click(function(){ae.reset_overview()});this.viewport_container.bind("draginit",function(aj,ak){if(aj.clientX>ae.viewport_container.width()-16){return false}}).bind("dragstart",function(aj,ak){ak.original_low=ae.low;ak.current_height=aj.clientY;ak.current_x=ak.offsetX}).bind("drag",function(al,an){var aj=$(this);var ao=an.offsetX-an.current_x;var ak=aj.scrollTop()-(al.clientY-an.current_height);aj.scrollTop(ak);an.current_height=al.clientY;an.current_x=an.offsetX;var am=Math.round(ao/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(am)}).bind("mousewheel",function(al,an,ak,aj){if(ak){var am=Math.round(-ak/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(am)}});this.top_labeltrack.bind("dragstart",function(aj,ak){return $("<div />").css({height:ae.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(an,ao){$(ao.proxy).css({left:Math.min(an.pageX,ao.startX),width:Math.abs(an.pageX-ao.startX)});var ak=Math.min(an.pageX,ao.startX)-ae.container.offset().left,aj=Math.max(an.pageX,ao.startX)-ae.container.offset().left,am=(ae.high-ae.low),al=ae.viewport_container.width();ae.update_location(Math.round(ak/al*am)+ae.low,Math.round(aj/al*am)+ae.low)}).bind("dragend",function(ao,ap){var ak=Math.min(ao.pageX,ap.startX),aj=Math.max(ao.pageX,ap.startX),am=(ae.high-ae.low),al=ae.viewport_container.width(),an=ae.low;ae.low=Math.round(ak/al*am)+an;ae.high=Math.round(aj/al*am)+an;$(ap.proxy).remove();ae.request_redraw()});this.add_label_track(new aa(this,this.top_labeltrack));this.add_label_track(new aa(this,this.nav_labeltrack));$(window).bind("resize",function(){ae.resize_window()});$(document).bind("redraw",function(){ae.redraw()});this.reset();$(window).trigger("resize");this.update_intro_div()},update_intro_div:function(){if(this.num_tracks===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(af,ag){af.num=v;$.extend(af,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var ae=this;$.ajax({url:chrom_url,data:af,dataType:"json",success:function(ai){if(ai.chrom_info.length===0){alert("Invalid chromosome: "+af.chrom);return}if(ai.reference){ae.add_label_track(new A(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);if(ag){ag()}ae.chrom_start_index=ai.start_index},error:function(){alert("Could not load chroms for this dbkey:",ae.dbkey)}})},change_chrom:function(ai,af,ak){if(!ai||ai==="None"){return}var ah=this;if(ai==="previous"){ah.load_chroms({low:this.chrom_start_index-v});return}if(ai==="next"){ah.load_chroms({low:this.chrom_start_index+v});return}var aj=$.grep(ah.chrom_data,function(am,an){return am.chrom===ai})[0];if(aj===undefined){ah.load_chroms({chrom:ai},function(){ah.change_chrom(ai,af,ak)});return}else{if(ai!==ah.chrom){ah.chrom=ai;ah.chrom_select.val(ah.chrom);ah.max_high=aj.len-1;ah.reset();ah.request_redraw(true);for(var al=0,ae=ah.tracks.length;al<ae;al++){var ag=ah.tracks[al];if(ag.init){ag.init()}}}if(af!==undefined&&ak!==undefined){ah.low=Math.max(af,0);ah.high=Math.min(ak,ah.max_high)}ah.reset_overview();ah.request_redraw()}},go_to:function(ai){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].replace(/,/g,""),10);ah=parseInt(aj[1].replace(/,/g,""),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_track:function(ae){ae.view=this;ae.track_id=this.track_id_counter;this.tracks.push(ae);if(ae.init){ae.init()}ae.container_div.attr("id","track_"+ae.track_id);m(ae.container_div,ae.drag_handle_class);this.track_id_counter+=1;this.num_tracks+=1;this.has_changes=true;this.update_intro_div()},add_label_track:function(ae){ae.view=this;this.label_tracks.push(ae)},remove_track:function(af){this.has_changes=true;this.tracks.splice(this.tracks.indexOf(af),1);this.num_tracks-=1;var ae=this;af.container_div.fadeOut("slow",function(){$(this).remove();ae.update_intro_div()})},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.tracks),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(C,Math.ceil(Math.log((this.high-this.low)/P)/Math.log(C)));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.enabled){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.nav_container.width(this.container.width());this.request_redraw()},set_overview:function(ae){$.when(ae.get_overview_tile()).then(function(af){view.overview_viewport.find(".track-tile").remove();view.overview_close.show();view.overview_viewport.append(af.canvas);view.overview_highlight.show().height(af.canvas.height());view.overview_viewport.height(af.canvas.height()+view.overview_box.outerHeight());view.resize_window();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=ae;ae.set_is_overview(true)});view.has_changes=true},reset_overview:function(){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();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=null}});var q=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 g(af,aq,ai,at,am.min,am.max)}else{if(ao=="select"){this.params[this.params.length]=new M(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("slider").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(q.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 ae={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},ag=this.track,af=ae.tool_id+ag.tool_region_and_parameters_str(ae.chrom,ae.low,ae.high),ah;if(ag instanceof e){ah=new T(af,view,ag.hda_ldda,undefined,{},{},ag);ah.change_mode(ag.mode)}this.track.view.add_track(ah);ah.content_div.text("Starting job.");this.run(ae,ah,function(ai){ah.dataset_id=ai.dataset_id;ah.content_div.text("Running job.");ah.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(I)}else{if(ai.error){ag.container_div.addClass("error");ag.content_div.text(x+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 M=function(af,ae,ag,ah){this.name=af;this.label=ae;this.html=ag;this.value=ah};var g=function(ag,af,ai,aj,ah,ae){M.call(this,ag,af,ai,aj);this.min=ah;this.max=ae};var h=function(af,ae,ag,ah){this.name=af;this.index=ae;this.tool_id=ag;this.tool_exp_name=ah};var U=function(af,ae,ag,ah){h.call(this,af,ae,ag,ah);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};p(U.prototype,{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=parseFloat(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.container.show()}else{this.container.hide()}var ag=function(aj,ah){var ai=ah-aj;return(ai<=2?0.01:1)};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",ag(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var Z=function(ao,av){this.track=ao;this.filters=[];for(var ap=0;ap<av.length;ap++){var aq=av[ap],aw=aq.name,ae=aq.type,ah=aq.index,au=aq.tool_id,at=aq.tool_exp_name;if(ae==="int"||ae==="float"){this.filters[ap]=new U(aw,ah,au,at)}else{console.log("ERROR: unsupported filter: ",aw,ae)}}var ai=function(ax,ay,az){ax.click(function(){var aA=ay.text();max=parseFloat(az.slider("option","max")),input_size=(max<=1?4:max<=1000000?max.toString().length:6),multi_value=false;if(az.slider("option","values")){input_size=2*input_size+1;multi_value=true}ay.text("");$("<input type='text'/>").attr("size",input_size).attr("maxlength",input_size).attr("value",aA).appendTo(ay).focus().select().click(function(aB){aB.stopPropagation()}).blur(function(){$(this).remove();ay.text(aA)}).keyup(function(aF){if(aF.keyCode===27){$(this).trigger("blur")}else{if(aF.keyCode===13){var aD=az.slider("option","min"),aB=az.slider("option","max"),aE=function(aG){return(isNaN(aG)||aG>aB||aG<aD)},aC=$(this).val();if(!multi_value){aC=parseFloat(aC);if(aE(aC)){alert("Parameter value must be in the range ["+aD+"-"+aB+"]");return $(this)}}else{aC=aC.split("-");aC=[parseFloat(aC[0]),parseFloat(aC[1])];if(aE(aC[0])||aE(aC[1])){alert("Parameter value must be in the range ["+aD+"-"+aB+"]");return $(this)}}az.slider((multi_value?"values":"value"),aC)}}})})};this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(ax){ax.stopPropagation()}).click(function(ax){ax.stopPropagation()}).bind("dblclick",function(ax){ax.stopPropagation()}).bind("keydown",function(ax){ax.stopPropagation()});var ar=$("<div/>").addClass("sliders").appendTo(this.parent_div);var am=this;$.each(this.filters,function(aA,aC){aC.container=$("<div/>").addClass("slider-row").appendTo(ar);var aB=$("<div/>").addClass("elt-label").appendTo(aC.container);var az=$("<span/>").addClass("slider-name").text(aC.name+" ").appendTo(aB);var ay=$("<span/>");var aE=$("<span/>").addClass("slider-value").appendTo(aB).append("[").append(ay).append("]");var ax=$("<div/>").addClass("slider").appendTo(aC.container);aC.control_element=$("<div/>").attr("id",aC.name+"-filter-control").appendTo(ax);var aD=[0,0];aC.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(aG,aH){var aF=aH.values;ay.text(aF[0]+"-"+aF[1]);aC.low=aF[0];aC.high=aF[1];am.track.request_draw(true,true)},change:function(aF,aG){aC.control_element.slider("option","slide").call(aC.control_element,aF,aG)}});aC.slider=aC.control_element;aC.slider_label=ay;ai(aE,ay,aC.control_element);$("<div style='clear: both;'/>").appendTo(aC.container)});if(this.filters.length!==0){var aj=$("<div/>").addClass("param-row").appendTo(ar);var al=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(aj);var ag=this;al.click(function(){ag.run_on_dataset()})}var an=$("<div/>").addClass("display-controls").appendTo(this.parent_div),ak=$("<span/>").addClass("elt-label").text("Transparency:").appendTo(an),af=$("<select/>").attr("name","alpha_dropdown").appendTo(an);this.alpha_filter=null;$("<option/>").attr("value",-1).text("== None ==").appendTo(af);for(var ap=0;ap<this.filters.length;ap++){$("<option/>").attr("value",ap).text(this.filters[ap].name).appendTo(af)}af.change(function(){$(this).children("option:selected").each(function(){var ax=parseInt($(this).val());am.alpha_filter=(ax>=0?am.filters[ax]:null);am.track.request_draw(true,true)})});$("<div style='clear: both;'/>").appendTo(this.parent_div)};p(Z.prototype,{reset_filters:function(){for(var ae=0;ae<this.filters.length;ae++){filter=this.filters[ae];filter.slider.slider("option","values",[filter.min,filter.max])}this.alpha_filter=null},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 N=function(af,ae){K.AlphaGenerator.call(this,ae);this.filter=af};N.prototype.gen_alpha=function(ae){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_alpha}return((parseFloat(ae[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var Y=function(ae){this.track=ae.track;this.params=ae.params;this.values={};if(ae.saved_values){this.restore_values(ae.saved_values)}this.onchange=ae.onchange};p(Y.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 af=this;var ae=$("<div />");$.each(this.params,function(aj,ah){if(!ah.hidden){var ag="param_"+aj;var al=af.values[ah.key];var ao=$("<div class='form-row' />").appendTo(ae);ao.append($("<label />").attr("for",ag).text(ah.label+":"));if(ah.type==="bool"){ao.append($('<input type="checkbox" />').attr("id",ag).attr("name",ag).attr("checked",al))}else{if(ah.type==="text"){ao.append($('<input type="text"/>').attr("id",ag).val(al).click(function(){$(this).select()}))}else{if(ah.type==="color"){var ak=$("<input />").attr("id",ag).attr("name",ag).val(al);var am=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var ai=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(am);var an=$("<div/>").appendTo(ai).farbtastic({width:100,height:100,callback:ak,color:al});$("<div />").append(ak).append(am).appendTo(ao).bind("click",function(ap){am.css({left:$(this).position().left+($(ak).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){am.hide();$(document).unbind("click.color-picker")});ap.stopPropagation()})}else{ao.append($("<input />").attr("id",ag).attr("name",ag).val(al))}}}}});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(ag,af,ae,ah){this.index=ag;this.low=ag*P*af;this.high=(ag+1)*P*af;this.resolution=af;this.canvas=$("<div class='track-tile'/>").append(ae);this.data=ah;this.stale=false};var l=function(ag,af,ae,ah,ai){b.call(this,ag,af,ae,ah);this.max_val=ai};var O=function(ag,af,ae,ai,ah){b.call(this,ag,af,ae,ai);this.message=ah};var o=function(af,ae){this.name=af;this.view=ae;this.parent_element=ae.viewport_container};o.prototype.request_draw=function(){};o.prototype.draw=function(){};var y=function(af,ae){o.call(this,af,ae);this.members=[];this.drag_handle_class="group-handle";this.container_div=$("<div/>").addClass("group").appendTo(this.parent_element);this.container_div.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("group-name").text(this.name).appendTo(this.container_div);this.content_div=$("<div/>").addClass("content-div").appendTo(this.container_div)};p(y.prototype,o.prototype,{request_draw:function(af,ae){},draw:function(){}});var j=function(af,ae,ai,ag,ah){this.name=af;this.view=ae;this.parent_element=ai;this.data_url=(ag?ag:default_data_url);this.data_url_extra_params={};this.data_query_wait=(ah?ah:J);this.dataset_check_url=converted_datasets_state_url;this.drag_handle_class="draghandle";this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};p(j.prototype,{get_type:function(){if(this instanceof aa){return"LabelTrack"}else{if(this instanceof A){return"ReferenceTrack"}else{if(this instanceof k){return"LineTrack"}else{if(this instanceof V){return"ReadTrack"}else{if(this instanceof T){return"ToolDataFeatureTrack"}else{if(this instanceof S){return"VcfTrack"}else{if(this instanceof e){return"FeatureTrack"}}}}}}}return""},init:function(){var ae=this;ae.enabled=false;ae.tile_cache.clear();ae.data_manager.clear();ae.initial_canvas=undefined;ae.content_div.css("height","auto");ae.container_div.removeClass("nodata error pending");if(!ae.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:ae.hda_ldda,dataset_id:ae.dataset_id,chrom:ae.view.chrom},function(af){if(!af||af==="error"||af.kind==="error"){ae.container_div.addClass("error");ae.content_div.text(n);if(af.message){var ah=ae.view.tracks.indexOf(ae);var ag=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+af.message+"</pre>",{Close:hide_modal})});ae.content_div.append(ag)}}else{if(af==="no converter"){ae.container_div.addClass("error");ae.content_div.text(I)}else{if(af==="no data"||(af.data!==undefined&&(af.data===null||af.data.length===0))){ae.container_div.addClass("nodata");ae.content_div.text(E)}else{if(af==="pending"){ae.container_div.addClass("pending");ae.content_div.text(s);setTimeout(function(){ae.init()},ae.data_query_wait)}else{if(af.status==="data"){if(af.valid_chroms){ae.valid_chroms=af.valid_chroms;ae.make_name_popup_menu()}ae.content_div.text(X);if(ae.view.chrom){ae.content_div.text("");ae.content_div.css("height",ae.height_px+"px");ae.enabled=true;$.when(ae.predraw_init()).done(function(){ae.container_div.removeClass("nodata error pending");ae.request_draw()})}}}}}}})},predraw_init: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)}});var L=function(al,aj,am){var af=this,an=af.view;this.filters_manager=(al!==undefined?new Z(this,al):undefined);this.filters_available=false;this.filters_visible=false;this.tool=(aj!==undefined&&obj_length(aj)>0?new q(this,aj):undefined);this.is_overview=false;this.parent_track=am;this.child_tracks=[];if(af.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}af.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();af.container_div.append(af.child_tracks_container);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)}if(af.display_modes!==undefined){if(af.mode_div===undefined){af.mode_div=$("<div class='right-float menubutton popup' />").appendTo(af.header_div);var ag=(af.track_config&&af.track_config.values.mode?af.track_config.values.mode:af.display_modes[0]);af.mode=ag;af.mode_div.text(ag);var ae={};for(var ah=0,ak=af.display_modes.length;ah<ak;ah++){var ai=af.display_modes[ah];ae[ai]=function(ao){return function(){af.change_mode(ao)}}(ai)}make_popupmenu(af.mode_div,ae)}else{af.mode_div.hide()}}this.make_name_popup_menu()};p(L.prototype,j.prototype,{change_mode:function(af){var ae=this;ae.mode_div.text(af);ae.mode=af;ae.track_config.values.mode=af;ae.tile_cache.clear();ae.request_draw()},make_name_popup_menu:function(){var af=this;var ae={};ae[(this.is_overview?"Hide overview":"Set as overview")]=function(){if(af.is_overview){af.view.reset_overview()}else{af.view.set_overview(af)}};ae["Edit configuration"]=function(){var al=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},aj=function(){af.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ak=function(am){if((am.keyCode||am.which)===27){al()}else{if((am.keyCode||am.which)===13){aj()}}};$(window).bind("keypress.check_enter_esc",ak);show_modal("Configure Track",af.track_config.build_form(),{Cancel:al,OK:aj})};if(af.filters_available>0){var ai=(af.filters_div.is(":visible")?"Hide filters":"Show filters");ae[ai]=function(){af.filters_visible=(af.filters_div.is(":visible"));if(af.filters_visible){af.filters_manager.reset_filters()}af.filters_div.toggle();af.make_name_popup_menu()}}if(af.tool){var ai=(af.dynamic_tool_div.is(":visible")?"Hide tool":"Show tool");ae[ai]=function(){if(!af.dynamic_tool_div.is(":visible")){af.set_name(af.name+af.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";af.revert_name()}af.dynamic_tool_div.toggle();af.make_name_popup_menu()}}if(af.valid_chroms){ae["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+af.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}var ag=view;var ah=function(){$("#no-tracks").show()};if(this.parent_track){ag=this.parent_track;ah=function(){}}ae.Remove=function(){ag.remove_track(af);if(ag.num_tracks===0){ah()}};make_popupmenu(af.name_div,ae)},set_is_overview:function(ae){this.is_overview=ae;this.make_name_popup_menu()},get_overview_tile:function(){var ae=this;view=ae.view,resolution=Math.pow(C,Math.ceil(Math.log((view.max_high-view.max_low)/P)/Math.log(C))),view_width=view.container.width(),w_scale=view_width/(view.max_high-view.max_low),overview_tile=$.Deferred();$.when(ae.data_manager.get_data(view.max_low,view.max_high,"Auto",resolution,ae.data_url_extra_params)).then(function(af){var ah=ae._gen_tile_cache_key(view_width,w_scale,0),aj=ae.tile_cache.get(ah);if(!aj){aj=ae.draw_tile(af,"Auto",resolution,0,w_scale);ae.tile_cache.set(ah,aj)}var am=$(aj.canvas.find("canvas")),ai=am.clone(),al=am.get(0).getContext("2d"),ag=ai.get(0).getContext("2d"),ak=al.getImageData(0,0,al.canvas.width,al.canvas.height);ag.putImageData(ak,-ae.left_offset,(aj.data.dataset_type==="summary_tree"?R:0));new_tile=new b(-1,resolution,ai);overview_tile.resolve(new_tile)});return overview_tile},_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,ap){if(!this.dataset_id){return}var ao=this.view.low,ak=this.view.high,am=ak-ao,ah=this.view.container.width(),at=ah/am,aj=this.view.resolution,ar=$("<div style='position: relative;'></div>");if(!ap){this.content_div.children().remove()}this.content_div.append(ar);this.max_height=0;var af=Math.floor(ao/aj/P);var an=true;var aq=[];var ae=0;while((af*P*aj)<ak){tile=this.draw_helper(ag,ah,af,aj,ar,at);if(tile){aq.push(tile)}else{an=false}af+=1;ae++}var ai=this;if(an){ai.postdraw_actions(aq,ah,at,ap)}for(var al=0;al<this.child_tracks.length;al++){this.child_tracks[al].request_draw(ag,ap)}},postdraw_actions:function(ai,aj,ak,ae){var ag=this;var ah=false;for(var af=0;af<ai.length;af++){if(ai[af].message){ah=true;break}}if(ah){for(var af=0;af<ai.length;af++){tile=ai[af];if(!tile.message){tile.canvas.css("padding-top",D)}}}},draw_helper:function(af,ag,ah,ak,aq,av,ar,al){var ai=this,ap=this._gen_tile_cache_key(ag,av,ah),am=ah*P*ak,au=am+P*ak;var an=(af?undefined:ai.tile_cache.get(ap));if(an){ai.show_tile(an,aq,av);return an}var ao=function(aw){return("isResolved" in aw)};var aj=true;var ae=ai.data_manager.get_data(am,au,ai.mode,ak,ai.data_url_extra_params);if(ao(ae)){aj=false}var at;if(view.reference_track&&av>view.canvas_manager.char_width_px){at=view.reference_track.data_manager.get_data(am,au,ai.mode,ak,view.reference_track.data_url_extra_params);if(ao(at)){aj=false}}if(aj){p(ae,al);var an=ai.draw_tile(ae,ai.mode,ak,ah,av,at);ai.tile_cache.set(ap,an);if(an!==undefined){ai.show_tile(an,aq,av)}return an}$.when(ae,at).then(function(){view.request_redraw()});return null},show_tile:function(al,an,ao){var ag=this,af=al.canvas,ak=af;if(al.message){var ap=$("<div/>"),am=$("<div/>").addClass("tile-message").text(al.message).css({height:D-1,width:al.canvas.width}).appendTo(ap),ai=$("<a href='javascript:void(0);'/>").addClass("icon more-down").appendTo(am),ae=$("<a href='javascript:void(0);'/>").addClass("icon more-across").appendTo(am);ap.append(af);ak=ap;ai.click(function(){al.stale=true;ag.data_manager.get_more_data(al.low,al.high,ag.mode,al.resolution,{},ag.data_manager.DEEP_DATA_REQ);ag.request_draw()}).dblclick(function(aq){aq.stopPropagation()});ae.click(function(){al.stale=true;ag.data_manager.get_more_data(al.low,al.high,ag.mode,al.resolution,{},ag.data_manager.BROAD_DATA_REQ);ag.request_draw()}).dblclick(function(aq){aq.stopPropagation()})}var aj=this.view.high-this.view.low,ah=(al.low-this.view.low)*ao;if(this.left_offset){ah-=this.left_offset}ak.css({position:"absolute",top:0,left:ah,height:""});an.append(ak);ag.max_height=Math.max(ag.max_height,ak.height());ag.content_div.css("height",ag.max_height+"px");an.children().css("height",ag.max_height+"px")},_get_tile_bounds:function(ae,af){var ah=ae*P*af,ai=P*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(", ")+"]"},add_track:function(ae){ae.track_id=this.track_id+"_"+this.child_tracks.length;ae.container_div.attr("id","track_"+ae.track_id);this.child_tracks_container.append(ae.container_div);m(ae.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(ae);this.view.has_changes=true},remove_track:function(ae){ae.container_div.fadeOut("slow",function(){$(this).remove()})}});var aa=function(ae,af){this.hidden=true;j.call(this,null,ae,af);this.container_div.addClass("label-track")};p(aa.prototype,j.prototype,{_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 A=function(ae){this.hidden=true;j.call(this,null,ae,ae.top_labeltrack);L.call(this);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(B,this,false);this.tile_cache=new c(t)};p(A.prototype,L.prototype,{draw_tile:function(ao,ak,aj,af,ap){var ai=this,ag=P*aj;if(ap>this.view.canvas_manager.char_width_px){if(ao===null){ai.content_div.css("height","0px");return}var ah=this.view.canvas_manager.new_canvas();var an=ah.getContext("2d");ah.width=Math.ceil(ag*ap+ai.left_offset);ah.height=ai.height_px;an.font=an.canvas.manager.default_font;an.textAlign="center";for(var al=0,am=ao.length;al<am;al++){var ae=Math.round(al*ap);an.fillText(ao[al],ae+ai.left_offset,10)}return new b(af,aj,ah,ao)}this.content_div.css("height","0px")}});var k=function(ai,ag,aj,ae,ah){var af=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";j.call(this,ai,ag,ag.viewport_container);L.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=aj;this.dataset_id=ae;this.original_dataset_id=ae;this.data_manager=new Q(B,this);this.tile_cache=new c(t);this.left_offset=0;this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ai},{key:"color",label:"Color",type:"color",default_value:"black"},{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:ah,onchange:function(){af.set_name(af.prefs.name);af.vertical_range=af.prefs.max_value-af.prefs.min_value;$("#linetrack_"+af.track_id+"_minval").text(af.prefs.min_value);$("#linetrack_"+af.track_id+"_maxval").text(af.prefs.max_value);af.tile_cache.clear();af.request_draw()}});this.prefs=this.track_config.values;this.height_px=this.track_config.values.height;this.vertical_range=this.track_config.values.max_value-this.track_config.values.min_value;this.add_resize_handle()};p(k.prototype,L.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(){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.track_config.values.height=ae.height_px}).appendTo(ae.container_div)},predraw_init:function(){var ae=this,af=ae.view.tracks.indexOf(ae);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(ag){ae.container_div.addClass("line-track");var ai=ag.data;if(isNaN(parseFloat(ae.prefs.min_value))||isNaN(parseFloat(ae.prefs.max_value))){ae.prefs.min_value=ai.min;ae.prefs.max_value=ai.max;$("#track_"+af+"_minval").val(ae.prefs.min_value);$("#track_"+af+"_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_"+af+"_minval").text(w(ae.prefs.min_value));var ah=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+af+"_maxval").text(w(ae.prefs.max_value));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(aq,aj,ai,ag,ap){if(this.vertical_range===undefined){return}var ae=this._get_tile_bounds(ag,ai),ak=ae[0],ao=ae[1],af=Math.ceil((ao-ak)*ap),am=this.height_px;var ah=this.view.canvas_manager.new_canvas();ah.width=af,ah.height=am;var an=ah.getContext("2d");var al=new K.LinePainter(aq.data,ak,ao,this.prefs,aj);al.draw(an,af,am);return new b(ag,ai,ah,aq.data)}});var e=function(ae,aj,ai,am,al,ag,ah,ak){var af=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{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(){af.set_name(af.prefs.name);af.tile_cache.clear();af.request_draw()}});this.prefs=this.track_config.values;j.call(this,ae,aj,aj.viewport_container);L.call(this,ag,ah,ak);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=ai;this.dataset_id=am;this.original_dataset_id=am;this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.inc_slots={};this.start_end_dct={};this.tile_cache=new c(d);this.data_manager=new Q(20,this);this.left_offset=200;this.painter=K.LinkedFeaturePainter};p(e.prototype,L.prototype,{postdraw_actions:function(au,ae,av,at){L.prototype.postdraw_actions.call(this,au,at);var ah=this;if(at){var aj=ah.content_div.children();var ak=false;for(var ai=aj.length-1,ao=0;ai>=ao;ai--){var ag=$(aj[ai]);if(ak){ag.remove()}else{if(ag.children().length!==0){ak=true}}}}if(ah.mode=="Histogram"){var an=-1;for(var ai=0;ai<au.length;ai++){var ar=au[ai].max_val;if(ar>an){an=ar}}for(var ai=0;ai<au.length;ai++){var aq=au[ai];if(aq.max_val!==an){aq.canvas.remove();ah.draw_helper(true,ae,aq.index,aq.resolution,aq.canvas.parent(),av,[],{max:an})}}}if(ah.filters_manager){var af=ah.filters_manager.filters;for(var am=0;am<af.length;am++){af[am].update_ui_elt()}var al=false,ap;for(var ai=0;ai<au.length;ai++){if(au[ai].data.length){ap=au[ai].data[0];for(var am=0;am<af.length;am++){if(af[am].applies_to(ap)){al=true;break}}}}if(ah.filters_available!==al){ah.filters_available=al;if(!ah.filters_available){ah.filters_div.hide()}ah.make_name_popup_menu()}}},update_auto_mode:function(ae){if(this.mode=="Auto"){if(ae=="no_detail"){ae="feature spans"}else{if(ae=="summary_tree"){ae="coverage histogram"}}this.mode_div.text("Auto ("+ae+")")}},incremental_slots:function(ai,af,ah){var ag=this.view.canvas_manager.dummy_context,ae=this.inc_slots[ai];if(!ae||(ae.mode!==ah)){ae=new (r.FeatureSlotter)(ai,ah==="Pack",z,function(aj){return ag.measureText(aj)});ae.mode=ah;this.inc_slots[ai]=ae}return ae.slot_features(af)},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}},draw_tile:function(at,aw,aB,aF,ao,ah){var ay=this,aj=ay._get_tile_bounds(aF,aB),aH=aj[0],af=aj[1],av=af-aH,az=Math.ceil(av*ao),aL=25,ai=this.left_offset,au,ak;if(aw==="Auto"){if(at.dataset_type==="summary_tree"){aw=at.dataset_type}else{if(at.extra_info==="no_detail"){aw="no_detail"}else{var aK=at.data;if(this.view.high-this.view.low>H){aw="Squish"}else{aw="Pack"}}}this.update_auto_mode(aw)}if(aw==="summary_tree"||aw==="Histogram"){ak=this.summary_draw_height;this.container_div.find(".yaxislabel").remove();var ae=$("<div />").addClass("yaxislabel");ae.text(at.max);ae.css({position:"absolute",top:"24px",left:"10px",color:this.prefs.label_color});ae.prependTo(this.container_div);var ag=this.view.canvas_manager.new_canvas();ag.width=az+ai;ag.height=ak+R;if(at.dataset_type!="summary_tree"){var ap=this.get_summary_tree_data(at.data,aH,af,200);if(at.max){ap.max=at.max}at=ap}var aI=new K.SummaryTreePainter(at,aH,af,this.prefs);var aA=ag.getContext("2d");aA.translate(ai,R);aI.draw(aA,az,ak);return new l(aF,aB,ag,at.data,at.max)}var au,am=1;if(aw==="no_detail"||aw==="Squish"||aw==="Pack"){am=this.incremental_slots(ao,at.data,aw);au=this.inc_slots[ao].slots}var an=[];if(at.data){var aq=this.filters_manager.filters;for(var aC=0,aE=at.data.length;aC<aE;aC++){var al=at.data[aC];var aD=false;var ar;for(var aG=0,aJ=aq.length;aG<aJ;aG++){ar=aq[aG];ar.update_attrs(al);if(!ar.keep(al)){aD=true;break}}if(!aD){an.push(al)}}}var ax=(this.filters_manager.alpha_filter?new N(this.filters_manager.alpha_filter):null);var aI=new (this.painter)(an,aH,af,this.prefs,aw,ax,ah);var ak=Math.max(ac,aI.get_required_height(am));var ag=this.view.canvas_manager.new_canvas();ag.width=az+ai;ag.height=ak;var aA=ag.getContext("2d");aA.fillStyle=this.prefs.block_color;aA.font=aA.canvas.manager.default_font;aA.textAlign="right";this.container_div.find(".yaxislabel").remove();if(at.data){aA.translate(ai,0);aI.draw(aA,az,ak,au)}return new O(aF,aB,ag,at.data,at.message)}});var S=function(ah,af,aj,ae,ag,ai){e.call(this,ah,af,aj,ae,ag,ai);this.painter=K.VariantPainter};p(S.prototype,L.prototype,e.prototype);var V=function(ah,af,aj,ae,ag,ai){e.call(this,ah,af,aj,ae,ag,ai);this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ah},{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{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:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:ag,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.track_config.values;this.painter=K.ReadPainter;this.make_name_popup_menu()};p(V.prototype,L.prototype,e.prototype);var T=function(ai,ag,ak,ae,ah,aj,af){e.call(this,ai,ag,ak,ae,ah,aj,{},af);this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};p(T.prototype,L.prototype,e.prototype,{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=J;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()}});W.View=ab;W.DrawableCollection=y;W.LineTrack=k;W.FeatureTrack=e;W.ReadTrack=V};var slotting_module=function(c,b){var e=c("class").extend;var d=2,a=5;b.FeatureSlotter=function(j,h,f,g){this.slots={};this.start_end_dct={};this.w_scale=j;this.include_label=h;this.max_rows=f;this.measureText=g};e(b.FeatureSlotter.prototype,{slot_features:function(m){var p=this.w_scale,s=this.slots,h=this.start_end_dct,y=[],A=[],n=0,z=this.max_rows;for(var w=0,x=m.length;w<x;w++){var l=m[w],o=l[0];if(s[o]!==undefined){n=Math.max(n,s[o]);A.push(s[o])}else{y.push(w)}}var q=function(G,H){for(var F=0;F<=z;F++){var D=false,I=h[F];if(I!==undefined){for(var C=0,E=I.length;C<E;C++){var B=I[C];if(H>B[0]&&G<B[1]){D=true;break}}}if(!D){return F}}return -1};for(var w=0,x=y.length;w<x;w++){var l=m[y[w]],o=l[0],u=l[1],f=l[2],r=l[3],g=Math.floor(u*p),k=Math.ceil(f*p),v=this.measureText(r).width,j;if(r!==undefined&&this.include_label){v+=(d+a);if(g-v>=0){g-=v;j="left"}else{k+=v;j="right"}}var t=q(g,k);if(t>=0){if(h[t]===undefined){h[t]=[]}h[t].push([g,k]);s[o]=t;n=Math.max(n,t)}else{}}return n+1}})};var painters_module=function(k,x){var u=k("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 g=function(y){this.default_alpha=(y?y:1)};g.prototype.gen_alpha=function(y){return this.default_alpha};var n=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};n.prototype.default_prefs={};var v=function(A,C,y,z,B){n.call(this,A,C,y,z,B)};v.prototype.default_prefs={show_counts:false};v.prototype.draw=function(M,z,L){var E=this.view_start,O=this.view_end-this.view_start,N=z/O;var J=this.data.data,I=this.data.delta,G=this.data.max,B=L;delta_x_px=Math.ceil(I*N);M.save();for(var C=0,D=J.length;C<D;C++){var H=Math.floor((J[C][0]-E)*N);var F=J[C][1];if(!F){continue}var K=F/G*L;if(F!==0&&K<1){K=1}M.fillStyle=this.prefs.block_color;M.fillRect(H,B-K,delta_x_px,K);var A=4;if(this.prefs.show_counts&&(M.measureText(F).width+A)<delta_x_px){M.fillStyle=this.prefs.label_color;M.textAlign="center";M.fillText(F,H+(delta_x_px/2),10)}}M.restore()};var c=function(y,C,E,F,A){n.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}};c.prototype.default_prefs={min_value:undefined,max_value:undefined,mode:"Histogram",color:"#000",overflow_color:"#F66"};c.prototype.draw=function(N,M,K){var F=false,H=this.prefs.min_value,D=this.prefs.max_value,J=D-H,z=K,A=this.view_start,L=this.view_end-this.view_start,B=M/L,I=this.mode,T=this.data;N.save();var U=Math.round(K+H/J*K);if(I!=="Intensity"){N.fillStyle="#aaa";N.fillRect(0,U,M,1)}N.beginPath();var R,E,C;if(T.length>1){C=Math.ceil((T[1][0]-T[0][0])*B)}else{C=10}for(var O=0,P=T.length;O<P;O++){N.fillStyle=this.prefs.color;R=Math.round((T[O][0]-A)*B);E=T[O][1];var Q=false,G=false;if(E===null){if(F&&I==="Filled"){N.lineTo(R,z)}F=false;continue}if(E<H){G=true;E=H}else{if(E>D){Q=true;E=D}}if(I==="Histogram"){E=Math.round(E/J*z);N.fillRect(R,U,C,-E)}else{if(I==="Intensity"){E=255-Math.floor((E-H)/J*255);N.fillStyle="rgb("+E+","+E+","+E+")";N.fillRect(R,0,C,z)}else{E=Math.round(z-(E-H)/J*z);if(F){N.lineTo(R,E)}else{F=true;if(I==="Filled"){N.moveTo(R,z);N.lineTo(R,E)}else{N.moveTo(R,E)}}}}N.fillStyle=this.prefs.overflow_color;if(Q||G){var S;if(I==="Histogram"||I==="Intensity"){S=C}else{R-=2;S=4}if(Q){N.fillRect(R,0,S,3)}if(G){N.fillRect(R,z-3,S,3)}}N.fillStyle=this.prefs.color}if(I==="Filled"){if(F){N.lineTo(R,U);N.lineTo(0,U)}N.fill()}else{N.stroke()}N.restore()};var o=function(B,D,y,A,C,z){n.call(this,B,D,y,A,C);this.alpha_generator=(z?z:new g())};o.prototype.default_prefs={block_color:"#FFF",connector_color:"#FFF"};u(o.prototype,{get_required_height:function(z){var y=y_scale=this.get_row_height(),A=this.mode;if(A==="no_detail"||A==="Squish"||A==="Pack"){y=z*y_scale}return y+Math.max(Math.round(y_scale/2),5)},draw:function(K,B,J,G){var E=this.data,H=this.view_start,L=this.view_end;K.save();K.fillStyle=this.prefs.block_color;K.textAlign="right";var O=this.view_end-this.view_start,N=B/O,A=this.get_row_height();for(var D=0,F=E.length;D<F;D++){var M=E[D],C=M[0],y=M[1],z=M[2],I=(G&&G[C]!==undefined?G[C]:null);if((y<L&&z>H)&&(this.mode=="Dense"||I!==null)){this.draw_element(K,this.mode,M,I,H,L,N,A,B)}}K.restore()},draw_element:function(E,A,G,C,B,D,F,z,y){console.log("WARNING: Unimplemented function.")}});var d=10,j=3,m=5,w=10,f=1,s=3,e=3,a=9,l=2,h="#ccc";var r=function(B,D,y,A,C,z){o.call(this,B,D,y,A,C,z)};u(r.prototype,o.prototype,{get_row_height:function(){var z=this.mode,y;if(z==="Dense"){y=d}else{if(z==="no_detail"){y=j}else{if(z==="Squish"){y=m}else{y=w}}}return y},draw_element:function(K,D,S,F,M,ac,ag,ah,y){var P=S[0],ae=S[1],W=S[2],N=S[3],X=Math.floor(Math.max(0,(ae-M)*ag)),L=Math.ceil(Math.min(y,Math.max(0,(W-M)*ag))),V=(D==="Dense"?0:(0+F))*ah,J,aa,O=null,ai=null,B=this.prefs.block_color,Z=this.prefs.label_color;K.globalAlpha=this.alpha_generator.gen_alpha(S);if(D=="Dense"){F=1}if(D==="no_detail"){K.fillStyle=B;K.fillRect(X,V+5,L-X,f)}else{var I=S[4],U=S[5],Y=S[6],C=S[7];if(U&&Y){O=Math.floor(Math.max(0,(U-M)*ag));ai=Math.ceil(Math.min(y,Math.max(0,(Y-M)*ag)))}var af,Q;if(D==="Squish"||D==="Dense"){af=1;Q=e}else{af=5;Q=a}if(!C){if(S.strand){if(S.strand==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand_inv")}else{if(S.strand==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand_inv")}}}else{K.fillStyle=B}K.fillRect(X,V,L-X,Q)}else{var H,R;if(D==="Squish"||D==="Dense"){K.fillStyle=h;H=V+Math.floor(e/2)+1;R=1}else{if(I){var H=V;var R=Q;if(I==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand")}else{if(I==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand")}}}else{K.fillStyle=h;H+=(e/2)+1;R=1}}K.fillRect(X,H,L-X,R);for(var ad=0,A=C.length;ad<A;ad++){var E=C[ad],z=Math.floor(Math.max(0,(E[0]-M)*ag)),T=Math.ceil(Math.min(y,Math.max((E[1]-M)*ag)));if(z>T){continue}K.fillStyle=B;K.fillRect(z,V+(Q-af)/2+1,T-z,af);if(O!==undefined&&Y>U&&!(z>ai||T<O)){var ab=Math.max(z,O),G=Math.min(T,ai);K.fillRect(ab,V+1,G-ab,Q);if(C.length==1&&D=="Pack"){if(I==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand_inv")}else{if(I==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand_inv")}}if(ab+14<G){ab+=2;G-=2}K.fillRect(ab,V+1,G-ab,Q)}}}}if(D==="Pack"&&ae>M){K.fillStyle=Z;if(M===0&&X-K.measureText(N).width<0){K.textAlign="left";K.fillText(N,L+l,V+8)}else{K.textAlign="right";K.fillText(N,X-l,V+8)}}}K.globalAlpha=1}});var b=function(B,D,y,A,C,z){o.call(this,B,D,y,A,C,z)};u(b.prototype,o.prototype,{draw_element:function(R,M,G,C,U,A,J,S,P){var G=data[i],I=G[0],Q=G[1],B=G[2],L=G[3],E=Math.floor(Math.max(0,(Q-U)*J)),H=Math.ceil(Math.min(P,Math.max(0,(B-U)*J))),D=(M==="Dense"?0:(0+C))*S,y,V,z=null,K=null;if(no_label){R.fillStyle=block_color;R.fillRect(E+left_offset,D+5,H-E,1)}else{var T=G[4],O=G[5],F=G[6];y=9;V=1;R.fillRect(E+left_offset,D,H-E,y);if(M!=="Dense"&&L!==undefined&&Q>U){R.fillStyle=label_color;if(U===0&&E-R.measureText(L).width<0){R.textAlign="left";R.fillText(L,H+2+left_offset,D+8)}else{R.textAlign="right";R.fillText(L,E-2+left_offset,D+8)}R.fillStyle=block_color}var N=T+" / "+O;if(Q>U&&R.measureText(N).width<(H-E)){R.fillStyle="white";R.textAlign="center";R.fillText(N,left_offset+E+(H-E)/2,D+8);R.fillStyle=block_color}}}});var t=function(C,E,y,B,D,z,A){o.call(this,C,E,y,B,D,z);this.ref_seq=A};t.prototype.default_prefs=u({},o.prototype.default_prefs,{show_insertions:false});u(t.prototype,o.prototype,{get_row_height:function(){var y,z=this.mode;if(z==="Dense"){y=d}else{if(z==="Squish"){y=m}else{y=w;if(this.prefs.show_insertions){y*=2}}}return y},draw_read:function(U,P,L,Z,A,T,I,F,E){U.textAlign="center";var S=this,z=[Z,A],O=0,V=0,R=0;ref_seq=this.ref_seq,char_width_px=U.canvas.manager.char_width_px;var ae=[];if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){R=Math.round(L/2)}if(!I){I=[[0,F.length]]}for(var M=0,X=I.length;M<X;M++){var J=I[M],B="MIDNSHP=X"[J[0]],N=J[1];if(B==="H"||B==="S"){O-=N}var G=T+O,ad=Math.floor(Math.max(0,(G-Z)*L)),H=Math.floor(Math.max(0,(G+N-Z)*L));if(ad===H){H+=1}switch(B){case"H":break;case"S":case"M":case"=":if(is_overlap([G,G+N],z)){var Q=F.slice(V,V+N);if(R>0){U.fillStyle=this.prefs.block_color;U.fillRect(ad-R,E+1,H-ad,9);U.fillStyle=h;for(var ab=0,y=Q.length;ab<y;ab++){if(this.prefs.show_differences&&ref_seq){var K=ref_seq[G-Z+ab];if(!K||K.toLowerCase()===Q[ab].toLowerCase()){continue}}if(G+ab>=Z&&G+ab<=A){var ac=Math.floor(Math.max(0,(G+ab-Z)*L));U.fillText(Q[ab],ac,E+9)}}}else{U.fillStyle=this.prefs.block_color;U.fillRect(ad,E+4,H-ad,e)}}V+=N;O+=N;break;case"N":U.fillStyle=h;U.fillRect(ad-R,E+5,H-ad,1);O+=N;break;case"D":U.fillStyle="red";U.fillRect(ad-R,E+4,H-ad,3);O+=N;break;case"P":break;case"I":var Y=ad-R;if(is_overlap([G,G+N],z)){var Q=F.slice(V,V+N);if(this.prefs.show_insertions){var D=ad-(H-ad)/2;if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){U.fillStyle="yellow";U.fillRect(D-R,E-9,H-ad,9);ae[ae.length]={type:"triangle",data:[Y,E+4,5]};U.fillStyle=h;switch(seq_tile_overlap){case (OVERLAP_START):Q=Q.slice(Z-G);break;case (OVERLAP_END):Q=Q.slice(0,G-A);break;case (CONTAINED_BY):break;case (CONTAINS):Q=Q.slice(Z-G,G-A);break}for(var ab=0,y=Q.length;ab<y;ab++){var ac=Math.floor(Math.max(0,(G+ab-Z)*L));U.fillText(Q[ab],ac-(H-ad)/2,E)}}else{U.fillStyle="yellow";U.fillRect(D,E+(this.mode!=="Dense"?2:5),H-ad,(P!=="Dense"?e:s))}}else{if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){ae[ae.length]={type:"text",data:[Q.length,Y,E+9]}}else{}}}V+=N;break;case"X":V+=N;break}}U.fillStyle="yellow";var aa,C,af;for(var W=0;W<ae.length;W++){aa=ae[W];C=aa.type;af=aa.data;if(C==="text"){U.save();U.font="bold "+U.font;U.fillText(af[0],af[1],af[2]);U.restore()}else{if(C=="triangle"){q(U,af[0],af[1],af[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,V=this.prefs.block_color,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)}R.fillStyle=V;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,U,z,E[4][0],E[4][2],E[4][3],C)}if(E[5][1]>=U&&E[5][0]<=z&&E[5][2]){this.draw_read(R,M,I,U,z,E[5][0],E[5][2],E[5][3],C)}if(K>L){R.fillStyle=h;p(R,L-O,C+5,K-O,C+5)}}else{R.fillStyle=V;this.draw_read(R,M,I,U,z,Q,E[4],E[5],C)}if(M==="Pack"&&Q>U){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+l-O,C+8)}else{R.textAlign="right";R.fillText(J,D-l-O,C+8)}R.fillStyle=V}}});x.AlphaGenerator=g;x.SummaryTreePainter=v;x.LinePainter=c;x.LinkedFeaturePainter=r;x.ReadPainter=t;x.VariantPainter=b};(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.