details: http://www.bx.psu.edu/hg/galaxy/rev/370777a0693f changeset: 3750:370777a0693f user: Kanwei Li <kanwei@gmail.com> date: Thu May 06 12:30:54 2010 -0400 description: trackster: - Custom dbkeys now create new HDA and copies info in - Fix track reordering for all browsers - Fix track deletion - Fix BAM display diffstat: lib/galaxy/visualization/tracks/data/bam.py | 6 ++-- lib/galaxy/web/controllers/tracks.py | 35 ++++++++++++++++++---------- lib/galaxy/web/controllers/user.py | 19 +++++++++++++-- static/scripts/packed/trackster.js | 2 +- static/scripts/trackster.js | 28 ++++++++++++++--------- templates/tracks/browser.mako | 4 +-- templates/user/dbkeys.mako | 25 +++++++++++--------- tool_conf.xml.main | 1 + 8 files changed, 75 insertions(+), 45 deletions(-) diffs (294 lines): diff -r e7d91d58f4ad -r 370777a0693f lib/galaxy/visualization/tracks/data/bam.py --- a/lib/galaxy/visualization/tracks/data/bam.py Thu May 06 12:11:47 2010 -0400 +++ b/lib/galaxy/visualization/tracks/data/bam.py Thu May 06 12:30:54 2010 -0400 @@ -10,7 +10,7 @@ import logging log = logging.getLogger(__name__) -MAX_VALS = 50 # only display first MAX_VALS datapoints +MAX_VALS = 5000 # only display first MAX_VALS datapoints class BamDataProvider( object ): """ @@ -36,7 +36,7 @@ if chrom.startswith( 'chr' ): try: data = bamfile.fetch( start=start, end=end, reference=chrom[3:] ) - except: + except ValueError: return None else: return None @@ -74,4 +74,4 @@ results.append( [ qname, start, end, read['seq'], r1, r2 ] ) bamfile.close() - return results \ No newline at end of file + return { 'data': results, 'message': message } diff -r e7d91d58f4ad -r 370777a0693f lib/galaxy/web/controllers/tracks.py --- a/lib/galaxy/web/controllers/tracks.py Thu May 06 12:11:47 2010 -0400 +++ b/lib/galaxy/web/controllers/tracks.py Thu May 06 12:30:54 2010 -0400 @@ -99,7 +99,7 @@ user = trans.get_user() if 'dbkeys' in user.preferences: user_keys = from_json_string( user.preferences['dbkeys'] ) - + dbkeys = [ (k, v) for k, v in trans.db_builds if k in self.len_files or k in user_keys ] return trans.fill_template( "tracks/new_browser.mako", dbkeys=dbkeys ) @@ -197,21 +197,24 @@ """ Helper method that returns chrom lengths for a given user and dbkey. """ + len_file = None + len_ds = None # If there is any dataset in the history of extension `len`, this will use it if 'dbkeys' in user.preferences: user_keys = from_json_string( user.preferences['dbkeys'] ) if dbkey in user_keys: - return user_keys[dbkey]['chroms'] + len_file = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( user_keys[dbkey]['len'] ).file_name - db_manifest = trans.db_dataset_for( dbkey ) - if not db_manifest: - db_manifest = os.path.join( trans.app.config.tool_data_path, 'shared','ucsc','chrom', "%s.len" % dbkey ) - else: - db_manifest = db_manifest.file_name + if not len_file: + len_ds = trans.db_dataset_for( dbkey ) + if not len_ds: + len_file = os.path.join( trans.app.config.tool_data_path, 'shared','ucsc','chrom', "%s.len" % dbkey ) + else: + len_file = len_ds.file_name manifest = {} - if not os.path.exists( db_manifest ): + if not os.path.exists( len_file ): return None - for line in open( db_manifest ): + for line in open( len_file ): if line.startswith("#"): continue line = line.rstrip("\r\n") fields = line.split("\t") @@ -240,7 +243,9 @@ # Need to check states again for the converted version if converted_dataset and converted_dataset.state == model.Dataset.states.ERROR: - return messages.ERROR + job_id = trans.sa_session.query( trans.app.model.JobToOutputDatasetAssociation ).filter_by( dataset_id=converted_dataset.id ).first().job_id + job = trans.sa_session.query( trans.app.model.Job ).get( job_id ) + return { 'kind': messages.ERROR, 'message': job.stderr } if not converted_dataset or converted_dataset.state != model.Dataset.states.OK: return messages.PENDING @@ -256,13 +261,17 @@ extra_info = "no_detail" else: frequencies, max_v, avg_v, delta = summary - return { "dataset_type": data_sources['index'], "data": frequencies, "max": max_v, "avg": avg_v, "delta": delta } + return { 'dataset_type': data_sources['index'], 'data': frequencies, 'max': max_v, 'avg': avg_v, 'delta': delta } dataset_type = data_sources['data'] data_provider = dataset_type_to_data_provider[ dataset_type ]( dataset.get_converted_dataset(trans, dataset_type), dataset ) - + data = data_provider.get_data( chrom, low, high, **kwargs ) - return { "dataset_type": dataset_type, "extra_info": extra_info, "data": data } + message = None + if isinstance(data, dict) and 'message' in data: + message = data['message'] + data = data['data'] + return { 'dataset_type': dataset_type, 'extra_info': extra_info, 'data': data, 'message': message } @web.expose def list_tracks( self, trans, hid ): diff -r e7d91d58f4ad -r 370777a0693f lib/galaxy/web/controllers/user.py --- a/lib/galaxy/web/controllers/user.py Thu May 06 12:11:47 2010 -0400 +++ b/lib/galaxy/web/controllers/user.py Thu May 06 12:30:54 2010 -0400 @@ -902,7 +902,18 @@ if not name or not key or not len_text: message = "You must specify values for all the fields." else: - chrom_dict = {} + # Create new len file + new_len = trans.app.model.HistoryDatasetAssociation( extension="len", create_dataset=True, sa_session=trans.sa_session ) + trans.sa_session.add( new_len ) + new_len.name = name + new_len.visible = False + new_len.history_id = trans.get_history().id + new_len.state = trans.app.model.Job.states.OK + new_len.info = "custom build .len file" + trans.sa_session.flush() + + counter = 0 + f = open(new_len.file_name, "w") for line in len_text.split("\n"): lst = line.strip().split() if not lst or len(lst) < 2: @@ -914,8 +925,10 @@ except ValueError: lines_skipped += 1 continue - chrom_dict[chrom] = length - dbkeys[key] = { "name": name, "chroms": chrom_dict } + counter += 1 + f.write("%s\t%s\n" % (chrom, length)) + f.close() + dbkeys[key] = { "name": name, "len": new_len.id, "count": counter } user.preferences['dbkeys'] = to_json_string(dbkeys) trans.sa_session.flush() diff -r e7d91d58f4ad -r 370777a0693f static/scripts/packed/trackster.js --- a/static/scripts/packed/trackster.js Thu May 06 12:11:47 2010 -0400 +++ b/static/scripts/packed/trackster.js Thu May 06 12:30:54 2010 -0400 @@ -1,1 +1,1 @@ -var DEBUG=false;var DENSITY=200,FEATURE_LEVELS=10,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_LOADING="Loading data...",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=30,CACHED_DATA=5,CONTEXT=$("<canvas></canvas>").get(0).getContext("2d"),RIGHT_STRAND,LEFT_STRAND;var right_img=new Image();right_img.src="/static/images/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src="/static/images/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="/static/images/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="/static/images/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}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.key_ary.splice(a,1);this.key_ary.push(b)}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},clear:function(){this.obj_cache={};this.key_ary=[]}});var Drawer=function(){};$.extend(Drawer.prototype,{intensity:function(b,a,c){},});drawer=new Drawer();var View=function(b,d,c,a){this.vis_id=c;this.dbkey=a;this.title=d;this.chrom=b;this.tracks=[];this.label_tracks=[];this.m! ax_low=0;this.max_high=0;this.center=(this.max_high-this.max_low)/2;th is.zoom_factor=3;this.zoom_level=0;this.track_id_counter=0};$.extend(View.prototype,{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);this.track_id_counter+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[a]},update_options:function(){var b=$("ul#sortable-ul").sortable("toArray");var d=[];var c=$("#viewport > div").sort(function(g,f){return b.indexOf($(g).attr("id"))>b.indexOf($(f).attr("id"))});$("#viewport > div").remove();$("#viewport").html(c);for(var e in view.tracks){var a=view.tracks[e];if(a.update_options){a.update_options(e)}}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.center=this.center=(this.max_high-this.max_low)/2;this.zoom_level=0;$(".yaxislabel").remove()},redraw:function(f){this.span=this.max_high-this.max! _low;var d=this.span/Math.pow(this.zoom_factor,this.zoom_level),b=this.center-(d/2),e=b+d;if(b<0){b=0;e=b+d}else{if(e>this.max_high){e=this.max_high;b=e-d}}this.low=Math.floor(b);this.high=Math.ceil(e);this.center=Math.round(this.low+(this.high-this.low)/2);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))));$("#overview-box").css({left:(this.low/this.span)*$("#overview-viewport").width(),width:Math.max(12,((this.high-this.low)/this.span)*$("#overview-viewport").width())}).show();$("#low").val(commatize(this.low));$("#high").val(commatize(this.high));if(!f){for(var c=0,a=this.tracks.length;c<a;c++){if(this.tracks[c].enabled){this.tracks[c].draw()}}for(var c=0,a=this.label_tracks.length;c<a;c++){this.label_tracks[c].draw()}}},zoom_in:function(a,b){if(this.max_high===0||this.high-this.low<30){return}if(a){this.center=! a/b.width()*(this.high-this.low)+this.low}this.zoom_level+=1;this.redr aw()},zoom_out:function(){if(this.max_high===0){return}if(this.zoom_level<=0){this.zoom_level=0;return}this.zoom_level-=1;this.redraw()}});var Track=function(a,b){this.name=a;this.parent_element=b;this.init_global()};$.extend(Track.prototype,{init_global:function(){this.header_div=$("<div class='track-header'>").text(this.name);this.content_div=$("<div class='track-content'>");this.container_div=$("<div></div>").addClass("track").append(this.header_div).append(this.content_div);this.parent_element.append(this.container_div)},init_each:function(c,b){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.content_div.css("height","30px");if(!a.content_div.text()){a.content_div.text(DATA_LOADING)}a.container_div.removeClass("nodata error pending");if(a.view.chrom){$.getJSON(data_url,c,function(d){if(!d||d==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR)}else{if(d==="no converter"){a.container_div.addClass("error");a.cont! ent_div.text(DATA_NOCONVERTER)}else{if(d.data&&d.data.length===0||d.data===null){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(d==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},5000)}else{a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;b(d);a.draw()}}}}})}else{a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}}});var TiledTrack=function(){};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(){var i=this.view.low,e=this.view.high,f=e-i,d=this.view.resolution;if(DEBUG){$("#debug").text(d+" "+this.view.zoom_res)}var k=$("<div style='position: relative;'></div>"),l=this.content_div.width()/f,h;this.content_div.children(":first").remove();this.content_div.append(k),this.max_height=0;var a=Math.floor(i/d/DENSITY);while((a*DENSITY*d)<e){var j=this.content_div.width()+"_"+this.view.zoom_level+"_"+a;var c=this.tile_cache.get(j);if(c! ){var g=a*DENSITY*d;var b=(g-i)*l;if(this.left_offset){b-=this.left_of fset}c.css({left:b});k.append(c);this.max_height=Math.max(this.max_height,c.height());this.content_div.css("height",this.max_height+"px")}else{this.delayed_draw(this,j,i,e,a,d,k,l)}a+=1}},delayed_draw:function(c,e,a,f,b,d,g,h){setTimeout(function(){if(!(a>c.view.high||f<c.view.low)){tile_element=c.draw_tile(d,b,g,h);if(tile_element){c.tile_cache.set(e,tile_element);c.max_height=Math.max(c.max_height,tile_element.height());c.content_div.css("height",c.max_height+"px")}}},50)}});var LabelTrack=function(a){Track.call(this,null,a);this.track_type="LabelTrack";this.hidden=true;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 LineTrack=function(c,a,b){this.track_type="LineTrack";Track.call(this,c,$("#viewport"));TiledTrack.call(this);this.height_px=100;this.container_div.addClass("line-track");this.dataset_id=a;this.data_cache=new Cache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={min_value:undefined,max_value:undefined,mode:"Line"};if(b.min_value!==undefined){this.prefs.min_value=b.min_value}if(b.max_value!==undefined){this.prefs.max_value=b.max_value}if(b.mode!==undefined){this.prefs.mode=b.mode}};$.extend(LineTrack.prototype,TiledTrack.prototype,{init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;this.init_each({stats:true,chrom:a.view.chrom,low:null,high:null,dataset_id:a.dataset_id},function(c){data=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=data.min;a.prefs.ma! x_value=data.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#t rack_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=data.total_frequency;$("#linetrack_"+b+"_minval").remove();$("#linetrack_"+b+"_maxval").remove();var e=$("<div></div>").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(a.prefs.min_value);var d=$("<div></div>").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(a.prefs.max_value);d.css({position:"relative",top:"25px"});d.prependTo(a.container_div);e.css({position:"relative",top:a.height_px+55+"px"});e.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: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){data=g.data;c.data_cache.set(e,data);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o! ,q,c,e){if(this.vertical_range===undefined){return}var r=q*DENSITY*o,a=DENSITY*o,b=$("<canvas class='tile'></canvas>"),u=o+"_"+q;if(this.data_cache.get(u)===undefined){this.get_data(o,q);return}var t=this.data_cache.get(u);if(t===null){return}b.css({position:"absolute",top:0,left:(r-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"),k=false,l=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,s=this.total_frequency,d=this.height_px;n.beginPath();if(t.length>1){var f=Math.ceil((t[1][0]-t[0][0])*e)}else{var f=10}for(var p=0;p<t.length;p++){var j=t[p][0]-r;var h=t[p][1];if(this.prefs.mode=="Intensity"){if(h===null){continue}j=j*e;if(h<=l){h=l}else{if(h>=g){h=g}}h=255-Math.floor((h-l)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(j,0,f,this.height_px)}else{if(h===null){k=false;continue}else{j=j*e;if(h<=l){h=l}else{if(h>=g){h=g}}h=Math.round(d-(h-l)/m*d);if(k){n.lineTo(j,h)}else{n.moveTo(j,h);k=! true}}}}n.stroke();c.append(b);return b},gen_options:function(n){var a =$("<div></div>").addClass("form-row");var h="track_"+n+"_minval",k="track_"+n+"_maxval",e="track_"+n+"_mode",l=$("<label></label>").attr("for",h).text("Min value:"),b=(this.prefs.min_value===undefined?"":this.prefs.min_value),m=$("<input></input>").attr("id",h).val(b),g=$("<label></label>").attr("for",k).text("Max value:"),j=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",k).val(j),d=$("<label></label>").attr("for",e).text("Display mode:"),i=(this.prefs.mode===undefined?"Line":this.prefs.mode),c=$('<select id="'+e+'"><option value="Line" id="mode_Line">Line</option><option value="Intensity" id="mode_Intensity">Intensity</option></select>');c.children("#mode_"+i).attr("selected","selected");return a.append(l).append(m).append(g).append(f).append(d).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_mode option:selected").val();if(a!==this.prefs.min_value||c!! ==this.prefs.max_value||b!=this.prefs.mode){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.mode=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(c,a,b){this.track_type="FeatureTrack";Track.call(this,c,$("#viewport"));TiledTrack.call(this);this.height_px=100;this.container_div.addClass("feature-track");this.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.default_font="9px Monaco, Lucida Console, monospace";this.left_offset=200;this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new Cache(20);this.prefs={block_color:"black",label_color:"black",show_counts:false};if(b.block_color!==undefine! d){this.prefs.block_color=b.block_color}if(b.label_color!==undefined){ this.prefs.label_color=b.label_color}if(b.show_counts!==undefined){this.prefs.show_counts=b.show_counts}};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{init:function(){var a=this,b=a.view.max_low+"_"+a.view.max_high;this.init_each({low:a.view.max_low,high:a.view.max_high,dataset_id:a.dataset_id,chrom:a.view.chrom,resolution:this.view.resolution},function(c){a.data_cache.set(b,c);a.draw()})},get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(data_url,{chrom:b.view.chrom,low:a,high:d,dataset_id:b.dataset_id,resolution:this.view.resolution},function(e){b.data_cache.set(c,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,g,c){if(!this.inc_slots[a]){this.inc_slots[a]={};this.inc_slots[a].w_scale=1/a;this.s_e_by_tile[a]={}}var m=this.inc_slots[a].w_scale,v=[],h=0,b=$("<canvas></canvas>").get(0).getContext("2d"),n=this.view.max_low;var d,f,x=[];for(var s=0,t=g.length;s<t;s++){var e=g[s],l=e[0];if(this.inc_slots[! a][l]!==undefined){h=Math.max(h,this.inc_slots[a][l]);x.push(this.inc_slots[a][l])}else{v.push(s)}}for(var s=0,t=v.length;s<t;s++){var e=g[v[s]];l=e[0],feature_start=e[1],feature_end=e[2],feature_name=e[3];d=Math.floor((feature_start-n)*m);f=Math.ceil((feature_end-n)*m);if(!c){var p=b.measureText(feature_name).width;if(d-p<0){f+=p}else{d-=p}}var r=0;while(true){var o=true;if(this.s_e_by_tile[a][r]!==undefined){for(var q=0,w=this.s_e_by_tile[a][r].length;q<w;q++){var u=this.s_e_by_tile[a][r][q];if(f>u[0]&&d<u[1]){o=false;break}}}if(o){if(this.s_e_by_tile[a][r]===undefined){this.s_e_by_tile[a][r]=[]}this.s_e_by_tile[a][r].push([d,f]);this.inc_slots[a][l]=r;h=Math.max(h,r);break}r++}}return h},rect_or_text:function(n,o,g,f,m,b,d,k,e,i){n.textAlign="center";var j=Math.round(o/2);if(d!==undefined&&o>g){n.fillStyle="#555";n.fillRect(k,i+1,e,9);n.fillStyle="#eee";for(var h=0,l=d.length;h<l;h++){if(b+h>=f&&b+h<=m){var a=Math.floor(Math.max(0,(b+h-f)*o));n.fillText(d[h],a+this.left_! offset+j,i+9)}}}else{n.fillStyle="#555";n.fillRect(k,i+4,e,3)}},draw_t ile:function(W,h,m,ak){var D=h*DENSITY*W,ac=(h+1)*DENSITY*W,C=DENSITY*W;var aj,r;var ad=D+"_"+ac;var w=this.data_cache.get(ad);if(w===undefined){this.data_queue[[D,ac]]=true;this.get_data(D,ac);return}if(w.dataset_type==="summary_tree"){r=30}else{var U=(w.extra_info==="no_detail");var al=(U?this.vertical_nodetail_px:this.vertical_detail_px);r=this.incremental_slots(this.view.zoom_res,w.data,U)*al+15;m.parent().css("height",Math.max(this.height_px,r)+"px");aj=this.inc_slots[this.view.zoom_res]}var a=Math.ceil(C*ak),K=$("<canvas class='tile'></canvas>"),Y=this.prefs.label_color,f=this.prefs.block_color,O=this.left_offset;K.css({position:"absolute",top:0,left:(D-this.view.low)*ak-O});K.get(0).width=a+O;K.get(0).height=r;var z=K.get(0).getContext("2d"),ah=z.measureText("A").width;z.fillStyle=this.prefs.block_color;z.font=this.default_font;z.textAlign="right";if(w.dataset_type=="summary_tree"){var J,G=55,ab=255-G,g=ab*2/3,Q=w.data,B=w.max,l=w.avg;if(Q.length>2){var b=Math.ceil((Q! [1][0]-Q[0][0])*ak)}else{var b=50}for(var af=0,v=Q.length;af<v;af++){var S=Math.ceil((Q[af][0]-D)*ak);var R=Q[af][1];if(!R){continue}J=Math.floor(ab-(R/B)*ab);z.fillStyle="rgb("+J+","+J+","+J+")";z.fillRect(S+O,0,b,20);if(this.prefs.show_counts){if(J>g){z.fillStyle="black"}else{z.fillStyle="#ddd"}z.textAlign="center";z.fillText(Q[af][1],S+O+(b/2),12)}}m.append(K);return K}var ai=w.data;var ae=0;for(var af=0,v=ai.length;af<v;af++){var L=ai[af],I=L[0],ag=L[1],T=L[2],E=L[3];if(ag<=ac&&T>=D){var V=Math.floor(Math.max(0,(ag-D)*ak)),A=Math.ceil(Math.min(a,Math.max(0,(T-D)*ak))),P=aj[I]*al;if(w.dataset_type==="bai"){z.fillStyle="#555";if(L[4] instanceof Array){var s=Math.floor(Math.max(0,(L[4][0]-D)*ak)),H=Math.ceil(Math.min(a,Math.max(0,(L[4][1]-D)*ak))),q=Math.floor(Math.max(0,(L[5][0]-D)*ak)),o=Math.ceil(Math.min(a,Math.max(0,(L[5][1]-D)*ak)));if(L[4][1]>=D&&L[4][0]<=ac){this.rect_or_text(z,ak,ah,D,ac,L[4][0],L[4][2],s+O,H-s,P)}if(L[5][1]>=D&&L[5][0]<=ac){this.rect_or_text(z,ak! ,ah,D,ac,L[5][0],L[5][2],q+O,o-q,P)}if(q>H){z.fillStyle="#999";z.fillR ect(H+O,P+5,q-H,1)}}else{z.fillStyle="#555";this.rect_or_text(z,ak,ah,D,ac,ag,E,V+O,A-V,P)}if(!U&&ag>D){z.fillStyle=this.prefs.label_color;if(h===0&&V-z.measureText(E).width<0){z.textAlign="left";z.fillText(I,A+2+O,P+8)}else{z.textAlign="right";z.fillText(I,V-2+O,P+8)}z.fillStyle="#555"}}else{if(w.dataset_type==="interval_index"){if(U){z.fillRect(V+O,P+5,A-V,1)}else{var u=L[4],N=L[5],X=L[6],e=L[7];var t,Z,F=null,am=null;if(N&&X){F=Math.floor(Math.max(0,(N-D)*ak));am=Math.ceil(Math.min(a,Math.max(0,(X-D)*ak)))}if(E!==undefined&&ag>D){z.fillStyle=Y;if(h===0&&V-z.measureText(E).width<0){z.textAlign="left";z.fillText(E,A+2+O,P+8)}else{z.textAlign="right";z.fillText(E,V-2+O,P+8)}z.fillStyle=f}if(e){if(u){if(u=="+"){z.fillStyle=RIGHT_STRAND}else{if(u=="-"){z.fillStyle=LEFT_STRAND}}z.fillRect(V+O,P,A-V,10);z.fillStyle=f}for(var ad=0,d=e.length;ad<d;ad++){var n=e[ad],c=Math.floor(Math.max(0,(n[0]-D)*ak)),M=Math.ceil(Math.min(a,Math.max((n[1]-D)*ak)));if(c>M){continue}t=5;Z=3;z.fillR! ect(c+O,P+Z,M-c,t);if(F!==undefined&&!(c>am||M<F)){t=9;Z=1;var aa=Math.max(c,F),p=Math.min(M,am);z.fillRect(aa+O,P+Z,p-aa,t)}}}else{t=9;Z=1;z.fillRect(V+O,P+Z,A-V,t);if(L.strand){if(L.strand=="+"){z.fillStyle=RIGHT_STRAND_INV}else{if(L.strand=="-"){z.fillStyle=LEFT_STRAND_INV}}z.fillRect(V+O,P,A-V,10);z.fillStyle=prefs.block_color}}}}}ae++}}m.append(K);return K},gen_options:function(i){var a=$("<div></div>").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label></label>").attr("for",e).text("Block color:"),l=$("<input></input>").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label></label>").attr("for",j).text("Text color:"),h=$("<input></input>").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label></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></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(c,a,b){FeatureTrack.call(this,c,a,b);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{}); \ No newline at end of file +var DEBUG=false;var DENSITY=200,FEATURE_LEVELS=10,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_LOADING="Loading data...",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=30,CACHED_DATA=5,CONTEXT=$("<canvas></canvas>").get(0).getContext("2d"),RIGHT_STRAND,LEFT_STRAND;var right_img=new Image();right_img.src="/static/images/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src="/static/images/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="/static/images/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="/static/images/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}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.key_ary.splice(a,1);this.key_ary.push(b)}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},clear:function(){this.obj_cache={};this.key_ary=[]}});var Drawer=function(){};$.extend(Drawer.prototype,{intensity:function(b,a,c){},});drawer=new Drawer();var View=function(b,d,c,a){this.vis_id=c;this.dbkey=a;this.title=d;this.chrom=b;this.tracks=[];this.label_tracks=[];this.! max_low=0;this.max_high=0;this.center=(this.max_high-this.max_low)/2;t his.zoom_factor=3;this.zoom_level=0;this.track_id_counter=0};$.extend(View.prototype,{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);this.track_id_counter+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks.splice(this.tracks.indexOf(a))},update_options:function(){var b=$("ul#sortable-ul").sortable("toArray");for(var c in b){var e=b[c].split("_li")[0].split("track_")[1];$("#viewport").append($("#track_"+e))}for(var d in view.tracks){var a=view.tracks[d];if(a.update_options){a.update_options(d)}}},reset:function(){this.low=this.max_low;this.high=this.max_high;this.center=this.center=(this.max_high-this.max_low)/2;this.zoom_level=0;$(".yaxislabel").remove()},redraw:function(f){this.span=this.max_high-this.max_low;var d=this.span/Math.pow(this.zoom_fa! ctor,this.zoom_level),b=this.center-(d/2),e=b+d;if(b<0){b=0;e=b+d}else{if(e>this.max_high){e=this.max_high;b=e-d}}this.low=Math.floor(b);this.high=Math.ceil(e);this.center=Math.round(this.low+(this.high-this.low)/2);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))));$("#overview-box").css({left:(this.low/this.span)*$("#overview-viewport").width(),width:Math.max(12,((this.high-this.low)/this.span)*$("#overview-viewport").width())}).show();$("#low").val(commatize(this.low));$("#high").val(commatize(this.high));if(!f){for(var c=0,a=this.tracks.length;c<a;c++){if(this.tracks[c].enabled){this.tracks[c].draw()}}for(var c=0,a=this.label_tracks.length;c<a;c++){this.label_tracks[c].draw()}}},zoom_in:function(a,b){if(this.max_high===0||this.high-this.low<30){return}if(a){this.center=a/b.width()*(this.high-this.low)+this.low}! this.zoom_level+=1;this.redraw()},zoom_out:function(){if(this.max_high ===0){return}if(this.zoom_level<=0){this.zoom_level=0;return}this.zoom_level-=1;this.redraw()}});var Track=function(a,b){this.name=a;this.parent_element=b;this.init_global()};$.extend(Track.prototype,{init_global:function(){this.header_div=$("<div class='track-header'>").text(this.name);this.content_div=$("<div class='track-content'>");this.container_div=$("<div></div>").addClass("track").append(this.header_div).append(this.content_div);this.parent_element.append(this.container_div)},init_each:function(c,b){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.content_div.css("height","30px");if(!a.content_div.text()){a.content_div.text(DATA_LOADING)}a.container_div.removeClass("nodata error pending");if(a.view.chrom){$.getJSON(data_url,c,function(d){if(!d||d==="error"||d.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(d.message){var f=a.view.tracks.indexOf(a);var e=$("<a href='javascript:void(0);'></a>").a! ttr("id",f+"_error");e.text("Click to view error");$("#"+f+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+d.message+"</pre>",{Close:hide_modal})});a.content_div.append(e)}}else{if(d==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(d.data!==undefined&&(d.data===null||d.data.length===0)){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(d==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},5000)}else{a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;b(d);a.draw()}}}}})}else{a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}}});var TiledTrack=function(){};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(){var i=this.view.low,e=this.view.high,f=e-i,d=this.view.resolution;if(DEBUG){$("#debug").text(d+" "+this.view.zoom_res)}var k=$("<div style='position: relative;'>! </div>"),l=this.content_div.width()/f,h;this.content_div.children(":fi rst").remove();this.content_div.append(k),this.max_height=0;var a=Math.floor(i/d/DENSITY);while((a*DENSITY*d)<e){var j=this.content_div.width()+"_"+this.view.zoom_level+"_"+a;var c=this.tile_cache.get(j);if(c){var g=a*DENSITY*d;var b=(g-i)*l;if(this.left_offset){b-=this.left_offset}c.css({left:b});k.append(c);this.max_height=Math.max(this.max_height,c.height());this.content_div.css("height",this.max_height+"px")}else{this.delayed_draw(this,j,i,e,a,d,k,l)}a+=1}},delayed_draw:function(c,e,a,f,b,d,g,h){setTimeout(function(){if(!(a>c.view.high||f<c.view.low)){tile_element=c.draw_tile(d,b,g,h);if(tile_element){c.tile_cache.set(e,tile_element);c.max_height=Math.max(c.max_height,tile_element.height());c.content_div.css("height",c.max_height+"px")}}},50)}});var LabelTrack=function(a){Track.call(this,null,a);this.track_type="LabelTrack";this.hidden=true;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 LineTrack=function(c,a,b){this.track_type="LineTrack";Track.call(this,c,$("#viewport"));TiledTrack.call(this);this.height_px=100;this.dataset_id=a;this.data_cache=new Cache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={min_value:undefined,max_value:undefined,mode:"Line"};if(b.min_value!==undefined){this.prefs.min_value=b.min_value}if(b.max_value!==undefined){this.prefs.max_value=b.max_value}if(b.mode!==undefined){this.prefs.mode=b.mode}};$.extend(LineTrack.prototype,TiledTrack.prototype,{init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=unde! fined;this.init_each({stats:true,chrom:a.view.chrom,low:null,high:null ,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");data=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=data.min;a.prefs.max_value=data.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=data.total_frequency;$("#linetrack_"+b+"_minval").remove();$("#linetrack_"+b+"_maxval").remove();var e=$("<div></div>").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(a.prefs.min_value);var d=$("<div></div>").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(a.prefs.max_value);d.css({position:"relative",top:"25px",left:"10px"});d.prependTo(a.container_div);e.css({position:"relative",top:a.height_px+55+"px",left:"10px"});e.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: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){data=g.data;c.data_cache.set(e,data);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(p,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*p,a=DENSITY*p,b=$("<canvas class='tile'></canvas>"),v=p+"_"+r;if(this.data_cache.get(v)===undefined){this.get_data(p,r);return}var j=this.data_cache.get(v);if(j===null){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 o=b.get(0).getContext("2d"),k=false,l=this.prefs.min_value,g=this.prefs.max_value,n=this.vertical_range,t=this.total_frequency,d=this.height_px,m=this.prefs.mode;o.beginPath();if(data.length>1){var f=Math.ceil((data[1][0]-data[0][0])*e)}else{var f=10}var u,h;for(var q=0;q<data.length;q++){u=(data[q][0]-s)*e;h=data[q][1]! ;if(m=="Intensity"){if(h===null){continue}if(h<=l){h=l}else{if(h>=g){h =g}}h=255-Math.floor((h-l)/n*255);o.fillStyle="rgb("+h+","+h+","+h+")";o.fillRect(u,0,f,this.height_px)}else{if(h===null){if(k&&m==="Filled"){o.lineTo(u,d)}k=false;continue}else{if(h<=l){h=l}else{if(h>=g){h=g}}h=Math.round(d-(h-l)/n*d);if(k){o.lineTo(u,h)}else{k=true;if(m==="Filled"){o.moveTo(u,d);o.lineTo(u,h)}else{o.moveTo(u,h)}}}}}if(m==="Filled"){if(k){o.lineTo(u,d)}o.fill()}else{o.stroke()}c.append(b);return b},gen_options:function(n){var a=$("<div></div>").addClass("form-row");var h="track_"+n+"_minval",k="track_"+n+"_maxval",e="track_"+n+"_mode",l=$("<label></label>").attr("for",h).text("Min value:"),b=(this.prefs.min_value===undefined?"":this.prefs.min_value),m=$("<input></input>").attr("id",h).val(b),g=$("<label></label>").attr("for",k).text("Max value:"),j=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",k).val(j),d=$("<label></label>").attr("for",e).text("Display mode:"),i=(this.prefs.mode===undefined?"Line":this.prefs.mo! de),c=$('<select id="'+e+'"><option value="Line" id="mode_Line">Line</option><option value="Filled" id="mode_Filled">Filled</option><option value="Intensity" id="mode_Intensity">Intensity</option></select>');c.children("#mode_"+i).attr("selected","selected");return a.append(l).append(m).append(g).append(f).append(d).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_mode option:selected").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!=this.prefs.mode){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.mode=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(c,a,b){this.track_type="FeatureTrack";Track.call(this,c,$("#viewport"));TiledTrack.call(this);this.height_px=100! ;this.container_div.addClass("feature-track");this.dataset_id=a;this.z o_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.default_font="9px Monaco, Lucida Console, monospace";this.left_offset=200;this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new Cache(20);this.prefs={block_color:"black",label_color:"black",show_counts:false};if(b.block_color!==undefined){this.prefs.block_color=b.block_color}if(b.label_color!==undefined){this.prefs.label_color=b.label_color}if(b.show_counts!==undefined){this.prefs.show_counts=b.show_counts}};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{init:function(){var a=this,b=a.view.max_low+"_"+a.view.max_high;this.init_each({low:a.view.max_low,high:a.view.max_high,dataset_id:a.dataset_id,chrom:a.view.chrom,resolution:this.view.resolution},function(c){a.data_cache.set(b,c);a.draw()})},get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=tr! ue;$.getJSON(data_url,{chrom:b.view.chrom,low:a,high:d,dataset_id:b.dataset_id,resolution:this.view.resolution},function(e){b.data_cache.set(c,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,g,c){if(!this.inc_slots[a]){this.inc_slots[a]={};this.inc_slots[a].w_scale=1/a;this.s_e_by_tile[a]={}}var m=this.inc_slots[a].w_scale,v=[],h=0,b=$("<canvas></canvas>").get(0).getContext("2d"),n=this.view.max_low;var d,f,x=[];for(var s=0,t=g.length;s<t;s++){var e=g[s],l=e[0];if(this.inc_slots[a][l]!==undefined){h=Math.max(h,this.inc_slots[a][l]);x.push(this.inc_slots[a][l])}else{v.push(s)}}for(var s=0,t=v.length;s<t;s++){var e=g[v[s]];l=e[0],feature_start=e[1],feature_end=e[2],feature_name=e[3];d=Math.floor((feature_start-n)*m);f=Math.ceil((feature_end-n)*m);if(!c){var p=b.measureText(feature_name).width;if(d-p<0){f+=p}else{d-=p}}var r=0;while(true){var o=true;if(this.s_e_by_tile[a][r]!==undefined){for(var q=0,w=this.s_e_by_tile[a][r].length;q<w;q++){var u=this.s_e_by! _tile[a][r][q];if(f>u[0]&&d<u[1]){o=false;break}}}if(o){if(this.s_e_by _tile[a][r]===undefined){this.s_e_by_tile[a][r]=[]}this.s_e_by_tile[a][r].push([d,f]);this.inc_slots[a][l]=r;h=Math.max(h,r);break}r++}}return h},rect_or_text:function(n,o,g,f,m,b,d,k,e,i){n.textAlign="center";var j=Math.round(o/2);if(d!==undefined&&o>g){n.fillStyle="#555";n.fillRect(k,i+1,e,9);n.fillStyle="#eee";for(var h=0,l=d.length;h<l;h++){if(b+h>=f&&b+h<=m){var a=Math.floor(Math.max(0,(b+h-f)*o));n.fillText(d[h],a+this.left_offset+j,i+9)}}}else{n.fillStyle="#555";n.fillRect(k,i+4,e,3)}},draw_tile:function(W,h,m,ak){var D=h*DENSITY*W,ac=(h+1)*DENSITY*W,C=DENSITY*W;var aj,r;var ad=D+"_"+ac;var w=this.data_cache.get(ad);if(w===undefined){this.data_queue[[D,ac]]=true;this.get_data(D,ac);return}if(w.dataset_type==="summary_tree"){r=30}else{var U=(w.extra_info==="no_detail");var al=(U?this.vertical_nodetail_px:this.vertical_detail_px);r=this.incremental_slots(this.view.zoom_res,w.data,U)*al+15;m.parent().css("height",Math.max(this.height_px,r)+"px");aj=this.inc_slots[this.vi! ew.zoom_res]}var a=Math.ceil(C*ak),K=$("<canvas class='tile'></canvas>"),Y=this.prefs.label_color,f=this.prefs.block_color,O=this.left_offset;K.css({position:"absolute",top:0,left:(D-this.view.low)*ak-O});K.get(0).width=a+O;K.get(0).height=r;var z=K.get(0).getContext("2d"),ah=z.measureText("A").width;z.fillStyle=this.prefs.block_color;z.font=this.default_font;z.textAlign="right";if(w.dataset_type=="summary_tree"){var J,G=55,ab=255-G,g=ab*2/3,Q=w.data,B=w.max,l=w.avg;if(Q.length>2){var b=Math.ceil((Q[1][0]-Q[0][0])*ak)}else{var b=50}for(var af=0,v=Q.length;af<v;af++){var S=Math.ceil((Q[af][0]-D)*ak);var R=Q[af][1];if(!R){continue}J=Math.floor(ab-(R/B)*ab);z.fillStyle="rgb("+J+","+J+","+J+")";z.fillRect(S+O,0,b,20);if(this.prefs.show_counts){if(J>g){z.fillStyle="black"}else{z.fillStyle="#ddd"}z.textAlign="center";z.fillText(Q[af][1],S+O+(b/2),12)}}m.append(K);return K}var ai=w.data;var ae=0;for(var af=0,v=ai.length;af<v;af++){var L=ai[af],I=L[0],ag=L[1],T=L[2],E=L[3];if(ag<=a! c&&T>=D){var V=Math.floor(Math.max(0,(ag-D)*ak)),A=Math.ceil(Math.min( a,Math.max(0,(T-D)*ak))),P=aj[I]*al;if(w.dataset_type==="bai"){z.fillStyle="#555";if(L[4] instanceof Array){var s=Math.floor(Math.max(0,(L[4][0]-D)*ak)),H=Math.ceil(Math.min(a,Math.max(0,(L[4][1]-D)*ak))),q=Math.floor(Math.max(0,(L[5][0]-D)*ak)),o=Math.ceil(Math.min(a,Math.max(0,(L[5][1]-D)*ak)));if(L[4][1]>=D&&L[4][0]<=ac){this.rect_or_text(z,ak,ah,D,ac,L[4][0],L[4][2],s+O,H-s,P)}if(L[5][1]>=D&&L[5][0]<=ac){this.rect_or_text(z,ak,ah,D,ac,L[5][0],L[5][2],q+O,o-q,P)}if(q>H){z.fillStyle="#999";z.fillRect(H+O,P+5,q-H,1)}}else{z.fillStyle="#555";this.rect_or_text(z,ak,ah,D,ac,ag,E,V+O,A-V,P)}if(!U&&ag>D){z.fillStyle=this.prefs.label_color;if(h===0&&V-z.measureText(E).width<0){z.textAlign="left";z.fillText(I,A+2+O,P+8)}else{z.textAlign="right";z.fillText(I,V-2+O,P+8)}z.fillStyle="#555"}}else{if(w.dataset_type==="interval_index"){if(U){z.fillRect(V+O,P+5,A-V,1)}else{var u=L[4],N=L[5],X=L[6],e=L[7];var t,Z,F=null,am=null;if(N&&X){F=Math.floor(Math.max(0,(N-D)*ak));am=Math.ceil(Math! .min(a,Math.max(0,(X-D)*ak)))}if(E!==undefined&&ag>D){z.fillStyle=Y;if(h===0&&V-z.measureText(E).width<0){z.textAlign="left";z.fillText(E,A+2+O,P+8)}else{z.textAlign="right";z.fillText(E,V-2+O,P+8)}z.fillStyle=f}if(e){if(u){if(u=="+"){z.fillStyle=RIGHT_STRAND}else{if(u=="-"){z.fillStyle=LEFT_STRAND}}z.fillRect(V+O,P,A-V,10);z.fillStyle=f}for(var ad=0,d=e.length;ad<d;ad++){var n=e[ad],c=Math.floor(Math.max(0,(n[0]-D)*ak)),M=Math.ceil(Math.min(a,Math.max((n[1]-D)*ak)));if(c>M){continue}t=5;Z=3;z.fillRect(c+O,P+Z,M-c,t);if(F!==undefined&&!(c>am||M<F)){t=9;Z=1;var aa=Math.max(c,F),p=Math.min(M,am);z.fillRect(aa+O,P+Z,p-aa,t)}}}else{t=9;Z=1;z.fillRect(V+O,P+Z,A-V,t);if(L.strand){if(L.strand=="+"){z.fillStyle=RIGHT_STRAND_INV}else{if(L.strand=="-"){z.fillStyle=LEFT_STRAND_INV}}z.fillRect(V+O,P,A-V,10);z.fillStyle=prefs.block_color}}}}}ae++}}m.append(K);return K},gen_options:function(i){var a=$("<div></div>").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label></label!
").attr("for",e).text("Block color:"),l=$("<input></input>").attr("id ",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label></label>").attr("for",j).text("Text color:"),h=$("<input></input>").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label></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></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(c,a,b){FeatureTrack.call(this,c,a,b);this.track_type="ReadTrack";this.vertical_det! ail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{}); \ No newline at end of file diff -r e7d91d58f4ad -r 370777a0693f static/scripts/trackster.js --- a/static/scripts/trackster.js Thu May 06 12:11:47 2010 -0400 +++ b/static/scripts/trackster.js Thu May 06 12:30:54 2010 -0400 @@ -5,7 +5,7 @@
var DENSITY = 200, FEATURE_LEVELS = 10, - DATA_ERROR = "There was an error in indexing this dataset.", + 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", @@ -118,17 +118,15 @@ }, remove_track: function( track ) { track.container_div.fadeOut('slow', function() { $(this).remove(); }); - delete this.tracks[track]; + delete this.tracks.splice(this.tracks.indexOf(track)); }, update_options: function() { var sorted = $("ul#sortable-ul").sortable('toArray'); - var payload = []; + for (var id_i in sorted) { + var id = sorted[id_i].split("_li")[0].split("track_")[1]; + $("#viewport").append( $("#track_" + id) ); + } - var divs = $("#viewport > div").sort(function (a, b) { - return sorted.indexOf( $(a).attr('id') ) > sorted.indexOf( $(b).attr('id') ); - }); - $("#viewport > div").remove(); - $("#viewport").html(divs); for (var track_id in view.tracks) { var track = view.tracks[track_id]; if (track.update_options) { @@ -234,13 +232,22 @@ if (track.view.chrom) { $.getJSON( data_url, params, function (result) { - if (!result || result === "error") { + if (!result || result === "error" || result.kind === "error") { track.container_div.addClass("error"); track.content_div.text(DATA_ERROR); + if (result.message) { + var track_id = track.view.tracks.indexOf(track); + var error_link = $("<a href='javascript:void(0);'></a>").attr("id", track_id + "_error"); + error_link.text("Click to view error"); + $("#" + track_id + "_error").live("click", function() { + show_modal( "Trackster Error", "<pre>" + result.message + "</pre>", { "Close" : hide_modal } ); + }); + track.content_div.append(error_link); + } } else if (result === "no converter") { track.container_div.addClass("error"); track.content_div.text(DATA_NOCONVERTER); - } else if (result.data && result.data.length === 0 || result.data === null) { + } else if (result.data !== undefined && (result.data === null || result.data.length === 0)) { track.container_div.addClass("nodata"); track.content_div.text(DATA_NONE); } else if (result === "pending") { @@ -441,7 +448,6 @@ var result = this.data_cache.get(key); if (result === null) { return; } - console.log(result); canvas.css( { position: "absolute", diff -r e7d91d58f4ad -r 370777a0693f templates/tracks/browser.mako --- a/templates/tracks/browser.mako Thu May 06 12:11:47 2010 -0400 +++ b/templates/tracks/browser.mako Thu May 06 12:30:54 2010 -0400 @@ -272,7 +272,6 @@ $.ajax({ url: "${h.url_for( action='chroms' )}", - ## If vis is new, it doesn't have an id, so send the dbkey instead. %if config.get('vis_id'): data: { vis_id: view.vis_id }, %else: @@ -327,7 +326,7 @@ $("#track_" + track_id + "_editable").toggle(); }); del_icon.bind("click", function() { - $("#track_" + track_id + "_li").fadeOut('slow', function() { $("#track_" + track_id).remove(); }); + $("#track_" + track_id + "_li").fadeOut('slow', function() { $("#track_" + track_id + "_li").remove(); }); view.remove_track(track); view.update_options(); }); @@ -354,4 +353,3 @@ </script> </%def> - diff -r e7d91d58f4ad -r 370777a0693f templates/user/dbkeys.mako --- a/templates/user/dbkeys.mako Thu May 06 12:11:47 2010 -0400 +++ b/templates/user/dbkeys.mako Thu May 06 12:30:54 2010 -0400 @@ -41,23 +41,26 @@ <tr class="header"> <th>Name</th> <th>Key</th> - <th>Chroms/Lengths</th> + <th>Number of Chroms</th> <th></th> </tr> % for key, dct in dbkeys.iteritems(): <tr> - <td>${dct["name"] | h}</td> + <td>${dct['name'] | h}</td> <td>${key | h}</td> <td> - <span>${len(dct["chroms"])} entries</span> - <pre id="pre_${key}" class="db_hide"> - <table cellspacing="0" cellpadding="0"> - <tr><th>Chrom</th><th>Length</th></tr> - % for chrom, chrom_len in dct["chroms"].iteritems(): - <tr><td>${chrom | h}</td><td>${chrom_len | h}</td></tr> - % endfor - </table> - </pre> +## <span>${len(dct["chroms"])} entries</span> +## <pre id="pre_${key}" class="db_hide"> +## <table cellspacing="0" cellpadding="0"> +## <tr><th>Chrom</th><th>Length</th></tr> +## % for chrom, chrom_len in dct["chroms"].iteritems(): +## <tr><td>${chrom | h}</td><td>${chrom_len | h}</td></tr> +## % endfor +## </table> +## </pre> + % if 'count' in dct: + ${dct['count']} + % endif </td> <td><form action="dbkeys" method="post"><input type="hidden" name="key" value="${key}" /><input type="submit" name="delete" value="Delete" /></form></td> </tr> diff -r e7d91d58f4ad -r 370777a0693f tool_conf.xml.main --- a/tool_conf.xml.main Thu May 06 12:11:47 2010 -0400 +++ b/tool_conf.xml.main Thu May 06 12:30:54 2010 -0400 @@ -35,6 +35,7 @@ <tool file="filters/changeCase.xml" /> <tool file="filters/pasteWrapper.xml" /> <tool file="filters/remove_beginning.xml" /> + <tool file="filters/randomlines.xml" /> <tool file="filters/headWrapper.xml" /> <tool file="filters/tailWrapper.xml" /> <tool file="filters/trimmer.xml" />
participants (1)
-
Nate Coraor