1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/05fc04a70a3b/ changeset: 05fc04a70a3b user: jgoecks date: 2012-10-05 22:01:55 summary: Enable circster to accept a dataset to add to visualization. Also, make visualization creation more flexible and some small refactoring for JS visualization objects. affected #: 6 files diff -r 3b63335f5b1b33a2d6f74c2dfd38b85d97e9eebd -r 05fc04a70a3bcbfaeedfcf6f2ec16a7e38fc7c94 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -335,16 +335,18 @@ viz_types = [ "trackster", "circster" ] - def create_visualization( self, trans, title, slug, type, dbkey, annotation=None, config={} ): + def create_visualization( self, trans, type, title="Untitled Genome Vis", slug=None, dbkey=None, annotation=None, config={}, save=True ): """ Create visualiation and first revision. """ - visualization = self._create_visualization( trans, title, type, dbkey, slug, annotation ) + visualization = self._create_visualization( trans, title, type, dbkey, slug, annotation, save ) # Create and save first visualization revision revision = trans.model.VisualizationRevision( visualization=visualization, title=title, config=config, dbkey=dbkey ) visualization.latest_revision = revision - session = trans.sa_session - session.add( revision ) - session.flush() + + if save: + session = trans.sa_session + session.add( revision ) + session.flush() return visualization @@ -440,7 +442,7 @@ """ Returns a visualization's configuration. Only works for trackster visualizations right now. """ config = None - if visualization.type == 'trackster': + if visualization.type in [ 'trackster', 'genome' ]: # Unpack Trackster config. latest_revision = visualization.latest_revision bookmarks = latest_revision.config.get( 'bookmarks', [] ) @@ -566,7 +568,7 @@ # -- Helper functions -- - def _create_visualization( self, trans, title, type, dbkey, slug=None, annotation=None ): + def _create_visualization( self, trans, title, type, dbkey=None, slug=None, annotation=None, save=True ): """ Create visualization but not first revision. Returns Visualization object. """ user = trans.get_user() @@ -593,9 +595,10 @@ annotation = sanitize_html( annotation, 'utf-8', 'text/html' ) self.add_item_annotation( trans.sa_session, trans.user, visualization, annotation ) - session = trans.sa_session - session.add( visualization ) - session.flush() + if save: + session = trans.sa_session + session.add( visualization ) + session.flush() return visualization diff -r 3b63335f5b1b33a2d6f74c2dfd38b85d97e9eebd -r 05fc04a70a3bcbfaeedfcf6f2ec16a7e38fc7c94 lib/galaxy/webapps/galaxy/controllers/visualization.py --- a/lib/galaxy/webapps/galaxy/controllers/visualization.py +++ b/lib/galaxy/webapps/galaxy/controllers/visualization.py @@ -741,20 +741,36 @@ return self.save_visualization( trans, config, type, id, title, dbkey, annotation ) @web.expose - def circster( self, trans, id, **kwargs ): + def circster( self, trans, id=None, hda_ldda=None, dataset_id=None, dbkey=None ): """ Display a circster visualization. """ - vis = self.get_visualization( trans, id, check_ownership=False, check_accessible=True ) + + # Get/create vis. + if id: + # Display existing viz. + vis = self.get_visualization( trans, id, check_ownership=False, check_accessible=True ) + else: + # Create new viz. + vis = self.create_visualization( trans, type="genome", dbkey=dbkey, save=False ) + + # Get the vis config and work with it from here on out. Working with the + # config is only possible because the config structure of trackster/genome + # visualizations is well known. viz_config = self.get_visualization_config( trans, vis ) + # Add dataset if specified. + if dataset_id: + dataset = self.get_hda_or_ldda( trans, hda_ldda, dataset_id ) + viz_config[ 'tracks' ].append( self.get_new_track_config( trans, dataset ) ) + # Get genome info. dbkey = viz_config[ 'dbkey' ] chroms_info = self.app.genomes.chroms( trans, dbkey=dbkey ) genome = { 'dbkey': dbkey, 'chroms_info': chroms_info } # Add genome-wide summary tree data to each track in viz. - tracks = viz_config[ 'tracks' ] + tracks = viz_config.get( 'tracks', [] ) for track in tracks: # Get dataset and indexed datatype. dataset = self.get_hda_or_ldda( trans, track[ 'hda_ldda'], track[ 'dataset_id' ] ) diff -r 3b63335f5b1b33a2d6f74c2dfd38b85d97e9eebd -r 05fc04a70a3bcbfaeedfcf6f2ec16a7e38fc7c94 static/scripts/viz/visualization.js --- a/static/scripts/viz/visualization.js +++ b/static/scripts/viz/visualization.js @@ -351,7 +351,6 @@ if (!extra_params) { extra_params = {}; } // Use additional parameters to get more detailed data. - var mode; if (cur_data.dataset_type === 'bigwig') { extra_params.num_samples = cur_data.data.length * detail_multiplier; } @@ -642,21 +641,10 @@ */ var Visualization = Backbone.RelationalModel.extend({ defaults: { - id: '', title: '', - type: '', - dbkey: '', - tracks: null + type: '' }, - relations: [ - { - type: Backbone.HasMany, - key: 'tracks', - relatedModel: BackboneTrack - } - ], - // Use function because visualization_url changes depending on viz. // FIXME: all visualizations should save to the same URL (and hence // this function won't be needed). @@ -682,13 +670,27 @@ }); /** - * A Genome space visualization. + * A visualization of genome data. */ var GenomeVisualization = Visualization.extend({ defaults: _.extend({}, Visualization.prototype.defaults, { + dbkey: '', + tracks: null, bookmarks: null, viewport: null - }) + }), + + relations: [ + { + type: Backbone.HasMany, + key: 'tracks', + relatedModel: BackboneTrack + } + ], + + add_track: function(track) { + this.get('tracks').push(track); + } }); /** @@ -727,6 +729,7 @@ }); return { + BackboneTrack: BackboneTrack, BrowserBookmark: BrowserBookmark, BrowserBookmarkCollection: BrowserBookmarkCollection, Cache: Cache, diff -r 3b63335f5b1b33a2d6f74c2dfd38b85d97e9eebd -r 05fc04a70a3bcbfaeedfcf6f2ec16a7e38fc7c94 templates/root/history.mako --- a/templates/root/history.mako +++ b/templates/root/history.mako @@ -236,7 +236,10 @@ } return action; }, - params = {dataset_id: dataset_id}; + params = { + dataset_id: dataset_id, + hda_ldda: 'hda' + }; // Add dbkey to params if it exists. if (dbkey) { params['dbkey'] = dbkey; } diff -r 3b63335f5b1b33a2d6f74c2dfd38b85d97e9eebd -r 05fc04a70a3bcbfaeedfcf6f2ec16a7e38fc7c94 templates/root/history_common.mako --- a/templates/root/history_common.mako +++ b/templates/root/history_common.mako @@ -226,11 +226,7 @@ ## Visualization icon + visualizations. Using anchor attributes is a HACK to encode needed ## information--URL base, dataset id, dbkey, visualizations--in anchor. <% - visualizations = data.get_visualizations() - ## HACK: if there are visualizations, only provide a subset for now - ## since others are not ready. - comment out to see all WIP visualizations - if visualizations: - visualizations = [ vis for vis in visualizations if vis in [ 'trackster', 'phyloviz', 'scatterplot' ] ] + visualizations = data.get_visualizations() %> %if visualizations: <a href="${h.url_for( controller='visualization' )}" diff -r 3b63335f5b1b33a2d6f74c2dfd38b85d97e9eebd -r 05fc04a70a3bcbfaeedfcf6f2ec16a7e38fc7c94 templates/visualization/circster.mako --- a/templates/visualization/circster.mako +++ b/templates/visualization/circster.mako @@ -33,7 +33,7 @@ } }); - require( [ "libs/d3", "viz/visualization", "viz/circster" ], function( d3, visualization, circster ) { + require( [ "viz/visualization", "viz/circster" ], function(visualization, circster ) { $(function() { 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.