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