mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
trackster: natural sort for chroms list, disable zooming when no data, can click on labels when selecting datasets
This commit is contained in:
@@ -15,7 +15,7 @@ Problems
|
||||
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
|
||||
@@ -49,6 +49,9 @@ dataset_type_to_data_provider = {
|
||||
# converters
|
||||
browsable_types = set( ["wig" ] )
|
||||
|
||||
# For natural sort
|
||||
NUM_RE = re.compile('([0-9]+)')
|
||||
|
||||
class TracksController( BaseController ):
|
||||
"""
|
||||
Controller for track browser interface. Handles building a new browser from
|
||||
@@ -116,10 +119,16 @@ class TracksController( BaseController ):
|
||||
|
||||
@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 ):
|
||||
"""
|
||||
|
||||
@@ -67,6 +67,9 @@ $.extend( View.prototype, {
|
||||
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 @@ $.extend( View.prototype, {
|
||||
}
|
||||
},
|
||||
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;
|
||||
|
||||
@@ -32,10 +32,10 @@ $( function() {
|
||||
</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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user