galaxy-commits
Threads by month
- ----- 2025 -----
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 15302 discussions
2 new changesets in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/f09b01f65503/
changeset: r5005:f09b01f65503
user: james_taylor
date: 2011-02-06 06:39:09
summary: trackster: refactor track configuration to be data/configuration driven -- easier to extend
affected #: 1 file (95 bytes)
--- a/static/scripts/trackster.js Sat Feb 05 16:04:30 2011 -0500
+++ b/static/scripts/trackster.js Sun Feb 06 00:39:09 2011 -0500
@@ -829,6 +829,71 @@
return filters;
};
+var TrackConfig = function( options ) {
+ this.track = options.track;
+ this.params = options.params;
+ this.values = {}
+ if ( options.saved_values ) {
+ this.restore_values( options.saved_values );
+ }
+ this.onchange = options.onchange
+}
+$.extend( TrackConfig.prototype, {
+ restore_values: function( values ) {
+ var track_config = this;
+ $.each( this.params, function( index, param ) {
+ if ( values[ param.key ] !== undefined ) {
+ track_config.values[ param.key ] = values[ param.key ];
+ } else {
+ track_config.values[ param.key ] = param.default_value;
+ }
+ });
+ },
+ build_form: function() {
+ var track_config = this;
+ var container = $("<div />");
+ $.each( this.params, function( index, param ) {
+ if ( ! param.hidden ) {
+ var id = 'param_' + index;
+ var row = $("<div class='form-row' />").appendTo( container );
+ row.append( $('<label />').attr("for", id ).text( param.label + ":" ) );
+ if ( param.type == 'bool' ) {
+ row.append( $('<input type="checkbox" />').attr("id", id ).attr("name", id ).attr( 'checked', track_config.values[ param.key ] ) );
+ } else {
+ row.append( $('<input />').attr("id", id ).attr("name", id ).val( track_config.values[ param.key ] ) );
+ }
+ }
+ });
+ return container;
+ },
+ update_from_form : function( container ) {
+ var track_config = this;
+ var changed = false;
+ $.each( this.params, function( index, param ) {
+ if ( ! param.hidden ) {
+ // Parse value from form element
+ var id = 'param_' + index;
+ var value = container.find( '#' + id ).val();
+ if ( param.type == 'float' ) {
+ value = parseFloat( value );
+ } else if ( param.type == 'int' ) {
+ value = parseInt( value );
+ } else if ( param.type == 'bool' ) {
+ value = container.find( '#' + id ).is( ':checked' );
+ }
+ // Save value only if changed
+ if ( value !== track_config.values[ param.key ] ) {
+ track_config.values[ param.key ] = value;
+ changed = true;
+ }
+ }
+ });
+ if ( changed ) {
+ this.onchange();
+ }
+ }
+});
+
/**
* Tracks are objects can be added to the View.
*
@@ -943,14 +1008,6 @@
* Additional initialization required before drawing track for the first time.
*/
predraw_init: function() {},
- restore_prefs: function(prefs) {
- var that = this;
- $.each(prefs, function(pref, val) {
- if (val !== undefined) {
- that.prefs[pref] = val;
- }
- });
- },
// Provide support for updating and reverting track name. Currently, it's only possible to revert once.
update_name: function(new_name) {
this.old_name = this.name;
@@ -1186,7 +1243,11 @@
var track_dropdown = {};
track_dropdown["Edit configuration"] = function() {
var cancel_fn = function() { hide_modal(); $(window).unbind("keypress.check_enter_esc"); },
- ok_fn = function() { track.update_options(track.track_id); hide_modal(); $(window).unbind("keypress.check_enter_esc"); },
+ ok_fn = function() {
+ track.track_config.update_from_form( $(".dialog-box") );
+ hide_modal();
+ $(window).unbind("keypress.check_enter_esc");
+ },
check_enter_esc = function(e) {
if ((e.keyCode || e.which) === 27) { // Escape key
cancel_fn();
@@ -1196,7 +1257,7 @@
};
$(window).bind("keypress.check_enter_esc", check_enter_esc);
- show_modal("Configure Track", track.gen_options(track.track_id), {
+ show_modal("Configure Track", track.track_config.build_form(), {
"Cancel": cancel_fn,
"OK": ok_fn
});
@@ -1641,6 +1702,7 @@
});
var LineTrack = function ( name, view, hda_ldda, dataset_id, prefs ) {
+ var track = this;
this.track_type = "LineTrack";
this.display_modes = ["Histogram", "Line", "Filled", "Intensity"];
this.mode = "Histogram";
@@ -1655,8 +1717,30 @@
this.original_dataset_id = dataset_id;
this.data_cache = new DataCache(CACHED_DATA);
this.tile_cache = new Cache(CACHED_TILES_LINE);
- this.prefs = { 'color': 'black', 'min_value': undefined, 'max_value': undefined, 'mode': this.mode };
- this.restore_prefs(prefs);
+
+ // Define track configuration
+ this.track_config = new TrackConfig( {
+ track: this,
+ params: [
+ { key: 'color', label: 'Color', type: 'color', default_value: 'black' },
+ { key: 'min_value', label: 'Min Value', type: 'float', default_value: undefined },
+ { key: 'max_value', label: 'Max Value', type: 'float', default_value: undefined },
+ { key: 'mode', type: 'string', default_value: this.mode, hidden: true },
+ { key: 'height', type: 'int', default_value: this.height_px, hidden: true }
+ ],
+ saved_values: prefs,
+ onchange: function() {
+ track.vertical_range = track.prefs.max_value - track.prefs.min_value;
+ // Update the y-axis
+ $('#linetrack_' + track.track_id + '_minval').text(track.prefs.min_value);
+ $('#linetrack_' + track.track_id + '_maxval').text(track.prefs.max_value);
+ track.tile_cache.clear();
+ track.draw();
+ }
+ });
+
+ this.prefs = this.track_config.values;
+ this.height_px = this.track_config.values.height;
// Add control for resizing
// Trickery here to deal with the hovering drag handle, can probably be
@@ -1687,6 +1771,7 @@
track.tile_cache.clear();
in_drag = false;
if ( ! in_handle ) { drag_control.hide(); }
+ track.track_config.values.height_px = track.height_px;
}).appendTo( track.container_div );
})(this);
};
@@ -1854,42 +1939,11 @@
ctx.stroke();
}
return canvas;
- }, gen_options: function(track_id) {
- var container = $("<div />").addClass("form-row");
-
- var color = 'track_' + track_id + '_color',
- color_label = $('<label />').attr("for", color).text("Color:"),
- color_input = $('<input />').attr("id", color).attr("name", color).val(this.prefs.color),
- minval = 'track_' + track_id + '_minval',
- min_label = $('<label></label>').attr("for", minval).text("Min value:"),
- min_val = (this.prefs.min_value === undefined ? "" : this.prefs.min_value),
- min_input = $('<input></input>').attr("id", minval).val(min_val),
- maxval = 'track_' + track_id + '_maxval',
- max_label = $('<label></label>').attr("for", maxval).text("Max value:"),
- max_val = (this.prefs.max_value === undefined ? "" : this.prefs.max_value),
- max_input = $('<input></input>').attr("id", maxval).val(max_val);
-
- return container.append(min_label).append(min_input).append(max_label)
- .append(max_input).append(color_label).append(color_input);
- }, update_options: function(track_id) {
- var min_value = $('#track_' + track_id + '_minval').val(),
- max_value = $('#track_' + track_id + '_maxval').val(),
- color = $('#track_' + track_id + '_color').val();
- if ( min_value !== this.prefs.min_value || max_value !== this.prefs.max_value || color !== this.prefs.color ) {
- this.prefs.min_value = parseFloat(min_value);
- this.prefs.max_value = parseFloat(max_value);
- this.prefs.color = color;
- this.vertical_range = this.prefs.max_value - this.prefs.min_value;
- // Update the y-axis
- $('#linetrack_' + track_id + '_minval').text(this.prefs.min_value);
- $('#linetrack_' + track_id + '_maxval').text(this.prefs.max_value);
- this.tile_cache.clear();
- this.draw();
- }
- }
+ }
});
var FeatureTrack = function (name, view, hda_ldda, dataset_id, prefs, filters, tool, parent_track) {
+ var track = this;
this.track_type = "FeatureTrack";
this.display_modes = ["Auto", "Dense", "Squish", "Pack"];
Track.call(this, name, view, view.viewport_container);
@@ -1914,8 +1968,22 @@
this.data_cache = new DataCache(20);
this.left_offset = 200;
- this.prefs = { 'block_color': '#444', 'label_color': 'black', 'show_counts': true };
- this.restore_prefs(prefs);
+ // Define track configuration
+ this.track_config = new TrackConfig( {
+ track: this,
+ params: [
+ { key: 'block_color', label: 'Block color', type: 'color', default_value: '#444' },
+ { key: 'label_color', label: 'Label color', type: 'color', default_value: 'black' },
+ { key: 'show_counts', label: 'Show summary counts', type: 'bool', default_value: true }
+ ],
+ saved_values: prefs,
+ onchange: function() {
+ track.tile_cache.clear();
+ track.draw();
+ }
+ });
+
+ this.prefs = this.track_config.values;
};
$.extend( FeatureTrack.prototype, TiledTrack.prototype, {
get_data: function( low, high ) {
@@ -2476,33 +2544,6 @@
}
}
return canvas;
- },
- gen_options: function(track_id) {
- var container = $("<div />").addClass("form-row");
-
- var block_color = 'track_' + track_id + '_block_color',
- block_color_label = $('<label />').attr("for", block_color).text("Block color:"),
- block_color_input = $('<input />').attr("id", block_color).attr("name", block_color).val(this.prefs.block_color),
- label_color = 'track_' + track_id + '_label_color',
- label_color_label = $('<label />').attr("for", label_color).text("Text color:"),
- label_color_input = $('<input />').attr("id", label_color).attr("name", label_color).val(this.prefs.label_color),
- show_count = 'track_' + track_id + '_show_count',
- show_count_label = $('<label />').attr("for", show_count).text("Show summary counts"),
- show_count_input = $('<input type="checkbox" style="float:left;"></input>').attr("id", show_count).attr("name", show_count).attr("checked", this.prefs.show_counts),
- show_count_div = $('<div />').append(show_count_input).append(show_count_label);
-
- return container.append(block_color_label).append(block_color_input).append(label_color_label).append(label_color_input).append(show_count_div);
- }, update_options: function(track_id) {
- var block_color = $('#track_' + track_id + '_block_color').val(),
- label_color = $('#track_' + track_id + '_label_color').val(),
- show_counts = $('#track_' + track_id + '_show_count').attr("checked");
- if (block_color !== this.prefs.block_color || label_color !== this.prefs.label_color || show_counts !== this.prefs.show_counts) {
- this.prefs.block_color = block_color;
- this.prefs.label_color = label_color;
- this.prefs.show_counts = show_counts;
- this.tile_cache.clear();
- this.draw();
- }
}
});
http://bitbucket.org/galaxy/galaxy-central/changeset/774738a3e49b/
changeset: r5006:774738a3e49b
user: james_taylor
date: 2011-02-06 06:41:03
summary: trackster: save line track height properly
affected #: 1 file (3 bytes)
--- a/static/scripts/trackster.js Sun Feb 06 00:39:09 2011 -0500
+++ b/static/scripts/trackster.js Sun Feb 06 00:41:03 2011 -0500
@@ -1771,7 +1771,7 @@
track.tile_cache.clear();
in_drag = false;
if ( ! in_handle ) { drag_control.hide(); }
- track.track_config.values.height_px = track.height_px;
+ track.track_config.values.height = track.height_px;
}).appendTo( track.container_div );
})(this);
};
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.
1
0
3 new changesets in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/66a1c6138524/
changeset: r5002:66a1c6138524
user: james_taylor
date: 2011-02-05 21:37:56
summary: Fix problem with adding filters when no data is returned, eliminates one of the problems drawing feature track tiles
affected #: 2 files (50 bytes)
--- a/static/scripts/trackster.js Fri Feb 04 14:48:39 2011 -0500
+++ b/static/scripts/trackster.js Sat Feb 05 15:37:56 2011 -0500
@@ -1638,7 +1638,7 @@
Track.call( this, name, view, view.viewport_container );
TiledTrack.call( this );
- this.min_height_px = 12;
+ this.min_height_px = 16;
this.max_height_px = 400;
this.height_px = 80;
this.hda_ldda = hda_ldda;
@@ -2255,12 +2255,12 @@
ctx.fillText(result.message, 100 + left_offset, y_scale);
return canvas;
}
-
+
//
// If tile is filterable, add class to canvas.
//
for (var f = 0; f < this.filters.length; f++) {
- if (this.filters[f].applies_to(result.data[0])) {
+ if (result.data.length && this.filters[f].applies_to(result.data[0])) {
canvas.addClass(FILTERABLE_CLASS);
break;
}
--- a/templates/tracks/browser.mako Fri Feb 04 14:48:39 2011 -0500
+++ b/templates/tracks/browser.mako Sat Feb 05 15:37:56 2011 -0500
@@ -104,6 +104,7 @@
.track-content {
background: #eee url(${h.url_for('/static/images/tracks/diag_bg.gif')});
min-height: 16px;
+ border-top: 1px solid #eee;
}
.label-track .track-content {
http://bitbucket.org/galaxy/galaxy-central/changeset/c1a6a293c870/
changeset: r5003:c1a6a293c870
user: james_taylor
date: 2011-02-05 21:38:11
summary: Automated merge with https://bitbucket.org/galaxy/galaxy-central
affected #: 1 file (14 bytes)
--- a/static/scripts/trackster.js Fri Feb 04 21:13:36 2011 -0500
+++ b/static/scripts/trackster.js Sat Feb 05 15:38:11 2011 -0500
@@ -1647,7 +1647,7 @@
Track.call( this, name, view, view.viewport_container );
TiledTrack.call( this );
- this.min_height_px = 12;
+ this.min_height_px = 16;
this.max_height_px = 400;
this.height_px = 80;
this.hda_ldda = hda_ldda;
@@ -2264,12 +2264,12 @@
ctx.fillText(result.message, 100 + left_offset, y_scale);
return canvas;
}
-
+
//
// If tile is filterable, add class to canvas.
//
for (var f = 0; f < this.filters.length; f++) {
- if (this.filters[f].applies_to(result.data[0])) {
+ if (result.data.length && this.filters[f].applies_to(result.data[0])) {
canvas.addClass(FILTERABLE_CLASS);
break;
}
--- a/templates/tracks/browser.mako Fri Feb 04 21:13:36 2011 -0500
+++ b/templates/tracks/browser.mako Sat Feb 05 15:38:11 2011 -0500
@@ -104,6 +104,7 @@
.track-content {
background: #eee url(${h.url_for('/static/images/tracks/diag_bg.gif')});
min-height: 16px;
+ border-top: 1px solid #eee;
}
.label-track .track-content {
http://bitbucket.org/galaxy/galaxy-central/changeset/92a7af072bc6/
changeset: r5004:92a7af072bc6
user: james_taylor
date: 2011-02-05 22:04:30
summary: trackster: Move some CSS rules into trackster.css, fix CSS problem with label tracks
affected #: 3 files (4.1 KB)
--- a/static/june_2007_style/blue/trackster.css Sat Feb 05 15:38:11 2011 -0500
+++ b/static/june_2007_style/blue/trackster.css Sat Feb 05 16:04:30 2011 -0500
@@ -18,17 +18,33 @@
.overview-box{cursor:pointer;bottom:0px;z-index:100;position:absolute;margin-top:0px;height:14px;background:#C1C9E5 url(../images/visualization/draggable_horizontal.png) center center no-repeat;border:solid #666 1px;}
.viewport-canvas{width:100%;height:100px;}
.yaxislabel{color:#777;z-index:100;}
-.line-track .track-content{border-top:1px solid #ddd;border-bottom:1px solid #ddd;}
+.line-track .track-content{border-top:1px solid #eee;border-bottom:1px solid #eee;}
.track{background:white;}
.track-header{text-align:left;padding:4px 0px;color:#666;}
.track-header .menubutton{margin-left:0px;}
-.track-content{overflow:hidden;text-align:center;margin-bottom:2px;border-bottom:#eee solid 1px;}
+.track-content{overflow:hidden;text-align:center;margin-bottom:2px;border-top:1px solid #eee;border-bottom:#eee solid 1px;background:#eee url('/static/images/tracks/diag_bg.gif');min-height:16px;}
+.label-track .track-content{background:white;}
+.track-tile{background:white;}
+.track-tile canvas{position:relative;z-index:100;}
.track.error .track-content{background-color:#ECB4AF;padding:2px 0;}
.track.nodata .track-content{background-color:#ddd;padding:2px 0;}
.loading{min-height:100px;}
-.label-track{font-size:10px;border:none;padding:0;margin:0;height:1.3em;}
+.label-track{font-size:10px;border:none;padding:0;margin:0;height:1.5em;overflow:hidden;}
.label-track .label{border-left:solid #999 1px;padding:1px;padding-bottom:2px;display:inline-block;}
+.label-track .track-content{border:none;}
.reference-track{border:none;margin:0;padding:0;}
.right-float{float:right;margin-left:5px;}
.top-labeltrack{position:relative;border-bottom:solid #999 1px;}
.nav-labeltrack{border-top:solid #999 1px;border-bottom:solid #333 1px;}
+.filter-name{float:left;}
+input{font:10px verdana;}
+table.filters{border-collapse:separate;border-spacing:7px 0px;}
+.values{padding-left:0.25em;}
+.dynamic-tool{width:400px;margin-left:0.25em;}
+.param-row{margin-top:0.4em;margin-left:1em;}
+.slider-label{float:left;font-weight:bold;}
+.slider{float:right;width:200px;position:relative;}
+.tool-name{font-size:110%;font-weight:bold;}
+.child-track-icon{background:url('../images/fugue/arrow-000-small-bw.png') no-repeat;width:30px;cursor:move;}
+.param-value{cursor:pointer;}
+.track-resize{background:white url('../images/visualization/draggable_vertical.png') no-repeat top center;position:absolute;right:3px;bottom:-4px;width:14px;height:7px;border:solid #999 1px;z-index:100;}
--- a/static/june_2007_style/trackster.css.tmpl Sat Feb 05 15:38:11 2011 -0500
+++ b/static/june_2007_style/trackster.css.tmpl Sat Feb 05 16:04:30 2011 -0500
@@ -123,8 +123,8 @@
}
/* Line track needs borders to show range */
.line-track .track-content {
- border-top: 1px solid #ddd;
- border-bottom: 1px solid #ddd;
+ border-top: 1px solid #eee;
+ border-bottom: 1px solid #eee;
}
.track {
@@ -147,7 +147,23 @@
overflow: hidden;
text-align: center;
margin-bottom: 2px;
+ border-top: 1px solid #eee;
border-bottom: #eee solid 1px;
+ background: #eee url('/static/images/tracks/diag_bg.gif');
+ min-height: 16px;
+}
+
+.label-track .track-content {
+ background: white;
+}
+
+.track-tile {
+ background: white;
+}
+
+.track-tile canvas {
+ position: relative;
+ z-index: 100;
}
.track.error .track-content {
@@ -162,14 +178,14 @@
.loading {
min-height: 100px;
}
-
.label-track {
/* font-weight: bold; */
font-size: 10px;
border: none;
padding: 0;
margin: 0;
- height: 1.3em;
+ height: 1.5em;
+ overflow: hidden;
}
.label-track .label {
border-left: solid #999 1px;
@@ -177,6 +193,9 @@
padding-bottom: 2px;
display: inline-block;
}
+.label-track .track-content {
+ border: none;
+}
.reference-track {
border: none;
margin: 0;
@@ -195,4 +214,61 @@
.nav-labeltrack {
border-top: solid #999 1px;
border-bottom: solid #333 1px;
+}
+
+## Styles for tools and filters.
+
+.filter-name {
+ float: left;
}
+input {
+ font: 10px verdana;
+}
+table.filters {
+ border-collapse: separate;
+ border-spacing: 7px 0px;
+}
+.values {
+ padding-left: 0.25em;
+}
+.dynamic-tool {
+ width: 400px;
+ margin-left: 0.25em;
+}
+.param-row {
+ margin-top: 0.4em;
+ margin-left: 1em;
+}
+.slider-label {
+ float: left;
+ font-weight: bold;
+}
+.slider {
+ float: right;
+ width: 200px;
+ position: relative;
+}
+.tool-name {
+ font-size: 110%;
+ font-weight: bold;
+}
+.child-track-icon {
+ background:url('../images/fugue/arrow-000-small-bw.png') no-repeat;
+ width: 30px;
+ cursor: move;
+}
+.param-value {
+ cursor: pointer;
+}
+
+.track-resize {
+ background: white url('../images/visualization/draggable_vertical.png') no-repeat top center;
+ position: absolute;
+ right: 3px;
+ bottom: -4px;
+ width: 14px;
+ height: 7px;
+ border: solid #999 1px;
+ z-index: 100;
+}
+
--- a/templates/tracks/browser.mako Sat Feb 05 15:38:11 2011 -0500
+++ b/templates/tracks/browser.mako Sat Feb 05 16:04:30 2011 -0500
@@ -18,16 +18,6 @@
#browser-container {
overflow: none;
}
- ul#sortable-ul {
- list-style: none;
- padding: 0;
- margin: 5px;
- }
- ul#sortable-ul li {
- display: block;
- margin: 5px 0;
- background: #eee;
- }
.nav-container {
width: 100%;
## Overriding styles from trackster.css to push nav up into title bar
@@ -42,83 +32,6 @@
background: transparent;
border: none;
}
- #
- # TODO: move these into trackster.css
- # Styles for tools and filters.
- #
- .filter-name {
- float: left;
- }
- input {
- font: 10px verdana;
- }
- table.filters {
- border-collapse: separate;
- border-spacing: 7px 0px;
- }
- .values {
- padding-left: 0.25em;
- }
- .dynamic-tool {
- width: 400px;
- margin-left: 0.25em;
- }
- .param-row {
- margin-top: 0.4em;
- margin-left: 1em;
- }
- .slider-label {
- float: left;
- font-weight: bold;
- }
- .slider {
- float: right;
- width: 200px;
- position: relative;
- }
- .tool-name {
- font-size: 110%;
- font-weight: bold;
- }
- .child-track-icon {
- background:url(${h.url_for('/static/images/fugue/arrow-000-small-bw.png')}) no-repeat;
- width: 30px;
- cursor: move;
- }
- .param-value {
- cursor: pointer;
- }
-
- .track-resize {
-
- background: white url(${h.url_for('/static/images/visualization/draggable_vertical.png')}) no-repeat top center;
- position: absolute;
- right: 3px;
- bottom: -4px;
- width: 14px;
- height: 7px;
- border: solid #999 1px;
- z-index: 100;
- }
-
- .track-content {
- background: #eee url(${h.url_for('/static/images/tracks/diag_bg.gif')});
- min-height: 16px;
- border-top: 1px solid #eee;
- }
-
- .label-track .track-content {
- background: white;
- }
-
- .track-tile {
- background: white;
- }
-
- .track-tile canvas {
- position: relative;
- z-index: 100;
- }
</style></%def>
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.
1
0
commit/galaxy-central: kanwei: trackster: Reference track should not have the new loading background and min-height
by Bitbucket 04 Feb '11
by Bitbucket 04 Feb '11
04 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/e9c04e1dc30a/
changeset: r5001:e9c04e1dc30a
user: kanwei
date: 2011-02-05 03:13:36
summary: trackster: Reference track should not have the new loading background and min-height
affected #: 2 files (206 bytes)
--- a/static/scripts/packed/trackster.js Fri Feb 04 21:02:23 2011 -0500
+++ b/static/scripts/packed/trackster.js Fri Feb 04 21:13:36 2011 -0500
@@ -1,1 +1,1 @@
-CanvasRenderingContext2D.prototype.dashedLine=function(c,i,b,h,f){if(f==undefined){f=4}var e=b-c;var d=h-i;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var k=e/g;var j=d/g;for(var a=0;a<g;a++,c+=k,i+=j){if(a%2!=0){continue}this.fillRect(c,i,f,1)}};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();for(var c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c==f.length){if(this!=f.get(c-1)){g.append(this)}}else{if(this!=f.get(c)){$(this).insertBefore(f.get(c))}}})}var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,MAX_CHROMS_SELECTABLE=100,CONNECTOR_COLOR="#ccc",DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",FILTERABLE_CLASS="filterable",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}CONTEXT=DUMMY_CANVAS.getContext("2d");PX_PER_CHAR=CONTEXT.measureText("A").width;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function(){RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.move_key_to_end(b,a)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_form=$("<form/>").attr("action",function(){}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.chrom_form);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.chrom_form);this.load_chroms({low:0},d);this.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});this.intro_div.show();this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var i=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(i/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("draginit",function(f,g){if(f.clientX>a.viewport_container.width()-16){return false}}).bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX}).bind("drag",function(h,j){var f=$(this);var k=j.offsetX-j.current_x;var g=f.scrollTop()-(h.clientY-j.current_height);f.scrollTop(g);j.current_height=h.clientY;j.current_x=j.offsetX;var i=Math.round(k/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)}).bind("mousewheel",function(h,j,g,f){if(g){var i=Math.round(-g/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)}});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height(),top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j,k){$(k.proxy).css({left:Math.min(j.pageX,k.startX),width:Math.abs(j.pageX-k.startX)});var g=Math.min(j.pageX,k.startX)-a.container.offset().left,f=Math.max(j.pageX,k.startX)-a.container.offset().left,i=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*i)+a.low,Math.round(f/h*i)+a.low)}).bind("dragend",function(k,l){var g=Math.min(k.pageX,l.startX),f=Math.max(k.pageX,l.startX),i=(a.high-a.low),h=a.viewport_container.width(),j=a.low;a.low=Math.round(g/h*i)+j;a.high=Math.round(f/h*i)+j;$(l.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},load_chroms:function(b,c){b.num=MAX_CHROMS_SELECTABLE;$.extend(b,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var a=this;$.ajax({url:chrom_url,data:b,dataType:"json",success:function(e){if(e.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=e.chrom_info;var h='<option value="">Select Chrom/Contig</option>';for(var g=0,d=a.chrom_data.length;g<d;g++){var f=a.chrom_data[g].chrom;h+='<option value="'+f+'">'+f+"</option>"}if(e.prev_chroms){h+='<option value="previous">Previous '+MAX_CHROMS_SELECTABLE+"</option>"}if(e.next_chroms){h+='<option value="next">Next '+MAX_CHROMS_SELECTABLE+"</option>"}a.chrom_select.html(h);if(c){c()}a.chrom_start_index=e.start_index},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}})},change_chrom:function(e,b,g){var d=this;if(e=="previous"){d.load_chroms({low:this.chrom_start_index-MAX_CHROMS_SELECTABLE});return}if(e=="next"){d.load_chroms({low:this.chrom_start_index+MAX_CHROMS_SELECTABLE});return}var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){d.load_chroms({chrom:e},function(){d.change_chrom(e,b,g)});return}else{if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()}},go_to:function(f){var j=this,a,d,b=f.split(":"),h=b[0],i=b[1];if(i!==undefined){try{var g=i.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}j.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);sortable(a.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_location(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide()}});var Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)==0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e=="int"||e=="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}if(a.view.chrom!=null){$.getJSON(this.dataset_check_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom,low:a.view.max_low,high:a.view.max_high},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").attr("id",d+"_error");c.text("View error");$("#"+d+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b==="data"){a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;a.predraw_init();a.draw()}}}}}}})}},predraw_init:function(){},restore_prefs:function(a){var b=this;$.each(a,function(c,d){if(d!==undefined){b.prefs[c]=d}})},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(g,d,s){var o=this,j=o.view;this.filters=(g!==undefined?get_filters_from_dict(g):[]);this.tool=(d!==undefined?get_tool_from_dict(d):undefined);this.parent_track=s;this.child_tracks=[];if(o.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filtering_div=$("<div/>").addClass("track-filters").hide();this.header_div.after(this.filtering_div);this.filtering_div.bind("drag",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var t=$("<table class='filters'>").appendTo(this.filtering_div);$.each(this.filters,function(w,z){var v=$("<tr>").appendTo(t);var y=$("<th class='filter-info'>").appendTo(v);var u=$("<span class='name'>").appendTo(y);u.text(z.name+" ");var i=$("<span class='values'>").appendTo(y);var x=$("<td>").appendTo(v);z.control_element=$("<div id='"+z.name+"-filter-control' style='width: 200px; position: relative'>").appendTo(x);z.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(B,C){var A=C.values;i.text("["+A[0]+"-"+A[1]+"]");z.low=A[0];z.high=A[1];o.draw(true)},change:function(A,B){z.control_element.slider("option","slide").call(z.control_element,A,B)}});z.slider=z.control_element;z.slider_label=i});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(i){i.stopPropagation()}).bind("click",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var l=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var e=this.tool.params;var o=this;$.each(this.tool.params,function(A,v){var y=$("<div>").addClass("param-row").appendTo(o.dynamic_tool_div);var x=$("<div>").addClass("slider-label").appendTo(y);var C=$("<span class='param-name'>").text(v.label+" ").appendTo(x);var w=$("<span/>").text(v.value);var z=$("<span class='param-value'>").appendTo(x).append("[").append(w).append("]");var B=$("<div/>").addClass("slider").appendTo(y);var i=$("<div id='"+v.name+"-param-control'>").appendTo(B);var u=(v.max<=1?0.01:(v.max<=1000?1:5));i.slider({min:v.min,max:v.max,step:u,value:v.value,slide:function(D,F){var E=F.value;v.value=E;if(0<E&&E<1){E=parseFloat(E).toFixed(2)}w.text(E)},change:function(D,E){v.value=E.value}});z.click(function(){var F=w,E=F.text(),D=(v.max<=1?4:v.max.length);F.text("");$("<input type='text'/>").attr("size",D).attr("maxlength",D).attr("value",E).appendTo(F).focus().select().click(function(G){G.stopPropagation()}).blur(function(){$(this).remove();F.text(E)}).keyup(function(I){if(I.keyCode===27){$(this).trigger("blur")}else{if(I.keyCode===13){var G=$(this),H=parseFloat(G.val());if(isNaN(H)||H>v.max||H<v.min){alert("Parameter value must be in the range ["+v.min+"-"+v.max+"]");return $(this)}F.text(H);i.slider("value",H);v.value=H}}})});$("<div style='clear: both;'/>").appendTo(y)});var b=$("<div>").addClass("param-row").appendTo(this.dynamic_tool_div);var n=$("<input type='submit'>").attr("value","Run").appendTo(b);var o=this;n.click(function(){o.run_tool()})}o.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();o.container_div.append(o.child_tracks_container);if(o.display_modes!==undefined){if(o.mode_div===undefined){o.mode_div=$("<div class='right-float menubutton popup' />").appendTo(o.header_div);var m=o.display_modes[0];o.mode=m;o.mode_div.text(m);var a=function(i){o.mode_div.text(i);o.mode=i;o.tile_cache.clear();o.draw()};var f={};for(var q=0,r=o.display_modes.length;q<r;q++){var k=o.display_modes[q];f[k]=function(i){return function(){a(i)}}(k)}make_popupmenu(o.mode_div,f)}else{o.mode_div.hide()}}var h={};h["Edit configuration"]=function(){var v=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},i=function(){o.update_options(o.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},u=function(w){if((w.keyCode||w.which)===27){v()}else{if((w.keyCode||w.which)===13){i()}}};$(window).bind("keypress.check_enter_esc",u);show_modal("Configure Track",o.gen_options(o.track_id),{Cancel:v,OK:i})};h["Set as overview"]=function(){j.overview_viewport.find("canvas").remove();o.is_overview=true;o.set_overview();for(var i in j.tracks){if(j.tracks[i]!==o){j.tracks[i].is_overview=false}}};if(o.filters.length>0){h["Show filters"]=function(){var i;if(!o.filtering_div.is(":visible")){i="Hide filters";o.filters_visible=true}else{i="Show filters";o.filters_visible=false}o.filtering_div.toggle()}}if(o.tool){h["Toggle Tool"]=function(){var i;if(!o.dynamic_tool_div.is(":visible")){i="Hide dynamic tool";o.update_name(o.name+o.tool_region_and_parameters_str())}else{i="Show dynamic tool";o.revert_name()}o.dynamic_tool_div.toggle()}}var c=j;var p=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;p=function(){}}h.Remove=function(){c.remove_track(o);if(c.num_tracks===0){p()}};o.popup_menu=make_popupmenu(o.name_div,h)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(a){var l=this.view.low,f=this.view.high,h=f-l,e=this.view.resolution;var o=$("<div style='position: relative;'></div>"),q=this.content_div.width()/h;this.content_div.append(o);this.max_height=0;var b=Math.floor(l/e/DENSITY);var k=0;while((b*DENSITY*e)<f){var m=this.content_div.width()+"_"+q+"_"+b;var d=this.tile_cache.get(m);var j=b*DENSITY*this.view.resolution;var p=j+DENSITY*this.view.resolution;if(!a&&d){this.show_tile(d,o,j)}else{this.delayed_draw(a,m,j,p,b,e,o,q,k)}b+=1}var c=this;var n=setInterval(function(){if(k===0){var t=c.content_div.children();var s=false;for(var u=t.length-1,r=0;u>=r;u--){var w=$(t[u]);if(s){w.remove()}else{if(w.children().length!==0){s=true}}}for(var v=0;v<c.filters.length;v++){c.filters[v].update_ui_elt()}clearInterval(n)}},50);for(var g=0;g<this.child_tracks.length;g++){this.child_tracks[g].draw(a)}},delayed_draw:function(b,h,g,j,c,e,i,k,f){var d=this;var a=setTimeout(function(){if(g<=d.view.high&&j>=d.view.low){var l;if(!b){l=d.tile_cache.get(h)}if(!l){l=d.draw_tile(e,c,i,k)}if(l){if(!d.initial_canvas&&!window.G_vmlCanvasManager){d.initial_canvas=$(l).clone();var o=l.get(0).getContext("2d");var m=d.initial_canvas.get(0).getContext("2d");var n=o.getImageData(0,0,o.canvas.width,o.canvas.height);m.putImageData(n,0,0);d.set_overview()}d.tile_cache.set(h,l);d.show_tile(l,i,g)}}delete f--},50);f++},show_tile:function(a,f,d){var b=this;var c=this.view.high-this.view.low,g=this.content_div.width()/c,e=(d-this.view.low)*g;if(this.left_offset){e-=this.left_offset}a.css({position:"absolute",top:0,left:e});f.append(a);b.max_height=Math.max(b.max_height,a.height());b.content_div.css("height",b.max_height+"px");if(b.hidden){return}if(a.hasClass(FILTERABLE_CLASS)){show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters");if(b.filters_visible){b.filtering_div.show()}}else{show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters",false);b.filtering_div.hide()}},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type=="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f=="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f=="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.data_queue={};this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(f,b,k,o){var g=b*DENSITY*f,d=DENSITY*f,j=f+"_"+b;var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var n=e.get(0).getContext("2d");if(o>PX_PER_CHAR){if(this.data_cache.get(j)===undefined){this.get_data(f,b);return}var m=this.data_cache.get(j);if(m===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*o+this.left_offset);e.get(0).height=this.height_px;for(var h=0,l=m.length;h<l;h++){var a=Math.round(h*o),i=Math.round(o/2);n.fillText(m[h],a+this.left_offset+i,10)}k.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,e,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.min_height_px=12;this.max_height_px=400;this.height_px=80;this.hda_ldda=e;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};this.restore_prefs(c);(function(f){var i=false;var h=false;var g=$("<div class='track-resize'>");$(f.container_div).hover(function(){i=true;g.show()},function(){i=false;if(!h){g.hide()}});g.hide().bind("dragstart",function(j,k){h=true;k.original_height=$(f.content_div).height()}).bind("drag",function(k,l){var j=Math.min(Math.max(l.original_height+l.deltaY,f.min_height_px),f.max_height_px);$(f.content_div).css("height",j);f.height_px=j;f.draw(true)}).bind("dragend",function(j,k){f.tile_cache.clear();h=false;if(!i){g.hide()}}).appendTo(f.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;$.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:this.data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){var h=g.data;c.data_cache.set(e,h);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*o,a=DENSITY*o,x=o+"_"+r;var b=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);if(this.data_cache.get(x)===undefined){this.get_data(o,r);return}var v=this.data_cache.get(x);if(!v){return}b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var n=b.get(0).getContext("2d"),j=false,k=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,t=this.total_frequency,d=this.height_px,l=this.mode;var w=Math.round(d+k/m*d);n.beginPath();n.moveTo(0,w);n.lineTo(a*e,w);n.fillStyle="#aaa";n.stroke();n.beginPath();n.fillStyle=this.prefs.color;var u,h,f;if(v.length>1){f=Math.ceil((v[1][0]-v[0][0])*e)}else{f=10}for(var p=0,q=v.length;p<q;p++){u=Math.round((v[p][0]-s)*e);h=v[p][1];if(h===null){if(j&&l==="Filled"){n.lineTo(u,d)}j=false;continue}if(h<k){h=k}else{if(h>g){h=g}}if(l==="Histogram"){h=Math.round(h/m*d);n.fillRect(u,w,f,-h)}else{if(l==="Intensity"){h=255-Math.floor((h-k)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(u,0,f,d)}else{h=Math.round(d-(h-k)/m*d);if(j){n.lineTo(u,h)}else{j=true;if(l==="Filled"){n.moveTo(u,d);n.lineTo(u,h)}else{n.moveTo(u,h)}}}}}if(l==="Filled"){if(j){n.lineTo(u,w);n.lineTo(0,w)}n.fill()}else{n.stroke()}return b},gen_options:function(m){var a=$("<div />").addClass("form-row");var e="track_"+m+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+m+"_minval",l=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),k=$("<input></input>").attr("id",h).val(d),j="track_"+m+"_maxval",g=$("<label></label>").attr("for",j).text("Max value:"),i=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",j).val(i);return a.append(l).append(k).append(g).append(f).append(b).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_color").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.color=b;this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+d+"_minval").text(this.prefs.min_value);$("#linetrack_"+d+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(f,c,h,a,e,g,d,b){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,f,c,c.viewport_container);TiledTrack.call(this,g,d,b);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=h;this.dataset_id=a;this.original_dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200;this.prefs={block_color:"#444",label_color:"black",show_counts:true};this.restore_prefs(e)};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(b.data_url,{chrom:b.view.chrom,low:a,high:d,hda_ldda:b.hda_ldda,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set_data(a,d,b.mode,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,b,p){var r=this.inc_slots[a];if(!r||(r.mode!==p)){r={};r.w_scale=a;r.mode=p;this.inc_slots[a]=r;this.s_e_by_tile[a]={}}var l=r.w_scale,x=[],y=[],j=0,n=this.view.max_low;for(var v=0,w=h.length;v<w;v++){var g=h[v],k=g[0];if(r[k]!==undefined){j=Math.max(j,r[k]);y.push(r[k])}else{x.push(v)}}var q=this.s_e_by_tile[a];var m=function(D,E){var C;for(var B=0,F;B<=MAX_FEATURE_DEPTH;B++){C=true;F=q[B];if(F!==undefined){for(var z=0,A=F.length;z<A;z++){var i=F[z];if(E>i[0]&&D<i[1]){C=false;break}}}if(C){break}}if(C){return B}else{return -1}};for(var v=0,w=x.length;v<w;v++){var g=h[x[v]],k=g[0],t=g[1],c=g[2],o=g[3],d=Math.floor((t-n)*l),f=Math.ceil((c-n)*l),u=CONTEXT.measureText(o).width,e;if(o!==undefined&&!b){if(d-u<0){f+=u;e="left"}else{d-=u;e="right"}}var s=m(d,f);if(s<0){}if(s>=0){slot=q[s];if(slot===undefined){slot=q[s]=[]}slot.push([d,f]);r[k]=s;j=Math.max(j,s)}else{}}return j},rect_or_text:function(r,l,u,b,q,j,g,f){r.textAlign="center";var d=0,s=0,p=Math.round(l/2);for(var m=0,t=j.length;m<t;m++){var k=j[m],e="MIDNSHP=X"[k[0]],n=k[1];if(e==="H"||e==="S"){d-=n}var h=q+d,x=Math.floor(Math.max(0,(h-u)*l)),i=Math.floor(Math.max(0,(h+n-u)*l));switch(e){case"H":break;case"S":case"M":case"=":var o=g.slice(s,s+n);if((this.mode==="Pack"||this.mode==="Auto")&&g!==undefined&&l>PX_PER_CHAR){r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+1,i-x,9);r.fillStyle=CONNECTOR_COLOR;for(var v=0,a=o.length;v<a;v++){if(h+v>=u&&h+v<=b){var w=Math.floor(Math.max(0,(h+v-u)*l));r.fillText(o[v],w+this.left_offset+p,f+9)}}}else{r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+(this.mode!="Dense"?4:5),i-x,(this.mode!="Dense"?3:1))}s+=n;break;case"N":r.fillStyle=CONNECTOR_COLOR;r.fillRect(x+this.left_offset,f+5,i-x,1);break;case"D":r.fillStyle="red";r.fillRect(x+this.left_offset,f+4,i-x,3);break;case"P":break;case"I":s+=n;break;case"X":s+=n;break}d+=n}},draw_tile:function(ad,n,r,ar){var L=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,K=ai-L;var G=this.data_cache.get_data(L,ai,this.mode);if(G===undefined||G==="pending"||(this.mode!=="Auto"&&G.dataset_type==="summary_tree")){this.data_queue[[L,ai]]=true;this.get_data(L,ai);return}var a=Math.ceil(K*ar),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,v=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,aq,B,at;var p=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(p)}p=$(p);if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(q==="Dense"){B=v;at=10}else{at=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ar<0.0001?1/this.view.zoom_res:ar);B=this.incremental_slots(w,G.data,ab,q)*at+v;aq=this.inc_slots[w]}}p.get(0).width=a+U;p.get(0).height=B;r.parent().css("height",Math.max(this.height_px,B)+"px");var H=p.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";this.container_div.find(".yaxislabel").remove();if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,b=Math.ceil(G.delta*ar);var o=$("<div />").addClass("yaxislabel");o.text(J);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,F=W.length;am<F;am++){var Y=Math.floor((W[am][0]-L)*ar);var X=W[am][1];if(!X){continue}var aj=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}return p}if(G.message){p.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,at);return p}for(var ao=0;ao<this.filters.length;ao++){if(this.filters[ao].applies_to(G.data[0])){p.addClass(FILTERABLE_CLASS);break}}var ap=G.data;var al=0;for(var am=0,F=ap.length;am<F;am++){var Q=ap[am],P=Q[0],an=Q[1],aa=Q[2],M=Q[3];if(this.mode!="Dense"&&aq[P]===undefined){continue}var Z=false;var S;for(var ao=0;ao<this.filters.length;ao++){S=this.filters[ao];S.update_attrs(Q);if(!S.keep(Q)){Z=true;break}}if(Z){continue}if(an<=ai&&aa>=L){var ac=Math.floor(Math.max(0,(an-L)*ar)),I=Math.ceil(Math.min(a,Math.max(0,(aa-L)*ar))),V=(q==="Dense"?1:(1+aq[P]))*at;var E,ag,N=null,au=null;if(G.dataset_type==="bai"){H.fillStyle=h;if(Q[5] instanceof Array){var C=Math.floor(Math.max(0,(Q[4][0]-L)*ar)),O=Math.ceil(Math.min(a,Math.max(0,(Q[4][1]-L)*ar))),A=Math.floor(Math.max(0,(Q[5][0]-L)*ar)),u=Math.ceil(Math.min(a,Math.max(0,(Q[5][1]-L)*ar)));if(Q[4][1]>=L&&Q[4][0]<=ai&&Q[4][2]){this.rect_or_text(H,ar,L,ai,Q[4][0],Q[4][2],Q[4][3],V)}if(Q[5][1]>=L&&Q[5][0]<=ai&&Q[5][2]){this.rect_or_text(H,ar,L,ai,Q[5][0],Q[5][2],Q[5][3],V)}if(A>O){H.fillStyle=CONNECTOR_COLOR;H.dashedLine(O+U,V+5,U+A,V+5)}}else{H.fillStyle=h;this.rect_or_text(H,ar,L,ai,an,Q[4],Q[5],V)}if(q!=="Dense"&&!ab&&an>L){H.fillStyle=this.prefs.label_color;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var D=Q[5],T=Q[6],ae=Q[7],g=Q[8];if(T&&ae){N=Math.floor(Math.max(0,(T-L)*ar));au=Math.ceil(Math.min(a,Math.max(0,(ae-L)*ar)))}if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}if(g){if(D){if(D=="+"){H.fillStyle=RIGHT_STRAND}else{if(D=="-"){H.fillStyle=LEFT_STRAND}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}for(var ak=0,e=g.length;ak<e;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-L)*ar)),R=Math.ceil(Math.min(a,Math.max((t[1]-L)*ar)));if(d>R){continue}E=5;ag=3;H.fillRect(d+U,V+ag,R-d,E);if(N!==undefined&&!(d>au||R<N)){E=9;ag=1;var ah=Math.max(d,N),z=Math.min(R,au);H.fillRect(ah+U,V+ag,z-ah,E)}}}else{E=9;ag=1;H.fillRect(ac+U,V+ag,I-ac,E);if(Q.strand){if(Q.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(Q.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var s=Q[4],m=Q[5],c=Q[6];E=9;ag=1;H.fillRect(ac+U,V,I-ac,E);if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}var l=s+" / "+m;if(an>L&&H.measureText(l).width<(I-ac)){H.fillStyle="white";H.textAlign="center";H.fillText(l,U+ac+(I-ac)/2,V+8);H.fillStyle=h}}}}}al++}}return p},gen_options:function(i){var a=$("<div />").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label />").attr("for",e).text("Block color:"),l=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label />").attr("for",j).text("Text color:"),h=$("<input />").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(k).append(l).append(g).append(h).append(d)},update_options:function(d){var b=$("#track_"+d+"_block_color").val(),c=$("#track_"+d+"_label_color").val(),a=$("#track_"+d+"_show_count").attr("checked");if(b!==this.prefs.block_color||c!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=c;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()==0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id},function(c){})}};a()}});
\ No newline at end of file
+CanvasRenderingContext2D.prototype.dashedLine=function(c,i,b,h,f){if(f==undefined){f=4}var e=b-c;var d=h-i;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var k=e/g;var j=d/g;for(var a=0;a<g;a++,c+=k,i+=j){if(a%2!=0){continue}this.fillRect(c,i,f,1)}};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();for(var c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c==f.length){if(this!=f.get(c-1)){g.append(this)}}else{if(this!=f.get(c)){$(this).insertBefore(f.get(c))}}})}var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,MAX_CHROMS_SELECTABLE=100,CONNECTOR_COLOR="#ccc",DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",FILTERABLE_CLASS="filterable",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}CONTEXT=DUMMY_CANVAS.getContext("2d");PX_PER_CHAR=CONTEXT.measureText("A").width;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function(){RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.move_key_to_end(b,a)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_form=$("<form/>").attr("action",function(){}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.chrom_form);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.chrom_form);this.load_chroms({low:0},d);this.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});this.intro_div.show();this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var i=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(i/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("draginit",function(f,g){if(f.clientX>a.viewport_container.width()-16){return false}}).bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX}).bind("drag",function(h,j){var f=$(this);var k=j.offsetX-j.current_x;var g=f.scrollTop()-(h.clientY-j.current_height);f.scrollTop(g);j.current_height=h.clientY;j.current_x=j.offsetX;var i=Math.round(k/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)}).bind("mousewheel",function(h,j,g,f){if(g){var i=Math.round(-g/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)}});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height(),top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j,k){$(k.proxy).css({left:Math.min(j.pageX,k.startX),width:Math.abs(j.pageX-k.startX)});var g=Math.min(j.pageX,k.startX)-a.container.offset().left,f=Math.max(j.pageX,k.startX)-a.container.offset().left,i=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*i)+a.low,Math.round(f/h*i)+a.low)}).bind("dragend",function(k,l){var g=Math.min(k.pageX,l.startX),f=Math.max(k.pageX,l.startX),i=(a.high-a.low),h=a.viewport_container.width(),j=a.low;a.low=Math.round(g/h*i)+j;a.high=Math.round(f/h*i)+j;$(l.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},load_chroms:function(b,c){b.num=MAX_CHROMS_SELECTABLE;$.extend(b,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var a=this;$.ajax({url:chrom_url,data:b,dataType:"json",success:function(e){if(e.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=e.chrom_info;var h='<option value="">Select Chrom/Contig</option>';for(var g=0,d=a.chrom_data.length;g<d;g++){var f=a.chrom_data[g].chrom;h+='<option value="'+f+'">'+f+"</option>"}if(e.prev_chroms){h+='<option value="previous">Previous '+MAX_CHROMS_SELECTABLE+"</option>"}if(e.next_chroms){h+='<option value="next">Next '+MAX_CHROMS_SELECTABLE+"</option>"}a.chrom_select.html(h);if(c){c()}a.chrom_start_index=e.start_index},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}})},change_chrom:function(e,b,g){if(!e||e==="None"){return}var d=this;if(e=="previous"){d.load_chroms({low:this.chrom_start_index-MAX_CHROMS_SELECTABLE});return}if(e=="next"){d.load_chroms({low:this.chrom_start_index+MAX_CHROMS_SELECTABLE});return}var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){d.load_chroms({chrom:e},function(){d.change_chrom(e,b,g)});return}else{if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()}},go_to:function(f){var j=this,a,d,b=f.split(":"),h=b[0],i=b[1];if(i!==undefined){try{var g=i.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}j.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);sortable(a.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_location(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide()}});var Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)==0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e=="int"||e=="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}if(a.view.chrom!=null){$.getJSON(this.dataset_check_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom,low:a.view.max_low,high:a.view.max_high},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").attr("id",d+"_error");c.text("View error");$("#"+d+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b==="data"){a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;a.predraw_init();a.draw()}}}}}}})}},predraw_init:function(){},restore_prefs:function(a){var b=this;$.each(a,function(c,d){if(d!==undefined){b.prefs[c]=d}})},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(g,d,s){var o=this,j=o.view;this.filters=(g!==undefined?get_filters_from_dict(g):[]);this.tool=(d!==undefined?get_tool_from_dict(d):undefined);this.parent_track=s;this.child_tracks=[];if(o.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filtering_div=$("<div/>").addClass("track-filters").hide();this.header_div.after(this.filtering_div);this.filtering_div.bind("drag",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var t=$("<table class='filters'>").appendTo(this.filtering_div);$.each(this.filters,function(w,z){var v=$("<tr>").appendTo(t);var y=$("<th class='filter-info'>").appendTo(v);var u=$("<span class='name'>").appendTo(y);u.text(z.name+" ");var i=$("<span class='values'>").appendTo(y);var x=$("<td>").appendTo(v);z.control_element=$("<div id='"+z.name+"-filter-control' style='width: 200px; position: relative'>").appendTo(x);z.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(B,C){var A=C.values;i.text("["+A[0]+"-"+A[1]+"]");z.low=A[0];z.high=A[1];o.draw(true)},change:function(A,B){z.control_element.slider("option","slide").call(z.control_element,A,B)}});z.slider=z.control_element;z.slider_label=i});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(i){i.stopPropagation()}).bind("click",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var l=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var e=this.tool.params;var o=this;$.each(this.tool.params,function(A,v){var y=$("<div>").addClass("param-row").appendTo(o.dynamic_tool_div);var x=$("<div>").addClass("slider-label").appendTo(y);var C=$("<span class='param-name'>").text(v.label+" ").appendTo(x);var w=$("<span/>").text(v.value);var z=$("<span class='param-value'>").appendTo(x).append("[").append(w).append("]");var B=$("<div/>").addClass("slider").appendTo(y);var i=$("<div id='"+v.name+"-param-control'>").appendTo(B);var u=(v.max<=1?0.01:(v.max<=1000?1:5));i.slider({min:v.min,max:v.max,step:u,value:v.value,slide:function(D,F){var E=F.value;v.value=E;if(0<E&&E<1){E=parseFloat(E).toFixed(2)}w.text(E)},change:function(D,E){v.value=E.value}});z.click(function(){var F=w,E=F.text(),D=(v.max<=1?4:v.max.length);F.text("");$("<input type='text'/>").attr("size",D).attr("maxlength",D).attr("value",E).appendTo(F).focus().select().click(function(G){G.stopPropagation()}).blur(function(){$(this).remove();F.text(E)}).keyup(function(I){if(I.keyCode===27){$(this).trigger("blur")}else{if(I.keyCode===13){var G=$(this),H=parseFloat(G.val());if(isNaN(H)||H>v.max||H<v.min){alert("Parameter value must be in the range ["+v.min+"-"+v.max+"]");return $(this)}F.text(H);i.slider("value",H);v.value=H}}})});$("<div style='clear: both;'/>").appendTo(y)});var b=$("<div>").addClass("param-row").appendTo(this.dynamic_tool_div);var n=$("<input type='submit'>").attr("value","Run").appendTo(b);var o=this;n.click(function(){o.run_tool()})}o.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();o.container_div.append(o.child_tracks_container);if(o.display_modes!==undefined){if(o.mode_div===undefined){o.mode_div=$("<div class='right-float menubutton popup' />").appendTo(o.header_div);var m=o.display_modes[0];o.mode=m;o.mode_div.text(m);var a=function(i){o.mode_div.text(i);o.mode=i;o.tile_cache.clear();o.draw()};var f={};for(var q=0,r=o.display_modes.length;q<r;q++){var k=o.display_modes[q];f[k]=function(i){return function(){a(i)}}(k)}make_popupmenu(o.mode_div,f)}else{o.mode_div.hide()}}var h={};h["Edit configuration"]=function(){var v=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},i=function(){o.update_options(o.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},u=function(w){if((w.keyCode||w.which)===27){v()}else{if((w.keyCode||w.which)===13){i()}}};$(window).bind("keypress.check_enter_esc",u);show_modal("Configure Track",o.gen_options(o.track_id),{Cancel:v,OK:i})};h["Set as overview"]=function(){j.overview_viewport.find("canvas").remove();o.is_overview=true;o.set_overview();for(var i in j.tracks){if(j.tracks[i]!==o){j.tracks[i].is_overview=false}}};if(o.filters.length>0){h["Show filters"]=function(){var i;if(!o.filtering_div.is(":visible")){i="Hide filters";o.filters_visible=true}else{i="Show filters";o.filters_visible=false}o.filtering_div.toggle()}}if(o.tool){h["Toggle Tool"]=function(){var i;if(!o.dynamic_tool_div.is(":visible")){i="Hide dynamic tool";o.update_name(o.name+o.tool_region_and_parameters_str())}else{i="Show dynamic tool";o.revert_name()}o.dynamic_tool_div.toggle()}}var c=j;var p=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;p=function(){}}h.Remove=function(){c.remove_track(o);if(c.num_tracks===0){p()}};o.popup_menu=make_popupmenu(o.name_div,h)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(a){var l=this.view.low,f=this.view.high,h=f-l,e=this.view.resolution;var o=$("<div style='position: relative;'></div>"),q=this.content_div.width()/h;this.content_div.append(o);this.max_height=0;var b=Math.floor(l/e/DENSITY);var k=0;while((b*DENSITY*e)<f){var m=this.content_div.width()+"_"+q+"_"+b;var d=this.tile_cache.get(m);var j=b*DENSITY*this.view.resolution;var p=j+DENSITY*this.view.resolution;if(!a&&d){this.show_tile(d,o,j)}else{this.delayed_draw(a,m,j,p,b,e,o,q,k)}b+=1}var c=this;var n=setInterval(function(){if(k===0){var t=c.content_div.children();var s=false;for(var u=t.length-1,r=0;u>=r;u--){var w=$(t[u]);if(s){w.remove()}else{if(w.children().length!==0){s=true}}}for(var v=0;v<c.filters.length;v++){c.filters[v].update_ui_elt()}clearInterval(n)}},50);for(var g=0;g<this.child_tracks.length;g++){this.child_tracks[g].draw(a)}},delayed_draw:function(b,h,g,j,c,e,i,k,f){var d=this;var a=setTimeout(function(){if(g<=d.view.high&&j>=d.view.low){var l;if(!b){l=d.tile_cache.get(h)}if(!l){l=d.draw_tile(e,c,i,k);if(l){var m=$("<div class='track-tile'>").prepend(l);if(l.hasClass(FILTERABLE_CLASS)){m.addClass(FILTERABLE_CLASS)}l=m}}if(l){d.tile_cache.set(h,l);d.show_tile(l,i,g)}}delete f--},50);f++},show_tile:function(a,f,d){var b=this;var c=this.view.high-this.view.low,g=this.content_div.width()/c,e=(d-this.view.low)*g;if(this.left_offset){e-=this.left_offset}a.css({position:"absolute",top:0,left:e,height:""});f.append(a);b.max_height=Math.max(b.max_height,a.height());b.content_div.css("height",b.max_height+"px");f.children().css("height",b.max_height+"px");if(b.hidden){return}if(a.hasClass(FILTERABLE_CLASS)){show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters");if(b.filters_visible){b.filtering_div.show()}}else{show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters",false);b.filtering_div.hide()}},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type=="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f=="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f=="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.content_div.css("background","none");this.content_div.css("min-height","0px");this.content_div.css("border","none");this.data_queue={};this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(f,b,k,o){var g=b*DENSITY*f,d=DENSITY*f,j=f+"_"+b;var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var n=e.get(0).getContext("2d");if(o>PX_PER_CHAR){if(this.data_cache.get(j)===undefined){this.get_data(f,b);return}var m=this.data_cache.get(j);if(m===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*o+this.left_offset);e.get(0).height=this.height_px;for(var h=0,l=m.length;h<l;h++){var a=Math.round(h*o),i=Math.round(o/2);n.fillText(m[h],a+this.left_offset+i,10)}k.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,e,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.min_height_px=12;this.max_height_px=400;this.height_px=80;this.hda_ldda=e;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};this.restore_prefs(c);(function(f){var i=false;var h=false;var g=$("<div class='track-resize'>");$(f.container_div).hover(function(){i=true;g.show()},function(){i=false;if(!h){g.hide()}});g.hide().bind("dragstart",function(j,k){h=true;k.original_height=$(f.content_div).height()}).bind("drag",function(k,l){var j=Math.min(Math.max(l.original_height+l.deltaY,f.min_height_px),f.max_height_px);$(f.content_div).css("height",j);f.height_px=j;f.draw(true)}).bind("dragend",function(j,k){f.tile_cache.clear();h=false;if(!i){g.hide()}}).appendTo(f.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;$.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:this.data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){var h=g.data;c.data_cache.set(e,h);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*o,a=DENSITY*o,x=o+"_"+r;var b=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);if(this.data_cache.get(x)===undefined){this.get_data(o,r);return}var v=this.data_cache.get(x);if(!v){return}b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var n=b.get(0).getContext("2d"),j=false,k=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,t=this.total_frequency,d=this.height_px,l=this.mode;var w=Math.round(d+k/m*d);n.beginPath();n.moveTo(0,w);n.lineTo(a*e,w);n.fillStyle="#aaa";n.stroke();n.beginPath();n.fillStyle=this.prefs.color;var u,h,f;if(v.length>1){f=Math.ceil((v[1][0]-v[0][0])*e)}else{f=10}for(var p=0,q=v.length;p<q;p++){u=Math.round((v[p][0]-s)*e);h=v[p][1];if(h===null){if(j&&l==="Filled"){n.lineTo(u,d)}j=false;continue}if(h<k){h=k}else{if(h>g){h=g}}if(l==="Histogram"){h=Math.round(h/m*d);n.fillRect(u,w,f,-h)}else{if(l==="Intensity"){h=255-Math.floor((h-k)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(u,0,f,d)}else{h=Math.round(d-(h-k)/m*d);if(j){n.lineTo(u,h)}else{j=true;if(l==="Filled"){n.moveTo(u,d);n.lineTo(u,h)}else{n.moveTo(u,h)}}}}}if(l==="Filled"){if(j){n.lineTo(u,w);n.lineTo(0,w)}n.fill()}else{n.stroke()}return b},gen_options:function(m){var a=$("<div />").addClass("form-row");var e="track_"+m+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+m+"_minval",l=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),k=$("<input></input>").attr("id",h).val(d),j="track_"+m+"_maxval",g=$("<label></label>").attr("for",j).text("Max value:"),i=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",j).val(i);return a.append(l).append(k).append(g).append(f).append(b).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_color").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.color=b;this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+d+"_minval").text(this.prefs.min_value);$("#linetrack_"+d+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(f,c,h,a,e,g,d,b){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,f,c,c.viewport_container);TiledTrack.call(this,g,d,b);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=h;this.dataset_id=a;this.original_dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200;this.prefs={block_color:"#444",label_color:"black",show_counts:true};this.restore_prefs(e)};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(b.data_url,{chrom:b.view.chrom,low:a,high:d,hda_ldda:b.hda_ldda,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set_data(a,d,b.mode,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,b,p){var r=this.inc_slots[a];if(!r||(r.mode!==p)){r={};r.w_scale=a;r.mode=p;this.inc_slots[a]=r;this.s_e_by_tile[a]={}}var l=r.w_scale,x=[],y=[],j=0,n=this.view.max_low;for(var v=0,w=h.length;v<w;v++){var g=h[v],k=g[0];if(r[k]!==undefined){j=Math.max(j,r[k]);y.push(r[k])}else{x.push(v)}}var q=this.s_e_by_tile[a];var m=function(D,E){var C;for(var B=0,F;B<=MAX_FEATURE_DEPTH;B++){C=true;F=q[B];if(F!==undefined){for(var z=0,A=F.length;z<A;z++){var i=F[z];if(E>i[0]&&D<i[1]){C=false;break}}}if(C){break}}if(C){return B}else{return -1}};for(var v=0,w=x.length;v<w;v++){var g=h[x[v]],k=g[0],t=g[1],c=g[2],o=g[3],d=Math.floor((t-n)*l),f=Math.ceil((c-n)*l),u=CONTEXT.measureText(o).width,e;if(o!==undefined&&!b){if(d-u<0){f+=u;e="left"}else{d-=u;e="right"}}var s=m(d,f);if(s<0){}if(s>=0){slot=q[s];if(slot===undefined){slot=q[s]=[]}slot.push([d,f]);r[k]=s;j=Math.max(j,s)}else{}}return j},rect_or_text:function(r,l,u,b,q,j,g,f){r.textAlign="center";var d=0,s=0,p=Math.round(l/2);for(var m=0,t=j.length;m<t;m++){var k=j[m],e="MIDNSHP=X"[k[0]],n=k[1];if(e==="H"||e==="S"){d-=n}var h=q+d,x=Math.floor(Math.max(0,(h-u)*l)),i=Math.floor(Math.max(0,(h+n-u)*l));switch(e){case"H":break;case"S":case"M":case"=":var o=g.slice(s,s+n);if((this.mode==="Pack"||this.mode==="Auto")&&g!==undefined&&l>PX_PER_CHAR){r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+1,i-x,9);r.fillStyle=CONNECTOR_COLOR;for(var v=0,a=o.length;v<a;v++){if(h+v>=u&&h+v<=b){var w=Math.floor(Math.max(0,(h+v-u)*l));r.fillText(o[v],w+this.left_offset+p,f+9)}}}else{r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+(this.mode!="Dense"?4:5),i-x,(this.mode!="Dense"?3:1))}s+=n;break;case"N":r.fillStyle=CONNECTOR_COLOR;r.fillRect(x+this.left_offset,f+5,i-x,1);break;case"D":r.fillStyle="red";r.fillRect(x+this.left_offset,f+4,i-x,3);break;case"P":break;case"I":s+=n;break;case"X":s+=n;break}d+=n}},draw_tile:function(ad,n,r,ar){var L=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,K=ai-L;var G=this.data_cache.get_data(L,ai,this.mode);if(G===undefined||G==="pending"||(this.mode!=="Auto"&&G.dataset_type==="summary_tree")){this.data_queue[[L,ai]]=true;this.get_data(L,ai);return}var a=Math.ceil(K*ar),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,v=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,aq,B,at;var p=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(p)}p=$(p);if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(q==="Dense"){B=v;at=10}else{at=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ar<0.0001?1/this.view.zoom_res:ar);B=this.incremental_slots(w,G.data,ab,q)*at+v;aq=this.inc_slots[w]}}p.get(0).width=a+U;p.get(0).height=B;r.parent().css("height",Math.max(this.height_px,B)+"px");var H=p.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";this.container_div.find(".yaxislabel").remove();if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,b=Math.ceil(G.delta*ar);var o=$("<div />").addClass("yaxislabel");o.text(J);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,F=W.length;am<F;am++){var Y=Math.floor((W[am][0]-L)*ar);var X=W[am][1];if(!X){continue}var aj=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}return p}if(G.message){p.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,at);return p}for(var ao=0;ao<this.filters.length;ao++){if(this.filters[ao].applies_to(G.data[0])){p.addClass(FILTERABLE_CLASS);break}}var ap=G.data;var al=0;for(var am=0,F=ap.length;am<F;am++){var Q=ap[am],P=Q[0],an=Q[1],aa=Q[2],M=Q[3];if(this.mode!="Dense"&&aq[P]===undefined){continue}var Z=false;var S;for(var ao=0;ao<this.filters.length;ao++){S=this.filters[ao];S.update_attrs(Q);if(!S.keep(Q)){Z=true;break}}if(Z){continue}if(an<=ai&&aa>=L){var ac=Math.floor(Math.max(0,(an-L)*ar)),I=Math.ceil(Math.min(a,Math.max(0,(aa-L)*ar))),V=(q==="Dense"?1:(1+aq[P]))*at;var E,ag,N=null,au=null;if(G.dataset_type==="bai"){H.fillStyle=h;if(Q[5] instanceof Array){var C=Math.floor(Math.max(0,(Q[4][0]-L)*ar)),O=Math.ceil(Math.min(a,Math.max(0,(Q[4][1]-L)*ar))),A=Math.floor(Math.max(0,(Q[5][0]-L)*ar)),u=Math.ceil(Math.min(a,Math.max(0,(Q[5][1]-L)*ar)));if(Q[4][1]>=L&&Q[4][0]<=ai&&Q[4][2]){this.rect_or_text(H,ar,L,ai,Q[4][0],Q[4][2],Q[4][3],V)}if(Q[5][1]>=L&&Q[5][0]<=ai&&Q[5][2]){this.rect_or_text(H,ar,L,ai,Q[5][0],Q[5][2],Q[5][3],V)}if(A>O){H.fillStyle=CONNECTOR_COLOR;H.dashedLine(O+U,V+5,U+A,V+5)}}else{H.fillStyle=h;this.rect_or_text(H,ar,L,ai,an,Q[4],Q[5],V)}if(q!=="Dense"&&!ab&&an>L){H.fillStyle=this.prefs.label_color;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var D=Q[5],T=Q[6],ae=Q[7],g=Q[8];if(T&&ae){N=Math.floor(Math.max(0,(T-L)*ar));au=Math.ceil(Math.min(a,Math.max(0,(ae-L)*ar)))}if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}if(g){if(D){if(D=="+"){H.fillStyle=RIGHT_STRAND}else{if(D=="-"){H.fillStyle=LEFT_STRAND}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}for(var ak=0,e=g.length;ak<e;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-L)*ar)),R=Math.ceil(Math.min(a,Math.max((t[1]-L)*ar)));if(d>R){continue}E=5;ag=3;H.fillRect(d+U,V+ag,R-d,E);if(N!==undefined&&!(d>au||R<N)){E=9;ag=1;var ah=Math.max(d,N),z=Math.min(R,au);H.fillRect(ah+U,V+ag,z-ah,E)}}}else{E=9;ag=1;H.fillRect(ac+U,V+ag,I-ac,E);if(Q.strand){if(Q.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(Q.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var s=Q[4],m=Q[5],c=Q[6];E=9;ag=1;H.fillRect(ac+U,V,I-ac,E);if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}var l=s+" / "+m;if(an>L&&H.measureText(l).width<(I-ac)){H.fillStyle="white";H.textAlign="center";H.fillText(l,U+ac+(I-ac)/2,V+8);H.fillStyle=h}}}}}al++}}return p},gen_options:function(i){var a=$("<div />").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label />").attr("for",e).text("Block color:"),l=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label />").attr("for",j).text("Text color:"),h=$("<input />").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(k).append(l).append(g).append(h).append(d)},update_options:function(d){var b=$("#track_"+d+"_block_color").val(),c=$("#track_"+d+"_label_color").val(),a=$("#track_"+d+"_show_count").attr("checked");if(b!==this.prefs.block_color||c!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=c;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()==0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id},function(c){})}};a()}});
\ No newline at end of file
--- a/static/scripts/trackster.js Fri Feb 04 21:02:23 2011 -0500
+++ b/static/scripts/trackster.js Fri Feb 04 21:13:36 2011 -0500
@@ -1574,6 +1574,9 @@
this.left_offset = 200;
this.height_px = 12;
this.container_div.addClass( "reference-track" );
+ this.content_div.css("background", "none");
+ this.content_div.css("min-height", "0px");
+ this.content_div.css("border", "none");
this.data_queue = {};
this.data_cache = new DataCache(CACHED_DATA);
this.tile_cache = new Cache(CACHED_TILES_LINE);
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.
1
0
commit/galaxy-central: kanwei: trackster: Fix infinite data query loop when chrom is null or 'None'
by Bitbucket 04 Feb '11
by Bitbucket 04 Feb '11
04 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/538ca7438a8a/
changeset: r5000:538ca7438a8a
user: kanwei
date: 2011-02-05 03:02:23
summary: trackster: Fix infinite data query loop when chrom is null or 'None'
affected #: 1 file (203 bytes)
--- a/static/scripts/trackster.js Fri Feb 04 16:16:00 2011 -0500
+++ b/static/scripts/trackster.js Fri Feb 04 21:02:23 2011 -0500
@@ -466,6 +466,12 @@
},
change_chrom: function(chrom, low, high) {
+
+ // Don't do anything if chrom is "None" (hackish but some browsers already have this set), or null/blank
+ if (!chrom || chrom === "None") {
+ return;
+ }
+
var view = this;
//
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.
1
0
04 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/6a84a0a756b2/
changeset: r4999:6a84a0a756b2
user: greg
date: 2011-02-04 22:16:00
summary: Data library fixes and improvements:
1. Fix a bug that included the option for a regular user to upload a directory of files when the config setting existed, but the user's directory did not exist.  Instead of throwing an exception, an attempt to create the directory will now be done.  If the attempt fails, the option to "Upload a directory of files" will not be included in the select list on the upload form.
2. When browsing a data library, only display the check boxes and the actions to perform on multiple selected datasets if library datasets are displayed.
3. Clean up the behavior when performing an action on multiple library datasets.  Instead of throwing an error and not allowing the action on any of the datasets if the user is not authorized to perform the action on 1 of them, all "unauthorized" datasets are now left alone and the action is performed on all datasets for which the user is authorized to perform the action.  Appropriate messages detail what occurred.
4. Allow regular users to delete multiple datasets returned from library dataset searches based on the behavior described in 3 above.
5. Do not include the "Select datasets for import into selected histories" option in the actions pop-up menu at the data library level if the library's root folder doesn't contain any accessible datasets.  Make behavior the same for folder popup menus.
6.  Add a new LibraryFolder.active_datasets mapper and eliminate the incorrect LibraryFolder.active_library_datasets property.  Callers of the incorrect property now use the mapper.
7. Eliminate the incorrect LibraryFolder.active_datasets property.
8. Fix the queries in the library_common controller's active_folders_and_lddas() and activable_folders_and_lddas() methods to return library_datasets instead of lddas, and rename the methods to be active_folders_and_library_datasets(0 and activatable_folders_and_library_datasets() respectively.
9. Fix bug where regular user could never see deleted library items when toggling show / hide deleted items.
10. Fix functional test for uploading directories of files to a library folder.  The test generally failed because not enough time would elapse before checking if the files uploaded.  The check is now performed in a later method in the test script, hopefully allowing for enough time to pass.
11. Functional test code clarifications for the browse_library() test method.
affected #: 11 files (7.2 KB)
--- a/lib/galaxy/model/__init__.py Fri Feb 04 14:48:39 2011 -0500
+++ b/lib/galaxy/model/__init__.py Fri Feb 04 16:16:00 2011 -0500
@@ -1040,33 +1040,9 @@
return template.get_widgets( trans.user )
return []
@property
- def active_library_datasets( self ):
- def sort_by_attr( seq, attr ):
- """
- Sort the sequence of objects by object's attribute
- Arguments:
- seq - the list or any sequence (including immutable one) of objects to sort.
- attr - the name of attribute to sort by
- """
- # Use the "Schwartzian transform"
- # Create the auxiliary list of tuples where every i-th tuple has form
- # (seq[i].attr, i, seq[i]) and sort it. The second item of tuple is needed not
- # only to provide stable sorting, but mainly to eliminate comparison of objects
- # (which can be expensive or prohibited) in case of equal attribute values.
- intermed = map( None, map( getattr, seq, ( attr, ) * len( seq ) ), xrange( len( seq ) ), seq )
- intermed.sort()
- return map( operator.getitem, intermed, ( -1, ) * len( intermed ) )
- # This needs to be a list
- active_library_datasets = [ ld for ld in self.datasets if ld.library_dataset_dataset_association and not ld.library_dataset_dataset_association.deleted ]
- return sort_by_attr( [ ld for ld in active_library_datasets ], 'name' )
- @property
def activatable_library_datasets( self ):
# This needs to be a list
return [ ld for ld in self.datasets if ld.library_dataset_dataset_association and not ld.library_dataset_dataset_association.dataset.deleted ]
- @property
- def active_datasets( self ):
- # This needs to be a list
- return [ ld.library_dataset_dataset_association.dataset for ld in self.datasets if ld.library_dataset_dataset_association and not ld.library_dataset_dataset_association.deleted ]
def get_display_name( self ):
# Library folder name can be either a string or a unicode object. If string,
# convert to unicode object assuming 'utf-8' format.
--- a/lib/galaxy/model/mapping.py Fri Feb 04 14:48:39 2011 -0500
+++ b/lib/galaxy/model/mapping.py Fri Feb 04 16:16:00 2011 -0500
@@ -1294,6 +1294,11 @@
primaryjoin=( ( LibraryDataset.table.c.folder_id == LibraryFolder.table.c.id ) ),
order_by=asc( LibraryDataset.table.c._name ),
lazy=False,
+ viewonly=True ),
+ active_datasets=relation( LibraryDataset,
+ primaryjoin=( ( LibraryDataset.table.c.folder_id == LibraryFolder.table.c.id ) & ( not_( LibraryDataset.table.c.deleted ) ) ),
+ order_by=asc( LibraryDataset.table.c._name ),
+ lazy=False,
viewonly=True )
) )
--- a/lib/galaxy/security/__init__.py Fri Feb 04 14:48:39 2011 -0500
+++ b/lib/galaxy/security/__init__.py Fri Feb 04 16:16:00 2011 -0500
@@ -270,6 +270,26 @@
.order_by( trans.app.model.Library.name ):
accessible_libraries.append( library )
return accessible_libraries
+ def has_accessible_folders( self, trans, folder, user, roles, search_downward=True ):
+ if self.has_accessible_library_datasets( trans, folder, user, roles, search_downward=search_downward ) or \
+ self.can_add_library_item( roles, folder ) or \
+ self.can_modify_library_item( roles, folder ) or \
+ self.can_manage_library_item( roles, folder ):
+ return True
+ if search_downward:
+ for folder in folder.active_folders:
+ return self.has_accessible_folders( trans, folder, user, roles, search_downward=search_downward )
+ return False
+ def has_accessible_library_datasets( self, trans, folder, user, roles, search_downward=True ):
+ for library_dataset in trans.sa_session.query( trans.model.LibraryDataset ) \
+ .filter( and_( trans.model.LibraryDataset.table.c.deleted == False,
+ trans.app.model.LibraryDataset.table.c.folder_id==folder.id ) ):
+ if self.can_access_library_item( roles, library_dataset, user ):
+ return True
+ if search_downward:
+ for folder in folder.active_folders:
+ return self.has_accessible_library_datasets( trans, folder, user, roles, search_downward=search_downward )
+ return False
def can_access_library_item( self, roles, item, user ):
if type( item ) == self.model.Library:
return self.can_access_library( roles, item )
@@ -504,7 +524,7 @@
permissions[ action ] = [ item_permission.role ]
return permissions
def get_accessible_request_types( self, trans, user ):
- """Return all ReqquestTypes that the received user has permission to access."""
+ """Return all RequestTypes that the received user has permission to access."""
accessible_request_types = []
current_user_role_ids = [ role.id for role in user.all_roles() ]
request_type_access_action = self.permitted_actions.REQUEST_TYPE_ACCESS.action
--- a/lib/galaxy/web/controllers/library_common.py Fri Feb 04 14:48:39 2011 -0500
+++ b/lib/galaxy/web/controllers/library_common.py Fri Feb 04 16:16:00 2011 -0500
@@ -1312,8 +1312,15 @@
if option_value == 'upload_directory':
if is_admin and not trans.app.config.library_import_dir:
continue
- elif not is_admin and not trans.app.config.user_library_import_dir:
- continue
+ elif not is_admin:
+ if not trans.app.config.user_library_import_dir:
+ continue
+ path = os.path.join( trans.app.config.user_library_import_dir, trans.user.email )
+ if not os.path.isdir( path ):
+ try:
+ os.makedirs( path )
+ except:
+ continue
elif option_value == 'upload_paths':
if not is_admin or not trans.app.config.allow_library_path_paste:
continue
@@ -1553,54 +1560,70 @@
error = True
message = 'You must select an action to perform on the selected datasets.'
else:
- # Set up the list of lddas for later, and get permission checks out of the way so we don't have to do it in multiple places later.
ldda_ids = util.listify( ldda_ids )
for ldda_id in ldda_ids:
try:
ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) )
+ lddas.append( ldda )
except:
ldda = None
- if not ldda or ( not is_admin and not trans.app.security_agent.can_access_library_item( current_user_roles, ldda, trans.user ) ):
- error = True
- message = "Invalid library dataset id ( %s ) specified." % str( ldda_id )
- break
- lddas.append( ldda )
- if not is_admin:
- if action == 'manage_permissions':
- for ldda in lddas:
- if not ( trans.app.security_agent.can_manage_library_item( current_user_roles, ldda ) and \
- trans.app.security_agent.can_manage_dataset( current_user_roles, ldda.dataset ) ):
- error = True
- message = "You are not authorized to manage permissions on library dataset '%s'." % ldda.name
- break
- elif action == 'delete':
- for ldda in lddas:
- if not trans.app.security_agent.can_modify_library_item( current_user_roles, ldda ):
- error = True
- message = "You are not authorized to modify library dataset '%s'." % ldda.name
- break
+ message += "Invalid library dataset id (%s) specified. " % str( ldda_id )
if not error:
if action == 'manage_permissions':
- trans.response.send_redirect( web.url_for( controller='library_common',
- action='ldda_permissions',
- cntrller=cntrller,
- use_panels=use_panels,
- library_id=library_id,
- folder_id=trans.security.encode_id( lddas[0].library_dataset.folder.id ),
- id=",".join( ldda_ids ),
- show_deleted=show_deleted,
- message=util.sanitize_text( message ),
- status=status ) )
+ valid_ldda_ids = []
+ valid_lddas = []
+ invalid_lddas = []
+ for ldda in lddas:
+ if trans.app.security_agent.can_manage_library_item( current_user_roles, ldda ):
+ valid_lddas.append( ldda )
+ valid_ldda_ids.append( ldda.id )
+ else:
+ invalid_lddas.append( ldda )
+ if invalid_lddas:
+ message += "You are not authorized to manage permissions on %s: " % inflector.cond_plural( len( invalid_lddas ), "dataset" )
+ for ldda in invalid_lddas:
+ message += '(%s)' % ldda.name
+ message += '. '
+ if valid_ldda_ids:
+ folder_id = trans.security.encode_id( valid_lddas[0].library_dataset.folder.id )
+ trans.response.send_redirect( web.url_for( controller='library_common',
+ action='ldda_permissions',
+ cntrller=cntrller,
+ use_panels=use_panels,
+ library_id=library_id,
+ folder_id=folder_id,
+ id=",".join( valid_ldda_ids ),
+ show_deleted=show_deleted,
+ message=util.sanitize_text( message ),
+ status=status ) )
+ else:
+ message = "You are not authorized to manage permissions on any of the selected datasets."
elif action == 'delete':
+ valid_lddas = []
+ invalid_lddas = []
for ldda in lddas:
- # Do not delete the association, just delete the library_dataset. The
- # cleanup_datasets.py script handles everything else.
- ld = ldda.library_dataset
- ld.deleted = True
- trans.sa_session.add( ld )
- trans.sa_session.flush()
- message = "The selected datasets have been deleted."
- elif action in ['zip','tgz','tbz','ngxzip']:
+ if trans.app.security_agent.can_modify_library_item( current_user_roles, ldda ):
+ valid_lddas.append( ldda )
+ else:
+ invalid_lddas.append( ldda )
+ if invalid_lddas:
+ message += "You are not authorized to delete %s: " % inflector.cond_plural( len( invalid_lddas ), "dataset" )
+ for ldda in invalid_lddas:
+ message += '(%s)' % ldda.name
+ message += '. '
+ if valid_lddas:
+ for ldda in valid_lddas:
+ # Do not delete the association, just delete the library_dataset. The
+ # cleanup_datasets.py script handles everything else.
+ ld = ldda.library_dataset
+ ld.deleted = True
+ trans.sa_session.add( ld )
+ trans.sa_session.flush()
+ num_valid_lddas = len( valid_lddas )
+ message += "Deleted %i %s." % ( num_valid_lddas, inflector.cond_plural( num_valid_lddas, "dataset" ) )
+ else:
+ message = "You are not authorized to delete any of the selected datasets."
+ elif action in [ 'zip','tgz','tbz','ngxzip' ]:
error = False
killme = string.punctuation + string.whitespace
trantab = string.maketrans(killme,'_'*len(killme))
@@ -1723,25 +1746,27 @@
archive.wsgi_status = trans.response.wsgi_status()
archive.wsgi_headeritems = trans.response.wsgi_headeritems()
return archive.stream
- else:
- status = 'error'
- message = 'Invalid action ( %s ) specified.' % action
+ else:
+ status = 'error'
+ message = 'Invalid action (%s) specified.' % str( action )
if library_id:
# If we have a library_id, browse the associated library
return trans.response.send_redirect( web.url_for( controller='library_common',
action='browse_library',
cntrller=cntrller,
+ current_user_roles=current_user_roles,
use_panels=use_panels,
id=library_id,
show_deleted=show_deleted,
message=util.sanitize_text( message ),
status=status ) )
else:
- # We must have arrived here from the library_dataset_search_results page, so reddirect there.
+ # We arrived here from the library_dataset_search_results page, so redirect there.
search_term = params.get( 'search_term', '' )
comptypes = get_comptypes( trans )
return trans.fill_template( '/library/common/library_dataset_search_results.mako',
cntrller=cntrller,
+ current_user_roles=current_user_roles,
search_term=search_term,
comptypes=comptypes,
lddas=lddas,
@@ -2121,27 +2146,26 @@
.options( eagerload_all( "actions" ) ) \
.order_by( trans.app.model.LibraryFolder.table.c.name ) \
.all()
-def active_folders_and_lddas( trans, folder ):
+def active_folders_and_library_datasets( trans, folder ):
folders = active_folders( trans, folder )
- # This query is much faster than the folder.active_library_datasets property
- lddas = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ) \
- .filter_by( deleted=False ) \
- .join( "library_dataset" ) \
- .filter( trans.app.model.LibraryDataset.table.c.folder_id==folder.id ) \
- .order_by( trans.app.model.LibraryDatasetDatasetAssociation.table.c.name ) \
- .all()
- return folders, lddas
-def activatable_folders_and_lddas( trans, folder ):
+ library_datasets = trans.sa_session.query( trans.model.LibraryDataset ) \
+ .filter( and_( trans.model.LibraryDataset.table.c.deleted == False,
+ trans.model.LibraryDataset.table.c.folder_id == folder.id ) ) \
+ .order_by( trans.model.LibraryDataset.table.c._name ) \
+ .all()
+ return folders, library_datasets
+def activatable_folders_and_library_datasets( trans, folder ):
folders = activatable_folders( trans, folder )
- # This query is much faster than the folder.activatable_library_datasets property
- lddas = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ) \
- .join( "library_dataset" ) \
- .filter( trans.app.model.LibraryDataset.table.c.folder_id==folder.id ) \
- .join( "dataset" ) \
- .filter( trans.app.model.Dataset.table.c.deleted==False ) \
- .order_by( trans.app.model.LibraryDatasetDatasetAssociation.table.c.name ) \
- .all()
- return folders, lddas
+ library_datasets = trans.sa_session.query( trans.model.LibraryDataset ) \
+ .filter( trans.model.LibraryDataset.table.c.folder_id == folder.id ) \
+ .join( ( trans.model.LibraryDatasetDatasetAssociation.table,
+ trans.model.LibraryDataset.table.c.library_dataset_dataset_association_id == trans.model.LibraryDatasetDatasetAssociation.table.c.id ) ) \
+ .join( ( trans.model.Dataset.table,
+ trans.model.LibraryDatasetDatasetAssociation.table.c.dataset_id == trans.model.Dataset.table.c.id ) ) \
+ .filter( trans.model.Dataset.table.c.deleted == False ) \
+ .order_by( trans.model.LibraryDataset.table.c._name ) \
+ .all()
+ return folders, library_datasets
def branch_deleted( folder ):
# Return True if a folder belongs to a branch that has been deleted
if folder.deleted:
--- a/templates/library/common/browse_library.mako Fri Feb 04 14:48:39 2011 -0500
+++ b/templates/library/common/browse_library.mako Fri Feb 04 16:16:00 2011 -0500
@@ -213,7 +213,9 @@
## children, which are always lddas ). We also need to make sure we're displaying the latest version of this
## library_dataset, so we display the attributes from the ldda.
- from galaxy.web.controllers.library_common import active_folders, active_folders_and_lddas, activatable_folders_and_lddas, branch_deleted
+ from galaxy.web.controllers.library_common import branch_deleted
+
+ is_admin = trans.user_is_admin() and cntrller == 'library_admin'
if ldda.user:
uploaded_by = ldda.user.email
@@ -221,7 +223,7 @@
uploaded_by = 'anonymous'
if ldda == library_dataset.library_dataset_dataset_association:
current_version = True
- if trans.user_is_admin() and cntrller == 'library_admin':
+ if is_admin:
can_modify = can_manage = True
elif cntrller in [ 'library', 'requests' ]:
can_modify = trans.app.security_agent.can_modify_library_item( current_user_roles, library_dataset )
@@ -307,7 +309,10 @@
<%def name="render_folder( cntrller, folder, folder_pad, created_ldda_ids, library, hidden_folder_ids, tracked_datasets, show_deleted=False, parent=None, row_counter=None, root_folder=False )"><%
- from galaxy.web.controllers.library_common import active_folders, active_folders_and_lddas, activatable_folders_and_lddas, branch_deleted
+ from galaxy.web.controllers.library_common import active_folders, active_folders_and_library_datasets, activatable_folders_and_library_datasets, branch_deleted
+
+ is_admin = trans.user_is_admin() and cntrller == 'library_admin'
+
if root_folder:
pad = folder_pad
expander = h.url_for("/static/images/silk/resultset_bottom.png")
@@ -321,7 +326,7 @@
if str( folder.id ) in hidden_folder_ids:
return ""
my_row = None
- if trans.user_is_admin() and cntrller == 'library_admin':
+ if is_admin:
can_add = can_modify = can_manage = True
elif cntrller in [ 'library' ]:
can_access, folder_ids = trans.app.security_agent.check_folder_contents( trans.user, current_user_roles, folder )
@@ -340,8 +345,11 @@
can_manage = trans.app.security_agent.can_manage_library_item( current_user_roles, folder )
else:
can_add = can_modify = can_manage = False
+
form_type = trans.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE
info_association, inherited = folder.get_info_association( restrict=True )
+
+ has_accessible_datasets = trans.app.security_agent.has_accessible_library_datasets( trans, folder, trans.user, current_user_roles, search_downward=False )
%>
%if not root_folder and ( not folder.deleted or show_deleted ):
<% encoded_id = trans.security.encode_id(folder.id) %>
@@ -371,7 +379,9 @@
<a class="action-button" href="${h.url_for( controller='library_common', action='create_folder', cntrller=cntrller, parent_id=trans.security.encode_id( folder.id ), library_id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}">Add sub-folder</a>
%endif
%if not branch_deleted( folder ):
- <a class="action-button" href="${h.url_for( controller='library_common', action='import_datasets_to_histories', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), use_panels=use_panels, show_deleted=show_deleted )}">Select folder datasets for import into selected histories</a>
+ %if has_accessible_datasets:
+ <a class="action-button" href="${h.url_for( controller='library_common', action='import_datasets_to_histories', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), use_panels=use_panels, show_deleted=show_deleted )}">Select datasets for import into selected histories</a>
+ %endif
%if can_modify:
<a class="action-button" href="${h.url_for( controller='library_common', action='folder_info', cntrller=cntrller, id=trans.security.encode_id( folder.id ), library_id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}">Edit information</a>
%else:
@@ -412,12 +422,28 @@
row_counter.increment()
%>
%endif
- %if cntrller == 'library':
- <% sub_folders = active_folders( trans, folder ) %>
+ <%
+ if show_deleted:
+ sub_folders, library_datasets = activatable_folders_and_library_datasets( trans, folder )
+ else:
+ sub_folders, library_datasets = active_folders_and_library_datasets( trans, folder )
+ %>
+ %if is_admin:
+ %for sub_folder in sub_folders:
+ ${render_folder( cntrller, sub_folder, pad, created_ldda_ids, library, [], tracked_datasets, show_deleted=show_deleted, parent=my_row, row_counter=row_counter, root_folder=False )}
+ %endfor
+ %for library_dataset in library_datasets:
+ <%
+ ldda = library_dataset.library_dataset_dataset_association
+ selected = created_ldda_ids and str( ldda.id ) in created_ldda_ids
+ %>
+ ${render_dataset( cntrller, ldda, library_dataset, selected, library, folder, pad, my_row, row_counter, tracked_datasets, show_deleted=show_deleted )}
+ %endfor
+ %else:
%for sub_folder in sub_folders:
${render_folder( cntrller, sub_folder, pad, created_ldda_ids, library, hidden_folder_ids, tracked_datasets, show_deleted=show_deleted, parent=my_row, row_counter=row_counter, root_folder=False )}
%endfor
- %for library_dataset in folder.active_library_datasets:
+ %for library_dataset in library_datasets:
<%
ldda = library_dataset.library_dataset_dataset_association
can_access = trans.app.security_agent.can_access_dataset( current_user_roles, ldda.dataset )
@@ -427,23 +453,6 @@
${render_dataset( cntrller, ldda, library_dataset, selected, library, folder, pad, my_row, row_counter, tracked_datasets, show_deleted=show_deleted )}
%endif
%endfor
- %elif trans.user_is_admin() and cntrller == 'library_admin':
- <%
- if show_deleted:
- sub_folders, lddas = activatable_folders_and_lddas( trans, folder )
- else:
- sub_folders, lddas = active_folders_and_lddas( trans, folder )
- %>
- %for sub_folder in sub_folders:
- ${render_folder( cntrller, sub_folder, pad, created_ldda_ids, library, [], tracked_datasets, show_deleted=show_deleted, parent=my_row, row_counter=row_counter, root_folder=False )}
- %endfor
- %for ldda in lddas:
- <%
- library_dataset = ldda.library_dataset
- selected = created_ldda_ids and str( ldda.id ) in created_ldda_ids
- %>
- ${render_dataset( cntrller, ldda, library_dataset, selected, library, folder, pad, my_row, row_counter, tracked_datasets, show_deleted=show_deleted )}
- %endfor
%endif
</%def>
@@ -453,7 +462,9 @@
from galaxy.web.controllers.library_common import branch_deleted
from time import strftime
- if trans.user_is_admin() and cntrller == 'library_admin':
+ is_admin = trans.user_is_admin() and cntrller == 'library_admin'
+
+ if is_admin:
can_add = can_modify = can_manage = True
elif cntrller in [ 'library', 'requests' ]:
can_add = trans.app.security_agent.can_add_library_item( current_user_roles, library )
@@ -461,11 +472,15 @@
can_manage = trans.app.security_agent.can_manage_library_item( current_user_roles, library )
else:
can_add = can_modify = can_manage = False
+
info_association, inherited = library.get_info_association()
form_type = trans.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE
-
+
+ has_accessible_datasets = trans.app.security_agent.has_accessible_library_datasets( trans, library.root_folder, trans.user, current_user_roles, search_downward=False )
+ has_accessible_folders = is_admin or trans.app.security_agent.has_accessible_folders( trans, library.root_folder, trans.user, current_user_roles )
+
tracked_datasets = {}
-
+
class RowCounter( object ):
def __init__( self ):
self.count = 0
@@ -478,7 +493,7 @@
<h2>Data Library “${library.name}”</h2><ul class="manage-table-actions">
- %if not library.deleted and ( ( trans.user_is_admin() and cntrller == 'library_admin' ) or can_add ):
+ %if not library.deleted and ( is_admin or can_add ):
<li><a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( library.root_folder.id ), use_panels=use_panels, show_deleted=show_deleted )}">Add datasets</a></li><li><a class="action-button" href="${h.url_for( controller='library_common', action='create_folder', cntrller=cntrller, parent_id=trans.security.encode_id( library.root_folder.id ), library_id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}">Add folder</a></li>
%endif
@@ -508,7 +523,9 @@
%endif
<a class="action-button" href="${h.url_for( controller='library_common', action='library_permissions', cntrller=cntrller, id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}">Edit permissions</a>
%endif
- <a class="action-button" href="${h.url_for( controller='library_common', action='import_datasets_to_histories', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( library.root_folder.id ), use_panels=use_panels, show_deleted=show_deleted )}">Select datasets for import into selected histories</a>
+ %if has_accessible_datasets:
+ <a class="action-button" href="${h.url_for( controller='library_common', action='import_datasets_to_histories', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( library.root_folder.id ), use_panels=use_panels, show_deleted=show_deleted )}">Select datasets for import into selected histories</a>
+ %endif
%elif can_modify and not library.purged:
<a class="action-button" href="${h.url_for( controller='library_common', action='undelete_library_item', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), item_id=trans.security.encode_id( library.id ), item_type='library', use_panels=use_panels )}">Undelete this data library</a>
%elif library.purged:
@@ -528,13 +545,18 @@
</div><br/>
%endif
-
- <form name="act_on_multiple_datasets" action="${h.url_for( controller='library_common', action='act_on_multiple_datasets', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}" onSubmit="javascript:return checkForm();" method="post">
+
+ %if has_accessible_datasets:
+ <form name="act_on_multiple_datasets" action="${h.url_for( controller='library_common', action='act_on_multiple_datasets', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}" onSubmit="javascript:return checkForm();" method="post">
+ %endif
+ %if has_accessible_folders:
<table cellspacing="0" cellpadding="0" border="0" width="100%" class="grid" id="library-grid"><thead><tr class="libraryTitle"><th>
- <input type="checkbox" id="checkAll" name=select_all_datasets_checkbox value="true" onclick='checkAllFields(1);'/><input type="hidden" name=select_all_datasets_checkbox value="true"/>
+ %if has_accessible_datasets:
+ <input type="checkbox" id="checkAll" name=select_all_datasets_checkbox value="true" onclick='checkAllFields(1);'/><input type="hidden" name=select_all_datasets_checkbox value="true"/>
+ %endif
Name
</th><th>Message</th>
@@ -546,18 +568,21 @@
<% row_counter = RowCounter() %>
%if cntrller in [ 'library', 'requests' ]:
${self.render_folder( 'library', library.root_folder, 0, created_ldda_ids, library, hidden_folder_ids, tracked_datasets, show_deleted=show_deleted, parent=None, row_counter=row_counter, root_folder=True )}
- %if not library.deleted:
+ %if not library.deleted and has_accessible_datasets:
${render_actions_on_multiple_items()}
%endif
%elif ( trans.user_is_admin() and cntrller in [ 'library_admin', 'requests_admin' ] ):
${self.render_folder( 'library_admin', library.root_folder, 0, created_ldda_ids, library, [], tracked_datasets, show_deleted=show_deleted, parent=None, row_counter=row_counter, root_folder=True )}
- %if not library.deleted and not show_deleted:
+ %if not library.deleted and not show_deleted and has_accessible_datasets:
${render_actions_on_multiple_items()}
%endif
%endif
</table>
- </form>
-
+ %endif
+ %if has_accessible_datasets:
+ </form>
+ %endif
+
%if tracked_datasets:
<script type="text/javascript">
// Updater
@@ -566,5 +591,10 @@
<!-- running: do not change this comment, used by TwillTestCase.library_wait -->
%endif
- ${render_compression_types_help( comptypes )}
+ %if has_accessible_datasets:
+ ${render_compression_types_help( comptypes )}
+ %endif
+ %if not has_accessible_folders:
+ The data library '${library.name}' does not contain any datasets that you can access.
+ %endif
</%def>
--- a/templates/library/common/common.mako Fri Feb 04 14:48:39 2011 -0500
+++ b/templates/library/common/common.mako Fri Feb 04 16:16:00 2011 -0500
@@ -395,7 +395,7 @@
<%def name="render_actions_on_multiple_items( actions_to_exclude=[] )"><%
is_admin = trans.user_is_admin() and cntrller=='library_admin'
- can_delete = 'delete' not in actions_to_exclude and is_admin
+ can_delete = 'delete' not in actions_to_exclude
can_download = 'download' not in actions_to_exclude
can_import_to_histories = 'import_to_histories' not in actions_to_exclude
can_manage_permissions = 'manage_permissions' not in actions_to_exclude
--- a/templates/library/common/library_dataset_search_results.mako Fri Feb 04 14:48:39 2011 -0500
+++ b/templates/library/common/library_dataset_search_results.mako Fri Feb 04 16:16:00 2011 -0500
@@ -95,6 +95,7 @@
<p>The string "${search_term}" was found in at least one of the following information components of the displayed library datasets.</p>
${render_searched_components()}
<form name="act_on_multiple_datasets" action="${h.url_for( controller='library_common', action='act_on_multiple_datasets', cntrller=cntrller, use_panels=use_panels, show_deleted=show_deleted )}" onSubmit="javascript:return checkForm();" method="post">
+ <input type="hidden" name=search_term value="${search_term}"/><table cellspacing="0" cellpadding="0" border="0" width="100%" class="grid" id="library-grid"><thead><tr class="libraryTitle">
--- a/test/base/twilltestcase.py Fri Feb 04 14:48:39 2011 -0500
+++ b/test/base/twilltestcase.py Fri Feb 04 16:16:00 2011 -0500
@@ -1844,10 +1844,8 @@
raise AssertionError, "String (%s) incorrectly displayed when browing library." % check_str
except:
pass
- def browse_library( self, cntrller, id, show_deleted=False, strings_displayed=[], strings_not_displayed=[] ):
- self.visit_url( '%s/library_common/browse_library?cntrller=%s&id=%s&show_deleted=%s' % ( self.url, cntrller, id, str( show_deleted ) ) )
- data=self.last_page()
- file( 'greg.html', 'wb' ).write( data )
+ def browse_library( self, cntrller, library_id, show_deleted=False, strings_displayed=[], strings_not_displayed=[] ):
+ self.visit_url( '%s/library_common/browse_library?cntrller=%s&id=%s&show_deleted=%s' % ( self.url, cntrller, library_id, str( show_deleted ) ) )
for check_str in strings_displayed:
self.check_page_for_string( check_str )
for check_str in strings_not_displayed:
--- a/test/functional/test_library_features.py Fri Feb 04 14:48:39 2011 -0500
+++ b/test/functional/test_library_features.py Fri Feb 04 16:16:00 2011 -0500
@@ -78,8 +78,8 @@
global folder1
folder1 = get_folder( root_folder.id, name, description )
assert folder1 is not None, 'Problem retrieving library folder named "%s" from the database' % name
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ folder1.name, folder1.description ] )
def test_035_add_subfolder_to_folder( self ):
"""Testing adding a folder to a folder"""
@@ -94,8 +94,8 @@
global subfolder1
subfolder1 = get_folder( folder1.id, name, description )
assert subfolder1 is not None, 'Problem retrieving subfolder1 from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ subfolder1.name, subfolder1.description ] )
def test_040_add_2nd_folder_to_library1( self ):
"""Testing adding a 2nd folder to a library1"""
@@ -110,8 +110,8 @@
global folder2
folder2 = get_folder( library1.root_folder.id, name, description )
assert folder2 is not None, 'Problem retrieving library folder named "%s" from the database' % name
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ folder2.name, folder2.description ] )
def test_045_add_public_dataset_to_folder2( self ):
"""Testing adding a public dataset to folder2"""
@@ -129,8 +129,8 @@
global ldda2
ldda2 = get_latest_ldda_by_name( filename )
assert ldda2 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda2 from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ ldda2.name, ldda2.message, admin_user.email ] )
def test_050_add_2nd_public_dataset_to_folder2( self ):
"""Testing adding a 2nd public dataset folder2"""
@@ -148,8 +148,8 @@
global ldda3
ldda3 = get_latest_ldda_by_name( filename )
assert ldda3 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda3 from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ ldda3.name, ldda3.message, admin_user.email ] )
def test_055_copy_dataset_from_history_to_subfolder( self ):
"""Testing copying a dataset from the current history to a subfolder"""
@@ -168,8 +168,8 @@
global ldda4
ldda4 = get_latest_ldda_by_name( filename )
assert ldda4 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda4 from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ ldda4.name, ldda4.message, admin_user.email ] )
def test_060_editing_dataset_attribute_info( self ):
"""Testing editing a library dataset's attribute information"""
@@ -182,8 +182,8 @@
ldda4.name,
new_ldda_name=new_ldda_name )
refresh( ldda4 )
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ new_ldda_name, ldda4.message ] )
def test_065_uploading_new_dataset_version( self ):
"""Testing uploading a new version of a library dataset"""
@@ -216,8 +216,8 @@
ldda4.name,
strings_displayed=[ 'This is an expired version of this library dataset' ] )
# Make sure ldda4 is no longer displayed in the library
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_not_displayed=[ ldda4.name, ldda4.message ] )
def test_070_upload_directory_of_files_from_libraries_view( self ):
"""Testing uploading a directory of files to a root folder from the Data Libraries view"""
@@ -249,9 +249,6 @@
server_dir=regular_user1.email,
ldda_message=ldda_message,
strings_displayed = [ "Upload a directory of files" ] )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
- strings_displayed=[ regular_user1.email, ldda_message, '1.fasta' ] )
self.logout()
self.login( regular_user3.email )
ldda_message = 'Uploaded all files in test-data/users/test3.../run1'
@@ -264,9 +261,6 @@
server_dir='run1',
ldda_message=ldda_message,
strings_displayed=[ 'Upload a directory of files', '<option>None</option>' ] )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
- strings_displayed=[ regular_user3.email, ldda_message, '2.fasta' ] )
def test_075_download_archive_of_library_files( self ):
"""Testing downloading an archive of files from library1"""
# logged in as regular_user3
@@ -290,7 +284,21 @@
format=format )
self.check_archive_contents( archive, ( ldda1, ldda2 ) )
os.remove( archive )
- def test_080_mark_ldda2_deleted( self ):
+ def test_080_check_libraries_for_uploaded_directories_of_files( self ):
+ """Testing the results of uploading directories of files to library1"""
+ # We'll make sure the directories of files were uploaded in test_070... above.
+ # We do this here because the check would generally fail if we did it in the
+ # test_070... method since the files would not finish uploading before the check
+ # was done. Hopefully doing the check here will allow for enough time...
+ ldda_message = 'Uploaded all files in test-data/users/test1...'
+ self.browse_library( 'library',
+ self.security.encode_id( library1.id ),
+ strings_displayed=[ regular_user1.email, ldda_message, '1.fasta' ] )
+ ldda_message = 'Uploaded all files in test-data/users/test3.../run1'
+ self.browse_library( 'library',
+ self.security.encode_id( library1.id ),
+ strings_displayed=[ regular_user3.email, ldda_message, '2.fasta' ] )
+ def test_085_mark_ldda2_deleted( self ):
"""Testing marking ldda2 as deleted"""
# Logged in as admin_user
self.delete_library_item( 'library_admin',
@@ -298,20 +306,20 @@
self.security.encode_id( ldda2.library_dataset.id ),
ldda2.name,
item_type='library_dataset' )
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_not_displayed=[ ldda2.name, ldda2.message ] )
- def test_085_display_and_hide_deleted_ldda2( self ):
+ def test_090_display_and_hide_deleted_ldda2( self ):
"""Testing displaying and hiding a deleted ldda2"""
# Logged in as admin_user
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
show_deleted=True,
strings_displayed=[ ldda2.name, ldda2.message ] )
self.browse_library( 'library_admin',
self.security.encode_id( library1.id ),
strings_not_displayed=[ ldda2.name, ldda2.message ] )
- def test_090_mark_folder2_deleted( self ):
+ def test_095_mark_folder2_deleted( self ):
"""Testing marking folder2 as deleted"""
# Logged in as admin_user
self.delete_library_item( 'library_admin',
@@ -319,10 +327,10 @@
self.security.encode_id( folder2.id ),
folder2.name,
item_type='folder' )
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_not_displayed=[ folder2.name ] )
- def test_095_mark_folder_undeleted( self ):
+ def test_100_mark_folder_undeleted( self ):
"""Testing marking a library folder as undeleted"""
# Logged in as admin_user
self.undelete_library_item( 'library_admin',
@@ -332,11 +340,11 @@
item_type='folder' )
# 2.bed was deleted before the folder was deleted, so state should have been saved. In order
# for 2.bed to be displayed, it would itself have to be marked undeleted.
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ folder2.name ],
strings_not_displayed=[ ldda2.name ] )
- def test_100_mark_library_deleted( self ):
+ def test_105_mark_library_deleted( self ):
"""Testing marking a library as deleted"""
# Logged in as admin_user
# First mark folder2 as deleted to further test state saving when we undelete the library
@@ -352,7 +360,7 @@
item_type='library' )
self.browse_libraries_admin( strings_not_displayed=[ library1.name ] )
self.browse_libraries_admin( deleted=True, strings_displayed=[ library1.name ] )
- def test_105_mark_library_undeleted( self ):
+ def test_110_mark_library_undeleted( self ):
"""Testing marking a library as undeleted"""
# Logged in as admin_user
self.undelete_library_item( 'library_admin',
@@ -361,11 +369,11 @@
library1.name,
item_type='library' )
self.browse_libraries_admin( strings_displayed=[ library1.name ] )
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
- strings_displayed=[ library1.name ],
- strings_not_displayed=[ folder2.name ] )
- def test_110_purge_library( self ):
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
+ strings_displayed=[ library1.name ],
+ strings_not_displayed=[ folder2.name ] )
+ def test_115_purge_library( self ):
"""Testing purging a library"""
# Logged in as admin_user
self.delete_library_item( 'library_admin',
--- a/test/functional/test_library_security.py Fri Feb 04 14:48:39 2011 -0500
+++ b/test/functional/test_library_security.py Fri Feb 04 16:16:00 2011 -0500
@@ -155,8 +155,8 @@
global ldda1
ldda1 = get_latest_ldda_by_name( filename )
assert ldda1 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda1 from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ ldda1.name, ldda1.message, admin_user.email ] )
def test_030_access_ldda1_with_private_role_restriction( self ):
"""Testing accessing ldda1 with a private role restriction"""
@@ -174,16 +174,16 @@
# 'test3(a)bx.psu.edu' ( regular_user3's private role ) since regular_user3 has Role1
#
# admin_user should not be able to see 1.bed from the analysis view's access libraries
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
- strings_not_displayed=[ folder1.name, ldda1.name, ldda1.message ] )
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
+ strings_not_displayed=[ folder1.name, ldda1.name, ldda1.message ] )
self.logout()
# regular_user1 should be able to see 1.bed from the Data Libraries view
# since it was associated with regular_user1's private role
self.login( email=regular_user1.email )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
- strings_displayed=[ folder1.name, ldda1.name, ldda1.message ] )
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
+ strings_displayed=[ folder1.name, ldda1.name, ldda1.message ] )
self.logout()
# regular_user2 should not be to see library1 since they do not have
# Role1 which is associated with the LIBRARY_ACCESS permission
@@ -192,8 +192,8 @@
self.logout()
# regular_user3 should not be able to see 1.bed from the analysis view's access librarys
self.login( email=regular_user3.email )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_not_displayed=[ folder1.name ] )
self.logout()
self.login( email=admin_user.email )
@@ -229,8 +229,8 @@
permissions_out,
ldda_name=ldda1.name )
# admin_user should now be able to see 1.bed from the analysis view's access libraries
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ ldda1.name, ldda1.message ] )
def test_040_create_ldda2_with_role2_associated_with_group_and_users( self ):
"""Testing creating ldda2 with a role that is associated with a group and users"""
@@ -261,20 +261,20 @@
ldda2 = get_latest_ldda_by_name( filename )
assert ldda2 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda2 from the database'
self.browse_library( cntrller='library',
- id=self.security.encode_id( library1.id ),
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ ldda2.name, ldda2.message, admin_user.email ] )
def test_045_accessing_ldda2_with_role_associated_with_group_and_users( self ):
"""Testing accessing ldda2 with a role that is associated with a group and users"""
# Logged in as admin_user
# admin_user should be able to see 2.bed since she is associated with role2
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ ldda2.name, ldda2.message, admin_user.email ] )
self.logout()
# regular_user1 should be able to see 2.bed since she is associated with group_two
self.login( email = regular_user1.email )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ folder1.name, ldda2.name, ldda2.message, admin_user.email ] )
# Check the permissions on the dataset 2.bed - they are as folows:
# DATASET_MANAGE_PERMISSIONS = test(a)bx.psu.edu
@@ -304,15 +304,15 @@
self.logout()
# regular_user2 should not be able to see ldda2
self.login( email=regular_user2.email )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_not_displayed=[ folder1.name, ldda2.name, ldda2.message ] )
self.logout()
# regular_user3 should not be able to see ldda2
self.login( email=regular_user3.email )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ folder1.name ],
strings_not_displayed=[ ldda2.name, ldda2.message ] )
self.logout()
@@ -325,8 +325,8 @@
self.logout()
# regular_user2 should now be able to see ldda2
self.login( email=regular_user2.email )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ folder1.name, ldda2.name, ldda2.message ] )
self.logout()
self.login( email=admin_user.email )
@@ -338,8 +338,8 @@
self.logout()
# regular_user3 should now be able to see ldda1
self.login( email=regular_user3.email )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ folder1.name, ldda1.name, ldda1.message ] )
self.logout()
self.login( email=admin_user.email )
@@ -354,8 +354,8 @@
server_dir='library',
ldda_message=ldda_message,
strings_displayed=[ "Upload a directory of files" ] )
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ admin_user.email, ldda_message ] )
def test_055_change_permissions_on_datasets_uploaded_from_library_dir( self ):
"""Testing changing the permissions on datasets uploaded from a directory from the Admin view"""
@@ -403,8 +403,8 @@
# Since regular_user2 is not associated with role1, she should not have
# access to any of the 3 datasets, so she will not see folder1 on the libraries page
self.login( email=regular_user2.email )
- self.browse_library( 'library',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library1.id ),
strings_not_displayed=[ folder1.name ] )
self.logout()
# regular_user3 is associated with role1, so should have all permissions on imported datasets
@@ -538,8 +538,8 @@
self.login( email=regular_user2.email )
self.visit_url( '%s/library/browse_libraries' % self.url )
self.check_page_for_string( library2.name )
- self.browse_library( 'library',
- self.security.encode_id( library2.id ),
+ self.browse_library( cntrller='library',
+ library_id=self.security.encode_id( library2.id ),
strings_displayed=[ ldda6.name, ldda6.message, ldda7.name, ldda7.message, ldda8.name, ldda8.message ] )
def test_999_reset_data_for_later_test_runs( self ):
"""Reseting data to enable later test runs to pass"""
--- a/test/functional/test_library_templates.py Fri Feb 04 14:48:39 2011 -0500
+++ b/test/functional/test_library_templates.py Fri Feb 04 16:16:00 2011 -0500
@@ -136,8 +136,8 @@
def test_025_check_library1( self ):
"""Checking library1 and its root folder"""
# Logged in as admin_user
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ folder1.name, folder1.description ] )
# Make sure the template and contents were inherited to folder1
self.folder_info( cntrller='library_admin',
@@ -179,8 +179,8 @@
global ldda1
ldda1 = get_latest_ldda_by_name( filename )
assert ldda1 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda1 from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library1.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library1.id ),
strings_displayed=[ ldda1.name, ldda1.message, admin_user.email ] )
# Make sure the library template contents were correctly saved
self.ldda_edit_info( 'library_admin',
@@ -275,8 +275,8 @@
def test_060_check_library2( self ):
"""Checking library2 and its root folder"""
# Logged in as admin_user
- self.browse_library( 'library_admin',
- self.security.encode_id( library2.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library2.id ),
strings_displayed=[ folder2.name, folder2.description ] )
def test_065_save_folder2_inherited_template( self ):
"""Saving the inherited template for folder2"""
@@ -306,8 +306,8 @@
strings_displayed=[ 'CheckboxField', 'checked' ] )
ldda = get_latest_ldda_by_name( filename )
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library2.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library2.id ),
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
# Make sure the library template contents were correctly saved
self.ldda_edit_info( 'library_admin',
@@ -347,8 +347,8 @@
def test_090_check_library3( self ):
"""Checking library3 and its root folder"""
# Logged in as admin_user
- self.browse_library( 'library_admin',
- self.security.encode_id( library3.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library3.id ),
strings_displayed=[ folder3.name, folder3.description ] )
def test_095_save_folder3_inherited_template( self ):
"""Saving the inherited template for folder3"""
@@ -379,8 +379,8 @@
strings_displayed=[ 'SelectField', 'selected>Option1' ] )
ldda = get_latest_ldda_by_name( filename )
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library3.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library3.id ),
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
# Make sure the library template contents were correctly saved
self.ldda_edit_info( 'library_admin',
@@ -402,8 +402,8 @@
strings_displayed=[ '<input type="hidden" name="%s" value="Option1"/>' % select_field_name ] )
ldda = get_latest_ldda_by_name( filename )
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library3.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library3.id ),
strings_displayed=[ ldda.name, admin_user.email ] )
# Make sure the library template contents were correctly saved
self.ldda_edit_info( 'library_admin',
@@ -469,8 +469,8 @@
strings_displayed=[ 'TextArea', 'This text should be inherited' ] )
ldda = get_latest_ldda_by_name( filename )
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library4.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library4.id ),
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
# Make sure the library template contents were correctly saved
self.ldda_edit_info( 'library_admin',
@@ -535,8 +535,8 @@
strings_displayed=[ 'TextField', 'This text should be inherited' ] )
ldda = get_latest_ldda_by_name( filename )
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library5.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library5.id ),
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
# Make sure the library template contents were correctly saved
self.ldda_edit_info( 'library_admin',
@@ -577,8 +577,8 @@
'TextArea' ] )
ldda = get_latest_ldda_by_name( filename )
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library5.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library5.id ),
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
# Make sure the library template contents were correctly saved
self.ldda_edit_info( 'library_admin',
@@ -642,8 +642,8 @@
strings_displayed=[ 'WorkflowField', 'none' ] )
ldda = get_latest_ldda_by_name( filename )
assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
- self.browse_library( 'library_admin',
- self.security.encode_id( library6.id ),
+ self.browse_library( cntrller='library_admin',
+ library_id=self.security.encode_id( library6.id ),
strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
# Make sure the library template contents were correctly saved
self.ldda_edit_info( 'library_admin',
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.
1
0
commit/galaxy-central: james_taylor: trackster: fix for track height calculation
by Bitbucket 04 Feb '11
by Bitbucket 04 Feb '11
04 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/046e456f2c5b/
changeset: r4998:046e456f2c5b
user: james_taylor
date: 2011-02-04 20:48:39
summary: trackster: fix for track height calculation
affected #: 1 file (12 bytes)
--- a/static/scripts/trackster.js Fri Feb 04 14:49:23 2011 -0500
+++ b/static/scripts/trackster.js Fri Feb 04 14:48:39 2011 -0500
@@ -1406,7 +1406,7 @@
if (this.left_offset) {
left -= this.left_offset;
}
- tile_element.css({ position: 'absolute', top: 0, left: left });
+ tile_element.css({ position: 'absolute', top: 0, left: left, height: '' });
// Setup and show tile element.
parent_element.append( tile_element );
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.
1
0
commit/galaxy-central: jgoecks: Trackster history dataset selection: show history name, show and order by hid in display.
by Bitbucket 04 Feb '11
by Bitbucket 04 Feb '11
04 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/d2db43017281/
changeset: r4997:d2db43017281
user: jgoecks
date: 2011-02-04 20:49:23
summary: Trackster history dataset selection: show history name, show and order by hid in display.
affected #: 4 files (400 bytes)
--- a/lib/galaxy/web/controllers/tracks.py Fri Feb 04 14:29:23 2011 -0500
+++ b/lib/galaxy/web/controllers/tracks.py Fri Feb 04 14:49:23 2011 -0500
@@ -106,23 +106,29 @@
available_tracks = None
title = "Add Datasets"
template = "tracks/history_datasets_select_grid.mako"
- async_template = "/page/select_items_grid_async.mako"
model_class = model.HistoryDatasetAssociation
default_filter = { "deleted" : "False" , "shared" : "All" }
- default_sort_key = "name"
+ default_sort_key = "-hid"
use_async = True
use_paging = False
columns = [
+ grids.GridColumn( "Id", key="hid" ),
grids.TextColumn( "Name", key="name", model_class=model.HistoryDatasetAssociation ),
grids.TextColumn( "Filetype", key="extension", model_class=model.HistoryDatasetAssociation ),
HistoryColumn( "History", key="history", visible=False ),
DbKeyColumn( "Dbkey", key="dbkey", model_class=model.HistoryDatasetAssociation, visible=True, sortable=False )
]
columns.append(
- grids.MulticolFilterColumn( "Search", cols_to_filter=[ columns[0], columns[1] ],
+ grids.MulticolFilterColumn( "Search name and filetype", cols_to_filter=[ columns[1], columns[2] ],
key="free-text-search", visible=False, filterable="standard" )
)
-
+
+ def get_current_item( self, trans, **kwargs ):
+ """
+ Current item for grid is the history being queried. This is a bit
+ of hack since current_item typically means the current item in the grid.
+ """
+ return model.History.get( trans.security.decode_id( kwargs[ 'f-history' ] ) )
def build_initial_query( self, trans, **kwargs ):
return trans.sa_session.query( self.model_class ).join( model.History.table ).join( model.Dataset.table )
def apply_query_filter( self, trans, query, **kwargs ):
@@ -144,13 +150,9 @@
use_async = True
use_paging = False
columns = [
- grids.TextColumn( "Title", key="title", model_class=model.Visualization ),
+ grids.TextColumn( "Title", key="title", model_class=model.Visualization, filterable="standard" ),
grids.TextColumn( "Dbkey", key="dbkey", model_class=model.Visualization )
]
- columns.append(
- grids.MulticolFilterColumn( "Search", cols_to_filter=[ columns[0] ],
- key="free-text-search", visible=False, filterable="standard" )
- )
def build_initial_query( self, trans, **kwargs ):
return trans.sa_session.query( self.model_class )
--- a/lib/galaxy/web/framework/helpers/grids.py Fri Feb 04 14:29:23 2011 -0500
+++ b/lib/galaxy/web/framework/helpers/grids.py Fri Feb 04 14:49:23 2011 -0500
@@ -271,7 +271,7 @@
message = message,
use_panels=self.use_panels,
webapp=webapp,
- show_item_checkboxes = kwargs.get( "show_item_checkboxes", False ),
+ show_item_checkboxes = ( kwargs.get( 'show_item_checkboxes', '' ) in ['True', 'true'] ),
# Pass back kwargs so that grid template can set and use args without
# grid explicitly having to pass them.
kwargs=kwargs )
--- a/templates/grid_base.mako Fri Feb 04 14:29:23 2011 -0500
+++ b/templates/grid_base.mako Fri Feb 04 14:49:23 2011 -0500
@@ -262,6 +262,9 @@
// Add sort argument to URL args.
url_args['sort'] = "${sort_key}";
+ // Add show_item_checkboxes argument to URL args.
+ url_args['show_item_checkboxes'] = ("${context.get('show_item_checkboxes', False)}" === "True");
+
// Add async keyword to URL args.
url_args['async'] = true;
--- a/templates/tracks/history_datasets_select_grid.mako Fri Feb 04 14:29:23 2011 -0500
+++ b/templates/tracks/history_datasets_select_grid.mako Fri Feb 04 14:49:23 2011 -0500
@@ -11,6 +11,5 @@
%>
## Use class 'label' to piggyback on URL functionality in parent template.
<a class="label" href="${h.url_for( **url_dict )}">Back to histories</a>
- <br /><br />
- ${parent.title()}
+ <h2>History '${grid.get_current_item( trans, **kwargs ).name}'</h2></%def>
\ No newline at end of file
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.
1
0
commit/galaxy-central: james_taylor: Disable overview canvas saving for now, need to do this right
by Bitbucket 04 Feb '11
by Bitbucket 04 Feb '11
04 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/4aa68bbab83f/
changeset: r4996:4aa68bbab83f
user: james_taylor
date: 2011-02-04 20:29:23
summary: Disable overview canvas saving for now, need to do this right
affected #: 1 file (173 bytes)
--- a/static/scripts/trackster.js Fri Feb 04 14:17:07 2011 -0500
+++ b/static/scripts/trackster.js Fri Feb 04 14:29:23 2011 -0500
@@ -1374,6 +1374,8 @@
}
if (tile_element) {
// Store initial canvas in case we need to use it for overview
+ /* This is completely broken, just saves the first tile it sees
+ regardless of if it should be the overview
if (!track.initial_canvas && !window.G_vmlCanvasManager) {
track.initial_canvas = $(tile_element).clone();
var src_ctx = tile_element.get(0).getContext("2d");
@@ -1382,6 +1384,7 @@
tgt_ctx.putImageData(data, 0, 0);
track.set_overview();
}
+ */
// Add tile to cache and show tile.
track.tile_cache.set(key, tile_element);
track.show_tile(tile_element, parent_element, tile_low);
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.
1
0
commit/galaxy-central: james_taylor: trackster: give tile tracks a background that shows when loading tiles
by Bitbucket 04 Feb '11
by Bitbucket 04 Feb '11
04 Feb '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/570bbff943b1/
changeset: r4995:570bbff943b1
user: james_taylor
date: 2011-02-04 20:17:07
summary: trackster: give tile tracks a background that shows when loading tiles
affected #: 3 files (766 bytes)
--- a/static/scripts/trackster.js Fri Feb 04 11:33:30 2011 -0500
+++ b/static/scripts/trackster.js Fri Feb 04 14:17:07 2011 -0500
@@ -51,6 +51,8 @@
});
}
+
+
/**
* Init constants & functions used throughout trackster.
*/
@@ -1360,6 +1362,15 @@
}
if (!tile_element) {
tile_element = track.draw_tile(resolution, tile_index, parent_element, w_scale);
+ if ( tile_element ) {
+ // Wrap element in div for background
+ var wrapper_element = $("<div class='track-tile'>").prepend( tile_element );
+ // HACK: filtering
+ if ( tile_element.hasClass( FILTERABLE_CLASS ) ) {
+ wrapper_element.addClass( FILTERABLE_CLASS );
+ }
+ tile_element = wrapper_element;
+ }
}
if (tile_element) {
// Store initial canvas in case we need to use it for overview
@@ -1398,6 +1409,7 @@
parent_element.append( tile_element );
track.max_height = Math.max( track.max_height, tile_element.height() );
track.content_div.css("height", track.max_height + "px");
+ parent_element.children().css("height", track.max_height + "px");
if (track.hidden) { return; }
--- a/templates/tracks/browser.mako Fri Feb 04 11:33:30 2011 -0500
+++ b/templates/tracks/browser.mako Fri Feb 04 14:17:07 2011 -0500
@@ -102,13 +102,22 @@
}
.track-content {
- background: #eee;
+ background: #eee url(${h.url_for('/static/images/tracks/diag_bg.gif')});
min-height: 16px;
}
.label-track .track-content {
background: white;
}
+
+ .track-tile {
+ background: white;
+ }
+
+ .track-tile canvas {
+ position: relative;
+ z-index: 100;
+ }
</style></%def>
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.
1
0
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/93f1baaa89ec/
changeset: r4994:93f1baaa89ec
user: jgoecks
date: 2011-02-04 17:33:30
summary: Trackster: support large (10,000+) sets of chromosomes/contigs, as is often the case for lower coverage genomes. Subsets of chromosomes are loaded into in the chrom select and there are options to move to the previous/next set of chromosomes. If user enters chrom not loaded into navigation box, chrom is loaded and then navigation is performed.
affected #: 3 files (4.3 KB)
--- a/lib/galaxy/web/controllers/tracks.py Thu Feb 03 17:13:49 2011 -0500
+++ b/lib/galaxy/web/controllers/tracks.py Fri Feb 04 11:33:30 2011 -0500
@@ -241,9 +241,10 @@
return trans.fill_template( 'tracks/browser.mako', config=viz_config, add_dataset=new_dataset )
@web.json
- def chroms(self, trans, vis_id=None, dbkey=None ):
+ def chroms( self, trans, vis_id=None, dbkey=None, num=None, chrom=None, low=None ):
"""
Returns a naturally sorted list of chroms/contigs for either a given visualization or a given dbkey.
+ Use either chrom or low to specify the starting chrom in the return list.
"""
def check_int(s):
if s.isdigit():
@@ -254,6 +255,25 @@
def split_by_number(s):
return [ check_int(c) for c in re.split('([0-9]+)', s) ]
+ #
+ # Parameter check, setting.
+ #
+ if num:
+ num = int( num )
+ else:
+ num = sys.maxint
+
+ if low:
+ low = int( low )
+ if low < 0:
+ low = 0
+ else:
+ low = 0
+
+ #
+ # Get viz, dbkey.
+ #
+
# Must specify either vis_id or dbkey.
if not vis_id and not dbkey:
return trans.show_error_message("No visualization id or dbkey specified.")
@@ -269,46 +289,96 @@
# No vis_id, so visualization is new. User is current user, dbkey must be given.
vis_user = trans.user
vis_dbkey = dbkey
+
+ #
+ # Get len file.
+ #
+ len_file = None
+ len_ds = None
+ # If there is any dataset in the history of extension `len`, this will use it
+ if 'dbkeys' in vis_user.preferences:
+ user_keys = from_json_string( vis_user.preferences['dbkeys'] )
+ if vis_dbkey in user_keys:
+ len_file = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( user_keys[ vis_dbkey ][ 'len' ] ).file_name
+
+ if not len_file:
+ len_ds = trans.db_dataset_for( dbkey )
+ if not len_ds:
+ len_file = os.path.join( trans.app.config.tool_data_path, 'shared','ucsc','chrom', "%s.len" % vis_dbkey )
+ else:
+ len_file = len_ds.file_name
- # Get chroms data.
- chroms = self._chroms( trans, vis_user, vis_dbkey )
+ #
+ # Get chroms data:
+ # (a) chrom name, len;
+ # (b) whether there are previous, next chroms;
+ # (c) index of start chrom.
+ #
+ len_file_enumerate = enumerate( open( len_file ) )
+ chroms = {}
+ prev_chroms = False
+ start_index = 0
+ if chrom:
+ # Use starting chrom to start list.
+ found = False
+ count = 0
+ for line_num, line in len_file_enumerate:
+ if line.startswith("#"):
+ continue
+ name, len = line.split("\t")
+ if found:
+ chroms[ name ] = int( len )
+ count += 1
+ elif name == chrom:
+ # Found starting chrom.
+ chroms[ name ] = int ( len )
+ count += 1
+ found = True
+ start_index = line_num
+ if line_num != 0:
+ prev_chroms = True
+ if count >= num:
+ break
+ else:
+ # Use low to start list.
+ high = low + int( num )
+ prev_chroms = ( low != 0 )
+ start_index = low
+
+ # Read chrom data from len file.
+ # TODO: this may be too slow for very large numbers of chroms/contigs,
+ # but try it out for now.
+ if not os.path.exists( len_file ):
+ return None
+
+ for line_num, line in len_file_enumerate:
+ if line_num < low:
+ continue
+ if line_num >= high:
+ break
+ if line.startswith("#"):
+ continue
+ # LEN files have format:
+ # <chrom_name><tab><chrom_length>
+ fields = line.split("\t")
+ chroms[ fields[0] ] = int( fields[1] )
+
+ # Set flag to indicate whether there are more chroms after list.
+ next_chroms = False
+ try:
+ len_file_enumerate.next()
+ next_chroms = True
+ except:
+ # No more chroms to read.
+ pass
# Check for reference chrom
if self.available_genomes is None: self._init_references(trans)
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 { 'reference': vis_dbkey in self.available_genomes, 'chrom_info': to_sort }
-
- def _chroms( self, trans, user, dbkey ):
- """
- Helper method that returns chrom lengths for a given user and dbkey.
- """
- len_file = None
- len_ds = None
- # If there is any dataset in the history of extension `len`, this will use it
- if 'dbkeys' in user.preferences:
- user_keys = from_json_string( user.preferences['dbkeys'] )
- if dbkey in user_keys:
- len_file = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( user_keys[dbkey]['len'] ).file_name
-
- if not len_file:
- len_ds = trans.db_dataset_for( dbkey )
- if not len_ds:
- len_file = os.path.join( trans.app.config.tool_data_path, 'shared','ucsc','chrom', "%s.len" % dbkey )
- else:
- len_file = len_ds.file_name
- manifest = {}
- if not os.path.exists( len_file ):
- return None
- for line in open( len_file ):
- if line.startswith("#"):
- continue
- # LEN files have format:
- # <chrom_name><tab><chrom_length>
- fields = line.split("\t")
- manifest[fields[0]] = int(fields[1])
- return manifest
+ return { 'reference': vis_dbkey in self.available_genomes, 'chrom_info': to_sort,
+ 'prev_chroms' : prev_chroms, 'next_chroms' : next_chroms, 'start_index' : start_index }
@web.json
def reference( self, trans, dbkey, chrom, low, high, **kwargs ):
--- a/static/scripts/packed/trackster.js Thu Feb 03 17:13:49 2011 -0500
+++ b/static/scripts/packed/trackster.js Fri Feb 04 11:33:30 2011 -0500
@@ -1,1 +1,1 @@
-CanvasRenderingContext2D.prototype.dashedLine=function(c,i,b,h,f){if(f==undefined){f=4}var e=b-c;var d=h-i;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var k=e/g;var j=d/g;for(var a=0;a<g;a++,c+=k,i+=j){if(a%2!=0){continue}this.fillRect(c,i,f,1)}};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();for(var c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c==f.length){if(this!=f.get(c-1)){g.append(this)}}else{if(this!=f.get(c)){$(this).insertBefore(f.get(c))}}})}var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,CONNECTOR_COLOR="#ccc",DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",FILTERABLE_CLASS="filterable",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}CONTEXT=DUMMY_CANVAS.getContext("2d");PX_PER_CHAR=CONTEXT.measureText("A").width;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function(){RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.move_key_to_end(b,a)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_form=$("<form/>").attr("action",function(){}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.chrom_form);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.chrom_form);$.ajax({url:chrom_url,data:(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}),dataType:"json",success:function(f){if(f.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=f.chrom_info;var j='<option value="">Select Chrom/Contig</option>';for(var h=0,e=a.chrom_data.length;h<e;h++){var g=a.chrom_data[h].chrom;j+='<option value="'+g+'">'+g+"</option>"}a.chrom_select.html(j);a.intro_div.show();a.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});if(d){d()}},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}});this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var i=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(i/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("draginit",function(f,g){if(f.clientX>a.viewport_container.width()-16){return false}}).bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX}).bind("drag",function(h,j){var f=$(this);var k=j.offsetX-j.current_x;var g=f.scrollTop()-(h.clientY-j.current_height);f.scrollTop(g);j.current_height=h.clientY;j.current_x=j.offsetX;var i=Math.round(k/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)}).bind("mousewheel",function(h,j,g,f){if(g){var i=Math.round(-g/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)}});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height(),top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j,k){$(k.proxy).css({left:Math.min(j.pageX,k.startX),width:Math.abs(j.pageX-k.startX)});var g=Math.min(j.pageX,k.startX)-a.container.offset().left,f=Math.max(j.pageX,k.startX)-a.container.offset().left,i=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*i)+a.low,Math.round(f/h*i)+a.low)}).bind("dragend",function(k,l){var g=Math.min(k.pageX,l.startX),f=Math.max(k.pageX,l.startX),i=(a.high-a.low),h=a.viewport_container.width(),j=a.low;a.low=Math.round(g/h*i)+j;a.high=Math.round(f/h*i)+j;$(l.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},change_chrom:function(e,b,g){var d=this;var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){return}if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()},go_to:function(f){var j=this,a,d,b=f.split(":"),h=b[0],i=b[1];if(i!==undefined){try{var g=i.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}j.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);sortable(a.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_location(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide()}});var Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)==0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e=="int"||e=="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}if(a.view.chrom!=null){$.getJSON(this.dataset_check_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom,low:a.view.max_low,high:a.view.max_high},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").attr("id",d+"_error");c.text("View error");$("#"+d+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b==="data"){a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;a.predraw_init();a.draw()}}}}}}})}},predraw_init:function(){},restore_prefs:function(a){var b=this;$.each(a,function(c,d){if(d!==undefined){b.prefs[c]=d}})},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(g,d,s){var o=this,j=o.view;this.filters=(g!==undefined?get_filters_from_dict(g):[]);this.tool=(d!==undefined?get_tool_from_dict(d):undefined);this.parent_track=s;this.child_tracks=[];if(o.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filtering_div=$("<div/>").addClass("track-filters").hide();this.header_div.after(this.filtering_div);this.filtering_div.bind("drag",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var t=$("<table class='filters'>").appendTo(this.filtering_div);$.each(this.filters,function(w,z){var v=$("<tr>").appendTo(t);var y=$("<th class='filter-info'>").appendTo(v);var u=$("<span class='name'>").appendTo(y);u.text(z.name+" ");var i=$("<span class='values'>").appendTo(y);var x=$("<td>").appendTo(v);z.control_element=$("<div id='"+z.name+"-filter-control' style='width: 200px; position: relative'>").appendTo(x);z.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(B,C){var A=C.values;i.text("["+A[0]+"-"+A[1]+"]");z.low=A[0];z.high=A[1];o.draw(true)},change:function(A,B){z.control_element.slider("option","slide").call(z.control_element,A,B)}});z.slider=z.control_element;z.slider_label=i});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(i){i.stopPropagation()}).bind("click",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var l=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var e=this.tool.params;var o=this;$.each(this.tool.params,function(A,v){var y=$("<div>").addClass("param-row").appendTo(o.dynamic_tool_div);var x=$("<div>").addClass("slider-label").appendTo(y);var C=$("<span class='param-name'>").text(v.label+" ").appendTo(x);var w=$("<span/>").text(v.value);var z=$("<span class='param-value'>").appendTo(x).append("[").append(w).append("]");var B=$("<div/>").addClass("slider").appendTo(y);var i=$("<div id='"+v.name+"-param-control'>").appendTo(B);var u=(v.max<=1?0.01:(v.max<=1000?1:5));i.slider({min:v.min,max:v.max,step:u,value:v.value,slide:function(D,F){var E=F.value;v.value=E;if(0<E&&E<1){E=parseFloat(E).toFixed(2)}w.text(E)},change:function(D,E){v.value=E.value}});z.click(function(){var F=w,E=F.text(),D=(v.max<=1?4:v.max.length);F.text("");$("<input type='text'/>").attr("size",D).attr("maxlength",D).attr("value",E).appendTo(F).focus().select().click(function(G){G.stopPropagation()}).blur(function(){$(this).remove();F.text(E)}).keyup(function(I){if(I.keyCode===27){$(this).trigger("blur")}else{if(I.keyCode===13){var G=$(this),H=parseFloat(G.val());if(isNaN(H)||H>v.max||H<v.min){alert("Parameter value must be in the range ["+v.min+"-"+v.max+"]");return $(this)}F.text(H);i.slider("value",H);v.value=H}}})});$("<div style='clear: both;'/>").appendTo(y)});var b=$("<div>").addClass("param-row").appendTo(this.dynamic_tool_div);var n=$("<input type='submit'>").attr("value","Run").appendTo(b);var o=this;n.click(function(){o.run_tool()})}o.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();o.container_div.append(o.child_tracks_container);if(o.display_modes!==undefined){if(o.mode_div===undefined){o.mode_div=$("<div class='right-float menubutton popup' />").appendTo(o.header_div);var m=o.display_modes[0];o.mode=m;o.mode_div.text(m);var a=function(i){o.mode_div.text(i);o.mode=i;o.tile_cache.clear();o.draw()};var f={};for(var q=0,r=o.display_modes.length;q<r;q++){var k=o.display_modes[q];f[k]=function(i){return function(){a(i)}}(k)}make_popupmenu(o.mode_div,f)}else{o.mode_div.hide()}}var h={};h["Edit configuration"]=function(){var v=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},i=function(){o.update_options(o.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},u=function(w){if((w.keyCode||w.which)===27){v()}else{if((w.keyCode||w.which)===13){i()}}};$(window).bind("keypress.check_enter_esc",u);show_modal("Configure Track",o.gen_options(o.track_id),{Cancel:v,OK:i})};h["Set as overview"]=function(){j.overview_viewport.find("canvas").remove();o.is_overview=true;o.set_overview();for(var i in j.tracks){if(j.tracks[i]!==o){j.tracks[i].is_overview=false}}};if(o.filters.length>0){h["Show filters"]=function(){var i;if(!o.filtering_div.is(":visible")){i="Hide filters";o.filters_visible=true}else{i="Show filters";o.filters_visible=false}o.filtering_div.toggle()}}if(o.tool){h["Toggle Tool"]=function(){var i;if(!o.dynamic_tool_div.is(":visible")){i="Hide dynamic tool";o.update_name(o.name+o.tool_region_and_parameters_str())}else{i="Show dynamic tool";o.revert_name()}o.dynamic_tool_div.toggle()}}var c=j;var p=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;p=function(){}}h.Remove=function(){c.remove_track(o);if(c.num_tracks===0){p()}};o.popup_menu=make_popupmenu(o.name_div,h)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(a){var l=this.view.low,f=this.view.high,h=f-l,e=this.view.resolution;var o=$("<div style='position: relative;'></div>"),q=this.content_div.width()/h;this.content_div.append(o);this.max_height=0;var b=Math.floor(l/e/DENSITY);var k=0;while((b*DENSITY*e)<f){var m=this.content_div.width()+"_"+q+"_"+b;var d=this.tile_cache.get(m);var j=b*DENSITY*this.view.resolution;var p=j+DENSITY*this.view.resolution;if(!a&&d){this.show_tile(d,o,j)}else{this.delayed_draw(a,m,j,p,b,e,o,q,k)}b+=1}var c=this;var n=setInterval(function(){if(k===0){var t=c.content_div.children();var s=false;for(var u=t.length-1,r=0;u>=r;u--){var w=$(t[u]);if(s){w.remove()}else{if(w.children().length!==0){s=true}}}for(var v=0;v<c.filters.length;v++){c.filters[v].update_ui_elt()}clearInterval(n)}},50);for(var g=0;g<this.child_tracks.length;g++){this.child_tracks[g].draw(a)}},delayed_draw:function(b,h,g,j,c,e,i,k,f){var d=this;var a=setTimeout(function(){if(g<=d.view.high&&j>=d.view.low){var l;if(!b){l=d.tile_cache.get(h)}if(!l){l=d.draw_tile(e,c,i,k)}if(l){if(!d.initial_canvas&&!window.G_vmlCanvasManager){d.initial_canvas=$(l).clone();var o=l.get(0).getContext("2d");var m=d.initial_canvas.get(0).getContext("2d");var n=o.getImageData(0,0,o.canvas.width,o.canvas.height);m.putImageData(n,0,0);d.set_overview()}d.tile_cache.set(h,l);d.show_tile(l,i,g)}}delete f--},50);f++},show_tile:function(a,f,d){var b=this;var c=this.view.high-this.view.low,g=this.content_div.width()/c,e=(d-this.view.low)*g;if(this.left_offset){e-=this.left_offset}a.css({position:"absolute",top:0,left:e});f.append(a);b.max_height=Math.max(b.max_height,a.height());b.content_div.css("height",b.max_height+"px");if(b.hidden){return}if(a.hasClass(FILTERABLE_CLASS)){show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters");if(b.filters_visible){b.filtering_div.show()}}else{show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters",false);b.filtering_div.hide()}},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type=="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f=="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f=="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.data_queue={};this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(f,b,k,o){var g=b*DENSITY*f,d=DENSITY*f,j=f+"_"+b;var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var n=e.get(0).getContext("2d");if(o>PX_PER_CHAR){if(this.data_cache.get(j)===undefined){this.get_data(f,b);return}var m=this.data_cache.get(j);if(m===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*o+this.left_offset);e.get(0).height=this.height_px;for(var h=0,l=m.length;h<l;h++){var a=Math.round(h*o),i=Math.round(o/2);n.fillText(m[h],a+this.left_offset+i,10)}k.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,e,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.min_height_px=12;this.max_height_px=400;this.height_px=80;this.hda_ldda=e;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};this.restore_prefs(c);(function(f){var i=false;var h=false;var g=$("<div class='track-resize'>");$(f.container_div).hover(function(){i=true;g.show()},function(){i=false;if(!h){g.hide()}});g.hide().bind("dragstart",function(j,k){h=true;k.original_height=$(f.content_div).height()}).bind("drag",function(k,l){var j=Math.min(Math.max(l.original_height+l.deltaY,f.min_height_px),f.max_height_px);$(f.content_div).css("height",j);f.height_px=j;f.draw(true)}).bind("dragend",function(j,k){f.tile_cache.clear();h=false;if(!i){g.hide()}}).appendTo(f.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;$.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:this.data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){var h=g.data;c.data_cache.set(e,h);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*o,a=DENSITY*o,x=o+"_"+r;var b=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);if(this.data_cache.get(x)===undefined){this.get_data(o,r);return}var v=this.data_cache.get(x);if(!v){return}b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var n=b.get(0).getContext("2d"),j=false,k=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,t=this.total_frequency,d=this.height_px,l=this.mode;var w=Math.round(d+k/m*d);n.beginPath();n.moveTo(0,w);n.lineTo(a*e,w);n.fillStyle="#aaa";n.stroke();n.beginPath();n.fillStyle=this.prefs.color;var u,h,f;if(v.length>1){f=Math.ceil((v[1][0]-v[0][0])*e)}else{f=10}for(var p=0,q=v.length;p<q;p++){u=Math.round((v[p][0]-s)*e);h=v[p][1];if(h===null){if(j&&l==="Filled"){n.lineTo(u,d)}j=false;continue}if(h<k){h=k}else{if(h>g){h=g}}if(l==="Histogram"){h=Math.round(h/m*d);n.fillRect(u,w,f,-h)}else{if(l==="Intensity"){h=255-Math.floor((h-k)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(u,0,f,d)}else{h=Math.round(d-(h-k)/m*d);if(j){n.lineTo(u,h)}else{j=true;if(l==="Filled"){n.moveTo(u,d);n.lineTo(u,h)}else{n.moveTo(u,h)}}}}}if(l==="Filled"){if(j){n.lineTo(u,w);n.lineTo(0,w)}n.fill()}else{n.stroke()}return b},gen_options:function(m){var a=$("<div />").addClass("form-row");var e="track_"+m+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+m+"_minval",l=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),k=$("<input></input>").attr("id",h).val(d),j="track_"+m+"_maxval",g=$("<label></label>").attr("for",j).text("Max value:"),i=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",j).val(i);return a.append(l).append(k).append(g).append(f).append(b).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_color").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.color=b;this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+d+"_minval").text(this.prefs.min_value);$("#linetrack_"+d+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(f,c,h,a,e,g,d,b){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,f,c,c.viewport_container);TiledTrack.call(this,g,d,b);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=h;this.dataset_id=a;this.original_dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200;this.prefs={block_color:"#444",label_color:"black",show_counts:true};this.restore_prefs(e)};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(b.data_url,{chrom:b.view.chrom,low:a,high:d,hda_ldda:b.hda_ldda,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set_data(a,d,b.mode,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,b,p){var r=this.inc_slots[a];if(!r||(r.mode!==p)){r={};r.w_scale=a;r.mode=p;this.inc_slots[a]=r;this.s_e_by_tile[a]={}}var l=r.w_scale,x=[],y=[],j=0,n=this.view.max_low;for(var v=0,w=h.length;v<w;v++){var g=h[v],k=g[0];if(r[k]!==undefined){j=Math.max(j,r[k]);y.push(r[k])}else{x.push(v)}}var q=this.s_e_by_tile[a];var m=function(D,E){var C;for(var B=0,F;B<=MAX_FEATURE_DEPTH;B++){C=true;F=q[B];if(F!==undefined){for(var z=0,A=F.length;z<A;z++){var i=F[z];if(E>i[0]&&D<i[1]){C=false;break}}}if(C){break}}if(C){return B}else{return -1}};for(var v=0,w=x.length;v<w;v++){var g=h[x[v]],k=g[0],t=g[1],c=g[2],o=g[3],d=Math.floor((t-n)*l),f=Math.ceil((c-n)*l),u=CONTEXT.measureText(o).width,e;if(o!==undefined&&!b){if(d-u<0){f+=u;e="left"}else{d-=u;e="right"}}var s=m(d,f);if(s<0){}if(s>=0){slot=q[s];if(slot===undefined){slot=q[s]=[]}slot.push([d,f]);r[k]=s;j=Math.max(j,s)}else{}}return j},rect_or_text:function(r,l,u,b,q,j,g,f){r.textAlign="center";var d=0,s=0,p=Math.round(l/2);for(var m=0,t=j.length;m<t;m++){var k=j[m],e="MIDNSHP=X"[k[0]],n=k[1];if(e==="H"||e==="S"){d-=n}var h=q+d,x=Math.floor(Math.max(0,(h-u)*l)),i=Math.floor(Math.max(0,(h+n-u)*l));switch(e){case"H":break;case"S":case"M":case"=":var o=g.slice(s,s+n);if((this.mode==="Pack"||this.mode==="Auto")&&g!==undefined&&l>PX_PER_CHAR){r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+1,i-x,9);r.fillStyle=CONNECTOR_COLOR;for(var v=0,a=o.length;v<a;v++){if(h+v>=u&&h+v<=b){var w=Math.floor(Math.max(0,(h+v-u)*l));r.fillText(o[v],w+this.left_offset+p,f+9)}}}else{r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+(this.mode!="Dense"?4:5),i-x,(this.mode!="Dense"?3:1))}s+=n;break;case"N":r.fillStyle=CONNECTOR_COLOR;r.fillRect(x+this.left_offset,f+5,i-x,1);break;case"D":r.fillStyle="red";r.fillRect(x+this.left_offset,f+4,i-x,3);break;case"P":break;case"I":s+=n;break;case"X":s+=n;break}d+=n}},draw_tile:function(ad,n,r,ar){var L=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,K=ai-L;var G=this.data_cache.get_data(L,ai,this.mode);if(G===undefined||G==="pending"||(this.mode!=="Auto"&&G.dataset_type==="summary_tree")){this.data_queue[[L,ai]]=true;this.get_data(L,ai);return}var a=Math.ceil(K*ar),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,v=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,aq,B,at;var p=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(p)}p=$(p);if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(q==="Dense"){B=v;at=10}else{at=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ar<0.0001?1/this.view.zoom_res:ar);B=this.incremental_slots(w,G.data,ab,q)*at+v;aq=this.inc_slots[w]}}p.get(0).width=a+U;p.get(0).height=B;r.parent().css("height",Math.max(this.height_px,B)+"px");var H=p.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";this.container_div.find(".yaxislabel").remove();if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,b=Math.ceil(G.delta*ar);var o=$("<div />").addClass("yaxislabel");o.text(J);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,F=W.length;am<F;am++){var Y=Math.floor((W[am][0]-L)*ar);var X=W[am][1];if(!X){continue}var aj=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}return p}if(G.message){p.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,at);return p}for(var ao=0;ao<this.filters.length;ao++){if(this.filters[ao].applies_to(G.data[0])){p.addClass(FILTERABLE_CLASS);break}}var ap=G.data;var al=0;for(var am=0,F=ap.length;am<F;am++){var Q=ap[am],P=Q[0],an=Q[1],aa=Q[2],M=Q[3];if(this.mode!="Dense"&&aq[P]===undefined){continue}var Z=false;var S;for(var ao=0;ao<this.filters.length;ao++){S=this.filters[ao];S.update_attrs(Q);if(!S.keep(Q)){Z=true;break}}if(Z){continue}if(an<=ai&&aa>=L){var ac=Math.floor(Math.max(0,(an-L)*ar)),I=Math.ceil(Math.min(a,Math.max(0,(aa-L)*ar))),V=(q==="Dense"?1:(1+aq[P]))*at;var E,ag,N=null,au=null;if(G.dataset_type==="bai"){H.fillStyle=h;if(Q[5] instanceof Array){var C=Math.floor(Math.max(0,(Q[4][0]-L)*ar)),O=Math.ceil(Math.min(a,Math.max(0,(Q[4][1]-L)*ar))),A=Math.floor(Math.max(0,(Q[5][0]-L)*ar)),u=Math.ceil(Math.min(a,Math.max(0,(Q[5][1]-L)*ar)));if(Q[4][1]>=L&&Q[4][0]<=ai&&Q[4][2]){this.rect_or_text(H,ar,L,ai,Q[4][0],Q[4][2],Q[4][3],V)}if(Q[5][1]>=L&&Q[5][0]<=ai&&Q[5][2]){this.rect_or_text(H,ar,L,ai,Q[5][0],Q[5][2],Q[5][3],V)}if(A>O){H.fillStyle=CONNECTOR_COLOR;H.dashedLine(O+U,V+5,U+A,V+5)}}else{H.fillStyle=h;this.rect_or_text(H,ar,L,ai,an,Q[4],Q[5],V)}if(q!=="Dense"&&!ab&&an>L){H.fillStyle=this.prefs.label_color;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var D=Q[5],T=Q[6],ae=Q[7],g=Q[8];if(T&&ae){N=Math.floor(Math.max(0,(T-L)*ar));au=Math.ceil(Math.min(a,Math.max(0,(ae-L)*ar)))}if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}if(g){if(D){if(D=="+"){H.fillStyle=RIGHT_STRAND}else{if(D=="-"){H.fillStyle=LEFT_STRAND}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}for(var ak=0,e=g.length;ak<e;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-L)*ar)),R=Math.ceil(Math.min(a,Math.max((t[1]-L)*ar)));if(d>R){continue}E=5;ag=3;H.fillRect(d+U,V+ag,R-d,E);if(N!==undefined&&!(d>au||R<N)){E=9;ag=1;var ah=Math.max(d,N),z=Math.min(R,au);H.fillRect(ah+U,V+ag,z-ah,E)}}}else{E=9;ag=1;H.fillRect(ac+U,V+ag,I-ac,E);if(Q.strand){if(Q.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(Q.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var s=Q[4],m=Q[5],c=Q[6];E=9;ag=1;H.fillRect(ac+U,V,I-ac,E);if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}var l=s+" / "+m;if(an>L&&H.measureText(l).width<(I-ac)){H.fillStyle="white";H.textAlign="center";H.fillText(l,U+ac+(I-ac)/2,V+8);H.fillStyle=h}}}}}al++}}return p},gen_options:function(i){var a=$("<div />").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label />").attr("for",e).text("Block color:"),l=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label />").attr("for",j).text("Text color:"),h=$("<input />").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(k).append(l).append(g).append(h).append(d)},update_options:function(d){var b=$("#track_"+d+"_block_color").val(),c=$("#track_"+d+"_label_color").val(),a=$("#track_"+d+"_show_count").attr("checked");if(b!==this.prefs.block_color||c!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=c;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()==0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id},function(c){})}};a()}});
\ No newline at end of file
+CanvasRenderingContext2D.prototype.dashedLine=function(c,i,b,h,f){if(f==undefined){f=4}var e=b-c;var d=h-i;var g=Math.floor(Math.sqrt(e*e+d*d)/f);var k=e/g;var j=d/g;for(var a=0;a<g;a++,c+=k,i+=j){if(a%2!=0){continue}this.fillRect(c,i,f,1)}};function sortable(a,b){a.bind("drag",{handle:b,relative:true},function(h,j){var g=$(this).parent();var f=g.children();for(var c=0;c<f.length;c++){if(j.offsetY<$(f.get(c)).position().top){break}}if(c==f.length){if(this!=f.get(c-1)){g.append(this)}}else{if(this!=f.get(c)){$(this).insertBefore(f.get(c))}}})}var DENSITY=200,FEATURE_LEVELS=10,MAX_FEATURE_DEPTH=100,DEFAULT_DATA_QUERY_WAIT=5000,MAX_CHROMS_SELECTABLE=100,CONNECTOR_COLOR="#ccc",DATA_ERROR="There was an error in indexing this dataset. ",DATA_NOCONVERTER="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",DATA_NONE="No data for this chrom/contig.",DATA_PENDING="Currently indexing... please wait",DATA_CANNOT_RUN_TOOL="Tool cannot be rerun: ",DATA_LOADING="Loading data...",DATA_OK="Ready for display",FILTERABLE_CLASS="filterable",CACHED_TILES_FEATURE=10,CACHED_TILES_LINE=5,CACHED_DATA=5,DUMMY_CANVAS=document.createElement("canvas"),RIGHT_STRAND,LEFT_STRAND;if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(DUMMY_CANVAS)}CONTEXT=DUMMY_CANVAS.getContext("2d");PX_PER_CHAR=CONTEXT.measureText("A").width;var right_img=new Image();right_img.src=image_path+"/visualization/strand_right.png";right_img.onload=function(){RIGHT_STRAND=CONTEXT.createPattern(right_img,"repeat")};var left_img=new Image();left_img.src=image_path+"/visualization/strand_left.png";left_img.onload=function(){LEFT_STRAND=CONTEXT.createPattern(left_img,"repeat")};var right_img_inv=new Image();right_img_inv.src=image_path+"/visualization/strand_right_inv.png";right_img_inv.onload=function(){RIGHT_STRAND_INV=CONTEXT.createPattern(right_img_inv,"repeat")};var left_img_inv=new Image();left_img_inv.src=image_path+"/visualization/strand_left_inv.png";left_img_inv.onload=function(){LEFT_STRAND_INV=CONTEXT.createPattern(left_img_inv,"repeat")};function round_1000(a){return Math.round(a*1000)/1000}var Cache=function(a){this.num_elements=a;this.clear()};$.extend(Cache.prototype,{get:function(b){var a=this.key_ary.indexOf(b);if(a!=-1){this.move_key_to_end(b,a)}return this.obj_cache[b]},set:function(b,c){if(!this.obj_cache[b]){if(this.key_ary.length>=this.num_elements){var a=this.key_ary.shift();delete this.obj_cache[a]}this.key_ary.push(b)}this.obj_cache[b]=c;return c},move_key_to_end:function(b,a){this.key_ary.splice(a,1);this.key_ary.push(b)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var DataCache=function(a){Cache.call(this,a)};$.extend(DataCache.prototype,Cache.prototype,{get_data:function(g,b,e){var h=this.get(this.gen_key(g,b,e));if(h){return h}var j,f,a,d,e,h;for(var c=0;c<this.key_ary.length;c++){j=this.key_ary[c];f=this.split_key(j);a=f[0];d=f[1];if(g>=a&&b<=d){h=this.obj_cache[j];if(h.dataset_type!=="summary_tree"&&h.extra_info!=="no_detail"){this.move_key_to_end(j,c);return h}}}return undefined},set_data:function(b,c,d,a){return this.set(this.gen_key(b,c,d),a)},gen_key:function(a,c,d){var b=a+"_"+c;return b},split_key:function(a){return a.split("_")}});var View=function(a,d,c,b,e){this.container=a;this.chrom=null;this.vis_id=c;this.dbkey=b;this.title=d;this.tracks=[];this.label_tracks=[];this.max_low=0;this.max_high=0;this.num_tracks=0;this.track_id_counter=0;this.zoom_factor=3;this.min_separation=30;this.has_changes=false;this.init(e);this.reset()};$.extend(View.prototype,{init:function(d){var c=this.container,a=this;this.top_container=$("<div/>").addClass("top-container").appendTo(c);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(c);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(c);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);this.intro_div=$("<div/>").addClass("intro").text("Select a chrom from the dropdown below").hide();this.nav_labeltrack=$("<div/>").addClass("nav-labeltrack").appendTo(this.bottom_container);this.nav_container=$("<div/>").addClass("nav-container").prependTo(this.top_container);this.nav=$("<div/>").addClass("nav").appendTo(this.nav_container);this.overview=$("<div/>").addClass("overview").appendTo(this.bottom_container);this.overview_viewport=$("<div/>").addClass("overview-viewport").appendTo(this.overview);this.overview_close=$("<a href='javascript:void(0);'>Close Overview</a>").addClass("overview-close").hide().appendTo(this.overview_viewport);this.overview_highlight=$("<div/>").addClass("overview-highlight").hide().appendTo(this.overview_viewport);this.overview_box_background=$("<div/>").addClass("overview-boxback").appendTo(this.overview_viewport);this.overview_box=$("<div/>").addClass("overview-box").appendTo(this.overview_viewport);this.default_overview_height=this.overview_box.height();this.nav_controls=$("<div/>").addClass("nav-controls").appendTo(this.nav);this.chrom_form=$("<form/>").attr("action",function(){}).appendTo(this.nav_controls);this.chrom_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.chrom_form);var b=function(f){if(f.type==="focusout"||(f.keyCode||f.which)===13||(f.keyCode||f.which)===27){if((f.keyCode||f.which)!==27){a.go_to($(this).val())}$(this).hide();a.location_span.show();a.chrom_select.show();return false}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keypress focusout",b).appendTo(this.chrom_form);this.location_span=$("<span/>").addClass("location").appendTo(this.chrom_form);this.location_span.bind("click",function(){a.location_span.hide();a.chrom_select.hide();a.nav_input.css("display","inline-block");a.nav_input.select();a.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.chrom_form)}this.zo_link=$("<a id='zoom-out' />").click(function(){a.zoom_out();a.redraw()}).appendTo(this.chrom_form);this.zi_link=$("<a id='zoom-in' />").click(function(){a.zoom_in();a.redraw()}).appendTo(this.chrom_form);this.load_chroms({low:0},d);this.chrom_select.bind("change",function(){a.change_chrom(a.chrom_select.val())});this.intro_div.show();this.content_div.bind("click",function(f){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(f){a.zoom_in(f.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(f,g){this.current_x=g.offsetX}).bind("drag",function(f,h){var i=h.offsetX-this.current_x;this.current_x=h.offsetX;var g=Math.round(i/a.viewport_container.width()*(a.max_high-a.max_low));a.move_delta(-g)});this.overview_close.bind("click",function(){for(var f=0,e=a.tracks.length;f<e;f++){a.tracks[f].is_overview=false}$(this).siblings().filter("canvas").remove();$(this).parent().css("height",a.overview_box.height());a.overview_highlight.hide();$(this).hide()});this.viewport_container.bind("draginit",function(f,g){if(f.clientX>a.viewport_container.width()-16){return false}}).bind("dragstart",function(f,g){g.original_low=a.low;g.current_height=f.clientY;g.current_x=g.offsetX}).bind("drag",function(h,j){var f=$(this);var k=j.offsetX-j.current_x;var g=f.scrollTop()-(h.clientY-j.current_height);f.scrollTop(g);j.current_height=h.clientY;j.current_x=j.offsetX;var i=Math.round(k/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)}).bind("mousewheel",function(h,j,g,f){if(g){var i=Math.round(-g/a.viewport_container.width()*(a.high-a.low));a.move_delta(i)}});this.top_labeltrack.bind("dragstart",function(f,g){return $("<div />").css({height:a.content_div.height()+a.top_labeltrack.height()+a.nav_labeltrack.height(),top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(j,k){$(k.proxy).css({left:Math.min(j.pageX,k.startX),width:Math.abs(j.pageX-k.startX)});var g=Math.min(j.pageX,k.startX)-a.container.offset().left,f=Math.max(j.pageX,k.startX)-a.container.offset().left,i=(a.high-a.low),h=a.viewport_container.width();a.update_location(Math.round(g/h*i)+a.low,Math.round(f/h*i)+a.low)}).bind("dragend",function(k,l){var g=Math.min(k.pageX,l.startX),f=Math.max(k.pageX,l.startX),i=(a.high-a.low),h=a.viewport_container.width(),j=a.low;a.low=Math.round(g/h*i)+j;a.high=Math.round(f/h*i)+j;$(l.proxy).remove();a.redraw()});this.add_label_track(new LabelTrack(this,this.top_labeltrack));this.add_label_track(new LabelTrack(this,this.nav_labeltrack));$(window).bind("resize",function(){a.resize_window()});$(document).bind("redraw",function(){a.redraw()});this.reset();$(window).trigger("resize")},update_location:function(a,b){this.location_span.text(commatize(a)+" - "+commatize(b));this.nav_input.val(this.chrom+":"+commatize(a)+"-"+commatize(b))},load_chroms:function(b,c){b.num=MAX_CHROMS_SELECTABLE;$.extend(b,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var a=this;$.ajax({url:chrom_url,data:b,dataType:"json",success:function(e){if(e.reference){a.add_label_track(new ReferenceTrack(a))}a.chrom_data=e.chrom_info;var h='<option value="">Select Chrom/Contig</option>';for(var g=0,d=a.chrom_data.length;g<d;g++){var f=a.chrom_data[g].chrom;h+='<option value="'+f+'">'+f+"</option>"}if(e.prev_chroms){h+='<option value="previous">Previous '+MAX_CHROMS_SELECTABLE+"</option>"}if(e.next_chroms){h+='<option value="next">Next '+MAX_CHROMS_SELECTABLE+"</option>"}a.chrom_select.html(h);if(c){c()}a.chrom_start_index=e.start_index},error:function(){alert("Could not load chroms for this dbkey:",a.dbkey)}})},change_chrom:function(e,b,g){var d=this;if(e=="previous"){d.load_chroms({low:this.chrom_start_index-MAX_CHROMS_SELECTABLE});return}if(e=="next"){d.load_chroms({low:this.chrom_start_index+MAX_CHROMS_SELECTABLE});return}var f=$.grep(d.chrom_data,function(j,k){return j.chrom===e})[0];if(f===undefined){d.load_chroms({chrom:e},function(){d.change_chrom(e,b,g)});return}else{if(e!==d.chrom){d.chrom=e;if(!d.chrom){d.intro_div.show()}else{d.intro_div.hide()}d.chrom_select.val(d.chrom);d.max_high=f.len;d.reset();d.redraw(true);for(var h=0,a=d.tracks.length;h<a;h++){var c=d.tracks[h];if(c.init){c.init()}}}if(b!==undefined&&g!==undefined){d.low=Math.max(b,0);d.high=Math.min(g,d.max_high)}d.reset_overview();d.redraw()}},go_to:function(f){var j=this,a,d,b=f.split(":"),h=b[0],i=b[1];if(i!==undefined){try{var g=i.split("-");a=parseInt(g[0].replace(/,/g,""),10);d=parseInt(g[1].replace(/,/g,""),10)}catch(c){return false}}j.change_chrom(h,a,d)},move_fraction:function(c){var a=this;var b=a.high-a.low;this.move_delta(c*b)},move_delta:function(c){var a=this;var b=a.high-a.low;if(a.low-c<a.max_low){a.low=a.max_low;a.high=a.max_low+b}else{if(a.high-c>a.max_high){a.high=a.max_high;a.low=a.max_high-b}else{a.high-=c;a.low-=c}}a.redraw()},add_track:function(a){a.view=this;a.track_id=this.track_id_counter;this.tracks.push(a);if(a.init){a.init()}a.container_div.attr("id","track_"+a.track_id);sortable(a.container_div,".draghandle");this.track_id_counter+=1;this.num_tracks+=1},add_label_track:function(a){a.view=this;this.label_tracks.push(a)},remove_track:function(a){this.has_changes=true;a.container_div.fadeOut("slow",function(){$(this).remove()});delete this.tracks[this.tracks.indexOf(a)];this.num_tracks-=1},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},redraw:function(h){var g=this.high-this.low,f=this.low,b=this.high;if(f<this.max_low){f=this.max_low}if(b>this.max_high){b=this.max_high}if(this.high!==0&&g<this.min_separation){b=f+this.min_separation}this.low=Math.floor(f);this.high=Math.ceil(b);this.resolution=Math.pow(10,Math.ceil(Math.log((this.high-this.low)/200)/Math.LN10));this.zoom_res=Math.pow(FEATURE_LEVELS,Math.max(0,Math.ceil(Math.log(this.resolution,FEATURE_LEVELS)/Math.log(FEATURE_LEVELS))));var a=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var e=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var j=13;this.overview_box.css({left:a,width:Math.max(j,e)}).show();if(e<j){this.overview_box.css("left",a-(j-e)/2)}if(this.overview_highlight){this.overview_highlight.css({left:a,width:e})}this.update_location(this.low,this.high);if(!h){for(var c=0,d=this.tracks.length;c<d;c++){if(this.tracks[c]&&this.tracks[c].enabled){this.tracks[c].draw()}}for(c=0,d=this.label_tracks.length;c<d;c++){this.label_tracks[c].draw()}}},zoom_in:function(b,c){if(this.max_high===0||this.high-this.low<this.min_separation){return}var d=this.high-this.low,e=d/2+this.low,a=(d/this.zoom_factor)/2;if(b){e=b/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(e-a);this.high=Math.round(e+a);this.redraw()},zoom_out:function(){if(this.max_high===0){return}var b=this.high-this.low,c=b/2+this.low,a=(b*this.zoom_factor)/2;this.low=Math.round(c-a);this.high=Math.round(c+a);this.redraw()},resize_window:function(){this.viewport_container.height(this.container.height()-this.top_container.height()-this.bottom_container.height());this.nav_container.width(this.container.width());this.redraw()},reset_overview:function(){this.overview_viewport.find("canvas").remove();this.overview_viewport.height(this.default_overview_height);this.overview_box.height(this.default_overview_height);this.overview_close.hide();this.overview_highlight.hide()}});var Tool=function(a,b){this.name=a;this.params=b};$.extend(Tool.prototype,{get_param_values_dict:function(){var b={};for(var a=0;a<this.params.length;a++){var c=this.params[a];b[c.name]=c.value}return b},get_param_values:function(){var b=[];for(var a=0;a<this.params.length;a++){b[a]=this.params[a].value}return b}});var NumberToolParameter=function(c,b,e,a,d){this.name=c;this.label=b;this.min=e;this.max=a;this.value=d};var get_tool_from_dict=function(f){if(obj_length(f)==0){return undefined}var b=f.name;var l=f.params;var c=Array();for(var e=0;e<l.length;e++){var g=l[e];var a=g.name,k=g.label,h=g.type,d=g.min,j=g.max,m=g.value;c[c.length]=new NumberToolParameter(a,k,d,j,m)}return new Tool(b,c)};var Filter=function(b,a,c){this.name=b;this.index=a;this.value=c};var NumberFilter=function(b,a){this.name=b;this.index=a;this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.slider_min=Number.MAX_VALUE;this.slider_max=-Number.MAX_VALUE;this.slider=null;this.slider_label=null};$.extend(NumberFilter.prototype,{applies_to:function(a){if(a.length>this.index){return true}return false},keep:function(a){if(!this.applies_to(a)){return true}return(a[this.index]>=this.low&&a[this.index]<=this.high)},update_attrs:function(b){var a=false;if(!this.applies_to(b)){return a}if(b[this.index]<this.slider_min){this.slider_min=b[this.index];a=true}if(b[this.index]>this.slider_max){this.slider_max=b[this.index];a=false}return a},update_ui_elt:function(){var b=this.slider.slider("option","min"),a=this.slider.slider("option","max");if(this.slider_min<b||this.slider_max>a){this.slider.slider("option","min",this.slider_min);this.slider.slider("option","max",this.slider_max);this.slider.slider("option","values",[this.slider_min,this.slider_max])}}});var get_filters_from_dict=function(a){var g=[];for(var d=0;d<a.length;d++){var f=a[d];var c=f.name,e=f.type,b=f.index;if(e=="int"||e=="float"){g[d]=new NumberFilter(c,b)}else{g[d]=new Filter(c,b,e)}}return g};var Track=function(b,a,e,c,d){this.name=b;this.view=a;this.parent_element=e;this.data_url=(c?c:default_data_url);this.data_query_wait=(d?d:DEFAULT_DATA_QUERY_WAIT);this.dataset_check_url=converted_datasets_state_url;this.container_div=$("<div />").addClass("track").css("position","relative");if(!this.hidden){this.header_div=$("<div class='track-header' />").appendTo(this.container_div);if(this.view.editor){this.drag_div=$("<div class='draghandle' />").appendTo(this.header_div)}this.name_div=$("<div class='menubutton popup' />").appendTo(this.header_div);this.name_div.text(this.name);this.name_div.attr("id",this.name.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9\-]/g,"").toLowerCase())}this.content_div=$("<div class='track-content'>").appendTo(this.container_div);this.parent_element.append(this.container_div)};$.extend(Track.prototype,{init:function(){var a=this;a.enabled=false;a.data_queue={};a.tile_cache.clear();a.data_cache.clear();a.initial_canvas=undefined;a.content_div.css("height","auto");a.container_div.removeClass("nodata error pending");if(!a.dataset_id){return}if(a.view.chrom!=null){$.getJSON(this.dataset_check_url,{hda_ldda:a.hda_ldda,dataset_id:a.dataset_id,chrom:a.view.chrom,low:a.view.max_low,high:a.view.max_high},function(b){if(!b||b==="error"||b.kind==="error"){a.container_div.addClass("error");a.content_div.text(DATA_ERROR);if(b.message){var d=a.view.tracks.indexOf(a);var c=$(" <a href='javascript:void(0);'></a>").attr("id",d+"_error");c.text("View error");$("#"+d+"_error").live("click",function(){show_modal("Trackster Error","<pre>"+b.message+"</pre>",{Close:hide_modal})});a.content_div.append(c)}}else{if(b==="no converter"){a.container_div.addClass("error");a.content_div.text(DATA_NOCONVERTER)}else{if(b==="no data"||(b.data!==undefined&&(b.data===null||b.data.length===0))){a.container_div.addClass("nodata");a.content_div.text(DATA_NONE)}else{if(b==="pending"){a.container_div.addClass("pending");a.content_div.text(DATA_PENDING);setTimeout(function(){a.init()},a.data_query_wait)}else{if(b==="data"){a.content_div.text(DATA_OK);if(a.view.chrom){a.content_div.text("");a.content_div.css("height",a.height_px+"px");a.enabled=true;a.predraw_init();a.draw()}}}}}}})}},predraw_init:function(){},restore_prefs:function(a){var b=this;$.each(a,function(c,d){if(d!==undefined){b.prefs[c]=d}})},update_name:function(a){this.old_name=this.name;this.name=a;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var TiledTrack=function(g,d,s){var o=this,j=o.view;this.filters=(g!==undefined?get_filters_from_dict(g):[]);this.tool=(d!==undefined?get_tool_from_dict(d):undefined);this.parent_track=s;this.child_tracks=[];if(o.hidden){return}if(this.parent_track){this.header_div.find(".draghandle").removeClass("draghandle").addClass("child-track-icon").addClass("icon-button");this.parent_element.addClass("child-track");this.tool=undefined}this.filtering_div=$("<div/>").addClass("track-filters").hide();this.header_div.after(this.filtering_div);this.filtering_div.bind("drag",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var t=$("<table class='filters'>").appendTo(this.filtering_div);$.each(this.filters,function(w,z){var v=$("<tr>").appendTo(t);var y=$("<th class='filter-info'>").appendTo(v);var u=$("<span class='name'>").appendTo(y);u.text(z.name+" ");var i=$("<span class='values'>").appendTo(y);var x=$("<td>").appendTo(v);z.control_element=$("<div id='"+z.name+"-filter-control' style='width: 200px; position: relative'>").appendTo(x);z.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(B,C){var A=C.values;i.text("["+A[0]+"-"+A[1]+"]");z.low=A[0];z.high=A[1];o.draw(true)},change:function(A,B){z.control_element.slider("option","slide").call(z.control_element,A,B)}});z.slider=z.control_element;z.slider_label=i});if(this.tool){this.dynamic_tool_div=$("<div/>").addClass("dynamic-tool").hide();this.header_div.after(this.dynamic_tool_div);this.dynamic_tool_div.bind("drag",function(i){i.stopPropagation()}).bind("click",function(i){i.stopPropagation()}).bind("dblclick",function(i){i.stopPropagation()});var l=$("<div class='tool-name'>").appendTo(this.dynamic_tool_div).text(this.tool.name);var e=this.tool.params;var o=this;$.each(this.tool.params,function(A,v){var y=$("<div>").addClass("param-row").appendTo(o.dynamic_tool_div);var x=$("<div>").addClass("slider-label").appendTo(y);var C=$("<span class='param-name'>").text(v.label+" ").appendTo(x);var w=$("<span/>").text(v.value);var z=$("<span class='param-value'>").appendTo(x).append("[").append(w).append("]");var B=$("<div/>").addClass("slider").appendTo(y);var i=$("<div id='"+v.name+"-param-control'>").appendTo(B);var u=(v.max<=1?0.01:(v.max<=1000?1:5));i.slider({min:v.min,max:v.max,step:u,value:v.value,slide:function(D,F){var E=F.value;v.value=E;if(0<E&&E<1){E=parseFloat(E).toFixed(2)}w.text(E)},change:function(D,E){v.value=E.value}});z.click(function(){var F=w,E=F.text(),D=(v.max<=1?4:v.max.length);F.text("");$("<input type='text'/>").attr("size",D).attr("maxlength",D).attr("value",E).appendTo(F).focus().select().click(function(G){G.stopPropagation()}).blur(function(){$(this).remove();F.text(E)}).keyup(function(I){if(I.keyCode===27){$(this).trigger("blur")}else{if(I.keyCode===13){var G=$(this),H=parseFloat(G.val());if(isNaN(H)||H>v.max||H<v.min){alert("Parameter value must be in the range ["+v.min+"-"+v.max+"]");return $(this)}F.text(H);i.slider("value",H);v.value=H}}})});$("<div style='clear: both;'/>").appendTo(y)});var b=$("<div>").addClass("param-row").appendTo(this.dynamic_tool_div);var n=$("<input type='submit'>").attr("value","Run").appendTo(b);var o=this;n.click(function(){o.run_tool()})}o.child_tracks_container=$("<div/>").addClass("child-tracks-container").hide();o.container_div.append(o.child_tracks_container);if(o.display_modes!==undefined){if(o.mode_div===undefined){o.mode_div=$("<div class='right-float menubutton popup' />").appendTo(o.header_div);var m=o.display_modes[0];o.mode=m;o.mode_div.text(m);var a=function(i){o.mode_div.text(i);o.mode=i;o.tile_cache.clear();o.draw()};var f={};for(var q=0,r=o.display_modes.length;q<r;q++){var k=o.display_modes[q];f[k]=function(i){return function(){a(i)}}(k)}make_popupmenu(o.mode_div,f)}else{o.mode_div.hide()}}var h={};h["Edit configuration"]=function(){var v=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},i=function(){o.update_options(o.track_id);hide_modal();$(window).unbind("keypress.check_enter_esc")},u=function(w){if((w.keyCode||w.which)===27){v()}else{if((w.keyCode||w.which)===13){i()}}};$(window).bind("keypress.check_enter_esc",u);show_modal("Configure Track",o.gen_options(o.track_id),{Cancel:v,OK:i})};h["Set as overview"]=function(){j.overview_viewport.find("canvas").remove();o.is_overview=true;o.set_overview();for(var i in j.tracks){if(j.tracks[i]!==o){j.tracks[i].is_overview=false}}};if(o.filters.length>0){h["Show filters"]=function(){var i;if(!o.filtering_div.is(":visible")){i="Hide filters";o.filters_visible=true}else{i="Show filters";o.filters_visible=false}o.filtering_div.toggle()}}if(o.tool){h["Toggle Tool"]=function(){var i;if(!o.dynamic_tool_div.is(":visible")){i="Hide dynamic tool";o.update_name(o.name+o.tool_region_and_parameters_str())}else{i="Show dynamic tool";o.revert_name()}o.dynamic_tool_div.toggle()}}var c=j;var p=function(){$("#no-tracks").show()};if(this.parent_track){c=this.parent_track;p=function(){}}h.Remove=function(){c.remove_track(o);if(c.num_tracks===0){p()}};o.popup_menu=make_popupmenu(o.name_div,h)};$.extend(TiledTrack.prototype,Track.prototype,{draw:function(a){var l=this.view.low,f=this.view.high,h=f-l,e=this.view.resolution;var o=$("<div style='position: relative;'></div>"),q=this.content_div.width()/h;this.content_div.append(o);this.max_height=0;var b=Math.floor(l/e/DENSITY);var k=0;while((b*DENSITY*e)<f){var m=this.content_div.width()+"_"+q+"_"+b;var d=this.tile_cache.get(m);var j=b*DENSITY*this.view.resolution;var p=j+DENSITY*this.view.resolution;if(!a&&d){this.show_tile(d,o,j)}else{this.delayed_draw(a,m,j,p,b,e,o,q,k)}b+=1}var c=this;var n=setInterval(function(){if(k===0){var t=c.content_div.children();var s=false;for(var u=t.length-1,r=0;u>=r;u--){var w=$(t[u]);if(s){w.remove()}else{if(w.children().length!==0){s=true}}}for(var v=0;v<c.filters.length;v++){c.filters[v].update_ui_elt()}clearInterval(n)}},50);for(var g=0;g<this.child_tracks.length;g++){this.child_tracks[g].draw(a)}},delayed_draw:function(b,h,g,j,c,e,i,k,f){var d=this;var a=setTimeout(function(){if(g<=d.view.high&&j>=d.view.low){var l;if(!b){l=d.tile_cache.get(h)}if(!l){l=d.draw_tile(e,c,i,k)}if(l){if(!d.initial_canvas&&!window.G_vmlCanvasManager){d.initial_canvas=$(l).clone();var o=l.get(0).getContext("2d");var m=d.initial_canvas.get(0).getContext("2d");var n=o.getImageData(0,0,o.canvas.width,o.canvas.height);m.putImageData(n,0,0);d.set_overview()}d.tile_cache.set(h,l);d.show_tile(l,i,g)}}delete f--},50);f++},show_tile:function(a,f,d){var b=this;var c=this.view.high-this.view.low,g=this.content_div.width()/c,e=(d-this.view.low)*g;if(this.left_offset){e-=this.left_offset}a.css({position:"absolute",top:0,left:e});f.append(a);b.max_height=Math.max(b.max_height,a.height());b.content_div.css("height",b.max_height+"px");if(b.hidden){return}if(a.hasClass(FILTERABLE_CLASS)){show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters");if(b.filters_visible){b.filtering_div.show()}}else{show_hide_popupmenu_options(b.popup_menu,"(Show|Hide) filters",false);b.filtering_div.hide()}},set_overview:function(){var a=this.view;if(this.initial_canvas&&this.is_overview){a.overview_close.show();a.overview_viewport.append(this.initial_canvas);a.overview_highlight.show().height(this.initial_canvas.height());a.overview_viewport.height(this.initial_canvas.height()+a.overview_box.height())}$(window).trigger("resize")},run_tool:function(){var b={dataset_id:this.original_dataset_id,chrom:this.view.chrom,low:this.view.low,high:this.view.high,tool_id:this.tool.name};$.extend(b,this.tool.get_param_values_dict());var d=this,c=b.tool_id+d.tool_region_and_parameters_str(b.chrom,b.low,b.high),e;if(d.track_type=="FeatureTrack"){e=new ToolDataFeatureTrack(c,view,undefined,{},{},d)}this.add_track(e);e.content_div.text("Starting job.");view.has_changes=true;var a=function(){$.getJSON(run_tool_url,b,function(f){if(f=="no converter"){e.container_div.addClass("error");e.content_div.text(DATA_NOCONVERTER)}else{if(f.error){e.container_div.addClass("error");e.content_div.text(DATA_CANNOT_RUN_TOOL+f.message)}else{if(f=="pending"){e.container_div.addClass("pending");e.content_div.text("Converting input data so that it can be easily reused.");setTimeout(a,2000)}else{e.dataset_id=f.dataset_id;e.content_div.text("Running job.");e.init()}}}})};a()},tool_region_and_parameters_str:function(c,a,d){var b=this,e=(c!==undefined&&a!==undefined&&d!==undefined?c+":"+a+"-"+d:"all");return" - region=["+e+"], parameters=["+b.tool.get_param_values().join(", ")+"]"},add_track:function(a){a.track_id=this.track_id+"_"+this.child_tracks.length;a.container_div.attr("id","track_"+a.track_id);this.child_tracks_container.append(a.container_div);sortable(a.container_div,".child-track-icon");if(!$(this.child_tracks_container).is(":visible")){this.child_tracks_container.show()}this.child_tracks.push(a)},remove_track:function(a){a.container_div.fadeOut("slow",function(){$(this).remove()})}});var LabelTrack=function(a,b){this.track_type="LabelTrack";this.hidden=true;Track.call(this,null,a,b);this.container_div.addClass("label-track")};$.extend(LabelTrack.prototype,Track.prototype,{draw:function(){var c=this.view,d=c.high-c.low,g=Math.floor(Math.pow(10,Math.floor(Math.log(d)/Math.log(10)))),a=Math.floor(c.low/g)*g,e=this.content_div.width(),b=$("<div style='position: relative; height: 1.3em;'></div>");while(a<c.high){var f=(a-c.low)/d*e;b.append($("<div class='label'>"+commatize(a)+"</div>").css({position:"absolute",left:f-1}));a+=g}this.content_div.children(":first").remove();this.content_div.append(b)}});var ReferenceTrack=function(a){this.track_type="ReferenceTrack";this.hidden=true;Track.call(this,null,a,a.top_labeltrack);TiledTrack.call(this);this.left_offset=200;this.height_px=12;this.container_div.addClass("reference-track");this.data_queue={};this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE)};$.extend(ReferenceTrack.prototype,TiledTrack.prototype,{get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:reference_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,dbkey:this.view.dbkey},success:function(g){c.data_cache.set(e,g);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(f,b,k,o){var g=b*DENSITY*f,d=DENSITY*f,j=f+"_"+b;var e=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(e)}e=$(e);var n=e.get(0).getContext("2d");if(o>PX_PER_CHAR){if(this.data_cache.get(j)===undefined){this.get_data(f,b);return}var m=this.data_cache.get(j);if(m===null){this.content_div.css("height","0px");return}e.get(0).width=Math.ceil(d*o+this.left_offset);e.get(0).height=this.height_px;for(var h=0,l=m.length;h<l;h++){var a=Math.round(h*o),i=Math.round(o/2);n.fillText(m[h],a+this.left_offset+i,10)}k.append(e);return e}this.content_div.css("height","0px")}});var LineTrack=function(d,b,e,a,c){this.track_type="LineTrack";this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";Track.call(this,d,b,b.viewport_container);TiledTrack.call(this);this.min_height_px=12;this.max_height_px=400;this.height_px=80;this.hda_ldda=e;this.dataset_id=a;this.original_dataset_id=a;this.data_cache=new DataCache(CACHED_DATA);this.tile_cache=new Cache(CACHED_TILES_LINE);this.prefs={color:"black",min_value:undefined,max_value:undefined,mode:this.mode};this.restore_prefs(c);(function(f){var i=false;var h=false;var g=$("<div class='track-resize'>");$(f.container_div).hover(function(){i=true;g.show()},function(){i=false;if(!h){g.hide()}});g.hide().bind("dragstart",function(j,k){h=true;k.original_height=$(f.content_div).height()}).bind("drag",function(k,l){var j=Math.min(Math.max(l.original_height+l.deltaY,f.min_height_px),f.max_height_px);$(f.content_div).css("height",j);f.height_px=j;f.draw(true)}).bind("dragend",function(j,k){f.tile_cache.clear();h=false;if(!i){g.hide()}}).appendTo(f.container_div)})(this)};$.extend(LineTrack.prototype,TiledTrack.prototype,{predraw_init:function(){var a=this,b=a.view.tracks.indexOf(a);a.vertical_range=undefined;$.getJSON(a.data_url,{stats:true,chrom:a.view.chrom,low:null,high:null,hda_ldda:a.hda_ldda,dataset_id:a.dataset_id},function(c){a.container_div.addClass("line-track");var e=c.data;if(isNaN(parseFloat(a.prefs.min_value))||isNaN(parseFloat(a.prefs.max_value))){a.prefs.min_value=e.min;a.prefs.max_value=e.max;$("#track_"+b+"_minval").val(a.prefs.min_value);$("#track_"+b+"_maxval").val(a.prefs.max_value)}a.vertical_range=a.prefs.max_value-a.prefs.min_value;a.total_frequency=e.total_frequency;a.container_div.find(".yaxislabel").remove();var f=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_minval").text(round_1000(a.prefs.min_value));var d=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+b+"_maxval").text(round_1000(a.prefs.max_value));d.css({position:"absolute",top:"24px",left:"10px"});d.prependTo(a.container_div);f.css({position:"absolute",bottom:"2px",left:"10px"});f.prependTo(a.container_div)})},get_data:function(d,b){var c=this,a=b*DENSITY*d,f=(b+1)*DENSITY*d,e=d+"_"+b;if(!c.data_queue[e]){c.data_queue[e]=true;$.ajax({url:this.data_url,dataType:"json",data:{chrom:this.view.chrom,low:a,high:f,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,resolution:this.view.resolution},success:function(g){var h=g.data;c.data_cache.set(e,h);delete c.data_queue[e];c.draw()},error:function(h,g,i){console.log(h,g,i)}})}},draw_tile:function(o,r,c,e){if(this.vertical_range===undefined){return}var s=r*DENSITY*o,a=DENSITY*o,x=o+"_"+r;var b=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(b)}b=$(b);if(this.data_cache.get(x)===undefined){this.get_data(o,r);return}var v=this.data_cache.get(x);if(!v){return}b.get(0).width=Math.ceil(a*e);b.get(0).height=this.height_px;var n=b.get(0).getContext("2d"),j=false,k=this.prefs.min_value,g=this.prefs.max_value,m=this.vertical_range,t=this.total_frequency,d=this.height_px,l=this.mode;var w=Math.round(d+k/m*d);n.beginPath();n.moveTo(0,w);n.lineTo(a*e,w);n.fillStyle="#aaa";n.stroke();n.beginPath();n.fillStyle=this.prefs.color;var u,h,f;if(v.length>1){f=Math.ceil((v[1][0]-v[0][0])*e)}else{f=10}for(var p=0,q=v.length;p<q;p++){u=Math.round((v[p][0]-s)*e);h=v[p][1];if(h===null){if(j&&l==="Filled"){n.lineTo(u,d)}j=false;continue}if(h<k){h=k}else{if(h>g){h=g}}if(l==="Histogram"){h=Math.round(h/m*d);n.fillRect(u,w,f,-h)}else{if(l==="Intensity"){h=255-Math.floor((h-k)/m*255);n.fillStyle="rgb("+h+","+h+","+h+")";n.fillRect(u,0,f,d)}else{h=Math.round(d-(h-k)/m*d);if(j){n.lineTo(u,h)}else{j=true;if(l==="Filled"){n.moveTo(u,d);n.lineTo(u,h)}else{n.moveTo(u,h)}}}}}if(l==="Filled"){if(j){n.lineTo(u,w);n.lineTo(0,w)}n.fill()}else{n.stroke()}return b},gen_options:function(m){var a=$("<div />").addClass("form-row");var e="track_"+m+"_color",b=$("<label />").attr("for",e).text("Color:"),c=$("<input />").attr("id",e).attr("name",e).val(this.prefs.color),h="track_"+m+"_minval",l=$("<label></label>").attr("for",h).text("Min value:"),d=(this.prefs.min_value===undefined?"":this.prefs.min_value),k=$("<input></input>").attr("id",h).val(d),j="track_"+m+"_maxval",g=$("<label></label>").attr("for",j).text("Max value:"),i=(this.prefs.max_value===undefined?"":this.prefs.max_value),f=$("<input></input>").attr("id",j).val(i);return a.append(l).append(k).append(g).append(f).append(b).append(c)},update_options:function(d){var a=$("#track_"+d+"_minval").val(),c=$("#track_"+d+"_maxval").val(),b=$("#track_"+d+"_color").val();if(a!==this.prefs.min_value||c!==this.prefs.max_value||b!==this.prefs.color){this.prefs.min_value=parseFloat(a);this.prefs.max_value=parseFloat(c);this.prefs.color=b;this.vertical_range=this.prefs.max_value-this.prefs.min_value;$("#linetrack_"+d+"_minval").text(this.prefs.min_value);$("#linetrack_"+d+"_maxval").text(this.prefs.max_value);this.tile_cache.clear();this.draw()}}});var FeatureTrack=function(f,c,h,a,e,g,d,b){this.track_type="FeatureTrack";this.display_modes=["Auto","Dense","Squish","Pack"];Track.call(this,f,c,c.viewport_container);TiledTrack.call(this,g,d,b);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=h;this.dataset_id=a;this.original_dataset_id=a;this.zo_slots={};this.show_labels_scale=0.001;this.showing_details=false;this.vertical_detail_px=10;this.vertical_nodetail_px=3;this.summary_draw_height=30;this.default_font="9px Monaco, Lucida Console, monospace";this.inc_slots={};this.data_queue={};this.s_e_by_tile={};this.tile_cache=new Cache(CACHED_TILES_FEATURE);this.data_cache=new DataCache(20);this.left_offset=200;this.prefs={block_color:"#444",label_color:"black",show_counts:true};this.restore_prefs(e)};$.extend(FeatureTrack.prototype,TiledTrack.prototype,{get_data:function(a,d){var b=this,c=a+"_"+d;if(!b.data_queue[c]){b.data_queue[c]=true;$.getJSON(b.data_url,{chrom:b.view.chrom,low:a,high:d,hda_ldda:b.hda_ldda,dataset_id:b.dataset_id,resolution:this.view.resolution,mode:this.mode},function(e){b.data_cache.set_data(a,d,b.mode,e);delete b.data_queue[c];b.draw()})}},incremental_slots:function(a,h,b,p){var r=this.inc_slots[a];if(!r||(r.mode!==p)){r={};r.w_scale=a;r.mode=p;this.inc_slots[a]=r;this.s_e_by_tile[a]={}}var l=r.w_scale,x=[],y=[],j=0,n=this.view.max_low;for(var v=0,w=h.length;v<w;v++){var g=h[v],k=g[0];if(r[k]!==undefined){j=Math.max(j,r[k]);y.push(r[k])}else{x.push(v)}}var q=this.s_e_by_tile[a];var m=function(D,E){var C;for(var B=0,F;B<=MAX_FEATURE_DEPTH;B++){C=true;F=q[B];if(F!==undefined){for(var z=0,A=F.length;z<A;z++){var i=F[z];if(E>i[0]&&D<i[1]){C=false;break}}}if(C){break}}if(C){return B}else{return -1}};for(var v=0,w=x.length;v<w;v++){var g=h[x[v]],k=g[0],t=g[1],c=g[2],o=g[3],d=Math.floor((t-n)*l),f=Math.ceil((c-n)*l),u=CONTEXT.measureText(o).width,e;if(o!==undefined&&!b){if(d-u<0){f+=u;e="left"}else{d-=u;e="right"}}var s=m(d,f);if(s<0){}if(s>=0){slot=q[s];if(slot===undefined){slot=q[s]=[]}slot.push([d,f]);r[k]=s;j=Math.max(j,s)}else{}}return j},rect_or_text:function(r,l,u,b,q,j,g,f){r.textAlign="center";var d=0,s=0,p=Math.round(l/2);for(var m=0,t=j.length;m<t;m++){var k=j[m],e="MIDNSHP=X"[k[0]],n=k[1];if(e==="H"||e==="S"){d-=n}var h=q+d,x=Math.floor(Math.max(0,(h-u)*l)),i=Math.floor(Math.max(0,(h+n-u)*l));switch(e){case"H":break;case"S":case"M":case"=":var o=g.slice(s,s+n);if((this.mode==="Pack"||this.mode==="Auto")&&g!==undefined&&l>PX_PER_CHAR){r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+1,i-x,9);r.fillStyle=CONNECTOR_COLOR;for(var v=0,a=o.length;v<a;v++){if(h+v>=u&&h+v<=b){var w=Math.floor(Math.max(0,(h+v-u)*l));r.fillText(o[v],w+this.left_offset+p,f+9)}}}else{r.fillStyle=this.prefs.block_color;r.fillRect(x+this.left_offset,f+(this.mode!="Dense"?4:5),i-x,(this.mode!="Dense"?3:1))}s+=n;break;case"N":r.fillStyle=CONNECTOR_COLOR;r.fillRect(x+this.left_offset,f+5,i-x,1);break;case"D":r.fillStyle="red";r.fillRect(x+this.left_offset,f+4,i-x,3);break;case"P":break;case"I":s+=n;break;case"X":s+=n;break}d+=n}},draw_tile:function(ad,n,r,ar){var L=n*DENSITY*ad,ai=(n+1)*DENSITY*ad,K=ai-L;var G=this.data_cache.get_data(L,ai,this.mode);if(G===undefined||G==="pending"||(this.mode!=="Auto"&&G.dataset_type==="summary_tree")){this.data_queue[[L,ai]]=true;this.get_data(L,ai);return}var a=Math.ceil(K*ar),af=this.prefs.label_color,h=this.prefs.block_color,q=this.mode,v=25,ab=(q==="Squish")||(q==="Dense")&&(q!=="Pack")||(q==="Auto"&&(G.extra_info==="no_detail")),U=this.left_offset,aq,B,at;var p=document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(p)}p=$(p);if(G.dataset_type==="summary_tree"){B=this.summary_draw_height}else{if(q==="Dense"){B=v;at=10}else{at=(ab?this.vertical_nodetail_px:this.vertical_detail_px);var w=(ar<0.0001?1/this.view.zoom_res:ar);B=this.incremental_slots(w,G.data,ab,q)*at+v;aq=this.inc_slots[w]}}p.get(0).width=a+U;p.get(0).height=B;r.parent().css("height",Math.max(this.height_px,B)+"px");var H=p.get(0).getContext("2d");H.fillStyle=h;H.font=this.default_font;H.textAlign="right";this.container_div.find(".yaxislabel").remove();if(G.dataset_type=="summary_tree"){var W=G.data,J=G.max,b=Math.ceil(G.delta*ar);var o=$("<div />").addClass("yaxislabel");o.text(J);o.css({position:"absolute",top:"22px",left:"10px"});o.prependTo(this.container_div);for(var am=0,F=W.length;am<F;am++){var Y=Math.floor((W[am][0]-L)*ar);var X=W[am][1];if(!X){continue}var aj=X/J*this.summary_draw_height;H.fillStyle="black";H.fillRect(Y+U,this.summary_draw_height-aj,b,aj);if(this.prefs.show_counts&&H.measureText(X).width<b){H.fillStyle="#bbb";H.textAlign="center";H.fillText(X,Y+U+(b/2),this.summary_draw_height-5)}}return p}if(G.message){p.css({border:"solid red","border-width":"2px 2px 2px 0px"});H.fillStyle="red";H.textAlign="left";H.fillText(G.message,100+U,at);return p}for(var ao=0;ao<this.filters.length;ao++){if(this.filters[ao].applies_to(G.data[0])){p.addClass(FILTERABLE_CLASS);break}}var ap=G.data;var al=0;for(var am=0,F=ap.length;am<F;am++){var Q=ap[am],P=Q[0],an=Q[1],aa=Q[2],M=Q[3];if(this.mode!="Dense"&&aq[P]===undefined){continue}var Z=false;var S;for(var ao=0;ao<this.filters.length;ao++){S=this.filters[ao];S.update_attrs(Q);if(!S.keep(Q)){Z=true;break}}if(Z){continue}if(an<=ai&&aa>=L){var ac=Math.floor(Math.max(0,(an-L)*ar)),I=Math.ceil(Math.min(a,Math.max(0,(aa-L)*ar))),V=(q==="Dense"?1:(1+aq[P]))*at;var E,ag,N=null,au=null;if(G.dataset_type==="bai"){H.fillStyle=h;if(Q[5] instanceof Array){var C=Math.floor(Math.max(0,(Q[4][0]-L)*ar)),O=Math.ceil(Math.min(a,Math.max(0,(Q[4][1]-L)*ar))),A=Math.floor(Math.max(0,(Q[5][0]-L)*ar)),u=Math.ceil(Math.min(a,Math.max(0,(Q[5][1]-L)*ar)));if(Q[4][1]>=L&&Q[4][0]<=ai&&Q[4][2]){this.rect_or_text(H,ar,L,ai,Q[4][0],Q[4][2],Q[4][3],V)}if(Q[5][1]>=L&&Q[5][0]<=ai&&Q[5][2]){this.rect_or_text(H,ar,L,ai,Q[5][0],Q[5][2],Q[5][3],V)}if(A>O){H.fillStyle=CONNECTOR_COLOR;H.dashedLine(O+U,V+5,U+A,V+5)}}else{H.fillStyle=h;this.rect_or_text(H,ar,L,ai,an,Q[4],Q[5],V)}if(q!=="Dense"&&!ab&&an>L){H.fillStyle=this.prefs.label_color;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}}else{if(G.dataset_type==="interval_index"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var D=Q[5],T=Q[6],ae=Q[7],g=Q[8];if(T&&ae){N=Math.floor(Math.max(0,(T-L)*ar));au=Math.ceil(Math.min(a,Math.max(0,(ae-L)*ar)))}if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}if(g){if(D){if(D=="+"){H.fillStyle=RIGHT_STRAND}else{if(D=="-"){H.fillStyle=LEFT_STRAND}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}for(var ak=0,e=g.length;ak<e;ak++){var t=g[ak],d=Math.floor(Math.max(0,(t[0]-L)*ar)),R=Math.ceil(Math.min(a,Math.max((t[1]-L)*ar)));if(d>R){continue}E=5;ag=3;H.fillRect(d+U,V+ag,R-d,E);if(N!==undefined&&!(d>au||R<N)){E=9;ag=1;var ah=Math.max(d,N),z=Math.min(R,au);H.fillRect(ah+U,V+ag,z-ah,E)}}}else{E=9;ag=1;H.fillRect(ac+U,V+ag,I-ac,E);if(Q.strand){if(Q.strand=="+"){H.fillStyle=RIGHT_STRAND_INV}else{if(Q.strand=="-"){H.fillStyle=LEFT_STRAND_INV}}H.fillRect(ac+U,V,I-ac,10);H.fillStyle=h}}}}else{if(G.dataset_type==="vcf"){if(ab){H.fillStyle=h;H.fillRect(ac+U,V+5,I-ac,1)}else{var s=Q[4],m=Q[5],c=Q[6];E=9;ag=1;H.fillRect(ac+U,V,I-ac,E);if(q!=="Dense"&&M!==undefined&&an>L){H.fillStyle=af;if(n===0&&ac-H.measureText(M).width<0){H.textAlign="left";H.fillText(M,I+2+U,V+8)}else{H.textAlign="right";H.fillText(M,ac-2+U,V+8)}H.fillStyle=h}var l=s+" / "+m;if(an>L&&H.measureText(l).width<(I-ac)){H.fillStyle="white";H.textAlign="center";H.fillText(l,U+ac+(I-ac)/2,V+8);H.fillStyle=h}}}}}al++}}return p},gen_options:function(i){var a=$("<div />").addClass("form-row");var e="track_"+i+"_block_color",k=$("<label />").attr("for",e).text("Block color:"),l=$("<input />").attr("id",e).attr("name",e).val(this.prefs.block_color),j="track_"+i+"_label_color",g=$("<label />").attr("for",j).text("Text color:"),h=$("<input />").attr("id",j).attr("name",j).val(this.prefs.label_color),f="track_"+i+"_show_count",c=$("<label />").attr("for",f).text("Show summary counts"),b=$('<input type="checkbox" style="float:left;"></input>').attr("id",f).attr("name",f).attr("checked",this.prefs.show_counts),d=$("<div />").append(b).append(c);return a.append(k).append(l).append(g).append(h).append(d)},update_options:function(d){var b=$("#track_"+d+"_block_color").val(),c=$("#track_"+d+"_label_color").val(),a=$("#track_"+d+"_show_count").attr("checked");if(b!==this.prefs.block_color||c!==this.prefs.label_color||a!==this.prefs.show_counts){this.prefs.block_color=b;this.prefs.label_color=c;this.prefs.show_counts=a;this.tile_cache.clear();this.draw()}}});var ReadTrack=function(d,b,f,a,c,e){FeatureTrack.call(this,d,b,f,a,c,e);this.track_type="ReadTrack";this.vertical_detail_px=10;this.vertical_nodetail_px=5};$.extend(ReadTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{});var ToolDataFeatureTrack=function(e,c,g,a,d,f,b){FeatureTrack.call(this,e,c,g,a,d,f,{},b);this.track_type="ToolDataFeatureTrack";this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};$.extend(ToolDataFeatureTrack.prototype,TiledTrack.prototype,FeatureTrack.prototype,{predraw_init:function(){var b=this;var a=function(){if(b.data_cache.size()==0){setTimeout(a,300)}else{b.data_url=default_data_url;b.data_query_wait=DEFAULT_DATA_QUERY_WAIT;b.dataset_state_url=converted_datasets_state_url;$.getJSON(b.dataset_state_url,{dataset_id:b.dataset_id},function(c){})}};a()}});
\ No newline at end of file
--- a/static/scripts/trackster.js Thu Feb 03 17:13:49 2011 -0500
+++ b/static/scripts/trackster.js Fri Feb 04 11:33:30 2011 -0500
@@ -59,6 +59,8 @@
FEATURE_LEVELS = 10,
MAX_FEATURE_DEPTH = 100,
DEFAULT_DATA_QUERY_WAIT = 5000,
+ // Maximum number of chromosomes that are selectable at any one time.
+ MAX_CHROMS_SELECTABLE = 100,
CONNECTOR_COLOR = "#ccc",
DATA_ERROR = "There was an error in indexing this dataset. ",
DATA_NOCONVERTER = "A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",
@@ -301,34 +303,13 @@
this.zo_link = $("<a id='zoom-out' />").click(function() { view.zoom_out(); view.redraw(); }).appendTo(this.chrom_form);
this.zi_link = $("<a id='zoom-in' />").click(function() { view.zoom_in(); view.redraw(); }).appendTo(this.chrom_form);
- $.ajax({
- url: chrom_url,
- data: (this.vis_id !== undefined ? { vis_id: this.vis_id } : { dbkey: this.dbkey }),
- dataType: "json",
- success: function ( result ) {
- if (result.reference) {
- view.add_label_track( new ReferenceTrack(view) );
- }
- view.chrom_data = result.chrom_info;
- var chrom_options = '<option value="">Select Chrom/Contig</option>';
- for (var i = 0, len = view.chrom_data.length; i < len; i++) {
- var chrom = view.chrom_data[i].chrom;
- chrom_options += '<option value="' + chrom + '">' + chrom + '</option>';
- }
- view.chrom_select.html(chrom_options);
- view.intro_div.show();
- view.chrom_select.bind("change", function() {
- view.change_chrom(view.chrom_select.val());
- });
- if ( callback ) {
- callback();
- }
- },
- error: function() {
- alert( "Could not load chroms for this dbkey:", view.dbkey );
- }
+ // Get initial set of chroms.
+ this.load_chroms({low: 0}, callback);
+ this.chrom_select.bind("change", function() {
+ view.change_chrom(view.chrom_select.val());
});
-
+ this.intro_div.show();
+
/*
this.content_div.bind("mousewheel", function( e, delta ) {
if (Math.abs(delta) < 0.5) {
@@ -446,42 +427,98 @@
this.location_span.text( commatize(low) + ' - ' + commatize(high) );
this.nav_input.val( this.chrom + ':' + commatize(low) + '-' + commatize(high) );
},
+ load_chroms: function(url_parms, callback) {
+ url_parms['num'] = MAX_CHROMS_SELECTABLE;
+ $.extend( url_parms, (this.vis_id !== undefined ? { vis_id: this.vis_id } : { dbkey: this.dbkey } ) );
+ var view = this;
+ $.ajax({
+ url: chrom_url,
+ data: url_parms,
+ dataType: "json",
+ success: function ( result ) {
+ if (result.reference) {
+ view.add_label_track( new ReferenceTrack(view) );
+ }
+ view.chrom_data = result.chrom_info;
+ var chrom_options = '<option value="">Select Chrom/Contig</option>';
+ for (var i = 0, len = view.chrom_data.length; i < len; i++) {
+ var chrom = view.chrom_data[i].chrom;
+ chrom_options += '<option value="' + chrom + '">' + chrom + '</option>';
+ }
+ if (result.prev_chroms) {
+ chrom_options += '<option value="previous">Previous ' + MAX_CHROMS_SELECTABLE + '</option>';
+ }
+ if (result.next_chroms) {
+ chrom_options += '<option value="next">Next ' + MAX_CHROMS_SELECTABLE + '</option>';
+ }
+ view.chrom_select.html(chrom_options);
+ if ( callback ) {
+ callback();
+ }
+ view.chrom_start_index = result.start_index;
+ },
+ error: function() {
+ alert( "Could not load chroms for this dbkey:", view.dbkey );
+ }
+ });
+
+ },
change_chrom: function(chrom, low, high) {
var view = this;
+
+ //
+ // If user is navigating to previous/next set of chroms, load new chrom set and return.
+ //
+ if (chrom == "previous") {
+ view.load_chroms({low: this.chrom_start_index - MAX_CHROMS_SELECTABLE});
+ return;
+ }
+ if (chrom == "next") {
+ view.load_chroms({low: this.chrom_start_index + MAX_CHROMS_SELECTABLE});
+ return;
+ }
+
+ //
+ // User is loading a particular chrom. Look first in current set; if not in current set, load new
+ // chrom set.
+ //
var found = $.grep(view.chrom_data, function(v, i) {
return v.chrom === chrom;
})[0];
if (found === undefined) {
- // Invalid chrom
+ // Try to load chrom and then change to chrom.
+ view.load_chroms({'chrom': chrom}, function() { view.change_chrom(chrom, low, high); });
return;
}
- if (chrom !== view.chrom) {
- view.chrom = chrom;
- if (!view.chrom) {
- // No chrom selected
- view.intro_div.show();
- } else {
- view.intro_div.hide();
- }
- view.chrom_select.val(view.chrom);
- view.max_high = found.len;
- view.reset();
- view.redraw(true);
-
- for (var track_id = 0, len = view.tracks.length; track_id < len; track_id++) {
- var track = view.tracks[track_id];
- if (track.init) {
- track.init();
+ else {
+ // Switching to local chrom.
+ if (chrom !== view.chrom) {
+ view.chrom = chrom;
+ if (!view.chrom) {
+ // No chrom selected
+ view.intro_div.show();
+ } else {
+ view.intro_div.hide();
+ }
+ view.chrom_select.val(view.chrom);
+ view.max_high = found.len;
+ view.reset();
+ view.redraw(true);
+
+ for (var track_id = 0, len = view.tracks.length; track_id < len; track_id++) {
+ var track = view.tracks[track_id];
+ if (track.init) {
+ track.init();
+ }
}
}
+ if (low !== undefined && high !== undefined) {
+ view.low = Math.max(low, 0);
+ view.high = Math.min(high, view.max_high);
+ }
+ view.reset_overview();
+ view.redraw();
}
- if (low !== undefined && high !== undefined) {
- view.low = Math.max(low, 0);
- view.high = Math.min(high, view.max_high);
- }
- view.reset_overview();
- view.redraw();
-
},
go_to: function(str) {
var view = this,
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.
1
0