[hg] galaxy 2758: trackster: natural sort for chroms list, disab...
details: http://www.bx.psu.edu/hg/galaxy/rev/509390d4e719 changeset: 2758:509390d4e719 user: Kanwei Li <kanwei@gmail.com> date: Wed Sep 23 17:32:16 2009 -0400 description: trackster: natural sort for chroms list, disable zooming when no data, can click on labels when selecting datasets 3 file(s) affected in this change: lib/galaxy/web/controllers/tracks.py static/scripts/trackster.js templates/tracks/new_browser.mako diffs (80 lines): diff -r dcdbb13b0c76 -r 509390d4e719 lib/galaxy/web/controllers/tracks.py --- a/lib/galaxy/web/controllers/tracks.py Wed Sep 23 17:16:13 2009 -0400 +++ b/lib/galaxy/web/controllers/tracks.py Wed Sep 23 17:32:16 2009 -0400 @@ -15,7 +15,7 @@ need to support that, but need to make user defined build support better) """ -import math, logging +import math, re, logging log = logging.getLogger(__name__) from galaxy.util.json import to_json_string @@ -48,6 +48,9 @@ # FIXME: hardcoding this for now, but it should be derived from the available # converters browsable_types = set( ["wig" ] ) + +# For natural sort +NUM_RE = re.compile('([0-9]+)') class TracksController( BaseController ): """ @@ -116,10 +119,16 @@ @web.json def chroms(self, trans, dbkey=None ): + """ + Returns a naturally sorted list of chroms/contigs for the given dbkey + """ + def split_by_number(s): + return [ int(c) if c.isdigit() else c for c in NUM_RE.split(s) ] + chroms = self._chroms( trans, dbkey ) - unsorted = [{ 'chrom': chrom, 'len': length } for chrom, length in chroms.iteritems()] - unsorted.sort( lambda a,b: cmp(a['chrom'], b['chrom']) ) - return unsorted + to_sort = [{ 'chrom': chrom, 'len': length } for chrom, length in chroms.iteritems()] + to_sort.sort(lambda a,b: cmp( split_by_number(a['chrom']), split_by_number(b['chrom']) )) + return to_sort def _chroms( self, trans, dbkey ): """ diff -r dcdbb13b0c76 -r 509390d4e719 static/scripts/trackster.js --- a/static/scripts/trackster.js Wed Sep 23 17:16:13 2009 -0400 +++ b/static/scripts/trackster.js Wed Sep 23 17:32:16 2009 -0400 @@ -67,6 +67,9 @@ this.high = Math.min( this.length, Math.ceil( new_high ) ); }, zoom_in: function ( factor, point ) { + console.log(this.max_high); + if (this.max_high == 0) return; + var range = this.high - this.low; var diff = range / factor / 2; @@ -92,6 +95,7 @@ } }, zoom_out: function ( factor ) { + if (this.max_high == 0) return; var center = ( this.low + this.high ) / 2; var range = this.high - this.low; var diff = range * factor / 2; diff -r dcdbb13b0c76 -r 509390d4e719 templates/tracks/new_browser.mako --- a/templates/tracks/new_browser.mako Wed Sep 23 17:16:13 2009 -0400 +++ b/templates/tracks/new_browser.mako Wed Sep 23 17:32:16 2009 -0400 @@ -32,10 +32,10 @@ </div> <div class="form-row"> <label for="dataset_ids">Datasets to include: </label> - %for key,value in datasets.items(): + %for dataset_id, dataset_name in datasets.items(): <div> - <input type="checkbox" name="dataset_ids" value="${key}" /> - ${value} + <input type="checkbox" id="${dataset_id}" name="dataset_ids" value="${dataset_id}" /> + <label style="display:inline; font-weight: normal" for="${dataset_id}">${dataset_name}</label> </div> %endfor
participants (1)
-
Nate Coraor