1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/d6ce5e2a1cdb/ changeset: d6ce5e2a1cdb user: jgoecks date: 2012-10-23 21:41:48 summary: Circster, enhancements for chords: (a) adjust chords when datasets added/removed from visualization; (b) use config to color; and (c) enable dynamic addition of chord/interaction datasets. affected #: 3 files diff -r f23c2b0ef005f1e44299d11fd8fbe5077fe850f0 -r d6ce5e2a1cdb8645f3490043b151f2b271f4b2b4 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -19,6 +19,7 @@ from paste.httpexceptions import * from galaxy.exceptions import * from galaxy.model import NoConverterException, ConverterDependencyException +from galaxy.datatypes.interval import ChromatinInteractions from Cheetah.Template import Template @@ -602,7 +603,7 @@ return visualization - def _get_genome_data( self, trans, dataset, dbkey=None, source='index' ): + def _get_genome_data( self, trans, dataset, dbkey=None ): """ Returns genome-wide data for dataset if available; if not, message is returned. """ @@ -621,6 +622,11 @@ if message: rval = message else: + # HACK: chromatin interactions tracks use data as source. + source = 'index' + if isinstance( dataset.datatype, ChromatinInteractions ): + source = 'data' + data_provider = trans.app.data_provider_registry.get_data_provider( trans, original_dataset=dataset, source=source ) diff -r f23c2b0ef005f1e44299d11fd8fbe5077fe850f0 -r d6ce5e2a1cdb8645f3490043b151f2b271f4b2b4 lib/galaxy/webapps/galaxy/controllers/visualization.py --- a/lib/galaxy/webapps/galaxy/controllers/visualization.py +++ b/lib/galaxy/webapps/galaxy/controllers/visualization.py @@ -8,7 +8,6 @@ from galaxy.visualization.genomes import decode_dbkey from galaxy.visualization.genome.visual_analytics import get_dataset_job from galaxy.visualization.data_providers.phyloviz import PhylovizDataProvider -from galaxy.datatypes.interval import ChromatinInteractions from .library import LibraryListGrid @@ -753,12 +752,8 @@ tracks = viz_config.get( 'tracks', [] ) for track in tracks: dataset = self.get_hda_or_ldda( trans, track[ 'hda_ldda'], track[ 'dataset_id' ] ) - # HACK: chromatin interactions tracks use data as source. - source = 'index' - if isinstance( dataset.datatype, ChromatinInteractions ): - source = 'data' - genome_data = self._get_genome_data( trans, dataset, dbkey, source=source ) + genome_data = self._get_genome_data( trans, dataset, dbkey ) if not isinstance( genome_data, str ): track[ 'preloaded_data' ] = genome_data diff -r f23c2b0ef005f1e44299d11fd8fbe5077fe850f0 -r d6ce5e2a1cdb8645f3490043b151f2b271f4b2b4 static/scripts/viz/circster.js --- a/static/scripts/viz/circster.js +++ b/static/scripts/viz/circster.js @@ -200,31 +200,53 @@ * Render a single track on the outside of the current visualization. */ add_track: function(new_track) { - // Recompute and update track bounds. - var new_track_bounds = this.get_tracks_bounds(); - _.each(this.circular_views, function(track_view, i) { - track_view.update_radius_bounds(new_track_bounds[i]); - }); + if (new_track.get('track_type') === 'DiagonalHeatmapTrack') { + // Added chords track. + var innermost_radius_bounds = this.circular_views[0].radius_bounds, + new_view = new CircsterChromInteractionsTrackView({ + el: d3.select('g.tracks').append('g')[0], + track: new_track, + radius_bounds: innermost_radius_bounds, + genome: this.genome, + total_gap: this.total_gap + }); + new_view.render(); + this.chords_views.push(new_view); + } + else { + // Added circular track. - // Render new track. - var track_index = this.circular_views.length, - track_view_class = (new_track.get('track_type') === 'LineTrack' ? - CircsterBigWigTrackView : - CircsterSummaryTreeTrackView ), - track_view = new track_view_class({ - el: d3.select('g.tracks').append('g')[0], - track: new_track, - radius_bounds: new_track_bounds[track_index], - genome: this.genome, - total_gap: this.total_gap + // Recompute and update track bounds. + var new_track_bounds = this.get_tracks_bounds(); + _.each(this.circular_views, function(track_view, i) { + track_view.update_radius_bounds(new_track_bounds[i]); }); - track_view.render(); - this.circular_views.push(track_view); - // Update label track. - var track_bounds = new_track_bounds[ new_track_bounds.length-1 ]; - track_bounds[1] = track_bounds[0]; - this.label_track_view.update_radius_bounds(track_bounds); + // Update chords tracks. + _.each(this.chords_views, function(track_view) { + track_view.update_radius_bounds(new_track_bounds[0]); + }); + + // Render new track. + var track_index = this.circular_views.length, + track_view_class = (new_track.get('track_type') === 'LineTrack' ? + CircsterBigWigTrackView : + CircsterSummaryTreeTrackView ), + track_view = new track_view_class({ + el: d3.select('g.tracks').append('g')[0], + track: new_track, + radius_bounds: new_track_bounds[track_index], + genome: this.genome, + total_gap: this.total_gap + }); + track_view.render(); + this.circular_views.push(track_view); + + // Update label track. + var track_bounds = new_track_bounds[ new_track_bounds.length-1 ]; + track_bounds[1] = track_bounds[0]; + this.label_track_view.update_radius_bounds(track_bounds); + } }, /** @@ -269,6 +291,15 @@ }, /** + * Get fill color from config. + */ + get_fill_color: function() { + var color = this.track.get('config').get_value('block_color'); + if (!color) { color = this.track.get('config').get_value('color'); } + return color; + }, + + /** * Render track's data by adding SVG elements to parent. */ render: function() { @@ -382,10 +413,8 @@ }); // Add new data path and apply preferences. - var prefs = self.track.get('prefs'), - block_color = prefs.block_color; - if (!block_color) { block_color = prefs.color; } - self._render_chrom_data(self.parent_elt, chrom_arc, data).style('stroke', block_color).style('fill', block_color); + var color = self.get_fill_color(); + self._render_chrom_data(self.parent_elt, chrom_arc, data).style('stroke', color).style('fill', color); }); }); @@ -463,10 +492,8 @@ }); // Apply prefs to all track data. - var config = track.get('config'), - block_color = config.get_value('block_color'); - if (!block_color) { block_color = config.get_value('color'); } - self.parent_elt.selectAll('path.chrom-data').style('stroke', block_color).style('fill', block_color); + var color = self.get_fill_color(); + self.parent_elt.selectAll('path.chrom-data').style('stroke', color).style('fill', color); rendered_deferred.resolve(svg); }); @@ -653,7 +680,7 @@ // When data is ready, render track. $.when(self.track.get('data_manager').data_is_ready()).then(function() { - // Convert genome-wide data in chord data. + // When data has been fetched, render track. $.when(self.track.get('data_manager').get_genome_wide_data(self.genome)).then(function(genome_wide_data) { var chord_data = [], chroms_info = self.genome.get_chroms_info(); @@ -685,13 +712,18 @@ .selectAll("path") .data(chord_data) .enter().append("path") - .style("fill", '000') + .style("fill", self.get_fill_color()) .attr("d", d3.svg.chord().radius(self.radius_bounds[0])) .style("opacity", 1); }); }); }, + update_radius_bounds: function(radius_bounds) { + this.radius_bounds = radius_bounds; + this.parent_elt.selectAll("path").transition().attr("d", d3.svg.chord().radius(this.radius_bounds[0])); + }, + /** * Returns radians for a genomic position. */ 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.