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/4ed9bc9bc0ed/ Changeset: 4ed9bc9bc0ed User: guerler Date: 2013-04-10 19:19:10 Summary: Enhance button for trackster visualization in data display viewer Affected #: 3 files diff -r aca1ebc3b774b723de1b1b33759365681351e17e -r 4ed9bc9bc0ed78969423e8acad5f5281ef903020 lib/galaxy/visualization/genomes.py --- a/lib/galaxy/visualization/genomes.py +++ b/lib/galaxy/visualization/genomes.py @@ -31,21 +31,38 @@ A genomic region on an individual chromosome. """ - def __init__( self, chrom=None, start=None, end=None ): + def __init__( self, chrom = None, start = 0, end = 0 ): self.chrom = chrom self.start = int( start ) self.end = int( end ) def __str__( self ): return self.chrom + ":" + str( self.start ) + "-" + str( self.end ) + + @staticmethod + def from_dict( obj_dict ): + return GenomeRegion( chrom = obj_dict[ 'chrom' ], + start = obj_dict[ 'start' ], + end = obj_dict[ 'end' ] ) @staticmethod - def from_dict( obj_dict ): - return GenomeRegion( chrom=obj_dict[ 'chrom' ], - start=obj_dict[ 'start' ], - end=obj_dict[ 'end' ] ) - - + def from_str( obj_str ): + # check for gene region + gene_region = obj_str.split(':') + + # split gene region into components + if (len(gene_region) == 2): + gene_interval = gene_region[1].split('-') + + # check length + if (len(gene_interval) == 2): + return GenomeRegion(chrom = gene_region[0], + start = gene_interval[0], + end = gene_interval[1]) + + # return genome region instance + return GenomeRegion() + class Genome( object ): """ Encapsulates information about a known genome/dbkey. diff -r aca1ebc3b774b723de1b1b33759365681351e17e -r 4ed9bc9bc0ed78969423e8acad5f5281ef903020 lib/galaxy/webapps/galaxy/controllers/visualization.py --- a/lib/galaxy/webapps/galaxy/controllers/visualization.py +++ b/lib/galaxy/webapps/galaxy/controllers/visualization.py @@ -12,6 +12,7 @@ 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.visualization.genomes import GenomeRegion from .library import LibraryListGrid @@ -697,22 +698,8 @@ # Get dataset to add. new_dataset_id = kwargs.get( "dataset_id", None ) - # 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]) + gene_region = GenomeRegion.from_str(kwargs.get("gene_region", "")) # Set up new browser if no id provided. if not id: @@ -722,18 +709,19 @@ dbkey = self.get_dataset( trans, new_dataset_id ).dbkey if dbkey == '?': dbkey = kwargs.get( "dbkey", None ) - - return trans.fill_template( "tracks/browser.mako", viewport_config=gene_region_config, add_dataset=new_dataset_id, default_dbkey=dbkey ) + + # fill template + return trans.fill_template( "tracks/browser.mako", viewport_config=gene_region.__dict__, 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'] + if gene_region.chrom is not None: + viz_config['viewport']['chrom'] = gene_region.chrom + viz_config['viewport']['start'] = gene_region.start + viz_config['viewport']['end'] = gene_region.end ''' FIXME: @@ -741,6 +729,7 @@ if trans.security.decode_id(new_dataset) in [ d["dataset_id"] for d in viz_config.get("tracks") ]: new_dataset = None # Already in browser, so don't add ''' + # fill template return trans.fill_template( 'tracks/browser.mako', config=viz_config, add_dataset=new_dataset_id ) @web.expose diff -r aca1ebc3b774b723de1b1b33759365681351e17e -r 4ed9bc9bc0ed78969423e8acad5f5281ef903020 static/scripts/mvc/data.js --- a/static/scripts/mvc/data.js +++ b/static/scripts/mvc/data.js @@ -109,7 +109,11 @@ */ var TabularDatasetChunkedView = Backbone.View.extend({ - initialize: function(options) {}, + initialize: function(options) + { + // load trackster button + (new TabularButtonTrackster(options)).render(); + }, render: function() { @@ -221,13 +225,8 @@ } }); -/** - * 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 TabularDatasetChunkedViewWithButton = TabularDatasetChunkedView.extend( +// button for trackster visualization +var TabularButtonTrackster = Backbone.View.extend( { // gene region columns col: { @@ -245,17 +244,13 @@ // 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("TabularDatasetChunkedViewWithButton : Metadata for column identification is missing."); + console.log("TabularButtonTrackster : Metadata for column identification is missing."); else { // read in columns @@ -270,13 +265,13 @@ // get dataset id if (typeof options.model.attributes.id === "undefined") - console.log("TabularDatasetChunkedViewWithButton : Dataset identification is missing."); + console.log("TabularButtonTrackster : Dataset identification is missing."); else this.dataset_id = options.model.attributes.id; // get url if (typeof options.model.attributes.url_viz === "undefined") - console.log("TabularDatasetChunkedViewWithButton : Url for visualization controller is missing."); + console.log("TabularButtonTrackster : Url for visualization controller is missing."); else this.url_viz = options.model.attributes.url_viz; @@ -301,20 +296,23 @@ // get selected data line var row = $(e.target).parent(); - - // get target gene region - var btn_viz_pars = { - dataset_id : this.dataset_id, - 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 (row.children().eq(this.col.chrom).html() != "") + var chrom = row.children().eq(this.col.chrom).html(); + var start = row.children().eq(this.col.start).html(); + var end = row.children().eq(this.col.end).html(); + if (chrom != "" && start != "" && end != "") { + // get target gene region + var btn_viz_pars = { + dataset_id : this.dataset_id, + gene_region : chrom + ":" + start + "-" + end + }; + // get button position - var offset = row.offset(); - var left = offset.left - 10; - var top = offset.top; + 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'}); @@ -401,9 +399,6 @@ // hide the button $('#btn_viz').hide(); - - // call parent render - TabularDatasetChunkedView.prototype.render.call(this); } }); @@ -436,7 +431,7 @@ var view_div = $('<div/>').appendTo(parent_elt); // default viewer - return new TabularDatasetChunkedViewWithButton({ + return new TabularDatasetChunkedView({ el: view_div, model: new TabularDataset(dataset_config) }).render(); 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