1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/2157b57ca8e4/ Changeset: 2157b57ca8e4 User: guerler Date: 2013-10-11 20:29:38 Summary: Add datatypes to api and connect with file type selector of the upload front end Affected #: 14 files diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 lib/galaxy/webapps/galaxy/api/datatypes.py --- /dev/null +++ b/lib/galaxy/webapps/galaxy/api/datatypes.py @@ -0,0 +1,25 @@ +""" +API operations allowing clients to determine datatype supported by Galaxy. +""" + +from galaxy import web +from galaxy.web.base.controller import BaseAPIController +from galaxy.datatypes.registry import Registry + +import logging +log = logging.getLogger( __name__ ) + +class DatatypesController( BaseAPIController ): + @web.expose_api + def index( self, trans, **kwd ): + """ + GET /api/datatypes + Return an object containing datatypes. + """ + try: + return trans.app.datatypes_registry.upload_file_formats + + except Exception, exception: + log.error( 'could not get datatypes: %s', str( exception ), exc_info=True ) + trans.response.status = 500 + return { 'error': str( exception ) } \ No newline at end of file diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -162,6 +162,7 @@ webapp.mapper.resource( 'workflow', 'workflows', path_prefix='/api' ) webapp.mapper.resource_with_deleted( 'history', 'histories', path_prefix='/api' ) webapp.mapper.resource( 'configuration', 'configuration', path_prefix='/api' ) + webapp.mapper.resource( 'datatype', 'datatypes', path_prefix='/api' ) #webapp.mapper.connect( 'run_workflow', '/api/workflow/{workflow_id}/library/{library_id}', controller='workflows', action='run', workflow_id=None, library_id=None, conditions=dict(method=["GET"]) ) webapp.mapper.resource( 'search', 'search', path_prefix='/api' ) diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/galaxy.upload.js --- a/static/scripts/galaxy.upload.js +++ b/static/scripts/galaxy.upload.js @@ -3,7 +3,7 @@ */ // dependencies -define(["galaxy.modal", "galaxy.master", "utils/galaxy.uploadbox", "libs/backbone/backbone-relational"], function(mod_modal, mod_master) { +define(["galaxy.modal", "galaxy.master", "utils/galaxy.utils", "utils/galaxy.uploadbox", "libs/backbone/backbone-relational"], function(mod_modal, mod_master, mod_util) { // galaxy upload var GalaxyUpload = Backbone.View.extend( @@ -69,6 +69,17 @@ // add to master Galaxy.master.prepend(this.button_show); + + // load extension + var self = this; + mod_util.jsonFromUrl(galaxy_config.root + "api/datatypes", + function(datatypes) { + for (key in datatypes) { + var filetype = datatypes[key]; + self.select_extension[filetype] = filetype; + } + }); + }, // events @@ -294,9 +305,20 @@ if (this.counter.running == 0) return; - // initiate upload procedure in plugin + // request pause this.uploadbox.pause(); - + + // set html content + $('#upload-info').html('Queueing will pause after completing the current file...'); + }, + + // queue is done + event_complete: function() + { + // update running + this.counter.running = 0; + this.update_screen(); + // switch icons for new uploads var items = $(this.el).find('.upload-item'); var self = this; @@ -314,17 +336,6 @@ $(this).find('#space_to_tabs').attr('disabled', false); } }); - - // set html content - $('#upload-info').html('Queueing will pause after completing the current file.'); - }, - - // queue is done - event_complete: function() - { - // update running - this.counter.running = 0; - this.update_screen(); }, // remove all diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/packed/galaxy.upload.js --- a/static/scripts/packed/galaxy.upload.js +++ b/static/scripts/packed/galaxy.upload.js @@ -1,1 +1,1 @@ -define(["galaxy.modal","galaxy.master","utils/galaxy.uploadbox","libs/backbone/backbone-relational"],function(b,c){var a=Backbone.View.extend({modal:null,button_show:null,uploadbox:null,select_extension:{auto:"Auto-detect"},state:{init:"fa-icon-trash",queued:"fa-icon-spinner fa-icon-spin",running:"__running__",success:"fa-icon-ok",error:"fa-icon-warning-sign"},counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},initialize:function(){if(!Galaxy.currHistoryPanel){var d=this;window.setTimeout(function(){d.initialize()},500);return}var d=this;this.button_show=new c.GalaxyMasterIcon({icon:"fa-icon-upload",tooltip:"Upload Files",on_click:function(f){d.event_show(f)},with_number:true});Galaxy.master.prepend(this.button_show)},events:{mouseover:"event_mouseover",mouseleave:"event_mouseleave"},event_mouseover:function(d){},event_mouseleave:function(d){},event_announce:function(e,f,h){var i="#upload-"+e;$(this.el).find("tbody:last").append(this.template_row(i,this.select_extension));var g=this.get_upload_item(e);g.fadeIn();g.find("#title").html(f.name);g.find("#size").html(this.size_to_string(f.size));var d=this;g.find("#symbol").on("click",function(){d.event_remove(e)});this.event_progress(e,f,0);this.counter.announce++;this.update_screen()},event_initialize:function(f,g,j){this.button_show.number(this.counter.announce);var h=this.get_upload_item(f);var k=h.find("#symbol");k.addClass(this.state.running);var d=Galaxy.currHistoryPanel.model.get("id");var e=h.find("#extension").val();var i=h.find("#space_to_tabs").is(":checked");this.uploadbox.configure({url:galaxy_config.root+"api/tools/",paramname:"files_0|file_data"});tool_input={};tool_input.dbkey="?";tool_input.file_type=e;tool_input["files_0|NAME"]=g.name;tool_input["files_0|type"]="upload_dataset";tool_input.space_to_tabs=i;data={};data.history_id=d;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},event_progress:function(e,f,h){var g=this.get_upload_item(e);var d=parseInt(h);g.find(".progress-bar").css({width:d+"%"});if(d!=100){g.find("#percentage").html(d+"%")}else{g.find("#percentage").html("Adding to history...")}},event_success:function(d,e,g){Galaxy.currHistoryPanel.refresh();this.event_progress(d,e,100);this.button_show.number("");this.counter.announce--;this.counter.success++;this.update_screen();var f=this.get_upload_item(d);f.addClass("success");f.find("#percentage").html("100%");var h=f.find("#symbol");h.removeClass(this.state.running);h.removeClass(this.state.queued);h.addClass(this.state.success)},event_error:function(d,e,g){this.event_progress(d,e,0);this.button_show.number("");this.counter.announce--;this.counter.error++;this.update_screen();var f=this.get_upload_item(d);f.addClass("danger");f.find(".progress").remove();f.find("#info").html("<strong>Failed: </strong>"+g).show();var h=f.find("#symbol");h.removeClass(this.state.running);h.removeClass(this.state.queued);h.addClass(this.state.error)},event_upload:function(){if(this.counter.announce==0||this.counter.running>0){return}var e=$(this.el).find(".upload-item");var d=this;e.each(function(){var f=$(this).find("#symbol");if(f.hasClass(d.state.init)){f.removeClass(d.state.init);f.addClass(d.state.queued);$(this).find("#extension").attr("disabled",true);$(this).find("#space_to_tabs").attr("disabled",true)}});this.counter.running=this.counter.announce;this.update_screen();this.uploadbox.upload()},event_pause:function(){if(this.counter.running==0){return}this.uploadbox.pause();var e=$(this.el).find(".upload-item");var d=this;e.each(function(){var f=$(this).find("#symbol");if(f.hasClass(d.state.queued)&&!f.hasClass(d.state.running)){f.removeClass(d.state.queued);f.addClass(d.state.init);$(this).find("#extension").attr("disabled",false);$(this).find("#space_to_tabs").attr("disabled",false)}})},event_complete:function(){this.counter.running=0;this.update_screen()},event_reset:function(){if(this.counter.running==0){var d=$(this.el).find(".upload-item");$(this.el).find("table").fadeOut({complete:function(){d.remove()}});this.counter.reset();this.update_screen();this.uploadbox.reset()}},event_remove:function(d){var e=this.get_upload_item(d);var f=e.find("#symbol");if(f.hasClass(this.state.init)||f.hasClass(this.state.success)||f.hasClass(this.state.error)){if(e.hasClass("success")){this.counter.success--}else{if(e.hasClass("danger")){this.counter.error--}else{this.counter.announce--}}this.update_screen();this.uploadbox.remove(d);e.remove()}},event_show:function(f){f.preventDefault();if(!this.modal){var d=this;this.modal=new b.GalaxyModal({title:"Upload files from your local drive",body:this.template("upload-box","upload-info"),buttons:{Select:function(){d.uploadbox.select()},Upload:function(){d.event_upload()},Pause:function(){d.event_pause()},Reset:function(){d.event_reset()},Close:function(){d.modal.hide()}},height:"350"});this.setElement("#upload-box");var d=this;this.uploadbox=this.$el.uploadbox({dragover:d.event_mouseover,dragleave:d.event_mouseleave,announce:function(e,g,h){d.event_announce(e,g,h)},initialize:function(e,g,h){return d.event_initialize(e,g,h)},success:function(e,g,h){d.event_success(e,g,h)},progress:function(e,g,h){d.event_progress(e,g,h)},error:function(e,g,h){d.event_error(e,g,h)},complete:function(){d.event_complete()},});this.update_screen()}this.modal.show()},get_upload_item:function(d){return $(this.el).find("#upload-"+d)},size_to_string:function(d){var e="";if(d>=100000000000){d=d/100000000000;e="TB"}else{if(d>=100000000){d=d/100000000;e="GB"}else{if(d>=100000){d=d/100000;e="MB"}else{if(d>=100){d=d/100;e="KB"}else{d=d*10;e="b"}}}}return"<strong>"+(Math.round(d)/10)+"</strong> "+e},update_screen:function(){if(this.counter.announce==0){if(this.uploadbox.compatible){message="Drag&drop files into this box or click 'Select' to select files!"}else{message="Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Please upgrade to i.e. Firefox 4+, Chrome 7+, IE 10+, Opera 12+ or Safari 6+."}}else{if(this.counter.running==0){message="You added "+this.counter.announce+" file(s) to the queue. Add more files or click 'Upload' to proceed."}else{message="Please wait..."+this.counter.announce+" out of "+this.counter.running+" remaining."}}$("#upload-info").html(message);if(this.counter.running==0&&this.counter.announce+this.counter.success+this.counter.error>0){this.modal.enableButton("Reset")}else{this.modal.disableButton("Reset")}if(this.counter.running==0&&this.counter.announce>0){this.modal.enableButton("Upload")}else{this.modal.disableButton("Upload")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Select")}else{this.modal.disableButton("Select")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("table").show()}else{$(this.el).find("table").hide()}},template:function(e,d){return'<div id="'+e+'" class="upload-box"><table class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Space→Tab</th><th>Progress</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+d+'" class="upload-info"></h6>'},template_row:function(f,e){var d='<tr id="'+f.substr(1)+'" class="upload-item"><td><div id="title" class="title"></div></td><td><div id="size" class="size"></div></td><td><select id="extension">';for(key in e){d+='<option value="'+key+'">'+e[key]+"</option>"}d+='</select></td><td><input id="space_to_tabs" type="checkbox"></input></td><td><div id="info" class="info"><div class="progress"><div class="progress-bar progress-bar-success"></div><div id="percentage" class="percentage">0%</div></div></div></td><td><div id="symbol" class="symbol '+this.state.init+'"></div></td></tr>';return d}});return{GalaxyUpload:a}}); \ No newline at end of file +define(["galaxy.modal","galaxy.master","utils/galaxy.utils","utils/galaxy.uploadbox","libs/backbone/backbone-relational"],function(b,d,c){var a=Backbone.View.extend({modal:null,button_show:null,uploadbox:null,select_extension:{auto:"Auto-detect"},state:{init:"fa-icon-trash",queued:"fa-icon-spinner fa-icon-spin",running:"__running__",success:"fa-icon-ok",error:"fa-icon-warning-sign"},counter:{announce:0,success:0,error:0,running:0,reset:function(){this.announce=this.success=this.error=this.running=0}},initialize:function(){if(!Galaxy.currHistoryPanel){var e=this;window.setTimeout(function(){e.initialize()},500);return}var e=this;this.button_show=new d.GalaxyMasterIcon({icon:"fa-icon-upload",tooltip:"Upload Files",on_click:function(f){e.event_show(f)},with_number:true});Galaxy.master.prepend(this.button_show);var e=this;c.jsonFromUrl(galaxy_config.root+"api/datatypes",function(g){for(key in g){var f=g[key];e.select_extension[f]=f}})},events:{mouseover:"event_mouseover",mouseleave:"event_mouseleave"},event_mouseover:function(f){},event_mouseleave:function(f){},event_announce:function(f,g,i){var j="#upload-"+f;$(this.el).find("tbody:last").append(this.template_row(j,this.select_extension));var h=this.get_upload_item(f);h.fadeIn();h.find("#title").html(g.name);h.find("#size").html(this.size_to_string(g.size));var e=this;h.find("#symbol").on("click",function(){e.event_remove(f)});this.event_progress(f,g,0);this.counter.announce++;this.update_screen()},event_initialize:function(g,h,k){this.button_show.number(this.counter.announce);var i=this.get_upload_item(g);var l=i.find("#symbol");l.addClass(this.state.running);var e=Galaxy.currHistoryPanel.model.get("id");var f=i.find("#extension").val();var j=i.find("#space_to_tabs").is(":checked");this.uploadbox.configure({url:galaxy_config.root+"api/tools/",paramname:"files_0|file_data"});tool_input={};tool_input.dbkey="?";tool_input.file_type=f;tool_input["files_0|NAME"]=h.name;tool_input["files_0|type"]="upload_dataset";tool_input.space_to_tabs=j;data={};data.history_id=e;data.tool_id="upload1";data.inputs=JSON.stringify(tool_input);return data},event_progress:function(f,g,i){var h=this.get_upload_item(f);var e=parseInt(i);h.find(".progress-bar").css({width:e+"%"});if(e!=100){h.find("#percentage").html(e+"%")}else{h.find("#percentage").html("Adding to history...")}},event_success:function(e,f,h){this.event_progress(e,f,100);this.button_show.number("");this.counter.announce--;this.counter.success++;this.update_screen();var g=this.get_upload_item(e);g.addClass("success");g.find("#percentage").html("100%");var i=g.find("#symbol");i.removeClass(this.state.running);i.removeClass(this.state.queued);i.addClass(this.state.success);Galaxy.currHistoryPanel.refresh()},event_error:function(e,f,h){this.event_progress(e,f,0);this.button_show.number("");this.counter.announce--;this.counter.error++;this.update_screen();var g=this.get_upload_item(e);g.addClass("danger");g.find(".progress").remove();g.find("#info").html("<strong>Failed: </strong>"+h).show();var i=g.find("#symbol");i.removeClass(this.state.running);i.removeClass(this.state.queued);i.addClass(this.state.error)},event_upload:function(){if(this.counter.announce==0||this.counter.running>0){return}var f=$(this.el).find(".upload-item");var e=this;f.each(function(){var g=$(this).find("#symbol");if(g.hasClass(e.state.init)){g.removeClass(e.state.init);g.addClass(e.state.queued);$(this).find("#extension").attr("disabled",true);$(this).find("#space_to_tabs").attr("disabled",true)}});this.counter.running=this.counter.announce;this.update_screen();this.uploadbox.upload()},event_pause:function(){if(this.counter.running==0){return}this.uploadbox.pause();$("#upload-info").html("Queueing will pause after completing the current file...")},event_complete:function(){this.counter.running=0;this.update_screen();var f=$(this.el).find(".upload-item");var e=this;f.each(function(){var g=$(this).find("#symbol");if(g.hasClass(e.state.queued)&&!g.hasClass(e.state.running)){g.removeClass(e.state.queued);g.addClass(e.state.init);$(this).find("#extension").attr("disabled",false);$(this).find("#space_to_tabs").attr("disabled",false)}})},event_reset:function(){if(this.counter.running==0){var e=$(this.el).find(".upload-item");$(this.el).find("table").fadeOut({complete:function(){e.remove()}});this.counter.reset();this.update_screen();this.uploadbox.reset()}},event_remove:function(e){var f=this.get_upload_item(e);var g=f.find("#symbol");if(g.hasClass(this.state.init)||g.hasClass(this.state.success)||g.hasClass(this.state.error)){if(f.hasClass("success")){this.counter.success--}else{if(f.hasClass("danger")){this.counter.error--}else{this.counter.announce--}}this.update_screen();this.uploadbox.remove(e);f.remove()}},event_show:function(g){g.preventDefault();if(!this.modal){var f=this;this.modal=new b.GalaxyModal({title:"Upload files from your local drive",body:this.template("upload-box","upload-info"),buttons:{Select:function(){f.uploadbox.select()},Upload:function(){f.event_upload()},Pause:function(){f.event_pause()},Reset:function(){f.event_reset()},Close:function(){f.modal.hide()}},height:"350"});this.setElement("#upload-box");var f=this;this.uploadbox=this.$el.uploadbox({dragover:f.event_mouseover,dragleave:f.event_mouseleave,announce:function(e,h,i){f.event_announce(e,h,i)},initialize:function(e,h,i){return f.event_initialize(e,h,i)},success:function(e,h,i){f.event_success(e,h,i)},progress:function(e,h,i){f.event_progress(e,h,i)},error:function(e,h,i){f.event_error(e,h,i)},complete:function(){f.event_complete()},});this.update_screen()}this.modal.show()},get_upload_item:function(e){return $(this.el).find("#upload-"+e)},size_to_string:function(e){var f="";if(e>=100000000000){e=e/100000000000;f="TB"}else{if(e>=100000000){e=e/100000000;f="GB"}else{if(e>=100000){e=e/100000;f="MB"}else{if(e>=100){e=e/100;f="KB"}else{e=e*10;f="b"}}}}return"<strong>"+(Math.round(e)/10)+"</strong> "+f},update_screen:function(){if(this.counter.announce==0){if(this.uploadbox.compatible){message="Drag&drop files into this box or click 'Select' to select files!"}else{message="Unfortunately, your browser does not support multiple file uploads or drag&drop.<br>Please upgrade to i.e. Firefox 4+, Chrome 7+, IE 10+, Opera 12+ or Safari 6+."}}else{if(this.counter.running==0){message="You added "+this.counter.announce+" file(s) to the queue. Add more files or click 'Upload' to proceed."}else{message="Please wait..."+this.counter.announce+" out of "+this.counter.running+" remaining."}}$("#upload-info").html(message);if(this.counter.running==0&&this.counter.announce+this.counter.success+this.counter.error>0){this.modal.enableButton("Reset")}else{this.modal.disableButton("Reset")}if(this.counter.running==0&&this.counter.announce>0){this.modal.enableButton("Upload")}else{this.modal.disableButton("Upload")}if(this.counter.running>0){this.modal.enableButton("Pause")}else{this.modal.disableButton("Pause")}if(this.counter.running==0){this.modal.enableButton("Select")}else{this.modal.disableButton("Select")}if(this.counter.announce+this.counter.success+this.counter.error>0){$(this.el).find("table").show()}else{$(this.el).find("table").hide()}},template:function(f,e){return'<div id="'+f+'" class="upload-box"><table class="table table-striped" style="display: none;"><thead><tr><th>Name</th><th>Size</th><th>Type</th><th>Space→Tab</th><th>Progress</th><th></th></tr></thead><tbody></tbody></table></div><h6 id="'+e+'" class="upload-info"></h6>'},template_row:function(g,f){var e='<tr id="'+g.substr(1)+'" class="upload-item"><td><div id="title" class="title"></div></td><td><div id="size" class="size"></div></td><td><select id="extension">';for(key in f){e+='<option value="'+key+'">'+f[key]+"</option>"}e+='</select></td><td><input id="space_to_tabs" type="checkbox"></input></td><td><div id="info" class="info"><div class="progress"><div class="progress-bar progress-bar-success"></div><div id="percentage" class="percentage">0%</div></div></div></td><td><div id="symbol" class="symbol '+this.state.init+'"></div></td></tr>';return e}});return{GalaxyUpload:a}}); \ No newline at end of file diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/packed/utils/galaxy.css.js --- a/static/scripts/packed/utils/galaxy.css.js +++ /dev/null @@ -1,1 +0,0 @@ -define(["libs/underscore"],function(a){function b(g,d){var e=$('<div class="'+g+'"></div>');e.appendTo(":eq(0)");var f=e.css(d);e.remove();return f}function c(d){if(!$('link[href^="'+d+'"]').length){$('<link href="'+galaxy_config.root+d+'" rel="stylesheet">').appendTo("head")}}return{load_file:c,get_attribute:b}}); \ No newline at end of file diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/packed/utils/galaxy.uploadbox.js --- a/static/scripts/packed/utils/galaxy.uploadbox.js +++ b/static/scripts/packed/utils/galaxy.uploadbox.js @@ -1,1 +1,1 @@ -(function(g){jQuery.event.props.push("dataTransfer");var c={url:"",paramname:"content",maxfilesize:250,maxfilenumber:20,dragover:function(){},dragleave:function(){},announce:function(){},initialize:function(){},progress:function(){},success:function(){},error:function(i,j,k){alert(k)},complete:function(){},error_filesize:"File exceeds 250MB. Please use an FTP client.",error_default:"Please make sure the file is available.",error_toomany:"You can only queue <20 files per upload session."};var f={};var a={};var b=0;var d=0;var h=false;var e=null;g.fn.uploadbox=function(y){f=g.extend({},c,y);e=this;e.append('<input id="uploadbox_input" type="file" style="display: none" multiple>');e.on("drop",l);e.on("dragover",m);e.on("dragleave",t);g("#uploadbox_input").change(function(z){v(z.target.files);g(this).val("")});function l(z){if(!z.dataTransfer){return}v(z.dataTransfer.files);z.preventDefault();return false}function m(z){z.preventDefault();f.dragover.call(z)}function t(z){z.stopPropagation();f.dragleave.call(z)}function i(z){if(z.lengthComputable){f.progress(this.index,this.file,Math.round((z.loaded*100)/z.total))}}function v(B){if(h){return}for(var A=0;A<B.length;A++){if(d>=f.maxfilenumber){break}var z=String(b++);a[z]=B[A];f.announce(z,a[z],"");d++}}function o(z){if(a[z]){delete a[z];d--}}function j(){if(d==0||!h){h=false;f.complete();return}else{h=true}var C=-1;for(var E in a){C=E;break}var D=a[C];o(C);var G=f.initialize(C,D);try{var A=new FileReader();var B=D.size;var z=1048576*f.maxfilesize;A.index=C;if(B<z){A.onload=function(H){n(C,D,G)};A.onerror=function(H){r(C,D,f.error_default)};A.readAsDataURL(D)}else{r(C,D,f.error_filesize)}}catch(F){r(C,D,F)}}function n(z,B,C){var D=new FormData();for(var A in C){D.append(A,C[A])}D.append(f.paramname,B,B.name);var E=new XMLHttpRequest();E.onloadend=function(){var F=null;if(E.responseText){try{F=jQuery.parseJSON(E.responseText)}catch(G){F=E.responseText}}if(E.status<200||E.status>299){var H=E.statusText;if(!E.statusText){H=f.error_default}r(z,B,H+" (Server Code "+E.status+")")}else{u(z,B,F)}};E.upload.index=z;E.upload.file=B;E.upload.addEventListener("progress",i,false);E.open("POST",f.url,true);E.setRequestHeader("Accept","application/json");E.setRequestHeader("Cache-Control","no-cache");E.setRequestHeader("X-Requested-With","XMLHttpRequest");E.send(D)}function u(z,A,B){f.success(z,A,B);j()}function r(z,A,B){f.error(z,A,B);j()}function s(){g("#uploadbox_input").trigger("click")}function q(z){for(z in a){o(z)}}function x(){if(!h){h=true;j()}}function w(){h=false}function k(z){f=g.extend({},f,z);return f}function p(){return window.File&&window.FileReader&&window.FormData&&window.XMLHttpRequest&&window.FileList}return{select:s,remove:o,upload:x,pause:w,reset:q,configure:k,compatible:p}}})(jQuery); \ No newline at end of file +(function(d){jQuery.event.props.push("dataTransfer");var h={url:"",paramname:"content",maxfilesize:250,maxfilenumber:20,dragover:function(){},dragleave:function(){},announce:function(){},initialize:function(){},progress:function(){},success:function(){},error:function(j,k,l){alert(l)},complete:function(){},error_filesize:"File exceeds 250MB. Please use an FTP client.",error_default:"Please make sure the file is available.",error_server:"The server is unavailable.",error_toomany:"You can only queue <20 files per upload session."};var b={};var f={};var g=0;var i=0;var e=false;var a=false;var c=null;d.fn.uploadbox=function(z){b=d.extend({},h,z);c=this;c.append('<input id="uploadbox_input" type="file" style="display: none" multiple>');c.on("drop",m);c.on("dragover",n);c.on("dragleave",u);d("#uploadbox_input").change(function(A){w(A.target.files);d(this).val("")});function m(A){if(!A.dataTransfer){return}w(A.dataTransfer.files);A.preventDefault();return false}function n(A){A.preventDefault();b.dragover.call(A)}function u(A){A.stopPropagation();b.dragleave.call(A)}function j(A){if(A.lengthComputable){b.progress(this.index,this.file,Math.round((A.loaded*100)/A.total))}}function w(C){if(e){return}for(var B=0;B<C.length;B++){if(i>=b.maxfilenumber){break}var A=String(g++);f[A]=C[B];b.announce(A,f[A],"");i++}}function p(A){if(f[A]){delete f[A];i--}}function k(){if(i==0||a){a=false;e=false;b.complete();return}else{e=true}var D=-1;for(var F in f){D=F;break}var E=f[D];p(D);var H=b.initialize(D,E);try{var B=new FileReader();var C=E.size;var A=1048576*b.maxfilesize;B.index=D;if(C<A){B.onload=function(I){o(D,E,H)};B.onerror=function(I){s(D,E,b.error_default)};B.onabort=function(I){s(D,E,b.error_default)};B.readAsDataURL(E)}else{s(D,E,b.error_filesize)}}catch(G){s(D,E,G)}}function o(A,C,D){var E=new FormData();for(var B in D){E.append(B,D[B])}E.append(b.paramname,C,C.name);var F=new XMLHttpRequest();F.onreadystatechange=function(){if(F.readyState!=F.DONE){return}var G=null;if(F.responseText){try{G=jQuery.parseJSON(F.responseText)}catch(H){G=F.responseText}}if(F.status<200||F.status>299){var I=F.statusText;if(!F.statusText){if(F.status==0){I=b.error_server}else{I=b.error_default}}s(A,C,I+" ("+F.status+")")}else{v(A,C,G)}};F.upload.index=A;F.upload.file=C;F.upload.addEventListener("progress",j,false);F.open("POST",b.url,true);F.setRequestHeader("Accept","application/json");F.setRequestHeader("Cache-Control","no-cache");F.setRequestHeader("X-Requested-With","XMLHttpRequest");F.send(E)}function v(A,B,C){b.success(A,B,C);k()}function s(A,B,C){b.error(A,B,C);k()}function t(){d("#uploadbox_input").trigger("click")}function r(A){for(A in f){p(A)}}function y(){if(!e){e=true;k()}}function x(){a=true}function l(A){b=d.extend({},b,A);return b}function q(){return window.File&&window.FileReader&&window.FormData&&window.XMLHttpRequest&&window.FileList}return{select:t,remove:p,upload:y,pause:x,reset:r,configure:l,compatible:q}}})(jQuery); \ No newline at end of file diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/packed/utils/galaxy.utils.js --- /dev/null +++ b/static/scripts/packed/utils/galaxy.utils.js @@ -0,0 +1,1 @@ +define(["libs/underscore"],function(c){function d(g,f,e){var h=new XMLHttpRequest();h.open("GET",g,true);h.setRequestHeader("Accept","application/json");h.setRequestHeader("Cache-Control","no-cache");h.setRequestHeader("X-Requested-With","XMLHttpRequest");h.onloadend=function(){var i=h.status;if(i==200){try{response=jQuery.parseJSON(h.responseText)}catch(j){response=h.responseText}f&&f(response)}else{e&&e(i)}};h.send()}function b(h,e){var f=$('<div class="'+h+'"></div>');f.appendTo(":eq(0)");var g=f.css(e);f.remove();return g}function a(e){if(!$('link[href^="'+e+'"]').length){$('<link href="'+galaxy_config.root+e+'" rel="stylesheet">').appendTo("head")}}return{cssLoadFile:a,cssGetAttribute:b,jsonFromUrl:d}}); \ No newline at end of file diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/packed/viz/trackster/tracks.js --- a/static/scripts/packed/viz/trackster/tracks.js +++ b/static/scripts/packed/viz/trackster/tracks.js @@ -1,1 +1,1 @@ -define(["libs/underscore","viz/visualization","viz/trackster/util","viz/trackster/slotting","viz/trackster/painters","viz/trackster/filters","mvc/data","mvc/tools"],function(ad,y,l,u,M,i,Y,S){var q=ad.extend;var n={};var k=function(ae,af){n[ae.attr("id")]=af};var m=function(ae,ag,ai,ah){ai=".group";var af={};n[ae.attr("id")]=ah;ae.bind("drag",{handle:"."+ag,relative:true},function(aq,ar){var ap=$(this),av=$(this).parent(),am=av.children(),ao=n[$(this).attr("id")],al,ak,at,aj,an;ak=$(this).parents(ai);if(ak.length!==0){at=ak.position().top;aj=at+ak.outerHeight();if(ar.offsetY<at){$(this).insertBefore(ak);var au=n[ak.attr("id")];au.remove_drawable(ao);au.container.add_drawable_before(ao,au);return}else{if(ar.offsetY>aj){$(this).insertAfter(ak);var au=n[ak.attr("id")];au.remove_drawable(ao);au.container.add_drawable(ao);return}}}ak=null;for(an=0;an<am.length;an++){al=$(am.get(an));at=al.position().top;aj=at+al.outerHeight();if(al.is(ai)&&this!==al.get(0)&&ar.offsetY>=at&&ar.offsetY<=aj){if(ar.offsetY-at<aj-ar.offsetY){al.find(".content-div").prepend(this)}else{al.find(".content-div").append(this)}if(ao.container){ao.container.remove_drawable(ao)}n[al.attr("id")].add_drawable(ao);return}}for(an=0;an<am.length;an++){al=$(am.get(an));if(ar.offsetY<al.position().top&&!(al.hasClass("reference-track")||al.hasClass("intro"))){break}}if(an===am.length){if(this!==am.get(an-1)){av.append(this);n[av.attr("id")].move_drawable(ao,an)}}else{if(this!==am.get(an)){$(this).insertBefore(am.get(an));n[av.attr("id")].move_drawable(ao,(ar.deltaY>0?an-1:an))}}}).bind("dragstart",function(){af["border-top"]=ae.css("border-top");af["border-bottom"]=ae.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(af)})};var ab=16,H=9,F=20,B=100,J=12000,T=400,L=5000,x=100,o="Cannot display dataset due to an error. ",K="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",G="No data for this chrom/contig.",w="Preparing data. This can take a while for a large dataset. If the visualization is saved and closed, preparation will continue in the background.",z="Tool cannot be rerun: ",b="Loading data...",V="Ready for display",R=10,I=20,C=["Histogram","Line","Filled","Intensity"];function W(af,ae){if(!ae){ae=0}var ag=Math.pow(10,ae);return Math.round(af*ag)/ag}var r=function(af,ae,ah){if(!r.id_counter){r.id_counter=0}this.id=r.id_counter++;this.name=ah.name;this.view=af;this.container=ae;this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name}],saved_values:ah.prefs,onchange:function(){this.track.set_name(this.track.config.get("values").name)}});this.prefs=this.config.get("values");this.drag_handle_class=ah.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(ai){ai.stopPropagation()});var ag=this;this.container_div.hover(function(){ag.icons_div.show()},function(){ag.icons_div.hide()});$("<div style='clear: both'/>").appendTo(this.container_div)}};r.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(ae){if(ae.content_visible){ae.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");ae.hide_contents();ae.content_visible=false}else{ae.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");ae.content_visible=true;ae.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"settings-icon",on_click_fn:function(af){var ae=new a({model:af.config});ae.render()}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(ae){$(".tooltip").remove();ae.remove()}}];q(r.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(ae){},to_dict:function(){},set_name:function(ae){this.old_name=this.name;this.name=ae;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 ae=this.view;this.container_div.hide(0,function(){$(this).remove();ae.update_intro_div()})},build_container_div:function(){},build_header_div:function(){},add_action_icon:function(af,ak,aj,ai,ae,ah){var ag=this;this.action_icons[af]=$("<a/>").attr("href","javascript:void(0);").attr("title",ak).addClass("icon-button").addClass(aj).tooltip().click(function(){ai(ag)}).appendTo(this.icons_div);if(ah){this.action_icons[af].hide()}},build_action_icons:function(ae){var ag;for(var af=0;af<ae.length;af++){ag=ae[af];this.add_action_icon(ag.name,ag.title,ag.css_class,ag.on_click_fn,ag.prepend,ag.hide)}},update_icons:function(){},hide_contents:function(){},show_contents:function(){},get_drawables:function(){}});var A=function(af,ae,ag){r.call(this,af,ae,ag);this.obj_type=ag.obj_type;this.drawables=[]};q(A.prototype,r.prototype,{unpack_drawables:function(ag){this.drawables=[];var af;for(var ae=0;ae<ag.length;ae++){af=p(ag[ae],this.view,this);this.add_drawable(af)}},init:function(){for(var ae=0;ae<this.drawables.length;ae++){this.drawables[ae].init()}},_draw:function(ae){for(var af=0;af<this.drawables.length;af++){this.drawables[af]._draw(ae)}},to_dict:function(){var af=[];for(var ae=0;ae<this.drawables.length;ae++){af.push(this.drawables[ae].to_dict())}return{name:this.name,prefs:this.prefs,obj_type:this.obj_type,drawables:af}},add_drawable:function(ae){this.drawables.push(ae);ae.container=this;this.changed()},add_drawable_before:function(ag,ae){this.changed();var af=this.drawables.indexOf(ae);if(af!==-1){this.drawables.splice(af,0,ag);return true}return false},replace_drawable:function(ag,ae,af){var ah=this.drawables.indexOf(ag);if(ah!==-1){this.drawables[ah]=ae;if(af){ag.container_div.replaceWith(ae.container_div)}this.changed()}return ah},remove_drawable:function(af){var ae=this.drawables.indexOf(af);if(ae!==-1){this.drawables.splice(ae,1);af.container=null;this.changed();return true}return false},move_drawable:function(af,ag){var ae=this.drawables.indexOf(af);if(ae!==-1){this.drawables.splice(ae,1);this.drawables.splice(ag,0,af);this.changed();return true}return false},get_drawables:function(){return this.drawables},get_tracks:function(ah){var ae=this.drawables.slice(0),af=[],ag;while(ae.length!==0){ag=ae.shift();if(ag instanceof ah){af.push(ag)}else{if(ag.drawables){ae=ae.concat(ag.drawables)}}}return af}});var Q=function(af,ae,ah){q(ah,{obj_type:"DrawableGroup",drag_handle_class:"group-handle"});A.call(this,af,ae,ah);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);m(this.container_div,this.drag_handle_class,".group",this);this.filters_manager=new i.FiltersManager(this);this.header_div.after(this.filters_manager.parent_div);this.saved_filters_managers=[];if("drawables" in ah){this.unpack_drawables(ah.drawables)}if("filters" in ah){var ag=this.filters_manager;this.filters_manager=new i.FiltersManager(this,ah.filters);ag.parent_div.replaceWith(this.filters_manager.parent_div);if(ah.filters.visible){this.setup_multitrack_filtering()}}};q(Q.prototype,r.prototype,A.prototype,{action_icons_def:[r.prototype.action_icons_def[0],r.prototype.action_icons_def[1],{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(ae){$(".tooltip").remove();ae.show_composite_track()}},{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(ae){if(ae.filters_manager.visible()){ae.filters_manager.clear_filters();ae._restore_filter_managers()}else{ae.setup_multitrack_filtering();ae.request_draw({clear_tile_cache:true})}ae.filters_manager.toggle()}},r.prototype.action_icons_def[2]],build_container_div:function(){var ae=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(ae)}return ae},build_header_div:function(){var ae=$("<div/>").addClass("track-header");ae.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("track-name").text(this.name).appendTo(ae);return ae},hide_contents:function(){this.tiles_div.hide()},show_contents:function(){this.tiles_div.show();this.request_draw()},update_icons:function(){var ag=this.drawables.length;if(ag===0){this.action_icons.composite_icon.hide();this.action_icons.filters_icon.hide()}else{if(ag===1){if(this.drawables[0] instanceof f){this.action_icons.composite_icon.show()}this.action_icons.filters_icon.hide()}else{var an,am,ak,aq=true,ai=this.drawables[0].get_type(),ae=0;for(an=0;an<ag;an++){ak=this.drawables[an];if(ak.get_type()!==ai){can_composite=false;break}if(ak instanceof d){ae++}}if(aq||ae===1){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tooltip").remove()}if(ae>1&&ae===this.drawables.length){var ar={},af;ak=this.drawables[0];for(am=0;am<ak.filters_manager.filters.length;am++){af=ak.filters_manager.filters[am];ar[af.name]=[af]}for(an=1;an<this.drawables.length;an++){ak=this.drawables[an];for(am=0;am<ak.filters_manager.filters.length;am++){af=ak.filters_manager.filters[am];if(af.name in ar){ar[af.name].push(af)}}}this.filters_manager.remove_all();var ah,aj,al,ao;for(var ap in ar){ah=ar[ap];if(ah.length===ae){aj=new i.NumberFilter({name:ah[0].name,index:ah[0].index});this.filters_manager.add_filter(aj)}}if(this.filters_manager.filters.length>0){this.action_icons.filters_icon.show()}else{this.action_icons.filters_icon.hide()}}else{this.action_icons.filters_icon.hide()}}}},_restore_filter_managers:function(){for(var ae=0;ae<this.drawables.length;ae++){this.drawables[ae].filters_manager=this.saved_filters_managers[ae]}this.saved_filters_managers=[]},setup_multitrack_filtering:function(){if(this.filters_manager.filters.length>0){this.saved_filters_managers=[];for(var ae=0;ae<this.drawables.length;ae++){drawable=this.drawables[ae];this.saved_filters_managers.push(drawable.filters_manager);drawable.filters_manager=this.filters_manager}}this.filters_manager.init_filters()},show_composite_track:function(){var af=new f(this.view,this.view,{name:this.name,drawables:this.drawables});var ae=this.container.replace_drawable(this,af,true);af.request_draw()},add_drawable:function(ae){A.prototype.add_drawable.call(this,ae);this.update_icons()},remove_drawable:function(ae){A.prototype.remove_drawable.call(this,ae);this.update_icons()},to_dict:function(){if(this.filters_manager.visible()){this._restore_filter_managers()}var ae=q(A.prototype.to_dict.call(this),{filters:this.filters_manager.to_dict()});if(this.filters_manager.visible()){this.setup_multitrack_filtering()}return ae},request_draw:function(ae){ad.each(this.drawables,function(af){af.request_draw(ae)})}});var Z=Backbone.View.extend({initialize:function(ae){q(ae,{obj_type:"View"});A.call(this,"View",ae.container,ae);this.chrom=null;this.vis_id=ae.vis_id;this.dbkey=ae.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.render();this.canvas_manager=new y.CanvasManager(this.container.get(0).ownerDocument);this.reset();this.config=new j({track:this,params:[{key:"a_color",label:"A Color",type:"color",default_value:"#FF0000"},{key:"c_color",label:"C Color",type:"color",default_value:"#00FF00"},{key:"g_color",label:"G Color",type:"color",default_value:"#0000FF"},{key:"t_color",label:"T Color",type:"color",default_value:"#FF00FF"},{key:"n_color",label:"N Color",type:"color",default_value:"#AAAAAA"}],saved_values:ae.prefs,onchange:function(){track.request_redraw({clear_tile_cache:true})}})},render:function(){this.requested_redraw=false;var ag=this.container,ae=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ag);this.browser_content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ag);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ag);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.browser_content_div);this.content_div=this.viewport_container;k(this.viewport_container,ae);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container).hide();var ah=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){y.select_datasets(galaxy_config.root+"visualization/list_current_history_datasets",galaxy_config.root+"api/datasets",{"f-dbkey":ae.dbkey},function(ai){ad.each(ai,function(aj){ae.add_drawable(p(aj,ae,ae))})})});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").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var af=function(ai){if(ai.type==="focusout"||(ai.keyCode||ai.which)===13||(ai.keyCode||ai.which)===27){if((ai.keyCode||ai.which)!==27){ae.go_to($(this).val())}$(this).hide();$(this).val("");ae.location_span.show();ae.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",af).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").attr("original-title","Click to change location").tooltip({placement:"bottom"}).appendTo(this.nav_controls);this.location_span.click(function(){ae.location_span.hide();ae.chrom_select.hide();ae.nav_input.val(ae.chrom+":"+ae.low+"-"+ae.high);ae.nav_input.css("display","inline-block");ae.nav_input.select();ae.nav_input.focus();ae.nav_input.autocomplete({source:function(ak,ai){var al=[],aj=$.map(ae.get_tracks(d),function(am){return am.data_manager.search_features(ak.term).success(function(an){al=al.concat(an)})});$.when.apply($,aj).done(function(){ai($.map(al,function(am){return{label:am[0],value:am[1]}}))})}})});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").tooltip({placement:"bottom"}).click(function(){ae.zoom_out();ae.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tooltip({placement:"bottom"}).click(function(){ae.zoom_in();ae.request_redraw()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){ae.change_chrom(ae.chrom_select.val())});this.browser_content_div.click(function(ai){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(ai){ae.zoom_in(ai.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ai,aj){this.current_x=aj.offsetX}).bind("drag",function(ai,ak){var al=ak.offsetX-this.current_x;this.current_x=ak.offsetX;var aj=Math.round(al/ae.viewport_container.width()*(ae.max_high-ae.max_low));ae.move_delta(-aj)});this.overview_close.click(function(){ae.reset_overview()});this.viewport_container.bind("draginit",function(ai,aj){if(ai.clientX>ae.viewport_container.width()-16){return false}}).bind("dragstart",function(ai,aj){aj.original_low=ae.low;aj.current_height=ai.clientY;aj.current_x=aj.offsetX}).bind("drag",function(ak,am){var ai=$(this);var an=am.offsetX-am.current_x;var aj=ai.scrollTop()-(ak.clientY-am.current_height);ai.scrollTop(aj);am.current_height=ak.clientY;am.current_x=am.offsetX;var al=Math.round(an/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(al)}).bind("mousewheel",function(ak,am,aj,ai){if(aj){aj*=50;var al=Math.round(-aj/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(al)}});this.top_labeltrack.bind("dragstart",function(ai,aj){return $("<div />").css({height:ae.browser_content_div.height()+ae.top_labeltrack.height()+ae.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(am,an){$(an.proxy).css({left:Math.min(am.pageX,an.startX)-ae.container.offset().left,width:Math.abs(am.pageX-an.startX)});var aj=Math.min(am.pageX,an.startX)-ae.container.offset().left,ai=Math.max(am.pageX,an.startX)-ae.container.offset().left,al=(ae.high-ae.low),ak=ae.viewport_container.width();ae.update_location(Math.round(aj/ak*al)+ae.low,Math.round(ai/ak*al)+ae.low)}).bind("dragend",function(an,ao){var aj=Math.min(an.pageX,ao.startX),ai=Math.max(an.pageX,ao.startX),al=(ae.high-ae.low),ak=ae.viewport_container.width(),am=ae.low;ae.low=Math.round(aj/ak*al)+am;ae.high=Math.round(ai/ak*al)+am;$(ao.proxy).remove();ae.request_redraw()});this.add_label_track(new X(this,{content_div:this.top_labeltrack}));this.add_label_track(new X(this,{content_div:this.nav_labeltrack}));$(window).bind("resize",function(){if(this.resize_timer){clearTimeout(this.resize_timer)}this.resize_timer=setTimeout(function(){ae.resize_window()},500)});$(document).bind("redraw",function(){ae.redraw()});this.reset();$(window).trigger("resize")},get_base_color:function(ae){return this.config.get("values")[ae.toLowerCase()+"_color"]||this.config.get("values")["n_color"]}});q(Z.prototype,A.prototype,{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(af,ah,ae,ai){if(this.timer){clearTimeout(this.timer)}if(ai){var ag=this;this.timer=setTimeout(function(){ag.trigger("navigate",af+":"+ah+"-"+ae)},500)}else{view.trigger("navigate",af+":"+ah+"-"+ae)}},update_location:function(ae,ag){this.location_span.text(commatize(ae)+" - "+commatize(ag));this.nav_input.val(this.chrom+":"+commatize(ae)+"-"+commatize(ag));var af=view.chrom_select.val();if(af!==""){this.trigger_navigate(af,view.low,view.high,true)}},load_chroms:function(ag){ag.num=x;var ae=this,af=$.Deferred();$.ajax({url:galaxy_config.root+"api/genomes/"+this.dbkey,data:ag,dataType:"json",success:function(ai){if(ai.chrom_info.length===0){return}if(ai.reference){var aj=new D(ae);ae.add_label_track(aj);ae.reference_track=aj}ae.chrom_data=ai.chrom_info;var am='<option value="">Select Chrom/Contig</option>';for(var al=0,ah=ae.chrom_data.length;al<ah;al++){var ak=ae.chrom_data[al].chrom;am+='<option value="'+ak+'">'+ak+"</option>"}if(ai.prev_chroms){am+='<option value="previous">Previous '+x+"</option>"}if(ai.next_chroms){am+='<option value="next">Next '+x+"</option>"}ae.chrom_select.html(am);ae.chrom_start_index=ai.start_index;af.resolve(ai.chrom_info)},error:function(){alert("Could not load chroms for this dbkey:",ae.dbkey)}});return af},change_chrom:function(aj,af,al){var ag=this;if(!ag.chrom_data){ag.load_chroms_deferred.then(function(){ag.change_chrom(aj,af,al)});return}if(!aj||aj==="None"){return}if(aj==="previous"){ag.load_chroms({low:this.chrom_start_index-x});return}if(aj==="next"){ag.load_chroms({low:this.chrom_start_index+x});return}var ak=$.grep(ag.chrom_data,function(am,an){return am.chrom===aj})[0];if(ak===undefined){ag.load_chroms({chrom:aj},function(){ag.change_chrom(aj,af,al)});return}else{if(aj!==ag.chrom){ag.chrom=aj;ag.chrom_select.val(ag.chrom);ag.max_high=ak.len-1;ag.reset();for(var ai=0,ae=ag.drawables.length;ai<ae;ai++){var ah=ag.drawables[ai];if(ah.init){ah.init()}}if(ag.reference_track){ag.reference_track.init()}}if(af&&al){ag.low=Math.max(af,0);ag.high=Math.min(al,ag.max_high)}else{ag.low=0;ag.high=ag.max_high}ag.reset_overview();ag.request_redraw()}},go_to:function(ai){ai=ai.replace(/,/g,"");ai=ai.replace(/:|\-/g," ");var af=ai.split(/\s+/),ah=af[0],ag=(af[1]?parseInt(af[1],10):null),ae=(af[2]?parseInt(af[2],10):null);if(!ae){ag=ag-15;ae=ag+15}this.change_chrom(ah,ag,ae)},move_fraction:function(ag){var ae=this;var af=ae.high-ae.low;this.move_delta(ag*af)},move_delta:function(ah){var ae=this;var ag=ae.high-ae.low;if(ae.low-ah<ae.max_low){ae.low=ae.max_low;ae.high=ae.max_low+ag}else{if(ae.high-ah>ae.max_high){ae.high=ae.max_high;ae.low=ae.max_high-ag}else{ae.high-=ah;ae.low-=ah}}ae.request_redraw({data_fetch:false});if(this.redraw_on_move_fn){clearTimeout(this.redraw_on_move_fn)}this.redraw_on_move_fn=setTimeout(function(){ae.request_redraw()},200);var af=ae.chrom_select.val();this.trigger_navigate(af,ae.low,ae.high,true)},add_drawable:function(ae){A.prototype.add_drawable.call(this,ae);ae.init();this.changed();this.update_intro_div()},add_label_track:function(ae){ae.view=this;ae.init();this.label_tracks.push(ae)},remove_drawable:function(ag,af){A.prototype.remove_drawable.call(this,ag);if(af){var ae=this;ag.container_div.hide(0,function(){$(this).remove();ae.update_intro_div()})}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(af,ag){var ae=this,ah=(ag?[ag]:ae.drawables);ad.each(ah,function(ai){var aj=ad.find(ae.tracks_to_be_redrawn,function(ak){return ak[0]===ai});if(aj){aj[1]=af}else{ae.tracks_to_be_redrawn.push([ai,af])}});if(!this.requested_redraw){requestAnimationFrame(function(){ae._redraw()});this.requested_redraw=true}},_redraw:function(){this.requested_redraw=false;var ae=this.low,ai=this.high;if(ae<this.max_low){ae=this.max_low}if(ai>this.max_high){ai=this.max_high}var af=this.high-this.low;if(this.high!==0&&af<this.min_separation){ai=ae+this.min_separation}this.low=Math.floor(ae);this.high=Math.ceil(ai);this.update_location(this.low,this.high);this.resolution_px_b=this.viewport_container.width()/(this.high-this.low);var ah=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var aj=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ag=13;this.overview_box.css({left:ah,width:Math.max(ag,aj)}).show();if(aj<ag){this.overview_box.css("left",ah-(ag-aj)/2)}if(this.overview_highlight){this.overview_highlight.css({left:ah,width:aj})}ad.each(this.tracks_to_be_redrawn,function(am){var ak=am[0],al=am[1];if(ak){ak._draw(al)}});this.tracks_to_be_redrawn=[];ad.each(this.label_tracks,function(ak){ak._draw()})},zoom_in:function(af,ag){if(this.max_high===0||this.high-this.low<=this.min_separation){return}var ah=this.high-this.low,ai=ah/2+this.low,ae=(ah/this.zoom_factor)/2;if(af){ai=af/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ai-ae);this.high=Math.round(ai+ae);this.changed();this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var af=this.high-this.low,ag=af/2+this.low,ae=(af*this.zoom_factor)/2;this.low=Math.round(ag-ae);this.high=Math.round(ag+ae);this.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(ag){if(this.overview_drawable){if(this.overview_drawable.dataset.id===ag.dataset.id){return}this.overview_viewport.find(".track").remove()}var af=ag.copy({content_div:this.overview_viewport}),ae=this;af.header_div.hide();af.is_overview=true;ae.overview_drawable=af;this.overview_drawable.postdraw_actions=function(){ae.overview_highlight.show().height(ae.overview_drawable.content_div.height());ae.overview_viewport.height(ae.overview_drawable.content_div.height()+ae.overview_box.outerHeight());ae.overview_close.show();ae.resize_window()};ae.overview_drawable.request_draw();this.changed()},reset_overview:function(){$(".tooltip").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 s=S.Tool.extend({defaults:{track:null},initialize:function(ae){if(ae.tool_state!==undefined){this.set("hidden",ae.tool_state.hidden)}this.remove_inputs(["data","hidden_data","conditional"])},state_dict:function(ae){return ad.extend(this.get_inputs_dict(),{hidden:!this.is_visible()})}});var v=Backbone.View.extend({events:{"change input":"update_value"},render:function(){var ag=this.$el.addClass("param-row"),ah=this.model;var ae=$("<div>").addClass("param-label").text(ah.get("label")).appendTo(ag);var af=$("<div/>").addClass("param-input").html(ah.get("html")).appendTo(ag);af.find(":input").val(ah.get("value"));$("<div style='clear: both;'/>").appendTo(ag)},update_value:function(ae){this.model.set_value($(ae.target).val())}});var ac=Backbone.View.extend({initialize:function(ae){this.model.on("change:hidden",this.set_visible,this)},render:function(){var af=this;tool=this.model,parent_div=this.$el.addClass("dynamic-tool").hide();parent_div.bind("drag",function(aj){aj.stopPropagation()}).click(function(aj){aj.stopPropagation()}).bind("dblclick",function(aj){aj.stopPropagation()}).keydown(function(aj){aj.stopPropagation()});var ag=$("<div class='tool-name'>").appendTo(parent_div).text(tool.get("name"));tool.get("inputs").each(function(ak){var aj=new v({model:ak});aj.render();parent_div.append(aj.$el)});parent_div.find("input").click(function(){$(this).select()});var ah=$("<div>").addClass("param-row").appendTo(parent_div);var ai=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(ah);var ae=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(ah);ae.click(function(){af.run_on_region()});ai.click(function(){af.run_on_dataset()});if(tool.is_visible()){this.$el.show()}},set_visible:function(){if(this.model.is_visible()){this.$el.show()}else{this.$el.hide()}},update_params:function(){for(var ae=0;ae<this.params.length;ae++){this.params[ae].update_value()}},run_on_dataset:function(){var ae=this.model;this.run({target_dataset_id:this.model.get("track").dataset.id,action:"rerun",tool_id:ae.id},null,function(af){Galaxy.modal.show({title:ae.get("name")+" is Running",body:ae.get("name")+" is running on the complete dataset. Tool outputs are in dataset's history.",buttons:{Close:function(){Galaxy.modal.hide()}}})})},run_on_region:function(){var af=this.model.get("track"),ai=this.model,ak=new y.GenomeRegion({chrom:af.view.chrom,start:af.view.low,end:af.view.high}),al={target_dataset_id:af.dataset.id,action:"rerun",tool_id:ai.id,regions:[ak.toJSON()]},aj=af,an=al.tool_id+aj.tool_region_and_parameters_str(ak),ae;if(aj.container===view){var am=new Q(view,view,{name:this.name});var ah=aj.container.replace_drawable(aj,am,false);am.container_div.insertBefore(aj.view.content_div.children()[ah]);am.add_drawable(aj);aj.container_div.appendTo(am.content_div);ae=am}else{ae=aj.container}var ag=new aj.constructor(view,ae,{name:an,hda_ldda:"hda"});ag.init_for_tool_data();ag.change_mode(aj.mode);ag.set_filters_manager(aj.filters_manager.copy(ag));ag.update_icons();ae.add_drawable(ag);ag.tiles_div.text("Starting job.");this.run(al,ag,function(ao){ag.set_dataset(new Y.Dataset(ao));ag.tiles_div.text("Running job.");ag.init()})},run:function(ae,ag,ah){ae.inputs=this.model.get_inputs_dict();var af=new l.ServerStateDeferred({ajax_settings:{url:galaxy_config.root+"api/tools",data:JSON.stringify(ae),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(ai){return ai!=="pending"}});$.when(af.go()).then(function(ai){if(ai==="no converter"){ag.container_div.addClass("error");ag.content_div.text(K)}else{if(ai.error){ag.container_div.addClass("error");ag.content_div.text(z+ai.message)}else{ah(ai)}}})}});var E=function(ae,af){M.Scaler.call(this,af);this.filter=ae};E.prototype.gen_val=function(ae){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_val}return((parseFloat(ae[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var j=Backbone.Model.extend({initialize:function(af){var ae={};ad.each(af.params,function(ag){ae[ag.key]=ag.default_value});if(af.saved_values){ad.each(this.get("params"),function(ag){if(ag.key in af.saved_values){ae[ag.key]=af.saved_values[ag.key]}})}this.set("values",ae);if(af.onchange){this.track=af.track;this.on("change:values",af.onchange,this)}},set_param_default_value:function(af,ae){var ag=ad.find(this.get("params"),function(ah){return ah.key===af});if(ag){ag.default_value=ae}},set_param_value:function(ae,af){var ag=ad.find(this.get("params"),function(ah){return ah.key===ae});if(ag){if(typeof af==="string"||af instanceof String){if(af.trim()===""){af=ag.default_value}else{if(ag.type==="float"){af=parseFloat(af)}else{if(ag.type==="int"){af=parseInt(af,10)}}}}}if(this.get("values")[ae]!==af){this.get("values")[ae]=af;this.trigger("change:values");return true}else{return false}}});var a=Backbone.View.extend({render:function(){var al=this.model;var ae=$("<div />");var ak;function aj(aq,am){for(var av=0;av<aq.length;av++){ak=aq[av];if(ak.hidden){continue}var ao="param_"+av;var az=al.get("values")[ak.key];var aB=$("<div class='form-row' />").appendTo(am);aB.append($("<label />").attr("for",ao).text(ak.label+":"));if(ak.type==="bool"){aB.append($('<input type="checkbox" />').attr("id",ao).attr("name",ao).attr("checked",az))}else{if(ak.type==="text"){aB.append($('<input type="text"/>').attr("id",ao).val(az).click(function(){$(this).select()}))}else{if(ak.type==="select"){var ax=$("<select />").attr("id",ao);for(var at=0;at<ak.options.length;at++){$("<option/>").text(ak.options[at].label).attr("value",ak.options[at].value).appendTo(ax)}ax.val(az);aB.append(ax)}else{if(ak.type==="color"){var aA=$("<div/>").appendTo(aB),aw=$("<input />").attr("id",ao).attr("name",ao).val(az).css("float","left").appendTo(aA).click(function(aD){$(".tooltip").removeClass("in");var aC=$(this).siblings(".tooltip").addClass("in");aC.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top+Galaxy.modal.scrollTop()-($(aC).height()/2)+($(this).height()/2)}).show();aC.click(function(aE){aE.stopPropagation()});$(document).bind("click.color-picker",function(){aC.hide();$(document).unbind("click.color-picker")});aD.stopPropagation()}),au=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(aA).attr("title","Set new random color").tooltip(),ay=$("<div class='tooltip right' style='position: absolute;' />").appendTo(aA).hide(),ap=$("<div class='tooltip-inner' style='text-align: inherit'></div>").appendTo(ay),an=$("<div class='tooltip-arrow'></div>").appendTo(ay),ar=$.farbtastic(ap,{width:100,height:100,callback:aw,color:az});aA.append($("<div/>").css("clear","both"));(function(aC){au.click(function(){aC.setColor(l.get_random_color())})})(ar)}else{aB.append($("<input />").attr("id",ao).attr("name",ao).val(az))}}}}if(ak.help){aB.append($("<div class='help'/>").text(ak.help))}}}aj(al.get("params"),ae);var af=this,ai=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},ag=function(){af.update_from_form($(Galaxy.modal.el));Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},ah=function(am){if((am.keyCode||am.which)===27){ai()}else{if((am.keyCode||am.which)===13){ag()}}};$(window).bind("keypress.check_enter_esc",ah);Galaxy.modal.show({title:"Configure",body:ae,buttons:{Cancel:ai,Ok:ag}})},update_from_form:function(ae){var af=this.model;var ag=false;ad.each(af.get("params"),function(aj,ah){if(!aj.hidden){var ak="param_"+ah;var ai=ae.find("#"+ak).val();if(aj.type==="bool"){ai=ae.find("#"+ak).is(":checked")}ag=af.set_param_value(aj.key,ai)||ag}})}});var c=function(ae,ah,ai,af,ag){this.track=ae;this.region=ah;this.low=ah.get("start");this.high=ah.get("end");this.w_scale=ai;this.canvas=af;this.html_elt=$("<div class='track-tile'/>").append(af);this.data=ag;this.stale=false};c.prototype.predisplay_actions=function(){};var N=function(ae,ah,ai,af,ag){c.call(this,ae,ah,ai,af,ag)};N.prototype.predisplay_actions=function(){};var P=function(ah,ao,aq,ag,aj,ak,ar,af,an){c.call(this,ah,ao,aq,ag,aj);this.mode=ak;this.all_slotted=af;this.feature_mapper=an;this.has_icons=false;if(ar){this.has_icons=true;var al=this;ag=this.html_elt.children()[0],message_div=$("<div/>").addClass("tile-message").css({height:F-1,width:ag.width}).prependTo(this.html_elt);var am=new y.GenomeRegion({chrom:ah.view.chrom,start:this.low,end:this.high}),ap=aj.length,ai=$("<a href='javascript:void(0);'/>").addClass("icon more-down").attr("title","For speed, only the first "+ap+" features in this region were obtained from server. Click to get more data including depth").tooltip().appendTo(message_div),ae=$("<a href='javascript:void(0);'/>").addClass("icon more-across").attr("title","For speed, only the first "+ap+" features in this region were obtained from server. Click to get more data excluding depth").tooltip().appendTo(message_div);ai.click(function(){al.stale=true;ah.data_manager.get_more_data(am,ah.mode,1/al.w_scale,{},ah.data_manager.DEEP_DATA_REQ);$(".tooltip").hide();ah.request_draw()}).dblclick(function(at){at.stopPropagation()});ae.click(function(){al.stale=true;ah.data_manager.get_more_data(am,ah.mode,1/al.w_scale,{},ah.data_manager.BROAD_DATA_REQ);$(".tooltip").hide();ah.request_draw()}).dblclick(function(at){at.stopPropagation()})}};q(P.prototype,c.prototype);P.prototype.predisplay_actions=function(){var af=this,ae={};if(af.mode!=="Pack"){return}$(this.html_elt).hover(function(){this.hovered=true;$(this).mousemove()},function(){this.hovered=false;$(this).parents(".track-content").children(".overlay").children(".feature-popup").remove()}).mousemove(function(aq){if(!this.hovered){return}var al=$(this).offset(),ap=aq.pageX-al.left,ao=aq.pageY-al.top,av=af.feature_mapper.get_feature_data(ap,ao),am=(av?av[0]:null);$(this).parents(".track-content").children(".overlay").children(".feature-popup").each(function(){if(!am||$(this).attr("id")!==am.toString()){$(this).remove()}});if(av){var ah=ae[am];if(!ah){var am=av[0],ar={name:av[3],start:av[1],end:av[2],strand:av[4]},ak=af.track.filters_manager.filters,aj;for(var an=0;an<ak.length;an++){aj=ak[an];ar[aj.name]=av[aj.index]}var ah=$("<div/>").attr("id",am).addClass("feature-popup"),aw=$("<table/>"),au,at,ax;for(au in ar){at=ar[au];ax=$("<tr/>").appendTo(aw);$("<th/>").appendTo(ax).text(au);$("<td/>").attr("align","left").appendTo(ax).text(typeof(at)==="number"?W(at,2):at)}ah.append($("<div class='feature-popup-inner'>").append(aw));ae[am]=ah}ah.appendTo($(this).parents(".track-content").children(".overlay"));var ai=ap+parseInt(af.html_elt.css("left"))-ah.width()/2,ag=ao+parseInt(af.html_elt.css("top"))+7;ah.css("left",ai+"px").css("top",ag+"px")}else{if(!aq.isPropagationStopped()){aq.stopPropagation();$(this).siblings().each(function(){$(this).trigger(aq)})}}}).mouseleave(function(){$(this).parents(".track-content").children(".overlay").children(".feature-popup").remove()})};var g=function(af,ae,ag){q(ag,{drag_handle_class:"draghandle"});r.call(this,af,ae,ag);this.dataset=null;if(ag.dataset){this.dataset=(ag.dataset instanceof Backbone.Model?ag.dataset:Y.Dataset.findOrCreate(ag.dataset))}this.dataset_check_type="converted_datasets_state";this.data_url_extra_params={};this.data_query_wait=("data_query_wait" in ag?ag.data_query_wait:L);this.data_manager=("data_manager" in ag?ag.data_manager:new y.GenomeDataManager({dataset:this.dataset,genome:new y.Genome({key:af.dbkey,chroms_info:{chrom_info:af.chrom_data}}),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 ag)||ag.resize){this.add_resize_handle()}}};q(g.prototype,r.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},r.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"overview-icon",on_click_fn:function(ae){ae.view.set_overview(ae)}},r.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(ae){if(ae.filters_manager.visible()){ae.filters_manager.clear_filters()}else{ae.filters_manager.init_filters()}ae.filters_manager.toggle()}},{name:"tools_icon",title:"Tool",css_class:"hammer",on_click_fn:function(ae){ae.tool.toggle();if(ae.tool.is_visible()){ae.set_name(ae.name+ae.tool_region_and_parameters_str())}else{ae.revert_name()}$(".tooltip").remove()}},{name:"param_space_viz_icon",title:"Tool parameter space visualization",css_class:"arrow-split",on_click_fn:function(ae){var ah='<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>',ag=ad.template(ah,{track:ae});var aj=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},af=function(){var al=$('select[name="regions"] option:selected').val(),an,ak=new y.GenomeRegion({chrom:view.chrom,start:view.low,end:view.high}),am=ad.map($(".bookmark"),function(ao){return new y.GenomeRegion({from_str:$(ao).children(".position").text()})});if(al==="cur"){an=[ak]}else{if(al==="bookmarks"){an=am}else{an=[ak].concat(am)}}Galaxy.modal.hide();window.location.href=galaxy_config.root+"visualization/sweepster?"+$.param({dataset_id:ae.dataset.id,hda_ldda:ae.dataset.get("hda_ldda"),regions:JSON.stringify(new Backbone.Collection(an).toJSON())})},ai=function(ak){if((ak.keyCode||ak.which)===27){aj()}else{if((ak.keyCode||ak.which)===13){af()}}};Galaxy.modal.show({title:"Visualize tool parameter space and output from different parameter settings?",body:ag,buttons:{No:aj,Yes:af}})}},r.prototype.action_icons_def[2]],can_draw:function(){return this.dataset&&r.prototype.can_draw.call(this)},build_container_div:function(){return $("<div/>").addClass("track").attr("id","track_"+this.id).css("position","relative")},build_header_div:function(){var ae=$("<div class='track-header'/>");if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(ae)}this.name_div=$("<div/>").addClass("track-name").appendTo(ae).text(this.name).attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase());return ae},set_dataset:function(ae){this.dataset=ae;this.data_manager.set("dataset",ae)},on_resize:function(){this.request_draw({clear_tile_cache:true})},add_resize_handle:function(){var ae=this;var ah=false;var ag=false;var af=$("<div class='track-resize'>");$(ae.container_div).hover(function(){if(ae.content_visible){ah=true;af.show()}},function(){ah=false;if(!ag){af.hide()}});af.hide().bind("dragstart",function(ai,aj){ag=true;aj.original_height=$(ae.content_div).height()}).bind("drag",function(aj,ak){var ai=Math.min(Math.max(ak.original_height+ak.deltaY,ae.min_height_px),ae.max_height_px);$(ae.tiles_div).css("height",ai);ae.visible_height_px=(ae.max_height_px===ai?0:ai);ae.on_resize()}).bind("dragend",function(ai,aj){ae.tile_cache.clear();ag=false;if(!ah){af.hide()}ae.config.get("values").height=ae.visible_height_px;ae.changed()}).appendTo(ae.container_div)},set_display_modes:function(ah,ak){this.display_modes=ah;this.mode=(ak?ak:(this.config&&this.config.get("values")["mode"]?this.config.get("values")["mode"]:this.display_modes[0]));this.action_icons.mode_icon.attr("title","Set display mode (now: "+this.mode+")");var af=this,ai={};for(var ag=0,ae=af.display_modes.length;ag<ae;ag++){var aj=af.display_modes[ag];ai[aj]=function(al){return function(){af.change_mode(al);af.icons_div.show();af.container_div.mouseleave(function(){af.icons_div.hide()})}}(aj)}make_popupmenu(this.action_icons.mode_icon,ai)},build_action_icons:function(){r.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 X){return"LabelTrack"}else{if(this instanceof D){return"ReferenceTrack"}else{if(this instanceof h){return"LineTrack"}else{if(this instanceof U){return"ReadTrack"}else{if(this instanceof aa){return"VariantTrack"}else{if(this instanceof f){return"CompositeTrack"}else{if(this instanceof d){return"FeatureTrack"}}}}}}}return""},init:function(ag){var af=this;af.enabled=false;af.tile_cache.clear();af.data_manager.clear();af.tiles_div.css("height","auto");af.tiles_div.text("").children().remove();af.container_div.removeClass("nodata error pending");if(!af.dataset.id){return}var ae=$.Deferred(),ah={hda_ldda:af.dataset.get("hda_ldda"),data_type:this.dataset_check_type,chrom:af.view.chrom,retry:ag};$.getJSON(this.dataset.url(),ah,function(ai){if(!ai||ai==="error"||ai.kind==="error"){af.container_div.addClass("error");af.tiles_div.text(o);if(ai.message){af.tiles_div.append($("<a href='javascript:void(0);'></a>").text("View error").click(function(){Galaxy.modal.show({title:"Trackster Error",body:"<pre>"+ai.message+"</pre>",buttons:{Close:function(){Galaxy.modal.hide()}}})}));af.tiles_div.append($("<span/>").text(" "));af.tiles_div.append($("<a href='javascript:void(0);'></a>").text("Try again").click(function(){af.init(true)}))}}else{if(ai==="no converter"){af.container_div.addClass("error");af.tiles_div.text(K)}else{if(ai==="no data"||(ai.data!==undefined&&(ai.data===null||ai.data.length===0))){af.container_div.addClass("nodata");af.tiles_div.text(G)}else{if(ai==="pending"){af.container_div.addClass("pending");af.tiles_div.html(w);setTimeout(function(){af.init()},af.data_query_wait)}else{if(ai==="data"||ai.status==="data"){if(ai.valid_chroms){af.valid_chroms=ai.valid_chroms;af.update_icons()}af.tiles_div.text(V);if(af.view.chrom){af.tiles_div.text("");af.tiles_div.css("height",af.visible_height_px+"px");af.enabled=true;$.when.apply($,af.predraw_init()).done(function(){ae.resolve();af.container_div.removeClass("nodata error pending");af.request_draw()})}else{ae.resolve()}}}}}}});this.update_icons();return ae},predraw_init:function(){var ae=this;return $.getJSON(ae.dataset.url(),{data_type:"data",stats:true,chrom:ae.view.chrom,low:0,high:ae.view.max_high,hda_ldda:ae.dataset.get("hda_ldda")},function(af){ae.container_div.addClass("line-track");var ah=af.data;if(ah&&ah.min&&ah.max){var ag=ah.min,ai=ah.max;ag=Math.floor(Math.min(0,Math.max(ag,ah.mean-2*ah.sd)));ai=Math.ceil(Math.max(0,Math.min(ai,ah.mean+2*ah.sd)));ae.config.set_param_default_value("min_value",ag);ae.config.set_param_default_value("max_value",ai);ae.prefs.min_value=ag;ae.prefs.max_value=ai}})},get_drawables:function(){return this}});var O=function(ag,af,ai){g.call(this,ag,af,ai);var ae=this;m(ae.container_div,ae.drag_handle_class,".group",ae);this.filters_manager=new i.FiltersManager(this,("filters" in ai?ai.filters:null));this.data_manager.set("filters_manager",this.filters_manager);this.filters_available=false;this.tool=(ai.tool?new s(ad.extend(ai.tool,{track:this,tool_state:ai.tool_state})):null);this.tile_cache=new y.Cache(R);this.left_offset=0;if(this.header_div){this.set_filters_manager(this.filters_manager);if(this.tool){var ah=new ac({model:this.tool});ah.render();this.dynamic_tool_div=ah.$el;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(ai.mode){this.change_mode(ai.mode)}};q(O.prototype,r.prototype,g.prototype,{action_icons_def:g.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(ae){$(".tooltip").remove();ae.slotters[ae.view.resolution_px_b].max_rows*=2;ae.request_draw({clear_tile_cache:true})},hide:true}]),copy:function(ae){var af=this.to_dict();q(af,{data_manager:this.data_manager});var ag=new this.constructor(this.view,ae,af);ag.change_mode(this.mode);ag.enabled=this.enabled;return ag},set_filters_manager:function(ae){this.filters_manager=ae;this.header_div.after(this.filters_manager.parent_div)},to_dict:function(){return{track_type:this.get_type(),name:this.name,dataset:{id:this.dataset.id,hda_ldda:this.dataset.get("hda_ldda")},prefs:this.prefs,mode:this.mode,filters:this.filters_manager.to_dict(),tool_state:(this.tool?this.tool.state_dict():{})}},set_min_max:function(){var ae=this;return $.getJSON(ae.dataset.url(),{data_type:"data",stats:true,chrom:ae.view.chrom,low:0,high:ae.view.max_high,hda_ldda:ae.dataset.get("hda_ldda")},function(af){var ah=af.data;if(isNaN(parseFloat(ae.prefs.min_value))||isNaN(parseFloat(ae.prefs.max_value))){var ag=ah.min,ai=ah.max;ag=Math.floor(Math.min(0,Math.max(ag,ah.mean-2*ah.sd)));ai=Math.ceil(Math.max(0,Math.min(ai,ah.mean+2*ah.sd)));ae.prefs.min_value=ag;ae.prefs.max_value=ai}})},change_mode:function(af){var ae=this;ae.mode=af;ae.config.get("values")["mode"]=af;if(af==="Auto"){this.data_manager.clear()}ae.request_draw({clear_tile_cache:true});this.action_icons.mode_icon.attr("title","Set display mode (now: "+ae.mode+")");return ae},update_icons:function(){var ae=this;if(ae.filters_available){ae.action_icons.filters_icon.show()}else{ae.action_icons.filters_icon.hide()}if(ae.tool){ae.action_icons.tools_icon.show();ae.action_icons.param_space_viz_icon.show()}else{ae.action_icons.tools_icon.hide();ae.action_icons.param_space_viz_icon.hide()}},_gen_tile_cache_key:function(af,ae){return af+"_"+ae},request_draw:function(ae){if(ae&&ae.clear_tile_cache){this.tile_cache.clear()}this.view.request_redraw(ae,this)},before_draw:function(){this.max_height_px=0},_draw:function(at){if(!this.can_draw()){return}var ap=at&&at.clear_after,an=this.view.low,ai=this.view.high,al=ai-an,af=this.view.container.width(),ar=this.view.resolution_px_b,ah=1/ar;if(this.is_overview){an=this.view.max_low;ai=this.view.max_high;ar=af/(view.max_high-view.max_low);ah=1/ar}this.before_draw();this.tiles_div.children().addClass("remove");var ae=Math.floor(an/(ah*T)),am,ao,aj,ak=[],aq=[];while((ae*T*ah)<ai){am=Math.floor(ae*T*ah);ao=new y.GenomeRegion({chrom:this.view.chrom,start:am,end:Math.min(am+Math.ceil(T*ah),this.view.max_high)});aj=this.draw_helper(ao,ar,at);ak.push(aj);$.when(aj).then(function(au){aq.push(au)});ae+=1}if(!ap){this.tiles_div.children(".remove").removeClass("remove").remove()}var ag=this;$.when.apply($,ak).then(function(){ag.tiles_div.children(".remove").remove();aq=ad.filter(aq,function(au){return au!==null});if(aq.length!==0){ag.postdraw_actions(aq,af,ar,ap)}})},_add_yaxis_label:function(ah,aj){var af=this,ai=(ah==="max"?"top":"bottom"),ak=(ah==="max"?"max":"min"),ae=(ah==="max"?"max_value":"min_value"),aj=aj||function(){af.request_draw({clear_tile_cache:true})},ag=this.container_div.find(".yaxislabel."+ai);if(ag.length!==0){ag.text(af.prefs[ae])}else{ag=$("<div/>").text(af.prefs[ae]).make_text_editable({num_cols:12,on_finish:function(al){$(".tooltip").remove();af.config.set_param_value(ae,al);aj()},help_text:"Set "+ak+" value"}).addClass("yaxislabel "+ai).css("color",this.prefs.label_color);this.container_div.prepend(ag)}},postdraw_actions:function(ah,ai,ak,ae){var ag=ad.filter(ah,function(al){return(al instanceof N)});if(ag.length>0){this.max_height_px=0;var af=this;ad.each(ah,function(al){if(!(al instanceof N)){al.html_elt.remove();af.draw_helper(al.region,ak,{force:true,mode:"Coverage"})}});af._add_yaxis_label("max")}else{this.container_div.find(".yaxislabel").remove();var aj=ad.find(ah,function(al){return al.has_icons});if(aj){ad.each(ah,function(al){if(!al.has_icons){al.html_elt.css("padding-top",F)}})}}},get_mode:function(ae){return this.mode},update_auto_mode:function(ae){},_get_drawables:function(){return[this]},draw_helper:function(an,aq,ar){if(!ar){ar={}}var af=ar.force,ap=!(ar.data_fetch===false),ak=ar.mode||this.mode,ah=1/aq,ag=this,ai=this._get_drawables(),ao=this._gen_tile_cache_key(aq,an),aj=function(at){return(at&&"track" in at)};var al=(af?undefined:ag.tile_cache.get_elt(ao));if(al){if(aj(al)){ag.show_tile(al,aq)}return al}if(!ap){return null}var am=function(){var at=(ad.find(C,function(av){return av===ak})?"Coverage":ak);var au=ad.map(ai,function(av){return av.data_manager.get_data(an,at,ah,ag.data_url_extra_params)});if(view.reference_track){au.push(view.reference_track.data_manager.get_data(an,ak,ah,view.reference_track.data_url_extra_params))}return au};var ae=$.Deferred();ag.tile_cache.set_elt(ao,ae);$.when.apply($,am()).then(function(){var at=am(),ay=at,aE;if(view.reference_track){aE=view.reference_track.data_manager.subset_entry(at.pop(),an)}var az=[],aw=[];ad.each(ai,function(aJ,aG){var aI=aJ.mode,aH=ay[aG];if(aI==="Auto"){aI=aJ.get_mode(aH);aJ.update_auto_mode(aI)}az.push(aI);aw.push(aJ.get_canvas_height(aH,aI,aq,au))});var ax=ag.view.canvas_manager.new_canvas(),aA=an.get("start"),aF=an.get("end"),av=0,au=Math.ceil((aF-aA)*aq)+ag.left_offset,aC=ad.max(aw),aB;ax.width=au;ax.height=(ar.height||aC);var aD=ax.getContext("2d");aD.translate(ag.left_offset,0);if(ai.length>1){aD.globalAlpha=0.5;aD.globalCompositeOperation="source-over"}ad.each(ai,function(aH,aG){aB=aH.draw_tile(ay[aG],aD,az[aG],an,aq,aE)});if(aB!==undefined){ag.tile_cache.set_elt(ao,aB);ag.show_tile(aB,aq)}ae.resolve(aB)});return ae},get_canvas_height:function(ae,ag,ah,af){return this.visible_height_px},_draw_line_track_tile:function(ae,ag,aj,ai,ak){var ah=ag.canvas,af=new M.LinePainter(ae.data,ai.get("start"),ai.get("end"),this.prefs,aj);af.draw(ag,ah.width,ah.height,ak);return new N(this,ai,ak,ah,ae.data)},draw_tile:function(ae,af,ai,ah,aj,ag){},show_tile:function(ag,aj){var af=this,ae=ag.html_elt;ag.predisplay_actions();var ai=(ag.low-(this.is_overview?this.view.max_low:this.view.low))*aj;if(this.left_offset){ai-=this.left_offset}ae.css({position:"absolute",top:0,left:ai});if(ae.hasClass("remove")){ae.removeClass("remove")}else{this.tiles_div.append(ae)}this.max_height_px=Math.max(this.max_height_px,$(ag.canvas).height());ae.parent().children().css("height",this.max_height_px+"px");var ah=this.max_height_px;if(this.visible_height_px!==0){ah=Math.min(this.max_height_px,this.visible_height_px)}this.tiles_div.css("height",ah+"px")},tool_region_and_parameters_str:function(ah){var ae=this,ag=(ah!==undefined?ah.toString():"all"),af=ad.values(ae.tool.get_inputs_dict()).join(", ");return" - region=["+ag+"], parameters=["+af+"]"},data_and_mode_compatible:function(ae,af){if(af==="Auto"){return true}else{if(af==="Coverage"){return ae.dataset_type==="bigwig"}else{if(ae.dataset_type==="bigwig"||ae.extra_info==="no_detail"){return false}else{return true}}}},can_subset:function(ae){if(ae.message||ae.extra_info==="no_detail"){return false}else{if(ae.dataset_type==="bigwig"){return(ae.data[1][0]-ae.data[0][0]===1)}}return true},init_for_tool_data:function(){this.data_manager.set("data_type","raw_data");this.data_query_wait=1000;this.dataset_check_type="state"}});var X=function(af,ae){var ag={resize:false};g.call(this,af,ae,ag);this.container_div.addClass("label-track")};q(X.prototype,g.prototype,{build_header_div:function(){},init:function(){this.enabled=true},predraw_init:function(){},_draw:function(ai){var ag=this.view,ah=ag.high-ag.low,al=Math.floor(Math.pow(10,Math.floor(Math.log(ah)/Math.log(10)))),ae=Math.floor(ag.low/al)*al,aj=this.view.container.width(),af=$("<div style='position: relative; height: 1.3em;'></div>");while(ae<ag.high){var ak=(ae-ag.low)/ah*aj;af.append($("<div class='label'>"+commatize(ae)+"</div>").css({position:"absolute",left:ak-1}));ae+=al}this.content_div.children(":first").remove();this.content_div.append(af)}});var f=function(af,ae,ai){this.display_modes=C;O.call(this,af,ae,ai);this.drawables=[];if("drawables" in ai){var ah;for(var ag=0;ag<ai.drawables.length;ag++){ah=ai.drawables[ag];this.drawables[ag]=p(ah,af,null);if(ah.left_offset>this.left_offset){this.left_offset=ah.left_offset}}this.enabled=true}ad.each(this.drawables,function(aj){if(aj instanceof d||aj instanceof U){aj.change_mode("Coverage")}});this.update_icons();this.obj_type="CompositeTrack"};q(f.prototype,O.prototype,{action_icons_def:[{name:"composite_icon",title:"Show individual tracks",css_class:"layers-stack",on_click_fn:function(ae){$(".tooltip").remove();ae.show_group()}}].concat(O.prototype.action_icons_def),to_dict:A.prototype.to_dict,add_drawable:A.prototype.add_drawable,unpack_drawables:A.prototype.unpack_drawables,change_mode:function(ae){O.prototype.change_mode.call(this,ae);for(var af=0;af<this.drawables.length;af++){this.drawables[af].change_mode(ae)}},init:function(){var ag=[];for(var af=0;af<this.drawables.length;af++){ag.push(this.drawables[af].init())}var ae=this;$.when.apply($,ag).then(function(){ae.enabled=true;ae.request_draw()})},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide();this.action_icons.param_space_viz_icon.hide()},can_draw:r.prototype.can_draw,_get_drawables:function(){return this.drawables},show_group:function(){var ah=new Q(this.view,this.container,{name:this.name}),ae;for(var ag=0;ag<this.drawables.length;ag++){ae=this.drawables[ag];ae.update_icons();ah.add_drawable(ae);ae.container=ah;ah.content_div.append(ae.container_div)}var af=this.container.replace_drawable(this,ah,true);ah.request_draw({clear_tile_cache:true})},before_draw:function(){O.prototype.before_draw.call(this);var af=ad.min(ad.map(this.drawables,function(ag){return ag.prefs.min_value})),ae=ad.max(ad.map(this.drawables,function(ag){return ag.prefs.max_value}));this.prefs.min_value=af;this.prefs.max_value=ae;ad.each(this.drawables,function(ag){ag.prefs.min_value=af;ag.prefs.max_value=ae})},update_all_min_max:function(){var ae=this;ad.each(this.drawables,function(af){af.prefs.min_value=ae.prefs.min_value;af.prefs.max_value=ae.prefs.max_value});this.request_draw({clear_tile_cache:true})},postdraw_actions:function(ak,ae,an,aj){O.prototype.postdraw_actions.call(this,ak,ae,an,aj);var ai=-1;for(var ag=0;ag<ak.length;ag++){var al=ak[ag].html_elt.find("canvas").height();if(al>ai){ai=al}}for(var ag=0;ag<ak.length;ag++){var ah=ak[ag];if(ah.html_elt.find("canvas").height()!==ai){this.draw_helper(ah.region,an,{force:true,height:ai});ah.html_elt.remove()}}var af=this,am=function(){af.update_all_min_max()};this._add_yaxis_label("min",am);this._add_yaxis_label("max",am)}});var D=function(ae){O.call(this,ae,{content_div:ae.top_labeltrack},{resize:false});this.visible_height_px=12;this.left_offset=ae.canvas_manager.char_width_px;this.container_div.addClass("reference-track");this.data_url=galaxy_config.root+"api/genomes/"+this.view.dbkey;this.data_url_extra_params={reference:true};this.data_manager=new y.GenomeReferenceDataManager({data_url:this.data_url,can_subset:this.can_subset});this.hide_contents()};q(D.prototype,r.prototype,O.prototype,{build_header_div:function(){},init:function(){this.data_manager.clear();this.enabled=true},predraw_init:function(){},can_draw:r.prototype.can_draw,draw_helper:function(af,ag,ae){if(ag>this.view.canvas_manager.char_width_px){this.tiles_div.show();return O.prototype.draw_helper.call(this,af,ag,ae)}else{this.tiles_div.hide();return null}},can_subset:function(ae){return true},draw_tile:function(ag,am,ah,aj,an){var af=this.data_manager.subset_entry(ag,aj),al=af.data;var ae=am.canvas;am.font=am.canvas.manager.default_font;am.textAlign="center";for(var ai=0,ak=al.length;ai<ak;ai++){am.fillStyle=this.view.get_base_color(al[ai]);am.fillText(al[ai],Math.floor(ai*an),10)}return new c(this,aj,an,ae,af)}});var h=function(ag,af,ah){var ae=this;this.display_modes=C;this.mode="Histogram";O.call(this,ag,af,ah);this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"color",label:"Color",type:"color",default_value:l.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:30,hidden:true}],saved_values:ah.prefs,onchange:function(){ae.set_name(ae.prefs.name);ae.request_redraw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.visible_height_px=this.prefs.height};q(h.prototype,r.prototype,O.prototype,{before_draw:function(){},draw_tile:function(ae,af,ah,ag,ai){return this._draw_line_track_tile(ae,af,ah,ag,ai)},can_subset:function(ae){return(ae.data[1][0]-ae.data[0][0]===1)},postdraw_actions:function(af,ag,ah,ae){this._add_yaxis_label("max");this._add_yaxis_label("min")}});var t=function(ag,af,ah){var ae=this;this.display_modes=["Heatmap"];this.mode="Heatmap";O.call(this,ag,af,ah);this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"pos_color",label:"Positive Color",type:"color",default_value:"#FF8C00"},{key:"neg_color",label:"Negative Color",type:"color",default_value:"#4169E1"},{key:"min_value",label:"Min Value",type:"float",default_value:-1},{key:"max_value",label:"Max Value",type:"float",default_value:1},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:500,hidden:true}],saved_values:ah.prefs,onchange:function(){ae.set_name(ae.prefs.name);this.request_redraw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.visible_height_px=this.prefs.height};q(t.prototype,r.prototype,O.prototype,{draw_tile:function(ae,ag,aj,ai,ak){var ah=ag.canvas,af=new M.DiagonalHeatmapPainter(ae.data,ai.get("start"),ai.get("end"),this.prefs,aj);af.draw(ag,ah.width,ah.height,ak);return new c(this,ai,ak,ah,ae.data)}});var d=function(ah,ag,aj){var af=this;this.display_modes=["Auto","Coverage","Dense","Squish","Pack"];O.call(this,ah,ag,aj);var ai=l.get_random_color(),ae=l.get_random_color([ai,"#FFFFFF"]);this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"block_color",label:"Block color",type:"color",default_value:ai},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:ae},{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:"min_value",label:"Histogram minimum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"max_value",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:aj.prefs,onchange:function(){af.set_name(af.prefs.name);af.set_painter_from_config();af.request_draw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.visible_height_px=this.prefs.height;this.container_div.addClass("feature-track");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()};q(d.prototype,r.prototype,O.prototype,{set_painter_from_config:function(){if(this.config.get("values")["connector_style"]==="arcs"){this.painter=M.ArcLinkedFeaturePainter}else{this.painter=M.LinkedFeaturePainter}},postdraw_actions:function(ao,ag,ap,an){O.prototype.postdraw_actions.call(this,ao,ag,ap,an);var ai=this,aj;if(ai.filters_manager){var ah=ai.filters_manager.filters;for(var al=0;al<ah.length;al++){ah[al].update_ui_elt()}var ak=false,am,af;for(aj=0;aj<ao.length;aj++){if(ao[aj].data.length){am=ao[aj].data[0];for(var al=0;al<ah.length;al++){af=ah[al];if(af.applies_to(am)&&af.min!==af.max){ak=true;break}}}}if(ai.filters_available!==ak){ai.filters_available=ak;if(!ai.filters_available){ai.filters_manager.hide()}ai.update_icons()}}if(ao[0] instanceof P){var ae=true;for(aj=0;aj<ao.length;aj++){if(!ao[aj].all_slotted){ae=false;break}}if(!ae){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(ae){var ae;if(this.mode==="Auto"){if(ae==="no_detail"){ae="feature spans"}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+ae+")")}},incremental_slots:function(ai,ae,ah){var af=this.view.canvas_manager.dummy_context,ag=this.slotters[ai];if(!ag||(ag.mode!==ah)){ag=new (u.FeatureSlotter)(ai,ah,B,function(aj){return af.measureText(aj)});this.slotters[ai]=ag}return ag.slot_features(ae)},get_mode:function(ae){if(ae.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>J){mode="Squish"}else{mode="Pack"}}return mode},get_canvas_height:function(ae,ai,aj,af){if(ai==="Coverage"||ae.dataset_type==="bigwig"){return this.summary_draw_height}else{var ah=this.incremental_slots(aj,ae.data,ai);var ag=new (this.painter)(null,null,null,this.prefs,ai);return Math.max(ab,ag.get_required_height(ah,af))}},draw_tile:function(ao,at,aq,ah,al,ag){var ar=this,af=at.canvas,az=ah.get("start"),ae=ah.get("end"),ai=this.left_offset;if(ao.dataset_type==="bigwig"){return this._draw_line_track_tile(ao,at,aq,ah,al)}var ak=[],ap=this.slotters[al].slots;all_slotted=true;if(ao.data){var am=this.filters_manager.filters;for(var au=0,aw=ao.data.length;au<aw;au++){var aj=ao.data[au];var av=false;var an;for(var ay=0,aD=am.length;ay<aD;ay++){an=am[ay];an.update_attrs(aj);if(!an.keep(aj)){av=true;break}}if(!av){ak.push(aj);if(!(aj[0] in ap)){all_slotted=false}}}}var aC=(this.filters_manager.alpha_filter?new E(this.filters_manager.alpha_filter):null),aA=(this.filters_manager.height_filter?new E(this.filters_manager.height_filter):null),aB=new (this.painter)(ak,az,ae,this.prefs,aq,aC,aA,ag,function(aE){return ar.view.get_base_color(aE)});var ax=null;at.fillStyle=this.prefs.block_color;at.font=at.canvas.manager.default_font;at.textAlign="right";if(ao.data){ax=aB.draw(at,af.width,af.height,al,ap);ax.translation=-ai}return new P(ar,ah,al,af,ao.data,aq,ao.message,all_slotted,ax)}});var aa=function(af,ae,ag){this.display_modes=["Auto","Coverage","Dense","Squish","Pack"];O.call(this,af,ae,ag);this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"color",label:"Histogram color",type:"color",default_value:l.get_random_color()},{key:"show_sample_data",label:"Show sample data",type:"bool",default_value:true},{key:"show_labels",label:"Show summary and sample labels",type:"bool",default_value:true},{key:"summary_height",label:"Locus summary height",type:"float",default_value:20},{key:"mode",type:"string",default_value:this.mode,hidden:true}],saved_values:ag.prefs,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.request_draw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.painter=M.VariantPainter;this.summary_draw_height=30;this.left_offset=30};q(aa.prototype,r.prototype,O.prototype,{draw_tile:function(ae,ah,aj,ai,ak){if(ae.dataset_type==="bigwig"){return this._draw_line_track_tile(ae,ah,"Histogram",ai,ak)}else{var ag=this.view,af=new (this.painter)(ae.data,ai.get("start"),ai.get("end"),this.prefs,aj,function(al){return ag.get_base_color(al)});af.draw(ah,ah.canvas.width,ah.canvas.height,ak);return new c(this,ai,ak,ah.canvas,ae.data)}},get_canvas_height:function(ae,ai,aj,ag){if(ae.dataset_type==="bigwig"){return this.summary_draw_height}else{var af=(this.dataset.get_metadata("sample_names")?this.dataset.get_metadata("sample_names").length:0);if(af===0&&ae.data.length!==0){af=ae.data[0][7].match(/,/g);if(af===null){af=1}else{af=af.length+1}}var ah=new (this.painter)(null,null,null,this.prefs,ai);return ah.get_required_height(af)}},predraw_init:function(){var ae=[g.prototype.predraw_init.call(this)];if(!this.dataset.get_metadata("sample_names")){ae.push(this.dataset.fetch())}return ae},postdraw_actions:function(ai,aj,al,af){O.prototype.postdraw_actions.call(this,ai,aj,al,af);var ah=ad.filter(ai,function(am){return(am instanceof N)});var ag=this.dataset.get_metadata("sample_names");if(ah.length===0&&this.prefs.show_labels&&ag){var ae;if(this.container_div.find(".yaxislabel.variant").length===0){ae=this.prefs.summary_height/2;this.tiles_div.prepend($("<div/>").text("Summary").addClass("yaxislabel variant top").css({"font-size":ae+"px",top:(this.prefs.summary_height-ae)/2+"px"}));if(this.prefs.show_sample_data){var ak=ag.join("<br/>");this.tiles_div.prepend($("<div/>").html(ak).addClass("yaxislabel variant top sample").css({top:this.prefs.summary_height+2,}))}}ae=(this.mode==="Squish"?5:10)+"px";$(this.tiles_div).find(".sample").css({"font-size":ae,"line-height":ae});$(this.tiles_div).find(".yaxislabel").css("color",this.prefs.label_color)}else{this.container_div.find(".yaxislabel.variant").remove()}}});var U=function(ag,af,ai){d.call(this,ag,af,ai);var ah=l.get_random_color(),ae=l.get_random_color([ah,"#ffffff"]);this.config=new j({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:ah},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:ae},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"min_value",label:"Histogram minimum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"max_value",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"}],saved_values:ai.prefs,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.request_draw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.painter=(ag.reference_track?M.RefBasedReadPainter:M.ReadPainter);this.update_icons()};q(U.prototype,r.prototype,O.prototype,d.prototype);var e={CompositeTrack:f,DrawableGroup:Q,DiagonalHeatmapTrack:t,FeatureTrack:d,LineTrack:h,ReadTrack:U,VariantTrack:aa,VcfTrack:aa};var p=function(ag,af,ae){if("copy" in ag){return ag.copy(ae)}else{var ah=ag.obj_type;if(!ah){ah=ag.track_type}return new e[ah](af,ae,ag)}};return{TracksterView:Z,DrawableGroup:Q,LineTrack:h,FeatureTrack:d,DiagonalHeatmapTrack:t,ReadTrack:U,VariantTrack:aa,CompositeTrack:f,object_from_template:p}}); \ No newline at end of file +define(["libs/underscore","viz/visualization","viz/trackster/util","viz/trackster/slotting","viz/trackster/painters","viz/trackster/filters","mvc/data","mvc/tools"],function(ad,y,l,u,M,i,Y,S){var q=ad.extend;var n={};var k=function(ae,af){n[ae.attr("id")]=af};var m=function(ae,ag,ai,ah){ai=".group";var af={};n[ae.attr("id")]=ah;ae.bind("drag",{handle:"."+ag,relative:true},function(aq,ar){var ap=$(this),av=$(this).parent(),am=av.children(),ao=n[$(this).attr("id")],al,ak,at,aj,an;ak=$(this).parents(ai);if(ak.length!==0){at=ak.position().top;aj=at+ak.outerHeight();if(ar.offsetY<at){$(this).insertBefore(ak);var au=n[ak.attr("id")];au.remove_drawable(ao);au.container.add_drawable_before(ao,au);return}else{if(ar.offsetY>aj){$(this).insertAfter(ak);var au=n[ak.attr("id")];au.remove_drawable(ao);au.container.add_drawable(ao);return}}}ak=null;for(an=0;an<am.length;an++){al=$(am.get(an));at=al.position().top;aj=at+al.outerHeight();if(al.is(ai)&&this!==al.get(0)&&ar.offsetY>=at&&ar.offsetY<=aj){if(ar.offsetY-at<aj-ar.offsetY){al.find(".content-div").prepend(this)}else{al.find(".content-div").append(this)}if(ao.container){ao.container.remove_drawable(ao)}n[al.attr("id")].add_drawable(ao);return}}for(an=0;an<am.length;an++){al=$(am.get(an));if(ar.offsetY<al.position().top&&!(al.hasClass("reference-track")||al.hasClass("intro"))){break}}if(an===am.length){if(this!==am.get(an-1)){av.append(this);n[av.attr("id")].move_drawable(ao,an)}}else{if(this!==am.get(an)){$(this).insertBefore(am.get(an));n[av.attr("id")].move_drawable(ao,(ar.deltaY>0?an-1:an))}}}).bind("dragstart",function(){af["border-top"]=ae.css("border-top");af["border-bottom"]=ae.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(af)})};var ab=16,H=9,F=20,B=100,J=12000,T=400,L=5000,x=100,o="Cannot display dataset due to an error. ",K="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",G="No data for this chrom/contig.",w="Preparing data. This can take a while for a large dataset. If the visualization is saved and closed, preparation will continue in the background.",z="Tool cannot be rerun: ",b="Loading data...",V="Ready for display",R=10,I=20,C=["Histogram","Line","Filled","Intensity"];function W(af,ae){if(!ae){ae=0}var ag=Math.pow(10,ae);return Math.round(af*ag)/ag}var r=function(af,ae,ah){if(!r.id_counter){r.id_counter=0}this.id=r.id_counter++;this.name=ah.name;this.view=af;this.container=ae;this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name}],saved_values:ah.prefs,onchange:function(){this.track.set_name(this.track.config.get("values").name)}});this.prefs=this.config.get("values");this.drag_handle_class=ah.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(ai){ai.stopPropagation()});var ag=this;this.container_div.hover(function(){ag.icons_div.show()},function(){ag.icons_div.hide()});$("<div style='clear: both'/>").appendTo(this.container_div)}};r.prototype.action_icons_def=[{name:"toggle_icon",title:"Hide/show content",css_class:"toggle",on_click_fn:function(ae){if(ae.content_visible){ae.action_icons.toggle_icon.addClass("toggle-expand").removeClass("toggle");ae.hide_contents();ae.content_visible=false}else{ae.action_icons.toggle_icon.addClass("toggle").removeClass("toggle-expand");ae.content_visible=true;ae.show_contents()}}},{name:"settings_icon",title:"Edit settings",css_class:"settings-icon",on_click_fn:function(af){var ae=new a({model:af.config});ae.render()}},{name:"remove_icon",title:"Remove",css_class:"remove-icon",on_click_fn:function(ae){$(".tooltip").remove();ae.remove()}}];q(r.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(ae){},to_dict:function(){},set_name:function(ae){this.old_name=this.name;this.name=ae;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 ae=this.view;this.container_div.hide(0,function(){$(this).remove();ae.update_intro_div()})},build_container_div:function(){},build_header_div:function(){},add_action_icon:function(af,ak,aj,ai,ae,ah){var ag=this;this.action_icons[af]=$("<a/>").attr("href","javascript:void(0);").attr("title",ak).addClass("icon-button").addClass(aj).tooltip().click(function(){ai(ag)}).appendTo(this.icons_div);if(ah){this.action_icons[af].hide()}},build_action_icons:function(ae){var ag;for(var af=0;af<ae.length;af++){ag=ae[af];this.add_action_icon(ag.name,ag.title,ag.css_class,ag.on_click_fn,ag.prepend,ag.hide)}},update_icons:function(){},hide_contents:function(){},show_contents:function(){},get_drawables:function(){}});var A=function(af,ae,ag){r.call(this,af,ae,ag);this.obj_type=ag.obj_type;this.drawables=[]};q(A.prototype,r.prototype,{unpack_drawables:function(ag){this.drawables=[];var af;for(var ae=0;ae<ag.length;ae++){af=p(ag[ae],this.view,this);this.add_drawable(af)}},init:function(){for(var ae=0;ae<this.drawables.length;ae++){this.drawables[ae].init()}},_draw:function(ae){for(var af=0;af<this.drawables.length;af++){this.drawables[af]._draw(ae)}},to_dict:function(){var af=[];for(var ae=0;ae<this.drawables.length;ae++){af.push(this.drawables[ae].to_dict())}return{name:this.name,prefs:this.prefs,obj_type:this.obj_type,drawables:af}},add_drawable:function(ae){this.drawables.push(ae);ae.container=this;this.changed()},add_drawable_before:function(ag,ae){this.changed();var af=this.drawables.indexOf(ae);if(af!==-1){this.drawables.splice(af,0,ag);return true}return false},replace_drawable:function(ag,ae,af){var ah=this.drawables.indexOf(ag);if(ah!==-1){this.drawables[ah]=ae;if(af){ag.container_div.replaceWith(ae.container_div)}this.changed()}return ah},remove_drawable:function(af){var ae=this.drawables.indexOf(af);if(ae!==-1){this.drawables.splice(ae,1);af.container=null;this.changed();return true}return false},move_drawable:function(af,ag){var ae=this.drawables.indexOf(af);if(ae!==-1){this.drawables.splice(ae,1);this.drawables.splice(ag,0,af);this.changed();return true}return false},get_drawables:function(){return this.drawables},get_tracks:function(ah){var ae=this.drawables.slice(0),af=[],ag;while(ae.length!==0){ag=ae.shift();if(ag instanceof ah){af.push(ag)}else{if(ag.drawables){ae=ae.concat(ag.drawables)}}}return af}});var Q=function(af,ae,ah){q(ah,{obj_type:"DrawableGroup",drag_handle_class:"group-handle"});A.call(this,af,ae,ah);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);m(this.container_div,this.drag_handle_class,".group",this);this.filters_manager=new i.FiltersManager(this);this.header_div.after(this.filters_manager.parent_div);this.saved_filters_managers=[];if("drawables" in ah){this.unpack_drawables(ah.drawables)}if("filters" in ah){var ag=this.filters_manager;this.filters_manager=new i.FiltersManager(this,ah.filters);ag.parent_div.replaceWith(this.filters_manager.parent_div);if(ah.filters.visible){this.setup_multitrack_filtering()}}};q(Q.prototype,r.prototype,A.prototype,{action_icons_def:[r.prototype.action_icons_def[0],r.prototype.action_icons_def[1],{name:"composite_icon",title:"Show composite track",css_class:"layers-stack",on_click_fn:function(ae){$(".tooltip").remove();ae.show_composite_track()}},{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(ae){if(ae.filters_manager.visible()){ae.filters_manager.clear_filters();ae._restore_filter_managers()}else{ae.setup_multitrack_filtering();ae.request_draw({clear_tile_cache:true})}ae.filters_manager.toggle()}},r.prototype.action_icons_def[2]],build_container_div:function(){var ae=$("<div/>").addClass("group").attr("id","group_"+this.id);if(this.container){this.container.content_div.append(ae)}return ae},build_header_div:function(){var ae=$("<div/>").addClass("track-header");ae.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("track-name").text(this.name).appendTo(ae);return ae},hide_contents:function(){this.tiles_div.hide()},show_contents:function(){this.tiles_div.show();this.request_draw()},update_icons:function(){var ag=this.drawables.length;if(ag===0){this.action_icons.composite_icon.hide();this.action_icons.filters_icon.hide()}else{if(ag===1){if(this.drawables[0] instanceof f){this.action_icons.composite_icon.show()}this.action_icons.filters_icon.hide()}else{var an,am,ak,aq=true,ai=this.drawables[0].get_type(),ae=0;for(an=0;an<ag;an++){ak=this.drawables[an];if(ak.get_type()!==ai){can_composite=false;break}if(ak instanceof d){ae++}}if(aq||ae===1){this.action_icons.composite_icon.show()}else{this.action_icons.composite_icon.hide();$(".tooltip").remove()}if(ae>1&&ae===this.drawables.length){var ar={},af;ak=this.drawables[0];for(am=0;am<ak.filters_manager.filters.length;am++){af=ak.filters_manager.filters[am];ar[af.name]=[af]}for(an=1;an<this.drawables.length;an++){ak=this.drawables[an];for(am=0;am<ak.filters_manager.filters.length;am++){af=ak.filters_manager.filters[am];if(af.name in ar){ar[af.name].push(af)}}}this.filters_manager.remove_all();var ah,aj,al,ao;for(var ap in ar){ah=ar[ap];if(ah.length===ae){aj=new i.NumberFilter({name:ah[0].name,index:ah[0].index});this.filters_manager.add_filter(aj)}}if(this.filters_manager.filters.length>0){this.action_icons.filters_icon.show()}else{this.action_icons.filters_icon.hide()}}else{this.action_icons.filters_icon.hide()}}}},_restore_filter_managers:function(){for(var ae=0;ae<this.drawables.length;ae++){this.drawables[ae].filters_manager=this.saved_filters_managers[ae]}this.saved_filters_managers=[]},setup_multitrack_filtering:function(){if(this.filters_manager.filters.length>0){this.saved_filters_managers=[];for(var ae=0;ae<this.drawables.length;ae++){drawable=this.drawables[ae];this.saved_filters_managers.push(drawable.filters_manager);drawable.filters_manager=this.filters_manager}}this.filters_manager.init_filters()},show_composite_track:function(){var af=new f(this.view,this.view,{name:this.name,drawables:this.drawables});var ae=this.container.replace_drawable(this,af,true);af.request_draw()},add_drawable:function(ae){A.prototype.add_drawable.call(this,ae);this.update_icons()},remove_drawable:function(ae){A.prototype.remove_drawable.call(this,ae);this.update_icons()},to_dict:function(){if(this.filters_manager.visible()){this._restore_filter_managers()}var ae=q(A.prototype.to_dict.call(this),{filters:this.filters_manager.to_dict()});if(this.filters_manager.visible()){this.setup_multitrack_filtering()}return ae},request_draw:function(ae){ad.each(this.drawables,function(af){af.request_draw(ae)})}});var Z=Backbone.View.extend({initialize:function(ae){q(ae,{obj_type:"View"});A.call(this,"View",ae.container,ae);this.chrom=null;this.vis_id=ae.vis_id;this.dbkey=ae.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.render();this.canvas_manager=new y.CanvasManager(this.container.get(0).ownerDocument);this.reset();this.config=new j({track:this,params:[{key:"a_color",label:"A Color",type:"color",default_value:"#FF0000"},{key:"c_color",label:"C Color",type:"color",default_value:"#00FF00"},{key:"g_color",label:"G Color",type:"color",default_value:"#0000FF"},{key:"t_color",label:"T Color",type:"color",default_value:"#FF00FF"},{key:"n_color",label:"N Color",type:"color",default_value:"#AAAAAA"}],saved_values:ae.prefs,onchange:function(){track.request_redraw({clear_tile_cache:true})}})},render:function(){this.requested_redraw=false;var ag=this.container,ae=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ag);this.browser_content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ag);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ag);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.browser_content_div);this.content_div=this.viewport_container;k(this.viewport_container,ae);this.intro_div=$("<div/>").addClass("intro").appendTo(this.viewport_container).hide();var ah=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){y.select_datasets(galaxy_config.root+"visualization/list_current_history_datasets",galaxy_config.root+"api/datasets",{"f-dbkey":ae.dbkey},function(ai){ad.each(ai,function(aj){ae.add_drawable(p(aj,ae,ae))})})});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").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var af=function(ai){if(ai.type==="focusout"||(ai.keyCode||ai.which)===13||(ai.keyCode||ai.which)===27){if((ai.keyCode||ai.which)!==27){ae.go_to($(this).val())}$(this).hide();$(this).val("");ae.location_span.show();ae.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",af).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").attr("original-title","Click to change location").tooltip({placement:"bottom"}).appendTo(this.nav_controls);this.location_span.click(function(){ae.location_span.hide();ae.chrom_select.hide();ae.nav_input.val(ae.chrom+":"+ae.low+"-"+ae.high);ae.nav_input.css("display","inline-block");ae.nav_input.select();ae.nav_input.focus();ae.nav_input.autocomplete({source:function(ak,ai){var al=[],aj=$.map(ae.get_tracks(d),function(am){return am.data_manager.search_features(ak.term).success(function(an){al=al.concat(an)})});$.when.apply($,aj).done(function(){ai($.map(al,function(am){return{label:am[0],value:am[1]}}))})}})});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").tooltip({placement:"bottom"}).click(function(){ae.zoom_out();ae.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a/>").attr("id","zoom-in").attr("title","Zoom in").tooltip({placement:"bottom"}).click(function(){ae.zoom_in();ae.request_redraw()}).appendTo(this.nav_controls);this.load_chroms_deferred=this.load_chroms({low:0});this.chrom_select.bind("change",function(){ae.change_chrom(ae.chrom_select.val())});this.browser_content_div.click(function(ai){$(this).find("input").trigger("blur")});this.browser_content_div.bind("dblclick",function(ai){ae.zoom_in(ai.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(ai,aj){this.current_x=aj.offsetX}).bind("drag",function(ai,ak){var al=ak.offsetX-this.current_x;this.current_x=ak.offsetX;var aj=Math.round(al/ae.viewport_container.width()*(ae.max_high-ae.max_low));ae.move_delta(-aj)});this.overview_close.click(function(){ae.reset_overview()});this.viewport_container.bind("draginit",function(ai,aj){if(ai.clientX>ae.viewport_container.width()-16){return false}}).bind("dragstart",function(ai,aj){aj.original_low=ae.low;aj.current_height=ai.clientY;aj.current_x=aj.offsetX}).bind("drag",function(ak,am){var ai=$(this);var an=am.offsetX-am.current_x;var aj=ai.scrollTop()-(ak.clientY-am.current_height);ai.scrollTop(aj);am.current_height=ak.clientY;am.current_x=am.offsetX;var al=Math.round(an/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(al)}).bind("mousewheel",function(ak,am,aj,ai){if(aj){aj*=50;var al=Math.round(-aj/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(al)}});this.top_labeltrack.bind("dragstart",function(ai,aj){return $("<div />").css({height:ae.browser_content_div.height()+ae.top_labeltrack.height()+ae.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(am,an){$(an.proxy).css({left:Math.min(am.pageX,an.startX)-ae.container.offset().left,width:Math.abs(am.pageX-an.startX)});var aj=Math.min(am.pageX,an.startX)-ae.container.offset().left,ai=Math.max(am.pageX,an.startX)-ae.container.offset().left,al=(ae.high-ae.low),ak=ae.viewport_container.width();ae.update_location(Math.round(aj/ak*al)+ae.low,Math.round(ai/ak*al)+ae.low)}).bind("dragend",function(an,ao){var aj=Math.min(an.pageX,ao.startX),ai=Math.max(an.pageX,ao.startX),al=(ae.high-ae.low),ak=ae.viewport_container.width(),am=ae.low;ae.low=Math.round(aj/ak*al)+am;ae.high=Math.round(ai/ak*al)+am;$(ao.proxy).remove();ae.request_redraw()});this.add_label_track(new X(this,{content_div:this.top_labeltrack}));this.add_label_track(new X(this,{content_div:this.nav_labeltrack}));$(window).bind("resize",function(){if(this.resize_timer){clearTimeout(this.resize_timer)}this.resize_timer=setTimeout(function(){ae.resize_window()},500)});$(document).bind("redraw",function(){ae.redraw()});this.reset();$(window).trigger("resize")},get_base_color:function(ae){return this.config.get("values")[ae.toLowerCase()+"_color"]||this.config.get("values")["n_color"]}});q(Z.prototype,A.prototype,{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(af,ah,ae,ai){if(this.timer){clearTimeout(this.timer)}if(ai){var ag=this;this.timer=setTimeout(function(){ag.trigger("navigate",af+":"+ah+"-"+ae)},500)}else{view.trigger("navigate",af+":"+ah+"-"+ae)}},update_location:function(ae,ag){this.location_span.text(commatize(ae)+" - "+commatize(ag));this.nav_input.val(this.chrom+":"+commatize(ae)+"-"+commatize(ag));var af=view.chrom_select.val();if(af!==""){this.trigger_navigate(af,view.low,view.high,true)}},load_chroms:function(ag){ag.num=x;var ae=this,af=$.Deferred();$.ajax({url:galaxy_config.root+"api/genomes/"+this.dbkey,data:ag,dataType:"json",success:function(ai){if(ai.chrom_info.length===0){return}if(ai.reference){var aj=new D(ae);ae.add_label_track(aj);ae.reference_track=aj}ae.chrom_data=ai.chrom_info;var am='<option value="">Select Chrom/Contig</option>';for(var al=0,ah=ae.chrom_data.length;al<ah;al++){var ak=ae.chrom_data[al].chrom;am+='<option value="'+ak+'">'+ak+"</option>"}if(ai.prev_chroms){am+='<option value="previous">Previous '+x+"</option>"}if(ai.next_chroms){am+='<option value="next">Next '+x+"</option>"}ae.chrom_select.html(am);ae.chrom_start_index=ai.start_index;af.resolve(ai.chrom_info)},error:function(){alert("Could not load chroms for this dbkey:",ae.dbkey)}});return af},change_chrom:function(aj,af,al){var ag=this;if(!ag.chrom_data){ag.load_chroms_deferred.then(function(){ag.change_chrom(aj,af,al)});return}if(!aj||aj==="None"){return}if(aj==="previous"){ag.load_chroms({low:this.chrom_start_index-x});return}if(aj==="next"){ag.load_chroms({low:this.chrom_start_index+x});return}var ak=$.grep(ag.chrom_data,function(am,an){return am.chrom===aj})[0];if(ak===undefined){ag.load_chroms({chrom:aj},function(){ag.change_chrom(aj,af,al)});return}else{if(aj!==ag.chrom){ag.chrom=aj;ag.chrom_select.val(ag.chrom);ag.max_high=ak.len-1;ag.reset();for(var ai=0,ae=ag.drawables.length;ai<ae;ai++){var ah=ag.drawables[ai];if(ah.init){ah.init()}}if(ag.reference_track){ag.reference_track.init()}}if(af&&al){ag.low=Math.max(af,0);ag.high=Math.min(al,ag.max_high)}else{ag.low=0;ag.high=ag.max_high}ag.reset_overview();ag.request_redraw()}},go_to:function(ai){ai=ai.replace(/,/g,"");ai=ai.replace(/:|\-/g," ");var af=ai.split(/\s+/),ah=af[0],ag=(af[1]?parseInt(af[1],10):null),ae=(af[2]?parseInt(af[2],10):null);if(!ae){ag=ag-15;ae=ag+15}this.change_chrom(ah,ag,ae)},move_fraction:function(ag){var ae=this;var af=ae.high-ae.low;this.move_delta(ag*af)},move_delta:function(ah){var ae=this;var ag=ae.high-ae.low;if(ae.low-ah<ae.max_low){ae.low=ae.max_low;ae.high=ae.max_low+ag}else{if(ae.high-ah>ae.max_high){ae.high=ae.max_high;ae.low=ae.max_high-ag}else{ae.high-=ah;ae.low-=ah}}ae.request_redraw({data_fetch:false});if(this.redraw_on_move_fn){clearTimeout(this.redraw_on_move_fn)}this.redraw_on_move_fn=setTimeout(function(){ae.request_redraw()},200);var af=ae.chrom_select.val();this.trigger_navigate(af,ae.low,ae.high,true)},add_drawable:function(ae){A.prototype.add_drawable.call(this,ae);ae.init();this.changed();this.update_intro_div()},add_label_track:function(ae){ae.view=this;ae.init();this.label_tracks.push(ae)},remove_drawable:function(ag,af){A.prototype.remove_drawable.call(this,ag);if(af){var ae=this;ag.container_div.hide(0,function(){$(this).remove();ae.update_intro_div()})}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(af,ag){var ae=this,ah=(ag?[ag]:ae.drawables);ad.each(ah,function(ai){var aj=ad.find(ae.tracks_to_be_redrawn,function(ak){return ak[0]===ai});if(aj){aj[1]=af}else{ae.tracks_to_be_redrawn.push([ai,af])}});if(!this.requested_redraw){requestAnimationFrame(function(){ae._redraw()});this.requested_redraw=true}},_redraw:function(){this.requested_redraw=false;var ae=this.low,ai=this.high;if(ae<this.max_low){ae=this.max_low}if(ai>this.max_high){ai=this.max_high}var af=this.high-this.low;if(this.high!==0&&af<this.min_separation){ai=ae+this.min_separation}this.low=Math.floor(ae);this.high=Math.ceil(ai);this.update_location(this.low,this.high);this.resolution_px_b=this.viewport_container.width()/(this.high-this.low);var ah=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var aj=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ag=13;this.overview_box.css({left:ah,width:Math.max(ag,aj)}).show();if(aj<ag){this.overview_box.css("left",ah-(ag-aj)/2)}if(this.overview_highlight){this.overview_highlight.css({left:ah,width:aj})}ad.each(this.tracks_to_be_redrawn,function(am){var ak=am[0],al=am[1];if(ak){ak._draw(al)}});this.tracks_to_be_redrawn=[];ad.each(this.label_tracks,function(ak){ak._draw()})},zoom_in:function(af,ag){if(this.max_high===0||this.high-this.low<=this.min_separation){return}var ah=this.high-this.low,ai=ah/2+this.low,ae=(ah/this.zoom_factor)/2;if(af){ai=af/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ai-ae);this.high=Math.round(ai+ae);this.changed();this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var af=this.high-this.low,ag=af/2+this.low,ae=(af*this.zoom_factor)/2;this.low=Math.round(ag-ae);this.high=Math.round(ag+ae);this.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(ag){if(this.overview_drawable){if(this.overview_drawable.dataset.id===ag.dataset.id){return}this.overview_viewport.find(".track").remove()}var af=ag.copy({content_div:this.overview_viewport}),ae=this;af.header_div.hide();af.is_overview=true;ae.overview_drawable=af;this.overview_drawable.postdraw_actions=function(){ae.overview_highlight.show().height(ae.overview_drawable.content_div.height());ae.overview_viewport.height(ae.overview_drawable.content_div.height()+ae.overview_box.outerHeight());ae.overview_close.show();ae.resize_window()};ae.overview_drawable.request_draw();this.changed()},reset_overview:function(){$(".tooltip").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 s=S.Tool.extend({defaults:{track:null},initialize:function(ae){if(ae.tool_state!==undefined){this.set("hidden",ae.tool_state.hidden)}this.remove_inputs(["data","hidden_data","conditional"])},state_dict:function(ae){return ad.extend(this.get_inputs_dict(),{hidden:!this.is_visible()})}});var v=Backbone.View.extend({events:{"change input":"update_value"},render:function(){var ag=this.$el.addClass("param-row"),ah=this.model;var ae=$("<div>").addClass("param-label").text(ah.get("label")).appendTo(ag);var af=$("<div/>").addClass("param-input").html(ah.get("html")).appendTo(ag);af.find(":input").val(ah.get("value"));$("<div style='clear: both;'/>").appendTo(ag)},update_value:function(ae){this.model.set_value($(ae.target).val())}});var ac=Backbone.View.extend({initialize:function(ae){this.model.on("change:hidden",this.set_visible,this)},render:function(){var af=this;tool=this.model,parent_div=this.$el.addClass("dynamic-tool").hide();parent_div.bind("drag",function(aj){aj.stopPropagation()}).click(function(aj){aj.stopPropagation()}).bind("dblclick",function(aj){aj.stopPropagation()}).keydown(function(aj){aj.stopPropagation()});var ag=$("<div class='tool-name'>").appendTo(parent_div).text(tool.get("name"));tool.get("inputs").each(function(ak){var aj=new v({model:ak});aj.render();parent_div.append(aj.$el)});parent_div.find("input").click(function(){$(this).select()});var ah=$("<div>").addClass("param-row").appendTo(parent_div);var ai=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(ah);var ae=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(ah);ae.click(function(){af.run_on_region()});ai.click(function(){af.run_on_dataset()});if(tool.is_visible()){this.$el.show()}},set_visible:function(){if(this.model.is_visible()){this.$el.show()}else{this.$el.hide()}},update_params:function(){for(var ae=0;ae<this.params.length;ae++){this.params[ae].update_value()}},run_on_dataset:function(){var ae=this.model;this.run({target_dataset_id:this.model.get("track").dataset.id,action:"rerun",tool_id:ae.id},null,function(af){Galaxy.modal.show({title:ae.get("name")+" is Running",body:ae.get("name")+" is running on the complete dataset. Tool outputs are in dataset's history.",buttons:{Close:function(){Galaxy.modal.hide()}}})})},run_on_region:function(){var af=this.model.get("track"),ai=this.model,ak=new y.GenomeRegion({chrom:af.view.chrom,start:af.view.low,end:af.view.high}),al={target_dataset_id:af.dataset.id,action:"rerun",tool_id:ai.id,regions:[ak.toJSON()]},aj=af,an=al.tool_id+aj.tool_region_and_parameters_str(ak),ae;if(aj.container===view){var am=new Q(view,view,{name:this.name});var ah=aj.container.replace_drawable(aj,am,false);am.container_div.insertBefore(aj.view.content_div.children()[ah]);am.add_drawable(aj);aj.container_div.appendTo(am.content_div);ae=am}else{ae=aj.container}var ag=new aj.constructor(view,ae,{name:an,hda_ldda:"hda"});ag.init_for_tool_data();ag.change_mode(aj.mode);ag.set_filters_manager(aj.filters_manager.copy(ag));ag.update_icons();ae.add_drawable(ag);ag.tiles_div.text("Starting job.");this.run(al,ag,function(ao){ag.set_dataset(new Y.Dataset(ao));ag.tiles_div.text("Running job.");ag.init()})},run:function(ae,ag,ah){ae.inputs=this.model.get_inputs_dict();var af=new l.ServerStateDeferred({ajax_settings:{url:galaxy_config.root+"api/tools",data:JSON.stringify(ae),dataType:"json",contentType:"application/json",type:"POST"},interval:2000,success_fn:function(ai){return ai!=="pending"}});$.when(af.go()).then(function(ai){if(ai==="no converter"){ag.container_div.addClass("error");ag.content_div.text(K)}else{if(ai.error){ag.container_div.addClass("error");ag.content_div.text(z+ai.message)}else{ah(ai)}}})}});var E=function(ae,af){M.Scaler.call(this,af);this.filter=ae};E.prototype.gen_val=function(ae){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_val}return((parseFloat(ae[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var j=Backbone.Model.extend({initialize:function(af){var ae={};ad.each(af.params,function(ag){ae[ag.key]=ag.default_value});if(af.saved_values){ad.each(this.get("params"),function(ag){if(ag.key in af.saved_values){ae[ag.key]=af.saved_values[ag.key]}})}this.set("values",ae);if(af.onchange){this.track=af.track;this.on("change:values",af.onchange,this)}},set_param_default_value:function(af,ae){var ag=ad.find(this.get("params"),function(ah){return ah.key===af});if(ag){ag.default_value=ae}},set_param_value:function(ae,af){var ag=ad.find(this.get("params"),function(ah){return ah.key===ae});if(ag){if(typeof af==="string"||af instanceof String){if(af.trim()===""){af=ag.default_value}else{if(ag.type==="float"){af=parseFloat(af)}else{if(ag.type==="int"){af=parseInt(af,10)}}}}}if(this.get("values")[ae]!==af){this.get("values")[ae]=af;this.trigger("change:values");return true}else{return false}}});var a=Backbone.View.extend({render:function(){var al=this.model;var ae=$("<div />");var ak;function aj(aq,am){for(var av=0;av<aq.length;av++){ak=aq[av];if(ak.hidden){continue}var ao="param_"+av;var az=al.get("values")[ak.key];var aB=$("<div class='form-row' />").appendTo(am);aB.append($("<label />").attr("for",ao).text(ak.label+":"));if(ak.type==="bool"){aB.append($('<input type="checkbox" />').attr("id",ao).attr("name",ao).attr("checked",az))}else{if(ak.type==="text"){aB.append($('<input type="text"/>').attr("id",ao).val(az).click(function(){$(this).select()}))}else{if(ak.type==="select"){var ax=$("<select />").attr("id",ao);for(var at=0;at<ak.options.length;at++){$("<option/>").text(ak.options[at].label).attr("value",ak.options[at].value).appendTo(ax)}ax.val(az);aB.append(ax)}else{if(ak.type==="color"){var aA=$("<div/>").appendTo(aB),aw=$("<input />").attr("id",ao).attr("name",ao).val(az).css("float","left").appendTo(aA).click(function(aD){$(".tooltip").removeClass("in");var aC=$(this).siblings(".tooltip").addClass("in");aC.css({left:$(this).position().left+$(this).width()+5,top:$(this).position().top+Galaxy.modal.scrollTop()-($(aC).height()/2)+($(this).height()/2)}).show();aC.click(function(aE){aE.stopPropagation()});$(document).bind("click.color-picker",function(){aC.hide();$(document).unbind("click.color-picker")});aD.stopPropagation()}),au=$("<a href='javascript:void(0)'/>").addClass("icon-button arrow-circle").appendTo(aA).attr("title","Set new random color").tooltip(),ay=$("<div class='tooltip right' style='position: absolute;' />").appendTo(aA).hide(),ap=$("<div class='tooltip-inner' style='text-align: inherit'></div>").appendTo(ay),an=$("<div class='tooltip-arrow'></div>").appendTo(ay),ar=$.farbtastic(ap,{width:100,height:100,callback:aw,color:az});aA.append($("<div/>").css("clear","both"));(function(aC){au.click(function(){aC.setColor(l.get_random_color())})})(ar)}else{aB.append($("<input />").attr("id",ao).attr("name",ao).val(az))}}}}if(ak.help){aB.append($("<div class='help'/>").text(ak.help))}}}aj(al.get("params"),ae);var af=this,ai=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},ag=function(){af.update_from_form($(Galaxy.modal.el));Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},ah=function(am){if((am.keyCode||am.which)===27){ai()}else{if((am.keyCode||am.which)===13){ag()}}};$(window).bind("keypress.check_enter_esc",ah);Galaxy.modal.show({title:"Configure",body:ae,buttons:{Cancel:ai,Ok:ag}})},update_from_form:function(ae){var af=this.model;var ag=false;ad.each(af.get("params"),function(aj,ah){if(!aj.hidden){var ak="param_"+ah;var ai=ae.find("#"+ak).val();if(aj.type==="bool"){ai=ae.find("#"+ak).is(":checked")}ag=af.set_param_value(aj.key,ai)||ag}})}});var c=function(ae,ah,ai,af,ag){this.track=ae;this.region=ah;this.low=ah.get("start");this.high=ah.get("end");this.w_scale=ai;this.canvas=af;this.html_elt=$("<div class='track-tile'/>").append(af);this.data=ag;this.stale=false};c.prototype.predisplay_actions=function(){};var N=function(ae,ah,ai,af,ag){c.call(this,ae,ah,ai,af,ag)};N.prototype.predisplay_actions=function(){};var P=function(ah,ao,aq,ag,aj,ak,ar,af,an){c.call(this,ah,ao,aq,ag,aj);this.mode=ak;this.all_slotted=af;this.feature_mapper=an;this.has_icons=false;if(ar){this.has_icons=true;var al=this;ag=this.html_elt.children()[0],message_div=$("<div/>").addClass("tile-message").css({height:F-1,width:ag.width}).prependTo(this.html_elt);var am=new y.GenomeRegion({chrom:ah.view.chrom,start:this.low,end:this.high}),ap=aj.length,ai=$("<a href='javascript:void(0);'/>").addClass("icon more-down").attr("title","For speed, only the first "+ap+" features in this region were obtained from server. Click to get more data including depth").tooltip().appendTo(message_div),ae=$("<a href='javascript:void(0);'/>").addClass("icon more-across").attr("title","For speed, only the first "+ap+" features in this region were obtained from server. Click to get more data excluding depth").tooltip().appendTo(message_div);ai.click(function(){al.stale=true;ah.data_manager.get_more_data(am,ah.mode,1/al.w_scale,{},ah.data_manager.DEEP_DATA_REQ);$(".tooltip").hide();ah.request_draw()}).dblclick(function(at){at.stopPropagation()});ae.click(function(){al.stale=true;ah.data_manager.get_more_data(am,ah.mode,1/al.w_scale,{},ah.data_manager.BROAD_DATA_REQ);$(".tooltip").hide();ah.request_draw()}).dblclick(function(at){at.stopPropagation()})}};q(P.prototype,c.prototype);P.prototype.predisplay_actions=function(){var af=this,ae={};if(af.mode!=="Pack"){return}$(this.html_elt).hover(function(){this.hovered=true;$(this).mousemove()},function(){this.hovered=false;$(this).parents(".track-content").children(".overlay").children(".feature-popup").remove()}).mousemove(function(aq){if(!this.hovered){return}var al=$(this).offset(),ap=aq.pageX-al.left,ao=aq.pageY-al.top,av=af.feature_mapper.get_feature_data(ap,ao),am=(av?av[0]:null);$(this).parents(".track-content").children(".overlay").children(".feature-popup").each(function(){if(!am||$(this).attr("id")!==am.toString()){$(this).remove()}});if(av){var ah=ae[am];if(!ah){var am=av[0],ar={name:av[3],start:av[1],end:av[2],strand:av[4]},ak=af.track.filters_manager.filters,aj;for(var an=0;an<ak.length;an++){aj=ak[an];ar[aj.name]=av[aj.index]}var ah=$("<div/>").attr("id",am).addClass("feature-popup"),aw=$("<table/>"),au,at,ax;for(au in ar){at=ar[au];ax=$("<tr/>").appendTo(aw);$("<th/>").appendTo(ax).text(au);$("<td/>").attr("align","left").appendTo(ax).text(typeof(at)==="number"?W(at,2):at)}ah.append($("<div class='feature-popup-inner'>").append(aw));ae[am]=ah}ah.appendTo($(this).parents(".track-content").children(".overlay"));var ai=ap+parseInt(af.html_elt.css("left"),10)-ah.width()/2,ag=ao+parseInt(af.html_elt.css("top"),10)+7;ah.css("left",ai+"px").css("top",ag+"px")}else{if(!aq.isPropagationStopped()){aq.stopPropagation();$(this).siblings().each(function(){$(this).trigger(aq)})}}}).mouseleave(function(){$(this).parents(".track-content").children(".overlay").children(".feature-popup").remove()})};var g=function(af,ae,ag){q(ag,{drag_handle_class:"draghandle"});r.call(this,af,ae,ag);this.dataset=null;if(ag.dataset){this.dataset=(ag.dataset instanceof Backbone.Model?ag.dataset:Y.Dataset.findOrCreate(ag.dataset))}this.dataset_check_type="converted_datasets_state";this.data_url_extra_params={};this.data_query_wait=("data_query_wait" in ag?ag.data_query_wait:L);this.data_manager=("data_manager" in ag?ag.data_manager:new y.GenomeDataManager({dataset:this.dataset,genome:new y.Genome({key:af.dbkey,chroms_info:{chrom_info:af.chrom_data}}),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 ag)||ag.resize){this.add_resize_handle()}}};q(g.prototype,r.prototype,{action_icons_def:[{name:"mode_icon",title:"Set display mode",css_class:"chevron-expand",on_click_fn:function(){}},r.prototype.action_icons_def[0],{name:"overview_icon",title:"Set as overview",css_class:"overview-icon",on_click_fn:function(ae){ae.view.set_overview(ae)}},r.prototype.action_icons_def[1],{name:"filters_icon",title:"Filters",css_class:"filters-icon",on_click_fn:function(ae){if(ae.filters_manager.visible()){ae.filters_manager.clear_filters()}else{ae.filters_manager.init_filters()}ae.filters_manager.toggle()}},{name:"tools_icon",title:"Tool",css_class:"hammer",on_click_fn:function(ae){ae.tool.toggle();if(ae.tool.is_visible()){ae.set_name(ae.name+ae.tool_region_and_parameters_str())}else{ae.revert_name()}$(".tooltip").remove()}},{name:"param_space_viz_icon",title:"Tool parameter space visualization",css_class:"arrow-split",on_click_fn:function(ae){var ah='<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>',ag=ad.template(ah,{track:ae});var aj=function(){Galaxy.modal.hide();$(window).unbind("keypress.check_enter_esc")},af=function(){var al=$('select[name="regions"] option:selected').val(),an,ak=new y.GenomeRegion({chrom:view.chrom,start:view.low,end:view.high}),am=ad.map($(".bookmark"),function(ao){return new y.GenomeRegion({from_str:$(ao).children(".position").text()})});if(al==="cur"){an=[ak]}else{if(al==="bookmarks"){an=am}else{an=[ak].concat(am)}}Galaxy.modal.hide();window.location.href=galaxy_config.root+"visualization/sweepster?"+$.param({dataset_id:ae.dataset.id,hda_ldda:ae.dataset.get("hda_ldda"),regions:JSON.stringify(new Backbone.Collection(an).toJSON())})},ai=function(ak){if((ak.keyCode||ak.which)===27){aj()}else{if((ak.keyCode||ak.which)===13){af()}}};Galaxy.modal.show({title:"Visualize tool parameter space and output from different parameter settings?",body:ag,buttons:{No:aj,Yes:af}})}},r.prototype.action_icons_def[2]],can_draw:function(){return this.dataset&&r.prototype.can_draw.call(this)},build_container_div:function(){return $("<div/>").addClass("track").attr("id","track_"+this.id).css("position","relative")},build_header_div:function(){var ae=$("<div class='track-header'/>");if(this.view.editor){this.drag_div=$("<div/>").addClass(this.drag_handle_class).appendTo(ae)}this.name_div=$("<div/>").addClass("track-name").appendTo(ae).text(this.name).attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase());return ae},set_dataset:function(ae){this.dataset=ae;this.data_manager.set("dataset",ae)},on_resize:function(){this.request_draw({clear_tile_cache:true})},add_resize_handle:function(){var ae=this;var ah=false;var ag=false;var af=$("<div class='track-resize'>");$(ae.container_div).hover(function(){if(ae.content_visible){ah=true;af.show()}},function(){ah=false;if(!ag){af.hide()}});af.hide().bind("dragstart",function(ai,aj){ag=true;aj.original_height=$(ae.content_div).height()}).bind("drag",function(aj,ak){var ai=Math.min(Math.max(ak.original_height+ak.deltaY,ae.min_height_px),ae.max_height_px);$(ae.tiles_div).css("height",ai);ae.visible_height_px=(ae.max_height_px===ai?0:ai);ae.on_resize()}).bind("dragend",function(ai,aj){ae.tile_cache.clear();ag=false;if(!ah){af.hide()}ae.config.get("values").height=ae.visible_height_px;ae.changed()}).appendTo(ae.container_div)},set_display_modes:function(ah,ak){this.display_modes=ah;this.mode=(ak?ak:(this.config&&this.config.get("values")["mode"]?this.config.get("values")["mode"]:this.display_modes[0]));this.action_icons.mode_icon.attr("title","Set display mode (now: "+this.mode+")");var af=this,ai={};for(var ag=0,ae=af.display_modes.length;ag<ae;ag++){var aj=af.display_modes[ag];ai[aj]=function(al){return function(){af.change_mode(al);af.icons_div.show();af.container_div.mouseleave(function(){af.icons_div.hide()})}}(aj)}make_popupmenu(this.action_icons.mode_icon,ai)},build_action_icons:function(){r.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 X){return"LabelTrack"}else{if(this instanceof D){return"ReferenceTrack"}else{if(this instanceof h){return"LineTrack"}else{if(this instanceof U){return"ReadTrack"}else{if(this instanceof aa){return"VariantTrack"}else{if(this instanceof f){return"CompositeTrack"}else{if(this instanceof d){return"FeatureTrack"}}}}}}}return""},init:function(ag){var af=this;af.enabled=false;af.tile_cache.clear();af.data_manager.clear();af.tiles_div.css("height","auto");af.tiles_div.text("").children().remove();af.container_div.removeClass("nodata error pending");if(!af.dataset.id){return}var ae=$.Deferred(),ah={hda_ldda:af.dataset.get("hda_ldda"),data_type:this.dataset_check_type,chrom:af.view.chrom,retry:ag};$.getJSON(this.dataset.url(),ah,function(ai){if(!ai||ai==="error"||ai.kind==="error"){af.container_div.addClass("error");af.tiles_div.text(o);if(ai.message){af.tiles_div.append($("<a href='javascript:void(0);'></a>").text("View error").click(function(){Galaxy.modal.show({title:"Trackster Error",body:"<pre>"+ai.message+"</pre>",buttons:{Close:function(){Galaxy.modal.hide()}}})}));af.tiles_div.append($("<span/>").text(" "));af.tiles_div.append($("<a href='javascript:void(0);'></a>").text("Try again").click(function(){af.init(true)}))}}else{if(ai==="no converter"){af.container_div.addClass("error");af.tiles_div.text(K)}else{if(ai==="no data"||(ai.data!==undefined&&(ai.data===null||ai.data.length===0))){af.container_div.addClass("nodata");af.tiles_div.text(G)}else{if(ai==="pending"){af.container_div.addClass("pending");af.tiles_div.html(w);setTimeout(function(){af.init()},af.data_query_wait)}else{if(ai==="data"||ai.status==="data"){if(ai.valid_chroms){af.valid_chroms=ai.valid_chroms;af.update_icons()}af.tiles_div.text(V);if(af.view.chrom){af.tiles_div.text("");af.tiles_div.css("height",af.visible_height_px+"px");af.enabled=true;$.when.apply($,af.predraw_init()).done(function(){ae.resolve();af.container_div.removeClass("nodata error pending");af.request_draw()})}else{ae.resolve()}}}}}}});this.update_icons();return ae},predraw_init:function(){var ae=this;return $.getJSON(ae.dataset.url(),{data_type:"data",stats:true,chrom:ae.view.chrom,low:0,high:ae.view.max_high,hda_ldda:ae.dataset.get("hda_ldda")},function(af){ae.container_div.addClass("line-track");var ah=af.data;if(ah&&ah.min&&ah.max){var ag=ah.min,ai=ah.max;ag=Math.floor(Math.min(0,Math.max(ag,ah.mean-2*ah.sd)));ai=Math.ceil(Math.max(0,Math.min(ai,ah.mean+2*ah.sd)));ae.config.set_param_default_value("min_value",ag);ae.config.set_param_default_value("max_value",ai);ae.prefs.min_value=ag;ae.prefs.max_value=ai}})},get_drawables:function(){return this}});var O=function(ag,af,ai){g.call(this,ag,af,ai);var ae=this;m(ae.container_div,ae.drag_handle_class,".group",ae);this.filters_manager=new i.FiltersManager(this,("filters" in ai?ai.filters:null));this.data_manager.set("filters_manager",this.filters_manager);this.filters_available=false;this.tool=(ai.tool?new s(ad.extend(ai.tool,{track:this,tool_state:ai.tool_state})):null);this.tile_cache=new y.Cache(R);this.left_offset=0;if(this.header_div){this.set_filters_manager(this.filters_manager);if(this.tool){var ah=new ac({model:this.tool});ah.render();this.dynamic_tool_div=ah.$el;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(ai.mode){this.change_mode(ai.mode)}};q(O.prototype,r.prototype,g.prototype,{action_icons_def:g.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(ae){$(".tooltip").remove();ae.slotters[ae.view.resolution_px_b].max_rows*=2;ae.request_draw({clear_tile_cache:true})},hide:true}]),copy:function(ae){var af=this.to_dict();q(af,{data_manager:this.data_manager});var ag=new this.constructor(this.view,ae,af);ag.change_mode(this.mode);ag.enabled=this.enabled;return ag},set_filters_manager:function(ae){this.filters_manager=ae;this.header_div.after(this.filters_manager.parent_div)},to_dict:function(){return{track_type:this.get_type(),name:this.name,dataset:{id:this.dataset.id,hda_ldda:this.dataset.get("hda_ldda")},prefs:this.prefs,mode:this.mode,filters:this.filters_manager.to_dict(),tool_state:(this.tool?this.tool.state_dict():{})}},set_min_max:function(){var ae=this;return $.getJSON(ae.dataset.url(),{data_type:"data",stats:true,chrom:ae.view.chrom,low:0,high:ae.view.max_high,hda_ldda:ae.dataset.get("hda_ldda")},function(af){var ah=af.data;if(isNaN(parseFloat(ae.prefs.min_value))||isNaN(parseFloat(ae.prefs.max_value))){var ag=ah.min,ai=ah.max;ag=Math.floor(Math.min(0,Math.max(ag,ah.mean-2*ah.sd)));ai=Math.ceil(Math.max(0,Math.min(ai,ah.mean+2*ah.sd)));ae.prefs.min_value=ag;ae.prefs.max_value=ai}})},change_mode:function(af){var ae=this;ae.mode=af;ae.config.get("values")["mode"]=af;if(af==="Auto"){this.data_manager.clear()}ae.request_draw({clear_tile_cache:true});this.action_icons.mode_icon.attr("title","Set display mode (now: "+ae.mode+")");return ae},update_icons:function(){var ae=this;if(ae.filters_available){ae.action_icons.filters_icon.show()}else{ae.action_icons.filters_icon.hide()}if(ae.tool){ae.action_icons.tools_icon.show();ae.action_icons.param_space_viz_icon.show()}else{ae.action_icons.tools_icon.hide();ae.action_icons.param_space_viz_icon.hide()}},_gen_tile_cache_key:function(af,ae){return af+"_"+ae},request_draw:function(ae){if(ae&&ae.clear_tile_cache){this.tile_cache.clear()}this.view.request_redraw(ae,this)},before_draw:function(){this.max_height_px=0},_draw:function(at){if(!this.can_draw()){return}var ap=at&&at.clear_after,an=this.view.low,ai=this.view.high,al=ai-an,af=this.view.container.width(),ar=this.view.resolution_px_b,ah=1/ar;if(this.is_overview){an=this.view.max_low;ai=this.view.max_high;ar=af/(view.max_high-view.max_low);ah=1/ar}this.before_draw();this.tiles_div.children().addClass("remove");var ae=Math.floor(an/(ah*T)),am,ao,aj,ak=[],aq=[];while((ae*T*ah)<ai){am=Math.floor(ae*T*ah);ao=new y.GenomeRegion({chrom:this.view.chrom,start:am,end:Math.min(am+Math.ceil(T*ah),this.view.max_high)});aj=this.draw_helper(ao,ar,at);ak.push(aj);$.when(aj).then(function(au){aq.push(au)});ae+=1}if(!ap){this.tiles_div.children(".remove").removeClass("remove").remove()}var ag=this;$.when.apply($,ak).then(function(){ag.tiles_div.children(".remove").remove();aq=ad.filter(aq,function(au){return au!==null});if(aq.length!==0){ag.postdraw_actions(aq,af,ar,ap)}})},_add_yaxis_label:function(ah,aj){var af=this,ai=(ah==="max"?"top":"bottom"),ak=(ah==="max"?"max":"min"),ae=(ah==="max"?"max_value":"min_value"),aj=aj||function(){af.request_draw({clear_tile_cache:true})},ag=this.container_div.find(".yaxislabel."+ai);if(ag.length!==0){ag.text(af.prefs[ae])}else{ag=$("<div/>").text(af.prefs[ae]).make_text_editable({num_cols:12,on_finish:function(al){$(".tooltip").remove();af.config.set_param_value(ae,al);aj()},help_text:"Set "+ak+" value"}).addClass("yaxislabel "+ai).css("color",this.prefs.label_color);this.container_div.prepend(ag)}},postdraw_actions:function(ah,ai,ak,ae){var ag=ad.filter(ah,function(al){return(al instanceof N)});if(ag.length>0){this.max_height_px=0;var af=this;ad.each(ah,function(al){if(!(al instanceof N)){al.html_elt.remove();af.draw_helper(al.region,ak,{force:true,mode:"Coverage"})}});af._add_yaxis_label("max")}else{this.container_div.find(".yaxislabel").remove();var aj=ad.find(ah,function(al){return al.has_icons});if(aj){ad.each(ah,function(al){if(!al.has_icons){al.html_elt.css("padding-top",F)}})}}},get_mode:function(ae){return this.mode},update_auto_mode:function(ae){},_get_drawables:function(){return[this]},draw_helper:function(an,aq,ar){if(!ar){ar={}}var af=ar.force,ap=!(ar.data_fetch===false),ak=ar.mode||this.mode,ah=1/aq,ag=this,ai=this._get_drawables(),ao=this._gen_tile_cache_key(aq,an),aj=function(at){return(at&&"track" in at)};var al=(af?undefined:ag.tile_cache.get_elt(ao));if(al){if(aj(al)){ag.show_tile(al,aq)}return al}if(!ap){return null}var am=function(){var at=(ad.find(C,function(av){return av===ak})?"Coverage":ak);var au=ad.map(ai,function(av){return av.data_manager.get_data(an,at,ah,ag.data_url_extra_params)});if(view.reference_track){au.push(view.reference_track.data_manager.get_data(an,ak,ah,view.reference_track.data_url_extra_params))}return au};var ae=$.Deferred();ag.tile_cache.set_elt(ao,ae);$.when.apply($,am()).then(function(){var at=am(),ay=at,aE;if(view.reference_track){aE=view.reference_track.data_manager.subset_entry(at.pop(),an)}var az=[],aw=[];ad.each(ai,function(aJ,aG){var aI=aJ.mode,aH=ay[aG];if(aI==="Auto"){aI=aJ.get_mode(aH);aJ.update_auto_mode(aI)}az.push(aI);aw.push(aJ.get_canvas_height(aH,aI,aq,au))});var ax=ag.view.canvas_manager.new_canvas(),aA=an.get("start"),aF=an.get("end"),av=0,au=Math.ceil((aF-aA)*aq)+ag.left_offset,aC=ad.max(aw),aB;ax.width=au;ax.height=(ar.height||aC);var aD=ax.getContext("2d");aD.translate(ag.left_offset,0);if(ai.length>1){aD.globalAlpha=0.5;aD.globalCompositeOperation="source-over"}ad.each(ai,function(aH,aG){aB=aH.draw_tile(ay[aG],aD,az[aG],an,aq,aE)});if(aB!==undefined){ag.tile_cache.set_elt(ao,aB);ag.show_tile(aB,aq)}ae.resolve(aB)});return ae},get_canvas_height:function(ae,ag,ah,af){return this.visible_height_px},_draw_line_track_tile:function(ae,ag,aj,ai,ak){var ah=ag.canvas,af=new M.LinePainter(ae.data,ai.get("start"),ai.get("end"),this.prefs,aj);af.draw(ag,ah.width,ah.height,ak);return new N(this,ai,ak,ah,ae.data)},draw_tile:function(ae,af,ai,ah,aj,ag){},show_tile:function(ag,aj){var af=this,ae=ag.html_elt;ag.predisplay_actions();var ai=(ag.low-(this.is_overview?this.view.max_low:this.view.low))*aj;if(this.left_offset){ai-=this.left_offset}ae.css({position:"absolute",top:0,left:ai});if(ae.hasClass("remove")){ae.removeClass("remove")}else{this.tiles_div.append(ae)}this.max_height_px=Math.max(this.max_height_px,$(ag.canvas).height());ae.parent().children().css("height",this.max_height_px+"px");var ah=this.max_height_px;if(this.visible_height_px!==0){ah=Math.min(this.max_height_px,this.visible_height_px)}this.tiles_div.css("height",ah+"px")},tool_region_and_parameters_str:function(ah){var ae=this,ag=(ah!==undefined?ah.toString():"all"),af=ad.values(ae.tool.get_inputs_dict()).join(", ");return" - region=["+ag+"], parameters=["+af+"]"},data_and_mode_compatible:function(ae,af){if(af==="Auto"){return true}else{if(af==="Coverage"){return ae.dataset_type==="bigwig"}else{if(ae.dataset_type==="bigwig"||ae.extra_info==="no_detail"){return false}else{return true}}}},can_subset:function(ae){if(ae.message||ae.extra_info==="no_detail"){return false}else{if(ae.dataset_type==="bigwig"){return(ae.data[1][0]-ae.data[0][0]===1)}}return true},init_for_tool_data:function(){this.data_manager.set("data_type","raw_data");this.data_query_wait=1000;this.dataset_check_type="state"}});var X=function(af,ae){var ag={resize:false};g.call(this,af,ae,ag);this.container_div.addClass("label-track")};q(X.prototype,g.prototype,{build_header_div:function(){},init:function(){this.enabled=true},predraw_init:function(){},_draw:function(ai){var ag=this.view,ah=ag.high-ag.low,al=Math.floor(Math.pow(10,Math.floor(Math.log(ah)/Math.log(10)))),ae=Math.floor(ag.low/al)*al,aj=this.view.container.width(),af=$("<div style='position: relative; height: 1.3em;'></div>");while(ae<ag.high){var ak=(ae-ag.low)/ah*aj;af.append($("<div class='label'>"+commatize(ae)+"</div>").css({position:"absolute",left:ak-1}));ae+=al}this.content_div.children(":first").remove();this.content_div.append(af)}});var f=function(af,ae,ai){this.display_modes=C;O.call(this,af,ae,ai);this.drawables=[];if("drawables" in ai){var ah;for(var ag=0;ag<ai.drawables.length;ag++){ah=ai.drawables[ag];this.drawables[ag]=p(ah,af,null);if(ah.left_offset>this.left_offset){this.left_offset=ah.left_offset}}this.enabled=true}ad.each(this.drawables,function(aj){if(aj instanceof d||aj instanceof U){aj.change_mode("Coverage")}});this.update_icons();this.obj_type="CompositeTrack"};q(f.prototype,O.prototype,{action_icons_def:[{name:"composite_icon",title:"Show individual tracks",css_class:"layers-stack",on_click_fn:function(ae){$(".tooltip").remove();ae.show_group()}}].concat(O.prototype.action_icons_def),to_dict:A.prototype.to_dict,add_drawable:A.prototype.add_drawable,unpack_drawables:A.prototype.unpack_drawables,change_mode:function(ae){O.prototype.change_mode.call(this,ae);for(var af=0;af<this.drawables.length;af++){this.drawables[af].change_mode(ae)}},init:function(){var ag=[];for(var af=0;af<this.drawables.length;af++){ag.push(this.drawables[af].init())}var ae=this;$.when.apply($,ag).then(function(){ae.enabled=true;ae.request_draw()})},update_icons:function(){this.action_icons.filters_icon.hide();this.action_icons.tools_icon.hide();this.action_icons.param_space_viz_icon.hide()},can_draw:r.prototype.can_draw,_get_drawables:function(){return this.drawables},show_group:function(){var ah=new Q(this.view,this.container,{name:this.name}),ae;for(var ag=0;ag<this.drawables.length;ag++){ae=this.drawables[ag];ae.update_icons();ah.add_drawable(ae);ae.container=ah;ah.content_div.append(ae.container_div)}var af=this.container.replace_drawable(this,ah,true);ah.request_draw({clear_tile_cache:true})},before_draw:function(){O.prototype.before_draw.call(this);var af=ad.min(ad.map(this.drawables,function(ag){return ag.prefs.min_value})),ae=ad.max(ad.map(this.drawables,function(ag){return ag.prefs.max_value}));this.prefs.min_value=af;this.prefs.max_value=ae;ad.each(this.drawables,function(ag){ag.prefs.min_value=af;ag.prefs.max_value=ae})},update_all_min_max:function(){var ae=this;ad.each(this.drawables,function(af){af.prefs.min_value=ae.prefs.min_value;af.prefs.max_value=ae.prefs.max_value});this.request_draw({clear_tile_cache:true})},postdraw_actions:function(ak,ae,an,aj){O.prototype.postdraw_actions.call(this,ak,ae,an,aj);var ai=-1;for(var ag=0;ag<ak.length;ag++){var al=ak[ag].html_elt.find("canvas").height();if(al>ai){ai=al}}for(var ag=0;ag<ak.length;ag++){var ah=ak[ag];if(ah.html_elt.find("canvas").height()!==ai){this.draw_helper(ah.region,an,{force:true,height:ai});ah.html_elt.remove()}}var af=this,am=function(){af.update_all_min_max()};this._add_yaxis_label("min",am);this._add_yaxis_label("max",am)}});var D=function(ae){O.call(this,ae,{content_div:ae.top_labeltrack},{resize:false});this.visible_height_px=12;this.left_offset=ae.canvas_manager.char_width_px;this.container_div.addClass("reference-track");this.data_url=galaxy_config.root+"api/genomes/"+this.view.dbkey;this.data_url_extra_params={reference:true};this.data_manager=new y.GenomeReferenceDataManager({data_url:this.data_url,can_subset:this.can_subset});this.hide_contents()};q(D.prototype,r.prototype,O.prototype,{build_header_div:function(){},init:function(){this.data_manager.clear();this.enabled=true},predraw_init:function(){},can_draw:r.prototype.can_draw,draw_helper:function(af,ag,ae){if(ag>this.view.canvas_manager.char_width_px){this.tiles_div.show();return O.prototype.draw_helper.call(this,af,ag,ae)}else{this.tiles_div.hide();return null}},can_subset:function(ae){return true},draw_tile:function(ag,am,ah,aj,an){var af=this.data_manager.subset_entry(ag,aj),al=af.data;var ae=am.canvas;am.font=am.canvas.manager.default_font;am.textAlign="center";for(var ai=0,ak=al.length;ai<ak;ai++){am.fillStyle=this.view.get_base_color(al[ai]);am.fillText(al[ai],Math.floor(ai*an),10)}return new c(this,aj,an,ae,af)}});var h=function(ag,af,ah){var ae=this;this.display_modes=C;this.mode="Histogram";O.call(this,ag,af,ah);this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"color",label:"Color",type:"color",default_value:l.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:30,hidden:true}],saved_values:ah.prefs,onchange:function(){ae.set_name(ae.prefs.name);ae.request_redraw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.visible_height_px=this.prefs.height};q(h.prototype,r.prototype,O.prototype,{before_draw:function(){},draw_tile:function(ae,af,ah,ag,ai){return this._draw_line_track_tile(ae,af,ah,ag,ai)},can_subset:function(ae){return(ae.data[1][0]-ae.data[0][0]===1)},postdraw_actions:function(af,ag,ah,ae){this._add_yaxis_label("max");this._add_yaxis_label("min")}});var t=function(ag,af,ah){var ae=this;this.display_modes=["Heatmap"];this.mode="Heatmap";O.call(this,ag,af,ah);this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"pos_color",label:"Positive Color",type:"color",default_value:"#FF8C00"},{key:"neg_color",label:"Negative Color",type:"color",default_value:"#4169E1"},{key:"min_value",label:"Min Value",type:"float",default_value:-1},{key:"max_value",label:"Max Value",type:"float",default_value:1},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"height",type:"int",default_value:500,hidden:true}],saved_values:ah.prefs,onchange:function(){ae.set_name(ae.prefs.name);this.request_redraw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.visible_height_px=this.prefs.height};q(t.prototype,r.prototype,O.prototype,{draw_tile:function(ae,ag,aj,ai,ak){var ah=ag.canvas,af=new M.DiagonalHeatmapPainter(ae.data,ai.get("start"),ai.get("end"),this.prefs,aj);af.draw(ag,ah.width,ah.height,ak);return new c(this,ai,ak,ah,ae.data)}});var d=function(ah,ag,aj){var af=this;this.display_modes=["Auto","Coverage","Dense","Squish","Pack"];O.call(this,ah,ag,aj);var ai=l.get_random_color(),ae=l.get_random_color([ai,"#FFFFFF"]);this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"block_color",label:"Block color",type:"color",default_value:ai},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:ae},{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:"min_value",label:"Histogram minimum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"max_value",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:aj.prefs,onchange:function(){af.set_name(af.prefs.name);af.set_painter_from_config();af.request_draw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.visible_height_px=this.prefs.height;this.container_div.addClass("feature-track");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()};q(d.prototype,r.prototype,O.prototype,{set_painter_from_config:function(){if(this.config.get("values")["connector_style"]==="arcs"){this.painter=M.ArcLinkedFeaturePainter}else{this.painter=M.LinkedFeaturePainter}},postdraw_actions:function(ao,ag,ap,an){O.prototype.postdraw_actions.call(this,ao,ag,ap,an);var ai=this,aj;if(ai.filters_manager){var ah=ai.filters_manager.filters;for(var al=0;al<ah.length;al++){ah[al].update_ui_elt()}var ak=false,am,af;for(aj=0;aj<ao.length;aj++){if(ao[aj].data.length){am=ao[aj].data[0];for(var al=0;al<ah.length;al++){af=ah[al];if(af.applies_to(am)&&af.min!==af.max){ak=true;break}}}}if(ai.filters_available!==ak){ai.filters_available=ak;if(!ai.filters_available){ai.filters_manager.hide()}ai.update_icons()}}if(ao[0] instanceof P){var ae=true;for(aj=0;aj<ao.length;aj++){if(!ao[aj].all_slotted){ae=false;break}}if(!ae){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(ae){if(this.mode==="Auto"){if(ae==="no_detail"){ae="feature spans"}this.action_icons.mode_icon.attr("title","Set display mode (now: Auto/"+ae+")")}},incremental_slots:function(ai,ae,ah){var af=this.view.canvas_manager.dummy_context,ag=this.slotters[ai];if(!ag||(ag.mode!==ah)){ag=new (u.FeatureSlotter)(ai,ah,B,function(aj){return af.measureText(aj)});this.slotters[ai]=ag}return ag.slot_features(ae)},get_mode:function(ae){if(ae.extra_info==="no_detail"||this.is_overview){mode="no_detail"}else{if(this.view.high-this.view.low>J){mode="Squish"}else{mode="Pack"}}return mode},get_canvas_height:function(ae,ai,aj,af){if(ai==="Coverage"||ae.dataset_type==="bigwig"){return this.summary_draw_height}else{var ah=this.incremental_slots(aj,ae.data,ai);var ag=new (this.painter)(null,null,null,this.prefs,ai);return Math.max(ab,ag.get_required_height(ah,af))}},draw_tile:function(ao,at,aq,ah,al,ag){var ar=this,af=at.canvas,az=ah.get("start"),ae=ah.get("end"),ai=this.left_offset;if(ao.dataset_type==="bigwig"){return this._draw_line_track_tile(ao,at,aq,ah,al)}var ak=[],ap=this.slotters[al].slots;all_slotted=true;if(ao.data){var am=this.filters_manager.filters;for(var au=0,aw=ao.data.length;au<aw;au++){var aj=ao.data[au];var av=false;var an;for(var ay=0,aD=am.length;ay<aD;ay++){an=am[ay];an.update_attrs(aj);if(!an.keep(aj)){av=true;break}}if(!av){ak.push(aj);if(!(aj[0] in ap)){all_slotted=false}}}}var aC=(this.filters_manager.alpha_filter?new E(this.filters_manager.alpha_filter):null),aA=(this.filters_manager.height_filter?new E(this.filters_manager.height_filter):null),aB=new (this.painter)(ak,az,ae,this.prefs,aq,aC,aA,ag,function(aE){return ar.view.get_base_color(aE)});var ax=null;at.fillStyle=this.prefs.block_color;at.font=at.canvas.manager.default_font;at.textAlign="right";if(ao.data){ax=aB.draw(at,af.width,af.height,al,ap);ax.translation=-ai}return new P(ar,ah,al,af,ao.data,aq,ao.message,all_slotted,ax)}});var aa=function(af,ae,ag){this.display_modes=["Auto","Coverage","Dense","Squish","Pack"];O.call(this,af,ae,ag);this.config=new j({track:this,params:[{key:"name",label:"Name",type:"text",default_value:this.name},{key:"color",label:"Histogram color",type:"color",default_value:l.get_random_color()},{key:"show_sample_data",label:"Show sample data",type:"bool",default_value:true},{key:"show_labels",label:"Show summary and sample labels",type:"bool",default_value:true},{key:"summary_height",label:"Locus summary height",type:"float",default_value:20},{key:"mode",type:"string",default_value:this.mode,hidden:true}],saved_values:ag.prefs,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.request_draw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.painter=M.VariantPainter;this.summary_draw_height=30;this.left_offset=30};q(aa.prototype,r.prototype,O.prototype,{draw_tile:function(ae,ah,aj,ai,ak){if(ae.dataset_type==="bigwig"){return this._draw_line_track_tile(ae,ah,"Histogram",ai,ak)}else{var ag=this.view,af=new (this.painter)(ae.data,ai.get("start"),ai.get("end"),this.prefs,aj,function(al){return ag.get_base_color(al)});af.draw(ah,ah.canvas.width,ah.canvas.height,ak);return new c(this,ai,ak,ah.canvas,ae.data)}},get_canvas_height:function(ae,ai,aj,ag){if(ae.dataset_type==="bigwig"){return this.summary_draw_height}else{var af=(this.dataset.get_metadata("sample_names")?this.dataset.get_metadata("sample_names").length:0);if(af===0&&ae.data.length!==0){af=ae.data[0][7].match(/,/g);if(af===null){af=1}else{af=af.length+1}}var ah=new (this.painter)(null,null,null,this.prefs,ai);return ah.get_required_height(af)}},predraw_init:function(){var ae=[g.prototype.predraw_init.call(this)];if(!this.dataset.get_metadata("sample_names")){ae.push(this.dataset.fetch())}return ae},postdraw_actions:function(ai,aj,al,af){O.prototype.postdraw_actions.call(this,ai,aj,al,af);var ah=ad.filter(ai,function(am){return(am instanceof N)});var ag=this.dataset.get_metadata("sample_names");if(ah.length===0&&this.prefs.show_labels&&ag){var ae;if(this.container_div.find(".yaxislabel.variant").length===0){ae=this.prefs.summary_height/2;this.tiles_div.prepend($("<div/>").text("Summary").addClass("yaxislabel variant top").css({"font-size":ae+"px",top:(this.prefs.summary_height-ae)/2+"px"}));if(this.prefs.show_sample_data){var ak=ag.join("<br/>");this.tiles_div.prepend($("<div/>").html(ak).addClass("yaxislabel variant top sample").css({top:this.prefs.summary_height+2,}))}}ae=(this.mode==="Squish"?5:10)+"px";$(this.tiles_div).find(".sample").css({"font-size":ae,"line-height":ae});$(this.tiles_div).find(".yaxislabel").css("color",this.prefs.label_color)}else{this.container_div.find(".yaxislabel.variant").remove()}}});var U=function(ag,af,ai){d.call(this,ag,af,ai);var ah=l.get_random_color(),ae=l.get_random_color([ah,"#ffffff"]);this.config=new j({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:ah},{key:"reverse_strand_color",label:"Antisense strand color",type:"color",default_value:ae},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},{key:"min_value",label:"Histogram minimum",type:"float",default_value:null,help:"clear value to set automatically"},{key:"max_value",label:"Histogram maximum",type:"float",default_value:null,help:"clear value to set automatically"}],saved_values:ai.prefs,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.request_draw({clear_tile_cache:true})}});this.prefs=this.config.get("values");this.painter=(ag.reference_track?M.RefBasedReadPainter:M.ReadPainter);this.update_icons()};q(U.prototype,r.prototype,O.prototype,d.prototype);var e={CompositeTrack:f,DrawableGroup:Q,DiagonalHeatmapTrack:t,FeatureTrack:d,LineTrack:h,ReadTrack:U,VariantTrack:aa,VcfTrack:aa};var p=function(ag,af,ae){if("copy" in ag){return ag.copy(ae)}else{var ah=ag.obj_type;if(!ah){ah=ag.track_type}return new e[ah](af,ae,ag)}};return{TracksterView:Z,DrawableGroup:Q,LineTrack:h,FeatureTrack:d,DiagonalHeatmapTrack:t,ReadTrack:U,VariantTrack:aa,CompositeTrack:f,object_from_template:p}}); \ No newline at end of file diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/packed/viz/visualization.js --- a/static/scripts/packed/viz/visualization.js +++ b/static/scripts/packed/viz/visualization.js @@ -1,1 +1,1 @@ -define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(s,i,l,o){var a=function(u,x,w,v){$.ajax({url:u,data:w,error:function(){alert("Grid failed")},success:function(y){Galaxy.modal.show({title:"Select datasets for new tracks",body:y,buttons:{Cancel:function(){Galaxy.modal.hide()},Add:function(){var z=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var A={data_type:"track_config",hda_ldda:"hda"},B=$(this).val();if($(this).attr("name")!=="id"){A.hda_ldda="ldda"}z[z.length]=$.ajax({url:x+"/"+B,data:A,dataType:"json"})});$.when.apply($,z).then(function(){var A=(arguments[0] instanceof Array?$.map(arguments,function(B){return B[0]}):[arguments[0]]);v(A)});Galaxy.modal.hide()}}})}})};var j=function(u){return("promise" in u)};var f=function(u){this.default_font=u!==undefined?u:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};s.extend(f.prototype,{load_pattern:function(u,y){var v=this.patterns,w=this.dummy_context,x=new Image();x.src=galaxy_config.root+"static/images"+y;x.onload=function(){v[u]=w.createPattern(x,"repeat")}},get_pattern:function(u){return this.patterns[u]},new_canvas:function(){var u=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(u)}u.manager=this;return u}});var q=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(u){this.clear()},get_elt:function(w){var x=this.attributes.obj_cache,y=this.attributes.key_ary,v=w.toString(),u=s.indexOf(y,function(z){return z.toString()===v});if(u!==-1){if(x[v].stale){y.splice(u,1);delete x[v]}else{this.move_key_to_end(w,u)}}return x[v]},set_elt:function(w,y){var z=this.attributes.obj_cache,A=this.attributes.key_ary,v=w.toString(),x=this.attributes.num_elements;if(!z[v]){if(A.length>=x){var u=A.shift();delete z[u.toString()]}A.push(w)}z[v]=y;return y},move_key_to_end:function(v,u){this.attributes.key_ary.splice(u,1);this.attributes.key_ary.push(v)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length},most_recently_added:function(){return this.size()===0?null:this.attributes.key_ary[this.attributes.key_ary.length-1]}});var d=q.extend({defaults:s.extend({},q.prototype.defaults,{dataset:null,genome:null,init_data:null,min_region_size:200,filters_manager:null,data_type:"data",data_mode_compatible:function(u,v){return true},can_subset:function(u){return false}}),initialize:function(u){q.prototype.initialize.call(this);var v=this.get("init_data");if(v){this.add_data(v)}},add_data:function(u){if(this.get("num_elements")<u.length){this.set("num_elements",u.length)}var v=this;s.each(u,function(w){v.set_data(w.region,w)})},data_is_ready:function(){var x=this.get("dataset"),w=$.Deferred(),u=(this.get("data_type")==="raw_data"?"state":this.get("data_type")==="data"?"converted_datasets_state":"error"),v=new l.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:x.get("hda_ldda"),data_type:u},dataType:"json"},interval:5000,success_fn:function(y){return y!=="pending"}});$.when(v.go()).then(function(y){w.resolve(y==="ok"||y==="data")});return w},search_features:function(u){var v=this.get("dataset"),w={query:u,hda_ldda:v.get("hda_ldda"),data_type:"features"};return $.getJSON(v.url(),w)},load_data:function(C,B,v,A){var y=this.get("dataset"),x={data_type:this.get("data_type"),chrom:C.get("chrom"),low:C.get("start"),high:C.get("end"),mode:B,resolution:v,hda_ldda:y.get("hda_ldda")};$.extend(x,A);var E=this.get("filters_manager");if(E){var F=[];var u=E.filters;for(var z=0;z<u.length;z++){F.push(u[z].name)}x.filter_cols=JSON.stringify(F)}var w=this,D=$.getJSON(y.url(),x,function(G){G.region=C;w.set_data(C,G)});this.set_data(C,D);return D},get_data:function(B,A,w,y){var C=this.get_elt(B);if(C&&(j(C)||this.get("data_mode_compatible")(C,A))){return C}var D=this.get("key_ary"),u=this.get("obj_cache"),v,z;for(var x=0;x<D.length;x++){v=D[x];if(v.contains(B)){z=true;C=u[v.toString()];if(j(C)||(this.get("data_mode_compatible")(C,A)&&this.get("can_subset")(C))){this.move_key_to_end(v,x);if(!j(C)){var F=this.subset_entry(C,B);this.set(B,F);C=F}return C}}}if(!z&&B.length()<this.attributes.min_region_size){var E=this.most_recently_added(),B=B.copy();if(!E||(B.get("start")>E.get("start"))){B.set("end",B.get("start")+this.attributes.min_region_size)}else{B.set("start",B.get("end")-this.attributes.min_region_size)}B.set("genome",this.attributes.genome);B.trim()}return this.load_data(B,A,w,y)},set_data:function(v,u){this.set_elt(v,u)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(C,B,x,A,y){var E=this._mark_stale(C);if(!(E&&this.get("data_mode_compatible")(E,B))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var w=C.get("start");if(y===this.DEEP_DATA_REQ){$.extend(A,{start_val:E.data.length+1})}else{if(y===this.BROAD_DATA_REQ){w=(E.max_high?E.max_high:E.data[E.data.length-1][2])+1}}var D=C.copy().set("start",w);var v=this,z=this.load_data(D,B,x,A),u=$.Deferred();this.set_data(C,u);$.when(z).then(function(F){if(F.data){F.data=E.data.concat(F.data);if(F.max_low){F.max_low=E.max_low}if(F.message){F.message=F.message.replace(/[0-9]+/,F.data.length)}}v.set_data(C,F);u.resolve(F)});return u},can_get_more_detailed_data:function(v){var u=this.get_elt(v);return(u.dataset_type==="bigwig"&&u.data.length<8000)},get_more_detailed_data:function(x,z,v,y,w){var u=this._mark_stale(x);if(!u){console.log("ERROR getting more detailed data: no current data");return}if(!w){w={}}if(u.dataset_type==="bigwig"){w.num_samples=1000*y}return this.load_data(x,z,v,w)},_mark_stale:function(v){var u=this.get_elt(v);if(!u){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),v.toString())}u.stale=true;return u},get_genome_wide_data:function(u){var w=this,y=true,x=s.map(u.get("chroms_info").chrom_info,function(A){var z=w.get_elt(new g({chrom:A.chrom,start:0,end:A.len}));if(!z){y=false}return z});if(y){return x}var v=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(z){w.add_data(z.data);v.resolve(z.data)});return v},subset_entry:function(w,x){var u={bigwig:function(y,z){return s.filter(y,function(A){return A[0]>=z.get("start")&&A[0]<=z.get("end")})},refseq:function(z,A){var B=A.get("start")-w.region.get("start"),y=w.data.length-(w.region.get("end")-A.get("end"));return w.data.slice(B,y)}};var v=w.data;if(!w.region.same(x)&&w.dataset_type in u){v=u[w.dataset_type](w.data,x)}return{region:x,data:v,dataset_type:w.dataset_type}}});var p=d.extend({initialize:function(u){var v=new Backbone.Model();v.urlRoot=u.data_url;this.set("dataset",v)},load_data:function(w,x,u,v){return(w.length()<=100000?d.prototype.load_data.call(this,w,x,u,v):{data:null,region:w})}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(u){this.id=u.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(u){var v=s.find(this.get_chroms_info(),function(w){return w.chrom===u});return new g({chrom:v.chrom,end:v.len})},get_chrom_len:function(u){return s.find(this.get_chroms_info(),function(v){return v.chrom===u}).len}});var g=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,str_val:null,genome:null},same:function(u){return this.attributes.chrom===u.get("chrom")&&this.attributes.start===u.get("start")&&this.attributes.end===u.get("end")},initialize:function(v){if(v.from_str){var x=v.from_str.split(":"),w=x[0],u=x[1].split("-");this.set({chrom:w,start:parseInt(u[0],10),end:parseInt(u[1],10)})}this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end");this.on("change",function(){this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},this)},copy:function(){return new g({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.attributes.str_val},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(B){var v=this.get("chrom"),A=B.get("chrom"),z=this.get("start"),x=B.get("start"),y=this.get("end"),w=B.get("end"),u;if(v&&A&&v!==A){return g.overlap_results.DIF_CHROMS}if(z<x){if(y<x){u=g.overlap_results.BEFORE}else{if(y<w){u=g.overlap_results.OVERLAP_START}else{u=g.overlap_results.CONTAINS}}}else{if(z>x){if(z>w){u=g.overlap_results.AFTER}else{if(y<=w){u=g.overlap_results.CONTAINED_BY}else{u=g.overlap_results.OVERLAP_END}}}else{u=(y>=w?g.overlap_results.CONTAINS:g.overlap_results.CONTAINED_BY)}}return u},trim:function(u){if(this.attributes.start<0){this.attributes.start=0}if(this.attributes.genome){var v=this.attributes.genome.get_chrom_len(this.attributes.chrom);if(this.attributes.end>v){this.attributes.end=v-1}}return this},contains:function(u){return this.compute_overlap(u)===g.overlap_results.CONTAINS},overlaps:function(u){return s.intersection([this.compute_overlap(u)],[g.overlap_results.DIF_CHROMS,g.overlap_results.BEFORE,g.overlap_results.AFTER]).length===0}},{overlap_results:{DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006}});var m=Backbone.Collection.extend({model:g});var e=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:g}]});var r=Backbone.Collection.extend({model:e});var t=Backbone.RelationalModel.extend({relations:[{type:Backbone.HasOne,key:"dataset",relatedModel:i.Dataset}],initialize:function(u){this.set("config",o.ConfigSettingCollection.from_config_dict(u.prefs));this.get("config").add([{key:"name",value:this.get("name")},{key:"color"}]);var v=this.get("preloaded_data");if(v){v=v.data}else{v=[]}this.set("data_manager",new d({dataset:this.get("dataset"),init_data:v}))}});var n=Backbone.RelationalModel.extend({defaults:{title:"",type:""},url:galaxy_config.root+"visualization/save",save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var k=n.extend({defaults:s.extend({},n.prototype.defaults,{dbkey:"",tracks:null,bookmarks:null,viewport:null}),relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:t}],add_tracks:function(u){this.get("tracks").add(u)}});var b=Backbone.Model.extend({});var h=Backbone.Router.extend({initialize:function(v){this.view=v.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var u=this;u.view.on("navigate",function(w){u.navigate(w)})},change_location:function(u){this.view.go_to(u)}});return{BackboneTrack:t,BrowserBookmark:e,BrowserBookmarkCollection:r,Cache:q,CanvasManager:f,Genome:c,GenomeDataManager:d,GenomeRegion:g,GenomeRegionCollection:m,GenomeVisualization:k,GenomeReferenceDataManager:p,TrackBrowserRouter:h,TrackConfig:b,Visualization:n,select_datasets:a}}); \ No newline at end of file +define(["libs/underscore","mvc/data","viz/trackster/util","utils/config"],function(s,i,l,o){var a=function(u,x,w,v){$.ajax({url:u,data:w,error:function(){alert("Grid failed")},success:function(y){Galaxy.modal.show({title:"Select datasets for new tracks",body:y,buttons:{Cancel:function(){Galaxy.modal.hide()},Add:function(){var z=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var A={data_type:"track_config",hda_ldda:"hda"},B=$(this).val();if($(this).attr("name")!=="id"){A.hda_ldda="ldda"}z[z.length]=$.ajax({url:x+"/"+B,data:A,dataType:"json"})});$.when.apply($,z).then(function(){var A=(arguments[0] instanceof Array?$.map(arguments,function(B){return B[0]}):[arguments[0]]);v(A)});Galaxy.modal.hide()}}})}})};var j=function(u){return("promise" in u)};var f=function(u){this.default_font=u!==undefined?u:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};s.extend(f.prototype,{load_pattern:function(u,y){var v=this.patterns,w=this.dummy_context,x=new Image();x.src=galaxy_config.root+"static/images"+y;x.onload=function(){v[u]=w.createPattern(x,"repeat")}},get_pattern:function(u){return this.patterns[u]},new_canvas:function(){var u=$("<canvas/>")[0];if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(u)}u.manager=this;return u}});var q=Backbone.Model.extend({defaults:{num_elements:20,obj_cache:null,key_ary:null},initialize:function(u){this.clear()},get_elt:function(w){var x=this.attributes.obj_cache,y=this.attributes.key_ary,v=w.toString(),u=s.indexOf(y,function(z){return z.toString()===v});if(u!==-1){if(x[v].stale){y.splice(u,1);delete x[v]}else{this.move_key_to_end(w,u)}}return x[v]},set_elt:function(w,y){var z=this.attributes.obj_cache,A=this.attributes.key_ary,v=w.toString(),x=this.attributes.num_elements;if(!z[v]){if(A.length>=x){var u=A.shift();delete z[u.toString()]}A.push(w)}z[v]=y;return y},move_key_to_end:function(v,u){this.attributes.key_ary.splice(u,1);this.attributes.key_ary.push(v)},clear:function(){this.attributes.obj_cache={};this.attributes.key_ary=[]},size:function(){return this.attributes.key_ary.length},most_recently_added:function(){return this.size()===0?null:this.attributes.key_ary[this.attributes.key_ary.length-1]}});var d=q.extend({defaults:s.extend({},q.prototype.defaults,{dataset:null,genome:null,init_data:null,min_region_size:200,filters_manager:null,data_type:"data",data_mode_compatible:function(u,v){return true},can_subset:function(u){return false}}),initialize:function(u){q.prototype.initialize.call(this);var v=this.get("init_data");if(v){this.add_data(v)}},add_data:function(u){if(this.get("num_elements")<u.length){this.set("num_elements",u.length)}var v=this;s.each(u,function(w){v.set_data(w.region,w)})},data_is_ready:function(){var x=this.get("dataset"),w=$.Deferred(),u=(this.get("data_type")==="raw_data"?"state":this.get("data_type")==="data"?"converted_datasets_state":"error"),v=new l.ServerStateDeferred({ajax_settings:{url:this.get("dataset").url(),data:{hda_ldda:x.get("hda_ldda"),data_type:u},dataType:"json"},interval:5000,success_fn:function(y){return y!=="pending"}});$.when(v.go()).then(function(y){w.resolve(y==="ok"||y==="data")});return w},search_features:function(u){var v=this.get("dataset"),w={query:u,hda_ldda:v.get("hda_ldda"),data_type:"features"};return $.getJSON(v.url(),w)},load_data:function(C,B,v,A){var y=this.get("dataset"),x={data_type:this.get("data_type"),chrom:C.get("chrom"),low:C.get("start"),high:C.get("end"),mode:B,resolution:v,hda_ldda:y.get("hda_ldda")};$.extend(x,A);var E=this.get("filters_manager");if(E){var F=[];var u=E.filters;for(var z=0;z<u.length;z++){F.push(u[z].name)}x.filter_cols=JSON.stringify(F)}var w=this,D=$.getJSON(y.url(),x,function(G){G.region=C;w.set_data(C,G)});this.set_data(C,D);return D},get_data:function(B,A,w,y){var C=this.get_elt(B);if(C&&(j(C)||this.get("data_mode_compatible")(C,A))){return C}var D=this.get("key_ary"),u=this.get("obj_cache"),v,z;for(var x=0;x<D.length;x++){v=D[x];if(v.contains(B)){z=true;C=u[v.toString()];if(j(C)||(this.get("data_mode_compatible")(C,A)&&this.get("can_subset")(C))){this.move_key_to_end(v,x);if(!j(C)){var F=this.subset_entry(C,B);this.set(B,F);C=F}return C}}}if(!z&&B.length()<this.attributes.min_region_size){B=B.copy();var E=this.most_recently_added();if(!E||(B.get("start")>E.get("start"))){B.set("end",B.get("start")+this.attributes.min_region_size)}else{B.set("start",B.get("end")-this.attributes.min_region_size)}B.set("genome",this.attributes.genome);B.trim()}return this.load_data(B,A,w,y)},set_data:function(v,u){this.set_elt(v,u)},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(C,B,x,A,y){var E=this._mark_stale(C);if(!(E&&this.get("data_mode_compatible")(E,B))){console.log("ERROR: problem with getting more data: current data is not compatible");return}var w=C.get("start");if(y===this.DEEP_DATA_REQ){$.extend(A,{start_val:E.data.length+1})}else{if(y===this.BROAD_DATA_REQ){w=(E.max_high?E.max_high:E.data[E.data.length-1][2])+1}}var D=C.copy().set("start",w);var v=this,z=this.load_data(D,B,x,A),u=$.Deferred();this.set_data(C,u);$.when(z).then(function(F){if(F.data){F.data=E.data.concat(F.data);if(F.max_low){F.max_low=E.max_low}if(F.message){F.message=F.message.replace(/[0-9]+/,F.data.length)}}v.set_data(C,F);u.resolve(F)});return u},can_get_more_detailed_data:function(v){var u=this.get_elt(v);return(u.dataset_type==="bigwig"&&u.data.length<8000)},get_more_detailed_data:function(x,z,v,y,w){var u=this._mark_stale(x);if(!u){console.log("ERROR getting more detailed data: no current data");return}if(!w){w={}}if(u.dataset_type==="bigwig"){w.num_samples=1000*y}return this.load_data(x,z,v,w)},_mark_stale:function(v){var u=this.get_elt(v);if(!u){console.log("ERROR: no data to mark as stale: ",this.get("dataset"),v.toString())}u.stale=true;return u},get_genome_wide_data:function(u){var w=this,y=true,x=s.map(u.get("chroms_info").chrom_info,function(A){var z=w.get_elt(new g({chrom:A.chrom,start:0,end:A.len}));if(!z){y=false}return z});if(y){return x}var v=$.Deferred();$.getJSON(this.get("dataset").url(),{data_type:"genome_data"},function(z){w.add_data(z.data);v.resolve(z.data)});return v},subset_entry:function(w,x){var u={bigwig:function(y,z){return s.filter(y,function(A){return A[0]>=z.get("start")&&A[0]<=z.get("end")})},refseq:function(z,A){var B=A.get("start")-w.region.get("start"),y=w.data.length-(w.region.get("end")-A.get("end"));return w.data.slice(B,y)}};var v=w.data;if(!w.region.same(x)&&w.dataset_type in u){v=u[w.dataset_type](w.data,x)}return{region:x,data:v,dataset_type:w.dataset_type}}});var p=d.extend({initialize:function(u){var v=new Backbone.Model();v.urlRoot=u.data_url;this.set("dataset",v)},load_data:function(w,x,u,v){return(w.length()<=100000?d.prototype.load_data.call(this,w,x,u,v):{data:null,region:w})}});var c=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},initialize:function(u){this.id=u.dbkey},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info},get_chrom_region:function(u){var v=s.find(this.get_chroms_info(),function(w){return w.chrom===u});return new g({chrom:v.chrom,end:v.len})},get_chrom_len:function(u){return s.find(this.get_chroms_info(),function(v){return v.chrom===u}).len}});var g=Backbone.RelationalModel.extend({defaults:{chrom:null,start:0,end:0,str_val:null,genome:null},same:function(u){return this.attributes.chrom===u.get("chrom")&&this.attributes.start===u.get("start")&&this.attributes.end===u.get("end")},initialize:function(v){if(v.from_str){var x=v.from_str.split(":"),w=x[0],u=x[1].split("-");this.set({chrom:w,start:parseInt(u[0],10),end:parseInt(u[1],10)})}this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end");this.on("change",function(){this.attributes.str_val=this.get("chrom")+":"+this.get("start")+"-"+this.get("end")},this)},copy:function(){return new g({chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")})},length:function(){return this.get("end")-this.get("start")},toString:function(){return this.attributes.str_val},toJSON:function(){return{chrom:this.get("chrom"),start:this.get("start"),end:this.get("end")}},compute_overlap:function(B){var v=this.get("chrom"),A=B.get("chrom"),z=this.get("start"),x=B.get("start"),y=this.get("end"),w=B.get("end"),u;if(v&&A&&v!==A){return g.overlap_results.DIF_CHROMS}if(z<x){if(y<x){u=g.overlap_results.BEFORE}else{if(y<w){u=g.overlap_results.OVERLAP_START}else{u=g.overlap_results.CONTAINS}}}else{if(z>x){if(z>w){u=g.overlap_results.AFTER}else{if(y<=w){u=g.overlap_results.CONTAINED_BY}else{u=g.overlap_results.OVERLAP_END}}}else{u=(y>=w?g.overlap_results.CONTAINS:g.overlap_results.CONTAINED_BY)}}return u},trim:function(u){if(this.attributes.start<0){this.attributes.start=0}if(this.attributes.genome){var v=this.attributes.genome.get_chrom_len(this.attributes.chrom);if(this.attributes.end>v){this.attributes.end=v-1}}return this},contains:function(u){return this.compute_overlap(u)===g.overlap_results.CONTAINS},overlaps:function(u){return s.intersection([this.compute_overlap(u)],[g.overlap_results.DIF_CHROMS,g.overlap_results.BEFORE,g.overlap_results.AFTER]).length===0}},{overlap_results:{DIF_CHROMS:1000,BEFORE:1001,CONTAINS:1002,OVERLAP_START:1003,OVERLAP_END:1004,CONTAINED_BY:1005,AFTER:1006}});var m=Backbone.Collection.extend({model:g});var e=Backbone.RelationalModel.extend({defaults:{region:null,note:""},relations:[{type:Backbone.HasOne,key:"region",relatedModel:g}]});var r=Backbone.Collection.extend({model:e});var t=Backbone.RelationalModel.extend({relations:[{type:Backbone.HasOne,key:"dataset",relatedModel:i.Dataset}],initialize:function(u){this.set("config",o.ConfigSettingCollection.from_config_dict(u.prefs));this.get("config").add([{key:"name",value:this.get("name")},{key:"color"}]);var v=this.get("preloaded_data");if(v){v=v.data}else{v=[]}this.set("data_manager",new d({dataset:this.get("dataset"),init_data:v}))}});var n=Backbone.RelationalModel.extend({defaults:{title:"",type:""},url:galaxy_config.root+"visualization/save",save:function(){return $.ajax({url:this.url(),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(this)}})}});var k=n.extend({defaults:s.extend({},n.prototype.defaults,{dbkey:"",tracks:null,bookmarks:null,viewport:null}),relations:[{type:Backbone.HasMany,key:"tracks",relatedModel:t}],add_tracks:function(u){this.get("tracks").add(u)}});var b=Backbone.Model.extend({});var h=Backbone.Router.extend({initialize:function(v){this.view=v.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var u=this;u.view.on("navigate",function(w){u.navigate(w)})},change_location:function(u){this.view.go_to(u)}});return{BackboneTrack:t,BrowserBookmark:e,BrowserBookmarkCollection:r,Cache:q,CanvasManager:f,Genome:c,GenomeDataManager:d,GenomeRegion:g,GenomeRegionCollection:m,GenomeVisualization:k,GenomeReferenceDataManager:p,TrackBrowserRouter:h,TrackConfig:b,Visualization:n,select_datasets:a}}); \ No newline at end of file diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/utils/galaxy.css.js --- a/static/scripts/utils/galaxy.css.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Galaxy CSS utilities -*/ - -// dependencies -define(["libs/underscore"], function(_) { - -// get css value -function get_attribute (classname, name) -{ - // place dummy element - var el = $('<div class="' + classname + '"></div>'); - - // required append - el.appendTo(':eq(0)'); - - // get value - var value = el.css(name); - - // remove element - el.remove(); - - // return css value - return value; -} - -// load css -function load_file (url) -{ - // check if css is already available - if (!$('link[href^="' + url + '"]').length) - $('<link href="' + galaxy_config.root + url + '" rel="stylesheet">').appendTo('head'); -}; - -// return -return { - load_file : load_file, - get_attribute : get_attribute -}; - -}); diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/utils/galaxy.uploadbox.js --- a/static/scripts/utils/galaxy.uploadbox.js +++ b/static/scripts/utils/galaxy.uploadbox.js @@ -41,6 +41,7 @@ // indicates if queue is currently running var queue_running = false; + var queue_pause = false; // element var el = null; @@ -155,8 +156,9 @@ function process() { // validate - if (queue_length == 0 || !queue_running) + if (queue_length == 0 || queue_pause) { + queue_pause = false; queue_running = false; opts.complete(); return; @@ -338,8 +340,8 @@ // pause upload process function pause() { - // set global status variable to false - queue_running = false; + // request pause + queue_pause = true; } // set options diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/scripts/utils/galaxy.utils.js --- /dev/null +++ b/static/scripts/utils/galaxy.utils.js @@ -0,0 +1,73 @@ +/** + * Galaxy utilities comprises small functions, which at this point + * do not require their own classes/files +*/ + +// dependencies +define(["libs/underscore"], function(_) { + +// generic function to recieve json from url +function jsonFromUrl (url, successHandler, errorHandler) { + + // open url + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + + // configure request + xhr.setRequestHeader('Accept', 'application/json'); + xhr.setRequestHeader('Cache-Control', 'no-cache'); + xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + + // on completion + xhr.onloadend = function() { + var status = xhr.status; + if (status == 200) { + try + { + response = jQuery.parseJSON(xhr.responseText); + } catch (e) { + response = xhr.responseText; + } + successHandler && successHandler(response); + } else { + errorHandler && errorHandler(status); + } + }; + + // submit request + xhr.send(); +}; + +// get css value +function cssGetAttribute (classname, name) { + // place dummy element + var el = $('<div class="' + classname + '"></div>'); + + // required append + el.appendTo(':eq(0)'); + + // get value + var value = el.css(name); + + // remove element + el.remove(); + + // return css value + return value; +}; + +// load css +function cssLoadFile (url) { + // check if css is already available + if (!$('link[href^="' + url + '"]').length) + $('<link href="' + galaxy_config.root + url + '" rel="stylesheet">').appendTo('head'); +}; + +// return +return { + cssLoadFile : cssLoadFile, + cssGetAttribute : cssGetAttribute, + jsonFromUrl : jsonFromUrl +}; + +}); diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/style/blue/base.css --- a/static/style/blue/base.css +++ b/static/style/blue/base.css @@ -1125,10 +1125,10 @@ .galaxy-frame .frame .f-pin{left:6px;top:1px} .galaxy-frame .frame .f-resize{background:#fff;width:16px;height:16px;color:#2c3143;right:0px;bottom:0px;text-align:center;line-height:16px;border:0px} .upload-info{font-weight:normal;text-align:center} -.upload-box{width:100%;height:90%;text-align:center;overflow:scroll;font-size:12px;line-height:1.33;-moz-border-radius:5px;border-radius:5px;border:1px dashed #bfbfbf;padding:10px}.upload-box .table{width:100%} +.upload-box{width:100%;height:95%;text-align:center;overflow:scroll;font-size:12px;line-height:1.33;-moz-border-radius:5px;border-radius:5px;border:1px dashed #bfbfbf;padding:10px}.upload-box .table{width:100%} .upload-box .table th{text-align:center;white-space:nowrap} .upload-box .table td{margin:0px;paddign:0px} -.upload-box .title{width:150px;word-wrap:break-word;font-size:11px} +.upload-box .title{width:120px;word-wrap:break-word;font-size:11px} .upload-box .size{white-space:nowrap} .upload-box .info{width:130px;font-size:11px}.upload-box .info .progress{top:1px;position:relative;width:100%;padding:0px;margin:0px}.upload-box .info .progress .progress-bar{border-radius:inherit;-moz-border-radius:inherit} .upload-box .info .progress .percentage{position:absolute;text-align:center;width:100%;color:#fff} diff -r ac7e402af32e98cb9a0a1e5d88f75db16dc78281 -r 2157b57ca8e49985cc9c0139a9cf771115e12934 static/style/src/less/upload.less --- a/static/style/src/less/upload.less +++ b/static/style/src/less/upload.less @@ -7,7 +7,7 @@ .upload-box { width : 100%; - height : 90%; + height : 95%; text-align : center; overflow : scroll; font-size : @font-size-base; @@ -32,7 +32,7 @@ } .title { - width: 150px; + width: 120px; word-wrap: break-word; font-size : @font-size-small; } 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.