galaxy-commits
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
February 2011
- 1 participants
- 166 discussions
commit/galaxy-central: dannon: Interval now uses line estimates instead of '? regions' for the peek.
by Bitbucket 03 Feb '11
by Bitbucket 03 Feb '11
03 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/2a8cb9436c2b/
changeset: r4984:2a8cb9436c2b
user: dannon
date: 2011-02-03 19:12:46
summary: Interval now uses line estimates instead of '? regions' for the peek.
affected #: 2 files (116 bytes)
--- a/lib/galaxy/datatypes/data.py Thu Feb 03 09:34:39 2011 -0500
+++ b/lib/galaxy/datatypes/data.py Thu Feb 03 13:12:46 2011 -0500
@@ -397,6 +397,15 @@
if line and not line.startswith( '#' ):
data_lines += 1
dataset.metadata.data_lines = data_lines
+ def estimate_file_lines( self, dataset ):
+ # Perform a rough estimate by extrapolating number of lines from a small read.
+ sample_size = 1048576
+ dataset_fh = open( dataset.file_name )
+ dataset_read = dataset_fh.read(sample_size)
+ dataset_fh.close()
+ sample_lines = dataset_read.count('\n')
+ est_lines = int(sample_lines * (float(dataset.get_size()) / float(sample_size)))
+ return est_lines
def set_peek( self, dataset, line_count=None, is_multi_byte=False ):
if not dataset.dataset.purged:
# The file must exist on disk for the get_file_peek() method
@@ -409,13 +418,7 @@
# Number of lines is not known ( this should not happen ), and auto-detect is
# needed to set metadata
# This can happen when the file is larger than max_optional_metadata_filesize.
- # Perform a rough estimate by extrapolating number of lines from a small read.
- sample_size = 1048576
- dataset_fh = open( dataset.file_name )
- dataset_read = dataset_fh.read(sample_size)
- dataset_fh.close()
- sample_lines = dataset_read.count('\n')
- est_lines = int(sample_lines * (float(dataset.get_size()) / float(sample_size)))
+ est_lines = self.estimate_file_lines(dataset)
dataset.blurb = "~%s %s" % ( util.commaify(str(est_lines)), inflector.cond_plural(est_lines, "line") )
else:
dataset.blurb = "%s %s" % util.commaify( str(line_count) ), inflector.cond_plural(line_count, "line")
--- a/lib/galaxy/datatypes/interval.py Thu Feb 03 09:34:39 2011 -0500
+++ b/lib/galaxy/datatypes/interval.py Thu Feb 03 13:12:46 2011 -0500
@@ -71,7 +71,7 @@
else:
# Number of lines is not known ( this should not happen ), and auto-detect is
# needed to set metadata
- dataset.blurb = "? regions"
+ dataset.blurb = "~%s regions" % util.commaify( str( self.estimate_file_lines(dataset) ) )
else:
dataset.blurb = "%s regions" % util.commaify( str( line_count ) )
else:
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.
1
0
commit/galaxy-central: jgoecks: Trackster: avoid drawing tiles multiple times by checking cache in delayed_draw.
by Bitbucket 03 Feb '11
by Bitbucket 03 Feb '11
03 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/b23f64804904/
changeset: r4983:b23f64804904
user: jgoecks
date: 2011-02-03 15:34:39
summary: Trackster: avoid drawing tiles multiple times by checking cache in delayed_draw.
affected #: 2 files (251 bytes)
--- a/static/scripts/packed/trackster.js Wed Feb 02 16:21:23 2011 -0500
+++ b/static/scripts/packed/trackster.js Thu Feb 03 09:34:39 2011 -0500
@@ -1,1 +1,1 @@
-CanvasRenderingContext2D.prototype.dashedLine=function(c,i,b,h,f){if(f==undefined){f=4}var e=b-c;var d=h-i;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var k=e/g;var j=d/g;for(var a=0;a<g;a++,c+=k,i+=j){if(a%2!=0){continue}this.fillRect(c,i,f,1)}};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();for(var c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c==f.length){if(this!=f.get(c-1)){g.append(this)}}else{if(this!=f.get(c)){$(this).insertBefore(f.get(c))}}})}var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,CONNECTOR_COLOR="#ccc",DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",FILTERABLE_CLASS="filterable",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}CONTEXT=DUMMY_CANVAS.getContext("2d");PX_PER_CHAR=CONTEXT.measureText("A").width;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function(){RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.move_key_to_end(b,a)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_form=$("<form/>").attr("action",function(){}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.chrom_form);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.chrom_form);$.ajax({url:chrom_url,data:(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}),dataType:"json",success:function(f){if(f.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=f.chrom_info;var j='<option value="">Select Chrom/Contig</option>';for(var h=0,e=a.chrom_data.length;h<e;h++){var g=a.chrom_data[h].chrom;j+='<option value="'+g+'">'+g+"</option>"}a.chrom_select.html(j);a.intro_div.show();a.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});if(d){d()}},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}});this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var i=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(i/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX;g.enable_pan=(f.clientX<a.viewport_container.width()-16)?true:false}).bind("drag",function(h,j){if(!j.enable_pan){return}var f=$(this);var k=j.offsetX-j.current_x;var g=f.scrollTop()-(h.clientY-j.current_height);f.scrollTop(g);j.current_height=h.clientY;j.current_x=j.offsetX;var i=Math.round(k/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height(),top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j,k){$(k.proxy).css({left:Math.min(j.pageX,k.startX),width:Math.abs(j.pageX-k.startX)});var g=Math.min(j.pageX,k.startX)-a.container.offset().left,f=Math.max(j.pageX,k.startX)-a.container.offset().left,i=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*i)+a.low,Math.round(f/h*i)+a.low)}).bind("dragend",function(k,l){var g=Math.min(k.pageX,l.startX),f=Math.max(k.pageX,l.startX),i=(a.high-a.low),h=a.viewport_container.width(),j=a.low;a.low=Math.round(g/h*i)+j;a.high=Math.round(f/h*i)+j;$(l.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},change_chrom:function(e,b,g){var d=this;var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){return}if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()},go_to:function(f){var j=this,a,d,b=f.split(":"),h=b[0],i=b[1];if(i!==undefined){try{var g=i.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}j.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);sortable(a.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_location(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").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()}});var Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)==0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e=="int"||e=="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");if(!a.content_div.text()){a.content_div.text(DATA_LOADING)}a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}$.getJSON(this.dataset_check_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom,low:a.view.max_low,high:a.view.max_high},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").attr("id",d+"_error");c.text("View error");$("#"+d+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b==="data"){a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;a.predraw_init();a.draw()}}}}}}})},predraw_init:function(){},restore_prefs:function(a){var b=this;$.each(a,function(c,d){if(d!==undefined){b.prefs[c]=d}})},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(g,d,s){var o=this,j=o.view;this.filters=(g!==undefined?get_filters_from_dict(g):[]);this.tool=(d!==undefined?get_tool_from_dict(d):undefined);this.parent_track=s;this.child_tracks=[];if(o.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filtering_div=$("<div/>").addClass("track-filters").hide();this.header_div.after(this.filtering_div);this.filtering_div.bind("drag",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var t=$("<table class='filters'>").appendTo(this.filtering_div);$.each(this.filters,function(w,z){var v=$("<tr>").appendTo(t);var y=$("<th class='filter-info'>").appendTo(v);var u=$("<span class='name'>").appendTo(y);u.text(z.name+" ");var i=$("<span class='values'>").appendTo(y);var x=$("<td>").appendTo(v);z.control_element=$("<div id='"+z.name+"-filter-control' style='width: 200px; position: relative'>").appendTo(x);z.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(B,C){var A=C.values;i.text("["+A[0]+"-"+A[1]+"]");z.low=A[0];z.high=A[1];o.draw(true)},change:function(A,B){z.control_element.slider("option","slide").call(z.control_element,A,B)}});z.slider=z.control_element;z.slider_label=i});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(i){i.stopPropagation()}).bind("click",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var l=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var e=this.tool.params;var o=this;$.each(this.tool.params,function(A,v){var y=$("<div>").addClass("param-row").appendTo(o.dynamic_tool_div);var x=$("<div>").addClass("slider-label").appendTo(y);var C=$("<span class='param-name'>").text(v.label+" ").appendTo(x);var w=$("<span/>").text(v.value);var z=$("<span class='param-value'>").appendTo(x).append("[").append(w).append("]");var B=$("<div/>").addClass("slider").appendTo(y);var i=$("<div id='"+v.name+"-param-control'>").appendTo(B);var u=(v.max<=1?0.01:(v.max<=1000?1:5));i.slider({min:v.min,max:v.max,step:u,value:v.value,slide:function(D,F){var E=F.value;v.value=E;if(0<E&&E<1){E=parseFloat(E).toFixed(2)}w.text(E)},change:function(D,E){v.value=E.value}});z.click(function(){var F=w,E=F.text(),D=(v.max<=1?4:v.max.length);F.text("");$("<input type='text'/>").attr("size",D).attr("maxlength",D).attr("value",E).appendTo(F).focus().select().click(function(G){G.stopPropagation()}).blur(function(){$(this).remove();F.text(E)}).keyup(function(I){if(I.keyCode===27){$(this).trigger("blur")}else{if(I.keyCode===13){var G=$(this),H=parseFloat(G.val());if(isNaN(H)||H>v.max||H<v.min){alert("Parameter value must be in the range ["+v.min+"-"+v.max+"]");return $(this)}F.text(H);i.slider("value",H);v.value=H}}})});$("<div style='clear: both;'/>").appendTo(y)});var b=$("<div>").addClass("param-row").appendTo(this.dynamic_tool_div);var n=$("<input type='submit'>").attr("value","Run").appendTo(b);var o=this;n.click(function(){o.run_tool()})}o.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();o.container_div.append(o.child_tracks_container);if(o.display_modes!==undefined){if(o.mode_div===undefined){o.mode_div=$("<div class='right-float menubutton popup' />").appendTo(o.header_div);var m=o.display_modes[0];o.mode=m;o.mode_div.text(m);var a=function(i){o.mode_div.text(i);o.mode=i;o.tile_cache.clear();o.draw()};var f={};for(var q=0,r=o.display_modes.length;q<r;q++){var k=o.display_modes[q];f[k]=function(i){return function(){a(i)}}(k)}make_popupmenu(o.mode_div,f)}else{o.mode_div.hide()}}var h={};h["Edit configuration"]=function(){var v=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},i=function(){o.update_options(o.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},u=function(w){if((w.keyCode||w.which)===27){v()}else{if((w.keyCode||w.which)===13){i()}}};$(window).bind("keypress.check_enter_esc",u);show_modal("Configure Track",o.gen_options(o.track_id),{Cancel:v,OK:i})};h["Set as overview"]=function(){j.overview_viewport.find("canvas").remove();o.is_overview=true;o.set_overview();for(var i in j.tracks){if(j.tracks[i]!==o){j.tracks[i].is_overview=false}}};if(o.filters.length>0){h["Show filters"]=function(){var i;if(!o.filtering_div.is(":visible")){i="Hide filters";o.filters_visible=true}else{i="Show filters";o.filters_visible=false}o.filtering_div.toggle()}}if(o.tool){h["Toggle Tool"]=function(){var i;if(!o.dynamic_tool_div.is(":visible")){i="Hide dynamic tool";o.update_name(o.name+o.tool_region_and_parameters_str())}else{i="Show dynamic tool";o.revert_name()}o.dynamic_tool_div.toggle()}}var c=j;var p=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;p=function(){}}h.Remove=function(){c.remove_track(o);if(c.num_tracks===0){p()}};o.popup_menu=make_popupmenu(o.name_div,h)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(a){var m=this.view.low,g=this.view.high,j=g-m,f=this.view.resolution;var p=$("<div style='position: relative;'></div>"),q=this.content_div.width()/j;this.content_div.append(p);this.max_height=0;var b=Math.floor(m/f/DENSITY);var l={};while((b*DENSITY*f)<g){var n=this.content_div.width()+"_"+q+"_"+b;var e=this.tile_cache.get(n);if(!a&&e){var k=b*DENSITY*f;var d=(k-m)*q;if(this.left_offset){d-=this.left_offset}e.css({left:d});this.show_tile(e,p)}else{this.delayed_draw(this,n,m,g,b,f,p,q,l)}b+=1}var c=this;var o=setInterval(function(){if(obj_length(l)===0){if(c.content_div.children().length>1){c.content_div.children(":first").remove()}for(var i=0;i<c.filters.length;i++){c.filters[i].update_ui_elt()}clearInterval(o)}},50);for(var h=0;h<this.child_tracks.length;h++){this.child_tracks[h].draw(a)}},delayed_draw:function(c,h,g,e,b,d,i,j,f){var a=setTimeout(function(){if(g<=c.view.high&&e>=c.view.low){var k=c.draw_tile(d,b,i,j);if(k){if(!c.initial_canvas&&!window.G_vmlCanvasManager){c.initial_canvas=$(k).clone();var n=k.get(0).getContext("2d");var l=c.initial_canvas.get(0).getContext("2d");var m=n.getImageData(0,0,n.canvas.width,n.canvas.height);l.putImageData(m,0,0);c.set_overview()}c.tile_cache.set(h,k);c.show_tile(k,i)}}delete f[a]},50);f[a]=true},show_tile:function(a,c){var b=this;c.append(a);b.max_height=Math.max(b.max_height,a.height());b.content_div.css("height",b.max_height+"px");if(b.hidden){return}if(a.hasClass(FILTERABLE_CLASS)){show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters");if(b.filters_visible){b.filtering_div.show()}}else{show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters",false);b.filtering_div.hide()}},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type=="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f=="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f=="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.data_queue={};this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(f,b,k,o){var g=b*DENSITY*f,d=DENSITY*f,j=f+"_"+b;var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var n=e.get(0).getContext("2d");if(o>PX_PER_CHAR){if(this.data_cache.get(j)===undefined){this.get_data(f,b);return}var m=this.data_cache.get(j);if(m===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*o+this.left_offset);e.get(0).height=this.height_px;e.css({position:"absolute",top:0,left:(g-this.view.low)*o-this.left_offset});for(var h=0,l=m.length;h<l;h++){var a=Math.round(h*o),i=Math.round(o/2);n.fillText(m[h],a+this.left_offset+i,10)}k.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,e,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.min_height_px=12;this.max_height_px=400;this.height_px=80;this.hda_ldda=e;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};this.restore_prefs(c);(function(f){var i=false;var h=false;var g=$("<div class='track-resize'>");$(f.container_div).hover(function(){i=true;g.show()},function(){i=false;if(!h){g.hide()}});g.hide().bind("dragstart",function(j,k){h=true;k.original_height=$(f.content_div).height()}).bind("drag",function(k,l){var j=Math.min(Math.max(l.original_height+l.deltaY,f.min_height_px),f.max_height_px);$(f.content_div).css("height",j);f.height_px=j;f.draw(true)}).bind("dragend",function(j,k){f.tile_cache.clear();h=false;if(!i){g.hide()}}).appendTo(f.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;$.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:this.data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){var h=g.data;c.data_cache.set(e,h);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*o,a=DENSITY*o,x=o+"_"+r;var b=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);if(this.data_cache.get(x)===undefined){this.get_data(o,r);return}var v=this.data_cache.get(x);if(!v){return}b.css({position:"absolute",top:0,left:(s-this.view.low)*e});b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var n=b.get(0).getContext("2d"),j=false,k=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,t=this.total_frequency,d=this.height_px,l=this.mode;var w=Math.round(d+k/m*d);n.beginPath();n.moveTo(0,w);n.lineTo(a*e,w);n.fillStyle="#aaa";n.stroke();n.beginPath();n.fillStyle=this.prefs.color;var u,h,f;if(v.length>1){f=Math.ceil((v[1][0]-v[0][0])*e)}else{f=10}for(var p=0,q=v.length;p<q;p++){u=Math.round((v[p][0]-s)*e);h=v[p][1];if(h===null){if(j&&l==="Filled"){n.lineTo(u,d)}j=false;continue}if(h<k){h=k}else{if(h>g){h=g}}if(l==="Histogram"){h=Math.round(h/m*d);n.fillRect(u,w,f,-h)}else{if(l==="Intensity"){h=255-Math.floor((h-k)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(u,0,f,d)}else{h=Math.round(d-(h-k)/m*d);if(j){n.lineTo(u,h)}else{j=true;if(l==="Filled"){n.moveTo(u,d);n.lineTo(u,h)}else{n.moveTo(u,h)}}}}}if(l==="Filled"){if(j){n.lineTo(u,w);n.lineTo(0,w)}n.fill()}else{n.stroke()}c.append(b);return b},gen_options:function(m){var a=$("<div />").addClass("form-row");var e="track_"+m+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+m+"_minval",l=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),k=$("<input></input>").attr("id",h).val(d),j="track_"+m+"_maxval",g=$("<label></label>").attr("for",j).text("Max value:"),i=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",j).val(i);return a.append(l).append(k).append(g).append(f).append(b).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_color").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.color=b;this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+d+"_minval").text(this.prefs.min_value);$("#linetrack_"+d+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(f,c,h,a,e,g,d,b){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,f,c,c.viewport_container);TiledTrack.call(this,g,d,b);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=h;this.dataset_id=a;this.original_dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200;this.prefs={block_color:"#444",label_color:"black",show_counts:true};this.restore_prefs(e)};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(b.data_url,{chrom:b.view.chrom,low:a,high:d,hda_ldda:b.hda_ldda,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set_data(a,d,b.mode,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,b,p){var r=this.inc_slots[a];if(!r||(r.mode!==p)){r={};r.w_scale=a;r.mode=p;this.inc_slots[a]=r;this.s_e_by_tile[a]={}}var l=r.w_scale,x=[],y=[],j=0,n=this.view.max_low;for(var v=0,w=h.length;v<w;v++){var g=h[v],k=g[0];if(r[k]!==undefined){j=Math.max(j,r[k]);y.push(r[k])}else{x.push(v)}}var q=this.s_e_by_tile[a];var m=function(D,E){var C;for(var B=0,F;B<=MAX_FEATURE_DEPTH;B++){C=true;F=q[B];if(F!==undefined){for(var z=0,A=F.length;z<A;z++){var i=F[z];if(E>i[0]&&D<i[1]){C=false;break}}}if(C){break}}if(C){return B}else{return -1}};for(var v=0,w=x.length;v<w;v++){var g=h[x[v]],k=g[0],t=g[1],c=g[2],o=g[3],d=Math.floor((t-n)*l),f=Math.ceil((c-n)*l),u=CONTEXT.measureText(o).width,e;if(o!==undefined&&!b){if(d-u<0){f+=u;e="left"}else{d-=u;e="right"}}var s=m(d,f);if(s<0){}if(s>=0){slot=q[s];if(slot===undefined){slot=q[s]=[]}slot.push([d,f]);r[k]=s;j=Math.max(j,s)}else{}}return j},rect_or_text:function(r,l,u,b,q,j,g,f){r.textAlign="center";var d=0,s=0,p=Math.round(l/2);for(var m=0,t=j.length;m<t;m++){var k=j[m],e="MIDNSHP=X"[k[0]],n=k[1];if(e==="H"||e==="S"){d-=n}var h=q+d,x=Math.floor(Math.max(0,(h-u)*l)),i=Math.floor(Math.max(0,(h+n-u)*l));switch(e){case"H":break;case"S":case"M":case"=":var o=g.slice(s,s+n);if((this.mode==="Pack"||this.mode==="Auto")&&g!==undefined&&l>PX_PER_CHAR){r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+1,i-x,9);r.fillStyle=CONNECTOR_COLOR;for(var v=0,a=o.length;v<a;v++){if(h+v>=u&&h+v<=b){var w=Math.floor(Math.max(0,(h+v-u)*l));r.fillText(o[v],w+this.left_offset+p,f+9)}}}else{r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+(this.mode!="Dense"?4:5),i-x,(this.mode!="Dense"?3:1))}s+=n;break;case"N":r.fillStyle=CONNECTOR_COLOR;r.fillRect(x+this.left_offset,f+5,i-x,1);break;case"D":r.fillStyle="red";r.fillRect(x+this.left_offset,f+4,i-x,3);break;case"P":break;case"I":s+=n;break;case"X":s+=n;break}d+=n}},draw_tile:function(ad,n,r,ar){var L=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,K=ai-L;var G=this.data_cache.get_data(L,ai,this.mode);if(G===undefined||G==="pending"||(this.mode!=="Auto"&&G.dataset_type==="summary_tree")){this.data_queue[[L,ai]]=true;this.get_data(L,ai);return}var a=Math.ceil(K*ar),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,v=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,aq,B,at;var p=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(p)}p=$(p);if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(q==="Dense"){B=v;at=10}else{at=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ar<0.0001?1/this.view.zoom_res:ar);B=this.incremental_slots(w,G.data,ab,q)*at+v;aq=this.inc_slots[w]}}p.css({position:"absolute",top:0,left:(L-this.view.low)*ar-U});p.get(0).width=a+U;p.get(0).height=B;r.parent().css("height",Math.max(this.height_px,B)+"px");var H=p.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";this.container_div.find(".yaxislabel").remove();if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,b=Math.ceil(G.delta*ar);var o=$("<div />").addClass("yaxislabel");o.text(J);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,F=W.length;am<F;am++){var Y=Math.floor((W[am][0]-L)*ar);var X=W[am][1];if(!X){continue}var aj=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}r.append(p);return p}if(G.message){p.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,at);return p}for(var ao=0;ao<this.filters.length;ao++){if(this.filters[ao].applies_to(G.data[0])){p.addClass(FILTERABLE_CLASS);break}}var ap=G.data;var al=0;for(var am=0,F=ap.length;am<F;am++){var Q=ap[am],P=Q[0],an=Q[1],aa=Q[2],M=Q[3];if(this.mode!="Dense"&&aq[P]===undefined){continue}var Z=false;var S;for(var ao=0;ao<this.filters.length;ao++){S=this.filters[ao];S.update_attrs(Q);if(!S.keep(Q)){Z=true;break}}if(Z){continue}if(an<=ai&&aa>=L){var ac=Math.floor(Math.max(0,(an-L)*ar)),I=Math.ceil(Math.min(a,Math.max(0,(aa-L)*ar))),V=(q==="Dense"?1:(1+aq[P]))*at;var E,ag,N=null,au=null;if(G.dataset_type==="bai"){H.fillStyle=h;if(Q[5] instanceof Array){var C=Math.floor(Math.max(0,(Q[4][0]-L)*ar)),O=Math.ceil(Math.min(a,Math.max(0,(Q[4][1]-L)*ar))),A=Math.floor(Math.max(0,(Q[5][0]-L)*ar)),u=Math.ceil(Math.min(a,Math.max(0,(Q[5][1]-L)*ar)));if(Q[4][1]>=L&&Q[4][0]<=ai&&Q[4][2]){this.rect_or_text(H,ar,L,ai,Q[4][0],Q[4][2],Q[4][3],V)}if(Q[5][1]>=L&&Q[5][0]<=ai&&Q[5][2]){this.rect_or_text(H,ar,L,ai,Q[5][0],Q[5][2],Q[5][3],V)}if(A>O){H.fillStyle=CONNECTOR_COLOR;H.dashedLine(O+U,V+5,U+A,V+5)}}else{H.fillStyle=h;this.rect_or_text(H,ar,L,ai,an,Q[4],Q[5],V)}if(q!=="Dense"&&!ab&&an>L){H.fillStyle=this.prefs.label_color;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var D=Q[5],T=Q[6],ae=Q[7],g=Q[8];if(T&&ae){N=Math.floor(Math.max(0,(T-L)*ar));au=Math.ceil(Math.min(a,Math.max(0,(ae-L)*ar)))}if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}if(g){if(D){if(D=="+"){H.fillStyle=RIGHT_STRAND}else{if(D=="-"){H.fillStyle=LEFT_STRAND}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}for(var ak=0,e=g.length;ak<e;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-L)*ar)),R=Math.ceil(Math.min(a,Math.max((t[1]-L)*ar)));if(d>R){continue}E=5;ag=3;H.fillRect(d+U,V+ag,R-d,E);if(N!==undefined&&!(d>au||R<N)){E=9;ag=1;var ah=Math.max(d,N),z=Math.min(R,au);H.fillRect(ah+U,V+ag,z-ah,E)}}}else{E=9;ag=1;H.fillRect(ac+U,V+ag,I-ac,E);if(Q.strand){if(Q.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(Q.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var s=Q[4],m=Q[5],c=Q[6];E=9;ag=1;H.fillRect(ac+U,V,I-ac,E);if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}var l=s+" / "+m;if(an>L&&H.measureText(l).width<(I-ac)){H.fillStyle="white";H.textAlign="center";H.fillText(l,U+ac+(I-ac)/2,V+8);H.fillStyle=h}}}}}al++}}return p},gen_options:function(i){var a=$("<div />").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label />").attr("for",e).text("Block color:"),l=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label />").attr("for",j).text("Text color:"),h=$("<input />").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(k).append(l).append(g).append(h).append(d)},update_options:function(d){var b=$("#track_"+d+"_block_color").val(),c=$("#track_"+d+"_label_color").val(),a=$("#track_"+d+"_show_count").attr("checked");if(b!==this.prefs.block_color||c!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=c;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()==0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id},function(c){})}};a()}});
\ No newline at end of file
+CanvasRenderingContext2D.prototype.dashedLine=function(c,i,b,h,f){if(f==undefined){f=4}var e=b-c;var d=h-i;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var k=e/g;var j=d/g;for(var a=0;a<g;a++,c+=k,i+=j){if(a%2!=0){continue}this.fillRect(c,i,f,1)}};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();for(var c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c==f.length){if(this!=f.get(c-1)){g.append(this)}}else{if(this!=f.get(c)){$(this).insertBefore(f.get(c))}}})}var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,CONNECTOR_COLOR="#ccc",DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",FILTERABLE_CLASS="filterable",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}CONTEXT=DUMMY_CANVAS.getContext("2d");PX_PER_CHAR=CONTEXT.measureText("A").width;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function(){RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.move_key_to_end(b,a)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_form=$("<form/>").attr("action",function(){}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.chrom_form);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.chrom_form);$.ajax({url:chrom_url,data:(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}),dataType:"json",success:function(f){if(f.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=f.chrom_info;var j='<option value="">Select Chrom/Contig</option>';for(var h=0,e=a.chrom_data.length;h<e;h++){var g=a.chrom_data[h].chrom;j+='<option value="'+g+'">'+g+"</option>"}a.chrom_select.html(j);a.intro_div.show();a.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});if(d){d()}},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}});this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var i=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(i/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX;g.enable_pan=(f.clientX<a.viewport_container.width()-16)?true:false}).bind("drag",function(h,j){if(!j.enable_pan){return}var f=$(this);var k=j.offsetX-j.current_x;var g=f.scrollTop()-(h.clientY-j.current_height);f.scrollTop(g);j.current_height=h.clientY;j.current_x=j.offsetX;var i=Math.round(k/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height(),top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j,k){$(k.proxy).css({left:Math.min(j.pageX,k.startX),width:Math.abs(j.pageX-k.startX)});var g=Math.min(j.pageX,k.startX)-a.container.offset().left,f=Math.max(j.pageX,k.startX)-a.container.offset().left,i=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*i)+a.low,Math.round(f/h*i)+a.low)}).bind("dragend",function(k,l){var g=Math.min(k.pageX,l.startX),f=Math.max(k.pageX,l.startX),i=(a.high-a.low),h=a.viewport_container.width(),j=a.low;a.low=Math.round(g/h*i)+j;a.high=Math.round(f/h*i)+j;$(l.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},change_chrom:function(e,b,g){var d=this;var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){return}if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()},go_to:function(f){var j=this,a,d,b=f.split(":"),h=b[0],i=b[1];if(i!==undefined){try{var g=i.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}j.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);sortable(a.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_location(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").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()}});var Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)==0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e=="int"||e=="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");if(!a.content_div.text()){a.content_div.text(DATA_LOADING)}a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}$.getJSON(this.dataset_check_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom,low:a.view.max_low,high:a.view.max_high},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").attr("id",d+"_error");c.text("View error");$("#"+d+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b==="data"){a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;a.predraw_init();a.draw()}}}}}}})},predraw_init:function(){},restore_prefs:function(a){var b=this;$.each(a,function(c,d){if(d!==undefined){b.prefs[c]=d}})},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(g,d,s){var o=this,j=o.view;this.filters=(g!==undefined?get_filters_from_dict(g):[]);this.tool=(d!==undefined?get_tool_from_dict(d):undefined);this.parent_track=s;this.child_tracks=[];if(o.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filtering_div=$("<div/>").addClass("track-filters").hide();this.header_div.after(this.filtering_div);this.filtering_div.bind("drag",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var t=$("<table class='filters'>").appendTo(this.filtering_div);$.each(this.filters,function(w,z){var v=$("<tr>").appendTo(t);var y=$("<th class='filter-info'>").appendTo(v);var u=$("<span class='name'>").appendTo(y);u.text(z.name+" ");var i=$("<span class='values'>").appendTo(y);var x=$("<td>").appendTo(v);z.control_element=$("<div id='"+z.name+"-filter-control' style='width: 200px; position: relative'>").appendTo(x);z.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(B,C){var A=C.values;i.text("["+A[0]+"-"+A[1]+"]");z.low=A[0];z.high=A[1];o.draw(true)},change:function(A,B){z.control_element.slider("option","slide").call(z.control_element,A,B)}});z.slider=z.control_element;z.slider_label=i});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(i){i.stopPropagation()}).bind("click",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var l=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var e=this.tool.params;var o=this;$.each(this.tool.params,function(A,v){var y=$("<div>").addClass("param-row").appendTo(o.dynamic_tool_div);var x=$("<div>").addClass("slider-label").appendTo(y);var C=$("<span class='param-name'>").text(v.label+" ").appendTo(x);var w=$("<span/>").text(v.value);var z=$("<span class='param-value'>").appendTo(x).append("[").append(w).append("]");var B=$("<div/>").addClass("slider").appendTo(y);var i=$("<div id='"+v.name+"-param-control'>").appendTo(B);var u=(v.max<=1?0.01:(v.max<=1000?1:5));i.slider({min:v.min,max:v.max,step:u,value:v.value,slide:function(D,F){var E=F.value;v.value=E;if(0<E&&E<1){E=parseFloat(E).toFixed(2)}w.text(E)},change:function(D,E){v.value=E.value}});z.click(function(){var F=w,E=F.text(),D=(v.max<=1?4:v.max.length);F.text("");$("<input type='text'/>").attr("size",D).attr("maxlength",D).attr("value",E).appendTo(F).focus().select().click(function(G){G.stopPropagation()}).blur(function(){$(this).remove();F.text(E)}).keyup(function(I){if(I.keyCode===27){$(this).trigger("blur")}else{if(I.keyCode===13){var G=$(this),H=parseFloat(G.val());if(isNaN(H)||H>v.max||H<v.min){alert("Parameter value must be in the range ["+v.min+"-"+v.max+"]");return $(this)}F.text(H);i.slider("value",H);v.value=H}}})});$("<div style='clear: both;'/>").appendTo(y)});var b=$("<div>").addClass("param-row").appendTo(this.dynamic_tool_div);var n=$("<input type='submit'>").attr("value","Run").appendTo(b);var o=this;n.click(function(){o.run_tool()})}o.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();o.container_div.append(o.child_tracks_container);if(o.display_modes!==undefined){if(o.mode_div===undefined){o.mode_div=$("<div class='right-float menubutton popup' />").appendTo(o.header_div);var m=o.display_modes[0];o.mode=m;o.mode_div.text(m);var a=function(i){o.mode_div.text(i);o.mode=i;o.tile_cache.clear();o.draw()};var f={};for(var q=0,r=o.display_modes.length;q<r;q++){var k=o.display_modes[q];f[k]=function(i){return function(){a(i)}}(k)}make_popupmenu(o.mode_div,f)}else{o.mode_div.hide()}}var h={};h["Edit configuration"]=function(){var v=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},i=function(){o.update_options(o.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},u=function(w){if((w.keyCode||w.which)===27){v()}else{if((w.keyCode||w.which)===13){i()}}};$(window).bind("keypress.check_enter_esc",u);show_modal("Configure Track",o.gen_options(o.track_id),{Cancel:v,OK:i})};h["Set as overview"]=function(){j.overview_viewport.find("canvas").remove();o.is_overview=true;o.set_overview();for(var i in j.tracks){if(j.tracks[i]!==o){j.tracks[i].is_overview=false}}};if(o.filters.length>0){h["Show filters"]=function(){var i;if(!o.filtering_div.is(":visible")){i="Hide filters";o.filters_visible=true}else{i="Show filters";o.filters_visible=false}o.filtering_div.toggle()}}if(o.tool){h["Toggle Tool"]=function(){var i;if(!o.dynamic_tool_div.is(":visible")){i="Hide dynamic tool";o.update_name(o.name+o.tool_region_and_parameters_str())}else{i="Show dynamic tool";o.revert_name()}o.dynamic_tool_div.toggle()}}var c=j;var p=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;p=function(){}}h.Remove=function(){c.remove_track(o);if(c.num_tracks===0){p()}};o.popup_menu=make_popupmenu(o.name_div,h)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(a){var m=this.view.low,g=this.view.high,j=g-m,f=this.view.resolution;var p=$("<div style='position: relative;'></div>"),q=this.content_div.width()/j;this.content_div.append(p);this.max_height=0;var b=Math.floor(m/f/DENSITY);var l={};while((b*DENSITY*f)<g){var n=this.content_div.width()+"_"+q+"_"+b;var e=this.tile_cache.get(n);if(!a&&e){var k=b*DENSITY*f;var d=(k-m)*q;if(this.left_offset){d-=this.left_offset}e.css({left:d});this.show_tile(e,p)}else{this.delayed_draw(n,m,g,b,f,p,q,l)}b+=1}var c=this;var o=setInterval(function(){if(obj_length(l)===0){if(c.content_div.children().length>1){c.content_div.children(":first").remove()}for(var i=0;i<c.filters.length;i++){c.filters[i].update_ui_elt()}clearInterval(o)}},50);for(var h=0;h<this.child_tracks.length;h++){this.child_tracks[h].draw(a)}},delayed_draw:function(h,g,e,b,d,i,j,f){var c=this;var a=setTimeout(function(){if(g<=c.view.high&&e>=c.view.low){var k=c.tile_cache.get(h);if(!k){k=c.draw_tile(d,b,i,j)}if(k){if(!c.initial_canvas&&!window.G_vmlCanvasManager){c.initial_canvas=$(k).clone();var n=k.get(0).getContext("2d");var l=c.initial_canvas.get(0).getContext("2d");var m=n.getImageData(0,0,n.canvas.width,n.canvas.height);l.putImageData(m,0,0);c.set_overview()}c.tile_cache.set(h,k);c.show_tile(k,i)}}delete f[a]},50);f[a]=true},show_tile:function(a,c){var b=this;c.append(a);b.max_height=Math.max(b.max_height,a.height());b.content_div.css("height",b.max_height+"px");if(b.hidden){return}if(a.hasClass(FILTERABLE_CLASS)){show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters");if(b.filters_visible){b.filtering_div.show()}}else{show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters",false);b.filtering_div.hide()}},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type=="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f=="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f=="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.data_queue={};this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(f,b,k,o){var g=b*DENSITY*f,d=DENSITY*f,j=f+"_"+b;var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var n=e.get(0).getContext("2d");if(o>PX_PER_CHAR){if(this.data_cache.get(j)===undefined){this.get_data(f,b);return}var m=this.data_cache.get(j);if(m===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*o+this.left_offset);e.get(0).height=this.height_px;e.css({position:"absolute",top:0,left:(g-this.view.low)*o-this.left_offset});for(var h=0,l=m.length;h<l;h++){var a=Math.round(h*o),i=Math.round(o/2);n.fillText(m[h],a+this.left_offset+i,10)}k.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,e,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.min_height_px=12;this.max_height_px=400;this.height_px=80;this.hda_ldda=e;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};this.restore_prefs(c);(function(f){var i=false;var h=false;var g=$("<div class='track-resize'>");$(f.container_div).hover(function(){i=true;g.show()},function(){i=false;if(!h){g.hide()}});g.hide().bind("dragstart",function(j,k){h=true;k.original_height=$(f.content_div).height()}).bind("drag",function(k,l){var j=Math.min(Math.max(l.original_height+l.deltaY,f.min_height_px),f.max_height_px);$(f.content_div).css("height",j);f.height_px=j;f.draw(true)}).bind("dragend",function(j,k){f.tile_cache.clear();h=false;if(!i){g.hide()}}).appendTo(f.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;$.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:this.data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){var h=g.data;c.data_cache.set(e,h);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*o,a=DENSITY*o,x=o+"_"+r;var b=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);if(this.data_cache.get(x)===undefined){this.get_data(o,r);return}var v=this.data_cache.get(x);if(!v){return}b.css({position:"absolute",top:0,left:(s-this.view.low)*e});b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var n=b.get(0).getContext("2d"),j=false,k=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,t=this.total_frequency,d=this.height_px,l=this.mode;var w=Math.round(d+k/m*d);n.beginPath();n.moveTo(0,w);n.lineTo(a*e,w);n.fillStyle="#aaa";n.stroke();n.beginPath();n.fillStyle=this.prefs.color;var u,h,f;if(v.length>1){f=Math.ceil((v[1][0]-v[0][0])*e)}else{f=10}for(var p=0,q=v.length;p<q;p++){u=Math.round((v[p][0]-s)*e);h=v[p][1];if(h===null){if(j&&l==="Filled"){n.lineTo(u,d)}j=false;continue}if(h<k){h=k}else{if(h>g){h=g}}if(l==="Histogram"){h=Math.round(h/m*d);n.fillRect(u,w,f,-h)}else{if(l==="Intensity"){h=255-Math.floor((h-k)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(u,0,f,d)}else{h=Math.round(d-(h-k)/m*d);if(j){n.lineTo(u,h)}else{j=true;if(l==="Filled"){n.moveTo(u,d);n.lineTo(u,h)}else{n.moveTo(u,h)}}}}}if(l==="Filled"){if(j){n.lineTo(u,w);n.lineTo(0,w)}n.fill()}else{n.stroke()}c.append(b);return b},gen_options:function(m){var a=$("<div />").addClass("form-row");var e="track_"+m+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+m+"_minval",l=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),k=$("<input></input>").attr("id",h).val(d),j="track_"+m+"_maxval",g=$("<label></label>").attr("for",j).text("Max value:"),i=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",j).val(i);return a.append(l).append(k).append(g).append(f).append(b).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_color").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.color=b;this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+d+"_minval").text(this.prefs.min_value);$("#linetrack_"+d+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(f,c,h,a,e,g,d,b){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,f,c,c.viewport_container);TiledTrack.call(this,g,d,b);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=h;this.dataset_id=a;this.original_dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200;this.prefs={block_color:"#444",label_color:"black",show_counts:true};this.restore_prefs(e)};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(b.data_url,{chrom:b.view.chrom,low:a,high:d,hda_ldda:b.hda_ldda,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set_data(a,d,b.mode,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,b,p){var r=this.inc_slots[a];if(!r||(r.mode!==p)){r={};r.w_scale=a;r.mode=p;this.inc_slots[a]=r;this.s_e_by_tile[a]={}}var l=r.w_scale,x=[],y=[],j=0,n=this.view.max_low;for(var v=0,w=h.length;v<w;v++){var g=h[v],k=g[0];if(r[k]!==undefined){j=Math.max(j,r[k]);y.push(r[k])}else{x.push(v)}}var q=this.s_e_by_tile[a];var m=function(D,E){var C;for(var B=0,F;B<=MAX_FEATURE_DEPTH;B++){C=true;F=q[B];if(F!==undefined){for(var z=0,A=F.length;z<A;z++){var i=F[z];if(E>i[0]&&D<i[1]){C=false;break}}}if(C){break}}if(C){return B}else{return -1}};for(var v=0,w=x.length;v<w;v++){var g=h[x[v]],k=g[0],t=g[1],c=g[2],o=g[3],d=Math.floor((t-n)*l),f=Math.ceil((c-n)*l),u=CONTEXT.measureText(o).width,e;if(o!==undefined&&!b){if(d-u<0){f+=u;e="left"}else{d-=u;e="right"}}var s=m(d,f);if(s<0){}if(s>=0){slot=q[s];if(slot===undefined){slot=q[s]=[]}slot.push([d,f]);r[k]=s;j=Math.max(j,s)}else{}}return j},rect_or_text:function(r,l,u,b,q,j,g,f){r.textAlign="center";var d=0,s=0,p=Math.round(l/2);for(var m=0,t=j.length;m<t;m++){var k=j[m],e="MIDNSHP=X"[k[0]],n=k[1];if(e==="H"||e==="S"){d-=n}var h=q+d,x=Math.floor(Math.max(0,(h-u)*l)),i=Math.floor(Math.max(0,(h+n-u)*l));switch(e){case"H":break;case"S":case"M":case"=":var o=g.slice(s,s+n);if((this.mode==="Pack"||this.mode==="Auto")&&g!==undefined&&l>PX_PER_CHAR){r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+1,i-x,9);r.fillStyle=CONNECTOR_COLOR;for(var v=0,a=o.length;v<a;v++){if(h+v>=u&&h+v<=b){var w=Math.floor(Math.max(0,(h+v-u)*l));r.fillText(o[v],w+this.left_offset+p,f+9)}}}else{r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+(this.mode!="Dense"?4:5),i-x,(this.mode!="Dense"?3:1))}s+=n;break;case"N":r.fillStyle=CONNECTOR_COLOR;r.fillRect(x+this.left_offset,f+5,i-x,1);break;case"D":r.fillStyle="red";r.fillRect(x+this.left_offset,f+4,i-x,3);break;case"P":break;case"I":s+=n;break;case"X":s+=n;break}d+=n}},draw_tile:function(ad,n,r,ar){var L=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,K=ai-L;var G=this.data_cache.get_data(L,ai,this.mode);if(G===undefined||G==="pending"||(this.mode!=="Auto"&&G.dataset_type==="summary_tree")){this.data_queue[[L,ai]]=true;this.get_data(L,ai);return}var a=Math.ceil(K*ar),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,v=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,aq,B,at;var p=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(p)}p=$(p);if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(q==="Dense"){B=v;at=10}else{at=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ar<0.0001?1/this.view.zoom_res:ar);B=this.incremental_slots(w,G.data,ab,q)*at+v;aq=this.inc_slots[w]}}p.css({position:"absolute",top:0,left:(L-this.view.low)*ar-U});p.get(0).width=a+U;p.get(0).height=B;r.parent().css("height",Math.max(this.height_px,B)+"px");var H=p.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";this.container_div.find(".yaxislabel").remove();if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,b=Math.ceil(G.delta*ar);var o=$("<div />").addClass("yaxislabel");o.text(J);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,F=W.length;am<F;am++){var Y=Math.floor((W[am][0]-L)*ar);var X=W[am][1];if(!X){continue}var aj=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}r.append(p);return p}if(G.message){p.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,at);return p}for(var ao=0;ao<this.filters.length;ao++){if(this.filters[ao].applies_to(G.data[0])){p.addClass(FILTERABLE_CLASS);break}}var ap=G.data;var al=0;for(var am=0,F=ap.length;am<F;am++){var Q=ap[am],P=Q[0],an=Q[1],aa=Q[2],M=Q[3];if(this.mode!="Dense"&&aq[P]===undefined){continue}var Z=false;var S;for(var ao=0;ao<this.filters.length;ao++){S=this.filters[ao];S.update_attrs(Q);if(!S.keep(Q)){Z=true;break}}if(Z){continue}if(an<=ai&&aa>=L){var ac=Math.floor(Math.max(0,(an-L)*ar)),I=Math.ceil(Math.min(a,Math.max(0,(aa-L)*ar))),V=(q==="Dense"?1:(1+aq[P]))*at;var E,ag,N=null,au=null;if(G.dataset_type==="bai"){H.fillStyle=h;if(Q[5] instanceof Array){var C=Math.floor(Math.max(0,(Q[4][0]-L)*ar)),O=Math.ceil(Math.min(a,Math.max(0,(Q[4][1]-L)*ar))),A=Math.floor(Math.max(0,(Q[5][0]-L)*ar)),u=Math.ceil(Math.min(a,Math.max(0,(Q[5][1]-L)*ar)));if(Q[4][1]>=L&&Q[4][0]<=ai&&Q[4][2]){this.rect_or_text(H,ar,L,ai,Q[4][0],Q[4][2],Q[4][3],V)}if(Q[5][1]>=L&&Q[5][0]<=ai&&Q[5][2]){this.rect_or_text(H,ar,L,ai,Q[5][0],Q[5][2],Q[5][3],V)}if(A>O){H.fillStyle=CONNECTOR_COLOR;H.dashedLine(O+U,V+5,U+A,V+5)}}else{H.fillStyle=h;this.rect_or_text(H,ar,L,ai,an,Q[4],Q[5],V)}if(q!=="Dense"&&!ab&&an>L){H.fillStyle=this.prefs.label_color;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var D=Q[5],T=Q[6],ae=Q[7],g=Q[8];if(T&&ae){N=Math.floor(Math.max(0,(T-L)*ar));au=Math.ceil(Math.min(a,Math.max(0,(ae-L)*ar)))}if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}if(g){if(D){if(D=="+"){H.fillStyle=RIGHT_STRAND}else{if(D=="-"){H.fillStyle=LEFT_STRAND}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}for(var ak=0,e=g.length;ak<e;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-L)*ar)),R=Math.ceil(Math.min(a,Math.max((t[1]-L)*ar)));if(d>R){continue}E=5;ag=3;H.fillRect(d+U,V+ag,R-d,E);if(N!==undefined&&!(d>au||R<N)){E=9;ag=1;var ah=Math.max(d,N),z=Math.min(R,au);H.fillRect(ah+U,V+ag,z-ah,E)}}}else{E=9;ag=1;H.fillRect(ac+U,V+ag,I-ac,E);if(Q.strand){if(Q.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(Q.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var s=Q[4],m=Q[5],c=Q[6];E=9;ag=1;H.fillRect(ac+U,V,I-ac,E);if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}var l=s+" / "+m;if(an>L&&H.measureText(l).width<(I-ac)){H.fillStyle="white";H.textAlign="center";H.fillText(l,U+ac+(I-ac)/2,V+8);H.fillStyle=h}}}}}al++}}return p},gen_options:function(i){var a=$("<div />").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label />").attr("for",e).text("Block color:"),l=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label />").attr("for",j).text("Text color:"),h=$("<input />").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(k).append(l).append(g).append(h).append(d)},update_options:function(d){var b=$("#track_"+d+"_block_color").val(),c=$("#track_"+d+"_label_color").val(),a=$("#track_"+d+"_show_count").attr("checked");if(b!==this.prefs.block_color||c!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=c;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()==0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id},function(c){})}};a()}});
\ No newline at end of file
--- a/static/scripts/trackster.js Wed Feb 02 16:21:23 2011 -0500
+++ b/static/scripts/trackster.js Thu Feb 03 09:34:39 2011 -0500
@@ -1254,7 +1254,7 @@
cached.css({ left: left });
this.show_tile( cached, parent_element );
} else {
- this.delayed_draw(this, key, low, high, tile_index, resolution, parent_element, w_scale, draw_tile_ids);
+ this.delayed_draw(key, low, high, tile_index, resolution, parent_element, w_scale, draw_tile_ids);
}
tile_index += 1;
}
@@ -1289,11 +1289,16 @@
for (var i = 0; i < this.child_tracks.length; i++) {
this.child_tracks[i].draw(force);
}
- }, delayed_draw: function(track, key, low, high, tile_index, resolution, parent_element, w_scale, draw_tile_ids) {
+ }, delayed_draw: function(key, low, high, tile_index, resolution, parent_element, w_scale, draw_tile_ids) {
+ var track = this;
// Put a 50ms delay on drawing so that if the user scrolls fast, we don't load extra data
var id = setTimeout(function() {
if (low <= track.view.high && high >= track.view.low) {
- var tile_element = track.draw_tile(resolution, tile_index, parent_element, w_scale);
+ // Show/draw tile: check cache for tile; if tile not in cache, draw it.
+ var tile_element = track.tile_cache.get(key);
+ if (!tile_element) {
+ tile_element = track.draw_tile(resolution, tile_index, parent_element, w_scale);
+ }
if (tile_element) {
// Store initial canvas in case we need to use it for overview
if (!track.initial_canvas && !window.G_vmlCanvasManager) {
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.
1
0
commit/galaxy-central: rc: Fix to support older postgres versions (<8.3) which does not support 'alter sequence'.
by Bitbucket 02 Feb '11
by Bitbucket 02 Feb '11
02 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/b2b7be6597c6/
changeset: r4982:b2b7be6597c6
user: rc
date: 2011-02-02 22:21:23
summary: Fix to support older postgres versions (<8.3) which does not support 'alter sequence'.
affected #: 1 file (3 bytes)
--- a/lib/galaxy/model/migrate/versions/0068_rename_sequencer_to_external_services.py Wed Feb 02 15:07:14 2011 -0500
+++ b/lib/galaxy/model/migrate/versions/0068_rename_sequencer_to_external_services.py Wed Feb 02 16:21:23 2011 -0500
@@ -102,7 +102,7 @@
return
# if running postgres then rename the primary key sequence too
if migrate_engine.name == 'postgres':
- cmd = "ALTER SEQUENCE sequencer_id_seq RENAME TO external_service_id_seq"
+ cmd = "ALTER TABLE sequencer_id_seq RENAME TO external_service_id_seq"
db_session.execute( cmd )
# rename 'sequencer_type_id' column to 'external_service_type_id' in the table 'external_service'
# create the column as 'external_service_type_id'
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.
1
0
commit/galaxy-central: kanwei: Fix adding datasets to trackster from history pane
by Bitbucket 02 Feb '11
by Bitbucket 02 Feb '11
02 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/0bfb73dea188/
changeset: r4981:0bfb73dea188
user: kanwei
date: 2011-02-02 21:07:14
summary: Fix adding datasets to trackster from history pane
affected #: 1 file (4 bytes)
--- a/templates/tracks/browser.mako Wed Feb 02 15:06:10 2011 -0500
+++ b/templates/tracks/browser.mako Wed Feb 02 15:07:14 2011 -0500
@@ -224,7 +224,7 @@
%if add_dataset is not None:
$.ajax( {
url: "${h.url_for( action='add_track_async' )}",
- data: { id: "${add_dataset}" },
+ data: { hda_id: "${add_dataset}" },
dataType: "json",
success: add_async_success
});
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.
1
0
commit/galaxy-central: kanwei: Make tool.execute pass kwargs instead of new "set_output_history" parameter for backwards compat
by Bitbucket 02 Feb '11
by Bitbucket 02 Feb '11
02 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/5709198bdc0a/
changeset: r4980:5709198bdc0a
user: kanwei
date: 2011-02-02 21:06:10
summary: Make tool.execute pass kwargs instead of new "set_output_history" parameter for backwards compat
affected #: 1 file (44 bytes)
--- a/lib/galaxy/tools/__init__.py Tue Feb 01 15:24:45 2011 +0000
+++ b/lib/galaxy/tools/__init__.py Wed Feb 02 15:06:10 2011 -0500
@@ -1215,14 +1215,14 @@
raise Exception( "Unexpected parameter type" )
return args
- def execute( self, trans, incoming={}, set_output_hid=True, set_output_history=True, history=None ):
+ def execute( self, trans, incoming={}, set_output_hid=True, history=None, **kwargs ):
"""
Execute the tool using parameter values in `incoming`. This just
dispatches to the `ToolAction` instance specified by
`self.tool_action`. In general this will create a `Job` that
when run will build the tool's outputs, e.g. `DefaultToolAction`.
"""
- return self.tool_action.execute( self, trans, incoming=incoming, set_output_hid=set_output_hid, set_output_history=set_output_history, history=history )
+ return self.tool_action.execute( self, trans, incoming=incoming, set_output_hid=set_output_hid, history=history, **kwargs )
def params_to_strings( self, params, app ):
return params_to_strings( self.inputs, params, app )
@@ -1233,7 +1233,7 @@
def check_and_update_param_values( self, values, trans ):
"""
Check that all parameters have values, and fill in with default
- values where neccesary. This could be called after loading values
+ values where necessary. This could be called after loading values
from a database in case new parameters have been added.
"""
messages = {}
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.
1
0
3 new changesets in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/c4c2e7dc5c02/
changeset: r4977:c4c2e7dc5c02
user: peterjc
date: 2011-01-31 18:13:13
summary: Access path field from BLAST loc file, and store ID in database instead
affected #: 5 files (1.1 KB)
--- a/tools/ncbi_blast_plus/ncbi_blastn_wrapper.xml Tue Feb 01 20:07:17 2011 -0500
+++ b/tools/ncbi_blast_plus/ncbi_blastn_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
@@ -1,4 +1,4 @@
-<tool id="ncbi_blastn_wrapper" name="NCBI BLAST+ blastn" version="0.0.7">
+<tool id="ncbi_blastn_wrapper" name="NCBI BLAST+ blastn" version="0.0.8"><description>Search nucleotide database with nucleotide query sequence(s)</description><command>
## The command is a Cheetah template which allows some Python based syntax.
@@ -6,7 +6,7 @@
blastn
-query "$query"
#if $db_opts.db_opts_selector == "db":
- -db "$db_opts.database"
+ -db "${db_opts.database.fields.path}"
#else:
-subject "$db_opts.subject"
#end if
@@ -40,13 +40,10 @@
</param><when value="db"><param name="database" type="select" label="Nucleotide BLAST database">
- <!-- The BLAST loc file has three columns:
- column 0 is an identifier (not used here, see legacy megablast wrapper),
- column 1 is the caption (show this to the user),
- column 2 is the database path (given to BLAST+) --><options from_file="blastdb.loc">
+ <column name="value" index="0"/><column name="name" index="1"/>
- <column name="value" index="2"/>
+ <column name="path" index="2"/></options></param><param name="subject" type="hidden" value="" />
--- a/tools/ncbi_blast_plus/ncbi_blastp_wrapper.xml Tue Feb 01 20:07:17 2011 -0500
+++ b/tools/ncbi_blast_plus/ncbi_blastp_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
@@ -1,4 +1,4 @@
-<tool id="ncbi_blastp_wrapper" name="NCBI BLAST+ blastp" version="0.0.7">
+<tool id="ncbi_blastp_wrapper" name="NCBI BLAST+ blastp" version="0.0.8"><description>Search protein database with protein query sequence(s)</description><command>
## The command is a Cheetah template which allows some Python based syntax.
@@ -6,7 +6,7 @@
blastp
-query "$query"
#if $db_opts.db_opts_selector == "db":
- -db "$db_opts.database"
+ -db "${db_opts.database.fields.path}"
#else:
-subject "$db_opts.subject"
#end if
@@ -41,13 +41,10 @@
</param><when value="db"><param name="database" type="select" label="Protein BLAST database">
- <!-- The BLAST loc file has three columns:
- column 0 is an identifier (not used),
- column 1 is the caption (show this to the user),
- column 2 is the database path (given to BLAST+) --><options from_file="blastdb_p.loc">
+ <column name="value" index="0"/><column name="name" index="1"/>
- <column name="value" index="2"/>
+ <column name="path" index="2"/></options></param><param name="subject" type="hidden" value="" />
--- a/tools/ncbi_blast_plus/ncbi_blastx_wrapper.xml Tue Feb 01 20:07:17 2011 -0500
+++ b/tools/ncbi_blast_plus/ncbi_blastx_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
@@ -1,4 +1,4 @@
-<tool id="ncbi_blastx_wrapper" name="NCBI BLAST+ blastx" version="0.0.7">
+<tool id="ncbi_blastx_wrapper" name="NCBI BLAST+ blastx" version="0.0.8"><description>Search protein database with translated nucleotide query sequence(s)</description><command>
## The command is a Cheetah template which allows some Python based syntax.
@@ -6,7 +6,7 @@
blastx
-query "$query"
#if $db_opts.db_opts_selector == "db":
- -db "$db_opts.database"
+ -db "${db_opts.database.fields.path}"
#else:
-subject "$db_opts.subject"
#end if
@@ -40,13 +40,10 @@
</param><when value="db"><param name="database" type="select" label="Protein BLAST database">
- <!-- The BLAST loc file has three columns:
- column 0 is an identifier (not used),
- column 1 is the caption (show this to the user),
- column 2 is the database path (given to BLAST+) --><options from_file="blastdb_p.loc">
+ <column name="value" index="0"/><column name="name" index="1"/>
- <column name="value" index="2"/>
+ <column name="path" index="2"/></options></param><param name="subject" type="hidden" value="" />
--- a/tools/ncbi_blast_plus/ncbi_tblastn_wrapper.xml Tue Feb 01 20:07:17 2011 -0500
+++ b/tools/ncbi_blast_plus/ncbi_tblastn_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
@@ -1,4 +1,4 @@
-<tool id="ncbi_tblastn_wrapper" name="NCBI BLAST+ tblastn" version="0.0.7">
+<tool id="ncbi_tblastn_wrapper" name="NCBI BLAST+ tblastn" version="0.0.8"><description>Search translated nucleotide database with protein query sequence(s)</description><command>
## The command is a Cheetah template which allows some Python based syntax.
@@ -6,7 +6,7 @@
tblastn
-query "$query"
#if $db_opts.db_opts_selector == "db":
- -db "$db_opts.database"
+ -db "${db_opts.database.fields.path}"
#else:
-subject "$db_opts.subject"
#end if
@@ -40,13 +40,10 @@
</param><when value="db"><param name="database" type="select" label="Nucleotide BLAST database">
- <!-- The BLAST loc file has three columns:
- column 0 is an identifier (not used here, see legacy megablast wrapper),
- column 1 is the caption (show this to the user),
- column 2 is the database path (given to BLAST+) --><options from_file="blastdb.loc">
+ <column name="value" index="0"/><column name="name" index="1"/>
- <column name="value" index="2"/>
+ <column name="path" index="2"/></options></param><param name="subject" type="hidden" value="" />
--- a/tools/ncbi_blast_plus/ncbi_tblastx_wrapper.xml Tue Feb 01 20:07:17 2011 -0500
+++ b/tools/ncbi_blast_plus/ncbi_tblastx_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
@@ -1,4 +1,4 @@
-<tool id="ncbi_tblastx_wrapper" name="NCBI BLAST+ tblastx" version="0.0.7">
+<tool id="ncbi_tblastx_wrapper" name="NCBI BLAST+ tblastx" version="0.0.8"><description>Search translated nucleotide database with translated nucleotide query sequence(s)</description><command>
## The command is a Cheetah template which allows some Python based syntax.
@@ -6,7 +6,7 @@
tblastx
-query "$query"
#if $db_opts.db_opts_selector == "db":
- -db "$db_opts.database"
+ -db "${db_opts.database.fields.path}"
#else:
-subject "$db_opts.subject"
#end if
@@ -39,13 +39,10 @@
</param><when value="db"><param name="database" type="select" label="Nucleotide BLAST database">
- <!-- The BLAST loc file has three columns:
- column 0 is an identifier (not used here, see legacy megablast wrapper),
- column 1 is the caption (show this to the user),
- column 2 is the database path (given to BLAST+) --><options from_file="blastdb.loc">
+ <column name="value" index="0"/><column name="name" index="1"/>
- <column name="value" index="2"/>
+ <column name="path" index="2"/></options></param><param name="subject" type="hidden" value="" />
http://bitbucket.org/galaxy/galaxy-central/changeset/17c2a47f67e3/
changeset: r4978:17c2a47f67e3
user: peterjc
date: 2011-02-01 11:52:50
summary: Use wrapper script to hide BLAST warnings on stderr (see issue 325)
affected #: 6 files (1.7 KB)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/ncbi_blast_plus/hide_stderr.py Tue Feb 01 10:52:50 2011 +0000
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+"""A simple script to redirect stderr to stdout when the return code is zero.
+
+See https://bitbucket.org/galaxy/galaxy-central/issue/325/
+
+Currently Galaxy ignores the return code from command line tools (even if it
+is non-zero which by convention indicates an error) and treats any output on
+stderr as an error (even though by convention stderr is used for errors or
+warnings).
+
+This script runs the given command line, capturing all stdout and stderr in
+memory, and gets the return code. For a zero return code, any stderr (which
+should be warnings only) is added to the stdout. That way Galaxy believes
+everything is fine. For a non-zero return code, we output stdout as is, and
+any stderr, plus the return code to ensure there is some output on stderr.
+That way Galaxy treats this as an error.
+
+Once issue 325 is fixed, this script will not be needed.
+"""
+import sys
+import subprocess
+
+#Sadly passing the list directly to subprocess didn't seem to work.
+words = []
+for w in sys.argv[1:]:
+ if " " in w:
+ words.append('"%s"' % w)
+ else:
+ words.append(w)
+cmd = " ".join(words)
+child = subprocess.Popen(cmd, shell=True,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+#Use .communicate as can get deadlocks with .wait(),
+stdout, stderr = child.communicate()
+return_code = child.returncode
+
+if return_code:
+ sys.stdout.write(stdout)
+ sys.stderr.write(stderr)
+ sys.stderr.write("Return error code %i from command:\n" % return_code)
+ sys.stderr.write("%s\n" % cmd)
+else:
+ sys.stdout.write(stdout)
+ sys.stdout.write(stderr)
--- a/tools/ncbi_blast_plus/ncbi_blastn_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
+++ b/tools/ncbi_blast_plus/ncbi_blastn_wrapper.xml Tue Feb 01 10:52:50 2011 +0000
@@ -1,6 +1,6 @@
<tool id="ncbi_blastn_wrapper" name="NCBI BLAST+ blastn" version="0.0.8"><description>Search nucleotide database with nucleotide query sequence(s)</description>
- <command>
+ <command interpreter="python">hide_stderr.py
## The command is a Cheetah template which allows some Python based syntax.
## Lines starting hash hash are comments. Galaxy will turn newlines into spaces
blastn
--- a/tools/ncbi_blast_plus/ncbi_blastp_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
+++ b/tools/ncbi_blast_plus/ncbi_blastp_wrapper.xml Tue Feb 01 10:52:50 2011 +0000
@@ -1,6 +1,6 @@
<tool id="ncbi_blastp_wrapper" name="NCBI BLAST+ blastp" version="0.0.8"><description>Search protein database with protein query sequence(s)</description>
- <command>
+ <command interpreter="python">hide_stderr.py
## The command is a Cheetah template which allows some Python based syntax.
## Lines starting hash hash are comments. Galaxy will turn newlines into spaces
blastp
--- a/tools/ncbi_blast_plus/ncbi_blastx_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
+++ b/tools/ncbi_blast_plus/ncbi_blastx_wrapper.xml Tue Feb 01 10:52:50 2011 +0000
@@ -1,6 +1,6 @@
<tool id="ncbi_blastx_wrapper" name="NCBI BLAST+ blastx" version="0.0.8"><description>Search protein database with translated nucleotide query sequence(s)</description>
- <command>
+ <command interpreter="python">hide_stderr.py
## The command is a Cheetah template which allows some Python based syntax.
## Lines starting hash hash are comments. Galaxy will turn newlines into spaces
blastx
--- a/tools/ncbi_blast_plus/ncbi_tblastn_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
+++ b/tools/ncbi_blast_plus/ncbi_tblastn_wrapper.xml Tue Feb 01 10:52:50 2011 +0000
@@ -1,7 +1,7 @@
<tool id="ncbi_tblastn_wrapper" name="NCBI BLAST+ tblastn" version="0.0.8"><description>Search translated nucleotide database with protein query sequence(s)</description>
- <command>
-## The command is a Cheetah template which allows some Python based syntax.
+ <command interpreter="python">hide_stderr.py
+# The command is a Cheetah template which allows some Python based syntax.
## Lines starting hash hash are comments. Galaxy will turn newlines into spaces
tblastn
-query "$query"
--- a/tools/ncbi_blast_plus/ncbi_tblastx_wrapper.xml Mon Jan 31 17:13:13 2011 +0000
+++ b/tools/ncbi_blast_plus/ncbi_tblastx_wrapper.xml Tue Feb 01 10:52:50 2011 +0000
@@ -1,6 +1,6 @@
<tool id="ncbi_tblastx_wrapper" name="NCBI BLAST+ tblastx" version="0.0.8"><description>Search translated nucleotide database with translated nucleotide query sequence(s)</description>
- <command>
+ <command interpreter="python">hide_stderr.py
## The command is a Cheetah template which allows some Python based syntax.
## Lines starting hash hash are comments. Galaxy will turn newlines into spaces
tblastx
http://bitbucket.org/galaxy/galaxy-central/changeset/ca4a622b52ce/
changeset: r4979:ca4a622b52ce
user: peterjc
date: 2011-02-01 16:24:45
summary: Avoid using shell=True when we call subprocess to ensure if the Python script is killed, so too is the BLAST process
affected #: 1 file (34 bytes)
--- a/tools/ncbi_blast_plus/hide_stderr.py Tue Feb 01 10:52:50 2011 +0000
+++ b/tools/ncbi_blast_plus/hide_stderr.py Tue Feb 01 15:24:45 2011 +0000
@@ -20,16 +20,14 @@
import sys
import subprocess
-#Sadly passing the list directly to subprocess didn't seem to work.
-words = []
-for w in sys.argv[1:]:
- if " " in w:
- words.append('"%s"' % w)
- else:
- words.append(w)
-cmd = " ".join(words)
-child = subprocess.Popen(cmd, shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+#Avoid using shell=True when we call subprocess to ensure if the Python
+#script is killed, so too is the BLAST process.
+try:
+ child = subprocess.Popen(sys.argv[1:],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+except Exception, err:
+ sys.stderr.write("Error invoking command:\n%s\n\n%s\n" % (cmd, err))
+ sys.exit(1)
#Use .communicate as can get deadlocks with .wait(),
stdout, stderr = child.communicate()
return_code = child.returncode
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.
1
0
commit/galaxy-central: kanwei: Backend changes to implicitly converted datasets:
by Bitbucket 01 Feb '11
by Bitbucket 01 Feb '11
01 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/0c1407634eb8/
changeset: r4976:0c1407634eb8
user: kanwei
date: 2011-02-02 02:07:17
summary: Backend changes to implicitly converted datasets:
- Library dataset LDDAs can now be implicitly converted to another format. For this to happen, an HDA is created by copying the LDDA info, and the HDA is then used as the tool input parameter. The implicitly converted dataset table will map the LDDA to the resulting converted output HDA.
- Added set_output_history optional param to tool.execute to specify whether output dataset is added to the current (or specified) history. Defaults to true but is set to false for implicitly converted datasets so that it does not show up as a hidden history item, which show up in features like "extract workflow from history".
Initial pass at UI for adding data library datasets to trackster using the "Select Library, then Select Datasets" paradigm currently also used for adding history datasets. Currently uses browse_library.mako code but this will need to be enhanced for trackster's purposes.
affected #: 12 files (4.1 KB)
--- a/lib/galaxy/datatypes/data.py Tue Feb 01 19:56:05 2011 -0500
+++ b/lib/galaxy/datatypes/data.py Tue Feb 01 20:07:17 2011 -0500
@@ -266,7 +266,7 @@
def find_conversion_destination( self, dataset, accepted_formats, datatypes_registry, **kwd ):
"""Returns ( target_ext, existing converted dataset )"""
return datatypes_registry.find_conversion_destination_for_dataset_by_extensions( dataset, accepted_formats, **kwd )
- def convert_dataset(self, trans, original_dataset, target_type, return_output = False, visible = True, deps=None):
+ def convert_dataset(self, trans, original_dataset, target_type, return_output=False, visible=True, deps=None, set_output_history=True):
"""This function adds a job to the queue to convert a dataset to another type. Returns a message about success/failure."""
converter = trans.app.datatypes_registry.get_converter_by_target_type( original_dataset.ext, target_type )
@@ -277,14 +277,14 @@
#determine input parameter name and add to params
input_name = 'input1'
for key, value in converter.inputs.items():
- if (deps) and (value.name in deps):
+ if deps and value.name in deps:
params[value.name] = deps[value.name]
elif value.type == 'data':
input_name = key
params[input_name] = original_dataset
#Run converter, job is dispatched through Queue
- converted_dataset = converter.execute( trans, incoming = params, set_output_hid = visible )[1]
+ converted_dataset = converter.execute( trans, incoming=params, set_output_hid=visible, set_output_history=set_output_history)[1]
if len(params) > 0:
trans.log_event( "Converter params: %s" % (str(params)), tool_id=converter.id )
if not visible:
--- a/lib/galaxy/model/__init__.py Tue Feb 01 19:56:05 2011 -0500
+++ b/lib/galaxy/model/__init__.py Tue Feb 01 20:07:17 2011 -0500
@@ -742,8 +742,7 @@
pass # No deps
assoc = ImplicitlyConvertedDatasetAssociation( parent=self, file_type=target_ext, metadata_safe=False )
- new_dataset = self.datatype.convert_dataset( trans, self, target_ext, return_output=True, visible=False, deps=deps ).values()[0]
- new_dataset.hid = self.hid
+ new_dataset = self.datatype.convert_dataset( trans, self, target_ext, return_output=True, visible=False, deps=deps, set_output_history=False ).values()[0]
new_dataset.name = self.name
session = trans.sa_session
session.add( new_dataset )
@@ -1326,7 +1325,12 @@
def __init__( self, id = None, parent = None, dataset = None, file_type = None, deleted = False, purged = False, metadata_safe = True ):
self.id = id
self.dataset = dataset
- self.parent = parent
+ if isinstance(parent, HistoryDatasetAssociation):
+ self.parent_hda = parent
+ elif isinstance(parent, LibraryDatasetDatasetAssociation):
+ self.parent_ldda = parent
+ else:
+ raise AttributeError
self.type = file_type
self.deleted = deleted
self.purged = purged
--- a/lib/galaxy/model/mapping.py Tue Feb 01 19:56:05 2011 -0500
+++ b/lib/galaxy/model/mapping.py Tue Feb 01 20:07:17 2011 -0500
@@ -145,6 +145,7 @@
Column( "update_time", DateTime, default=now, onupdate=now ),
Column( "hda_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True, nullable=True ),
Column( "hda_parent_id", Integer, ForeignKey( "history_dataset_association.id" ), index=True ),
+ Column( "ldda_parent_id", Integer, ForeignKey( "library_dataset_dataset_association.id" ), index=True ),
Column( "deleted", Boolean, index=True, default=False ),
Column( "metadata_safe", Boolean, index=True, default=True ),
Column( "type", TrimmedString( 255 ) ) )
@@ -1135,13 +1136,17 @@
user = relation( User ) ) )
assign_mapper( context, ImplicitlyConvertedDatasetAssociation, ImplicitlyConvertedDatasetAssociation.table,
- properties=dict( parent=relation(
- HistoryDatasetAssociation,
- primaryjoin=( ImplicitlyConvertedDatasetAssociation.table.c.hda_parent_id == HistoryDatasetAssociation.table.c.id ) ),
+ properties=dict( parent_hda=relation(
+ HistoryDatasetAssociation,
+ primaryjoin=( ImplicitlyConvertedDatasetAssociation.table.c.hda_parent_id == HistoryDatasetAssociation.table.c.id ) ),
+
+ parent_ldda=relation(
+ LibraryDatasetDatasetAssociation,
+ primaryjoin=( ImplicitlyConvertedDatasetAssociation.table.c.ldda_parent_id == LibraryDatasetDatasetAssociation.table.c.id ) ),
dataset=relation(
- HistoryDatasetAssociation,
- primaryjoin=( ImplicitlyConvertedDatasetAssociation.table.c.hda_id == HistoryDatasetAssociation.table.c.id ) ) ) )
+ HistoryDatasetAssociation,
+ primaryjoin=( ImplicitlyConvertedDatasetAssociation.table.c.hda_id == HistoryDatasetAssociation.table.c.id ) ) ) )
assign_mapper( context, History, History.table,
properties=dict( galaxy_sessions=relation( GalaxySessionToHistoryAssociation ),
@@ -1322,6 +1327,9 @@
HistoryDatasetAssociation,
primaryjoin=( HistoryDatasetAssociation.table.c.copied_from_library_dataset_dataset_association_id == LibraryDatasetDatasetAssociation.table.c.id ),
backref=backref( "copied_from_library_dataset_dataset_association", primaryjoin=( HistoryDatasetAssociation.table.c.copied_from_library_dataset_dataset_association_id == LibraryDatasetDatasetAssociation.table.c.id ), remote_side=[LibraryDatasetDatasetAssociation.table.c.id], uselist=False ) ),
+ implicitly_converted_datasets=relation(
+ ImplicitlyConvertedDatasetAssociation,
+ primaryjoin=( ImplicitlyConvertedDatasetAssociation.table.c.ldda_parent_id == LibraryDatasetDatasetAssociation.table.c.id ) ),
children=relation(
LibraryDatasetDatasetAssociation,
primaryjoin=( LibraryDatasetDatasetAssociation.table.c.parent_id == LibraryDatasetDatasetAssociation.table.c.id ),
--- a/lib/galaxy/tools/__init__.py Tue Feb 01 19:56:05 2011 -0500
+++ b/lib/galaxy/tools/__init__.py Tue Feb 01 20:07:17 2011 -0500
@@ -1215,14 +1215,14 @@
raise Exception( "Unexpected parameter type" )
return args
- def execute( self, trans, incoming={}, set_output_hid=True, history=None ):
+ def execute( self, trans, incoming={}, set_output_hid=True, set_output_history=True, history=None ):
"""
Execute the tool using parameter values in `incoming`. This just
dispatches to the `ToolAction` instance specified by
`self.tool_action`. In general this will create a `Job` that
when run will build the tool's outputs, e.g. `DefaultToolAction`.
"""
- return self.tool_action.execute( self, trans, incoming=incoming, set_output_hid=set_output_hid, history=history )
+ return self.tool_action.execute( self, trans, incoming=incoming, set_output_hid=set_output_hid, set_output_history=set_output_history, history=history )
def params_to_strings( self, params, app ):
return params_to_strings( self.inputs, params, app )
--- a/lib/galaxy/tools/actions/__init__.py Tue Feb 01 19:56:05 2011 -0500
+++ b/lib/galaxy/tools/actions/__init__.py Tue Feb 01 20:07:17 2011 -0500
@@ -1,3 +1,4 @@
+from galaxy.model import LibraryDatasetDatasetAssociation
from galaxy.util.bunch import Bunch
from galaxy.util.odict import odict
from galaxy.tools.parameters import *
@@ -100,7 +101,7 @@
tool.visit_inputs( param_values, visitor )
return input_datasets
- def execute(self, tool, trans, incoming={}, return_job=False, set_output_hid=True, history=None ):
+ def execute(self, tool, trans, incoming={}, return_job=False, set_output_hid=True, set_output_history=True, history=None ):
"""
Executes a tool, creating job and tool outputs, associating them, and
submitting the job to the job queue. If history is not specified, use
@@ -166,11 +167,20 @@
input_ext = 'data'
input_dbkey = incoming.get( "dbkey", "?" )
for name, data in inp_data.items():
- if data:
- input_names.append( 'data %s' % data.hid )
- input_ext = data.ext
- else:
+ if not data:
data = NoneDataset( datatypes_registry = trans.app.datatypes_registry )
+ continue
+
+ # Convert LDDA to an HDA.
+ if isinstance(data, LibraryDatasetDatasetAssociation):
+ data = data.to_history_dataset_association( None )
+ inp_data[name] = data
+
+ else: # HDA
+ if data.hid:
+ input_names.append( 'data %s' % data.hid )
+ input_ext = data.ext
+
if data.dbkey not in [None, '?']:
input_dbkey = data.dbkey
@@ -306,11 +316,12 @@
output.actions.apply_action( data, output_action_params )
# Store all changes to database
trans.sa_session.flush()
- # Add all the top-level (non-child) datasets to the history
+ # Add all the top-level (non-child) datasets to the history unless otherwise specified
for name in out_data.keys():
if name not in child_dataset_names and name not in incoming: #don't add children; or already existing datasets, i.e. async created
data = out_data[ name ]
- history.add_dataset( data, set_hid = set_output_hid )
+ if set_output_history:
+ history.add_dataset( data, set_hid = set_output_hid )
trans.sa_session.add( data )
trans.sa_session.flush()
# Add all the children to their parents
--- a/lib/galaxy/web/base/controller.py Tue Feb 01 19:56:05 2011 -0500
+++ b/lib/galaxy/web/base/controller.py Tue Feb 01 20:07:17 2011 -0500
@@ -164,14 +164,19 @@
# Set tracks.
if 'tracks' in latest_revision.config:
- hda_query = trans.sa_session.query( trans.model.HistoryDatasetAssociation )
for t in visualization.latest_revision.config['tracks']:
dataset_id = t['dataset_id']
+ hda_ldda = t.get('hda_ldda', 'hda')
+ if hda_ldda == "hda":
+ dataset = self.get_dataset( trans, dataset_id, check_ownership=False, check_accessible=True )
+ else:
+ dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id(dataset_id) )
+
try:
prefs = t['prefs']
except KeyError:
prefs = {}
- dataset = hda_query.get( dataset_id )
+
track_type, _ = dataset.datatype.get_track_type()
track_data_provider_class = get_data_provider( original_dataset=dataset )
track_data_provider = track_data_provider_class( original_dataset=dataset )
@@ -179,6 +184,7 @@
tracks.append( {
"track_type": track_type,
"name": t['name'],
+ "hda_ldda": t.get("hda_ldda", "hda"),
"dataset_id": trans.security.encode_id( dataset.id ),
"prefs": prefs,
"filters": track_data_provider.get_filters(),
--- a/lib/galaxy/web/controllers/tracks.py Tue Feb 01 19:56:05 2011 -0500
+++ b/lib/galaxy/web/controllers/tracks.py Tue Feb 01 20:07:17 2011 -0500
@@ -9,6 +9,7 @@
from galaxy import model
from galaxy.util.json import to_json_string, from_json_string
from galaxy.web.base.controller import *
+from galaxy.web.controllers.library import LibraryListGrid
from galaxy.web.framework import simplejson
from galaxy.web.framework.helpers import time_ago, grids
from galaxy.util.bunch import Bunch
@@ -36,8 +37,8 @@
# Provide link to list all datasets in history that have a given dbkey.
# Right now, only dbkey needs to be passed through, but pass through
# all for now since it's cleaner.
- d = dict( action='list_history_datasets', show_item_checkboxes=True )
- d[ "f-history" ] = history.id
+ d = dict( action=grid.datasets_action, show_item_checkboxes=True )
+ d[ grid.datasets_param ] = trans.security.encode_id( history.id )
for filter, value in grid.cur_filter_dict.iteritems():
d[ "f-" + filter ] = value
return d
@@ -56,6 +57,8 @@
model_class = model.History
template='/tracks/history_select_grid.mako'
default_sort_key = "-update_time"
+ datasets_action = 'list_history_datasets'
+ datasets_param = "f-history"
columns = [
NameColumn( "History Name", key="name", filterable="standard" ),
grids.GridColumn( "Last Updated", key="update_time", format=time_ago ),
@@ -67,6 +70,24 @@
def apply_query_filter( self, trans, query, **kwargs ):
return query.filter_by( user=trans.user, purged=False, deleted=False, importing=False )
+class LibrarySelectionGrid( LibraryListGrid ):
+ """
+ Grid enables user to select a Library, which is then used to display
+ datasets from the history.
+ """
+ title = "Add Track: Select Library"
+ template='/tracks/history_select_grid.mako'
+ model_class = model.Library
+ datasets_action = 'list_library_datasets'
+ datasets_param = "f-library"
+ columns = [
+ NameColumn( "Library Name", key="name", filterable="standard" ),
+ grids.GridColumn( "Description", key="description" )
+ ]
+ num_rows_per_page = 10
+ use_async = True
+ use_paging = True
+
class DbKeyColumn( grids.GridColumn ):
""" Column for filtering by and displaying dataset dbkey. """
def filter( self, trans, user, query, dbkey ):
@@ -78,7 +99,7 @@
class HistoryColumn( grids.GridColumn ):
""" Column for filtering by history id. """
def filter( self, trans, user, query, history_id ):
- return query.filter( model.History.id==history_id )
+ return query.filter( model.History.id==trans.security.decode_id(history_id) )
class HistoryDatasetsSelectionGrid( grids.Grid ):
# Grid definition.
@@ -95,7 +116,7 @@
grids.TextColumn( "Name", key="name", model_class=model.HistoryDatasetAssociation ),
grids.TextColumn( "Filetype", key="extension", model_class=model.HistoryDatasetAssociation ),
HistoryColumn( "History", key="history", visible=False ),
- DbKeyColumn( "Dbkey", key="dbkey", model_class=model.HistoryDatasetAssociation, visible=False )
+ DbKeyColumn( "Dbkey", key="dbkey", model_class=model.HistoryDatasetAssociation, visible=True, sortable=False )
]
columns.append(
grids.MulticolFilterColumn( "Search", cols_to_filter=[ columns[0], columns[1] ],
@@ -103,7 +124,7 @@
)
def build_initial_query( self, trans, **kwargs ):
- return trans.sa_session.query( self.model_class ).join( model.History.table).join( model.Dataset.table )
+ return trans.sa_session.query( self.model_class ).join( model.History.table ).join( model.Dataset.table )
def apply_query_filter( self, trans, query, **kwargs ):
if self.available_tracks is None:
self.available_tracks = trans.app.datatypes_registry.get_available_tracks()
@@ -111,42 +132,6 @@
.filter( model.Dataset.state == model.Dataset.states.OK ) \
.filter( model.HistoryDatasetAssociation.deleted == False ) \
.filter( model.HistoryDatasetAssociation.visible == True )
-
-# TODO: not currently used. Do we want to keep this?
-class DatasetSelectionGrid( grids.Grid ):
- """ Lists all user datasets that can be added to a visualization. """
-
- # Grid definition.
- available_tracks = None
- title = "Add Tracks"
- template = "/tracks/add_tracks.mako"
- async_template = "/page/select_items_grid_async.mako"
- model_class = model.HistoryDatasetAssociation
- default_filter = { "deleted" : "False" , "shared" : "All" }
- default_sort_key = "name"
- use_async = True
- use_paging = False
- columns = [
- grids.TextColumn( "Name", key="name", model_class=model.HistoryDatasetAssociation ),
- grids.TextColumn( "Filetype", key="extension", model_class=model.HistoryDatasetAssociation ),
- DbKeyColumn( "Dbkey", key="dbkey", model_class=model.HistoryDatasetAssociation, visible=False )
- ]
- columns.append(
- grids.MulticolFilterColumn( "Search", cols_to_filter=[ columns[0], columns[1] ],
- key="free-text-search", visible=False, filterable="standard" )
- )
-
- def build_initial_query( self, trans, **kwargs ):
- return trans.sa_session.query( self.model_class ).join( model.History.table).join( model.Dataset.table )
- def apply_query_filter( self, trans, query, **kwargs ):
- if self.available_tracks is None:
- self.available_tracks = trans.app.datatypes_registry.get_available_tracks()
- return query.filter( model.History.user == trans.user ) \
- .filter( model.HistoryDatasetAssociation.extension.in_(self.available_tracks) ) \
- .filter( model.Dataset.state == model.Dataset.states.OK ) \
- .filter( model.History.deleted == False ) \
- .filter( model.HistoryDatasetAssociation.deleted == False ) \
- .filter( model.HistoryDatasetAssociation.visible == True )
class TracksterSelectionGrid( grids.Grid ):
# Grid definition.
@@ -178,9 +163,9 @@
datasets in the current history, and display of the resulting browser.
"""
+ libraries_grid = LibrarySelectionGrid()
histories_grid = HistorySelectionGrid()
history_datasets_grid = HistoryDatasetsSelectionGrid()
- data_grid = DatasetSelectionGrid()
tracks_grid = TracksterSelectionGrid()
#
@@ -216,8 +201,13 @@
@web.json
@web.require_login()
- def add_track_async(self, trans, id):
- dataset = self.get_dataset( trans, id, check_ownership=False, check_accessible=True )
+ def add_track_async(self, trans, hda_id=None, ldda_id=None):
+ if hda_id:
+ hda_ldda = "hda"
+ dataset = self.get_dataset( trans, hda_id, check_ownership=False, check_accessible=True )
+ elif ldda_id:
+ hda_ldda = "ldda"
+ dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) )
track_type, _ = dataset.datatype.get_track_type()
track_data_provider_class = get_data_provider( original_dataset=dataset )
track_data_provider = track_data_provider_class( original_dataset=dataset )
@@ -225,6 +215,7 @@
track = {
"track_type": track_type,
"name": dataset.name,
+ "hda_ldda": hda_ldda,
"dataset_id": trans.security.encode_id( dataset.id ),
"prefs": {},
"filters": track_data_provider.get_filters(),
@@ -371,7 +362,7 @@
return msg
@web.json
- def converted_datasets_state( self, trans, dataset_id, chrom=None, low=None, high=None ):
+ def converted_datasets_state( self, trans, hda_ldda, dataset_id, chrom=None, low=None, high=None ):
"""
Returns state of dataset's converted datasets. If a genome window is
specified, method checks whether dataset has data in the window.
@@ -379,7 +370,10 @@
# TODO: this code is copied from data() -- should refactor.
# Dataset check.
- dataset = self.get_dataset( trans, dataset_id )
+ if hda_ldda == "hda":
+ dataset = self.get_dataset( trans, dataset_id )
+ else:
+ dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( dataset_id ) )
msg = self._check_dataset_state( trans, dataset )
if msg:
return msg
@@ -402,7 +396,7 @@
return messages.DATA
@web.json
- def data( self, trans, dataset_id, chrom, low, high, **kwargs ):
+ def data( self, trans, hda_ldda, dataset_id, chrom, low, high, **kwargs ):
"""
Called by the browser to request a block of data
"""
@@ -412,7 +406,10 @@
return messages.NO_DATA
# Dataset check.
- dataset = self.get_dataset( trans, dataset_id )
+ if hda_ldda == "hda":
+ dataset = self.get_dataset( trans, dataset_id )
+ else:
+ dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( dataset_id ) )
msg = self._check_dataset_state( trans, dataset )
if msg:
return msg
@@ -491,11 +488,12 @@
# Tracks from payload
tracks = []
for track in decoded_payload['tracks']:
- tracks.append( { "dataset_id": str( trans.security.decode_id( track['dataset_id']) ),
+ tracks.append( { "dataset_id": track['dataset_id'],
+ "hda_ldda": track.get('hda_ldda', "hda"),
"name": track['name'],
"track_type": track['track_type'],
"prefs": track['prefs'],
- "is_child": track['is_child']
+ "is_child": track.get('is_child', False)
} )
# Viewport from payload
if 'viewport' in decoded_payload:
@@ -511,6 +509,32 @@
return trans.security.encode_id(vis.id)
@web.expose
+ @web.require_login( "see all available libraries" )
+ def list_libraries( self, trans, **kwargs ):
+ """List all libraries that can be used for selecting datasets."""
+
+ # Render the list view
+ return self.libraries_grid( trans, **kwargs )
+
+ @web.expose
+ @web.require_login( "see a library's datasets that can added to this visualization" )
+ def list_library_datasets( self, trans, **kwargs ):
+ """List a library's datasets that can be added to a visualization."""
+
+ library = trans.sa_session.query( trans.app.model.Library ).get( trans.security.decode_id( kwargs.get('f-library') ) )
+ return trans.fill_template( '/library/common/browse_library.mako',
+ cntrller="library",
+ use_panels=False,
+ library=library,
+ created_ldda_ids='',
+ hidden_folder_ids='',
+ show_deleted=False,
+ comptypes=[],
+ current_user_roles=trans.get_current_user_roles(),
+ message='',
+ status="done" )
+
+ @web.expose
@web.require_login( "see all available histories" )
def list_histories( self, trans, **kwargs ):
"""List all histories that can be used for selecting datasets."""
@@ -654,6 +678,12 @@
output_dataset = joda.dataset
return self.add_track_async( trans, output_dataset.id )
+
+ @web.expose
+ def woot( self, trans, ldda_id, target_type ):
+ ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) )
+ converted_dataset = ldda.get_converted_dataset( trans, target_type )
+ raise converted_dataset
#
# Helper methods.
--- a/static/scripts/packed/trackster.js Tue Feb 01 19:56:05 2011 -0500
+++ b/static/scripts/packed/trackster.js Tue Feb 01 20:07:17 2011 -0500
@@ -1,1 +1,1 @@
-CanvasRenderingContext2D.prototype.dashedLine=function(c,i,b,h,f){if(f==undefined){f=4}var e=b-c;var d=h-i;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var k=e/g;var j=d/g;for(var a=0;a<g;a++,c+=k,i+=j){if(a%2!=0){continue}this.fillRect(c,i,f,1)}};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();for(var c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c==f.length){if(this!=f.get(c-1)){g.append(this)}}else{if(this!=f.get(c)){$(this).insertBefore(f.get(c))}}})}var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,CONNECTOR_COLOR="#ccc",DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",FILTERABLE_CLASS="filterable",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}CONTEXT=DUMMY_CANVAS.getContext("2d");PX_PER_CHAR=CONTEXT.measureText("A").width;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function(){RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.move_key_to_end(b,a)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_form=$("<form/>").attr("action",function(){}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.chrom_form);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.chrom_form);$.ajax({url:chrom_url,data:(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}),dataType:"json",success:function(f){if(f.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=f.chrom_info;var j='<option value="">Select Chrom/Contig</option>';for(var h=0,e=a.chrom_data.length;h<e;h++){var g=a.chrom_data[h].chrom;j+='<option value="'+g+'">'+g+"</option>"}a.chrom_select.html(j);a.intro_div.show();a.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});if(d){d()}},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}});this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var i=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(i/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX;g.enable_pan=(f.clientX<a.viewport_container.width()-16)?true:false}).bind("drag",function(h,j){if(!j.enable_pan){return}var f=$(this);var k=j.offsetX-j.current_x;var g=f.scrollTop()-(h.clientY-j.current_height);console.log(g);f.scrollTop(g);j.current_height=h.clientY;j.current_x=j.offsetX;var i=Math.round(k/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height(),top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j,k){$(k.proxy).css({left:Math.min(j.pageX,k.startX),width:Math.abs(j.pageX-k.startX)});var g=Math.min(j.pageX,k.startX)-a.container.offset().left,f=Math.max(j.pageX,k.startX)-a.container.offset().left,i=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*i)+a.low,Math.round(f/h*i)+a.low)}).bind("dragend",function(k,l){var g=Math.min(k.pageX,l.startX),f=Math.max(k.pageX,l.startX),i=(a.high-a.low),h=a.viewport_container.width(),j=a.low;a.low=Math.round(g/h*i)+j;a.high=Math.round(f/h*i)+j;$(l.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},change_chrom:function(e,b,g){var d=this;var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){return}if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()},go_to:function(f){var j=this,a,d,b=f.split(":"),h=b[0],i=b[1];if(i!==undefined){try{var g=i.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}j.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);sortable(a.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_location(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").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()}});var Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)==0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e=="int"||e=="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");if(!a.content_div.text()){a.content_div.text(DATA_LOADING)}a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}$.getJSON(this.dataset_check_url,{dataset_id:a.dataset_id,chrom:a.view.chrom,low:a.view.max_low,high:a.view.max_high},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").attr("id",d+"_error");c.text("View error");$("#"+d+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b==="data"){a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;a.predraw_init();a.draw()}}}}}}})},predraw_init:function(){},restore_prefs:function(a){var b=this;$.each(a,function(c,d){if(d!==undefined){b.prefs[c]=d}})},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(g,d,s){var o=this,j=o.view;this.filters=(g!==undefined?get_filters_from_dict(g):[]);this.tool=(d!==undefined?get_tool_from_dict(d):undefined);this.parent_track=s;this.child_tracks=[];if(o.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filtering_div=$("<div/>").addClass("track-filters").hide();this.header_div.after(this.filtering_div);this.filtering_div.bind("drag",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var t=$("<table class='filters'>").appendTo(this.filtering_div);$.each(this.filters,function(w,z){var v=$("<tr>").appendTo(t);var y=$("<th class='filter-info'>").appendTo(v);var u=$("<span class='name'>").appendTo(y);u.text(z.name+" ");var i=$("<span class='values'>").appendTo(y);var x=$("<td>").appendTo(v);z.control_element=$("<div id='"+z.name+"-filter-control' style='width: 200px; position: relative'>").appendTo(x);z.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(B,C){var A=C.values;i.text("["+A[0]+"-"+A[1]+"]");z.low=A[0];z.high=A[1];o.draw(true)},change:function(A,B){z.control_element.slider("option","slide").call(z.control_element,A,B)}});z.slider=z.control_element;z.slider_label=i});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(i){i.stopPropagation()}).bind("click",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var l=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var e=this.tool.params;var o=this;$.each(this.tool.params,function(A,v){var y=$("<div>").addClass("param-row").appendTo(o.dynamic_tool_div);var x=$("<div>").addClass("slider-label").appendTo(y);var C=$("<span class='param-name'>").text(v.label+" ").appendTo(x);var w=$("<span/>").text(v.value);var z=$("<span class='param-value'>").appendTo(x).append("[").append(w).append("]");var B=$("<div/>").addClass("slider").appendTo(y);var i=$("<div id='"+v.name+"-param-control'>").appendTo(B);var u=(v.max<=1?0.01:(v.max<=1000?1:5));i.slider({min:v.min,max:v.max,step:u,value:v.value,slide:function(D,F){var E=F.value;v.value=E;if(0<E&&E<1){E=parseFloat(E).toFixed(2)}w.text(E)},change:function(D,E){v.value=E.value}});z.click(function(){var F=w,E=F.text(),D=(v.max<=1?4:v.max.length);F.text("");$("<input type='text'/>").attr("size",D).attr("maxlength",D).attr("value",E).appendTo(F).focus().select().click(function(G){G.stopPropagation()}).blur(function(){$(this).remove();F.text(E)}).keyup(function(I){if(I.keyCode===27){$(this).trigger("blur")}else{if(I.keyCode===13){var G=$(this),H=parseFloat(G.val());if(isNaN(H)||H>v.max||H<v.min){alert("Parameter value must be in the range ["+v.min+"-"+v.max+"]");return $(this)}F.text(H);i.slider("value",H);v.value=H}}})});$("<div style='clear: both;'/>").appendTo(y)});var b=$("<div>").addClass("param-row").appendTo(this.dynamic_tool_div);var n=$("<input type='submit'>").attr("value","Run").appendTo(b);var o=this;n.click(function(){o.run_tool()})}o.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();o.container_div.append(o.child_tracks_container);if(o.display_modes!==undefined){if(o.mode_div===undefined){o.mode_div=$("<div class='right-float menubutton popup' />").appendTo(o.header_div);var m=o.display_modes[0];o.mode=m;o.mode_div.text(m);var a=function(i){o.mode_div.text(i);o.mode=i;o.tile_cache.clear();o.draw()};var f={};for(var q=0,r=o.display_modes.length;q<r;q++){var k=o.display_modes[q];f[k]=function(i){return function(){a(i)}}(k)}make_popupmenu(o.mode_div,f)}else{o.mode_div.hide()}}var h={};h["Edit configuration"]=function(){var v=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},i=function(){o.update_options(o.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},u=function(w){if((w.keyCode||w.which)===27){v()}else{if((w.keyCode||w.which)===13){i()}}};$(window).bind("keypress.check_enter_esc",u);show_modal("Configure Track",o.gen_options(o.track_id),{Cancel:v,OK:i})};h["Set as overview"]=function(){j.overview_viewport.find("canvas").remove();o.is_overview=true;o.set_overview();for(var i in j.tracks){if(j.tracks[i]!==o){j.tracks[i].is_overview=false}}};if(o.filters.length>0){h["Show filters"]=function(){var i;if(!o.filtering_div.is(":visible")){i="Hide filters";o.filters_visible=true}else{i="Show filters";o.filters_visible=false}o.filtering_div.toggle()}}if(o.tool){h["Toggle Tool"]=function(){var i;if(!o.dynamic_tool_div.is(":visible")){i="Hide dynamic tool";o.update_name(o.name+o.tool_region_and_parameters_str())}else{i="Show dynamic tool";o.revert_name()}o.dynamic_tool_div.toggle()}}var c=j;var p=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;p=function(){}}h.Remove=function(){c.remove_track(o);if(c.num_tracks===0){p()}};o.popup_menu=make_popupmenu(o.name_div,h)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(a){var m=this.view.low,g=this.view.high,j=g-m,f=this.view.resolution;var p=$("<div style='position: relative;'></div>"),q=this.content_div.width()/j;this.content_div.append(p);this.max_height=0;var b=Math.floor(m/f/DENSITY);var l={};while((b*DENSITY*f)<g){var n=this.content_div.width()+"_"+q+"_"+b;var e=this.tile_cache.get(n);if(!a&&e){var k=b*DENSITY*f;var d=(k-m)*q;if(this.left_offset){d-=this.left_offset}e.css({left:d});this.show_tile(e,p)}else{this.delayed_draw(this,n,m,g,b,f,p,q,l)}b+=1}var c=this;var o=setInterval(function(){if(obj_length(l)===0){if(c.content_div.children().length>1){c.content_div.children(":first").remove()}for(var i=0;i<c.filters.length;i++){c.filters[i].update_ui_elt()}clearInterval(o)}},50);for(var h=0;h<this.child_tracks.length;h++){this.child_tracks[h].draw(a)}},delayed_draw:function(c,h,g,e,b,d,i,j,f){var a=setTimeout(function(){if(g<=c.view.high&&e>=c.view.low){var k=c.draw_tile(d,b,i,j);if(k){if(!c.initial_canvas&&!window.G_vmlCanvasManager){c.initial_canvas=$(k).clone();var n=k.get(0).getContext("2d");var l=c.initial_canvas.get(0).getContext("2d");var m=n.getImageData(0,0,n.canvas.width,n.canvas.height);l.putImageData(m,0,0);c.set_overview()}c.tile_cache.set(h,k);c.show_tile(k,i)}}delete f[a]},50);f[a]=true},show_tile:function(a,c){var b=this;c.append(a);b.max_height=Math.max(b.max_height,a.height());b.content_div.css("height",b.max_height+"px");if(b.hidden){return}if(a.hasClass(FILTERABLE_CLASS)){show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters");if(b.filters_visible){b.filtering_div.show()}}else{show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters",false);b.filtering_div.hide()}},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type=="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f=="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f=="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.data_queue={};this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(f,b,k,o){var g=b*DENSITY*f,d=DENSITY*f,j=f+"_"+b;var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var n=e.get(0).getContext("2d");if(o>PX_PER_CHAR){if(this.data_cache.get(j)===undefined){this.get_data(f,b);return}var m=this.data_cache.get(j);if(m===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*o+this.left_offset);e.get(0).height=this.height_px;e.css({position:"absolute",top:0,left:(g-this.view.low)*o-this.left_offset});for(var h=0,l=m.length;h<l;h++){var a=Math.round(h*o),i=Math.round(o/2);n.fillText(m[h],a+this.left_offset+i,10)}k.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.min_height_px=12;this.max_height_px=400;this.height_px=80;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};this.restore_prefs(c);(function(e){var h=false;var g=false;var f=$("<div class='track-resize'>");$(e.container_div).hover(function(){h=true;f.show()},function(){h=false;if(!g){f.hide()}});f.hide().bind("dragstart",function(i,j){g=true;j.original_height=$(e.content_div).height()}).bind("drag",function(j,k){var i=Math.min(Math.max(k.original_height+k.deltaY,e.min_height_px),e.max_height_px);$(e.content_div).css("height",i);e.height_px=i;e.draw(true)}).bind("dragend",function(i,j){e.tile_cache.clear();g=false;if(!h){f.hide()}}).appendTo(e.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;$.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:this.data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){var h=g.data;c.data_cache.set(e,h);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*o,a=DENSITY*o,x=o+"_"+r;var b=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);if(this.data_cache.get(x)===undefined){this.get_data(o,r);return}var v=this.data_cache.get(x);if(!v){return}b.css({position:"absolute",top:0,left:(s-this.view.low)*e});b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var n=b.get(0).getContext("2d"),j=false,k=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,t=this.total_frequency,d=this.height_px,l=this.mode;var w=Math.round(d+k/m*d);n.beginPath();n.moveTo(0,w);n.lineTo(a*e,w);n.fillStyle="#aaa";n.stroke();n.beginPath();n.fillStyle=this.prefs.color;var u,h,f;if(v.length>1){f=Math.ceil((v[1][0]-v[0][0])*e)}else{f=10}for(var p=0,q=v.length;p<q;p++){u=Math.round((v[p][0]-s)*e);h=v[p][1];if(h===null){if(j&&l==="Filled"){n.lineTo(u,d)}j=false;continue}if(h<k){h=k}else{if(h>g){h=g}}if(l==="Histogram"){h=Math.round(h/m*d);n.fillRect(u,w,f,-h)}else{if(l==="Intensity"){h=255-Math.floor((h-k)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(u,0,f,d)}else{h=Math.round(d-(h-k)/m*d);if(j){n.lineTo(u,h)}else{j=true;if(l==="Filled"){n.moveTo(u,d);n.lineTo(u,h)}else{n.moveTo(u,h)}}}}}if(l==="Filled"){if(j){n.lineTo(u,w);n.lineTo(0,w)}n.fill()}else{n.stroke()}c.append(b);return b},gen_options:function(m){var a=$("<div />").addClass("form-row");var e="track_"+m+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+m+"_minval",l=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),k=$("<input></input>").attr("id",h).val(d),j="track_"+m+"_maxval",g=$("<label></label>").attr("for",j).text("Max value:"),i=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",j).val(i);return a.append(l).append(k).append(g).append(f).append(b).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_color").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.color=b;this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+d+"_minval").text(this.prefs.min_value);$("#linetrack_"+d+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(f,c,a,e,g,d,b){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,f,c,c.viewport_container);TiledTrack.call(this,g,d,b);this.height_px=0;this.container_div.addClass("feature-track");this.dataset_id=a;this.original_dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200;this.prefs={block_color:"#444",label_color:"black",show_counts:true};this.restore_prefs(e)};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(b.data_url,{chrom:b.view.chrom,low:a,high:d,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set_data(a,d,b.mode,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,b,p){var r=this.inc_slots[a];if(!r||(r.mode!==p)){r={};r.w_scale=a;r.mode=p;this.inc_slots[a]=r;this.s_e_by_tile[a]={}}var l=r.w_scale,x=[],y=[],j=0,n=this.view.max_low;for(var v=0,w=h.length;v<w;v++){var g=h[v],k=g[0];if(r[k]!==undefined){j=Math.max(j,r[k]);y.push(r[k])}else{x.push(v)}}var q=this.s_e_by_tile[a];var m=function(D,E){var C;for(var B=0,F;B<=MAX_FEATURE_DEPTH;B++){C=true;F=q[B];if(F!==undefined){for(var z=0,A=F.length;z<A;z++){var i=F[z];if(E>i[0]&&D<i[1]){C=false;break}}}if(C){break}}if(C){return B}else{return -1}};for(var v=0,w=x.length;v<w;v++){var g=h[x[v]],k=g[0],t=g[1],c=g[2],o=g[3],d=Math.floor((t-n)*l),f=Math.ceil((c-n)*l),u=CONTEXT.measureText(o).width,e;if(o!==undefined&&!b){if(d-u<0){f+=u;e="left"}else{d-=u;e="right"}}var s=m(d,f);if(s<0){}if(s>=0){slot=q[s];if(slot===undefined){slot=q[s]=[]}slot.push([d,f]);r[k]=s;j=Math.max(j,s)}else{console.log("WARNING: not displaying feature")}}return j},rect_or_text:function(r,l,u,b,q,j,g,f){r.textAlign="center";var d=0,s=0,p=Math.round(l/2);for(var m=0,t=j.length;m<t;m++){var k=j[m],e="MIDNSHP=X"[k[0]],n=k[1];if(e==="H"||e==="S"){d-=n}var h=q+d,x=Math.floor(Math.max(0,(h-u)*l)),i=Math.floor(Math.max(0,(h+n-u)*l));switch(e){case"H":break;case"S":case"M":case"=":var o=g.slice(s,s+n);if((this.mode==="Pack"||this.mode==="Auto")&&g!==undefined&&l>PX_PER_CHAR){r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+1,i-x,9);r.fillStyle=CONNECTOR_COLOR;for(var v=0,a=o.length;v<a;v++){if(h+v>=u&&h+v<=b){var w=Math.floor(Math.max(0,(h+v-u)*l));r.fillText(o[v],w+this.left_offset+p,f+9)}}}else{r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+(this.mode!="Dense"?4:5),i-x,(this.mode!="Dense"?3:1))}s+=n;break;case"N":r.fillStyle=CONNECTOR_COLOR;r.fillRect(x+this.left_offset,f+5,i-x,1);break;case"D":r.fillStyle="red";r.fillRect(x+this.left_offset,f+4,i-x,3);break;case"P":break;case"I":s+=n;break;case"X":s+=n;break}d+=n}},draw_tile:function(ad,n,r,ar){var L=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,K=ai-L;var G=this.data_cache.get_data(L,ai,this.mode);if(G===undefined||G==="pending"||(this.mode!=="Auto"&&G.dataset_type==="summary_tree")){this.data_queue[[L,ai]]=true;this.get_data(L,ai);return}var a=Math.ceil(K*ar),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,v=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,aq,B,at;var p=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(p)}p=$(p);if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(q==="Dense"){B=v;at=10}else{at=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ar<0.0001?1/this.view.zoom_res:ar);B=this.incremental_slots(w,G.data,ab,q)*at+v;aq=this.inc_slots[w]}}p.css({position:"absolute",top:0,left:(L-this.view.low)*ar-U});p.get(0).width=a+U;p.get(0).height=B;r.parent().css("height",Math.max(this.height_px,B)+"px");var H=p.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";this.container_div.find(".yaxislabel").remove();if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,b=Math.ceil(G.delta*ar);var o=$("<div />").addClass("yaxislabel");o.text(J);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,F=W.length;am<F;am++){var Y=Math.floor((W[am][0]-L)*ar);var X=W[am][1];if(!X){continue}var aj=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}r.append(p);return p}if(G.message){p.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,at);return p}for(var ao=0;ao<this.filters.length;ao++){if(this.filters[ao].applies_to(G.data[0])){p.addClass(FILTERABLE_CLASS);break}}var ap=G.data;var al=0;for(var am=0,F=ap.length;am<F;am++){var Q=ap[am],P=Q[0],an=Q[1],aa=Q[2],M=Q[3];if(this.mode!="Dense"&&aq[P]===undefined){continue}var Z=false;var S;for(var ao=0;ao<this.filters.length;ao++){S=this.filters[ao];S.update_attrs(Q);if(!S.keep(Q)){Z=true;break}}if(Z){continue}if(an<=ai&&aa>=L){var ac=Math.floor(Math.max(0,(an-L)*ar)),I=Math.ceil(Math.min(a,Math.max(0,(aa-L)*ar))),V=(q==="Dense"?1:(1+aq[P]))*at;var E,ag,N=null,au=null;if(G.dataset_type==="bai"){H.fillStyle=h;if(Q[5] instanceof Array){var C=Math.floor(Math.max(0,(Q[4][0]-L)*ar)),O=Math.ceil(Math.min(a,Math.max(0,(Q[4][1]-L)*ar))),A=Math.floor(Math.max(0,(Q[5][0]-L)*ar)),u=Math.ceil(Math.min(a,Math.max(0,(Q[5][1]-L)*ar)));if(Q[4][1]>=L&&Q[4][0]<=ai&&Q[4][2]){this.rect_or_text(H,ar,L,ai,Q[4][0],Q[4][2],Q[4][3],V)}if(Q[5][1]>=L&&Q[5][0]<=ai&&Q[5][2]){this.rect_or_text(H,ar,L,ai,Q[5][0],Q[5][2],Q[5][3],V)}if(A>O){H.fillStyle=CONNECTOR_COLOR;H.dashedLine(O+U,V+5,U+A,V+5)}}else{H.fillStyle=h;this.rect_or_text(H,ar,L,ai,an,Q[4],Q[5],V)}if(q!=="Dense"&&!ab&&an>L){H.fillStyle=this.prefs.label_color;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var D=Q[5],T=Q[6],ae=Q[7],g=Q[8];if(T&&ae){N=Math.floor(Math.max(0,(T-L)*ar));au=Math.ceil(Math.min(a,Math.max(0,(ae-L)*ar)))}if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}if(g){if(D){if(D=="+"){H.fillStyle=RIGHT_STRAND}else{if(D=="-"){H.fillStyle=LEFT_STRAND}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}for(var ak=0,e=g.length;ak<e;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-L)*ar)),R=Math.ceil(Math.min(a,Math.max((t[1]-L)*ar)));if(d>R){continue}E=5;ag=3;H.fillRect(d+U,V+ag,R-d,E);if(N!==undefined&&!(d>au||R<N)){E=9;ag=1;var ah=Math.max(d,N),z=Math.min(R,au);H.fillRect(ah+U,V+ag,z-ah,E)}}}else{E=9;ag=1;H.fillRect(ac+U,V+ag,I-ac,E);if(Q.strand){if(Q.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(Q.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var s=Q[4],m=Q[5],c=Q[6];E=9;ag=1;H.fillRect(ac+U,V,I-ac,E);if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}var l=s+" / "+m;if(an>L&&H.measureText(l).width<(I-ac)){H.fillStyle="white";H.textAlign="center";H.fillText(l,U+ac+(I-ac)/2,V+8);H.fillStyle=h}}}}}al++}}return p},gen_options:function(i){var a=$("<div />").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label />").attr("for",e).text("Block color:"),l=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label />").attr("for",j).text("Text color:"),h=$("<input />").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(k).append(l).append(g).append(h).append(d)},update_options:function(d){var b=$("#track_"+d+"_block_color").val(),c=$("#track_"+d+"_label_color").val(),a=$("#track_"+d+"_show_count").attr("checked");if(b!==this.prefs.block_color||c!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=c;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,a,c,e){FeatureTrack.call(this,d,b,a,c,e);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});var ToolDataFeatureTrack=function(e,c,a,d,f,b){FeatureTrack.call(this,e,c,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()==0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id},function(c){})}};a()}});
\ No newline at end of file
+CanvasRenderingContext2D.prototype.dashedLine=function(c,i,b,h,f){if(f==undefined){f=4}var e=b-c;var d=h-i;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var k=e/g;var j=d/g;for(var a=0;a<g;a++,c+=k,i+=j){if(a%2!=0){continue}this.fillRect(c,i,f,1)}};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();for(var c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c==f.length){if(this!=f.get(c-1)){g.append(this)}}else{if(this!=f.get(c)){$(this).insertBefore(f.get(c))}}})}var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,CONNECTOR_COLOR="#ccc",DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",FILTERABLE_CLASS="filterable",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}CONTEXT=DUMMY_CANVAS.getContext("2d");PX_PER_CHAR=CONTEXT.measureText("A").width;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function(){RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.move_key_to_end(b,a)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_form=$("<form/>").attr("action",function(){}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.chrom_form);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.chrom_form);$.ajax({url:chrom_url,data:(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}),dataType:"json",success:function(f){if(f.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=f.chrom_info;var j='<option value="">Select Chrom/Contig</option>';for(var h=0,e=a.chrom_data.length;h<e;h++){var g=a.chrom_data[h].chrom;j+='<option value="'+g+'">'+g+"</option>"}a.chrom_select.html(j);a.intro_div.show();a.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});if(d){d()}},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}});this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var i=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(i/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX;g.enable_pan=(f.clientX<a.viewport_container.width()-16)?true:false}).bind("drag",function(h,j){if(!j.enable_pan){return}var f=$(this);var k=j.offsetX-j.current_x;var g=f.scrollTop()-(h.clientY-j.current_height);f.scrollTop(g);j.current_height=h.clientY;j.current_x=j.offsetX;var i=Math.round(k/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height(),top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j,k){$(k.proxy).css({left:Math.min(j.pageX,k.startX),width:Math.abs(j.pageX-k.startX)});var g=Math.min(j.pageX,k.startX)-a.container.offset().left,f=Math.max(j.pageX,k.startX)-a.container.offset().left,i=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*i)+a.low,Math.round(f/h*i)+a.low)}).bind("dragend",function(k,l){var g=Math.min(k.pageX,l.startX),f=Math.max(k.pageX,l.startX),i=(a.high-a.low),h=a.viewport_container.width(),j=a.low;a.low=Math.round(g/h*i)+j;a.high=Math.round(f/h*i)+j;$(l.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},change_chrom:function(e,b,g){var d=this;var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){return}if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()},go_to:function(f){var j=this,a,d,b=f.split(":"),h=b[0],i=b[1];if(i!==undefined){try{var g=i.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}j.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);sortable(a.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_location(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").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()}});var Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)==0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e=="int"||e=="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");if(!a.content_div.text()){a.content_div.text(DATA_LOADING)}a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}$.getJSON(this.dataset_check_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom,low:a.view.max_low,high:a.view.max_high},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").attr("id",d+"_error");c.text("View error");$("#"+d+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b==="data"){a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;a.predraw_init();a.draw()}}}}}}})},predraw_init:function(){},restore_prefs:function(a){var b=this;$.each(a,function(c,d){if(d!==undefined){b.prefs[c]=d}})},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(g,d,s){var o=this,j=o.view;this.filters=(g!==undefined?get_filters_from_dict(g):[]);this.tool=(d!==undefined?get_tool_from_dict(d):undefined);this.parent_track=s;this.child_tracks=[];if(o.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filtering_div=$("<div/>").addClass("track-filters").hide();this.header_div.after(this.filtering_div);this.filtering_div.bind("drag",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var t=$("<table class='filters'>").appendTo(this.filtering_div);$.each(this.filters,function(w,z){var v=$("<tr>").appendTo(t);var y=$("<th class='filter-info'>").appendTo(v);var u=$("<span class='name'>").appendTo(y);u.text(z.name+" ");var i=$("<span class='values'>").appendTo(y);var x=$("<td>").appendTo(v);z.control_element=$("<div id='"+z.name+"-filter-control' style='width: 200px; position: relative'>").appendTo(x);z.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(B,C){var A=C.values;i.text("["+A[0]+"-"+A[1]+"]");z.low=A[0];z.high=A[1];o.draw(true)},change:function(A,B){z.control_element.slider("option","slide").call(z.control_element,A,B)}});z.slider=z.control_element;z.slider_label=i});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(i){i.stopPropagation()}).bind("click",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var l=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var e=this.tool.params;var o=this;$.each(this.tool.params,function(A,v){var y=$("<div>").addClass("param-row").appendTo(o.dynamic_tool_div);var x=$("<div>").addClass("slider-label").appendTo(y);var C=$("<span class='param-name'>").text(v.label+" ").appendTo(x);var w=$("<span/>").text(v.value);var z=$("<span class='param-value'>").appendTo(x).append("[").append(w).append("]");var B=$("<div/>").addClass("slider").appendTo(y);var i=$("<div id='"+v.name+"-param-control'>").appendTo(B);var u=(v.max<=1?0.01:(v.max<=1000?1:5));i.slider({min:v.min,max:v.max,step:u,value:v.value,slide:function(D,F){var E=F.value;v.value=E;if(0<E&&E<1){E=parseFloat(E).toFixed(2)}w.text(E)},change:function(D,E){v.value=E.value}});z.click(function(){var F=w,E=F.text(),D=(v.max<=1?4:v.max.length);F.text("");$("<input type='text'/>").attr("size",D).attr("maxlength",D).attr("value",E).appendTo(F).focus().select().click(function(G){G.stopPropagation()}).blur(function(){$(this).remove();F.text(E)}).keyup(function(I){if(I.keyCode===27){$(this).trigger("blur")}else{if(I.keyCode===13){var G=$(this),H=parseFloat(G.val());if(isNaN(H)||H>v.max||H<v.min){alert("Parameter value must be in the range ["+v.min+"-"+v.max+"]");return $(this)}F.text(H);i.slider("value",H);v.value=H}}})});$("<div style='clear: both;'/>").appendTo(y)});var b=$("<div>").addClass("param-row").appendTo(this.dynamic_tool_div);var n=$("<input type='submit'>").attr("value","Run").appendTo(b);var o=this;n.click(function(){o.run_tool()})}o.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();o.container_div.append(o.child_tracks_container);if(o.display_modes!==undefined){if(o.mode_div===undefined){o.mode_div=$("<div class='right-float menubutton popup' />").appendTo(o.header_div);var m=o.display_modes[0];o.mode=m;o.mode_div.text(m);var a=function(i){o.mode_div.text(i);o.mode=i;o.tile_cache.clear();o.draw()};var f={};for(var q=0,r=o.display_modes.length;q<r;q++){var k=o.display_modes[q];f[k]=function(i){return function(){a(i)}}(k)}make_popupmenu(o.mode_div,f)}else{o.mode_div.hide()}}var h={};h["Edit configuration"]=function(){var v=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},i=function(){o.update_options(o.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},u=function(w){if((w.keyCode||w.which)===27){v()}else{if((w.keyCode||w.which)===13){i()}}};$(window).bind("keypress.check_enter_esc",u);show_modal("Configure Track",o.gen_options(o.track_id),{Cancel:v,OK:i})};h["Set as overview"]=function(){j.overview_viewport.find("canvas").remove();o.is_overview=true;o.set_overview();for(var i in j.tracks){if(j.tracks[i]!==o){j.tracks[i].is_overview=false}}};if(o.filters.length>0){h["Show filters"]=function(){var i;if(!o.filtering_div.is(":visible")){i="Hide filters";o.filters_visible=true}else{i="Show filters";o.filters_visible=false}o.filtering_div.toggle()}}if(o.tool){h["Toggle Tool"]=function(){var i;if(!o.dynamic_tool_div.is(":visible")){i="Hide dynamic tool";o.update_name(o.name+o.tool_region_and_parameters_str())}else{i="Show dynamic tool";o.revert_name()}o.dynamic_tool_div.toggle()}}var c=j;var p=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;p=function(){}}h.Remove=function(){c.remove_track(o);if(c.num_tracks===0){p()}};o.popup_menu=make_popupmenu(o.name_div,h)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(a){var m=this.view.low,g=this.view.high,j=g-m,f=this.view.resolution;var p=$("<div style='position: relative;'></div>"),q=this.content_div.width()/j;this.content_div.append(p);this.max_height=0;var b=Math.floor(m/f/DENSITY);var l={};while((b*DENSITY*f)<g){var n=this.content_div.width()+"_"+q+"_"+b;var e=this.tile_cache.get(n);if(!a&&e){var k=b*DENSITY*f;var d=(k-m)*q;if(this.left_offset){d-=this.left_offset}e.css({left:d});this.show_tile(e,p)}else{this.delayed_draw(this,n,m,g,b,f,p,q,l)}b+=1}var c=this;var o=setInterval(function(){if(obj_length(l)===0){if(c.content_div.children().length>1){c.content_div.children(":first").remove()}for(var i=0;i<c.filters.length;i++){c.filters[i].update_ui_elt()}clearInterval(o)}},50);for(var h=0;h<this.child_tracks.length;h++){this.child_tracks[h].draw(a)}},delayed_draw:function(c,h,g,e,b,d,i,j,f){var a=setTimeout(function(){if(g<=c.view.high&&e>=c.view.low){var k=c.draw_tile(d,b,i,j);if(k){if(!c.initial_canvas&&!window.G_vmlCanvasManager){c.initial_canvas=$(k).clone();var n=k.get(0).getContext("2d");var l=c.initial_canvas.get(0).getContext("2d");var m=n.getImageData(0,0,n.canvas.width,n.canvas.height);l.putImageData(m,0,0);c.set_overview()}c.tile_cache.set(h,k);c.show_tile(k,i)}}delete f[a]},50);f[a]=true},show_tile:function(a,c){var b=this;c.append(a);b.max_height=Math.max(b.max_height,a.height());b.content_div.css("height",b.max_height+"px");if(b.hidden){return}if(a.hasClass(FILTERABLE_CLASS)){show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters");if(b.filters_visible){b.filtering_div.show()}}else{show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters",false);b.filtering_div.hide()}},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type=="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f=="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f=="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.data_queue={};this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(f,b,k,o){var g=b*DENSITY*f,d=DENSITY*f,j=f+"_"+b;var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var n=e.get(0).getContext("2d");if(o>PX_PER_CHAR){if(this.data_cache.get(j)===undefined){this.get_data(f,b);return}var m=this.data_cache.get(j);if(m===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*o+this.left_offset);e.get(0).height=this.height_px;e.css({position:"absolute",top:0,left:(g-this.view.low)*o-this.left_offset});for(var h=0,l=m.length;h<l;h++){var a=Math.round(h*o),i=Math.round(o/2);n.fillText(m[h],a+this.left_offset+i,10)}k.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,e,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.min_height_px=12;this.max_height_px=400;this.height_px=80;this.hda_ldda=e;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};this.restore_prefs(c);(function(f){var i=false;var h=false;var g=$("<div class='track-resize'>");$(f.container_div).hover(function(){i=true;g.show()},function(){i=false;if(!h){g.hide()}});g.hide().bind("dragstart",function(j,k){h=true;k.original_height=$(f.content_div).height()}).bind("drag",function(k,l){var j=Math.min(Math.max(l.original_height+l.deltaY,f.min_height_px),f.max_height_px);$(f.content_div).css("height",j);f.height_px=j;f.draw(true)}).bind("dragend",function(j,k){f.tile_cache.clear();h=false;if(!i){g.hide()}}).appendTo(f.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;$.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:this.data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){var h=g.data;c.data_cache.set(e,h);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*o,a=DENSITY*o,x=o+"_"+r;var b=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);if(this.data_cache.get(x)===undefined){this.get_data(o,r);return}var v=this.data_cache.get(x);if(!v){return}b.css({position:"absolute",top:0,left:(s-this.view.low)*e});b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var n=b.get(0).getContext("2d"),j=false,k=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,t=this.total_frequency,d=this.height_px,l=this.mode;var w=Math.round(d+k/m*d);n.beginPath();n.moveTo(0,w);n.lineTo(a*e,w);n.fillStyle="#aaa";n.stroke();n.beginPath();n.fillStyle=this.prefs.color;var u,h,f;if(v.length>1){f=Math.ceil((v[1][0]-v[0][0])*e)}else{f=10}for(var p=0,q=v.length;p<q;p++){u=Math.round((v[p][0]-s)*e);h=v[p][1];if(h===null){if(j&&l==="Filled"){n.lineTo(u,d)}j=false;continue}if(h<k){h=k}else{if(h>g){h=g}}if(l==="Histogram"){h=Math.round(h/m*d);n.fillRect(u,w,f,-h)}else{if(l==="Intensity"){h=255-Math.floor((h-k)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(u,0,f,d)}else{h=Math.round(d-(h-k)/m*d);if(j){n.lineTo(u,h)}else{j=true;if(l==="Filled"){n.moveTo(u,d);n.lineTo(u,h)}else{n.moveTo(u,h)}}}}}if(l==="Filled"){if(j){n.lineTo(u,w);n.lineTo(0,w)}n.fill()}else{n.stroke()}c.append(b);return b},gen_options:function(m){var a=$("<div />").addClass("form-row");var e="track_"+m+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+m+"_minval",l=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),k=$("<input></input>").attr("id",h).val(d),j="track_"+m+"_maxval",g=$("<label></label>").attr("for",j).text("Max value:"),i=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",j).val(i);return a.append(l).append(k).append(g).append(f).append(b).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_color").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.color=b;this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+d+"_minval").text(this.prefs.min_value);$("#linetrack_"+d+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(f,c,h,a,e,g,d,b){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,f,c,c.viewport_container);TiledTrack.call(this,g,d,b);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=h;this.dataset_id=a;this.original_dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200;this.prefs={block_color:"#444",label_color:"black",show_counts:true};this.restore_prefs(e)};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(b.data_url,{chrom:b.view.chrom,low:a,high:d,hda_ldda:b.hda_ldda,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set_data(a,d,b.mode,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,b,p){var r=this.inc_slots[a];if(!r||(r.mode!==p)){r={};r.w_scale=a;r.mode=p;this.inc_slots[a]=r;this.s_e_by_tile[a]={}}var l=r.w_scale,x=[],y=[],j=0,n=this.view.max_low;for(var v=0,w=h.length;v<w;v++){var g=h[v],k=g[0];if(r[k]!==undefined){j=Math.max(j,r[k]);y.push(r[k])}else{x.push(v)}}var q=this.s_e_by_tile[a];var m=function(D,E){var C;for(var B=0,F;B<=MAX_FEATURE_DEPTH;B++){C=true;F=q[B];if(F!==undefined){for(var z=0,A=F.length;z<A;z++){var i=F[z];if(E>i[0]&&D<i[1]){C=false;break}}}if(C){break}}if(C){return B}else{return -1}};for(var v=0,w=x.length;v<w;v++){var g=h[x[v]],k=g[0],t=g[1],c=g[2],o=g[3],d=Math.floor((t-n)*l),f=Math.ceil((c-n)*l),u=CONTEXT.measureText(o).width,e;if(o!==undefined&&!b){if(d-u<0){f+=u;e="left"}else{d-=u;e="right"}}var s=m(d,f);if(s<0){}if(s>=0){slot=q[s];if(slot===undefined){slot=q[s]=[]}slot.push([d,f]);r[k]=s;j=Math.max(j,s)}else{}}return j},rect_or_text:function(r,l,u,b,q,j,g,f){r.textAlign="center";var d=0,s=0,p=Math.round(l/2);for(var m=0,t=j.length;m<t;m++){var k=j[m],e="MIDNSHP=X"[k[0]],n=k[1];if(e==="H"||e==="S"){d-=n}var h=q+d,x=Math.floor(Math.max(0,(h-u)*l)),i=Math.floor(Math.max(0,(h+n-u)*l));switch(e){case"H":break;case"S":case"M":case"=":var o=g.slice(s,s+n);if((this.mode==="Pack"||this.mode==="Auto")&&g!==undefined&&l>PX_PER_CHAR){r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+1,i-x,9);r.fillStyle=CONNECTOR_COLOR;for(var v=0,a=o.length;v<a;v++){if(h+v>=u&&h+v<=b){var w=Math.floor(Math.max(0,(h+v-u)*l));r.fillText(o[v],w+this.left_offset+p,f+9)}}}else{r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+(this.mode!="Dense"?4:5),i-x,(this.mode!="Dense"?3:1))}s+=n;break;case"N":r.fillStyle=CONNECTOR_COLOR;r.fillRect(x+this.left_offset,f+5,i-x,1);break;case"D":r.fillStyle="red";r.fillRect(x+this.left_offset,f+4,i-x,3);break;case"P":break;case"I":s+=n;break;case"X":s+=n;break}d+=n}},draw_tile:function(ad,n,r,ar){var L=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,K=ai-L;var G=this.data_cache.get_data(L,ai,this.mode);if(G===undefined||G==="pending"||(this.mode!=="Auto"&&G.dataset_type==="summary_tree")){this.data_queue[[L,ai]]=true;this.get_data(L,ai);return}var a=Math.ceil(K*ar),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,v=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,aq,B,at;var p=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(p)}p=$(p);if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(q==="Dense"){B=v;at=10}else{at=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ar<0.0001?1/this.view.zoom_res:ar);B=this.incremental_slots(w,G.data,ab,q)*at+v;aq=this.inc_slots[w]}}p.css({position:"absolute",top:0,left:(L-this.view.low)*ar-U});p.get(0).width=a+U;p.get(0).height=B;r.parent().css("height",Math.max(this.height_px,B)+"px");var H=p.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";this.container_div.find(".yaxislabel").remove();if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,b=Math.ceil(G.delta*ar);var o=$("<div />").addClass("yaxislabel");o.text(J);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,F=W.length;am<F;am++){var Y=Math.floor((W[am][0]-L)*ar);var X=W[am][1];if(!X){continue}var aj=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}r.append(p);return p}if(G.message){p.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,at);return p}for(var ao=0;ao<this.filters.length;ao++){if(this.filters[ao].applies_to(G.data[0])){p.addClass(FILTERABLE_CLASS);break}}var ap=G.data;var al=0;for(var am=0,F=ap.length;am<F;am++){var Q=ap[am],P=Q[0],an=Q[1],aa=Q[2],M=Q[3];if(this.mode!="Dense"&&aq[P]===undefined){continue}var Z=false;var S;for(var ao=0;ao<this.filters.length;ao++){S=this.filters[ao];S.update_attrs(Q);if(!S.keep(Q)){Z=true;break}}if(Z){continue}if(an<=ai&&aa>=L){var ac=Math.floor(Math.max(0,(an-L)*ar)),I=Math.ceil(Math.min(a,Math.max(0,(aa-L)*ar))),V=(q==="Dense"?1:(1+aq[P]))*at;var E,ag,N=null,au=null;if(G.dataset_type==="bai"){H.fillStyle=h;if(Q[5] instanceof Array){var C=Math.floor(Math.max(0,(Q[4][0]-L)*ar)),O=Math.ceil(Math.min(a,Math.max(0,(Q[4][1]-L)*ar))),A=Math.floor(Math.max(0,(Q[5][0]-L)*ar)),u=Math.ceil(Math.min(a,Math.max(0,(Q[5][1]-L)*ar)));if(Q[4][1]>=L&&Q[4][0]<=ai&&Q[4][2]){this.rect_or_text(H,ar,L,ai,Q[4][0],Q[4][2],Q[4][3],V)}if(Q[5][1]>=L&&Q[5][0]<=ai&&Q[5][2]){this.rect_or_text(H,ar,L,ai,Q[5][0],Q[5][2],Q[5][3],V)}if(A>O){H.fillStyle=CONNECTOR_COLOR;H.dashedLine(O+U,V+5,U+A,V+5)}}else{H.fillStyle=h;this.rect_or_text(H,ar,L,ai,an,Q[4],Q[5],V)}if(q!=="Dense"&&!ab&&an>L){H.fillStyle=this.prefs.label_color;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var D=Q[5],T=Q[6],ae=Q[7],g=Q[8];if(T&&ae){N=Math.floor(Math.max(0,(T-L)*ar));au=Math.ceil(Math.min(a,Math.max(0,(ae-L)*ar)))}if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}if(g){if(D){if(D=="+"){H.fillStyle=RIGHT_STRAND}else{if(D=="-"){H.fillStyle=LEFT_STRAND}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}for(var ak=0,e=g.length;ak<e;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-L)*ar)),R=Math.ceil(Math.min(a,Math.max((t[1]-L)*ar)));if(d>R){continue}E=5;ag=3;H.fillRect(d+U,V+ag,R-d,E);if(N!==undefined&&!(d>au||R<N)){E=9;ag=1;var ah=Math.max(d,N),z=Math.min(R,au);H.fillRect(ah+U,V+ag,z-ah,E)}}}else{E=9;ag=1;H.fillRect(ac+U,V+ag,I-ac,E);if(Q.strand){if(Q.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(Q.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var s=Q[4],m=Q[5],c=Q[6];E=9;ag=1;H.fillRect(ac+U,V,I-ac,E);if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}var l=s+" / "+m;if(an>L&&H.measureText(l).width<(I-ac)){H.fillStyle="white";H.textAlign="center";H.fillText(l,U+ac+(I-ac)/2,V+8);H.fillStyle=h}}}}}al++}}return p},gen_options:function(i){var a=$("<div />").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label />").attr("for",e).text("Block color:"),l=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label />").attr("for",j).text("Text color:"),h=$("<input />").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(k).append(l).append(g).append(h).append(d)},update_options:function(d){var b=$("#track_"+d+"_block_color").val(),c=$("#track_"+d+"_label_color").val(),a=$("#track_"+d+"_show_count").attr("checked");if(b!==this.prefs.block_color||c!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=c;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()==0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id},function(c){})}};a()}});
\ No newline at end of file
--- a/static/scripts/trackster.js Tue Feb 01 19:56:05 2011 -0500
+++ b/static/scripts/trackster.js Tue Feb 01 20:07:17 2011 -0500
@@ -385,7 +385,6 @@
var container = $(this);
var delta = d.offsetX - d.current_x;
var new_scroll = container.scrollTop() - (e.clientY - d.current_height);
- console.log( new_scroll );
container.scrollTop(new_scroll);
d.current_height = e.clientY;
d.current_x = d.offsetX;
@@ -843,8 +842,8 @@
// Get dataset state; if state is fine, enable and draw track. Otherwise, show message
// about track status.
- $.getJSON(this.dataset_check_url,
- {dataset_id : track.dataset_id, chrom: track.view.chrom, low: track.view.max_low, high: track.view.max_high},
+ $.getJSON(this.dataset_check_url, { hda_ldda: track.hda_ldda, dataset_id: track.dataset_id,
+ chrom: track.view.chrom, low: track.view.max_low, high: track.view.max_high},
function (result) {
if (!result || result === "error" || result.kind === "error") {
track.container_div.addClass("error");
@@ -1548,7 +1547,7 @@
}
});
-var LineTrack = function ( name, view, dataset_id, prefs ) {
+var LineTrack = function ( name, view, hda_ldda, dataset_id, prefs ) {
this.track_type = "LineTrack";
this.display_modes = ["Histogram", "Line", "Filled", "Intensity"];
this.mode = "Histogram";
@@ -1558,6 +1557,7 @@
this.min_height_px = 12;
this.max_height_px = 400;
this.height_px = 80;
+ this.hda_ldda = hda_ldda;
this.dataset_id = dataset_id;
this.original_dataset_id = dataset_id;
this.data_cache = new DataCache(CACHED_DATA);
@@ -1604,7 +1604,7 @@
track.vertical_range = undefined;
$.getJSON( track.data_url, { stats: true, chrom: track.view.chrom, low: null, high: null,
- dataset_id: track.dataset_id }, function(result) {
+ hda_ldda: track.hda_ldda, dataset_id: track.dataset_id }, function(result) {
track.container_div.addClass( "line-track" );
var data = result.data;
if ( isNaN(parseFloat(track.prefs.min_value)) || isNaN(parseFloat(track.prefs.max_value)) ) {
@@ -1646,9 +1646,8 @@
track.draw();
});*/
$.ajax({ 'url': this.data_url, 'dataType': 'json',
- 'data': { "chrom": this.view.chrom,
- "low": low, "high": high, "dataset_id": this.dataset_id,
- "resolution": this.view.resolution },
+ 'data': { chrom: this.view.chrom, low: low, high: high,
+ hda_ldda: this.hda_ldda, dataset_id: this.dataset_id, resolution: this.view.resolution },
success: function (result) {
var data = result.data;
track.data_cache.set(key, data);
@@ -1804,7 +1803,7 @@
}
});
-var FeatureTrack = function (name, view, dataset_id, prefs, filters, tool, parent_track) {
+var FeatureTrack = function (name, view, hda_ldda, dataset_id, prefs, filters, tool, parent_track) {
this.track_type = "FeatureTrack";
this.display_modes = ["Auto", "Dense", "Squish", "Pack"];
Track.call(this, name, view, view.viewport_container);
@@ -1812,6 +1811,7 @@
this.height_px = 0;
this.container_div.addClass( "feature-track" );
+ this.hda_ldda = hda_ldda;
this.dataset_id = dataset_id;
this.original_dataset_id = dataset_id;
this.zo_slots = {};
@@ -1839,7 +1839,7 @@
if (!track.data_queue[key]) {
track.data_queue[key] = true;
$.getJSON( track.data_url, { chrom: track.view.chrom,
- low: low, high: high, dataset_id: track.dataset_id,
+ low: low, high: high, hda_ldda: track.hda_ldda, dataset_id: track.dataset_id,
resolution: this.view.resolution, mode: this.mode }, function (result) {
track.data_cache.set_data(low, high, track.mode, result);
// console.log("datacache", track.data_cache.get(key));
@@ -1987,7 +1987,7 @@
else {
// TODO: remove this warning when skipped features are handled.
// Show warning for skipped feature.
- console.log("WARNING: not displaying feature"); // , feature_uid, f_start, f_end);
+ // console.log("WARNING: not displaying feature"); // , feature_uid, f_start, f_end);
}
}
@@ -2425,8 +2425,8 @@
}
});
-var ReadTrack = function (name, view, dataset_id, prefs, filters) {
- FeatureTrack.call(this, name, view, dataset_id, prefs, filters);
+var ReadTrack = function (name, view, hda_ldda, dataset_id, prefs, filters) {
+ FeatureTrack.call(this, name, view, hda_ldda, dataset_id, prefs, filters);
this.track_type = "ReadTrack";
this.vertical_detail_px = 10;
this.vertical_nodetail_px = 5;
@@ -2436,8 +2436,8 @@
/**
* Feature track that displays data generated from tool.
*/
-var ToolDataFeatureTrack = function(name, view, dataset_id, prefs, filters, parent_track) {
- FeatureTrack.call(this, name, view, dataset_id, prefs, filters, {}, parent_track);
+var ToolDataFeatureTrack = function(name, view, hda_ldda, dataset_id, prefs, filters, parent_track) {
+ FeatureTrack.call(this, name, view, hda_ldda, dataset_id, prefs, filters, {}, parent_track);
this.track_type = "ToolDataFeatureTrack";
// Set up track to fetch initial data from raw data URL when the dataset--not the converted datasets--
--- a/templates/tracks/browser.mako Tue Feb 01 19:56:05 2011 -0500
+++ b/templates/tracks/browser.mako Tue Feb 01 20:07:17 2011 -0500
@@ -156,7 +156,8 @@
track_config = tracks_config[i];
track = new addable_track_types[track_config["track_type"]](
track_config['name'],
- view,
+ view,
+ track_config['hda_ldda'],
track_config['dataset_id'],
track_config['prefs'],
track_config['filters'],
@@ -211,10 +212,10 @@
var add_async_success = function(track_data) {
var td = track_data,
new_track = new addable_track_types[track_data.track_type](
- track_data.name, view, track_data.dataset_id, track_data.prefs,
- track_data.filters, track_data.tool );
+ track_data.name, view, track_data.hda_ldda, track_data.dataset_id,
+ track_data.prefs, track_data.filters, track_data.tool );
view.add_track(new_track);
- // Should replace with live event but can't get working
+ ## Should replace with live event but can't get working
sortable( new_track.container_div, ".draghandle" );
view.has_changes = true;
$("#no-tracks").hide();
@@ -229,7 +230,7 @@
});
%endif
-
+
// Use a popup grid to add more tracks
$("#add-track").bind("click", function(e) {
$.ajax({
@@ -238,18 +239,24 @@
error: function() { alert( "Grid failed" ); },
success: function(table_html) {
show_modal(
- "Add Track — Select History, then Dataset(s)",
+ "Add Track — Select history/library, then datasets",
table_html,
{
"Cancel": function() {
hide_modal();
},
"Insert": function() {
- $('input[name=id]:checked').each(function() {
- var item_id = $(this).val();
+ $('input[name=id]:checked,input[name=ldda_ids]:checked').each(function() {
+ var data,
+ id = $(this).val();
+ if ($(this).attr("name") === "id") {
+ data = { hda_id: id };
+ } else {
+ data = { ldda_id: id};
+ }
$.ajax( {
url: "${h.url_for( action='add_track_async' )}",
- data: { id: item_id },
+ data: data,
dataType: "json",
success: add_async_success
});
@@ -286,6 +293,7 @@
tracks.push( {
"track_type": track.track_type,
"name": track.name,
+ "hda_ldda": track.hda_ldda,
"dataset_id": track.dataset_id,
"prefs": track.prefs,
"is_child": (child_id ? true : false )
--- a/templates/tracks/history_datasets_select_grid.mako Tue Feb 01 19:56:05 2011 -0500
+++ b/templates/tracks/history_datasets_select_grid.mako Tue Feb 01 20:07:17 2011 -0500
@@ -10,6 +10,7 @@
url_dict[ "f-" + filter ] = value
%>
## Use class 'label' to piggyback on URL functionality in parent template.
- <a class="label" href="${h.url_for( **url_dict )}">Back to histories</a><br/>
+ <a class="label" href="${h.url_for( **url_dict )}">Back to histories</a>
+ <br /><br />
${parent.title()}
</%def>
\ No newline at end of file
--- a/templates/tracks/history_select_grid.mako Tue Feb 01 19:56:05 2011 -0500
+++ b/templates/tracks/history_select_grid.mako Tue Feb 01 20:07:17 2011 -0500
@@ -6,7 +6,7 @@
<%namespace file="../grid_base.mako" import="*" />
## Need to define title so that it can be overridden by child templates.
-<%def name="title()"><h2>${grid.title}</h2></%def>
+<%def name="title()"></%def>
${self.title()}
${stylesheets()}
@@ -19,11 +19,11 @@
var f = function() {
$("a.label,.page-link>a").click(function() {
var parent_body = $(this).parents("div.body");
- if (parent_body.length != 0) {
+ if (parent_body.length !== 0) {
parent_body.load($(this).attr("href"));
return false;
}
- });
+ });
};
// Need to process label URLs when document loaded and when grid changes.
$(document).ready(function() {
@@ -31,5 +31,15 @@
$('#grid-table-body').bind('update', f);
});
</script>
+
+%if getattr(grid, "datasets_param", None):
+ %if grid.datasets_param == "f-history":
+ <a class="label" href="${h.url_for( action='list_libraries' )}">Show Data Libraries</a>
+ %else:
+ <a class="label" href="${h.url_for( action='list_histories' )}">Show Histories</a>
+ %endif
+ <br /><br />
+%endif
+
${render_grid_header( grid, False )}
${render_grid_table( grid, show_item_checkboxes=show_item_checkboxes )}
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: kanwei: Add migration for ldda_parent_id field to implicitly_converted_dataset_association table
by Bitbucket 01 Feb '11
by Bitbucket 01 Feb '11
01 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/32e6782161be/
changeset: r4975:32e6782161be
user: kanwei
date: 2011-02-02 01:56:05
summary: Add migration for ldda_parent_id field to implicitly_converted_dataset_association table
affected #: 1 file (0 bytes)
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.
1
0
commit/galaxy-central: dan: Add YeastMine datasource tool. Site is still under development.
by Bitbucket 01 Feb '11
by Bitbucket 01 Feb '11
01 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/d65fb6e05729/
changeset: r4974:d65fb6e05729
user: dan
date: 2011-02-01 23:29:40
summary: Add YeastMine datasource tool. Site is still under development.
affected #: 2 files (46 bytes)
--- a/tool_conf.xml.sample Tue Feb 01 13:35:46 2011 -0500
+++ b/tool_conf.xml.sample Tue Feb 01 17:29:40 2011 -0500
@@ -16,6 +16,7 @@
<tool file="data_source/flymine_test.xml" /><tool file="data_source/modmine.xml" /><tool file="data_source/ratmine.xml" />
+ <tool file="data_source/yeastmine.xml" /><tool file="data_source/worm_modencode.xml" /><tool file="data_source/wormbase.xml" /><tool file="data_source/wormbase_test.xml" />
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.
1
0
commit/galaxy-central: dannon: workflows: When running a workflow, filter possible values for Input Dataset steps to datatypes that are valid for next connected steps, instead of just using 'data'.
by Bitbucket 01 Feb '11
by Bitbucket 01 Feb '11
01 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/ea364eb4375f/
changeset: r4973:ea364eb4375f
user: dannon
date: 2011-02-01 19:35:46
summary: workflows: When running a workflow, filter possible values for Input Dataset steps to datatypes that are valid for next connected steps, instead of just using 'data'.
affected #: 2 files (528 bytes)
--- a/lib/galaxy/workflow/modules.py Tue Feb 01 13:32:02 2011 -0500
+++ b/lib/galaxy/workflow/modules.py Tue Feb 01 13:35:46 2011 -0500
@@ -129,9 +129,9 @@
def update_state( self, incoming ):
self.state['name'] = incoming.get( 'name', 'Input Dataset' )
- def get_runtime_inputs( self ):
+ def get_runtime_inputs( self, filter_set=['data'] ):
label = self.state.get( "name", "Input Dataset" )
- return dict( input=DataToolParameter( None, Element( "param", name="input", label=label, type="data", format="data" ) ) )
+ return dict( input=DataToolParameter( None, Element( "param", name="input", label=label, type="data", format=', '.join(filter_set) ) ) )
def get_runtime_state( self ):
state = DefaultToolState()
state.inputs = dict( input=None )
--- a/templates/workflow/run.mako Tue Feb 01 13:32:02 2011 -0500
+++ b/templates/workflow/run.mako Tue Feb 01 13:35:46 2011 -0500
@@ -315,7 +315,17 @@
% endif
</div><div class="toolFormBody">
- ${do_inputs( module.get_runtime_inputs(), step.state.inputs, errors.get( step.id, dict() ), "", step )}
+ <%
+ # Filter possible inputs to data types that are valid for subsequent steps
+ type_filter = []
+ for oc in step.output_connections:
+ for ic in oc.input_step.module.get_data_inputs():
+ if 'extensions' in ic and ic['name'] == oc.input_name:
+ type_filter += ic['extensions']
+ if not type_filter:
+ type_filter = ['data']
+ %>
+ ${do_inputs( module.get_runtime_inputs(type_filter), step.state.inputs, errors.get( step.id, dict() ), "", step )}
</div></div>
%endif
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.
1
0