1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/4f992059bfeb/ changeset: 4f992059bfeb user: jgoecks date: 2011-08-25 17:37:07 summary: Trackster: treat numbers as floats when dynamically filtering. Pack scripts. affected #: 3 files (26 bytes)
--- a/static/scripts/packed/trackster.js Thu Aug 25 11:28:01 2011 -0400 +++ b/static/scripts/packed/trackster.js Thu Aug 25 11:37:07 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,U){var n=f("class").extend,p=f("slotting"),I=f("painters");var ab=function(ac,ad){this.document=ac;this.default_font=ad!==undefined?ad:"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")};n(ab.prototype,{load_pattern:function(ac,ag){var ad=this.patterns,ae=this.dummy_context,af=new Image();af.src=image_path+ag;af.onload=function(){ad[ac]=ae.createPattern(af,"repeat")}},get_pattern:function(ac){return this.patterns[ac]},new_canvas:function(){var ac=this.document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(ac)}ac.manager=this;return ac}});var C=function(ac,ad){ac.bind("drag",{handle:ad,relative:true},function(ah,ai){var ag=$(this).parent();var af=ag.children();var ae;for(ae=0;ae<af.length;ae++){if(ai.offsetY<$(af.get(ae)).position().top){break}}if(ae===af.length){if(this!==af.get(ae-1)){ag.append(this)}}else{if(this!==af.get(ae)){$(this).insertBefore(af.get(ae))}}}).bind("dragstart",function(){$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css("border","0px")})};U.sortable=C;var aa=16,D=9,A=20,P=D+2,w=100,F=12000,N=200,z=5,s=10,H=5000,t=100,m="There was an error in indexing this dataset. ",G="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",B="No data for this chrom/contig.",q="Currently indexing... please wait",v="Tool cannot be rerun: ",a="Loading data...",V="Ready for display",d=10,r=5,y=5;function u(ac){return Math.round(ac*1000)/1000}var c=function(ac){this.num_elements=ac;this.clear()};n(c.prototype,{get:function(ad){var ac=this.key_ary.indexOf(ad);if(ac!==-1){if(this.obj_cache[ad].stale){this.key_ary.splice(ac,1);delete this.obj_cache[ad]}else{this.move_key_to_end(ad,ac)}}return this.obj_cache[ad]},set:function(ad,ae){if(!this.obj_cache[ad]){if(this.key_ary.length>=this.num_elements){var ac=this.key_ary.shift();delete this.obj_cache[ac]}this.key_ary.push(ad)}this.obj_cache[ad]=ae;return ae},move_key_to_end:function(ad,ac){this.key_ary.splice(ac,1);this.key_ary.push(ad)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var O=function(ad,ac,ae){c.call(this,ad);this.track=ac;this.subset=(ae!==undefined?ae:true)};n(O.prototype,c.prototype,{load_data:function(al,ag,aj,ad,ai){var ak=this.track.view.chrom,af={chrom:ak,low:al,high:ag,mode:aj,resolution:ad,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(af,ai);if(this.track.filters_manager){var am=[];var ac=this.track.filters_manager.filters;for(var ah=0;ah<ac.length;ah++){am[am.length]=ac[ah].name}af.filter_cols=JSON.stringify(am)}var ae=this;return $.getJSON(this.track.data_url,af,function(an){ae.set_data(al,ag,aj,an)})},get_data:function(ac,ag,ah,ad,af){var ae=this.get_data_from_cache(ac,ag,ah);if(ae){return ae}ae=this.load_data(ac,ag,ah,ad,af);this.set_data(ac,ag,ah,ae);return ae},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(ak,af,aj,ae,ai,ag){var al=this.get_data_from_cache(ak,af,aj);if(!al){console.log("ERROR: no current data for: ",this.track,ak,af,aj,ae,ai);return}al.stale=true;var ad=ak;if(ag===this.DEEP_DATA_REQ){$.extend(ai,{start_val:al.data.length+1})}else{if(ag===this.BROAD_DATA_REQ){ad=al.data[al.data.length-1][2]+1}}var ac=this,ah=this.load_data(ad,af,aj,ae,ai);new_data_available=$.Deferred();this.set_data(ak,af,aj,new_data_available);$.when(ah).then(function(am){if(am.data){am.data=al.data.concat(am.data);if(am.message){am.message=am.message.replace(/[0-9]+/,am.data.length)}}ac.set_data(ak,af,aj,am);new_data_available.resolve(am)});return new_data_available},get_data_from_cache:function(ac,ad,ae){return this.get(this.gen_key(ac,ad,ae))},set_data:function(ad,ae,af,ac){return this.set(this.gen_key(ad,ae,af),ac)},gen_key:function(ac,ae,af){var ad=ac+"_"+ae+"_"+af;return ad},split_key:function(ac){return ac.split("_")}});var E=function(ad,ac,ae){O.call(this,ad,ac,ae)};n(E.prototype,O.prototype,c.prototype,{load_data:function(ae,ac,ag,ah,ad,af){if(ad>1){return}return O.prototype.load_data.call(this,ae,ac,ag,ah,ad,af)}});var Z=function(ac,af,ae,ad,ag){this.container=ac;this.chrom=null;this.vis_id=ae;this.dbkey=ad;this.title=af;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(ag);this.canvas_manager=new ab(ac.get(0).ownerDocument);this.reset()};n(Z.prototype,{init:function(ag){var ae=this.container,ac=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ae);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ae);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ae);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 af=$("<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 ad=function(ah){if(ah.type==="focusout"||(ah.keyCode||ah.which)===13||(ah.keyCode||ah.which)===27){if((ah.keyCode||ah.which)!==27){ac.go_to($(this).val())}$(this).hide();$(this).val("");ac.location_span.show();ac.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",ad).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").appendTo(this.nav_controls);this.location_span.click(function(){ac.location_span.hide();ac.chrom_select.hide();ac.nav_input.val(ac.chrom+":"+ac.low+"-"+ac.high);ac.nav_input.css("display","inline-block");ac.nav_input.select();ac.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(){ac.zoom_out();ac.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){ac.zoom_in();ac.request_redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},ag);this.chrom_select.bind("change",function(){ac.change_chrom(ac.chrom_select.val())});this.content_div.click(function(ah){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(ah){ac.zoom_in(ah.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ah,ai){this.current_x=ai.offsetX}).bind("drag",function(ah,aj){var ak=aj.offsetX-this.current_x;this.current_x=aj.offsetX;var ai=Math.round(ak/ac.viewport_container.width()*(ac.max_high-ac.max_low));ac.move_delta(-ai)});this.overview_close.click(function(){ac.reset_overview()});this.viewport_container.bind("draginit",function(ah,ai){if(ah.clientX>ac.viewport_container.width()-16){return false}}).bind("dragstart",function(ah,ai){ai.original_low=ac.low;ai.current_height=ah.clientY;ai.current_x=ai.offsetX}).bind("drag",function(aj,al){var ah=$(this);var am=al.offsetX-al.current_x;var ai=ah.scrollTop()-(aj.clientY-al.current_height);ah.scrollTop(ai);al.current_height=aj.clientY;al.current_x=al.offsetX;var ak=Math.round(am/ac.viewport_container.width()*(ac.high-ac.low));ac.move_delta(ak)}).bind("mousewheel",function(aj,al,ai,ah){if(ai){var ak=Math.round(-ai/ac.viewport_container.width()*(ac.high-ac.low));ac.move_delta(ak)}});this.top_labeltrack.bind("dragstart",function(ah,ai){return $("<div />").css({height:ac.content_div.height()+ac.top_labeltrack.height()+ac.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(al,am){$(am.proxy).css({left:Math.min(al.pageX,am.startX),width:Math.abs(al.pageX-am.startX)});var ai=Math.min(al.pageX,am.startX)-ac.container.offset().left,ah=Math.max(al.pageX,am.startX)-ac.container.offset().left,ak=(ac.high-ac.low),aj=ac.viewport_container.width();ac.update_location(Math.round(ai/aj*ak)+ac.low,Math.round(ah/aj*ak)+ac.low)}).bind("dragend",function(am,an){var ai=Math.min(am.pageX,an.startX),ah=Math.max(am.pageX,an.startX),ak=(ac.high-ac.low),aj=ac.viewport_container.width(),al=ac.low;ac.low=Math.round(ai/aj*ak)+al;ac.high=Math.round(ah/aj*ak)+al;$(an.proxy).remove();ac.request_redraw()});this.add_label_track(new Y(this,this.top_labeltrack));this.add_label_track(new Y(this,this.nav_labeltrack));$(window).bind("resize",function(){ac.resize_window()});$(document).bind("redraw",function(){ac.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(ac,ad){this.location_span.text(commatize(ac)+" - "+commatize(ad));this.nav_input.val(this.chrom+":"+commatize(ac)+"-"+commatize(ad))},load_chroms:function(ad,ae){ad.num=t;$.extend(ad,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var ac=this;$.ajax({url:chrom_url,data:ad,dataType:"json",success:function(ag){if(ag.chrom_info.length===0){alert("Invalid chromosome: "+ad.chrom);return}if(ag.reference){ac.add_label_track(new x(ac))}ac.chrom_data=ag.chrom_info;var aj='<option value="">Select Chrom/Contig</option>';for(var ai=0,af=ac.chrom_data.length;ai<af;ai++){var ah=ac.chrom_data[ai].chrom;aj+='<option value="'+ah+'">'+ah+"</option>"}if(ag.prev_chroms){aj+='<option value="previous">Previous '+t+"</option>"}if(ag.next_chroms){aj+='<option value="next">Next '+t+"</option>"}ac.chrom_select.html(aj);if(ae){ae()}ac.chrom_start_index=ag.start_index},error:function(){alert("Could not load chroms for this dbkey:",ac.dbkey)}})},change_chrom:function(ag,ad,ai){if(!ag||ag==="None"){return}var af=this;if(ag==="previous"){af.load_chroms({low:this.chrom_start_index-t});return}if(ag==="next"){af.load_chroms({low:this.chrom_start_index+t});return}var ah=$.grep(af.chrom_data,function(ak,al){return ak.chrom===ag})[0];if(ah===undefined){af.load_chroms({chrom:ag},function(){af.change_chrom(ag,ad,ai)});return}else{if(ag!==af.chrom){af.chrom=ag;af.chrom_select.val(af.chrom);af.max_high=ah.len-1;af.reset();af.request_redraw(true);for(var aj=0,ac=af.tracks.length;aj<ac;aj++){var ae=af.tracks[aj];if(ae.init){ae.init()}}}if(ad!==undefined&&ai!==undefined){af.low=Math.max(ad,0);af.high=Math.min(ai,af.max_high)}af.reset_overview();af.request_redraw()}},go_to:function(ag){var ak=this,ac,af,ad=ag.split(":"),ai=ad[0],aj=ad[1];if(aj!==undefined){try{var ah=aj.split("-");ac=parseInt(ah[0].replace(/,/g,""),10);af=parseInt(ah[1].replace(/,/g,""),10)}catch(ae){return false}}ak.change_chrom(ai,ac,af)},move_fraction:function(ae){var ac=this;var ad=ac.high-ac.low;this.move_delta(ae*ad)},move_delta:function(ae){var ac=this;var ad=ac.high-ac.low;if(ac.low-ae<ac.max_low){ac.low=ac.max_low;ac.high=ac.max_low+ad}else{if(ac.high-ae>ac.max_high){ac.high=ac.max_high;ac.low=ac.max_high-ad}else{ac.high-=ae;ac.low-=ae}}ac.request_redraw()},add_track:function(ac){ac.view=this;ac.track_id=this.track_id_counter;this.tracks.push(ac);if(ac.init){ac.init()}ac.container_div.attr("id","track_"+ac.track_id);C(ac.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1;this.update_intro_div()},add_label_track:function(ac){ac.view=this;this.label_tracks.push(ac)},remove_track:function(ad){this.has_changes=true;delete this.tracks[this.tracks.indexOf(ad)];this.num_tracks-=1;var ac=this;ad.container_div.fadeOut("slow",function(){$(this).remove();ac.update_intro_div()})},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(ak,ac,aj,ad){var ai=this,ag=(ad?[ad]:ai.tracks),ae;var ad;for(var ah=0;ah<ag.length;ah++){ad=ag[ah];ae=-1;for(var af=0;af<ai.tracks_to_be_redrawn.length;af++){if(ai.tracks_to_be_redrawn[af][0]===ad){ae=af;break}}if(ae<0){ai.tracks_to_be_redrawn.push([ad,ac,aj])}else{ai.tracks_to_be_redrawn[ah][1]=ac;ai.tracks_to_be_redrawn[ah][2]=aj}}requestAnimationFrame(function(){ai._redraw(ak)})},_redraw:function(am){var aj=this.low,af=this.high;if(aj<this.max_low){aj=this.max_low}if(af>this.max_high){af=this.max_high}var al=this.high-this.low;if(this.high!==0&&al<this.min_separation){af=aj+this.min_separation}this.low=Math.floor(aj);this.high=Math.ceil(af);this.resolution=Math.pow(z,Math.ceil(Math.log((this.high-this.low)/N)/Math.log(z)));this.zoom_res=Math.pow(s,Math.max(0,Math.ceil(Math.log(this.resolution,s)/Math.log(s))));var ac=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ai=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var an=13;this.overview_box.css({left:ac,width:Math.max(an,ai)}).show();if(ai<an){this.overview_box.css("left",ac-(an-ai)/2)}if(this.overview_highlight){this.overview_highlight.css({left:ac,width:ai})}this.update_location(this.low,this.high);if(!am){var ae,ad,ak;for(var ag=0,ah=this.tracks_to_be_redrawn.length;ag<ah;ag++){ae=this.tracks_to_be_redrawn[ag][0];ad=this.tracks_to_be_redrawn[ag][1];ak=this.tracks_to_be_redrawn[ag][2];if(ae&&ae.enabled){ae._draw(ad,ak)}}this.tracks_to_be_redrawn=[];for(ag=0,ah=this.label_tracks.length;ag<ah;ag++){this.label_tracks[ag]._draw()}}},zoom_in:function(ad,ae){if(this.max_high===0||this.high-this.low<this.min_separation){return}var af=this.high-this.low,ag=af/2+this.low,ac=(af/this.zoom_factor)/2;if(ad){ag=ad/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ag-ac);this.high=Math.round(ag+ac);this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var ad=this.high-this.low,ae=ad/2+this.low,ac=(ad*this.zoom_factor)/2;this.low=Math.round(ae-ac);this.high=Math.round(ae+ac);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(ac){$.when(ac.get_overview_tile()).then(function(ad){view.overview_viewport.find(".track-tile").remove();view.overview_close.show();view.overview_viewport.append(ad.canvas);view.overview_highlight.show().height(ad.canvas.height());view.overview_viewport.height(ad.canvas.height()+view.overview_box.outerHeight());view.resize_window();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=ac;view.has_changes=true;ac.set_is_overview(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 o=function(ae,ai){this.track=ae;this.name=ai.name;this.params=[];var ap=ai.params;for(var af=0;af<ap.length;af++){var ak=ap[af],ad=ak.name,ao=ak.label,ag=unescape(ak.html),aq=ak.value,am=ak.type;if(am==="number"){this.params[this.params.length]=new g(ad,ao,ag,aq,ak.min,ak.max)}else{if(am=="select"){this.params[this.params.length]=new K(ad,ao,ag,aq)}else{console.log("WARNING: unrecognized tool parameter type:",ad,am)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(at){at.stopPropagation()}).click(function(at){at.stopPropagation()}).bind("dblclick",function(at){at.stopPropagation()});var an=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var al=this.params;var aj=this;$.each(this.params,function(au,ax){var aw=$("<div>").addClass("param-row").appendTo(aj.parent_div);var at=$("<div>").addClass("param-label").text(ax.label).appendTo(aw);var av=$("<div/>").addClass("slider").html(ax.html).appendTo(aw);av.find(":input").val(ax.value);$("<div style='clear: both;'/>").appendTo(aw)});this.parent_div.find("input").click(function(){$(this).select()});var ar=$("<div>").addClass("param-row").appendTo(this.parent_div);var ah=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(ar);var ac=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(ar);var aj=this;ac.click(function(){aj.run_on_region()});ah.click(function(){aj.run_on_dataset()})};n(o.prototype,{get_param_values_dict:function(){var ac={};this.parent_div.find(":input").each(function(){var ad=$(this).attr("name"),ae=$(this).val();ac[ad]=JSON.stringify(ae)});return ac},get_param_values:function(){var ad=[];var ac={};this.parent_div.find(":input").each(function(){var ae=$(this).attr("name"),af=$(this).val();if(ae){ad[ad.length]=af}});return ad},run_on_dataset:function(){var ac=this;ac.run({dataset_id:this.track.original_dataset_id,tool_id:ac.name},null,function(ad){show_modal(ac.name+" is Running",ac.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var ac={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},ae=this.track,ad=ac.tool_id+ae.tool_region_and_parameters_str(ac.chrom,ac.low,ac.high),af;if(ae instanceof e){af=new R(ad,view,ae.hda_ldda,undefined,{},{},ae);af.change_mode(ae.mode)}this.track.add_track(af);af.content_div.text("Starting job.");this.run(ac,af,function(ag){af.dataset_id=ag.dataset_id;af.content_div.text("Running job.");af.init()})},run:function(ad,ae,af){$.extend(ad,this.get_param_values_dict());var ac=function(){$.getJSON(rerun_tool_url,ad,function(ag){if(ag==="no converter"){ae.container_div.addClass("error");ae.content_div.text(G)}else{if(ag.error){ae.container_div.addClass("error");ae.content_div.text(v+ag.message)}else{if(ag==="pending"){ae.container_div.addClass("pending");ae.content_div.text("Converting input data so that it can be used quickly with tool.");setTimeout(ac,2000)}else{af(ag)}}}})};ac()}});var K=function(ad,ac,ae,af){this.name=ad;this.label=ac;this.html=ae;this.value=af};var g=function(ae,ad,ag,ah,af,ac){K.call(this,ae,ad,ag,ah);this.min=af;this.max=ac};var h=function(ad,ac,ae,af){this.name=ad;this.index=ac;this.tool_id=ae;this.tool_exp_name=af};var S=function(ad,ac,ae,af){h.call(this,ad,ac,ae,af);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};n(S.prototype,{applies_to:function(ac){if(ac.length>this.index){return true}return false},keep:function(ac){if(!this.applies_to(ac)){return true}var ad=parseInt(ac[this.index]);return(isNaN(ad)||(ad>=this.low&&ad<=this.high))},update_attrs:function(ad){var ac=false;if(!this.applies_to(ad)){return ac}if(ad[this.index]<this.min){this.min=Math.floor(ad[this.index]);ac=true}if(ad[this.index]>this.max){this.max=Math.ceil(ad[this.index]);ac=true}return ac},update_ui_elt:function(){if(this.min!=this.max){this.container.show()}else{this.container.hide()}var ae=function(ah,af){var ag=af-ah;return(ag<=2?0.01:1)};var ad=this.slider.slider("option","min"),ac=this.slider.slider("option","max");if(this.min<ad||this.max>ac){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",ae(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var X=function(am,at){this.track=am;this.filters=[];for(var an=0;an<at.length;an++){var ao=at[an],au=ao.name,ac=ao.type,af=ao.index,ar=ao.tool_id,aq=ao.tool_exp_name;if(ac==="int"||ac==="float"){this.filters[an]=new S(au,af,ar,aq)}else{console.log("ERROR: unsupported filter: ",au,ac)}}var ag=function(av,aw,ax){av.click(function(){var ay=aw.text();max=parseFloat(ax.slider("option","max")),input_size=(max<=1?4:max<=1000000?max.toString().length:6),multi_value=false;if(ax.slider("option","values")){input_size=2*input_size+1;multi_value=true}aw.text("");$("<input type='text'/>").attr("size",input_size).attr("maxlength",input_size).attr("value",ay).appendTo(aw).focus().select().click(function(az){az.stopPropagation()}).blur(function(){$(this).remove();aw.text(ay)}).keyup(function(aD){if(aD.keyCode===27){$(this).trigger("blur")}else{if(aD.keyCode===13){var aB=ax.slider("option","min"),az=ax.slider("option","max"),aC=function(aE){return(isNaN(aE)||aE>az||aE<aB)},aA=$(this).val();if(!multi_value){aA=parseFloat(aA);if(aC(aA)){alert("Parameter value must be in the range ["+aB+"-"+az+"]");return $(this)}}else{aA=aA.split("-");aA=[parseFloat(aA[0]),parseFloat(aA[1])];if(aC(aA[0])||aC(aA[1])){alert("Parameter value must be in the range ["+aB+"-"+az+"]");return $(this)}}ax.slider((multi_value?"values":"value"),aA)}}})})};this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(av){av.stopPropagation()}).click(function(av){av.stopPropagation()}).bind("dblclick",function(av){av.stopPropagation()}).bind("keydown",function(av){av.stopPropagation()});var ap=$("<div/>").addClass("sliders").appendTo(this.parent_div);var ak=this;$.each(this.filters,function(ay,aA){aA.container=$("<div/>").addClass("slider-row").appendTo(ap);var az=$("<div/>").addClass("elt-label").appendTo(aA.container);var ax=$("<span/>").addClass("slider-name").text(aA.name+" ").appendTo(az);var aw=$("<span/>");var aC=$("<span/>").addClass("slider-value").appendTo(az).append("[").append(aw).append("]");var av=$("<div/>").addClass("slider").appendTo(aA.container);aA.control_element=$("<div/>").attr("id",aA.name+"-filter-control").appendTo(av);var aB=[0,0];aA.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(aE,aF){var aD=aF.values;aw.text(aD[0]+"-"+aD[1]);aA.low=aD[0];aA.high=aD[1];ak.track.request_draw(true,true)},change:function(aD,aE){aA.control_element.slider("option","slide").call(aA.control_element,aD,aE)}});aA.slider=aA.control_element;aA.slider_label=aw;ag(aC,aw,aA.control_element);$("<div style='clear: both;'/>").appendTo(aA.container)});if(this.filters.length!==0){var ah=$("<div/>").addClass("param-row").appendTo(ap);var aj=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(ah);var ae=this;aj.click(function(){ae.run_on_dataset()})}var al=$("<div/>").addClass("display-controls").appendTo(this.parent_div),ai=$("<span/>").addClass("elt-label").text("Transparency:").appendTo(al),ad=$("<select/>").attr("name","alpha_dropdown").appendTo(al);this.alpha_filter=null;$("<option/>").attr("value",-1).text("== None ==").appendTo(ad);for(var an=0;an<this.filters.length;an++){$("<option/>").attr("value",an).text(this.filters[an].name).appendTo(ad)}ad.change(function(){$(this).children("option:selected").each(function(){var av=parseInt($(this).val());ak.alpha_filter=(av>=0?ak.filters[av]:null);ak.track.request_draw(true,true)})});$("<div style='clear: both;'/>").appendTo(this.parent_div)};n(X.prototype,{reset_filters:function(){for(var ac=0;ac<this.filters.length;ac++){filter=this.filters[ac];filter.slider.slider("option","values",[filter.min,filter.max])}this.alpha_filter=null},run_on_dataset:function(){var ak=function(ao,am,an){if(!(am in ao)){ao[am]=an}return ao[am]};var ae={},ac,ad,af;for(var ag=0;ag<this.filters.length;ag++){ac=this.filters[ag];if(ac.tool_id){if(ac.min!=ac.low){ad=ak(ae,ac.tool_id,[]);ad[ad.length]=ac.tool_exp_name+" >= "+ac.low}if(ac.max!=ac.high){ad=ak(ae,ac.tool_id,[]);ad[ad.length]=ac.tool_exp_name+" <= "+ac.high}}}var ai=[];for(var al in ae){ai[ai.length]=[al,ae[al]]}var aj=ai.length;(function ah(at,ap){var an=ap[0],ao=an[0],ar=an[1],aq="("+ar.join(") and (")+")",am={cond:aq,input:at,target_dataset_id:at,tool_id:ao},ap=ap.slice(1);$.getJSON(run_tool_url,am,function(au){if(au.error){show_modal("Filter Dataset","Error running tool "+ao,{Close:hide_modal})}else{if(ap.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{ah(au.dataset_id,ap)}}})})(this.track.dataset_id,ai)}});var L=function(ad,ac){I.AlphaGenerator.call(this,ac);this.filter=ad};L.prototype.gen_alpha=function(ac){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(ac[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var W=function(ac){this.track=ac.track;this.params=ac.params;this.values={};if(ac.saved_values){this.restore_values(ac.saved_values)}this.onchange=ac.onchange};n(W.prototype,{restore_values:function(ac){var ad=this;$.each(this.params,function(ae,af){if(ac[af.key]!==undefined){ad.values[af.key]=ac[af.key]}else{ad.values[af.key]=af.default_value}})},build_form:function(){var ad=this;var ac=$("<div />");$.each(this.params,function(ah,af){if(!af.hidden){var ae="param_"+ah;var am=$("<div class='form-row' />").appendTo(ac);am.append($("<label />").attr("for",ae).text(af.label+":"));if(af.type==="bool"){am.append($('<input type="checkbox" />').attr("id",ae).attr("name",ae).attr("checked",ad.values[af.key]))}else{if(af.type==="color"){var aj=ad.values[af.key];var ai=$("<input />").attr("id",ae).attr("name",ae).val(aj);var ak=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var ag=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(ak);var al=$("<div/>").appendTo(ag).farbtastic({width:100,height:100,callback:ai,color:aj});$("<div />").append(ai).append(ak).appendTo(am).bind("click",function(an){ak.css({left:$(this).position().left+($(ai).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){ak.hide();$(document).unbind("click.color-picker")});an.stopPropagation()})}else{am.append($("<input />").attr("id",ae).attr("name",ae).val(ad.values[af.key]))}}}});return ac},update_from_form:function(ac){var ae=this;var ad=false;$.each(this.params,function(af,ah){if(!ah.hidden){var ai="param_"+af;var ag=ac.find("#"+ai).val();if(ah.type==="float"){ag=parseFloat(ag)}else{if(ah.type==="int"){ag=parseInt(ag)}else{if(ah.type==="bool"){ag=ac.find("#"+ai).is(":checked")}}}if(ag!==ae.values[ah.key]){ae.values[ah.key]=ag;ad=true}}});if(ad){this.onchange()}}});var b=function(ae,ad,ac,af){this.index=ae;this.low=ae*N*ad;this.high=(ae+1)*N*ad;this.resolution=ad;this.canvas=$("<div class='track-tile'/>").append(ac);this.data=af;this.stale=false};var l=function(ae,ad,ac,af,ag){b.call(this,ae,ad,ac,af);this.max_val=ag};var M=function(ae,ad,ac,ag,af){b.call(this,ae,ad,ac,ag);this.message=af};var j=function(ad,ac,ag,ae,af){this.name=ad;this.view=ac;this.parent_element=ag;this.data_url=(ae?ae:default_data_url);this.data_url_extra_params={};this.data_query_wait=(af?af:H);this.dataset_check_url=converted_datasets_state_url;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 class='draghandle' />").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)};n(j.prototype,{get_type:function(){if(this instanceof Y){return"LabelTrack"}else{if(this instanceof x){return"ReferenceTrack"}else{if(this instanceof k){return"LineTrack"}else{if(this instanceof T){return"ReadTrack"}else{if(this instanceof R){return"ToolDataFeatureTrack"}else{if(this instanceof Q){return"VcfTrack"}else{if(this instanceof e){return"FeatureTrack"}}}}}}}return""},init:function(){var ac=this;ac.enabled=false;ac.tile_cache.clear();ac.data_manager.clear();ac.initial_canvas=undefined;ac.content_div.css("height","auto");ac.container_div.removeClass("nodata error pending");if(!ac.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:ac.hda_ldda,dataset_id:ac.dataset_id,chrom:ac.view.chrom},function(ad){if(!ad||ad==="error"||ad.kind==="error"){ac.container_div.addClass("error");ac.content_div.text(m);if(ad.message){var af=ac.view.tracks.indexOf(ac);var ae=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+ad.message+"</pre>",{Close:hide_modal})});ac.content_div.append(ae)}}else{if(ad==="no converter"){ac.container_div.addClass("error");ac.content_div.text(G)}else{if(ad==="no data"||(ad.data!==undefined&&(ad.data===null||ad.data.length===0))){ac.container_div.addClass("nodata");ac.content_div.text(B)}else{if(ad==="pending"){ac.container_div.addClass("pending");ac.content_div.text(q);setTimeout(function(){ac.init()},ac.data_query_wait)}else{if(ad.status==="data"){if(ad.valid_chroms){ac.valid_chroms=ad.valid_chroms;ac.make_name_popup_menu()}ac.content_div.text(V);if(ac.view.chrom){ac.content_div.text("");ac.content_div.css("height",ac.height_px+"px");ac.enabled=true;$.when(ac.predraw_init()).done(function(){ac.container_div.removeClass("nodata error pending");ac.request_draw()})}}}}}}})},predraw_init:function(){},update_name:function(ac){this.old_name=this.name;this.name=ac;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var J=function(aj,ah,ak){var ad=this,al=ad.view;this.filters_manager=(aj!==undefined?new X(this,aj):undefined);this.filters_available=false;this.filters_visible=false;this.tool=(ah!==undefined&&obj_length(ah)>0?new o(this,ah):undefined);this.is_overview=false;this.parent_track=ak;this.child_tracks=[];if(ad.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}ad.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();ad.container_div.append(ad.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(ad.display_modes!==undefined){if(ad.mode_div===undefined){ad.mode_div=$("<div class='right-float menubutton popup' />").appendTo(ad.header_div);var ae=(ad.track_config&&ad.track_config.values.mode?ad.track_config.values.mode:ad.display_modes[0]);ad.mode=ae;ad.mode_div.text(ae);var ac={};for(var af=0,ai=ad.display_modes.length;af<ai;af++){var ag=ad.display_modes[af];ac[ag]=function(am){return function(){ad.change_mode(am)}}(ag)}make_popupmenu(ad.mode_div,ac)}else{ad.mode_div.hide()}}this.make_name_popup_menu()};n(J.prototype,j.prototype,{change_mode:function(ad){var ac=this;ac.mode_div.text(ad);ac.mode=ad;ac.track_config.values.mode=ad;ac.tile_cache.clear();ac.request_draw()},make_name_popup_menu:function(){var ad=this;var ac={};ac[(this.is_overview?"Hide overview":"Set as overview")]=function(){if(ad.is_overview){ad.view.reset_overview()}else{ad.view.set_overview(ad)}};ac["Edit configuration"]=function(){var aj=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},ah=function(){ad.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ai=function(ak){if((ak.keyCode||ak.which)===27){aj()}else{if((ak.keyCode||ak.which)===13){ah()}}};$(window).bind("keypress.check_enter_esc",ai);show_modal("Configure Track",ad.track_config.build_form(),{Cancel:aj,OK:ah})};if(ad.filters_available>0){var ag=(ad.filters_div.is(":visible")?"Hide filters":"Show filters");ac[ag]=function(){ad.filters_visible=(ad.filters_div.is(":visible"));if(ad.filters_visible){ad.filters_manager.reset_filters()}ad.filters_div.toggle();ad.make_name_popup_menu()}}if(ad.tool){var ag=(ad.dynamic_tool_div.is(":visible")?"Hide tool":"Show tool");ac[ag]=function(){if(!ad.dynamic_tool_div.is(":visible")){ad.update_name(ad.name+ad.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";ad.revert_name()}ad.dynamic_tool_div.toggle();ad.make_name_popup_menu()}}if(ad.valid_chroms){ac["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+ad.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}var ae=view;var af=function(){$("#no-tracks").show()};if(this.parent_track){ae=this.parent_track;af=function(){}}ac.Remove=function(){ae.remove_track(ad);if(ae.num_tracks===0){af()}};make_popupmenu(ad.name_div,ac)},set_is_overview:function(ac){this.is_overview=ac;this.make_name_popup_menu()},get_overview_tile:function(){var ac=this;view=ac.view,resolution=Math.pow(z,Math.ceil(Math.log((view.max_high-view.max_low)/N)/Math.log(z))),view_width=view.container.width(),w_scale=view_width/(view.max_high-view.max_low),overview_tile=$.Deferred();$.when(ac.data_manager.get_data(view.max_low,view.max_high,"Auto",resolution,ac.data_url_extra_params)).then(function(ad){var af=ac._gen_tile_cache_key(view_width,w_scale,0),ah=ac.tile_cache.get(af);if(!ah){ah=ac.draw_tile(ad,resolution,0,w_scale);ac.tile_cache.set(af,ah)}var ak=$(ah.canvas.find("canvas")),ag=ak.clone(),aj=ak.get(0).getContext("2d"),ae=ag.get(0).getContext("2d"),ai=aj.getImageData(0,0,aj.canvas.width,aj.canvas.height);ae.putImageData(ai,-ac.left_offset,(ah.data.dataset_type==="summary_tree"?P:0));new_tile=new b(-1,resolution,ag);overview_tile.resolve(new_tile)});return overview_tile},_gen_tile_cache_key:function(ad,ae,ac){return ad+"_"+ae+"_"+ac},request_draw:function(ad,ac){this.view.request_redraw(false,ad,ac,this)},_draw:function(ae,an){if(!this.dataset_id){return}var am=this.view.low,ai=this.view.high,ak=ai-am,af=this.view.container.width(),aq=af/ak,ah=this.view.resolution,ap=$("<div style='position: relative;'></div>");if(!an){this.content_div.children().remove()}this.content_div.append(ap);this.max_height=0;var ad=Math.floor(am/ah/N);var al=true;var ao=[];var ac=0;while((ad*N*ah)<ai){tile=this.draw_helper(ae,af,ad,ah,ap,aq);if(tile){ao.push(tile)}else{al=false}ad+=1;ac++}var ag=this;if(al){ag.postdraw_actions(ao,af,aq,an)}for(var aj=0;aj<this.child_tracks.length;aj++){this.child_tracks[aj].request_draw(ae,an)}},postdraw_actions:function(ag,ah,ai,ac){var ae=this;var af=false;for(var ad=0;ad<ag.length;ad++){if(ag[ad].message){af=true;break}}if(af){for(var ad=0;ad<ag.length;ad++){tile=ag[ad];if(!tile.message){tile.canvas.css("padding-top",A)}}}},draw_helper:function(ad,ae,af,ai,ao,at,ap,aj){var ag=this,an=this._gen_tile_cache_key(ae,at,af),ak=af*N*ai,ar=ak+N*ai;var al=(ad?undefined:ag.tile_cache.get(an));if(al){ag.show_tile(al,ao,at);return al}var am=function(au){return("isResolved" in au)};var ah=true;var ac=ag.data_manager.get_data(ak,ar,ag.mode,ai,ag.data_url_extra_params);if(am(ac)){ah=false}var aq;if(view.reference_track&&at>view.canvas_manager.char_width_px){aq=view.reference_track.data_manager.get_data(ak,ar,ag.mode,ai,view.reference_track.data_url_extra_params);if(am(aq)){ah=false}}if(ah){n(ac,aj);var al=ag.draw_tile(ac,ai,af,at,aq);ag.tile_cache.set(an,al);if(al!==undefined){ag.show_tile(al,ao,at)}return al}$.when(ac,aq).then(function(){view.request_redraw()});return null},show_tile:function(aj,al,am){var ae=this,ad=aj.canvas,ai=ad;if(aj.message){var an=$("<div/>"),ak=$("<div/>").addClass("tile-message").text(aj.message).css({height:A-1,width:aj.canvas.width}).appendTo(an),ag=$("<a href='javascript:void(0);'/>").addClass("icon more-down").appendTo(ak),ac=$("<a href='javascript:void(0);'/>").addClass("icon more-across").appendTo(ak);an.append(ad);ai=an;ag.click(function(){aj.stale=true;ae.data_manager.get_more_data(aj.low,aj.high,ae.mode,aj.resolution,{},ae.data_manager.DEEP_DATA_REQ);ae.request_draw()}).dblclick(function(ao){ao.stopPropagation()});ac.click(function(){aj.stale=true;ae.data_manager.get_more_data(aj.low,aj.high,ae.mode,aj.resolution,{},ae.data_manager.BROAD_DATA_REQ);ae.request_draw()}).dblclick(function(ao){ao.stopPropagation()})}var ah=this.view.high-this.view.low,af=(aj.low-this.view.low)*am;if(this.left_offset){af-=this.left_offset}ai.css({position:"absolute",top:0,left:af,height:""});al.append(ai);ae.max_height=Math.max(ae.max_height,ai.height());ae.content_div.css("height",ae.max_height+"px");al.children().css("height",ae.max_height+"px")},tool_region_and_parameters_str:function(ae,ac,af){var ad=this,ag=(ae!==undefined&&ac!==undefined&&af!==undefined?ae+":"+ac+"-"+af:"all");return" - region=["+ag+"], parameters=["+ad.tool.get_param_values().join(", ")+"]"},add_track:function(ac){ac.track_id=this.track_id+"_"+this.child_tracks.length;ac.container_div.attr("id","track_"+ac.track_id);this.child_tracks_container.append(ac.container_div);C(ac.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(ac);this.view.has_changes=true},remove_track:function(ac){ac.container_div.fadeOut("slow",function(){$(this).remove()})}});var Y=function(ac,ad){this.hidden=true;j.call(this,null,ac,ad);this.container_div.addClass("label-track")};n(Y.prototype,j.prototype,{_draw:function(){var ae=this.view,af=ae.high-ae.low,ai=Math.floor(Math.pow(10,Math.floor(Math.log(af)/Math.log(10)))),ac=Math.floor(ae.low/ai)*ai,ag=this.view.container.width(),ad=$("<div style='position: relative; height: 1.3em;'></div>");while(ac<ae.high){var ah=(ac-ae.low)/af*ag;ad.append($("<div class='label'>"+commatize(ac)+"</div>").css({position:"absolute",left:ah-1}));ac+=ai}this.content_div.children(":first").remove();this.content_div.append(ad)}});var x=function(ac){this.hidden=true;j.call(this,null,ac,ac.top_labeltrack);J.call(this);ac.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:ac.dbkey};this.data_manager=new E(y,this,false);this.tile_cache=new c(r)};n(x.prototype,J.prototype,{draw_tile:function(ak,ah,ad,am){var ag=this,ae=N*ah;if(am>this.view.canvas_manager.char_width_px){if(ak===null){ag.content_div.css("height","0px");return}var af=this.view.canvas_manager.new_canvas();var al=af.getContext("2d");af.width=Math.ceil(ae*am+ag.left_offset);af.height=ag.height_px;al.font=al.canvas.manager.default_font;al.textAlign="center";for(var ai=0,aj=ak.length;ai<aj;ai++){var ac=Math.round(ai*am);al.fillText(ak[ai],ac+ag.left_offset,10)}return new b(ad,ah,af,ak)}this.content_div.css("height","0px")}});var k=function(ag,ae,ah,ac,af){var ad=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";j.call(this,ag,ae,ae.viewport_container);J.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=ah;this.dataset_id=ac;this.original_dataset_id=ac;this.data_manager=new O(y,this);this.tile_cache=new c(r);this.track_config=new W({track:this,params:[{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:af,onchange:function(){ad.vertical_range=ad.prefs.max_value-ad.prefs.min_value;$("#linetrack_"+ad.track_id+"_minval").text(ad.prefs.min_value);$("#linetrack_"+ad.track_id+"_maxval").text(ad.prefs.max_value);ad.tile_cache.clear();ad.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()};n(k.prototype,J.prototype,{add_resize_handle:function(){var ac=this;var af=false;var ae=false;var ad=$("<div class='track-resize'>");$(ac.container_div).hover(function(){af=true;ad.show()},function(){af=false;if(!ae){ad.hide()}});ad.hide().bind("dragstart",function(ag,ah){ae=true;ah.original_height=$(ac.content_div).height()}).bind("drag",function(ah,ai){var ag=Math.min(Math.max(ai.original_height+ai.deltaY,ac.min_height_px),ac.max_height_px);$(ac.content_div).css("height",ag);ac.height_px=ag;ac.request_draw(true)}).bind("dragend",function(ag,ah){ac.tile_cache.clear();ae=false;if(!af){ad.hide()}ac.track_config.values.height=ac.height_px}).appendTo(ac.container_div)},predraw_init:function(){var ac=this,ad=ac.view.tracks.indexOf(ac);ac.vertical_range=undefined;return $.getJSON(ac.data_url,{stats:true,chrom:ac.view.chrom,low:null,high:null,hda_ldda:ac.hda_ldda,dataset_id:ac.dataset_id},function(ae){ac.container_div.addClass("line-track");var ag=ae.data;if(isNaN(parseFloat(ac.prefs.min_value))||isNaN(parseFloat(ac.prefs.max_value))){ac.prefs.min_value=ag.min;ac.prefs.max_value=ag.max;$("#track_"+ad+"_minval").val(ac.prefs.min_value);$("#track_"+ad+"_maxval").val(ac.prefs.max_value)}ac.vertical_range=ac.prefs.max_value-ac.prefs.min_value;ac.total_frequency=ag.total_frequency;ac.container_div.find(".yaxislabel").remove();var ah=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+ad+"_minval").text(u(ac.prefs.min_value));var af=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+ad+"_maxval").text(u(ac.prefs.max_value));af.css({position:"absolute",top:"24px",left:"10px"});af.prependTo(ac.container_div);ah.css({position:"absolute",bottom:"2px",left:"10px"});ah.prependTo(ac.container_div)})},draw_tile:function(am,ag,ad,al){if(this.vertical_range===undefined){return}var ah=ad*N*ag,af=N*ag,ac=Math.ceil(af*al),aj=this.height_px;var ae=this.view.canvas_manager.new_canvas();ae.width=ac,ae.height=aj;var ak=ae.getContext("2d");var ai=new I.LinePainter(am.data,ah,ah+af,this.prefs,this.mode);ai.draw(ak,ac,aj);return new b(ad,ag,ae,am.data)}});var e=function(ac,ah,ag,ak,aj,ae,af,ai){var ad=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];this.track_config=new W({track:this,params:[{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:aj,onchange:function(){ad.tile_cache.clear();ad.request_draw()}});this.prefs=this.track_config.values;j.call(this,ac,ah,ah.viewport_container);J.call(this,ae,af,ai);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=ag;this.dataset_id=ak;this.original_dataset_id=ak;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 O(20,this);this.left_offset=200;this.painter=I.LinkedFeaturePainter};n(e.prototype,J.prototype,{postdraw_actions:function(ar,ac,at,aq){J.prototype.postdraw_actions.call(this,ar,aq);var af=this;if(aq){var ah=af.content_div.children();var ai=false;for(var ag=ah.length-1,am=0;ag>=am;ag--){var ae=$(ah[ag]);if(ai){ae.remove()}else{if(ae.children().length!==0){ai=true}}}}if(af.mode=="Histogram"){var al=-1;for(var ag=0;ag<ar.length;ag++){var ap=ar[ag].max_val;if(ap>al){al=ap}}for(var ag=0;ag<ar.length;ag++){var ao=ar[ag];if(ao.max_val!==al){ao.canvas.remove();af.draw_helper(true,ac,ao.index,ao.resolution,ao.canvas.parent(),at,[],{max:al})}}}if(af.filters_manager){var ad=af.filters_manager.filters;for(var ak=0;ak<ad.length;ak++){ad[ak].update_ui_elt()}var aj=false,an;for(var ag=0;ag<ar.length;ag++){if(ar[ag].data.length){an=ar[ag].data[0];for(var ak=0;ak<ad.length;ak++){if(ad[ak].applies_to(an)){aj=true;break}}}}if(af.filters_available!==aj){af.filters_available=aj;if(!af.filters_available){af.filters_div.hide()}af.make_name_popup_menu()}}},update_auto_mode:function(ac){if(this.mode=="Auto"){if(ac=="no_detail"){ac="feature spans"}else{if(ac=="summary_tree"){ac="coverage histogram"}}this.mode_div.text("Auto ("+ac+")")}},incremental_slots:function(ag,ad,af){var ae=this.view.canvas_manager.dummy_context,ac=this.inc_slots[ag];if(!ac||(ac.mode!==af)){ac=new (p.FeatureSlotter)(ag,af==="Pack",w,function(ah){return ae.measureText(ah)});ac.mode=af;this.inc_slots[ag]=ac}return ac.slot_features(ad)},get_summary_tree_data:function(ag,aj,ae,ar){if(ar>ae-aj){ar=ae-aj}var an=Math.floor((ae-aj)/ar),aq=[],af=0;var ah=0,ai=0,am,ap=0,ak=[],ao,al;var ad=function(av,au,aw,at){av[0]=au+aw*at;av[1]=au+(aw+1)*at};while(ap<ar&&ah!==ag.length){var ac=false;for(;ap<ar&&!ac;ap++){ad(ak,aj,ap,an);for(ai=ah;ai<ag.length;ai++){am=ag[ai].slice(1,3);if(is_overlap(am,ak)){ac=true;break}}if(ac){break}}data_start_index=ai;aq[aq.length]=ao=[ak[0],0];for(;ai<ag.length;ai++){am=ag[ai].slice(1,3);if(is_overlap(am,ak)){ao[1]++}else{break}}if(ao[1]>af){af=ao[1]}ap++}return{max:af,delta:an,data:aq}},draw_tile:function(ap,ay,aC,al,af){var av=this,aE=aC*N*ay,ad=(aC+1)*N*ay,ar=ad-aE,aw=Math.ceil(ar*al),at=this.mode,aI=25,ag=this.left_offset,aq,ah;if(at==="Auto"){if(ap.dataset_type==="summary_tree"){at=ap.dataset_type}else{if(ap.extra_info==="no_detail"){at="no_detail"}else{var aH=ap.data;if(this.view.high-this.view.low>F){at="Squish"}else{at="Pack"}}}this.update_auto_mode(at)}if(at==="summary_tree"||at==="Histogram"){ah=this.summary_draw_height;this.container_div.find(".yaxislabel").remove();var ac=$("<div />").addClass("yaxislabel");ac.text(ap.max);ac.css({position:"absolute",top:"24px",left:"10px",color:this.prefs.label_color});ac.prependTo(this.container_div);var ae=this.view.canvas_manager.new_canvas();ae.width=aw+ag;ae.height=ah+P;if(ap.dataset_type!="summary_tree"){var am=this.get_summary_tree_data(ap.data,aE,ad,200);if(ap.max){am.max=ap.max}ap=am}var aF=new I.SummaryTreePainter(ap,aE,ad,this.prefs);var ax=ae.getContext("2d");ax.translate(ag,P);aF.draw(ax,aw,ah);return new l(aC,ay,ae,ap.data,ap.max)}var aq,aj=1;if(at==="no_detail"||at==="Squish"||at==="Pack"){aj=this.incremental_slots(al,ap.data,at);aq=this.inc_slots[al].slots}var ak=[];if(ap.data){var an=this.filters_manager.filters;for(var az=0,aB=ap.data.length;az<aB;az++){var ai=ap.data[az];var aA=false;var ao;for(var aD=0,aG=an.length;aD<aG;aD++){ao=an[aD];ao.update_attrs(ai);if(!ao.keep(ai)){aA=true;break}}if(!aA){ak.push(ai)}}}var au=(this.filters_manager.alpha_filter?new L(this.filters_manager.alpha_filter):null);var aF=new (this.painter)(ak,aE,ad,this.prefs,at,au,af);var ah=Math.max(aa,aF.get_required_height(aj));var ae=this.view.canvas_manager.new_canvas();ae.width=aw+ag;ae.height=ah;var ax=ae.getContext("2d");ax.fillStyle=this.prefs.block_color;ax.font=ax.canvas.manager.default_font;ax.textAlign="right";this.container_div.find(".yaxislabel").remove();if(ap.data){ax.translate(ag,0);aF.draw(ax,aw,ah,aq)}return new M(aC,ay,ae,ap.data,ap.message)}});var Q=function(af,ad,ah,ac,ae,ag){e.call(this,af,ad,ah,ac,ae,ag);this.painter=I.VariantPainter};n(Q.prototype,J.prototype,e.prototype);var T=function(af,ad,ah,ac,ae,ag){e.call(this,af,ad,ah,ac,ae,ag);this.track_config=new W({track:this,params:[{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:ae,onchange:function(){this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.track_config.values;this.painter=I.ReadPainter;this.make_name_popup_menu()};n(T.prototype,J.prototype,e.prototype);var R=function(ag,ae,ai,ac,af,ah,ad){e.call(this,ag,ae,ai,ac,af,ah,{},ad);this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};n(R.prototype,J.prototype,e.prototype,{predraw_init:function(){var ad=this;var ac=function(){if(ad.data_manager.size()===0){setTimeout(ac,300)}else{ad.data_url=default_data_url;ad.data_query_wait=H;ad.dataset_state_url=converted_datasets_state_url;$.getJSON(ad.dataset_state_url,{dataset_id:ad.dataset_id,hda_ldda:ad.hda_ldda},function(ae){})}};ac()}});U.View=Z;U.LineTrack=k;U.FeatureTrack=e;U.ReadTrack=T};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,U){var n=f("class").extend,p=f("slotting"),I=f("painters");var ab=function(ac,ad){this.document=ac;this.default_font=ad!==undefined?ad:"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")};n(ab.prototype,{load_pattern:function(ac,ag){var ad=this.patterns,ae=this.dummy_context,af=new Image();af.src=image_path+ag;af.onload=function(){ad[ac]=ae.createPattern(af,"repeat")}},get_pattern:function(ac){return this.patterns[ac]},new_canvas:function(){var ac=this.document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(ac)}ac.manager=this;return ac}});var C=function(ac,ad){ac.bind("drag",{handle:ad,relative:true},function(ah,ai){var ag=$(this).parent();var af=ag.children();var ae;for(ae=0;ae<af.length;ae++){if(ai.offsetY<$(af.get(ae)).position().top){break}}if(ae===af.length){if(this!==af.get(ae-1)){ag.append(this)}}else{if(this!==af.get(ae)){$(this).insertBefore(af.get(ae))}}}).bind("dragstart",function(){$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css("border","0px")})};U.sortable=C;var aa=16,D=9,A=20,P=D+2,w=100,F=12000,N=200,z=5,s=10,H=5000,t=100,m="There was an error in indexing this dataset. ",G="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",B="No data for this chrom/contig.",q="Currently indexing... please wait",v="Tool cannot be rerun: ",a="Loading data...",V="Ready for display",d=10,r=5,y=5;function u(ac){return Math.round(ac*1000)/1000}var c=function(ac){this.num_elements=ac;this.clear()};n(c.prototype,{get:function(ad){var ac=this.key_ary.indexOf(ad);if(ac!==-1){if(this.obj_cache[ad].stale){this.key_ary.splice(ac,1);delete this.obj_cache[ad]}else{this.move_key_to_end(ad,ac)}}return this.obj_cache[ad]},set:function(ad,ae){if(!this.obj_cache[ad]){if(this.key_ary.length>=this.num_elements){var ac=this.key_ary.shift();delete this.obj_cache[ac]}this.key_ary.push(ad)}this.obj_cache[ad]=ae;return ae},move_key_to_end:function(ad,ac){this.key_ary.splice(ac,1);this.key_ary.push(ad)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var O=function(ad,ac,ae){c.call(this,ad);this.track=ac;this.subset=(ae!==undefined?ae:true)};n(O.prototype,c.prototype,{load_data:function(al,ag,aj,ad,ai){var ak=this.track.view.chrom,af={chrom:ak,low:al,high:ag,mode:aj,resolution:ad,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(af,ai);if(this.track.filters_manager){var am=[];var ac=this.track.filters_manager.filters;for(var ah=0;ah<ac.length;ah++){am[am.length]=ac[ah].name}af.filter_cols=JSON.stringify(am)}var ae=this;return $.getJSON(this.track.data_url,af,function(an){ae.set_data(al,ag,aj,an)})},get_data:function(ac,ag,ah,ad,af){var ae=this.get_data_from_cache(ac,ag,ah);if(ae){return ae}ae=this.load_data(ac,ag,ah,ad,af);this.set_data(ac,ag,ah,ae);return ae},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(ak,af,aj,ae,ai,ag){var al=this.get_data_from_cache(ak,af,aj);if(!al){console.log("ERROR: no current data for: ",this.track,ak,af,aj,ae,ai);return}al.stale=true;var ad=ak;if(ag===this.DEEP_DATA_REQ){$.extend(ai,{start_val:al.data.length+1})}else{if(ag===this.BROAD_DATA_REQ){ad=al.data[al.data.length-1][2]+1}}var ac=this,ah=this.load_data(ad,af,aj,ae,ai);new_data_available=$.Deferred();this.set_data(ak,af,aj,new_data_available);$.when(ah).then(function(am){if(am.data){am.data=al.data.concat(am.data);if(am.message){am.message=am.message.replace(/[0-9]+/,am.data.length)}}ac.set_data(ak,af,aj,am);new_data_available.resolve(am)});return new_data_available},get_data_from_cache:function(ac,ad,ae){return this.get(this.gen_key(ac,ad,ae))},set_data:function(ad,ae,af,ac){return this.set(this.gen_key(ad,ae,af),ac)},gen_key:function(ac,ae,af){var ad=ac+"_"+ae+"_"+af;return ad},split_key:function(ac){return ac.split("_")}});var E=function(ad,ac,ae){O.call(this,ad,ac,ae)};n(E.prototype,O.prototype,c.prototype,{load_data:function(ae,ac,ag,ah,ad,af){if(ad>1){return}return O.prototype.load_data.call(this,ae,ac,ag,ah,ad,af)}});var Z=function(ac,af,ae,ad,ag){this.container=ac;this.chrom=null;this.vis_id=ae;this.dbkey=ad;this.title=af;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(ag);this.canvas_manager=new ab(ac.get(0).ownerDocument);this.reset()};n(Z.prototype,{init:function(ag){var ae=this.container,ac=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ae);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ae);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ae);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 af=$("<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 ad=function(ah){if(ah.type==="focusout"||(ah.keyCode||ah.which)===13||(ah.keyCode||ah.which)===27){if((ah.keyCode||ah.which)!==27){ac.go_to($(this).val())}$(this).hide();$(this).val("");ac.location_span.show();ac.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",ad).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").appendTo(this.nav_controls);this.location_span.click(function(){ac.location_span.hide();ac.chrom_select.hide();ac.nav_input.val(ac.chrom+":"+ac.low+"-"+ac.high);ac.nav_input.css("display","inline-block");ac.nav_input.select();ac.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(){ac.zoom_out();ac.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){ac.zoom_in();ac.request_redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},ag);this.chrom_select.bind("change",function(){ac.change_chrom(ac.chrom_select.val())});this.content_div.click(function(ah){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(ah){ac.zoom_in(ah.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ah,ai){this.current_x=ai.offsetX}).bind("drag",function(ah,aj){var ak=aj.offsetX-this.current_x;this.current_x=aj.offsetX;var ai=Math.round(ak/ac.viewport_container.width()*(ac.max_high-ac.max_low));ac.move_delta(-ai)});this.overview_close.click(function(){ac.reset_overview()});this.viewport_container.bind("draginit",function(ah,ai){if(ah.clientX>ac.viewport_container.width()-16){return false}}).bind("dragstart",function(ah,ai){ai.original_low=ac.low;ai.current_height=ah.clientY;ai.current_x=ai.offsetX}).bind("drag",function(aj,al){var ah=$(this);var am=al.offsetX-al.current_x;var ai=ah.scrollTop()-(aj.clientY-al.current_height);ah.scrollTop(ai);al.current_height=aj.clientY;al.current_x=al.offsetX;var ak=Math.round(am/ac.viewport_container.width()*(ac.high-ac.low));ac.move_delta(ak)}).bind("mousewheel",function(aj,al,ai,ah){if(ai){var ak=Math.round(-ai/ac.viewport_container.width()*(ac.high-ac.low));ac.move_delta(ak)}});this.top_labeltrack.bind("dragstart",function(ah,ai){return $("<div />").css({height:ac.content_div.height()+ac.top_labeltrack.height()+ac.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(al,am){$(am.proxy).css({left:Math.min(al.pageX,am.startX),width:Math.abs(al.pageX-am.startX)});var ai=Math.min(al.pageX,am.startX)-ac.container.offset().left,ah=Math.max(al.pageX,am.startX)-ac.container.offset().left,ak=(ac.high-ac.low),aj=ac.viewport_container.width();ac.update_location(Math.round(ai/aj*ak)+ac.low,Math.round(ah/aj*ak)+ac.low)}).bind("dragend",function(am,an){var ai=Math.min(am.pageX,an.startX),ah=Math.max(am.pageX,an.startX),ak=(ac.high-ac.low),aj=ac.viewport_container.width(),al=ac.low;ac.low=Math.round(ai/aj*ak)+al;ac.high=Math.round(ah/aj*ak)+al;$(an.proxy).remove();ac.request_redraw()});this.add_label_track(new Y(this,this.top_labeltrack));this.add_label_track(new Y(this,this.nav_labeltrack));$(window).bind("resize",function(){ac.resize_window()});$(document).bind("redraw",function(){ac.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(ac,ad){this.location_span.text(commatize(ac)+" - "+commatize(ad));this.nav_input.val(this.chrom+":"+commatize(ac)+"-"+commatize(ad))},load_chroms:function(ad,ae){ad.num=t;$.extend(ad,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var ac=this;$.ajax({url:chrom_url,data:ad,dataType:"json",success:function(ag){if(ag.chrom_info.length===0){alert("Invalid chromosome: "+ad.chrom);return}if(ag.reference){ac.add_label_track(new x(ac))}ac.chrom_data=ag.chrom_info;var aj='<option value="">Select Chrom/Contig</option>';for(var ai=0,af=ac.chrom_data.length;ai<af;ai++){var ah=ac.chrom_data[ai].chrom;aj+='<option value="'+ah+'">'+ah+"</option>"}if(ag.prev_chroms){aj+='<option value="previous">Previous '+t+"</option>"}if(ag.next_chroms){aj+='<option value="next">Next '+t+"</option>"}ac.chrom_select.html(aj);if(ae){ae()}ac.chrom_start_index=ag.start_index},error:function(){alert("Could not load chroms for this dbkey:",ac.dbkey)}})},change_chrom:function(ag,ad,ai){if(!ag||ag==="None"){return}var af=this;if(ag==="previous"){af.load_chroms({low:this.chrom_start_index-t});return}if(ag==="next"){af.load_chroms({low:this.chrom_start_index+t});return}var ah=$.grep(af.chrom_data,function(ak,al){return ak.chrom===ag})[0];if(ah===undefined){af.load_chroms({chrom:ag},function(){af.change_chrom(ag,ad,ai)});return}else{if(ag!==af.chrom){af.chrom=ag;af.chrom_select.val(af.chrom);af.max_high=ah.len-1;af.reset();af.request_redraw(true);for(var aj=0,ac=af.tracks.length;aj<ac;aj++){var ae=af.tracks[aj];if(ae.init){ae.init()}}}if(ad!==undefined&&ai!==undefined){af.low=Math.max(ad,0);af.high=Math.min(ai,af.max_high)}af.reset_overview();af.request_redraw()}},go_to:function(ag){var ak=this,ac,af,ad=ag.split(":"),ai=ad[0],aj=ad[1];if(aj!==undefined){try{var ah=aj.split("-");ac=parseInt(ah[0].replace(/,/g,""),10);af=parseInt(ah[1].replace(/,/g,""),10)}catch(ae){return false}}ak.change_chrom(ai,ac,af)},move_fraction:function(ae){var ac=this;var ad=ac.high-ac.low;this.move_delta(ae*ad)},move_delta:function(ae){var ac=this;var ad=ac.high-ac.low;if(ac.low-ae<ac.max_low){ac.low=ac.max_low;ac.high=ac.max_low+ad}else{if(ac.high-ae>ac.max_high){ac.high=ac.max_high;ac.low=ac.max_high-ad}else{ac.high-=ae;ac.low-=ae}}ac.request_redraw()},add_track:function(ac){ac.view=this;ac.track_id=this.track_id_counter;this.tracks.push(ac);if(ac.init){ac.init()}ac.container_div.attr("id","track_"+ac.track_id);C(ac.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1;this.has_changes=true;this.update_intro_div()},add_label_track:function(ac){ac.view=this;this.label_tracks.push(ac)},remove_track:function(ad){this.has_changes=true;delete this.tracks[this.tracks.indexOf(ad)];this.num_tracks-=1;var ac=this;ad.container_div.fadeOut("slow",function(){$(this).remove();ac.update_intro_div()})},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(ak,ac,aj,ad){var ai=this,ag=(ad?[ad]:ai.tracks),ae;var ad;for(var ah=0;ah<ag.length;ah++){ad=ag[ah];ae=-1;for(var af=0;af<ai.tracks_to_be_redrawn.length;af++){if(ai.tracks_to_be_redrawn[af][0]===ad){ae=af;break}}if(ae<0){ai.tracks_to_be_redrawn.push([ad,ac,aj])}else{ai.tracks_to_be_redrawn[ah][1]=ac;ai.tracks_to_be_redrawn[ah][2]=aj}}requestAnimationFrame(function(){ai._redraw(ak)})},_redraw:function(am){var aj=this.low,af=this.high;if(aj<this.max_low){aj=this.max_low}if(af>this.max_high){af=this.max_high}var al=this.high-this.low;if(this.high!==0&&al<this.min_separation){af=aj+this.min_separation}this.low=Math.floor(aj);this.high=Math.ceil(af);this.resolution=Math.pow(z,Math.ceil(Math.log((this.high-this.low)/N)/Math.log(z)));this.zoom_res=Math.pow(s,Math.max(0,Math.ceil(Math.log(this.resolution,s)/Math.log(s))));var ac=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ai=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var an=13;this.overview_box.css({left:ac,width:Math.max(an,ai)}).show();if(ai<an){this.overview_box.css("left",ac-(an-ai)/2)}if(this.overview_highlight){this.overview_highlight.css({left:ac,width:ai})}this.update_location(this.low,this.high);if(!am){var ae,ad,ak;for(var ag=0,ah=this.tracks_to_be_redrawn.length;ag<ah;ag++){ae=this.tracks_to_be_redrawn[ag][0];ad=this.tracks_to_be_redrawn[ag][1];ak=this.tracks_to_be_redrawn[ag][2];if(ae&&ae.enabled){ae._draw(ad,ak)}}this.tracks_to_be_redrawn=[];for(ag=0,ah=this.label_tracks.length;ag<ah;ag++){this.label_tracks[ag]._draw()}}},zoom_in:function(ad,ae){if(this.max_high===0||this.high-this.low<this.min_separation){return}var af=this.high-this.low,ag=af/2+this.low,ac=(af/this.zoom_factor)/2;if(ad){ag=ad/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ag-ac);this.high=Math.round(ag+ac);this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var ad=this.high-this.low,ae=ad/2+this.low,ac=(ad*this.zoom_factor)/2;this.low=Math.round(ae-ac);this.high=Math.round(ae+ac);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(ac){$.when(ac.get_overview_tile()).then(function(ad){view.overview_viewport.find(".track-tile").remove();view.overview_close.show();view.overview_viewport.append(ad.canvas);view.overview_highlight.show().height(ad.canvas.height());view.overview_viewport.height(ad.canvas.height()+view.overview_box.outerHeight());view.resize_window();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=ac;ac.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 o=function(ae,ai){this.track=ae;this.name=ai.name;this.params=[];var ap=ai.params;for(var af=0;af<ap.length;af++){var ak=ap[af],ad=ak.name,ao=ak.label,ag=unescape(ak.html),aq=ak.value,am=ak.type;if(am==="number"){this.params[this.params.length]=new g(ad,ao,ag,aq,ak.min,ak.max)}else{if(am=="select"){this.params[this.params.length]=new K(ad,ao,ag,aq)}else{console.log("WARNING: unrecognized tool parameter type:",ad,am)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(at){at.stopPropagation()}).click(function(at){at.stopPropagation()}).bind("dblclick",function(at){at.stopPropagation()});var an=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var al=this.params;var aj=this;$.each(this.params,function(au,ax){var aw=$("<div>").addClass("param-row").appendTo(aj.parent_div);var at=$("<div>").addClass("param-label").text(ax.label).appendTo(aw);var av=$("<div/>").addClass("slider").html(ax.html).appendTo(aw);av.find(":input").val(ax.value);$("<div style='clear: both;'/>").appendTo(aw)});this.parent_div.find("input").click(function(){$(this).select()});var ar=$("<div>").addClass("param-row").appendTo(this.parent_div);var ah=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(ar);var ac=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(ar);var aj=this;ac.click(function(){aj.run_on_region()});ah.click(function(){aj.run_on_dataset()})};n(o.prototype,{get_param_values_dict:function(){var ac={};this.parent_div.find(":input").each(function(){var ad=$(this).attr("name"),ae=$(this).val();ac[ad]=JSON.stringify(ae)});return ac},get_param_values:function(){var ad=[];var ac={};this.parent_div.find(":input").each(function(){var ae=$(this).attr("name"),af=$(this).val();if(ae){ad[ad.length]=af}});return ad},run_on_dataset:function(){var ac=this;ac.run({dataset_id:this.track.original_dataset_id,tool_id:ac.name},null,function(ad){show_modal(ac.name+" is Running",ac.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var ac={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},ae=this.track,ad=ac.tool_id+ae.tool_region_and_parameters_str(ac.chrom,ac.low,ac.high),af;if(ae instanceof e){af=new R(ad,view,ae.hda_ldda,undefined,{},{},ae);af.change_mode(ae.mode)}this.track.add_track(af);af.content_div.text("Starting job.");this.run(ac,af,function(ag){af.dataset_id=ag.dataset_id;af.content_div.text("Running job.");af.init()})},run:function(ad,ae,af){$.extend(ad,this.get_param_values_dict());var ac=function(){$.getJSON(rerun_tool_url,ad,function(ag){if(ag==="no converter"){ae.container_div.addClass("error");ae.content_div.text(G)}else{if(ag.error){ae.container_div.addClass("error");ae.content_div.text(v+ag.message)}else{if(ag==="pending"){ae.container_div.addClass("pending");ae.content_div.text("Converting input data so that it can be used quickly with tool.");setTimeout(ac,2000)}else{af(ag)}}}})};ac()}});var K=function(ad,ac,ae,af){this.name=ad;this.label=ac;this.html=ae;this.value=af};var g=function(ae,ad,ag,ah,af,ac){K.call(this,ae,ad,ag,ah);this.min=af;this.max=ac};var h=function(ad,ac,ae,af){this.name=ad;this.index=ac;this.tool_id=ae;this.tool_exp_name=af};var S=function(ad,ac,ae,af){h.call(this,ad,ac,ae,af);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};n(S.prototype,{applies_to:function(ac){if(ac.length>this.index){return true}return false},keep:function(ac){if(!this.applies_to(ac)){return true}var ad=parseFloat(ac[this.index]);return(isNaN(ad)||(ad>=this.low&&ad<=this.high))},update_attrs:function(ad){var ac=false;if(!this.applies_to(ad)){return ac}if(ad[this.index]<this.min){this.min=Math.floor(ad[this.index]);ac=true}if(ad[this.index]>this.max){this.max=Math.ceil(ad[this.index]);ac=true}return ac},update_ui_elt:function(){if(this.min!=this.max){this.container.show()}else{this.container.hide()}var ae=function(ah,af){var ag=af-ah;return(ag<=2?0.01:1)};var ad=this.slider.slider("option","min"),ac=this.slider.slider("option","max");if(this.min<ad||this.max>ac){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",ae(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var X=function(am,at){this.track=am;this.filters=[];for(var an=0;an<at.length;an++){var ao=at[an],au=ao.name,ac=ao.type,af=ao.index,ar=ao.tool_id,aq=ao.tool_exp_name;if(ac==="int"||ac==="float"){this.filters[an]=new S(au,af,ar,aq)}else{console.log("ERROR: unsupported filter: ",au,ac)}}var ag=function(av,aw,ax){av.click(function(){var ay=aw.text();max=parseFloat(ax.slider("option","max")),input_size=(max<=1?4:max<=1000000?max.toString().length:6),multi_value=false;if(ax.slider("option","values")){input_size=2*input_size+1;multi_value=true}aw.text("");$("<input type='text'/>").attr("size",input_size).attr("maxlength",input_size).attr("value",ay).appendTo(aw).focus().select().click(function(az){az.stopPropagation()}).blur(function(){$(this).remove();aw.text(ay)}).keyup(function(aD){if(aD.keyCode===27){$(this).trigger("blur")}else{if(aD.keyCode===13){var aB=ax.slider("option","min"),az=ax.slider("option","max"),aC=function(aE){return(isNaN(aE)||aE>az||aE<aB)},aA=$(this).val();if(!multi_value){aA=parseFloat(aA);if(aC(aA)){alert("Parameter value must be in the range ["+aB+"-"+az+"]");return $(this)}}else{aA=aA.split("-");aA=[parseFloat(aA[0]),parseFloat(aA[1])];if(aC(aA[0])||aC(aA[1])){alert("Parameter value must be in the range ["+aB+"-"+az+"]");return $(this)}}ax.slider((multi_value?"values":"value"),aA)}}})})};this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(av){av.stopPropagation()}).click(function(av){av.stopPropagation()}).bind("dblclick",function(av){av.stopPropagation()}).bind("keydown",function(av){av.stopPropagation()});var ap=$("<div/>").addClass("sliders").appendTo(this.parent_div);var ak=this;$.each(this.filters,function(ay,aA){aA.container=$("<div/>").addClass("slider-row").appendTo(ap);var az=$("<div/>").addClass("elt-label").appendTo(aA.container);var ax=$("<span/>").addClass("slider-name").text(aA.name+" ").appendTo(az);var aw=$("<span/>");var aC=$("<span/>").addClass("slider-value").appendTo(az).append("[").append(aw).append("]");var av=$("<div/>").addClass("slider").appendTo(aA.container);aA.control_element=$("<div/>").attr("id",aA.name+"-filter-control").appendTo(av);var aB=[0,0];aA.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(aE,aF){var aD=aF.values;aw.text(aD[0]+"-"+aD[1]);aA.low=aD[0];aA.high=aD[1];ak.track.request_draw(true,true)},change:function(aD,aE){aA.control_element.slider("option","slide").call(aA.control_element,aD,aE)}});aA.slider=aA.control_element;aA.slider_label=aw;ag(aC,aw,aA.control_element);$("<div style='clear: both;'/>").appendTo(aA.container)});if(this.filters.length!==0){var ah=$("<div/>").addClass("param-row").appendTo(ap);var aj=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(ah);var ae=this;aj.click(function(){ae.run_on_dataset()})}var al=$("<div/>").addClass("display-controls").appendTo(this.parent_div),ai=$("<span/>").addClass("elt-label").text("Transparency:").appendTo(al),ad=$("<select/>").attr("name","alpha_dropdown").appendTo(al);this.alpha_filter=null;$("<option/>").attr("value",-1).text("== None ==").appendTo(ad);for(var an=0;an<this.filters.length;an++){$("<option/>").attr("value",an).text(this.filters[an].name).appendTo(ad)}ad.change(function(){$(this).children("option:selected").each(function(){var av=parseInt($(this).val());ak.alpha_filter=(av>=0?ak.filters[av]:null);ak.track.request_draw(true,true)})});$("<div style='clear: both;'/>").appendTo(this.parent_div)};n(X.prototype,{reset_filters:function(){for(var ac=0;ac<this.filters.length;ac++){filter=this.filters[ac];filter.slider.slider("option","values",[filter.min,filter.max])}this.alpha_filter=null},run_on_dataset:function(){var ak=function(ao,am,an){if(!(am in ao)){ao[am]=an}return ao[am]};var ae={},ac,ad,af;for(var ag=0;ag<this.filters.length;ag++){ac=this.filters[ag];if(ac.tool_id){if(ac.min!=ac.low){ad=ak(ae,ac.tool_id,[]);ad[ad.length]=ac.tool_exp_name+" >= "+ac.low}if(ac.max!=ac.high){ad=ak(ae,ac.tool_id,[]);ad[ad.length]=ac.tool_exp_name+" <= "+ac.high}}}var ai=[];for(var al in ae){ai[ai.length]=[al,ae[al]]}var aj=ai.length;(function ah(at,ap){var an=ap[0],ao=an[0],ar=an[1],aq="("+ar.join(") and (")+")",am={cond:aq,input:at,target_dataset_id:at,tool_id:ao},ap=ap.slice(1);$.getJSON(run_tool_url,am,function(au){if(au.error){show_modal("Filter Dataset","Error running tool "+ao,{Close:hide_modal})}else{if(ap.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{ah(au.dataset_id,ap)}}})})(this.track.dataset_id,ai)}});var L=function(ad,ac){I.AlphaGenerator.call(this,ac);this.filter=ad};L.prototype.gen_alpha=function(ac){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(ac[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var W=function(ac){this.track=ac.track;this.params=ac.params;this.values={};if(ac.saved_values){this.restore_values(ac.saved_values)}this.onchange=ac.onchange};n(W.prototype,{restore_values:function(ac){var ad=this;$.each(this.params,function(ae,af){if(ac[af.key]!==undefined){ad.values[af.key]=ac[af.key]}else{ad.values[af.key]=af.default_value}})},build_form:function(){var ad=this;var ac=$("<div />");$.each(this.params,function(ah,af){if(!af.hidden){var ae="param_"+ah;var am=$("<div class='form-row' />").appendTo(ac);am.append($("<label />").attr("for",ae).text(af.label+":"));if(af.type==="bool"){am.append($('<input type="checkbox" />').attr("id",ae).attr("name",ae).attr("checked",ad.values[af.key]))}else{if(af.type==="color"){var aj=ad.values[af.key];var ai=$("<input />").attr("id",ae).attr("name",ae).val(aj);var ak=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var ag=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(ak);var al=$("<div/>").appendTo(ag).farbtastic({width:100,height:100,callback:ai,color:aj});$("<div />").append(ai).append(ak).appendTo(am).bind("click",function(an){ak.css({left:$(this).position().left+($(ai).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){ak.hide();$(document).unbind("click.color-picker")});an.stopPropagation()})}else{am.append($("<input />").attr("id",ae).attr("name",ae).val(ad.values[af.key]))}}}});return ac},update_from_form:function(ac){var ae=this;var ad=false;$.each(this.params,function(af,ah){if(!ah.hidden){var ai="param_"+af;var ag=ac.find("#"+ai).val();if(ah.type==="float"){ag=parseFloat(ag)}else{if(ah.type==="int"){ag=parseInt(ag)}else{if(ah.type==="bool"){ag=ac.find("#"+ai).is(":checked")}}}if(ag!==ae.values[ah.key]){ae.values[ah.key]=ag;ad=true}}});if(ad){this.onchange()}}});var b=function(ae,ad,ac,af){this.index=ae;this.low=ae*N*ad;this.high=(ae+1)*N*ad;this.resolution=ad;this.canvas=$("<div class='track-tile'/>").append(ac);this.data=af;this.stale=false};var l=function(ae,ad,ac,af,ag){b.call(this,ae,ad,ac,af);this.max_val=ag};var M=function(ae,ad,ac,ag,af){b.call(this,ae,ad,ac,ag);this.message=af};var j=function(ad,ac,ag,ae,af){this.name=ad;this.view=ac;this.parent_element=ag;this.data_url=(ae?ae:default_data_url);this.data_url_extra_params={};this.data_query_wait=(af?af:H);this.dataset_check_url=converted_datasets_state_url;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 class='draghandle' />").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)};n(j.prototype,{get_type:function(){if(this instanceof Y){return"LabelTrack"}else{if(this instanceof x){return"ReferenceTrack"}else{if(this instanceof k){return"LineTrack"}else{if(this instanceof T){return"ReadTrack"}else{if(this instanceof R){return"ToolDataFeatureTrack"}else{if(this instanceof Q){return"VcfTrack"}else{if(this instanceof e){return"FeatureTrack"}}}}}}}return""},init:function(){var ac=this;ac.enabled=false;ac.tile_cache.clear();ac.data_manager.clear();ac.initial_canvas=undefined;ac.content_div.css("height","auto");ac.container_div.removeClass("nodata error pending");if(!ac.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:ac.hda_ldda,dataset_id:ac.dataset_id,chrom:ac.view.chrom},function(ad){if(!ad||ad==="error"||ad.kind==="error"){ac.container_div.addClass("error");ac.content_div.text(m);if(ad.message){var af=ac.view.tracks.indexOf(ac);var ae=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+ad.message+"</pre>",{Close:hide_modal})});ac.content_div.append(ae)}}else{if(ad==="no converter"){ac.container_div.addClass("error");ac.content_div.text(G)}else{if(ad==="no data"||(ad.data!==undefined&&(ad.data===null||ad.data.length===0))){ac.container_div.addClass("nodata");ac.content_div.text(B)}else{if(ad==="pending"){ac.container_div.addClass("pending");ac.content_div.text(q);setTimeout(function(){ac.init()},ac.data_query_wait)}else{if(ad.status==="data"){if(ad.valid_chroms){ac.valid_chroms=ad.valid_chroms;ac.make_name_popup_menu()}ac.content_div.text(V);if(ac.view.chrom){ac.content_div.text("");ac.content_div.css("height",ac.height_px+"px");ac.enabled=true;$.when(ac.predraw_init()).done(function(){ac.container_div.removeClass("nodata error pending");ac.request_draw()})}}}}}}})},predraw_init:function(){},update_name:function(ac){this.old_name=this.name;this.name=ac;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var J=function(aj,ah,ak){var ad=this,al=ad.view;this.filters_manager=(aj!==undefined?new X(this,aj):undefined);this.filters_available=false;this.filters_visible=false;this.tool=(ah!==undefined&&obj_length(ah)>0?new o(this,ah):undefined);this.is_overview=false;this.parent_track=ak;this.child_tracks=[];if(ad.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}ad.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();ad.container_div.append(ad.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(ad.display_modes!==undefined){if(ad.mode_div===undefined){ad.mode_div=$("<div class='right-float menubutton popup' />").appendTo(ad.header_div);var ae=(ad.track_config&&ad.track_config.values.mode?ad.track_config.values.mode:ad.display_modes[0]);ad.mode=ae;ad.mode_div.text(ae);var ac={};for(var af=0,ai=ad.display_modes.length;af<ai;af++){var ag=ad.display_modes[af];ac[ag]=function(am){return function(){ad.change_mode(am)}}(ag)}make_popupmenu(ad.mode_div,ac)}else{ad.mode_div.hide()}}this.make_name_popup_menu()};n(J.prototype,j.prototype,{change_mode:function(ad){var ac=this;ac.mode_div.text(ad);ac.mode=ad;ac.track_config.values.mode=ad;ac.tile_cache.clear();ac.request_draw()},make_name_popup_menu:function(){var ad=this;var ac={};ac[(this.is_overview?"Hide overview":"Set as overview")]=function(){if(ad.is_overview){ad.view.reset_overview()}else{ad.view.set_overview(ad)}};ac["Edit configuration"]=function(){var aj=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},ah=function(){ad.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ai=function(ak){if((ak.keyCode||ak.which)===27){aj()}else{if((ak.keyCode||ak.which)===13){ah()}}};$(window).bind("keypress.check_enter_esc",ai);show_modal("Configure Track",ad.track_config.build_form(),{Cancel:aj,OK:ah})};if(ad.filters_available>0){var ag=(ad.filters_div.is(":visible")?"Hide filters":"Show filters");ac[ag]=function(){ad.filters_visible=(ad.filters_div.is(":visible"));if(ad.filters_visible){ad.filters_manager.reset_filters()}ad.filters_div.toggle();ad.make_name_popup_menu()}}if(ad.tool){var ag=(ad.dynamic_tool_div.is(":visible")?"Hide tool":"Show tool");ac[ag]=function(){if(!ad.dynamic_tool_div.is(":visible")){ad.update_name(ad.name+ad.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";ad.revert_name()}ad.dynamic_tool_div.toggle();ad.make_name_popup_menu()}}if(ad.valid_chroms){ac["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+ad.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}var ae=view;var af=function(){$("#no-tracks").show()};if(this.parent_track){ae=this.parent_track;af=function(){}}ac.Remove=function(){ae.remove_track(ad);if(ae.num_tracks===0){af()}};make_popupmenu(ad.name_div,ac)},set_is_overview:function(ac){this.is_overview=ac;this.make_name_popup_menu()},get_overview_tile:function(){var ac=this;view=ac.view,resolution=Math.pow(z,Math.ceil(Math.log((view.max_high-view.max_low)/N)/Math.log(z))),view_width=view.container.width(),w_scale=view_width/(view.max_high-view.max_low),overview_tile=$.Deferred();$.when(ac.data_manager.get_data(view.max_low,view.max_high,"Auto",resolution,ac.data_url_extra_params)).then(function(ad){var af=ac._gen_tile_cache_key(view_width,w_scale,0),ah=ac.tile_cache.get(af);if(!ah){ah=ac.draw_tile(ad,resolution,0,w_scale);ac.tile_cache.set(af,ah)}var ak=$(ah.canvas.find("canvas")),ag=ak.clone(),aj=ak.get(0).getContext("2d"),ae=ag.get(0).getContext("2d"),ai=aj.getImageData(0,0,aj.canvas.width,aj.canvas.height);ae.putImageData(ai,-ac.left_offset,(ah.data.dataset_type==="summary_tree"?P:0));new_tile=new b(-1,resolution,ag);overview_tile.resolve(new_tile)});return overview_tile},_gen_tile_cache_key:function(ad,ae,ac){return ad+"_"+ae+"_"+ac},request_draw:function(ad,ac){this.view.request_redraw(false,ad,ac,this)},_draw:function(ae,an){if(!this.dataset_id){return}var am=this.view.low,ai=this.view.high,ak=ai-am,af=this.view.container.width(),aq=af/ak,ah=this.view.resolution,ap=$("<div style='position: relative;'></div>");if(!an){this.content_div.children().remove()}this.content_div.append(ap);this.max_height=0;var ad=Math.floor(am/ah/N);var al=true;var ao=[];var ac=0;while((ad*N*ah)<ai){tile=this.draw_helper(ae,af,ad,ah,ap,aq);if(tile){ao.push(tile)}else{al=false}ad+=1;ac++}var ag=this;if(al){ag.postdraw_actions(ao,af,aq,an)}for(var aj=0;aj<this.child_tracks.length;aj++){this.child_tracks[aj].request_draw(ae,an)}},postdraw_actions:function(ag,ah,ai,ac){var ae=this;var af=false;for(var ad=0;ad<ag.length;ad++){if(ag[ad].message){af=true;break}}if(af){for(var ad=0;ad<ag.length;ad++){tile=ag[ad];if(!tile.message){tile.canvas.css("padding-top",A)}}}},draw_helper:function(ad,ae,af,ai,ao,at,ap,aj){var ag=this,an=this._gen_tile_cache_key(ae,at,af),ak=af*N*ai,ar=ak+N*ai;var al=(ad?undefined:ag.tile_cache.get(an));if(al){ag.show_tile(al,ao,at);return al}var am=function(au){return("isResolved" in au)};var ah=true;var ac=ag.data_manager.get_data(ak,ar,ag.mode,ai,ag.data_url_extra_params);if(am(ac)){ah=false}var aq;if(view.reference_track&&at>view.canvas_manager.char_width_px){aq=view.reference_track.data_manager.get_data(ak,ar,ag.mode,ai,view.reference_track.data_url_extra_params);if(am(aq)){ah=false}}if(ah){n(ac,aj);var al=ag.draw_tile(ac,ai,af,at,aq);ag.tile_cache.set(an,al);if(al!==undefined){ag.show_tile(al,ao,at)}return al}$.when(ac,aq).then(function(){view.request_redraw()});return null},show_tile:function(aj,al,am){var ae=this,ad=aj.canvas,ai=ad;if(aj.message){var an=$("<div/>"),ak=$("<div/>").addClass("tile-message").text(aj.message).css({height:A-1,width:aj.canvas.width}).appendTo(an),ag=$("<a href='javascript:void(0);'/>").addClass("icon more-down").appendTo(ak),ac=$("<a href='javascript:void(0);'/>").addClass("icon more-across").appendTo(ak);an.append(ad);ai=an;ag.click(function(){aj.stale=true;ae.data_manager.get_more_data(aj.low,aj.high,ae.mode,aj.resolution,{},ae.data_manager.DEEP_DATA_REQ);ae.request_draw()}).dblclick(function(ao){ao.stopPropagation()});ac.click(function(){aj.stale=true;ae.data_manager.get_more_data(aj.low,aj.high,ae.mode,aj.resolution,{},ae.data_manager.BROAD_DATA_REQ);ae.request_draw()}).dblclick(function(ao){ao.stopPropagation()})}var ah=this.view.high-this.view.low,af=(aj.low-this.view.low)*am;if(this.left_offset){af-=this.left_offset}ai.css({position:"absolute",top:0,left:af,height:""});al.append(ai);ae.max_height=Math.max(ae.max_height,ai.height());ae.content_div.css("height",ae.max_height+"px");al.children().css("height",ae.max_height+"px")},tool_region_and_parameters_str:function(ae,ac,af){var ad=this,ag=(ae!==undefined&&ac!==undefined&&af!==undefined?ae+":"+ac+"-"+af:"all");return" - region=["+ag+"], parameters=["+ad.tool.get_param_values().join(", ")+"]"},add_track:function(ac){ac.track_id=this.track_id+"_"+this.child_tracks.length;ac.container_div.attr("id","track_"+ac.track_id);this.child_tracks_container.append(ac.container_div);C(ac.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(ac);this.view.has_changes=true},remove_track:function(ac){ac.container_div.fadeOut("slow",function(){$(this).remove()})}});var Y=function(ac,ad){this.hidden=true;j.call(this,null,ac,ad);this.container_div.addClass("label-track")};n(Y.prototype,j.prototype,{_draw:function(){var ae=this.view,af=ae.high-ae.low,ai=Math.floor(Math.pow(10,Math.floor(Math.log(af)/Math.log(10)))),ac=Math.floor(ae.low/ai)*ai,ag=this.view.container.width(),ad=$("<div style='position: relative; height: 1.3em;'></div>");while(ac<ae.high){var ah=(ac-ae.low)/af*ag;ad.append($("<div class='label'>"+commatize(ac)+"</div>").css({position:"absolute",left:ah-1}));ac+=ai}this.content_div.children(":first").remove();this.content_div.append(ad)}});var x=function(ac){this.hidden=true;j.call(this,null,ac,ac.top_labeltrack);J.call(this);ac.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:ac.dbkey};this.data_manager=new E(y,this,false);this.tile_cache=new c(r)};n(x.prototype,J.prototype,{draw_tile:function(ak,ah,ad,am){var ag=this,ae=N*ah;if(am>this.view.canvas_manager.char_width_px){if(ak===null){ag.content_div.css("height","0px");return}var af=this.view.canvas_manager.new_canvas();var al=af.getContext("2d");af.width=Math.ceil(ae*am+ag.left_offset);af.height=ag.height_px;al.font=al.canvas.manager.default_font;al.textAlign="center";for(var ai=0,aj=ak.length;ai<aj;ai++){var ac=Math.round(ai*am);al.fillText(ak[ai],ac+ag.left_offset,10)}return new b(ad,ah,af,ak)}this.content_div.css("height","0px")}});var k=function(ag,ae,ah,ac,af){var ad=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";j.call(this,ag,ae,ae.viewport_container);J.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=ah;this.dataset_id=ac;this.original_dataset_id=ac;this.data_manager=new O(y,this);this.tile_cache=new c(r);this.track_config=new W({track:this,params:[{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:af,onchange:function(){ad.vertical_range=ad.prefs.max_value-ad.prefs.min_value;$("#linetrack_"+ad.track_id+"_minval").text(ad.prefs.min_value);$("#linetrack_"+ad.track_id+"_maxval").text(ad.prefs.max_value);ad.tile_cache.clear();ad.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()};n(k.prototype,J.prototype,{add_resize_handle:function(){var ac=this;var af=false;var ae=false;var ad=$("<div class='track-resize'>");$(ac.container_div).hover(function(){af=true;ad.show()},function(){af=false;if(!ae){ad.hide()}});ad.hide().bind("dragstart",function(ag,ah){ae=true;ah.original_height=$(ac.content_div).height()}).bind("drag",function(ah,ai){var ag=Math.min(Math.max(ai.original_height+ai.deltaY,ac.min_height_px),ac.max_height_px);$(ac.content_div).css("height",ag);ac.height_px=ag;ac.request_draw(true)}).bind("dragend",function(ag,ah){ac.tile_cache.clear();ae=false;if(!af){ad.hide()}ac.track_config.values.height=ac.height_px}).appendTo(ac.container_div)},predraw_init:function(){var ac=this,ad=ac.view.tracks.indexOf(ac);ac.vertical_range=undefined;return $.getJSON(ac.data_url,{stats:true,chrom:ac.view.chrom,low:null,high:null,hda_ldda:ac.hda_ldda,dataset_id:ac.dataset_id},function(ae){ac.container_div.addClass("line-track");var ag=ae.data;if(isNaN(parseFloat(ac.prefs.min_value))||isNaN(parseFloat(ac.prefs.max_value))){ac.prefs.min_value=ag.min;ac.prefs.max_value=ag.max;$("#track_"+ad+"_minval").val(ac.prefs.min_value);$("#track_"+ad+"_maxval").val(ac.prefs.max_value)}ac.vertical_range=ac.prefs.max_value-ac.prefs.min_value;ac.total_frequency=ag.total_frequency;ac.container_div.find(".yaxislabel").remove();var ah=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+ad+"_minval").text(u(ac.prefs.min_value));var af=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+ad+"_maxval").text(u(ac.prefs.max_value));af.css({position:"absolute",top:"24px",left:"10px"});af.prependTo(ac.container_div);ah.css({position:"absolute",bottom:"2px",left:"10px"});ah.prependTo(ac.container_div)})},draw_tile:function(am,ag,ad,al){if(this.vertical_range===undefined){return}var ah=ad*N*ag,af=N*ag,ac=Math.ceil(af*al),aj=this.height_px;var ae=this.view.canvas_manager.new_canvas();ae.width=ac,ae.height=aj;var ak=ae.getContext("2d");var ai=new I.LinePainter(am.data,ah,ah+af,this.prefs,this.mode);ai.draw(ak,ac,aj);return new b(ad,ag,ae,am.data)}});var e=function(ac,ah,ag,ak,aj,ae,af,ai){var ad=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];this.track_config=new W({track:this,params:[{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:aj,onchange:function(){ad.tile_cache.clear();ad.request_draw()}});this.prefs=this.track_config.values;j.call(this,ac,ah,ah.viewport_container);J.call(this,ae,af,ai);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=ag;this.dataset_id=ak;this.original_dataset_id=ak;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 O(20,this);this.left_offset=200;this.painter=I.LinkedFeaturePainter};n(e.prototype,J.prototype,{postdraw_actions:function(ar,ac,at,aq){J.prototype.postdraw_actions.call(this,ar,aq);var af=this;if(aq){var ah=af.content_div.children();var ai=false;for(var ag=ah.length-1,am=0;ag>=am;ag--){var ae=$(ah[ag]);if(ai){ae.remove()}else{if(ae.children().length!==0){ai=true}}}}if(af.mode=="Histogram"){var al=-1;for(var ag=0;ag<ar.length;ag++){var ap=ar[ag].max_val;if(ap>al){al=ap}}for(var ag=0;ag<ar.length;ag++){var ao=ar[ag];if(ao.max_val!==al){ao.canvas.remove();af.draw_helper(true,ac,ao.index,ao.resolution,ao.canvas.parent(),at,[],{max:al})}}}if(af.filters_manager){var ad=af.filters_manager.filters;for(var ak=0;ak<ad.length;ak++){ad[ak].update_ui_elt()}var aj=false,an;for(var ag=0;ag<ar.length;ag++){if(ar[ag].data.length){an=ar[ag].data[0];for(var ak=0;ak<ad.length;ak++){if(ad[ak].applies_to(an)){aj=true;break}}}}if(af.filters_available!==aj){af.filters_available=aj;if(!af.filters_available){af.filters_div.hide()}af.make_name_popup_menu()}}},update_auto_mode:function(ac){if(this.mode=="Auto"){if(ac=="no_detail"){ac="feature spans"}else{if(ac=="summary_tree"){ac="coverage histogram"}}this.mode_div.text("Auto ("+ac+")")}},incremental_slots:function(ag,ad,af){var ae=this.view.canvas_manager.dummy_context,ac=this.inc_slots[ag];if(!ac||(ac.mode!==af)){ac=new (p.FeatureSlotter)(ag,af==="Pack",w,function(ah){return ae.measureText(ah)});ac.mode=af;this.inc_slots[ag]=ac}return ac.slot_features(ad)},get_summary_tree_data:function(ag,aj,ae,ar){if(ar>ae-aj){ar=ae-aj}var an=Math.floor((ae-aj)/ar),aq=[],af=0;var ah=0,ai=0,am,ap=0,ak=[],ao,al;var ad=function(av,au,aw,at){av[0]=au+aw*at;av[1]=au+(aw+1)*at};while(ap<ar&&ah!==ag.length){var ac=false;for(;ap<ar&&!ac;ap++){ad(ak,aj,ap,an);for(ai=ah;ai<ag.length;ai++){am=ag[ai].slice(1,3);if(is_overlap(am,ak)){ac=true;break}}if(ac){break}}data_start_index=ai;aq[aq.length]=ao=[ak[0],0];for(;ai<ag.length;ai++){am=ag[ai].slice(1,3);if(is_overlap(am,ak)){ao[1]++}else{break}}if(ao[1]>af){af=ao[1]}ap++}return{max:af,delta:an,data:aq}},draw_tile:function(ap,ay,aC,al,af){var av=this,aE=aC*N*ay,ad=(aC+1)*N*ay,ar=ad-aE,aw=Math.ceil(ar*al),at=this.mode,aI=25,ag=this.left_offset,aq,ah;if(at==="Auto"){if(ap.dataset_type==="summary_tree"){at=ap.dataset_type}else{if(ap.extra_info==="no_detail"){at="no_detail"}else{var aH=ap.data;if(this.view.high-this.view.low>F){at="Squish"}else{at="Pack"}}}this.update_auto_mode(at)}if(at==="summary_tree"||at==="Histogram"){ah=this.summary_draw_height;this.container_div.find(".yaxislabel").remove();var ac=$("<div />").addClass("yaxislabel");ac.text(ap.max);ac.css({position:"absolute",top:"24px",left:"10px",color:this.prefs.label_color});ac.prependTo(this.container_div);var ae=this.view.canvas_manager.new_canvas();ae.width=aw+ag;ae.height=ah+P;if(ap.dataset_type!="summary_tree"){var am=this.get_summary_tree_data(ap.data,aE,ad,200);if(ap.max){am.max=ap.max}ap=am}var aF=new I.SummaryTreePainter(ap,aE,ad,this.prefs);var ax=ae.getContext("2d");ax.translate(ag,P);aF.draw(ax,aw,ah);return new l(aC,ay,ae,ap.data,ap.max)}var aq,aj=1;if(at==="no_detail"||at==="Squish"||at==="Pack"){aj=this.incremental_slots(al,ap.data,at);aq=this.inc_slots[al].slots}var ak=[];if(ap.data){var an=this.filters_manager.filters;for(var az=0,aB=ap.data.length;az<aB;az++){var ai=ap.data[az];var aA=false;var ao;for(var aD=0,aG=an.length;aD<aG;aD++){ao=an[aD];ao.update_attrs(ai);if(!ao.keep(ai)){aA=true;break}}if(!aA){ak.push(ai)}}}var au=(this.filters_manager.alpha_filter?new L(this.filters_manager.alpha_filter):null);var aF=new (this.painter)(ak,aE,ad,this.prefs,at,au,af);var ah=Math.max(aa,aF.get_required_height(aj));var ae=this.view.canvas_manager.new_canvas();ae.width=aw+ag;ae.height=ah;var ax=ae.getContext("2d");ax.fillStyle=this.prefs.block_color;ax.font=ax.canvas.manager.default_font;ax.textAlign="right";this.container_div.find(".yaxislabel").remove();if(ap.data){ax.translate(ag,0);aF.draw(ax,aw,ah,aq)}return new M(aC,ay,ae,ap.data,ap.message)}});var Q=function(af,ad,ah,ac,ae,ag){e.call(this,af,ad,ah,ac,ae,ag);this.painter=I.VariantPainter};n(Q.prototype,J.prototype,e.prototype);var T=function(af,ad,ah,ac,ae,ag){e.call(this,af,ad,ah,ac,ae,ag);this.track_config=new W({track:this,params:[{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:ae,onchange:function(){this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.track_config.values;this.painter=I.ReadPainter;this.make_name_popup_menu()};n(T.prototype,J.prototype,e.prototype);var R=function(ag,ae,ai,ac,af,ah,ad){e.call(this,ag,ae,ai,ac,af,ah,{},ad);this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};n(R.prototype,J.prototype,e.prototype,{predraw_init:function(){var ad=this;var ac=function(){if(ad.data_manager.size()===0){setTimeout(ac,300)}else{ad.data_url=default_data_url;ad.data_query_wait=H;ad.dataset_state_url=converted_datasets_state_url;$.getJSON(ad.dataset_state_url,{dataset_id:ad.dataset_id,hda_ldda:ad.hda_ldda},function(ae){})}};ac()}});U.View=Z;U.LineTrack=k;U.FeatureTrack=e;U.ReadTrack=T};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
--- a/static/scripts/trackster.js Thu Aug 25 11:28:01 2011 -0400 +++ b/static/scripts/trackster.js Thu Aug 25 11:37:07 2011 -0400 @@ -1280,7 +1280,7 @@ // No element to filter on. return true; } - var val = parseInt(element[this.index]); + var val = parseFloat(element[this.index]); return (isNaN(val) || (val >= this.low && val <= this.high)); }, /**
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.
galaxy-commits@lists.galaxyproject.org