commit/galaxy-central: guerler: Enhance button for trackster visualization in data display viewer
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/6d1e0123ffef/ Changeset: 6d1e0123ffef User: guerler Date: 2013-04-09 19:59:56 Summary: Enhance button for trackster visualization in data display viewer Affected #: 2 files diff -r 7b58daa018e17ce6d48393596b05be6ba823f117 -r 6d1e0123ffef00c0f1de717d31dfc350bf9027ce lib/galaxy/webapps/galaxy/controllers/visualization.py --- a/lib/galaxy/webapps/galaxy/controllers/visualization.py +++ b/lib/galaxy/webapps/galaxy/controllers/visualization.py @@ -697,11 +697,23 @@ # 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 ) - + # viewport configuration + gene_region_config = {"chrom" : None, "start" : 0, "end" : 0} + + # Check for gene region + gene_region = kwargs.get("gene_region", "").split(':') + + # Split gene region into components + if (len(gene_region) == 2): + gene_chrom = gene_region[0]; + gene_interval = gene_region[1].split('-') + + # Check length + if (len(gene_interval) == 2): + gene_region_config['chrom'] = gene_chrom + gene_region_config['start'] = int(gene_interval[0]) + gene_region_config['end'] = int(gene_interval[1]) + # Set up new browser if no id provided. if not id: # Use dbkey from dataset to be added or from incoming parameter. @@ -711,14 +723,18 @@ if dbkey == '?': dbkey = kwargs.get( "dbkey", None ) - 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 ) + return trans.fill_template( "tracks/browser.mako", viewport_config=gene_region_config, add_dataset=new_dataset_id, default_dbkey=dbkey ) # Display saved visualization. vis = self.get_visualization( trans, id, check_ownership=False, check_accessible=True ) viz_config = self.get_visualization_config( trans, vis ) + # Update gene region of saved visualization if user parses a new gene region in the url + if gene_region_config['chrom'] is not None: + viz_config['viewport']['chrom'] = gene_region_config['chrom'] + viz_config['viewport']['start'] = gene_region_config['start'] + viz_config['viewport']['end'] = gene_region_config['end'] + ''' FIXME: if new_dataset is not None: diff -r 7b58daa018e17ce6d48393596b05be6ba823f117 -r 6d1e0123ffef00c0f1de717d31dfc350bf9027ce static/scripts/mvc/data.js --- a/static/scripts/mvc/data.js +++ b/static/scripts/mvc/data.js @@ -227,7 +227,7 @@ * creating the view so that scrolling event can be attached * to the correct container. */ -var BedDatasetChunkedView = TabularDatasetChunkedView.extend( +var TabularDatasetChunkedViewWithButton = TabularDatasetChunkedView.extend( { // gene region columns col: { @@ -242,13 +242,20 @@ // dataset id dataset_id : null, + // database key + genome_build: null, + + get_type : function(obj) { + return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() + }, + // 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."); + console.log("TabularDatasetChunkedViewWithButton : Metadata for column identification is missing."); else { // read in columns @@ -257,17 +264,25 @@ this.col.end = metadata.endCol - 1; } + // check + if(this.col.chrom == null) + return; + // get dataset id if (typeof options.model.attributes.id === "undefined") - console.log("BedDatasetChunkedView:initialize() : Dataset identification is missing."); + console.log("TabularDatasetChunkedViewWithButton : 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."); + console.log("TabularDatasetChunkedViewWithButton : Url for visualization controller is missing."); else this.url_viz = options.model.attributes.url_viz; + + // get genome_build / database key + if (typeof options.model.attributes.genome_build !== "undefined") + this.genome_build = options.model.attributes.genome_build; }, // backbone events @@ -280,19 +295,21 @@ // show button btn_viz_show: function (e) { + // check + if(this.col.chrom == null) + return; + // 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() + gene_region : row.children().eq(this.col.chrom).html() + ":" + row.children().eq(this.col.start).html() + "-" + row.children().eq(this.col.end).html() }; // verify that location has been found - if (btn_viz_pars.chrom != "") + if (row.children().eq(this.col.chrom).html() != "") { // get button position var offset = row.offset(); @@ -301,8 +318,9 @@ // 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) + "';"); - + $('#btn_viz').off('click'); + $('#btn_viz').click(this.create_trackster_action(this.url_viz, btn_viz_pars, this.genome_build)); + // show the button $('#btn_viz').show(); } @@ -315,6 +333,59 @@ $('#btn_viz').hide(); }, + + // create action + create_trackster_action_new : function (vis_url, dataset_params, dbkey) + { + return function () { + window.parent.location.href = vis_url + "/trackster?" + $.param(dataset_params); + } + }, + + // create action + create_trackster_action : function (vis_url, dataset_params, dbkey) { + return function() { + var listTracksParams = {}; + if (dbkey){ + // list_tracks seems to use 'f-dbkey' (??) + listTracksParams[ 'f-dbkey' ] = dbkey; + } + $.ajax({ + url: vis_url + '/list_tracks?' + $.param( listTracksParams ), + dataType: "html", + error: function() { alert( ( "Could not add this dataset to browser" ) + '.' ); }, + success: function(table_html) { + var parent = window.parent; + + parent.show_modal( ( "View Data in a New or Saved Visualization" ), "", { + "Cancel": function() { + parent.hide_modal(); + }, + "View in saved visualization": function() { + // Show new modal with saved visualizations. + parent.show_modal( ( "Add Data to Saved Visualization" ), table_html, { + "Cancel": function() { + parent.hide_modal(); + }, + "Add to visualization": function() { + $(parent.document).find('input[name=id]:checked').each(function() { + var vis_id = $(this).val(); + dataset_params.id = vis_id; + parent.location = vis_url + "/trackster?" + $.param(dataset_params); + }); + } + }); + }, + "View in new visualization": function() { + parent.location = vis_url + "/trackster?" + $.param(dataset_params); + } + }); + } + }); + return false; + }; + }, + // render frame render: function() { @@ -333,7 +404,7 @@ // call parent render TabularDatasetChunkedView.prototype.render.call(this); - } + } }); // -- Utility functions. -- @@ -364,20 +435,11 @@ // Create view element and add to parent. var view_div = $('<div/>').appendTo(parent_elt); - // Create view with model, render, and return. - 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(); - + // default viewer + return new TabularDatasetChunkedViewWithButton({ + el: view_div, + model: new TabularDataset(dataset_config) + }).render(); }; return { @@ -385,7 +447,6 @@ TabularDataset: TabularDataset, DatasetCollection: DatasetCollection, TabularDatasetChunkedView: TabularDatasetChunkedView, - BedDatasetChunkedView: BedDatasetChunkedView, createTabularDatasetChunkedView: createTabularDatasetChunkedView }; 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)
-
commits-noreply@bitbucket.org