diff --git a/lib/galaxy/datatypes/indexers/coverage.py b/lib/galaxy/datatypes/indexers/coverage.py index 2bfec91c25f..454f5f29b70 100644 --- a/lib/galaxy/datatypes/indexers/coverage.py +++ b/lib/galaxy/datatypes/indexers/coverage.py @@ -2,7 +2,7 @@ """ Read a chromosome of coverage data, and write it as a npy array, as -well as averages over regions of progessively larger size in powers of 10 +well as averages over regions of progressively larger size in powers of 10 """ from __future__ import division diff --git a/lib/galaxy/datatypes/indexers/wiggle.py b/lib/galaxy/datatypes/indexers/wiggle.py index 5ba1380aaa1..88e8fd7aca3 100644 --- a/lib/galaxy/datatypes/indexers/wiggle.py +++ b/lib/galaxy/datatypes/indexers/wiggle.py @@ -2,7 +2,7 @@ """ Read a chromosome of wiggle data, and write it as a npy array, as -well as averages over regions of progessively larger size in powers of 10 +well as averages over regions of progressively larger size in powers of 10 """ from __future__ import division diff --git a/lib/galaxy/web/controllers/tracks.py b/lib/galaxy/web/controllers/tracks.py index 95660613c65..7a48ab867b0 100644 --- a/lib/galaxy/web/controllers/tracks.py +++ b/lib/galaxy/web/controllers/tracks.py @@ -49,7 +49,8 @@ dataset_type_to_data_provider = { # FIXME: hardcoding this for now, but it should be derived from the available # converters -browsable_types = set( ["wig", "bed" ] ) +browsable_types = ( "wig", "bed" ) + class TracksController( BaseController ): """ @@ -92,7 +93,7 @@ class TracksController( BaseController ): if dataset.metadata.dbkey == dbkey and dataset.extension in browsable_types: datasets[dataset.id] = (dataset.extension, dataset.name) # Render the template - return trans.fill_template( "tracks/new_browser.mako", dbkey=dbkey, dbkey_set=dbkey_set, datasets=datasets ) + return trans.fill_template( "tracks/new_browser.mako", converters=browsable_types, dbkey=dbkey, dbkey_set=dbkey_set, datasets=datasets ) @web.expose def browser(self, trans, dataset_ids, chrom=""): diff --git a/static/scripts/trackster.js b/static/scripts/trackster.js index 8c4d5c53c26..092855096ef 100644 --- a/static/scripts/trackster.js +++ b/static/scripts/trackster.js @@ -6,35 +6,6 @@ var DENSITY = 1000, DATA_ERROR = "There was an error in indexing this dataset.", DATA_NONE = "No data for this chrom/contig."; -var DataCache = function( type, track ) { - this.type = type; - this.track = track; - this.cache = Object(); -}; -$.extend( DataCache.prototype, { - get: function( resolution, position ) { - var cache = this.cache; - if ( !( cache[resolution] && cache[resolution][position] ) ) { - if ( !cache[resolution] ) { - cache[resolution] = Object(); - } - var low = position * DENSITY * resolution; - var high = ( position + 1 ) * DENSITY * resolution; - cache[resolution][position] = { state: "loading" }; - - $.getJSON( data_url, { track_type: this.track.track_type, chrom: this.track.view.chrom, low: low, high: high, dataset_id: this.track.dataset_id }, function ( data ) { - if( data == "pending" ) { - setTimeout( fetcher, 5000 ); - } else { - cache[resolution][position] = { state: "loaded", values: data }; - } - $(document).trigger( "redraw" ); - }); - } - return cache[resolution][position]; - } -}); - var View = function( chrom, max_length ) { this.chrom = chrom; this.tracks = []; @@ -234,7 +205,7 @@ var LineTrack = function ( name, dataset_id, height ) { this.container_div.addClass( "line-track" ); this.content_div.css( "height", this.height_px + "px" ); this.dataset_id = dataset_id; - this.cache = new DataCache( "", this ); + this.cache = new Cache(50); }; $.extend( LineTrack.prototype, TiledTrack.prototype, { init: function() { @@ -254,6 +225,21 @@ $.extend( LineTrack.prototype, TiledTrack.prototype, { } }); }, + get_data: function( resolution, position ) { + var key = resolution + '-' + position, + cache = this.cache; + + if ( !cache[key] ) { + var low = position * DENSITY * resolution, + high = ( position + 1 ) * DENSITY * resolution; + + $.getJSON( data_url, { track_type: this.track_type, chrom: this.view.chrom, low: low, high: high, dataset_id: this.dataset_id }, function ( data ) { + cache[key] = data; + $(document).trigger( "redraw" ); + }); + } + return cache[key]; + }, draw_tile: function( resolution, tile_index, parent_element, w_scale, h_scale ) { if (!this.vertical_range) // We don't have the necessary information yet return; @@ -261,13 +247,13 @@ $.extend( LineTrack.prototype, TiledTrack.prototype, { var tile_low = tile_index * DENSITY * resolution, tile_high = ( tile_index + 1 ) * DENSITY * resolution, tile_length = DENSITY * resolution; - var chunk = this.cache.get( resolution, tile_index ); - var element; - if ( chunk.state == "loading" ) { - element = $("
"); - } else { - element = $(""); + var data = this.get_data( resolution, tile_index ); + if ( !data ) { + in_path = false; + return null; } + var element = $(""); + element.css( { position: "absolute", top: 0, @@ -275,18 +261,13 @@ $.extend( LineTrack.prototype, TiledTrack.prototype, { }); parent_element.append( element ); // Chunk is still loading, do nothing - if ( chunk.state == "loading" ) { - in_path = false; - return null; - } + var canvas = element; canvas.get(0).width = Math.ceil( tile_length * w_scale ); canvas.get(0).height = this.height_px; var ctx = canvas.get(0).getContext("2d"); var in_path = false; ctx.beginPath(); - var data = chunk.values; - if (!data) return; for ( var i = 0; i < data.length - 1; i++ ) { var x = data[i][0] - tile_low; var y = data[i][1]; diff --git a/templates/tracks/browser.mako b/templates/tracks/browser.mako index 59abec82503..1953b4b7b4d 100644 --- a/templates/tracks/browser.mako +++ b/templates/tracks/browser.mako @@ -7,7 +7,7 @@ ${parent.stylesheets()} <%def name="javascripts()"> ${parent.javascripts()} -${h.js( "jquery", "jquery.event.drag", "jquery.mousewheel", "trackster" )} +${h.js( "jquery", "jquery.event.drag", "jquery.mousewheel", "lrucache", "trackster" )} -
-
Select datasets to include in browser
-
-
-
- -
- -
-
-
-
- - %for dataset_id, (dataset_ext, dataset_name) in datasets.iteritems(): -
- - -
- %endfor +% if not converters: +
+ There are no available converters needed for visualization. Please verify that your tool_conf.xml file contains + converters for datatypes (see tool_conf.xml.sample) for examples. +
-
+% else: +
+
Select datasets to include in browser
+ +
+ +
+ +
+ +
+
+
+
+ + %for dataset_id, (dataset_ext, dataset_name) in datasets.iteritems(): +
+ + +
+ %endfor + +
+
-
-
- -
- -
+
+ +
+ +
+% endif