1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b12b245510be/ Changeset: b12b245510be User: guerler Date: 2013-04-08 16:19:37 Summary: Inserted a button for trackster visualization into the BED-file data display viewer. Affected #: 4 files diff -r cb25513c63cd7aa2ebd472e91109c96276ed6d9d -r b12b245510bea4d59f485dbfdd663a47c5443d5c lib/galaxy/webapps/galaxy/controllers/visualization.py --- a/lib/galaxy/webapps/galaxy/controllers/visualization.py +++ b/lib/galaxy/webapps/galaxy/controllers/visualization.py @@ -696,6 +696,11 @@ # Get dataset to add. new_dataset_id = kwargs.get( "dataset_id", None ) + + # Get gene region + new_chrom = kwargs.get( "chrom", None ) + new_start = kwargs.get( "start", 0 ) + new_end = kwargs.get( "end", 0 ) # Set up new browser if no id provided. if not id: @@ -706,7 +711,7 @@ if dbkey == '?': dbkey = kwargs.get( "dbkey", None ) - return trans.fill_template( "tracks/browser.mako", config={}, + return trans.fill_template( "tracks/browser.mako", viewport_config={"chrom" : new_chrom, "start" : int(new_start), "end" : int(new_end)}, add_dataset=new_dataset_id, default_dbkey=dbkey ) diff -r cb25513c63cd7aa2ebd472e91109c96276ed6d9d -r b12b245510bea4d59f485dbfdd663a47c5443d5c static/scripts/mvc/data.js --- a/static/scripts/mvc/data.js +++ b/static/scripts/mvc/data.js @@ -20,7 +20,7 @@ }, initialize: function() { - // -- Create and initialize metadata. -- + // -- Create and initialize metadata. -- var metadata = new DatasetMetadata(); @@ -111,10 +111,8 @@ initialize: function(options) {}, - render: function() { - // Add loading indicator div. - this.$el.append( $('<div/>').attr('id', 'loading_indicator') ); - + render: function() + { // Add data table and header. var data_table = $('<table/>').attr({ id: 'content_table', @@ -223,6 +221,121 @@ } }); +/** + * Provides table-based, dynamic view of a bed dataset. + * NOTE: view's el must be in DOM already and provided when + * creating the view so that scrolling event can be attached + * to the correct container. + */ +var BedDatasetChunkedView = TabularDatasetChunkedView.extend( +{ + // gene region columns + col: { + chrom : null, + start : null, + end : null, + }, + + // url for trackster + url_viz : null, + + // dataset id + dataset_id : null, + + // backbone initialize + initialize: function (options) + { + // verify that metadata exists + var metadata = options.model.attributes.metadata.attributes; + if (typeof metadata.chromCol === "undefined" || typeof metadata.startCol === "undefined" || typeof metadata.endCol === "undefined") + console.log("BedDatasetChunkedView:initialize() : Metadata for column identification is missing."); + else + { + // read in columns + this.col.chrom = metadata.chromCol - 1; + this.col.start = metadata.startCol - 1; + this.col.end = metadata.endCol - 1; + } + + // get dataset id + if (typeof options.model.attributes.id === "undefined") + console.log("BedDatasetChunkedView:initialize() : Dataset identification is missing."); + else + this.dataset_id = options.model.attributes.id; + + // get url + if (typeof options.model.attributes.url_viz === "undefined") + console.log("BedDatasetChunkedView:initialize() : Url for visualization controller is missing."); + else + this.url_viz = options.model.attributes.url_viz; + }, + + // backbone events + events: + { + 'mouseover tr' : 'btn_viz_show', + 'mouseleave' : 'btn_viz_hide' + }, + + // show button + btn_viz_show: function (e) + { + // get selected data line + var row = $(e.target).parent(); + + // get target gene region + var btn_viz_pars = { + dataset_id : this.dataset_id, + chrom : row.children().eq(this.col.chrom).html(), + start : row.children().eq(this.col.start).html(), + end : row.children().eq(this.col.end).html() + }; + + // verify that location has been found + if (btn_viz_pars.chrom != "") + { + // get button position + var offset = row.offset(); + var left = offset.left - 10; + var top = offset.top; + + // update css + $('#btn_viz').css({'position': 'fixed', 'top': top + 'px', 'left': left + 'px'}); + $('#btn_viz').attr('href', "javascript:window.parent.location.href = '" + this.url_viz + "/trackster?" + $.param(btn_viz_pars) + "';"); + + // show the button + $('#btn_viz').show(); + } + }, + + // hide button + btn_viz_hide: function (e) + { + // hide button from screen + $('#btn_viz').hide(); + }, + + // render frame + render: function() + { + // render the icon from template + var btn_viz = new IconButtonView({ model : new IconButton({ + title : 'Visualize', + icon_class : 'chart_curve', + id : 'btn_viz' + })}); + + // add it to the screen + this.$el.append(btn_viz.render().$el); + + // hide the button + $('#btn_viz').hide(); + + // call parent render + TabularDatasetChunkedView.prototype.render.call(this); + } +}); + // -- Utility functions. -- /** @@ -252,10 +365,19 @@ var view_div = $('<div/>').appendTo(parent_elt); // Create view with model, render, and return. - return new TabularDatasetChunkedView({ - el: view_div, - model: new TabularDataset(dataset_config) - }).render(); + if (dataset_config.data_type == 'bed') + // bed datatype viewer + return new BedDatasetChunkedView({ + el: view_div, + model: new TabularDataset(dataset_config) + }).render(); + else + // default viewer + return new TabularDatasetChunkedView({ + el: view_div, + model: new TabularDataset(dataset_config) + }).render(); + }; return { @@ -263,6 +385,7 @@ TabularDataset: TabularDataset, DatasetCollection: DatasetCollection, TabularDatasetChunkedView: TabularDatasetChunkedView, + BedDatasetChunkedView: BedDatasetChunkedView, createTabularDatasetChunkedView: createTabularDatasetChunkedView }; diff -r cb25513c63cd7aa2ebd472e91109c96276ed6d9d -r b12b245510bea4d59f485dbfdd663a47c5443d5c templates/webapps/galaxy/dataset/tabular_chunked.mako --- a/templates/webapps/galaxy/dataset/tabular_chunked.mako +++ b/templates/webapps/galaxy/dataset/tabular_chunked.mako @@ -6,6 +6,8 @@ <%def name="javascripts()"> ${parent.javascripts()} ${h.js( "libs/require" )} + ${h.templates("helpers-common-templates")} + <script type="text/javascript"> require.config({ baseUrl: "${h.url_for('/static/scripts')}", @@ -19,7 +21,8 @@ data.createTabularDatasetChunkedView( _.extend( ${h.to_json_string( trans.security.encode_dict_ids( dataset.get_api_value() ) )}, { - chunk_url: "${h.url_for( controller='/dataset', action='display', + url_viz: "${h.url_for( controller='/visualization')}", + chunk_url: "${h.url_for( controller='/dataset', action='display', dataset_id=trans.security.encode_id( dataset.id ))}", first_data_chunk: ${chunk} } diff -r cb25513c63cd7aa2ebd472e91109c96276ed6d9d -r b12b245510bea4d59f485dbfdd663a47c5443d5c templates/webapps/galaxy/tracks/browser.mako --- a/templates/webapps/galaxy/tracks/browser.mako +++ b/templates/webapps/galaxy/tracks/browser.mako @@ -89,7 +89,7 @@ container: $("#browser-container"), name: $("#new-title").val(), dbkey: $("#new-dbkey").val() - } ); + }, JSON.parse('${ h.to_json_string( viewport_config ) }')); view.editor = true; init_editor(); set_up_router({view: view}); 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.