commit/galaxy-central: jgoecks: Trackster: subset reference data when available.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b7b000557d12/ changeset: b7b000557d12 user: jgoecks date: 2013-02-21 20:11:09 summary: Trackster: subset reference data when available. affected #: 2 files diff -r 5a910304b25466d3781821bc35f7d0a6c1eae28a -r b7b000557d128c537dfeb5bb4a9260853463793b static/scripts/viz/trackster/tracks.js --- a/static/scripts/viz/trackster/tracks.js +++ b/static/scripts/viz/trackster/tracks.js @@ -2915,6 +2915,10 @@ if ( is_deferred( seq_data ) ) { can_draw_now = false; } + else { + // Sequence data is available, subset to get only data in region. + seq_data = view.reference_track.data_manager.subset_entry(seq_data, region); + } } // If we can draw now, do so. @@ -3440,7 +3444,8 @@ this.data_url = reference_url + "/" + this.view.dbkey; this.data_url_extra_params = {reference: true}; this.data_manager = new visualization.ReferenceTrackDataManager({ - data_url: this.data_url + data_url: this.data_url, + can_subset: this.can_subset }); this.hide_contents(); }; @@ -3456,10 +3461,11 @@ can_draw: Drawable.prototype.can_draw, /** - * Only retrieves data and draws tile if reference data can be displayed. + * Retrieves data and draws tile if reference data can be displayed. */ draw_helper: function(force, region, resolution, parent_element, w_scale, kwargs) { if (w_scale > this.view.canvas_manager.char_width_px) { + this.show_contents(); return TiledTrack.prototype.draw_helper.call(this, force, region, resolution, parent_element, w_scale, kwargs); } else { @@ -3468,28 +3474,27 @@ } }, + can_subset: function(data) { return true; }, + /** * Draw ReferenceTrack tile. */ - draw_tile: function(seq, ctx, mode, resolution, region, w_scale) { - var track = this; - + draw_tile: function(data, ctx, mode, resolution, region, w_scale) { if (w_scale > this.view.canvas_manager.char_width_px) { - if (seq.data === null) { - this.hide_contents(); - return; - } + // Try to subset data. + var subset = this.data_manager.subset_entry(data, region), + seq_data = subset.data; + + // Draw sequence data. var canvas = ctx.canvas; ctx.font = ctx.canvas.manager.default_font; - ctx.textAlign = "center"; - seq = seq.data; - for (var c = 0, str_len = seq.length; c < str_len; c++) { - var c_start = Math.floor(c * w_scale); - ctx.fillText(seq[c], c_start, 10); + ctx.textAlign = "center"; + for (var c = 0, str_len = seq_data.length; c < str_len; c++) { + ctx.fillText(seq_data[c], Math.floor(c * w_scale), 10); } - this.show_contents(); - return new Tile(track, region, resolution, canvas, seq); + return new Tile(this, region, resolution, canvas, subset); } + this.hide_contents(); } }); diff -r 5a910304b25466d3781821bc35f7d0a6c1eae28a -r b7b000557d128c537dfeb5bb4a9260853463793b static/scripts/viz/visualization.js --- a/static/scripts/viz/visualization.js +++ b/static/scripts/viz/visualization.js @@ -318,6 +318,8 @@ // Do request. var manager = this, entry = $.getJSON(dataset.url(), params, function (result) { + // Add region to the result. + result.region = region; manager.set_data(region, result); }); @@ -582,7 +584,25 @@ return { data: null }; } return GenomeDataManager.prototype.load_data.call(this, region, mode, resolution, extra_params); - } + }, + + /** + * Return an entry that includes only data in the subregion. + */ + subset_entry: function(entry, subregion) { + var seq_data = entry.data; + if (!entry.region.same(subregion)) { + // Need to subset sequence data. + var seq_start = subregion.get('start') - entry.region.get('start'), + seq_end = entry.data.length - ( entry.region.get('end') - subregion.get('end') ); + seq_data = entry.data.slice(seq_start, seq_end); + } + + return { + region: subregion, + data: seq_data + }; + } }); /** @@ -639,6 +659,16 @@ end: 0, genome: null }, + + /** + * Returns true if this region is the same as a given region. + * It does not test the genome right now. + */ + same: function(region) { + return this.attributes.chrom === region.get('chrom') && + this.attributes.start === region.get('start') && + this.attributes.end === region.get('end'); + }, /** * If from_str specified, use it to initialize attributes. Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket