galaxy-commits
Threads by month
- ----- 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
September 2011
- 1 participants
- 91 discussions
commit/galaxy-central: jgoecks: Trackster: rename TrackConfig to DrawableConfig and provide every Drawable object with a config.
by Bitbucket 26 Sep '11
by Bitbucket 26 Sep '11
26 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/f4d8554b0715/
changeset: f4d8554b0715
user: jgoecks
date: 2011-09-26 16:23:15
summary: Trackster: rename TrackConfig to DrawableConfig and provide every Drawable object with a config.
affected #: 1 file (-1 bytes)
--- a/static/scripts/trackster.js Sun Sep 25 13:27:14 2011 -0400
+++ b/static/scripts/trackster.js Mon Sep 26 10:23:15 2011 -0400
@@ -581,6 +581,9 @@
this.parent_element = parent_element;
this.drag_handle_class = drag_handle_class;
this.container = container;
+ this.config = new DrawableConfig({
+ track: this
+ });
};
Drawable.prototype.init = function() {};
@@ -1882,9 +1885,9 @@
};
/**
- * Container for track configuration data.
+ * Container for Drawable configuration data.
*/
-var TrackConfig = function( options ) {
+var DrawableConfig = function( options ) {
this.track = options.track;
this.params = options.params;
this.values = {}
@@ -1894,7 +1897,7 @@
this.onchange = options.onchange
};
-extend(TrackConfig.prototype, {
+extend(DrawableConfig.prototype, {
restore_values: function( values ) {
var track_config = this;
$.each( this.params, function( index, param ) {
@@ -2199,8 +2202,8 @@
if (track.display_modes !== undefined) {
if (track.mode_div === undefined) {
track.mode_div = $("<div class='right-float menubutton popup' />").appendTo(track.header_div);
- var init_mode = (track.track_config && track.track_config.values['mode'] ?
- track.track_config.values['mode'] : track.display_modes[0]);
+ var init_mode = (track.config && track.config.values['mode'] ?
+ track.config.values['mode'] : track.display_modes[0]);
track.mode = init_mode;
track.mode_div.text(init_mode);
@@ -2240,7 +2243,7 @@
track.mode_div.text(name);
// TODO: is it necessary to store the mode in two places (.mode and track_config)?
track.mode = name;
- track.track_config.values['mode'] = name;
+ track.config.values['mode'] = name;
track.tile_cache.clear();
track.request_draw();
},
@@ -2270,7 +2273,7 @@
track_dropdown["Edit configuration"] = function() {
var cancel_fn = function() { hide_modal(); $(window).unbind("keypress.check_enter_esc"); },
ok_fn = function() {
- track.track_config.update_from_form( $(".dialog-box") );
+ track.config.update_from_form( $(".dialog-box") );
hide_modal();
$(window).unbind("keypress.check_enter_esc");
},
@@ -2283,7 +2286,7 @@
};
$(window).bind("keypress.check_enter_esc", check_enter_esc);
- show_modal("Configure Track", track.track_config.build_form(), {
+ show_modal("Configure Track", track.config.build_form(), {
"Cancel": cancel_fn,
"OK": ok_fn
});
@@ -2329,11 +2332,13 @@
//
// List chrom/contigs with data option.
//
+ /*
if (track.valid_chroms) {
track_dropdown["List chrom/contigs with data"] = function() {
show_modal("Chrom/contigs with data", "<p>" + track.valid_chroms.join("<br/>") + "</p>", { "Close": function() { hide_modal(); } });
};
}
+ */
//
// Remove option.
@@ -2723,7 +2728,7 @@
this.left_offset = 0;
// Define track configuration
- this.track_config = new TrackConfig( {
+ this.config = new DrawableConfig( {
track: this,
params: [
{ key: 'name', label: 'Name', type: 'text', default_value: name },
@@ -2745,9 +2750,9 @@
}
});
- this.prefs = this.track_config.values;
- this.height_px = this.track_config.values.height;
- this.vertical_range = this.track_config.values.max_value - this.track_config.values.min_value;
+ this.prefs = this.config.values;
+ this.height_px = this.config.values.height;
+ this.vertical_range = this.config.values.max_value - this.config.values.min_value;
this.add_resize_handle();
};
@@ -2782,7 +2787,7 @@
track.tile_cache.clear();
in_drag = false;
if (!in_handle) { drag_control.hide(); }
- track.track_config.values.height = track.height_px;
+ track.config.values.height = track.height_px;
}).appendTo(track.container_div);
},
predraw_init: function() {
@@ -2854,7 +2859,7 @@
var track = this;
this.display_modes = ["Auto", "Histogram", "Dense", "Squish", "Pack"];
// Define and restore track configuration.
- this.track_config = new TrackConfig( {
+ this.config = new DrawableConfig( {
track: this,
params: [
{ key: 'name', label: 'Name', type: 'text', default_value: name },
@@ -2870,7 +2875,7 @@
track.request_draw();
}
});
- this.prefs = this.track_config.values;
+ this.prefs = this.config.values;
//
// Initialization.
@@ -3244,7 +3249,7 @@
var ReadTrack = function (name, view, hda_ldda, dataset_id, prefs, filters) {
FeatureTrack.call(this, name, view, hda_ldda, dataset_id, prefs, filters);
- this.track_config = new TrackConfig( {
+ this.config = new DrawableConfig( {
track: this,
params: [
{ key: 'name', label: 'Name', type: 'text', default_value: name },
@@ -3262,7 +3267,7 @@
this.track.request_draw();
}
});
- this.prefs = this.track_config.values;
+ this.prefs = this.config.values;
this.painter = painters.ReadPainter;
this.make_name_popup_menu();
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/2469c53051ea/
changeset: 2469c53051ea
user: dan
date: 2011-09-25 19:27:14
summary: Some random lines tool tweaks.
affected #: 3 files (-1 bytes)
--- a/test-data/1_bed_random_lines_1_seed_asdf_out.bed Sat Sep 24 10:45:34 2011 -0400
+++ b/test-data/1_bed_random_lines_1_seed_asdf_out.bed Sun Sep 25 13:27:14 2011 -0400
@@ -1,1 +1,1 @@
-chrX 152694029 152694263 CCDS14736.1_cds_0_0_chrX_152694030_r 0 -
+chr5 131424298 131424460 CCDS4149.1_cds_0_0_chr5_131424299_f 0 +
--- a/tools/filters/random_lines_two_pass.py Sat Sep 24 10:45:34 2011 -0400
+++ b/tools/filters/random_lines_two_pass.py Sun Sep 25 13:27:14 2011 -0400
@@ -2,9 +2,25 @@
#Dan Blankenberg
#Selects N random lines from a file and outputs to another file, maintaining original line order
#allows specifying a seed
-#does two passes to determine line counts and offsets, and then to output contents
+#does two passes to determine line offsets/count, and then to output contents
-import optparse, random
+import optparse, random
+
+def get_random_by_subtraction( line_offsets, num_lines ):
+ while len( line_offsets ) > num_lines:
+ del line_offsets[ random.randint( 0, len( line_offsets ) - 1 ) ]
+ return line_offsets
+
+def get_random_by_sample( line_offsets, num_lines ):
+ line_offsets = random.sample( line_offsets, num_lines )
+ line_offsets.sort()
+ return line_offsets
+
+def get_random( line_offsets, num_lines ):
+ if num_lines > ( len( line_offsets ) / 2 ):
+ return get_random_by_subtraction( line_offsets, num_lines )
+ else:
+ return get_random_by_sample( line_offsets, num_lines )
def __main__():
#Parse Command Line
@@ -14,7 +30,7 @@
assert len( args ) == 3, "Invalid command line specified."
- input = open( args[0] )
+ input = open( args[0], 'rb' )
output = open( args[1], 'wb' )
num_lines = int( args[2] )
assert num_lines > 0, "You must select at least one line."
@@ -24,10 +40,13 @@
#get line offsets
line_offsets = []
+ teller = input.tell
+ readliner = input.readline
+ appender = line_offsets.append
while True:
- offset = input.tell()
- if input.readline():
- line_offsets.append( offset )
+ offset = teller()
+ if readliner():
+ appender( offset )
else:
break
@@ -35,13 +54,14 @@
assert num_lines <= total_lines, "Error: asked to select more lines (%i) than there were in the file (%i)." % ( num_lines, total_lines )
#get random line offsets
- while len( line_offsets ) > num_lines:
- line_offsets.pop( random.randint( 0, len( line_offsets ) - 1 ) )
+ line_offsets = get_random( line_offsets, num_lines )
#write out random lines
+ seeker = input.seek
+ writer = output.write
for line_offset in line_offsets:
- input.seek( line_offset )
- output.write( input.readline() )
+ seeker( line_offset )
+ writer( readliner() )
input.close()
output.close()
print "Kept %i of %i total lines." % ( num_lines, total_lines )
--- a/tools/filters/randomlines.xml Sat Sep 24 10:45:34 2011 -0400
+++ b/tools/filters/randomlines.xml Sun Sep 25 13:27:14 2011 -0400
@@ -1,4 +1,4 @@
-<tool id="random_lines1" name="Select random lines" version="2.0.0">
+<tool id="random_lines1" name="Select random lines" version="2.0.1"><description>from a file</description><command interpreter="python">random_lines_two_pass.py "${input}" "${out_file1}" "${num_lines}"
#if str( $seed_source.seed_source_selector ) == "set_seed":
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: (1) save and restore track groups; (2) support nested groups; (3) make View a DrawableCollection.
by Bitbucket 24 Sep '11
by Bitbucket 24 Sep '11
24 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/61b82db00101/
changeset: 61b82db00101
user: jgoecks
date: 2011-09-24 16:45:34
summary: Trackster: (1) save and restore track groups; (2) support nested groups; (3) make View a DrawableCollection.
affected #: 5 files (-1 bytes)
--- a/lib/galaxy/web/base/controller.py Fri Sep 23 14:27:29 2011 -0400
+++ b/lib/galaxy/web/base/controller.py Sat Sep 24 10:45:34 2011 -0400
@@ -310,40 +310,62 @@
config = None
if visualization.type == 'trackster':
- # Trackster config; taken from tracks/browser
+ # Unpack Trackster config.
latest_revision = visualization.latest_revision
bookmarks = latest_revision.config.get( 'bookmarks', [] )
- tracks = []
+
+ def pack_track( track_dict ):
+ dataset_id = track_dict['dataset_id']
+ hda_ldda = track_dict.get('hda_ldda', 'hda')
+ if hda_ldda == "hda":
+ dataset = self.get_dataset( trans, dataset_id, check_ownership=False, check_accessible=True )
+ else:
+ dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id(dataset_id) )
+
+ try:
+ prefs = track_dict['prefs']
+ except KeyError:
+ prefs = {}
+
+ track_type, _ = dataset.datatype.get_track_type()
+ track_data_provider_class = get_data_provider( original_dataset=dataset )
+ track_data_provider = track_data_provider_class( original_dataset=dataset )
+
+ return {
+ "track_type": track_type,
+ "name": track_dict['name'],
+ "hda_ldda": track_dict.get("hda_ldda", "hda"),
+ "dataset_id": trans.security.encode_id( dataset.id ),
+ "prefs": prefs,
+ "filters": track_data_provider.get_filters(),
+ "tool": get_tool_def( trans, dataset )
+ }
+
+ def pack_collection( collection_dict ):
+ drawables = []
+ for drawable_dict in collection_dict[ 'drawables' ]:
+ if 'track_type' in drawable_dict:
+ drawables.append( pack_track( drawable_dict ) )
+ else:
+ drawables.append( pack_collection( drawable_dict ) )
+ return {
+ 'obj_type': collection_dict[ 'obj_type' ],
+ 'drawables': drawables
+ }
# Set tracks.
+ tracks = []
if 'tracks' in latest_revision.config:
- for t in visualization.latest_revision.config['tracks']:
- dataset_id = t['dataset_id']
- hda_ldda = t.get('hda_ldda', 'hda')
- if hda_ldda == "hda":
- dataset = self.get_dataset( trans, dataset_id, check_ownership=False, check_accessible=True )
+ # Legacy code.
+ for track_dict in visualization.latest_revision.config[ 'tracks' ]:
+ tracks.append( pack_track( track_dict ) )
+ elif 'view' in latest_revision.config:
+ for drawable_dict in visualization.latest_revision.config[ 'view' ][ 'drawables' ]:
+ if 'track_type' in drawable_dict:
+ tracks.append( pack_track( drawable_dict ) )
else:
- dataset = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id(dataset_id) )
-
- try:
- prefs = t['prefs']
- except KeyError:
- prefs = {}
-
- track_type, _ = dataset.datatype.get_track_type()
- track_data_provider_class = get_data_provider( original_dataset=dataset )
- track_data_provider = track_data_provider_class( original_dataset=dataset )
-
- tracks.append( {
- "track_type": track_type,
- "name": t['name'],
- "hda_ldda": t.get("hda_ldda", "hda"),
- "dataset_id": trans.security.encode_id( dataset.id ),
- "prefs": prefs,
- "filters": track_data_provider.get_filters(),
- "tool": get_tool_def( trans, dataset )
- } )
-
+ tracks.append( pack_collection( drawable_dict ) )
+
config = { "title": visualization.title, "vis_id": trans.security.encode_id( visualization.id ),
"tracks": tracks, "bookmarks": bookmarks, "chrom": "", "dbkey": visualization.dbkey }
--- a/lib/galaxy/web/controllers/tracks.py Fri Sep 23 14:27:29 2011 -0400
+++ b/lib/galaxy/web/controllers/tracks.py Sat Sep 24 10:45:34 2011 -0400
@@ -615,19 +615,40 @@
vis_rev.visualization = vis
vis_rev.title = vis.title
vis_rev.dbkey = dbkey
- # Tracks from payload
- tracks = []
- # TODO: why go through the trouble of unpacking config only to repack and
- # put in database? How about sticking JSON directly into database?
- for track in decoded_payload['tracks']:
- tracks.append( { "dataset_id": track['dataset_id'],
- "hda_ldda": track.get('hda_ldda', "hda"),
- "name": track['name'],
- "track_type": track['track_type'],
- "prefs": track['prefs']
- } )
- bookmarks = decoded_payload[ 'bookmarks' ]
- vis_rev.config = { "tracks": tracks, "bookmarks": bookmarks }
+
+ def unpack_track( track_json ):
+ """ Unpack a track from its json. """
+ return {
+ "dataset_id": track_json['dataset_id'],
+ "hda_ldda": track_json.get('hda_ldda', "hda"),
+ "name": track_json['name'],
+ "track_type": track_json['track_type'],
+ "prefs": track_json['prefs']
+ }
+
+ def unpack_collection( collection_json ):
+ """ Unpack a collection from its json. """
+ unpacked_drawables = []
+ drawables = collection_json[ 'drawables' ]
+ for drawable_json in drawables:
+ if 'track_type' in drawable_json:
+ drawable = unpack_track( drawable_json )
+ else:
+ drawable = unpack_collection( drawable_json )
+ unpacked_drawables.append( drawable )
+ return {
+ "obj_type": collection_json[ 'obj_type' ],
+ "drawables": unpacked_drawables
+ }
+
+ # TODO: unpack and validate bookmarks:
+ def unpack_bookmarks( bookmarks_json ):
+ return
+
+ # Unpack and validate view content.
+ view_content = unpack_collection( decoded_payload[ 'view' ] )
+ bookmarks = unpack_bookmarks( decoded_payload[ 'bookmarks' ] )
+ vis_rev.config = { "view": view_content, "bookmarks": bookmarks }
# Viewport from payload
if 'viewport' in decoded_payload:
chrom = decoded_payload['viewport']['chrom']
--- a/static/scripts/trackster.js Fri Sep 23 14:27:29 2011 -0400
+++ b/static/scripts/trackster.js Sat Sep 24 10:45:34 2011 -0400
@@ -213,7 +213,7 @@
}
}
- // Handle dragging into container.
+ // Handle dragging into container. Child is appended to container's content_div.
container = null;
for ( i = 0; i < children.length; i++ ) {
child = $(children.get(i));
@@ -229,8 +229,10 @@
else {
child.find(".content-div").append(this);
}
- // Update containers.
- this_obj.container.remove_drawable(this_obj);
+ // Update containers. Object may not have container if it is being moved quickly.
+ if (this_obj.container) {
+ this_obj.container.remove_drawable(this_obj);
+ }
html_elt_js_obj_dict[child.attr("id")].add_drawable(this_obj);
return;
}
@@ -250,7 +252,6 @@
if ( i === children.length ) {
if ( this !== children.get(i - 1) ) {
parent.append(this);
- // Update container.
html_elt_js_obj_dict[parent.attr("id")].move_drawable(this_obj, i);
}
}
@@ -574,32 +575,58 @@
/**
* Base interface for all drawable objects.
*/
-var Drawable = function(name, view, parent_element, container) {
+var Drawable = function(name, view, parent_element, drag_handle_class, container) {
this.name = name;
this.view = view;
this.parent_element = parent_element;
+ this.drag_handle_class = drag_handle_class;
this.container = container;
};
+Drawable.prototype.init = function() {};
Drawable.prototype.request_draw = function() {};
-Drawable.prototype.draw = function() {};
+Drawable.prototype._draw = function() {};
+Drawable.prototype.to_json = function() {};
/**
* A collection of drawable objects.
*/
-var DrawableCollection = function(name, view, parent_element, container) {
+var DrawableCollection = function(obj_type, name, view, parent_element, container) {
Drawable.call(this, name, view, parent_element, container);
// Attribute init.
+ this.obj_type = obj_type;
this.drawables = [];
};
extend(DrawableCollection.prototype, Drawable.prototype, {
+ /**
+ * Init each drawable in the collection.
+ */
+ init: function() {
+ for (var i = 0; i < this.drawables.length; i++) {
+ this.drawables[i].init();
+ }
+ },
+ /**
+ * Draw each drawable in the collection.
+ */
+ _draw: function() {
+ for (var i = 0; i < this.drawables.length; i++) {
+ this.drawables[i]._draw();
+ }
+ },
+ /**
+ * Returns jsonified representation of collection.
+ */
to_json: function() {
- // For now, just return list of drawables in collection.
- var json_obj = [];
+ var jsonified_drawables = [];
for (var i = 0; i < this.drawables.length; i++) {
-
+ jsonified_drawables.push(this.drawables[i].to_json());
}
+ return {
+ obj_type: this.obj_type,
+ drawables: jsonified_drawables
+ };
},
/**
* Add a drawable to the end of the collection.
@@ -652,25 +679,30 @@
* A group of drawables that are moveable, visible.
*/
var DrawableGroup = function(name, view, parent_element, container) {
- DrawableCollection.call(this, name, view, parent_element, container);
-
- this.drag_handle_class = "group-handle";
+ DrawableCollection.call(this, "DrawableGroup", name, view, parent_element, "group-handle", container);
// HTML elements.
- this.container_div = $("<div/>").addClass("group").appendTo(this.parent_element);
+ if (!DrawableGroup.id_counter) { DrawableGroup.id_counter = 0; }
+ var group_id = DrawableGroup.id_counter++
+ this.container_div = $("<div/>").addClass("group").attr("id", "group_" + group_id).appendTo(this.parent_element);
this.container_div.append($("<div/>").addClass(this.drag_handle_class));
this.name_div = $("<div/>").addClass("group-name").text(this.name).appendTo(this.container_div);
- this.content_div = $("<div/>").addClass("content-div").appendTo(this.container_div);
+ this.content_div = $("<div/>").addClass("content-div").attr("id", "group_" + group_id + "_content_div").appendTo(this.container_div);
+
+ // Set up containers/moving for group: register both container and content div as container
+ // because both are used as containers. Group can be moved.
is_container(this.container_div, this);
+ is_container(this.content_div, this);
+ moveable(this.container_div, this.drag_handle_class, ".group", this);
};
-extend(DrawableGroup.prototype, DrawableCollection.prototype, Drawable.prototype);
+extend(DrawableGroup.prototype, Drawable.prototype, DrawableCollection.prototype);
/**
* View object manages complete viz view, including tracks and user interactions.
*/
var View = function(container, title, vis_id, dbkey, callback) {
- DrawableCollection.call(this);
+ DrawableCollection.call(this, "View");
this.container = container;
this.chrom = null;
this.vis_id = vis_id;
@@ -682,8 +714,6 @@
this.tracks_to_be_redrawn = [];
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;
@@ -870,22 +900,6 @@
$(window).trigger("resize");
this.update_intro_div();
},
- /** JSONify view. */
- to_json: function() {
- var
- view = this,
- jsonified_drawables = [];
- this.viewport_container.children(".track,.group").each(function() {
- // Get object ID.
- var id = $(this).attr("id");
- id = parseInt( id.slice(id.lastIndexOf("_") + 1) );
-
- // JSONify drawable.
- jsonified_drawables.push(view.tracks[id].to_json());
- });
-
- return jsonified_drawables;
- },
/** Add or remove intro div depending on view state. */
update_intro_div: function() {
if (this.num_tracks === 0) {
@@ -1039,17 +1053,11 @@
view.request_redraw();
},
/**
- * Add a track to the view.
+ * Add a drawable to the view.
*/
- add_track: function(track) {
- track.view = this;
- track.track_id = this.track_id_counter;
- this.tracks.push(track);
- if (track.init) { track.init(); }
- track.container_div.attr('id', 'track_' + track.track_id);
- moveable(track.container_div, track.drag_handle_class, ".group", track);
- this.track_id_counter += 1;
- this.num_tracks += 1;
+ add_drawable: function(drawable) {
+ DrawableCollection.prototype.add_drawable.call(this, drawable);
+ if (drawable.init) { drawable.init(); }
this.has_changes = true;
this.update_intro_div();
},
@@ -1058,17 +1066,18 @@
this.label_tracks.push(label_track);
},
/**
- * Remove a track from the view.
+ * Remove drawable from the view.
*/
- remove_track: function(track) {
- this.has_changes = true;
- this.tracks.splice(this.tracks.indexOf(track), 1);
- this.num_tracks -= 1;
- var view = this;
- track.container_div.fadeOut('slow', function() {
- $(this).remove();
- view.update_intro_div();
- });
+ remove_drawable: function(drawable, hide) {
+ DrawableCollection.prototype.remove_drawable.call(this, drawable);
+ if (hide) {
+ var view = this;
+ drawable.container_div.fadeOut('slow', function() {
+ $(this).remove();
+ view.update_intro_div();
+ });
+ this.has_changes = true;
+ }
},
reset: function() {
this.low = this.max_low;
@@ -1161,7 +1170,7 @@
track = this.tracks_to_be_redrawn[i][0];
force = this.tracks_to_be_redrawn[i][1];
clear_after = this.tracks_to_be_redrawn[i][2];
- if (track && track.enabled) {
+ if (track) {
track._draw(force, clear_after);
}
}
@@ -1310,9 +1319,9 @@
run_on_region_button.click( function() {
// Create group for track + new tracks and put track in group.
var
- parent_elt = this.track.parent_element,
- new_group = new DrawableCollection("New Group", parent_elt);
- //this.track.view.add_track(new_group);
+ parent_elt = this.track.parent_element;
+ //new_group = new DrawableCollection("New Group", parent_elt);
+ //this.track.view.add_drawable(new_group);
// Run tool to create new track.
@@ -1399,7 +1408,7 @@
new_track = new ToolDataFeatureTrack(track_name, view, current_track.hda_ldda, undefined, {}, {}, current_track);
new_track.change_mode(current_track.mode);
}
- this.track.view.add_track(new_track);
+ this.track.view.add_drawable(new_track);
new_track.content_div.text("Starting job.");
// Run tool.
@@ -2007,7 +2016,7 @@
*/
var Track = function(name, view, parent_element, data_url, data_query_wait) {
// For now, track's container is always view.
- Drawable.call(this, name, view, parent_element, view);
+ Drawable.call(this, name, view, parent_element, "draghandle", view);
//
// Attribute init.
@@ -2016,12 +2025,12 @@
this.data_url_extra_params = {}
this.data_query_wait = (data_query_wait ? data_query_wait : DEFAULT_DATA_QUERY_WAIT);
this.dataset_check_url = converted_datasets_state_url;
- this.drag_handle_class = "draghandle";
//
// Create HTML element structure for track.
//
- this.container_div = $("<div />").addClass('track').css("position", "relative");
+ if (!Track.id_counter) { Track.id_counter = 0; }
+ this.container_div = $("<div />").addClass('track').attr("id", "track_" + Track.id_counter++).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/>").addClass(this.drag_handle_class).appendTo(this.header_div); }
@@ -2154,6 +2163,9 @@
var TiledTrack = function(filters_list, tool_dict, parent_track) {
var track = this,
view = track.view;
+
+ // Make track moveable.
+ moveable(track.container_div, track.drag_handle_class, ".group", track);
// Attribute init.
this.filters_manager = (filters_list !== undefined ? new FiltersManager(this, filters_list) : undefined);
@@ -2327,8 +2339,8 @@
// Remove option.
//
track_dropdown.Remove = function() {
- view.remove_track(track);
- if (parent_obj.num_tracks === 0) {
+ view.remove_drawable(track, true);
+ if (view.num_tracks === 0) {
$("#no-tracks").show();
}
};
@@ -2401,6 +2413,8 @@
* can manage drawing.
*/
_draw: function(force, clear_after) {
+ if (!this.enabled) { return; }
+
// HACK: ReferenceTrack can draw without dataset ID, but other tracks cannot.
if ( !(this instanceof ReferenceTrack) && (!this.dataset_id) ) { return; }
--- a/static/scripts/trackster_ui.js Fri Sep 23 14:27:29 2011 -0400
+++ b/static/scripts/trackster_ui.js Sat Sep 24 10:45:34 2011 -0400
@@ -29,20 +29,54 @@
};
/**
- * Types of tracks that can be added to a view.
+ * Objects that can be added to a view.
*/
-var addable_track_types = { "LineTrack": LineTrack, "FeatureTrack": FeatureTrack, "ReadTrack": ReadTrack };
+var addable_objects = { "LineTrack": LineTrack, "FeatureTrack": FeatureTrack, "ReadTrack": ReadTrack, "DrawableGroup": DrawableGroup };
/**
* Decode a track from a dictionary.
*/
var track_from_dict = function(track_dict) {
- return new addable_track_types[track_dict.track_type](
+ return new addable_objects[track_dict.track_type](
track_dict.name, view, track_dict.hda_ldda, track_dict.dataset_id,
track_dict.prefs, track_dict.filters, track_dict.tool);
};
/**
+ * Decode a drawable collection from a dictionary.
+ */
+var drawable_collection_from_dict = function(collection_dict) {
+ var collection = new addable_objects[collection_dict.obj_type]("New Group", view, view.viewport_container, view);
+ for (var i = 0; i < collection_dict.drawables.length; i++) {
+ var
+ drawable_dict = collection_dict.drawables[i],
+ drawable;
+ if (drawable_dict['track_type']) {
+ drawable = track_from_dict(drawable_dict);
+ }
+ else {
+ drawable = drawable_collection_from_dict(drawable_dict);
+ }
+ collection.add_drawable(drawable);
+ // HACK: move track from view to collection's content_div.
+ // FIX: Tracks should be able to be be added to arbitrary containers;
+ // every moveable should have a container_div, and every container should have
+ // a content_div (though perhaps name changes are needed).
+ collection.content_div.append(drawable.container_div);
+ }
+ return collection;
+};
+
+/**
+ * Decode a drawable from a dict.
+ */
+var drawable_from_dict = function(drawable_dict) {
+ return (drawable_dict['track_type'] ?
+ track_from_dict(drawable_dict) :
+ drawable_collection_from_dict(drawable_dict));
+};
+
+/**
* Create a complete Trackster visualization. Returns view.
*/
var create_visualization = function(parent_elt, title, id, dbkey, callback, tracks_config, bookmarks_config) {
@@ -51,21 +85,12 @@
view = new View(parent_elt, title, id, dbkey, callback);
view.editor = true;
- // Add tracks to view.
+ // Add drawables to view.
if (tracks_config) {
- var track_config, track, parent_track, parent_obj;
+ var track_config;
for (var i = 0; i < tracks_config.length; i++) {
track_config = tracks_config[i];
- track = track_from_dict(track_config);
- parent_obj = view;
- if (track_config.is_child) {
- parent_obj = parent_track;
- }
- else {
- // New parent track is this track.
- parent_track = track;
- }
- parent_obj.add_track(track);
+ view.add_drawable( drawable_from_dict(track_config) );
}
}
--- a/templates/tracks/browser.mako Fri Sep 23 14:27:29 2011 -0400
+++ b/templates/tracks/browser.mako Sat Sep 24 10:45:34 2011 -0400
@@ -101,7 +101,7 @@
[ arguments[0] ]
);
for (var i= 0; i < track_defs.length; i++) {
- view.add_track( track_from_dict(track_defs[i]) );
+ view.add_drawable( track_from_dict(track_defs[i]) );
}
});
hide_modal();
@@ -186,7 +186,7 @@
url: "${h.url_for( action='add_track_async' )}",
data: { hda_id: "${add_dataset}" },
dataType: "json",
- success: function(track_data) { view.add_track( track_from_dict(track_data) ) }
+ success: function(track_data) { view.add_drawable( track_from_dict(track_data) ) }
});
%endif
@@ -199,15 +199,12 @@
"Add Tracks": add_tracks,
"Add Group": function() {
var group = new DrawableGroup("New Group", view, view.viewport_container, view);
- view.add_track(group);
+ view.add_drawable(group);
},
"Save": function() {
// Show saving dialog box
show_modal("Saving...", "<img src='${h.url_for('/static/images/yui/rel_interstitial_loading.gif')}'/>");
-
- // Save tracks.
- var saved_tracks = view.to_json();
-
+
// Save bookmarks.
var bookmarks = [];
$(".bookmark").each(function() {
@@ -219,7 +216,7 @@
var overview_track_name = (view.overview_track ? view.overview_track.name : null);
var payload = {
- 'tracks': saved_tracks,
+ 'view': view.to_json(),
'viewport': { 'chrom': view.chrom, 'start': view.low , 'end': view.high, 'overview': overview_track_name },
'bookmarks': bookmarks
};
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: greg: Correct the message displayed when index files are missing under certain circumstances in the tool shed.
by Bitbucket 23 Sep '11
by Bitbucket 23 Sep '11
23 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/a88d39b19b01/
changeset: a88d39b19b01
user: greg
date: 2011-09-23 20:27:29
summary: Correct the message displayed when index files are missing under certain circumstances in the tool shed.
affected #: 1 file (-1 bytes)
--- a/lib/galaxy/webapps/community/controllers/common.py Fri Sep 23 13:51:55 2011 -0400
+++ b/lib/galaxy/webapps/community/controllers/common.py Fri Sep 23 14:27:29 2011 -0400
@@ -426,8 +426,12 @@
exception_items = exception_msg.split()
missing_file_items = exception_items[7].split( '/' )
missing_file = missing_file_items[-1].rstrip( '\'' )
+ if missing_file.endswith( '.loc' ):
+ sample_ext = '%s.sample' % missing_file
+ else:
+ sample_ext = missing_file
correction_msg = "This file refers to a missing file <b>%s</b>. " % str( missing_file )
- correction_msg += "Upload a file named <b>%s</b> to the repository to correct this error." % missing_file
+ correction_msg += "Upload a file named <b>%s</b> to the repository to correct this error." % sample_ext
else:
correction_msg = exception_msg
message += "<b>%s</b> - %s<br/>" % ( tool_file, correction_msg )
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: greg: Make sure dymanically generated select list options exist before checking for missing dependencies.
by Bitbucket 23 Sep '11
by Bitbucket 23 Sep '11
23 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/dc4a8297d0ab/
changeset: dc4a8297d0ab
user: greg
date: 2011-09-23 19:51:55
summary: Make sure dymanically generated select list options exist before checking for missing dependencies.
affected #: 3 files (-1 bytes)
--- a/lib/galaxy/web/base/controller.py Fri Sep 23 13:49:33 2011 -0400
+++ b/lib/galaxy/web/base/controller.py Fri Sep 23 13:51:55 2011 -0400
@@ -2447,23 +2447,24 @@
# If the tool refers to .loc files or requires an entry in the
# tool_data_table_conf.xml, make sure all requirements exist.
options = input_param.dynamic_options or input_param.options
- if options.missing_tool_data_table_name:
- # The repository must contain a tool_data_table_conf.xml.sample file.
- for sample_file in sample_files:
- head, tail = os.path.split( sample_file )
- if tail == 'tool_data_table_conf.xml.sample':
- error, correction_msg = handle_sample_tool_data_table_conf_file( trans, sample_file )
- if error:
- log.debug( exception_msg )
- break
- if options.missing_index_file:
- missing_head, missing_tail = os.path.split( options.missing_index_file )
- # The repository must contain the required xxx.loc.sample file.
- for sample_file in sample_files:
- sample_head, sample_tail = os.path.split( sample_file )
- if sample_tail == '%s.sample' % missing_tail:
- copy_sample_loc_file( trans, sample_file )
- break
+ if options:
+ if options.missing_tool_data_table_name:
+ # The repository must contain a tool_data_table_conf.xml.sample file.
+ for sample_file in sample_files:
+ head, tail = os.path.split( sample_file )
+ if tail == 'tool_data_table_conf.xml.sample':
+ error, correction_msg = handle_sample_tool_data_table_conf_file( trans, sample_file )
+ if error:
+ log.debug( exception_msg )
+ break
+ if options.missing_index_file:
+ missing_head, missing_tail = os.path.split( options.missing_index_file )
+ # The repository must contain the required xxx.loc.sample file.
+ for sample_file in sample_files:
+ sample_head, sample_tail = os.path.split( sample_file )
+ if sample_tail == '%s.sample' % missing_tail:
+ copy_sample_loc_file( trans, sample_file )
+ break
# At this point, we need to lstrip tool_path from relative_path.
tup_path = relative_path.replace( tool_path, '' ).lstrip( '/' )
repository_tools_tups.append( ( tup_path, repository_tool ) )
--- a/lib/galaxy/webapps/community/controllers/common.py Fri Sep 23 13:49:33 2011 -0400
+++ b/lib/galaxy/webapps/community/controllers/common.py Fri Sep 23 13:51:55 2011 -0400
@@ -175,39 +175,40 @@
# If the tool refers to .loc files or requires an entry in the
# tool_data_table_conf.xml, make sure all requirements exist.
options = input_param.dynamic_options or input_param.options
- if options.missing_tool_data_table_name:
- # See if the repository contains a tool_data_table_conf.xml.sample file.
- sample_found = False
- for sample_file in sample_files:
- head, tail = os.path.split( sample_file )
- if tail == 'tool_data_table_conf.xml.sample':
- sample_found = True
- error, correction_msg = handle_sample_tool_data_table_conf_file( trans, sample_file )
- if error:
- can_set_metadata = False
- invalid_files.append( ( tail, correction_msg ) )
- break
- if not sample_found:
- can_set_metadata = False
- correction_msg = "This file requires an entry in the tool_data_table_conf.xml file. "
- correction_msg += "Upload a file named tool_data_table_conf.xml.sample to the repository "
- correction_msg += "that includes the required entry to resolve this issue.<br/>"
- invalid_files.append( ( name, correction_msg ) )
- elif options.missing_index_file:
- missing_head, missing_tail = os.path.split( options.missing_index_file )
- # See if the repository contains the required xxx.loc.sample file.
- sample_found = False
- for sample_file in sample_files:
- sample_head, sample_tail = os.path.split( sample_file )
- if sample_tail == '%s.sample' % missing_tail:
- copy_sample_loc_file( trans, sample_file )
- sample_found = True
- break
- if not sample_found:
- can_set_metadata = False
- correction_msg = "This file refers to a missing file <b>%s</b>. " % str( options.missing_index_file )
- correction_msg += "Upload a file named <b>%s.sample</b> to the repository to correct this error." % str( missing_tail )
- invalid_files.append( ( name, correction_msg ) )
+ if options:
+ if options.missing_tool_data_table_name:
+ # See if the repository contains a tool_data_table_conf.xml.sample file.
+ sample_found = False
+ for sample_file in sample_files:
+ head, tail = os.path.split( sample_file )
+ if tail == 'tool_data_table_conf.xml.sample':
+ sample_found = True
+ error, correction_msg = handle_sample_tool_data_table_conf_file( trans, sample_file )
+ if error:
+ can_set_metadata = False
+ invalid_files.append( ( tail, correction_msg ) )
+ break
+ if not sample_found:
+ can_set_metadata = False
+ correction_msg = "This file requires an entry in the tool_data_table_conf.xml file. "
+ correction_msg += "Upload a file named tool_data_table_conf.xml.sample to the repository "
+ correction_msg += "that includes the required entry to resolve this issue.<br/>"
+ invalid_files.append( ( name, correction_msg ) )
+ elif options.missing_index_file:
+ missing_head, missing_tail = os.path.split( options.missing_index_file )
+ # See if the repository contains the required xxx.loc.sample file.
+ sample_found = False
+ for sample_file in sample_files:
+ sample_head, sample_tail = os.path.split( sample_file )
+ if sample_tail == '%s.sample' % missing_tail:
+ copy_sample_loc_file( trans, sample_file )
+ sample_found = True
+ break
+ if not sample_found:
+ can_set_metadata = False
+ correction_msg = "This file refers to a missing file <b>%s</b>. " % str( options.missing_index_file )
+ correction_msg += "Upload a file named <b>%s.sample</b> to the repository to correct this error." % str( missing_tail )
+ invalid_files.append( ( name, correction_msg ) )
return can_set_metadata, invalid_files
def generate_tool_metadata( trans, id, changeset_revision, tool_config, tool, metadata_dict ):
"""
--- a/templates/tool_form.mako Fri Sep 23 13:49:33 2011 -0400
+++ b/templates/tool_form.mako Fri Sep 23 13:51:55 2011 -0400
@@ -257,12 +257,13 @@
# If the tool refers to .loc files or requires an entry in the
# tool_data_table_conf.xml, make sure all requirements exist.
options = input_param.dynamic_options or input_param.options
- if options.missing_tool_data_table_name:
- message = "Data table named '%s' is required by tool but not configured" % options.missing_tool_data_table_name
- break
- if options.missing_index_file:
- message = "Index file named '%s' is required by tool but not availble" % options.missing_index_file
- break
+ if options:
+ if options.missing_tool_data_table_name:
+ message = "Data table named '%s' is required by tool but not configured" % options.missing_tool_data_table_name
+ break
+ if options.missing_index_file:
+ message = "Index file named '%s' is required by tool but not availble" % options.missing_index_file
+ break
# Handle calculating the redirect url for the special case where we have nginx proxy
# upload and need to do url_for on the redirect portion of the tool action.
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
23 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/72ed536a988d/
changeset: 72ed536a988d
user: dan
date: 2011-09-23 19:49:33
summary: Rewrite random lines tool. Does two passes through input file: first pass determines line offsets/count, offsets are randomly removed, second pass writes out lines by seeking to remaining offsets. The random seed can now be optionally specified.
affected #: 3 files (-1 bytes)
--- a/tools/filters/randomlines.xml Fri Sep 23 13:26:34 2011 -0400
+++ b/tools/filters/randomlines.xml Fri Sep 23 13:49:33 2011 -0400
@@ -1,9 +1,25 @@
-<tool id="random_lines1" name="Select random lines">
+<tool id="random_lines1" name="Select random lines" version="2.0.0"><description>from a file</description>
- <command interpreter="python">randomlines.py $input $num_lines $out_file1</command>
+ <command interpreter="python">random_lines_two_pass.py "${input}" "${out_file1}" "${num_lines}"
+ #if str( $seed_source.seed_source_selector ) == "set_seed":
+ --seed "${seed_source.seed}"
+ #end if
+ </command><inputs><param name="num_lines" size="5" type="integer" value="1" label="Randomly select" help="lines"/><param format="txt" name="input" type="data" label="from"/>
+ <conditional name="seed_source">
+ <param name="seed_source_selector" type="select" label="Set a random seed">
+ <option value="no_seed" selected="True">Don't set seed</option>
+ <option value="set_seed">Set seed</option>
+ </param>
+ <when value="no_seed">
+ <!-- Do nothing here -->
+ </when>
+ <when value="set_seed">
+ <param name="seed" type="text" label="Random seed" />
+ </when>
+ </conditional></inputs><outputs><data format="input" name="out_file1" metadata_source="input"/>
@@ -12,8 +28,16 @@
<test><param name="num_lines" value="65"/><param name="input" value="1.bed"/>
+ <param name="seed_source_selector" value="no_seed"/><output name="out_file1" file="1.bed"/></test>
+ <test>
+ <param name="num_lines" value="1"/>
+ <param name="input" value="1.bed"/>
+ <param name="seed_source_selector" value="set_seed"/>
+ <param name="seed" value="asdf"/>
+ <output name="out_file1" file="1_bed_random_lines_1_seed_asdf_out.bed"/>
+ </test></tests><help>
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: put in framework to manage track collections.
by Bitbucket 23 Sep '11
by Bitbucket 23 Sep '11
23 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/c691f5c65011/
changeset: c691f5c65011
user: jgoecks
date: 2011-09-23 19:26:34
summary: Trackster: put in framework to manage track collections.
affected #: 3 files (-1 bytes)
--- a/static/scripts/packed/trackster.js Fri Sep 23 11:32:08 2011 -0400
+++ b/static/scripts/packed/trackster.js Fri Sep 23 13:26:34 2011 -0400
@@ -1,1 +1,1 @@
-var class_module=function(b,a){var c=function(){var f=arguments[0];for(var e=1;e<arguments.length;e++){var d=arguments[e];for(key in d){f[key]=d[key]}}return f};a.extend=c};var requestAnimationFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(b,a){window.setTimeout(b,1000/60)}})();var BEFORE=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005,AFTER=1006;var compute_overlap=function(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=BEFORE}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=AFTER}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a};var is_overlap=function(c,b){var a=compute_overlap(c,b);return(a!==BEFORE&&a!==AFTER)};var trackster_module=function(f,W){var p=f("class").extend,r=f("slotting"),K=f("painters");var ad=function(ae,af){this.document=ae;this.default_font=af!==undefined?af:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};p(ad.prototype,{load_pattern:function(ae,ai){var af=this.patterns,ag=this.dummy_context,ah=new Image();ah.src=image_path+ai;ah.onload=function(){af[ae]=ag.createPattern(ah,"repeat")}},get_pattern:function(ae){return this.patterns[ae]},new_canvas:function(){var ae=this.document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(ae)}ae.manager=this;return ae}});var m=function(ae,ag,ah){ah=".group";var af={};ae.bind("drag",{handle:"."+ag,relative:true},function(an,ao){var aq=$(this).parent(),al=aq.children(),ak,aj,ap,ai,am;aj=$(this).parents(ah);if(aj.length!==0){ap=aj.position().top;ai=ap+aj.outerHeight();if(ao.offsetY<ap){$(this).insertBefore(aj);return}else{if(ao.offsetY>ai){$(this).insertAfter(aj);return}}}aj=null;for(am=0;am<al.length;am++){ak=$(al.get(am));ap=ak.position().top;ai=ap+ak.outerHeight();if(ak.is(ah)&&this!==ak.get(0)&&ao.offsetY>=ap&&ao.offsetY<=ai){if(ao.offsetY-ap<ai-ao.offsetY){ak.find(".content-div").prepend(this)}else{ak.find(".content-div").append(this)}return}}for(am=0;am<al.length;am++){if(ao.offsetY<$(al.get(am)).position().top){break}}if(am===al.length){if(this!==al.get(am-1)){aq.append(this)}}else{if(this!==al.get(am)){$(this).insertBefore(al.get(am))}}}).bind("dragstart",function(){af["border-top"]=ae.css("border-top");af["border-bottom"]=ae.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(af)})};W.moveable=m;var ac=16,F=9,D=20,R=F+2,z=100,H=12000,P=200,C=5,u=10,J=5000,v=100,n="There was an error in indexing this dataset. ",I="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",E="No data for this chrom/contig.",s="Currently indexing... please wait",x="Tool cannot be rerun: ",a="Loading data...",X="Ready for display",d=10,t=5,B=5;function w(ae){return Math.round(ae*1000)/1000}var c=function(ae){this.num_elements=ae;this.clear()};p(c.prototype,{get:function(af){var ae=this.key_ary.indexOf(af);if(ae!==-1){if(this.obj_cache[af].stale){this.key_ary.splice(ae,1);delete this.obj_cache[af]}else{this.move_key_to_end(af,ae)}}return this.obj_cache[af]},set:function(af,ag){if(!this.obj_cache[af]){if(this.key_ary.length>=this.num_elements){var ae=this.key_ary.shift();delete this.obj_cache[ae]}this.key_ary.push(af)}this.obj_cache[af]=ag;return ag},move_key_to_end:function(af,ae){this.key_ary.splice(ae,1);this.key_ary.push(af)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var Q=function(af,ae,ag){c.call(this,af);this.track=ae;this.subset=(ag!==undefined?ag:true)};p(Q.prototype,c.prototype,{load_data:function(an,ai,al,af,ak){var am=this.track.view.chrom,ah={chrom:am,low:an,high:ai,mode:al,resolution:af,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(ah,ak);if(this.track.filters_manager){var ao=[];var ae=this.track.filters_manager.filters;for(var aj=0;aj<ae.length;aj++){ao[ao.length]=ae[aj].name}ah.filter_cols=JSON.stringify(ao)}var ag=this;return $.getJSON(this.track.data_url,ah,function(ap){ag.set_data(an,ai,al,ap)})},get_data:function(ae,ai,aj,af,ah){var ag=this.get_data_from_cache(ae,ai,aj);if(ag){return ag}ag=this.load_data(ae,ai,aj,af,ah);this.set_data(ae,ai,aj,ag);return ag},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(am,ah,al,ag,ak,ai){var an=this.get_data_from_cache(am,ah,al);if(!an){console.log("ERROR: no current data for: ",this.track,am,ah,al,ag,ak);return}an.stale=true;var af=am;if(ai===this.DEEP_DATA_REQ){$.extend(ak,{start_val:an.data.length+1})}else{if(ai===this.BROAD_DATA_REQ){af=(an.max_high?an.max_high:an.data[an.data.length-1][2])+1}}var ae=this,aj=this.load_data(af,ah,al,ag,ak);new_data_available=$.Deferred();this.set_data(am,ah,al,new_data_available);$.when(aj).then(function(ao){if(ao.data){ao.data=an.data.concat(ao.data);if(ao.max_low){ao.max_low=an.max_low}if(ao.message){ao.message=ao.message.replace(/[0-9]+/,ao.data.length)}}ae.set_data(am,ah,al,ao);new_data_available.resolve(ao)});return new_data_available},get_data_from_cache:function(ae,af,ag){return this.get(this.gen_key(ae,af,ag))},set_data:function(af,ag,ah,ae){return this.set(this.gen_key(af,ag,ah),ae)},gen_key:function(ae,ag,ah){var af=ae+"_"+ag+"_"+ah;return af},split_key:function(ae){return ae.split("_")}});var G=function(af,ae,ag){Q.call(this,af,ae,ag)};p(G.prototype,Q.prototype,c.prototype,{load_data:function(ag,ae,ai,aj,af,ah){if(af>1){return}return Q.prototype.load_data.call(this,ag,ae,ai,aj,af,ah)}});var ab=function(ae,ah,ag,af,ai){this.container=ae;this.chrom=null;this.vis_id=ag;this.dbkey=af;this.title=ah;this.tracks=[];this.label_tracks=[];this.tracks_to_be_redrawn=[];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(ai);this.canvas_manager=new ad(ae.get(0).ownerDocument);this.reset()};p(ab.prototype,{init:function(ai){var ag=this.container,ae=this;this.top_container=$("<div/>").addClass("top-container").appendTo(ag);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(ag);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(ag);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").appendTo(this.viewport_container).hide();var ah=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){add_tracks()});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_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var af=function(aj){if(aj.type==="focusout"||(aj.keyCode||aj.which)===13||(aj.keyCode||aj.which)===27){if((aj.keyCode||aj.which)!==27){ae.go_to($(this).val())}$(this).hide();$(this).val("");ae.location_span.show();ae.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",af).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").appendTo(this.nav_controls);this.location_span.click(function(){ae.location_span.hide();ae.chrom_select.hide();ae.nav_input.val(ae.chrom+":"+ae.low+"-"+ae.high);ae.nav_input.css("display","inline-block");ae.nav_input.select();ae.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.nav_controls)}this.zo_link=$("<a id='zoom-out' />").click(function(){ae.zoom_out();ae.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){ae.zoom_in();ae.request_redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},ai);this.chrom_select.bind("change",function(){ae.change_chrom(ae.chrom_select.val())});this.content_div.click(function(aj){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(aj){ae.zoom_in(aj.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(aj,ak){this.current_x=ak.offsetX}).bind("drag",function(aj,al){var am=al.offsetX-this.current_x;this.current_x=al.offsetX;var ak=Math.round(am/ae.viewport_container.width()*(ae.max_high-ae.max_low));ae.move_delta(-ak)});this.overview_close.click(function(){ae.reset_overview()});this.viewport_container.bind("draginit",function(aj,ak){if(aj.clientX>ae.viewport_container.width()-16){return false}}).bind("dragstart",function(aj,ak){ak.original_low=ae.low;ak.current_height=aj.clientY;ak.current_x=ak.offsetX}).bind("drag",function(al,an){var aj=$(this);var ao=an.offsetX-an.current_x;var ak=aj.scrollTop()-(al.clientY-an.current_height);aj.scrollTop(ak);an.current_height=al.clientY;an.current_x=an.offsetX;var am=Math.round(ao/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(am)}).bind("mousewheel",function(al,an,ak,aj){if(ak){var am=Math.round(-ak/ae.viewport_container.width()*(ae.high-ae.low));ae.move_delta(am)}});this.top_labeltrack.bind("dragstart",function(aj,ak){return $("<div />").css({height:ae.content_div.height()+ae.top_labeltrack.height()+ae.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(an,ao){$(ao.proxy).css({left:Math.min(an.pageX,ao.startX),width:Math.abs(an.pageX-ao.startX)});var ak=Math.min(an.pageX,ao.startX)-ae.container.offset().left,aj=Math.max(an.pageX,ao.startX)-ae.container.offset().left,am=(ae.high-ae.low),al=ae.viewport_container.width();ae.update_location(Math.round(ak/al*am)+ae.low,Math.round(aj/al*am)+ae.low)}).bind("dragend",function(ao,ap){var ak=Math.min(ao.pageX,ap.startX),aj=Math.max(ao.pageX,ap.startX),am=(ae.high-ae.low),al=ae.viewport_container.width(),an=ae.low;ae.low=Math.round(ak/al*am)+an;ae.high=Math.round(aj/al*am)+an;$(ap.proxy).remove();ae.request_redraw()});this.add_label_track(new aa(this,this.top_labeltrack));this.add_label_track(new aa(this,this.nav_labeltrack));$(window).bind("resize",function(){ae.resize_window()});$(document).bind("redraw",function(){ae.redraw()});this.reset();$(window).trigger("resize");this.update_intro_div()},to_json:function(){var ae=this,af=[];this.viewport_container.children(".track,.group").each(function(){var ag=$(this).attr("id");ag=parseInt(ag.slice(ag.lastIndexOf("_")+1));af.push(ae.tracks[ag].to_json())});return af},update_intro_div:function(){if(this.num_tracks===0){this.intro_div.show()}else{this.intro_div.hide()}},update_location:function(ae,af){this.location_span.text(commatize(ae)+" - "+commatize(af));this.nav_input.val(this.chrom+":"+commatize(ae)+"-"+commatize(af))},load_chroms:function(af,ag){af.num=v;$.extend(af,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var ae=this;$.ajax({url:chrom_url,data:af,dataType:"json",success:function(ai){if(ai.chrom_info.length===0){alert("Invalid chromosome: "+af.chrom);return}if(ai.reference){ae.add_label_track(new A(ae))}ae.chrom_data=ai.chrom_info;var al='<option value="">Select Chrom/Contig</option>';for(var ak=0,ah=ae.chrom_data.length;ak<ah;ak++){var aj=ae.chrom_data[ak].chrom;al+='<option value="'+aj+'">'+aj+"</option>"}if(ai.prev_chroms){al+='<option value="previous">Previous '+v+"</option>"}if(ai.next_chroms){al+='<option value="next">Next '+v+"</option>"}ae.chrom_select.html(al);if(ag){ag()}ae.chrom_start_index=ai.start_index},error:function(){alert("Could not load chroms for this dbkey:",ae.dbkey)}})},change_chrom:function(ai,af,ak){if(!ai||ai==="None"){return}var ah=this;if(ai==="previous"){ah.load_chroms({low:this.chrom_start_index-v});return}if(ai==="next"){ah.load_chroms({low:this.chrom_start_index+v});return}var aj=$.grep(ah.chrom_data,function(am,an){return am.chrom===ai})[0];if(aj===undefined){ah.load_chroms({chrom:ai},function(){ah.change_chrom(ai,af,ak)});return}else{if(ai!==ah.chrom){ah.chrom=ai;ah.chrom_select.val(ah.chrom);ah.max_high=aj.len-1;ah.reset();ah.request_redraw(true);for(var al=0,ae=ah.tracks.length;al<ae;al++){var ag=ah.tracks[al];if(ag.init){ag.init()}}}if(af!==undefined&&ak!==undefined){ah.low=Math.max(af,0);ah.high=Math.min(ak,ah.max_high)}ah.reset_overview();ah.request_redraw()}},go_to:function(ai){var am=this,ae,ah,af=ai.split(":"),ak=af[0],al=af[1];if(al!==undefined){try{var aj=al.split("-");ae=parseInt(aj[0].replace(/,/g,""),10);ah=parseInt(aj[1].replace(/,/g,""),10)}catch(ag){return false}}am.change_chrom(ak,ae,ah)},move_fraction:function(ag){var ae=this;var af=ae.high-ae.low;this.move_delta(ag*af)},move_delta:function(ag){var ae=this;var af=ae.high-ae.low;if(ae.low-ag<ae.max_low){ae.low=ae.max_low;ae.high=ae.max_low+af}else{if(ae.high-ag>ae.max_high){ae.high=ae.max_high;ae.low=ae.max_high-af}else{ae.high-=ag;ae.low-=ag}}ae.request_redraw()},add_track:function(ae){ae.view=this;ae.track_id=this.track_id_counter;this.tracks.push(ae);if(ae.init){ae.init()}ae.container_div.attr("id","track_"+ae.track_id);m(ae.container_div,ae.drag_handle_class);this.track_id_counter+=1;this.num_tracks+=1;this.has_changes=true;this.update_intro_div()},add_label_track:function(ae){ae.view=this;this.label_tracks.push(ae)},remove_track:function(af){this.has_changes=true;this.tracks.splice(this.tracks.indexOf(af),1);this.num_tracks-=1;var ae=this;af.container_div.fadeOut("slow",function(){$(this).remove();ae.update_intro_div()})},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(am,ae,al,af){var ak=this,ai=(af?[af]:ak.tracks),ag;var af;for(var aj=0;aj<ai.length;aj++){af=ai[aj];ag=-1;for(var ah=0;ah<ak.tracks_to_be_redrawn.length;ah++){if(ak.tracks_to_be_redrawn[ah][0]===af){ag=ah;break}}if(ag<0){ak.tracks_to_be_redrawn.push([af,ae,al])}else{ak.tracks_to_be_redrawn[aj][1]=ae;ak.tracks_to_be_redrawn[aj][2]=al}}requestAnimationFrame(function(){ak._redraw(am)})},_redraw:function(ao){var al=this.low,ah=this.high;if(al<this.max_low){al=this.max_low}if(ah>this.max_high){ah=this.max_high}var an=this.high-this.low;if(this.high!==0&&an<this.min_separation){ah=al+this.min_separation}this.low=Math.floor(al);this.high=Math.ceil(ah);this.resolution=Math.pow(C,Math.ceil(Math.log((this.high-this.low)/P)/Math.log(C)));this.zoom_res=Math.pow(u,Math.max(0,Math.ceil(Math.log(this.resolution,u)/Math.log(u))));var ae=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ak=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var ap=13;this.overview_box.css({left:ae,width:Math.max(ap,ak)}).show();if(ak<ap){this.overview_box.css("left",ae-(ap-ak)/2)}if(this.overview_highlight){this.overview_highlight.css({left:ae,width:ak})}this.update_location(this.low,this.high);if(!ao){var ag,af,am;for(var ai=0,aj=this.tracks_to_be_redrawn.length;ai<aj;ai++){ag=this.tracks_to_be_redrawn[ai][0];af=this.tracks_to_be_redrawn[ai][1];am=this.tracks_to_be_redrawn[ai][2];if(ag&&ag.enabled){ag._draw(af,am)}}this.tracks_to_be_redrawn=[];for(ai=0,aj=this.label_tracks.length;ai<aj;ai++){this.label_tracks[ai]._draw()}}},zoom_in:function(af,ag){if(this.max_high===0||this.high-this.low<this.min_separation){return}var ah=this.high-this.low,ai=ah/2+this.low,ae=(ah/this.zoom_factor)/2;if(af){ai=af/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(ai-ae);this.high=Math.round(ai+ae);this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var af=this.high-this.low,ag=af/2+this.low,ae=(af*this.zoom_factor)/2;this.low=Math.round(ag-ae);this.high=Math.round(ag+ae);this.request_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.request_redraw()},set_overview:function(ae){$.when(ae.get_overview_tile()).then(function(af){view.overview_viewport.find(".track-tile").remove();view.overview_close.show();view.overview_viewport.append(af.canvas);view.overview_highlight.show().height(af.canvas.height());view.overview_viewport.height(af.canvas.height()+view.overview_box.outerHeight());view.resize_window();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=ae;ae.set_is_overview(true)});view.has_changes=true},reset_overview:function(){this.overview_viewport.find(".track-tile").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();view.resize_window();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=null}});var q=function(ag,ak){this.track=ag;this.name=ak.name;this.params=[];var ar=ak.params;for(var ah=0;ah<ar.length;ah++){var am=ar[ah],af=am.name,aq=am.label,ai=unescape(am.html),at=am.value,ao=am.type;if(ao==="number"){this.params[this.params.length]=new g(af,aq,ai,at,am.min,am.max)}else{if(ao=="select"){this.params[this.params.length]=new M(af,aq,ai,at)}else{console.log("WARNING: unrecognized tool parameter type:",af,ao)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(av){av.stopPropagation()}).click(function(av){av.stopPropagation()}).bind("dblclick",function(av){av.stopPropagation()});var ap=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var an=this.params;var al=this;$.each(this.params,function(aw,az){var ay=$("<div>").addClass("param-row").appendTo(al.parent_div);var av=$("<div>").addClass("param-label").text(az.label).appendTo(ay);var ax=$("<div/>").addClass("slider").html(az.html).appendTo(ay);ax.find(":input").val(az.value);$("<div style='clear: both;'/>").appendTo(ay)});this.parent_div.find("input").click(function(){$(this).select()});var au=$("<div>").addClass("param-row").appendTo(this.parent_div);var aj=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(au);var ae=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(au);var al=this;ae.click(function(){al.run_on_region()});aj.click(function(){al.run_on_dataset()})};p(q.prototype,{get_param_values_dict:function(){var ae={};this.parent_div.find(":input").each(function(){var af=$(this).attr("name"),ag=$(this).val();ae[af]=JSON.stringify(ag)});return ae},get_param_values:function(){var af=[];var ae={};this.parent_div.find(":input").each(function(){var ag=$(this).attr("name"),ah=$(this).val();if(ag){af[af.length]=ah}});return af},run_on_dataset:function(){var ae=this;ae.run({dataset_id:this.track.original_dataset_id,tool_id:ae.name},null,function(af){show_modal(ae.name+" is Running",ae.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var ae={dataset_id:this.track.original_dataset_id,chrom:this.track.view.chrom,low:this.track.view.low,high:this.track.view.high,tool_id:this.name},ag=this.track,af=ae.tool_id+ag.tool_region_and_parameters_str(ae.chrom,ae.low,ae.high),ah;if(ag instanceof e){ah=new T(af,view,ag.hda_ldda,undefined,{},{},ag);ah.change_mode(ag.mode)}this.track.view.add_track(ah);ah.content_div.text("Starting job.");this.run(ae,ah,function(ai){ah.dataset_id=ai.dataset_id;ah.content_div.text("Running job.");ah.init()})},run:function(af,ag,ah){$.extend(af,this.get_param_values_dict());var ae=function(){$.getJSON(rerun_tool_url,af,function(ai){if(ai==="no converter"){ag.container_div.addClass("error");ag.content_div.text(I)}else{if(ai.error){ag.container_div.addClass("error");ag.content_div.text(x+ai.message)}else{if(ai==="pending"){ag.container_div.addClass("pending");ag.content_div.text("Converting input data so that it can be used quickly with tool.");setTimeout(ae,2000)}else{ah(ai)}}}})};ae()}});var M=function(af,ae,ag,ah){this.name=af;this.label=ae;this.html=ag;this.value=ah};var g=function(ag,af,ai,aj,ah,ae){M.call(this,ag,af,ai,aj);this.min=ah;this.max=ae};var h=function(af,ae,ag,ah){this.name=af;this.index=ae;this.tool_id=ag;this.tool_exp_name=ah};var U=function(af,ae,ag,ah){h.call(this,af,ae,ag,ah);this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.min=Number.MAX_VALUE;this.max=-Number.MAX_VALUE;this.container=null;this.slider=null;this.slider_label=null};p(U.prototype,{applies_to:function(ae){if(ae.length>this.index){return true}return false},keep:function(ae){if(!this.applies_to(ae)){return true}var af=parseFloat(ae[this.index]);return(isNaN(af)||(af>=this.low&&af<=this.high))},update_attrs:function(af){var ae=false;if(!this.applies_to(af)){return ae}if(af[this.index]<this.min){this.min=Math.floor(af[this.index]);ae=true}if(af[this.index]>this.max){this.max=Math.ceil(af[this.index]);ae=true}return ae},update_ui_elt:function(){if(this.min!=this.max){this.container.show()}else{this.container.hide()}var ag=function(aj,ah){var ai=ah-aj;return(ai<=2?0.01:1)};var af=this.slider.slider("option","min"),ae=this.slider.slider("option","max");if(this.min<af||this.max>ae){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",ag(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var Z=function(ao,av){this.track=ao;this.filters=[];for(var ap=0;ap<av.length;ap++){var aq=av[ap],aw=aq.name,ae=aq.type,ah=aq.index,au=aq.tool_id,at=aq.tool_exp_name;if(ae==="int"||ae==="float"){this.filters[ap]=new U(aw,ah,au,at)}else{console.log("ERROR: unsupported filter: ",aw,ae)}}var ai=function(ax,ay,az){ax.click(function(){var aA=ay.text();max=parseFloat(az.slider("option","max")),input_size=(max<=1?4:max<=1000000?max.toString().length:6),multi_value=false;if(az.slider("option","values")){input_size=2*input_size+1;multi_value=true}ay.text("");$("<input type='text'/>").attr("size",input_size).attr("maxlength",input_size).attr("value",aA).appendTo(ay).focus().select().click(function(aB){aB.stopPropagation()}).blur(function(){$(this).remove();ay.text(aA)}).keyup(function(aF){if(aF.keyCode===27){$(this).trigger("blur")}else{if(aF.keyCode===13){var aD=az.slider("option","min"),aB=az.slider("option","max"),aE=function(aG){return(isNaN(aG)||aG>aB||aG<aD)},aC=$(this).val();if(!multi_value){aC=parseFloat(aC);if(aE(aC)){alert("Parameter value must be in the range ["+aD+"-"+aB+"]");return $(this)}}else{aC=aC.split("-");aC=[parseFloat(aC[0]),parseFloat(aC[1])];if(aE(aC[0])||aE(aC[1])){alert("Parameter value must be in the range ["+aD+"-"+aB+"]");return $(this)}}az.slider((multi_value?"values":"value"),aC)}}})})};this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(ax){ax.stopPropagation()}).click(function(ax){ax.stopPropagation()}).bind("dblclick",function(ax){ax.stopPropagation()}).bind("keydown",function(ax){ax.stopPropagation()});var ar=$("<div/>").addClass("sliders").appendTo(this.parent_div);var am=this;$.each(this.filters,function(aA,aC){aC.container=$("<div/>").addClass("slider-row").appendTo(ar);var aB=$("<div/>").addClass("elt-label").appendTo(aC.container);var az=$("<span/>").addClass("slider-name").text(aC.name+" ").appendTo(aB);var ay=$("<span/>");var aE=$("<span/>").addClass("slider-value").appendTo(aB).append("[").append(ay).append("]");var ax=$("<div/>").addClass("slider").appendTo(aC.container);aC.control_element=$("<div/>").attr("id",aC.name+"-filter-control").appendTo(ax);var aD=[0,0];aC.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(aG,aH){var aF=aH.values;ay.text(aF[0]+"-"+aF[1]);aC.low=aF[0];aC.high=aF[1];am.track.request_draw(true,true)},change:function(aF,aG){aC.control_element.slider("option","slide").call(aC.control_element,aF,aG)}});aC.slider=aC.control_element;aC.slider_label=ay;ai(aE,ay,aC.control_element);$("<div style='clear: both;'/>").appendTo(aC.container)});if(this.filters.length!==0){var aj=$("<div/>").addClass("param-row").appendTo(ar);var al=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(aj);var ag=this;al.click(function(){ag.run_on_dataset()})}var an=$("<div/>").addClass("display-controls").appendTo(this.parent_div),ak=$("<span/>").addClass("elt-label").text("Transparency:").appendTo(an),af=$("<select/>").attr("name","alpha_dropdown").appendTo(an);this.alpha_filter=null;$("<option/>").attr("value",-1).text("== None ==").appendTo(af);for(var ap=0;ap<this.filters.length;ap++){$("<option/>").attr("value",ap).text(this.filters[ap].name).appendTo(af)}af.change(function(){$(this).children("option:selected").each(function(){var ax=parseInt($(this).val());am.alpha_filter=(ax>=0?am.filters[ax]:null);am.track.request_draw(true,true)})});$("<div style='clear: both;'/>").appendTo(this.parent_div)};p(Z.prototype,{reset_filters:function(){for(var ae=0;ae<this.filters.length;ae++){filter=this.filters[ae];filter.slider.slider("option","values",[filter.min,filter.max])}this.alpha_filter=null},run_on_dataset:function(){var am=function(aq,ao,ap){if(!(ao in aq)){aq[ao]=ap}return aq[ao]};var ag={},ae,af,ah;for(var ai=0;ai<this.filters.length;ai++){ae=this.filters[ai];if(ae.tool_id){if(ae.min!=ae.low){af=am(ag,ae.tool_id,[]);af[af.length]=ae.tool_exp_name+" >= "+ae.low}if(ae.max!=ae.high){af=am(ag,ae.tool_id,[]);af[af.length]=ae.tool_exp_name+" <= "+ae.high}}}var ak=[];for(var an in ag){ak[ak.length]=[an,ag[an]]}var al=ak.length;(function aj(av,ar){var ap=ar[0],aq=ap[0],au=ap[1],at="("+au.join(") and (")+")",ao={cond:at,input:av,target_dataset_id:av,tool_id:aq},ar=ar.slice(1);$.getJSON(run_tool_url,ao,function(aw){if(aw.error){show_modal("Filter Dataset","Error running tool "+aq,{Close:hide_modal})}else{if(ar.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{aj(aw.dataset_id,ar)}}})})(this.track.dataset_id,ak)}});var N=function(af,ae){K.AlphaGenerator.call(this,ae);this.filter=af};N.prototype.gen_alpha=function(ae){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_alpha}return((parseFloat(ae[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var Y=function(ae){this.track=ae.track;this.params=ae.params;this.values={};if(ae.saved_values){this.restore_values(ae.saved_values)}this.onchange=ae.onchange};p(Y.prototype,{restore_values:function(ae){var af=this;$.each(this.params,function(ag,ah){if(ae[ah.key]!==undefined){af.values[ah.key]=ae[ah.key]}else{af.values[ah.key]=ah.default_value}})},build_form:function(){var af=this;var ae=$("<div />");$.each(this.params,function(aj,ah){if(!ah.hidden){var ag="param_"+aj;var al=af.values[ah.key];var ao=$("<div class='form-row' />").appendTo(ae);ao.append($("<label />").attr("for",ag).text(ah.label+":"));if(ah.type==="bool"){ao.append($('<input type="checkbox" />').attr("id",ag).attr("name",ag).attr("checked",al))}else{if(ah.type==="text"){ao.append($('<input type="text"/>').attr("id",ag).val(al).click(function(){$(this).select()}))}else{if(ah.type==="color"){var ak=$("<input />").attr("id",ag).attr("name",ag).val(al);var am=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var ai=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(am);var an=$("<div/>").appendTo(ai).farbtastic({width:100,height:100,callback:ak,color:al});$("<div />").append(ak).append(am).appendTo(ao).bind("click",function(ap){am.css({left:$(this).position().left+($(ak).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){am.hide();$(document).unbind("click.color-picker")});ap.stopPropagation()})}else{ao.append($("<input />").attr("id",ag).attr("name",ag).val(al))}}}}});return ae},update_from_form:function(ae){var ag=this;var af=false;$.each(this.params,function(ah,aj){if(!aj.hidden){var ak="param_"+ah;var ai=ae.find("#"+ak).val();if(aj.type==="float"){ai=parseFloat(ai)}else{if(aj.type==="int"){ai=parseInt(ai)}else{if(aj.type==="bool"){ai=ae.find("#"+ak).is(":checked")}}}if(ai!==ag.values[aj.key]){ag.values[aj.key]=ai;af=true}}});if(af){this.onchange()}}});var b=function(ag,af,ae,ah){this.index=ag;this.low=ag*P*af;this.high=(ag+1)*P*af;this.resolution=af;this.canvas=$("<div class='track-tile'/>").append(ae);this.data=ah;this.stale=false};var l=function(ag,af,ae,ah,ai){b.call(this,ag,af,ae,ah);this.max_val=ai};var O=function(ag,af,ae,ai,ah){b.call(this,ag,af,ae,ai);this.message=ah};var o=function(af,ae){this.name=af;this.view=ae;this.parent_element=ae.viewport_container};o.prototype.request_draw=function(){};o.prototype.draw=function(){};var y=function(af,ae){o.call(this,af,ae);this.members=[];this.drag_handle_class="group-handle";this.container_div=$("<div/>").addClass("group").appendTo(this.parent_element);this.container_div.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("group-name").text(this.name).appendTo(this.container_div);this.content_div=$("<div/>").addClass("content-div").appendTo(this.container_div)};p(y.prototype,o.prototype,{request_draw:function(af,ae){},draw:function(){}});var j=function(af,ae,ai,ag,ah){this.name=af;this.view=ae;this.parent_element=ai;this.data_url=(ag?ag:default_data_url);this.data_url_extra_params={};this.data_query_wait=(ah?ah:J);this.dataset_check_url=converted_datasets_state_url;this.drag_handle_class="draghandle";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/>").addClass(this.drag_handle_class).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)};p(j.prototype,{get_type:function(){if(this instanceof aa){return"LabelTrack"}else{if(this instanceof A){return"ReferenceTrack"}else{if(this instanceof k){return"LineTrack"}else{if(this instanceof V){return"ReadTrack"}else{if(this instanceof T){return"ToolDataFeatureTrack"}else{if(this instanceof S){return"VcfTrack"}else{if(this instanceof e){return"FeatureTrack"}}}}}}}return""},init:function(){var ae=this;ae.enabled=false;ae.tile_cache.clear();ae.data_manager.clear();ae.initial_canvas=undefined;ae.content_div.css("height","auto");ae.container_div.removeClass("nodata error pending");if(!ae.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:ae.hda_ldda,dataset_id:ae.dataset_id,chrom:ae.view.chrom},function(af){if(!af||af==="error"||af.kind==="error"){ae.container_div.addClass("error");ae.content_div.text(n);if(af.message){var ah=ae.view.tracks.indexOf(ae);var ag=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+af.message+"</pre>",{Close:hide_modal})});ae.content_div.append(ag)}}else{if(af==="no converter"){ae.container_div.addClass("error");ae.content_div.text(I)}else{if(af==="no data"||(af.data!==undefined&&(af.data===null||af.data.length===0))){ae.container_div.addClass("nodata");ae.content_div.text(E)}else{if(af==="pending"){ae.container_div.addClass("pending");ae.content_div.text(s);setTimeout(function(){ae.init()},ae.data_query_wait)}else{if(af.status==="data"){if(af.valid_chroms){ae.valid_chroms=af.valid_chroms;ae.make_name_popup_menu()}ae.content_div.text(X);if(ae.view.chrom){ae.content_div.text("");ae.content_div.css("height",ae.height_px+"px");ae.enabled=true;$.when(ae.predraw_init()).done(function(){ae.container_div.removeClass("nodata error pending");ae.request_draw()})}}}}}}})},predraw_init:function(){},set_name:function(ae){this.old_name=this.name;this.name=ae;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var L=function(al,aj,am){var af=this,an=af.view;this.filters_manager=(al!==undefined?new Z(this,al):undefined);this.filters_available=false;this.filters_visible=false;this.tool=(aj!==undefined&&obj_length(aj)>0?new q(this,aj):undefined);this.is_overview=false;if(af.hidden){return}if(this.filters_manager){this.filters_div=this.filters_manager.parent_div;this.header_div.after(this.filters_div)}if(this.tool){this.dynamic_tool_div=this.tool.parent_div;this.header_div.after(this.dynamic_tool_div)}if(af.display_modes!==undefined){if(af.mode_div===undefined){af.mode_div=$("<div class='right-float menubutton popup' />").appendTo(af.header_div);var ag=(af.track_config&&af.track_config.values.mode?af.track_config.values.mode:af.display_modes[0]);af.mode=ag;af.mode_div.text(ag);var ae={};for(var ah=0,ak=af.display_modes.length;ah<ak;ah++){var ai=af.display_modes[ah];ae[ai]=function(ao){return function(){af.change_mode(ao)}}(ai)}make_popupmenu(af.mode_div,ae)}else{af.mode_div.hide()}}this.make_name_popup_menu()};p(L.prototype,j.prototype,{to_json:function(){return{track_type:this.get_type(),name:this.name,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,prefs:this.prefs}},change_mode:function(af){var ae=this;ae.mode_div.text(af);ae.mode=af;ae.track_config.values.mode=af;ae.tile_cache.clear();ae.request_draw()},make_name_popup_menu:function(){var af=this;var ae={};ae[(this.is_overview?"Hide overview":"Set as overview")]=function(){if(af.is_overview){af.view.reset_overview()}else{af.view.set_overview(af)}};ae["Edit configuration"]=function(){var aj=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},ah=function(){af.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},ai=function(ak){if((ak.keyCode||ak.which)===27){aj()}else{if((ak.keyCode||ak.which)===13){ah()}}};$(window).bind("keypress.check_enter_esc",ai);show_modal("Configure Track",af.track_config.build_form(),{Cancel:aj,OK:ah})};if(af.filters_available>0){var ag=(af.filters_div.is(":visible")?"Hide filters":"Show filters");ae[ag]=function(){af.filters_visible=(af.filters_div.is(":visible"));if(af.filters_visible){af.filters_manager.reset_filters()}af.filters_div.toggle();af.make_name_popup_menu()}}if(af.tool){var ag=(af.dynamic_tool_div.is(":visible")?"Hide tool":"Show tool");ae[ag]=function(){if(!af.dynamic_tool_div.is(":visible")){af.set_name(af.name+af.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";af.revert_name()}af.dynamic_tool_div.toggle();af.make_name_popup_menu()}}if(af.valid_chroms){ae["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+af.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}ae.Remove=function(){view.remove_track(af);if(parent_obj.num_tracks===0){$("#no-tracks").show()}};make_popupmenu(af.name_div,ae)},set_is_overview:function(ae){this.is_overview=ae;this.make_name_popup_menu()},get_overview_tile:function(){var ae=this;view=ae.view,resolution=Math.pow(C,Math.ceil(Math.log((view.max_high-view.max_low)/P)/Math.log(C))),view_width=view.container.width(),w_scale=view_width/(view.max_high-view.max_low),overview_tile=$.Deferred();$.when(ae.data_manager.get_data(view.max_low,view.max_high,"Auto",resolution,ae.data_url_extra_params)).then(function(af){var ah=ae._gen_tile_cache_key(view_width,w_scale,0),aj=ae.tile_cache.get(ah);if(!aj){aj=ae.draw_tile(af,"Auto",resolution,0,w_scale);ae.tile_cache.set(ah,aj)}var am=$(aj.canvas.find("canvas")),ai=am.clone(),al=am.get(0).getContext("2d"),ag=ai.get(0).getContext("2d"),ak=al.getImageData(0,0,al.canvas.width,al.canvas.height);ag.putImageData(ak,-ae.left_offset,(aj.data.dataset_type==="summary_tree"?R:0));new_tile=new b(-1,resolution,ai);overview_tile.resolve(new_tile)});return overview_tile},_gen_tile_cache_key:function(af,ag,ae){return af+"_"+ag+"_"+ae},request_draw:function(af,ae){this.view.request_redraw(false,af,ae,this)},_draw:function(ag,ao){if(!(this instanceof A)&&(!this.dataset_id)){return}var an=this.view.low,ak=this.view.high,al=ak-an,ah=this.view.container.width(),ar=ah/al,aj=this.view.resolution,aq=$("<div style='position: relative;'></div>");if(!ao){this.content_div.children().remove()}this.content_div.append(aq);this.max_height=0;var af=Math.floor(an/aj/P);var am=true;var ap=[];var ae=0;while((af*P*aj)<ak){tile=this.draw_helper(ag,ah,af,aj,aq,ar);if(tile){ap.push(tile)}else{am=false}af+=1;ae++}var ai=this;if(am){ai.postdraw_actions(ap,ah,ar,ao)}},postdraw_actions:function(ai,aj,ak,ae){var ag=this;var ah=false;for(var af=0;af<ai.length;af++){if(ai[af].message){ah=true;break}}if(ah){for(var af=0;af<ai.length;af++){tile=ai[af];if(!tile.message){tile.canvas.css("padding-top",D)}}}},draw_helper:function(af,ag,ah,ak,aq,av,ar,al){var ai=this,ap=this._gen_tile_cache_key(ag,av,ah),am=ah*P*ak,au=am+P*ak;var an=(af?undefined:ai.tile_cache.get(ap));if(an){ai.show_tile(an,aq,av);return an}var ao=function(aw){return("isResolved" in aw)};var aj=true;var ae=ai.data_manager.get_data(am,au,ai.mode,ak,ai.data_url_extra_params);if(ao(ae)){aj=false}var at;if(view.reference_track&&av>view.canvas_manager.char_width_px){at=view.reference_track.data_manager.get_data(am,au,ai.mode,ak,view.reference_track.data_url_extra_params);if(ao(at)){aj=false}}if(aj){p(ae,al);var an=ai.draw_tile(ae,ai.mode,ak,ah,av,at);ai.tile_cache.set(ap,an);if(an!==undefined){ai.show_tile(an,aq,av)}return an}$.when(ae,at).then(function(){view.request_redraw()});return null},show_tile:function(al,an,ao){var ag=this,af=al.canvas,ak=af;if(al.message){var ap=$("<div/>"),am=$("<div/>").addClass("tile-message").text(al.message).css({height:D-1,width:al.canvas.width}).appendTo(ap),ai=$("<a href='javascript:void(0);'/>").addClass("icon more-down").appendTo(am),ae=$("<a href='javascript:void(0);'/>").addClass("icon more-across").appendTo(am);ap.append(af);ak=ap;ai.click(function(){al.stale=true;ag.data_manager.get_more_data(al.low,al.high,ag.mode,al.resolution,{},ag.data_manager.DEEP_DATA_REQ);ag.request_draw()}).dblclick(function(aq){aq.stopPropagation()});ae.click(function(){al.stale=true;ag.data_manager.get_more_data(al.low,al.high,ag.mode,al.resolution,{},ag.data_manager.BROAD_DATA_REQ);ag.request_draw()}).dblclick(function(aq){aq.stopPropagation()})}var aj=this.view.high-this.view.low,ah=(al.low-this.view.low)*ao;if(this.left_offset){ah-=this.left_offset}ak.css({position:"absolute",top:0,left:ah,height:""});an.append(ak);ag.max_height=Math.max(ag.max_height,ak.height());ag.content_div.css("height",ag.max_height+"px");an.children().css("height",ag.max_height+"px")},_get_tile_bounds:function(ae,af){var ah=ae*P*af,ai=P*af,ag=(ah+ai<=this.view.max_high?ah+ai:this.view.max_high);return[ah,ag]},tool_region_and_parameters_str:function(ag,ae,ah){var af=this,ai=(ag!==undefined&&ae!==undefined&&ah!==undefined?ag+":"+ae+"-"+ah:"all");return" - region=["+ai+"], parameters=["+af.tool.get_param_values().join(", ")+"]"}});var aa=function(ae,af){this.hidden=true;j.call(this,null,ae,af);this.container_div.addClass("label-track")};p(aa.prototype,j.prototype,{_draw:function(){var ag=this.view,ah=ag.high-ag.low,ak=Math.floor(Math.pow(10,Math.floor(Math.log(ah)/Math.log(10)))),ae=Math.floor(ag.low/ak)*ak,ai=this.view.container.width(),af=$("<div style='position: relative; height: 1.3em;'></div>");while(ae<ag.high){var aj=(ae-ag.low)/ah*ai;af.append($("<div class='label'>"+commatize(ae)+"</div>").css({position:"absolute",left:aj-1}));ae+=ak}this.content_div.children(":first").remove();this.content_div.append(af)}});var A=function(ae){this.hidden=true;j.call(this,null,ae,ae.top_labeltrack);L.call(this);ae.reference_track=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_url=reference_url;this.data_url_extra_params={dbkey:ae.dbkey};this.data_manager=new G(B,this,false);this.tile_cache=new c(t)};p(A.prototype,L.prototype,{draw_tile:function(ao,ak,aj,af,ap){var ai=this,ag=P*aj;if(ap>this.view.canvas_manager.char_width_px){if(ao===null){ai.content_div.css("height","0px");return}var ah=this.view.canvas_manager.new_canvas();var an=ah.getContext("2d");ah.width=Math.ceil(ag*ap+ai.left_offset);ah.height=ai.height_px;an.font=an.canvas.manager.default_font;an.textAlign="center";ao=ao.data;for(var al=0,am=ao.length;al<am;al++){var ae=Math.round(al*ap);an.fillText(ao[al],ae+ai.left_offset,10)}return new b(af,aj,ah,ao)}this.content_div.css("height","0px")}});var k=function(ai,ag,aj,ae,ah){var af=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";j.call(this,ai,ag,ag.viewport_container);L.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=aj;this.dataset_id=ae;this.original_dataset_id=ae;this.data_manager=new Q(B,this);this.tile_cache=new c(t);this.left_offset=0;this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ai},{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:ah,onchange:function(){af.set_name(af.prefs.name);af.vertical_range=af.prefs.max_value-af.prefs.min_value;$("#linetrack_"+af.track_id+"_minval").text(af.prefs.min_value);$("#linetrack_"+af.track_id+"_maxval").text(af.prefs.max_value);af.tile_cache.clear();af.request_draw()}});this.prefs=this.track_config.values;this.height_px=this.track_config.values.height;this.vertical_range=this.track_config.values.max_value-this.track_config.values.min_value;this.add_resize_handle()};p(k.prototype,L.prototype,{add_resize_handle:function(){var ae=this;var ah=false;var ag=false;var af=$("<div class='track-resize'>");$(ae.container_div).hover(function(){ah=true;af.show()},function(){ah=false;if(!ag){af.hide()}});af.hide().bind("dragstart",function(ai,aj){ag=true;aj.original_height=$(ae.content_div).height()}).bind("drag",function(aj,ak){var ai=Math.min(Math.max(ak.original_height+ak.deltaY,ae.min_height_px),ae.max_height_px);$(ae.content_div).css("height",ai);ae.height_px=ai;ae.request_draw(true)}).bind("dragend",function(ai,aj){ae.tile_cache.clear();ag=false;if(!ah){af.hide()}ae.track_config.values.height=ae.height_px}).appendTo(ae.container_div)},predraw_init:function(){var ae=this,af=ae.view.tracks.indexOf(ae);ae.vertical_range=undefined;return $.getJSON(ae.data_url,{stats:true,chrom:ae.view.chrom,low:null,high:null,hda_ldda:ae.hda_ldda,dataset_id:ae.dataset_id},function(ag){ae.container_div.addClass("line-track");var ai=ag.data;if(isNaN(parseFloat(ae.prefs.min_value))||isNaN(parseFloat(ae.prefs.max_value))){ae.prefs.min_value=ai.min;ae.prefs.max_value=ai.max;$("#track_"+af+"_minval").val(ae.prefs.min_value);$("#track_"+af+"_maxval").val(ae.prefs.max_value)}ae.vertical_range=ae.prefs.max_value-ae.prefs.min_value;ae.total_frequency=ai.total_frequency;ae.container_div.find(".yaxislabel").remove();var aj=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+af+"_minval").text(w(ae.prefs.min_value));var ah=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+af+"_maxval").text(w(ae.prefs.max_value));ah.css({position:"absolute",top:"24px",left:"10px"});ah.prependTo(ae.container_div);aj.css({position:"absolute",bottom:"2px",left:"10px"});aj.prependTo(ae.container_div)})},draw_tile:function(aq,aj,ai,ag,ap){if(this.vertical_range===undefined){return}var ae=this._get_tile_bounds(ag,ai),ak=ae[0],ao=ae[1],af=Math.ceil((ao-ak)*ap),am=this.height_px;var ah=this.view.canvas_manager.new_canvas();ah.width=af,ah.height=am;var an=ah.getContext("2d");var al=new K.LinePainter(aq.data,ak,ao,this.prefs,aj);al.draw(an,af,am);return new b(ag,ai,ah,aq.data)}});var e=function(ae,aj,ai,am,al,ag,ah,ak){var af=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ae},{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},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:al,onchange:function(){af.set_name(af.prefs.name);af.tile_cache.clear();af.request_draw()}});this.prefs=this.track_config.values;j.call(this,ae,aj,aj.viewport_container);L.call(this,ag,ah,ak);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=ai;this.dataset_id=am;this.original_dataset_id=am;this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.inc_slots={};this.start_end_dct={};this.tile_cache=new c(d);this.data_manager=new Q(20,this);this.left_offset=200;this.painter=K.LinkedFeaturePainter};p(e.prototype,L.prototype,{postdraw_actions:function(au,ae,av,at){L.prototype.postdraw_actions.call(this,au,at);var ah=this;if(at){var aj=ah.content_div.children();var ak=false;for(var ai=aj.length-1,ao=0;ai>=ao;ai--){var ag=$(aj[ai]);if(ak){ag.remove()}else{if(ag.children().length!==0){ak=true}}}}if(ah.mode=="Histogram"){var an=-1;for(var ai=0;ai<au.length;ai++){var ar=au[ai].max_val;if(ar>an){an=ar}}for(var ai=0;ai<au.length;ai++){var aq=au[ai];if(aq.max_val!==an){aq.canvas.remove();ah.draw_helper(true,ae,aq.index,aq.resolution,aq.canvas.parent(),av,[],{max:an})}}}if(ah.filters_manager){var af=ah.filters_manager.filters;for(var am=0;am<af.length;am++){af[am].update_ui_elt()}var al=false,ap;for(var ai=0;ai<au.length;ai++){if(au[ai].data.length){ap=au[ai].data[0];for(var am=0;am<af.length;am++){if(af[am].applies_to(ap)){al=true;break}}}}if(ah.filters_available!==al){ah.filters_available=al;if(!ah.filters_available){ah.filters_div.hide()}ah.make_name_popup_menu()}}},update_auto_mode:function(ae){if(this.mode=="Auto"){if(ae=="no_detail"){ae="feature spans"}else{if(ae=="summary_tree"){ae="coverage histogram"}}this.mode_div.text("Auto ("+ae+")")}},incremental_slots:function(ai,af,ah){var ag=this.view.canvas_manager.dummy_context,ae=this.inc_slots[ai];if(!ae||(ae.mode!==ah)){ae=new (r.FeatureSlotter)(ai,ah==="Pack",z,function(aj){return ag.measureText(aj)});ae.mode=ah;this.inc_slots[ai]=ae}return ae.slot_features(af)},get_summary_tree_data:function(ai,al,ag,au){if(au>ag-al){au=ag-al}var ap=Math.floor((ag-al)/au),at=[],ah=0;var aj=0,ak=0,ao,ar=0,am=[],aq,an;var af=function(ax,aw,ay,av){ax[0]=aw+ay*av;ax[1]=aw+(ay+1)*av};while(ar<au&&aj!==ai.length){var ae=false;for(;ar<au&&!ae;ar++){af(am,al,ar,ap);for(ak=aj;ak<ai.length;ak++){ao=ai[ak].slice(1,3);if(is_overlap(ao,am)){ae=true;break}}if(ae){break}}data_start_index=ak;at[at.length]=aq=[am[0],0];for(;ak<ai.length;ak++){ao=ai[ak].slice(1,3);if(is_overlap(ao,am)){aq[1]++}else{break}}if(aq[1]>ah){ah=aq[1]}ar++}return{max:ah,delta:ap,data:at}},draw_tile:function(at,aw,aB,aF,ao,ah){var ay=this,aj=ay._get_tile_bounds(aF,aB),aH=aj[0],af=aj[1],av=af-aH,az=Math.ceil(av*ao),aL=25,ai=this.left_offset,au,ak;if(aw==="Auto"){if(at.dataset_type==="summary_tree"){aw=at.dataset_type}else{if(at.extra_info==="no_detail"){aw="no_detail"}else{var aK=at.data;if(this.view.high-this.view.low>H){aw="Squish"}else{aw="Pack"}}}this.update_auto_mode(aw)}if(aw==="summary_tree"||aw==="Histogram"){ak=this.summary_draw_height;this.container_div.find(".yaxislabel").remove();var ae=$("<div />").addClass("yaxislabel");ae.text(at.max);ae.css({position:"absolute",top:"24px",left:"10px",color:this.prefs.label_color});ae.prependTo(this.container_div);var ag=this.view.canvas_manager.new_canvas();ag.width=az+ai;ag.height=ak+R;if(at.dataset_type!="summary_tree"){var ap=this.get_summary_tree_data(at.data,aH,af,200);if(at.max){ap.max=at.max}at=ap}var aI=new K.SummaryTreePainter(at,aH,af,this.prefs);var aA=ag.getContext("2d");aA.translate(ai,R);aI.draw(aA,az,ak);return new l(aF,aB,ag,at.data,at.max)}var au,am=1;if(aw==="no_detail"||aw==="Squish"||aw==="Pack"){am=this.incremental_slots(ao,at.data,aw);au=this.inc_slots[ao].slots}var an=[];if(at.data){var aq=this.filters_manager.filters;for(var aC=0,aE=at.data.length;aC<aE;aC++){var al=at.data[aC];var aD=false;var ar;for(var aG=0,aJ=aq.length;aG<aJ;aG++){ar=aq[aG];ar.update_attrs(al);if(!ar.keep(al)){aD=true;break}}if(!aD){an.push(al)}}}var ax=(this.filters_manager.alpha_filter?new N(this.filters_manager.alpha_filter):null);var aI=new (this.painter)(an,aH,af,this.prefs,aw,ax,ah);var ak=Math.max(ac,aI.get_required_height(am));var ag=this.view.canvas_manager.new_canvas();ag.width=az+ai;ag.height=ak;var aA=ag.getContext("2d");aA.fillStyle=this.prefs.block_color;aA.font=aA.canvas.manager.default_font;aA.textAlign="right";this.container_div.find(".yaxislabel").remove();if(at.data){aA.translate(ai,0);aI.draw(aA,az,ak,au)}return new O(aF,aB,ag,at.data,at.message)}});var S=function(ah,af,aj,ae,ag,ai){e.call(this,ah,af,aj,ae,ag,ai);this.painter=K.VariantPainter};p(S.prototype,L.prototype,e.prototype);var V=function(ah,af,aj,ae,ag,ai){e.call(this,ah,af,aj,ae,ag,ai);this.track_config=new Y({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ah},{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:ag,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.track_config.values;this.painter=K.ReadPainter;this.make_name_popup_menu()};p(V.prototype,L.prototype,e.prototype);var T=function(ai,ag,ak,ae,ah,aj,af){e.call(this,ai,ag,ak,ae,ah,aj,{},af);this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};p(T.prototype,L.prototype,e.prototype,{predraw_init:function(){var af=this;var ae=function(){if(af.data_manager.size()===0){setTimeout(ae,300)}else{af.data_url=default_data_url;af.data_query_wait=J;af.dataset_state_url=converted_datasets_state_url;$.getJSON(af.dataset_state_url,{dataset_id:af.dataset_id,hda_ldda:af.hda_ldda},function(ag){})}};ae()}});W.View=ab;W.DrawableCollection=y;W.LineTrack=k;W.FeatureTrack=e;W.ReadTrack=V};var slotting_module=function(c,b){var e=c("class").extend;var d=2,a=5;b.FeatureSlotter=function(j,h,f,g){this.slots={};this.start_end_dct={};this.w_scale=j;this.include_label=h;this.max_rows=f;this.measureText=g};e(b.FeatureSlotter.prototype,{slot_features:function(m){var p=this.w_scale,s=this.slots,h=this.start_end_dct,y=[],A=[],n=0,z=this.max_rows;for(var w=0,x=m.length;w<x;w++){var l=m[w],o=l[0];if(s[o]!==undefined){n=Math.max(n,s[o]);A.push(s[o])}else{y.push(w)}}var q=function(G,H){for(var F=0;F<=z;F++){var D=false,I=h[F];if(I!==undefined){for(var C=0,E=I.length;C<E;C++){var B=I[C];if(H>B[0]&&G<B[1]){D=true;break}}}if(!D){return F}}return -1};for(var w=0,x=y.length;w<x;w++){var l=m[y[w]],o=l[0],u=l[1],f=l[2],r=l[3],g=Math.floor(u*p),k=Math.ceil(f*p),v=this.measureText(r).width,j;if(r!==undefined&&this.include_label){v+=(d+a);if(g-v>=0){g-=v;j="left"}else{k+=v;j="right"}}var t=q(g,k);if(t>=0){if(h[t]===undefined){h[t]=[]}h[t].push([g,k]);s[o]=t;n=Math.max(n,t)}else{}}return n+1}})};var painters_module=function(k,x){var u=k("class").extend;var p=function(I,A,G,z,F,D){if(D===undefined){D=4}var C=z-A;var B=F-G;var E=Math.floor(Math.sqrt(C*C+B*B)/D);var J=C/E;var H=B/E;var y;for(y=0;y<E;y++,A+=J,G+=H){if(y%2!==0){continue}I.fillRect(A,G,D,1)}};var q=function(B,A,z,E){var D=A-E/2,C=A+E/2,F=z-Math.sqrt(E*3/2);B.beginPath();B.moveTo(D,F);B.lineTo(C,F);B.lineTo(A,z);B.lineTo(D,F);B.strokeStyle=this.fillStyle;B.fill();B.stroke();B.closePath()};var g=function(y){this.default_alpha=(y?y:1)};g.prototype.gen_alpha=function(y){return this.default_alpha};var n=function(A,C,y,z,B){this.data=A;this.view_start=C;this.view_end=y;this.prefs=u({},this.default_prefs,z);this.mode=B};n.prototype.default_prefs={};var v=function(A,C,y,z,B){n.call(this,A,C,y,z,B)};v.prototype.default_prefs={show_counts:false};v.prototype.draw=function(M,z,L){var E=this.view_start,O=this.view_end-this.view_start,N=z/O;var J=this.data.data,I=this.data.delta,G=this.data.max,B=L;delta_x_px=Math.ceil(I*N);M.save();for(var C=0,D=J.length;C<D;C++){var H=Math.floor((J[C][0]-E)*N);var F=J[C][1];if(!F){continue}var K=F/G*L;if(F!==0&&K<1){K=1}M.fillStyle=this.prefs.block_color;M.fillRect(H,B-K,delta_x_px,K);var A=4;if(this.prefs.show_counts&&(M.measureText(F).width+A)<delta_x_px){M.fillStyle=this.prefs.label_color;M.textAlign="center";M.fillText(F,H+(delta_x_px/2),10)}}M.restore()};var c=function(y,C,E,F,A){n.call(this,y,C,E,F,A);if(this.prefs.min_value===undefined){var G=Infinity;for(var z=0,B=this.data.length;z<B;z++){G=Math.min(G,this.data[z][1])}this.prefs.min_value=G}if(this.prefs.max_value===undefined){var D=-Infinity;for(var z=0,B=this.data.length;z<B;z++){D=Math.max(D,this.data[z][1])}this.prefs.max_value=D}};c.prototype.default_prefs={min_value:undefined,max_value:undefined,mode:"Histogram",color:"#000",overflow_color:"#F66"};c.prototype.draw=function(N,M,K){var F=false,H=this.prefs.min_value,D=this.prefs.max_value,J=D-H,z=K,A=this.view_start,L=this.view_end-this.view_start,B=M/L,I=this.mode,T=this.data;N.save();var U=Math.round(K+H/J*K);if(I!=="Intensity"){N.fillStyle="#aaa";N.fillRect(0,U,M,1)}N.beginPath();var R,E,C;if(T.length>1){C=Math.ceil((T[1][0]-T[0][0])*B)}else{C=10}for(var O=0,P=T.length;O<P;O++){N.fillStyle=this.prefs.color;R=Math.round((T[O][0]-A)*B);E=T[O][1];var Q=false,G=false;if(E===null){if(F&&I==="Filled"){N.lineTo(R,z)}F=false;continue}if(E<H){G=true;E=H}else{if(E>D){Q=true;E=D}}if(I==="Histogram"){E=Math.round(E/J*z);N.fillRect(R,U,C,-E)}else{if(I==="Intensity"){E=255-Math.floor((E-H)/J*255);N.fillStyle="rgb("+E+","+E+","+E+")";N.fillRect(R,0,C,z)}else{E=Math.round(z-(E-H)/J*z);if(F){N.lineTo(R,E)}else{F=true;if(I==="Filled"){N.moveTo(R,z);N.lineTo(R,E)}else{N.moveTo(R,E)}}}}N.fillStyle=this.prefs.overflow_color;if(Q||G){var S;if(I==="Histogram"||I==="Intensity"){S=C}else{R-=2;S=4}if(Q){N.fillRect(R,0,S,3)}if(G){N.fillRect(R,z-3,S,3)}}N.fillStyle=this.prefs.color}if(I==="Filled"){if(F){N.lineTo(R,U);N.lineTo(0,U)}N.fill()}else{N.stroke()}N.restore()};var o=function(B,D,y,A,C,z){n.call(this,B,D,y,A,C);this.alpha_generator=(z?z:new g())};o.prototype.default_prefs={block_color:"#FFF",connector_color:"#FFF"};u(o.prototype,{get_required_height:function(z){var y=y_scale=this.get_row_height(),A=this.mode;if(A==="no_detail"||A==="Squish"||A==="Pack"){y=z*y_scale}return y+Math.max(Math.round(y_scale/2),5)},draw:function(K,B,J,G){var E=this.data,H=this.view_start,L=this.view_end;K.save();K.fillStyle=this.prefs.block_color;K.textAlign="right";var O=this.view_end-this.view_start,N=B/O,A=this.get_row_height();for(var D=0,F=E.length;D<F;D++){var M=E[D],C=M[0],y=M[1],z=M[2],I=(G&&G[C]!==undefined?G[C]:null);if((y<L&&z>H)&&(this.mode=="Dense"||I!==null)){this.draw_element(K,this.mode,M,I,H,L,N,A,B)}}K.restore()},draw_element:function(E,A,G,C,B,D,F,z,y){console.log("WARNING: Unimplemented function.")}});var d=10,j=3,m=5,w=10,f=1,s=3,e=3,a=9,l=2,h="#ccc";var r=function(B,D,y,A,C,z){o.call(this,B,D,y,A,C,z)};u(r.prototype,o.prototype,{get_row_height:function(){var z=this.mode,y;if(z==="Dense"){y=d}else{if(z==="no_detail"){y=j}else{if(z==="Squish"){y=m}else{y=w}}}return y},draw_element:function(K,D,S,F,M,ac,ag,ah,y){var P=S[0],ae=S[1],W=S[2],N=S[3],X=Math.floor(Math.max(0,(ae-M)*ag)),L=Math.ceil(Math.min(y,Math.max(0,(W-M)*ag))),V=(D==="Dense"?0:(0+F))*ah,J,aa,O=null,ai=null,B=this.prefs.block_color,Z=this.prefs.label_color;K.globalAlpha=this.alpha_generator.gen_alpha(S);if(D=="Dense"){F=1}if(D==="no_detail"){K.fillStyle=B;K.fillRect(X,V+5,L-X,f)}else{var I=S[4],U=S[5],Y=S[6],C=S[7];if(U&&Y){O=Math.floor(Math.max(0,(U-M)*ag));ai=Math.ceil(Math.min(y,Math.max(0,(Y-M)*ag)))}var af,Q;if(D==="Squish"||D==="Dense"){af=1;Q=e}else{af=5;Q=a}if(!C){if(S.strand){if(S.strand==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand_inv")}else{if(S.strand==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand_inv")}}}else{K.fillStyle=B}K.fillRect(X,V,L-X,Q)}else{var H,R;if(D==="Squish"||D==="Dense"){K.fillStyle=h;H=V+Math.floor(e/2)+1;R=1}else{if(I){var H=V;var R=Q;if(I==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand")}else{if(I==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand")}}}else{K.fillStyle=h;H+=(e/2)+1;R=1}}K.fillRect(X,H,L-X,R);for(var ad=0,A=C.length;ad<A;ad++){var E=C[ad],z=Math.floor(Math.max(0,(E[0]-M)*ag)),T=Math.ceil(Math.min(y,Math.max((E[1]-M)*ag)));if(z>T){continue}K.fillStyle=B;K.fillRect(z,V+(Q-af)/2+1,T-z,af);if(O!==undefined&&Y>U&&!(z>ai||T<O)){var ab=Math.max(z,O),G=Math.min(T,ai);K.fillRect(ab,V+1,G-ab,Q);if(C.length==1&&D=="Pack"){if(I==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand_inv")}else{if(I==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand_inv")}}if(ab+14<G){ab+=2;G-=2}K.fillRect(ab,V+1,G-ab,Q)}}}}if(D==="Pack"&&ae>M){K.fillStyle=Z;if(M===0&&X-K.measureText(N).width<0){K.textAlign="left";K.fillText(N,L+l,V+8)}else{K.textAlign="right";K.fillText(N,X-l,V+8)}}}K.globalAlpha=1}});var b=function(B,D,y,A,C,z){o.call(this,B,D,y,A,C,z)};u(b.prototype,o.prototype,{draw_element:function(R,M,G,C,U,A,J,S,P){var G=data[i],I=G[0],Q=G[1],B=G[2],L=G[3],E=Math.floor(Math.max(0,(Q-U)*J)),H=Math.ceil(Math.min(P,Math.max(0,(B-U)*J))),D=(M==="Dense"?0:(0+C))*S,y,V,z=null,K=null;if(no_label){R.fillStyle=block_color;R.fillRect(E+left_offset,D+5,H-E,1)}else{var T=G[4],O=G[5],F=G[6];y=9;V=1;R.fillRect(E+left_offset,D,H-E,y);if(M!=="Dense"&&L!==undefined&&Q>U){R.fillStyle=label_color;if(U===0&&E-R.measureText(L).width<0){R.textAlign="left";R.fillText(L,H+2+left_offset,D+8)}else{R.textAlign="right";R.fillText(L,E-2+left_offset,D+8)}R.fillStyle=block_color}var N=T+" / "+O;if(Q>U&&R.measureText(N).width<(H-E)){R.fillStyle="white";R.textAlign="center";R.fillText(N,left_offset+E+(H-E)/2,D+8);R.fillStyle=block_color}}}});var t=function(C,E,y,B,D,z,A){o.call(this,C,E,y,B,D,z);this.ref_seq=A};t.prototype.default_prefs=u({},o.prototype.default_prefs,{show_insertions:false});u(t.prototype,o.prototype,{get_row_height:function(){var y,z=this.mode;if(z==="Dense"){y=d}else{if(z==="Squish"){y=m}else{y=w;if(this.prefs.show_insertions){y*=2}}}return y},draw_read:function(U,P,L,Z,A,T,I,F,E){U.textAlign="center";var S=this,z=[Z,A],O=0,V=0,R=0;ref_seq=this.ref_seq,char_width_px=U.canvas.manager.char_width_px;var ae=[];if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){R=Math.round(L/2)}if(!I){I=[[0,F.length]]}for(var M=0,X=I.length;M<X;M++){var J=I[M],B="MIDNSHP=X"[J[0]],N=J[1];if(B==="H"||B==="S"){O-=N}var G=T+O,ad=Math.floor(Math.max(0,(G-Z)*L)),H=Math.floor(Math.max(0,(G+N-Z)*L));if(ad===H){H+=1}switch(B){case"H":break;case"S":case"M":case"=":if(is_overlap([G,G+N],z)){var Q=F.slice(V,V+N);if(R>0){U.fillStyle=this.prefs.block_color;U.fillRect(ad-R,E+1,H-ad,9);U.fillStyle=h;for(var ab=0,y=Q.length;ab<y;ab++){if(this.prefs.show_differences&&ref_seq){var K=ref_seq[G-Z+ab];if(!K||K.toLowerCase()===Q[ab].toLowerCase()){continue}}if(G+ab>=Z&&G+ab<=A){var ac=Math.floor(Math.max(0,(G+ab-Z)*L));U.fillText(Q[ab],ac,E+9)}}}else{U.fillStyle=this.prefs.block_color;U.fillRect(ad,E+4,H-ad,e)}}V+=N;O+=N;break;case"N":U.fillStyle=h;U.fillRect(ad-R,E+5,H-ad,1);O+=N;break;case"D":U.fillStyle="red";U.fillRect(ad-R,E+4,H-ad,3);O+=N;break;case"P":break;case"I":var Y=ad-R;if(is_overlap([G,G+N],z)){var Q=F.slice(V,V+N);if(this.prefs.show_insertions){var D=ad-(H-ad)/2;if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){U.fillStyle="yellow";U.fillRect(D-R,E-9,H-ad,9);ae[ae.length]={type:"triangle",data:[Y,E+4,5]};U.fillStyle=h;switch(seq_tile_overlap){case (OVERLAP_START):Q=Q.slice(Z-G);break;case (OVERLAP_END):Q=Q.slice(0,G-A);break;case (CONTAINED_BY):break;case (CONTAINS):Q=Q.slice(Z-G,G-A);break}for(var ab=0,y=Q.length;ab<y;ab++){var ac=Math.floor(Math.max(0,(G+ab-Z)*L));U.fillText(Q[ab],ac-(H-ad)/2,E)}}else{U.fillStyle="yellow";U.fillRect(D,E+(this.mode!=="Dense"?2:5),H-ad,(P!=="Dense"?e:s))}}else{if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){ae[ae.length]={type:"text",data:[Q.length,Y,E+9]}}else{}}}V+=N;break;case"X":V+=N;break}}U.fillStyle="yellow";var aa,C,af;for(var W=0;W<ae.length;W++){aa=ae[W];C=aa.type;af=aa.data;if(C==="text"){U.save();U.font="bold "+U.font;U.fillText(af[0],af[1],af[2]);U.restore()}else{if(C=="triangle"){q(U,af[0],af[1],af[2])}}}},draw_element:function(R,M,E,B,U,z,I,S,P){var H=E[0],Q=E[1],A=E[2],J=E[3],D=Math.floor(Math.max(0,(Q-U)*I)),F=Math.ceil(Math.min(P,Math.max(0,(A-U)*I))),C=(M==="Dense"?0:(0+B))*S,V=this.prefs.block_color,G=this.prefs.label_color,O=0;if((M==="Pack"||this.mode==="Auto")&&I>R.canvas.manager.char_width_px){var O=Math.round(I/2)}R.fillStyle=V;if(E[5] instanceof Array){var N=Math.floor(Math.max(0,(E[4][0]-U)*I)),L=Math.ceil(Math.min(P,Math.max(0,(E[4][1]-U)*I))),K=Math.floor(Math.max(0,(E[5][0]-U)*I)),y=Math.ceil(Math.min(P,Math.max(0,(E[5][1]-U)*I)));if(E[4][1]>=U&&E[4][0]<=z&&E[4][2]){this.draw_read(R,M,I,U,z,E[4][0],E[4][2],E[4][3],C)}if(E[5][1]>=U&&E[5][0]<=z&&E[5][2]){this.draw_read(R,M,I,U,z,E[5][0],E[5][2],E[5][3],C)}if(K>L){R.fillStyle=h;p(R,L-O,C+5,K-O,C+5)}}else{R.fillStyle=V;this.draw_read(R,M,I,U,z,Q,E[4],E[5],C)}if(M==="Pack"&&Q>U){R.fillStyle=this.prefs.label_color;var T=1;if(T===0&&D-R.measureText(J).width<0){R.textAlign="left";R.fillText(J,F+l-O,C+8)}else{R.textAlign="right";R.fillText(J,D-l-O,C+8)}R.fillStyle=V}}});x.AlphaGenerator=g;x.SummaryTreePainter=v;x.LinePainter=c;x.LinkedFeaturePainter=r;x.ReadPainter=t;x.VariantPainter=b};(function(d){var c={};var b=function(e){return c[e]};var a=function(f,g){var e={};g(b,e);c[f]=e};a("class",class_module);a("slotting",slotting_module);a("painters",painters_module);a("trackster",trackster_module);for(key in c.trackster){d[key]=c.trackster[key]}})(window);
\ No newline at end of file
+var class_module=function(b,a){var c=function(){var f=arguments[0];for(var e=1;e<arguments.length;e++){var d=arguments[e];for(key in d){f[key]=d[key]}}return f};a.extend=c};var requestAnimationFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(b,a){window.setTimeout(b,1000/60)}})();var BEFORE=1001,CONTAINS=1002,OVERLAP_START=1003,OVERLAP_END=1004,CONTAINED_BY=1005,AFTER=1006;var compute_overlap=function(e,b){var g=e[0],f=e[1],d=b[0],c=b[1],a;if(g<d){if(f<d){a=BEFORE}else{if(f<=c){a=OVERLAP_START}else{a=CONTAINS}}}else{if(g>c){a=AFTER}else{if(f<=c){a=CONTAINED_BY}else{a=OVERLAP_END}}}return a};var is_overlap=function(c,b){var a=compute_overlap(c,b);return(a!==BEFORE&&a!==AFTER)};var trackster_module=function(f,Z){var q=f("class").extend,t=f("slotting"),M=f("painters");var ag=function(ah,ai){this.document=ah;this.default_font=ai!==undefined?ai:"9px Monaco, Lucida Console, monospace";this.dummy_canvas=this.new_canvas();this.dummy_context=this.dummy_canvas.getContext("2d");this.dummy_context.font=this.default_font;this.char_width_px=this.dummy_context.measureText("A").width;this.patterns={};this.load_pattern("right_strand","/visualization/strand_right.png");this.load_pattern("left_strand","/visualization/strand_left.png");this.load_pattern("right_strand_inv","/visualization/strand_right_inv.png");this.load_pattern("left_strand_inv","/visualization/strand_left_inv.png")};q(ag.prototype,{load_pattern:function(ah,al){var ai=this.patterns,aj=this.dummy_context,ak=new Image();ak.src=image_path+al;ak.onload=function(){ai[ah]=aj.createPattern(ak,"repeat")}},get_pattern:function(ah){return this.patterns[ah]},new_canvas:function(){var ah=this.document.createElement("canvas");if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(ah)}ah.manager=this;return ah}});var o={};var m=function(ah,ai){o[ah.attr("id")]=ai};var n=function(ah,aj,al,ak){al=".group";var ai={};o[ah.attr("id")]=ak;ah.bind("drag",{handle:"."+aj,relative:true},function(au,av){var at=$(this);var ay=$(this).parent(),ap=ay.children(),ar=o[$(this).attr("id")],ao,an,aw,am,aq;an=$(this).parents(al);if(an.length!==0){aw=an.position().top;am=aw+an.outerHeight();if(av.offsetY<aw){$(this).insertBefore(an);var ax=o[an.attr("id")];ax.remove_drawable(ar);ax.container.add_drawable_before(ar,ax);return}else{if(av.offsetY>am){$(this).insertAfter(an);var ax=o[an.attr("id")];ax.remove_drawable(ar);ax.container.add_drawable(ar);return}}}an=null;for(aq=0;aq<ap.length;aq++){ao=$(ap.get(aq));aw=ao.position().top;am=aw+ao.outerHeight();if(ao.is(al)&&this!==ao.get(0)&&av.offsetY>=aw&&av.offsetY<=am){if(av.offsetY-aw<am-av.offsetY){ao.find(".content-div").prepend(this)}else{ao.find(".content-div").append(this)}ar.container.remove_drawable(ar);o[ao.attr("id")].add_drawable(ar);return}}for(aq=0;aq<ap.length;aq++){if(av.offsetY<$(ap.get(aq)).position().top){break}}if(aq===ap.length){if(this!==ap.get(aq-1)){ay.append(this);o[ay.attr("id")].move_drawable(ar,aq)}}else{if(this!==ap.get(aq)){$(this).insertBefore(ap.get(aq));o[ay.attr("id")].move_drawable(ar,(av.deltaY>0?aq-1:aq))}}}).bind("dragstart",function(){ai["border-top"]=ah.css("border-top");ai["border-bottom"]=ah.css("border-bottom");$(this).css({"border-top":"1px solid blue","border-bottom":"1px solid blue"})}).bind("dragend",function(){$(this).css(ai)})};Z.moveable=n;var af=16,H=9,F=20,U=H+2,B=100,J=12000,S=200,E=5,w=10,L=5000,x=100,p="There was an error in indexing this dataset. ",K="A converter for this dataset is not installed. Please check your datatypes_conf.xml file.",G="No data for this chrom/contig.",u="Currently indexing... please wait",z="Tool cannot be rerun: ",a="Loading data...",aa="Ready for display",d=10,v=5,D=5;function y(ah){return Math.round(ah*1000)/1000}var c=function(ah){this.num_elements=ah;this.clear()};q(c.prototype,{get:function(ai){var ah=this.key_ary.indexOf(ai);if(ah!==-1){if(this.obj_cache[ai].stale){this.key_ary.splice(ah,1);delete this.obj_cache[ai]}else{this.move_key_to_end(ai,ah)}}return this.obj_cache[ai]},set:function(ai,aj){if(!this.obj_cache[ai]){if(this.key_ary.length>=this.num_elements){var ah=this.key_ary.shift();delete this.obj_cache[ah]}this.key_ary.push(ai)}this.obj_cache[ai]=aj;return aj},move_key_to_end:function(ai,ah){this.key_ary.splice(ah,1);this.key_ary.push(ai)},clear:function(){this.obj_cache={};this.key_ary=[]},size:function(){return this.key_ary.length}});var T=function(ai,ah,aj){c.call(this,ai);this.track=ah;this.subset=(aj!==undefined?aj:true)};q(T.prototype,c.prototype,{load_data:function(aq,al,ao,ai,an){var ap=this.track.view.chrom,ak={chrom:ap,low:aq,high:al,mode:ao,resolution:ai,dataset_id:this.track.dataset_id,hda_ldda:this.track.hda_ldda};$.extend(ak,an);if(this.track.filters_manager){var ar=[];var ah=this.track.filters_manager.filters;for(var am=0;am<ah.length;am++){ar[ar.length]=ah[am].name}ak.filter_cols=JSON.stringify(ar)}var aj=this;return $.getJSON(this.track.data_url,ak,function(at){aj.set_data(aq,al,ao,at)})},get_data:function(ah,al,am,ai,ak){var aj=this.get_data_from_cache(ah,al,am);if(aj){return aj}aj=this.load_data(ah,al,am,ai,ak);this.set_data(ah,al,am,aj);return aj},DEEP_DATA_REQ:"deep",BROAD_DATA_REQ:"breadth",get_more_data:function(ap,ak,ao,aj,an,al){var aq=this.get_data_from_cache(ap,ak,ao);if(!aq){console.log("ERROR: no current data for: ",this.track,ap,ak,ao,aj,an);return}aq.stale=true;var ai=ap;if(al===this.DEEP_DATA_REQ){$.extend(an,{start_val:aq.data.length+1})}else{if(al===this.BROAD_DATA_REQ){ai=(aq.max_high?aq.max_high:aq.data[aq.data.length-1][2])+1}}var ah=this,am=this.load_data(ai,ak,ao,aj,an);new_data_available=$.Deferred();this.set_data(ap,ak,ao,new_data_available);$.when(am).then(function(ar){if(ar.data){ar.data=aq.data.concat(ar.data);if(ar.max_low){ar.max_low=aq.max_low}if(ar.message){ar.message=ar.message.replace(/[0-9]+/,ar.data.length)}}ah.set_data(ap,ak,ao,ar);new_data_available.resolve(ar)});return new_data_available},get_data_from_cache:function(ah,ai,aj){return this.get(this.gen_key(ah,ai,aj))},set_data:function(ai,aj,ak,ah){return this.set(this.gen_key(ai,aj,ak),ah)},gen_key:function(ah,aj,ak){var ai=ah+"_"+aj+"_"+ak;return ai},split_key:function(ah){return ah.split("_")}});var I=function(ai,ah,aj){T.call(this,ai,ah,aj)};q(I.prototype,T.prototype,c.prototype,{load_data:function(aj,ah,al,am,ai,ak){if(ai>1){return}return T.prototype.load_data.call(this,aj,ah,al,am,ai,ak)}});var r=function(aj,ai,ak,ah){this.name=aj;this.view=ai;this.parent_element=ak;this.container=ah};r.prototype.request_draw=function(){};r.prototype.draw=function(){};var A=function(aj,ai,ak,ah){r.call(this,aj,ai,ak,ah);this.drawables=[]};q(A.prototype,r.prototype,{to_json:function(){var ai=[];for(var ah=0;ah<this.drawables.length;ah++){}},add_drawable:function(ah){this.drawables.push(ah);ah.container=this},add_drawable_before:function(aj,ah){var ai=this.drawables.indexOf(ah);if(ai!=-1){this.drawables.splice(ai,0,aj);return true}return false},remove_drawable:function(ai){var ah=this.drawables.indexOf(ai);if(ah!=-1){this.drawables.splice(ah,1);ai.container=null;return true}return false},move_drawable:function(ai,aj){var ah=this.drawables.indexOf(ai);if(ah!=-1){this.drawables.splice(ah,1);this.drawables.splice(aj,0,ai);return true}return false}});var R=function(aj,ai,ak,ah){A.call(this,aj,ai,ak,ah);this.drag_handle_class="group-handle";this.container_div=$("<div/>").addClass("group").appendTo(this.parent_element);this.container_div.append($("<div/>").addClass(this.drag_handle_class));this.name_div=$("<div/>").addClass("group-name").text(this.name).appendTo(this.container_div);this.content_div=$("<div/>").addClass("content-div").appendTo(this.container_div);m(this.container_div,this)};q(R.prototype,A.prototype,r.prototype);var ae=function(ah,ak,aj,ai,al){A.call(this);this.container=ah;this.chrom=null;this.vis_id=aj;this.dbkey=ai;this.title=ak;this.tracks=this.drawables;this.label_tracks=[];this.tracks_to_be_redrawn=[];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(al);this.canvas_manager=new ag(ah.get(0).ownerDocument);this.reset()};q(ae.prototype,A.prototype,{init:function(al){var aj=this.container,ah=this;this.top_container=$("<div/>").addClass("top-container").appendTo(aj);this.content_div=$("<div/>").addClass("content").css("position","relative").appendTo(aj);this.bottom_container=$("<div/>").addClass("bottom-container").appendTo(aj);this.top_labeltrack=$("<div/>").addClass("top-labeltrack").appendTo(this.top_container);this.viewport_container=$("<div/>").addClass("viewport-container").attr("id","viewport-container").appendTo(this.content_div);m(this.viewport_container,ah);this.intro_div=$("<div/>").addClass("intro");var ak=$("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function(){add_tracks()});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_select=$("<select/>").attr({name:"chrom"}).css("width","15em").addClass("no-autocomplete").append("<option value=''>Loading</option>").appendTo(this.nav_controls);var ai=function(am){if(am.type==="focusout"||(am.keyCode||am.which)===13||(am.keyCode||am.which)===27){if((am.keyCode||am.which)!==27){ah.go_to($(this).val())}$(this).hide();$(this).val("");ah.location_span.show();ah.chrom_select.show()}};this.nav_input=$("<input/>").addClass("nav-input").hide().bind("keyup focusout",ai).appendTo(this.nav_controls);this.location_span=$("<span/>").addClass("location").appendTo(this.nav_controls);this.location_span.click(function(){ah.location_span.hide();ah.chrom_select.hide();ah.nav_input.val(ah.chrom+":"+ah.low+"-"+ah.high);ah.nav_input.css("display","inline-block");ah.nav_input.select();ah.nav_input.focus()});if(this.vis_id!==undefined){this.hidden_input=$("<input/>").attr("type","hidden").val(this.vis_id).appendTo(this.nav_controls)}this.zo_link=$("<a id='zoom-out' />").click(function(){ah.zoom_out();ah.request_redraw()}).appendTo(this.nav_controls);this.zi_link=$("<a id='zoom-in' />").click(function(){ah.zoom_in();ah.request_redraw()}).appendTo(this.nav_controls);this.load_chroms({low:0},al);this.chrom_select.bind("change",function(){ah.change_chrom(ah.chrom_select.val())});this.content_div.click(function(am){$(this).find("input").trigger("blur")});this.content_div.bind("dblclick",function(am){ah.zoom_in(am.pageX,this.viewport_container)});this.overview_box.bind("dragstart",function(am,an){this.current_x=an.offsetX}).bind("drag",function(am,ao){var ap=ao.offsetX-this.current_x;this.current_x=ao.offsetX;var an=Math.round(ap/ah.viewport_container.width()*(ah.max_high-ah.max_low));ah.move_delta(-an)});this.overview_close.click(function(){ah.reset_overview()});this.viewport_container.bind("draginit",function(am,an){if(am.clientX>ah.viewport_container.width()-16){return false}}).bind("dragstart",function(am,an){an.original_low=ah.low;an.current_height=am.clientY;an.current_x=an.offsetX}).bind("drag",function(ao,aq){var am=$(this);var ar=aq.offsetX-aq.current_x;var an=am.scrollTop()-(ao.clientY-aq.current_height);am.scrollTop(an);aq.current_height=ao.clientY;aq.current_x=aq.offsetX;var ap=Math.round(ar/ah.viewport_container.width()*(ah.high-ah.low));ah.move_delta(ap)}).bind("mousewheel",function(ao,aq,an,am){if(an){var ap=Math.round(-an/ah.viewport_container.width()*(ah.high-ah.low));ah.move_delta(ap)}});this.top_labeltrack.bind("dragstart",function(am,an){return $("<div />").css({height:ah.content_div.height()+ah.top_labeltrack.height()+ah.nav_labeltrack.height()+1,top:"0px",position:"absolute","background-color":"#ccf",opacity:0.5,"z-index":1000}).appendTo($(this))}).bind("drag",function(aq,ar){$(ar.proxy).css({left:Math.min(aq.pageX,ar.startX),width:Math.abs(aq.pageX-ar.startX)});var an=Math.min(aq.pageX,ar.startX)-ah.container.offset().left,am=Math.max(aq.pageX,ar.startX)-ah.container.offset().left,ap=(ah.high-ah.low),ao=ah.viewport_container.width();ah.update_location(Math.round(an/ao*ap)+ah.low,Math.round(am/ao*ap)+ah.low)}).bind("dragend",function(ar,at){var an=Math.min(ar.pageX,at.startX),am=Math.max(ar.pageX,at.startX),ap=(ah.high-ah.low),ao=ah.viewport_container.width(),aq=ah.low;ah.low=Math.round(an/ao*ap)+aq;ah.high=Math.round(am/ao*ap)+aq;$(at.proxy).remove();ah.request_redraw()});this.add_label_track(new ad(this,this.top_labeltrack));this.add_label_track(new ad(this,this.nav_labeltrack));$(window).bind("resize",function(){ah.resize_window()});$(document).bind("redraw",function(){ah.redraw()});this.reset();$(window).trigger("resize");this.update_intro_div()},to_json:function(){var ah=this,ai=[];this.viewport_container.children(".track,.group").each(function(){var aj=$(this).attr("id");aj=parseInt(aj.slice(aj.lastIndexOf("_")+1));ai.push(ah.tracks[aj].to_json())});return ai},update_intro_div:function(){if(this.num_tracks===0){this.intro_div.appendTo(this.viewport_container)}else{this.intro_div.remove()}},update_location:function(ah,ai){this.location_span.text(commatize(ah)+" - "+commatize(ai));this.nav_input.val(this.chrom+":"+commatize(ah)+"-"+commatize(ai))},load_chroms:function(ai,aj){ai.num=x;$.extend(ai,(this.vis_id!==undefined?{vis_id:this.vis_id}:{dbkey:this.dbkey}));var ah=this;$.ajax({url:chrom_url,data:ai,dataType:"json",success:function(al){if(al.chrom_info.length===0){alert("Invalid chromosome: "+ai.chrom);return}if(al.reference){ah.add_label_track(new C(ah))}ah.chrom_data=al.chrom_info;var ao='<option value="">Select Chrom/Contig</option>';for(var an=0,ak=ah.chrom_data.length;an<ak;an++){var am=ah.chrom_data[an].chrom;ao+='<option value="'+am+'">'+am+"</option>"}if(al.prev_chroms){ao+='<option value="previous">Previous '+x+"</option>"}if(al.next_chroms){ao+='<option value="next">Next '+x+"</option>"}ah.chrom_select.html(ao);if(aj){aj()}ah.chrom_start_index=al.start_index},error:function(){alert("Could not load chroms for this dbkey:",ah.dbkey)}})},change_chrom:function(al,ai,an){if(!al||al==="None"){return}var ak=this;if(al==="previous"){ak.load_chroms({low:this.chrom_start_index-x});return}if(al==="next"){ak.load_chroms({low:this.chrom_start_index+x});return}var am=$.grep(ak.chrom_data,function(ap,aq){return ap.chrom===al})[0];if(am===undefined){ak.load_chroms({chrom:al},function(){ak.change_chrom(al,ai,an)});return}else{if(al!==ak.chrom){ak.chrom=al;ak.chrom_select.val(ak.chrom);ak.max_high=am.len-1;ak.reset();ak.request_redraw(true);for(var ao=0,ah=ak.tracks.length;ao<ah;ao++){var aj=ak.tracks[ao];if(aj.init){aj.init()}}}if(ai!==undefined&&an!==undefined){ak.low=Math.max(ai,0);ak.high=Math.min(an,ak.max_high)}ak.reset_overview();ak.request_redraw()}},go_to:function(al){var ap=this,ah,ak,ai=al.split(":"),an=ai[0],ao=ai[1];if(ao!==undefined){try{var am=ao.split("-");ah=parseInt(am[0].replace(/,/g,""),10);ak=parseInt(am[1].replace(/,/g,""),10)}catch(aj){return false}}ap.change_chrom(an,ah,ak)},move_fraction:function(aj){var ah=this;var ai=ah.high-ah.low;this.move_delta(aj*ai)},move_delta:function(aj){var ah=this;var ai=ah.high-ah.low;if(ah.low-aj<ah.max_low){ah.low=ah.max_low;ah.high=ah.max_low+ai}else{if(ah.high-aj>ah.max_high){ah.high=ah.max_high;ah.low=ah.max_high-ai}else{ah.high-=aj;ah.low-=aj}}ah.request_redraw()},add_track:function(ah){ah.view=this;ah.track_id=this.track_id_counter;this.tracks.push(ah);if(ah.init){ah.init()}ah.container_div.attr("id","track_"+ah.track_id);n(ah.container_div,ah.drag_handle_class,".group",ah);this.track_id_counter+=1;this.num_tracks+=1;this.has_changes=true;this.update_intro_div()},add_label_track:function(ah){ah.view=this;this.label_tracks.push(ah)},remove_track:function(ai){this.has_changes=true;this.tracks.splice(this.tracks.indexOf(ai),1);this.num_tracks-=1;var ah=this;ai.container_div.fadeOut("slow",function(){$(this).remove();ah.update_intro_div()})},reset:function(){this.low=this.max_low;this.high=this.max_high;this.viewport_container.find(".yaxislabel").remove()},request_redraw:function(ap,ah,ao,ai){var an=this,al=(ai?[ai]:an.tracks),aj;var ai;for(var am=0;am<al.length;am++){ai=al[am];aj=-1;for(var ak=0;ak<an.tracks_to_be_redrawn.length;ak++){if(an.tracks_to_be_redrawn[ak][0]===ai){aj=ak;break}}if(aj<0){an.tracks_to_be_redrawn.push([ai,ah,ao])}else{an.tracks_to_be_redrawn[am][1]=ah;an.tracks_to_be_redrawn[am][2]=ao}}requestAnimationFrame(function(){an._redraw(ap)})},_redraw:function(ar){var ao=this.low,ak=this.high;if(ao<this.max_low){ao=this.max_low}if(ak>this.max_high){ak=this.max_high}var aq=this.high-this.low;if(this.high!==0&&aq<this.min_separation){ak=ao+this.min_separation}this.low=Math.floor(ao);this.high=Math.ceil(ak);this.resolution=Math.pow(E,Math.ceil(Math.log((this.high-this.low)/S)/Math.log(E)));this.zoom_res=Math.pow(w,Math.max(0,Math.ceil(Math.log(this.resolution,w)/Math.log(w))));var ah=(this.low/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var an=((this.high-this.low)/(this.max_high-this.max_low)*this.overview_viewport.width())||0;var at=13;this.overview_box.css({left:ah,width:Math.max(at,an)}).show();if(an<at){this.overview_box.css("left",ah-(at-an)/2)}if(this.overview_highlight){this.overview_highlight.css({left:ah,width:an})}this.update_location(this.low,this.high);if(!ar){var aj,ai,ap;for(var al=0,am=this.tracks_to_be_redrawn.length;al<am;al++){aj=this.tracks_to_be_redrawn[al][0];ai=this.tracks_to_be_redrawn[al][1];ap=this.tracks_to_be_redrawn[al][2];if(aj&&aj.enabled){aj._draw(ai,ap)}}this.tracks_to_be_redrawn=[];for(al=0,am=this.label_tracks.length;al<am;al++){this.label_tracks[al]._draw()}}},zoom_in:function(ai,aj){if(this.max_high===0||this.high-this.low<this.min_separation){return}var ak=this.high-this.low,al=ak/2+this.low,ah=(ak/this.zoom_factor)/2;if(ai){al=ai/this.viewport_container.width()*(this.high-this.low)+this.low}this.low=Math.round(al-ah);this.high=Math.round(al+ah);this.request_redraw()},zoom_out:function(){if(this.max_high===0){return}var ai=this.high-this.low,aj=ai/2+this.low,ah=(ai*this.zoom_factor)/2;this.low=Math.round(aj-ah);this.high=Math.round(aj+ah);this.request_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.request_redraw()},set_overview:function(ah){$.when(ah.get_overview_tile()).then(function(ai){view.overview_viewport.find(".track-tile").remove();view.overview_close.show();view.overview_viewport.append(ai.canvas);view.overview_highlight.show().height(ai.canvas.height());view.overview_viewport.height(ai.canvas.height()+view.overview_box.outerHeight());view.resize_window();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=ah;ah.set_is_overview(true)});view.has_changes=true},reset_overview:function(){this.overview_viewport.find(".track-tile").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();view.resize_window();if(view.overview_track){view.overview_track.set_is_overview(false)}view.overview_track=null}});var s=function(aj,an){this.track=aj;this.name=an.name;this.params=[];var av=an.params;for(var ak=0;ak<av.length;ak++){var ap=av[ak],ai=ap.name,au=ap.label,al=unescape(ap.html),aw=ap.value,ar=ap.type;if(ar==="number"){this.params[this.params.length]=new g(ai,au,al,aw,ap.min,ap.max)}else{if(ar=="select"){this.params[this.params.length]=new O(ai,au,al,aw)}else{console.log("WARNING: unrecognized tool parameter type:",ai,ar)}}}this.parent_div=$("<div/>").addClass("dynamic-tool").hide();this.parent_div.bind("drag",function(ay){ay.stopPropagation()}).click(function(ay){ay.stopPropagation()}).bind("dblclick",function(ay){ay.stopPropagation()});var at=$("<div class='tool-name'>").appendTo(this.parent_div).text(this.name);var aq=this.params;var ao=this;$.each(this.params,function(az,aC){var aB=$("<div>").addClass("param-row").appendTo(ao.parent_div);var ay=$("<div>").addClass("param-label").text(aC.label).appendTo(aB);var aA=$("<div/>").addClass("slider").html(aC.html).appendTo(aB);aA.find(":input").val(aC.value);$("<div style='clear: both;'/>").appendTo(aB)});this.parent_div.find("input").click(function(){$(this).select()});var ax=$("<div>").addClass("param-row").appendTo(this.parent_div);var am=$("<input type='submit'>").attr("value","Run on complete dataset").appendTo(ax);var ah=$("<input type='submit'>").attr("value","Run on visible region").css("margin-left","3em").appendTo(ax);var ao=this;ah.click(function(){var ay=this.track.parent_element,az=new A("New Group",ay);ao.run_on_region()});am.click(function(){ao.run_on_dataset()})};q(s.prototype,{get_param_values_dict:function(){var ah={};this.parent_div.find(":input").each(function(){var ai=$(this).attr("name"),aj=$(this).val();ah[ai]=JSON.stringify(aj)});return ah},get_param_values:function(){var ai=[];var ah={};this.parent_div.find(":input").each(function(){var aj=$(this).attr("name"),ak=$(this).val();if(aj){ai[ai.length]=ak}});return ai},run_on_dataset:function(){var ah=this;ah.run({dataset_id:this.track.original_dataset_id,tool_id:ah.name},null,function(ai){show_modal(ah.name+" is Running",ah.name+" is running on the complete dataset. Tool outputs are in dataset's history.",{Close:hide_modal})})},run_on_region:function(){var ah={dataset_id:this.track.original_dataset_id,chrom:this.track.view.chrom,low:this.track.view.low,high:this.track.view.high,tool_id:this.name},aj=this.track,ai=ah.tool_id+aj.tool_region_and_parameters_str(ah.chrom,ah.low,ah.high),ak;if(aj instanceof e){ak=new W(ai,view,aj.hda_ldda,undefined,{},{},aj);ak.change_mode(aj.mode)}this.track.view.add_track(ak);ak.content_div.text("Starting job.");this.run(ah,ak,function(al){ak.dataset_id=al.dataset_id;ak.content_div.text("Running job.");ak.init()})},run:function(ai,aj,ak){$.extend(ai,this.get_param_values_dict());var ah=function(){$.getJSON(rerun_tool_url,ai,function(al){if(al==="no converter"){aj.container_div.addClass("error");aj.content_div.text(K)}else{if(al.error){aj.container_div.addClass("error");aj.content_div.text(z+al.message)}else{if(al==="pending"){aj.container_div.addClass("pending");aj.content_div.text("Converting input data so that it can be used quickly with tool.");setTimeout(ah,2000)}else{ak(al)}}}})};ah()}});var O=function(ai,ah,aj,ak){this.name=ai;this.label=ah;this.html=aj;this.value=ak};var g=function(aj,ai,al,am,ak,ah){O.call(this,aj,ai,al,am);this.min=ak;this.max=ah};var h=function(ai,ah,aj,ak){this.name=ai;this.index=ah;this.tool_id=aj;this.tool_exp_name=ak};var X=function(ai,ah,aj,ak){h.call(this,ai,ah,aj,ak);this.low=-Number.MAX_VALUE;this.high=Number.MAX_VALUE;this.min=Number.MAX_VALUE;this.max=-Number.MAX_VALUE;this.container=null;this.slider=null;this.slider_label=null};q(X.prototype,{applies_to:function(ah){if(ah.length>this.index){return true}return false},keep:function(ah){if(!this.applies_to(ah)){return true}var ai=parseFloat(ah[this.index]);return(isNaN(ai)||(ai>=this.low&&ai<=this.high))},update_attrs:function(ai){var ah=false;if(!this.applies_to(ai)){return ah}if(ai[this.index]<this.min){this.min=Math.floor(ai[this.index]);ah=true}if(ai[this.index]>this.max){this.max=Math.ceil(ai[this.index]);ah=true}return ah},update_ui_elt:function(){if(this.min!=this.max){this.container.show()}else{this.container.hide()}var aj=function(am,ak){var al=ak-am;return(al<=2?0.01:1)};var ai=this.slider.slider("option","min"),ah=this.slider.slider("option","max");if(this.min<ai||this.max>ah){this.slider.slider("option","min",this.min);this.slider.slider("option","max",this.max);this.slider.slider("option","step",aj(this.min,this.max));this.slider.slider("option","values",[this.min,this.max])}}});var ac=function(ar,ay){this.track=ar;this.filters=[];for(var at=0;at<ay.length;at++){var au=ay[at],az=au.name,ah=au.type,ak=au.index,ax=au.tool_id,aw=au.tool_exp_name;if(ah==="int"||ah==="float"){this.filters[at]=new X(az,ak,ax,aw)}else{console.log("ERROR: unsupported filter: ",az,ah)}}var al=function(aA,aB,aC){aA.click(function(){var aD=aB.text();max=parseFloat(aC.slider("option","max")),input_size=(max<=1?4:max<=1000000?max.toString().length:6),multi_value=false;if(aC.slider("option","values")){input_size=2*input_size+1;multi_value=true}aB.text("");$("<input type='text'/>").attr("size",input_size).attr("maxlength",input_size).attr("value",aD).appendTo(aB).focus().select().click(function(aE){aE.stopPropagation()}).blur(function(){$(this).remove();aB.text(aD)}).keyup(function(aI){if(aI.keyCode===27){$(this).trigger("blur")}else{if(aI.keyCode===13){var aG=aC.slider("option","min"),aE=aC.slider("option","max"),aH=function(aJ){return(isNaN(aJ)||aJ>aE||aJ<aG)},aF=$(this).val();if(!multi_value){aF=parseFloat(aF);if(aH(aF)){alert("Parameter value must be in the range ["+aG+"-"+aE+"]");return $(this)}}else{aF=aF.split("-");aF=[parseFloat(aF[0]),parseFloat(aF[1])];if(aH(aF[0])||aH(aF[1])){alert("Parameter value must be in the range ["+aG+"-"+aE+"]");return $(this)}}aC.slider((multi_value?"values":"value"),aF)}}})})};this.parent_div=$("<div/>").addClass("filters").hide();this.parent_div.bind("drag",function(aA){aA.stopPropagation()}).click(function(aA){aA.stopPropagation()}).bind("dblclick",function(aA){aA.stopPropagation()}).bind("keydown",function(aA){aA.stopPropagation()});var av=$("<div/>").addClass("sliders").appendTo(this.parent_div);var ap=this;$.each(this.filters,function(aD,aF){aF.container=$("<div/>").addClass("slider-row").appendTo(av);var aE=$("<div/>").addClass("elt-label").appendTo(aF.container);var aC=$("<span/>").addClass("slider-name").text(aF.name+" ").appendTo(aE);var aB=$("<span/>");var aH=$("<span/>").addClass("slider-value").appendTo(aE).append("[").append(aB).append("]");var aA=$("<div/>").addClass("slider").appendTo(aF.container);aF.control_element=$("<div/>").attr("id",aF.name+"-filter-control").appendTo(aA);var aG=[0,0];aF.control_element.slider({range:true,min:Number.MAX_VALUE,max:-Number.MIN_VALUE,values:[0,0],slide:function(aJ,aK){var aI=aK.values;aB.text(aI[0]+"-"+aI[1]);aF.low=aI[0];aF.high=aI[1];ap.track.request_draw(true,true)},change:function(aI,aJ){aF.control_element.slider("option","slide").call(aF.control_element,aI,aJ)}});aF.slider=aF.control_element;aF.slider_label=aB;al(aH,aB,aF.control_element);$("<div style='clear: both;'/>").appendTo(aF.container)});if(this.filters.length!==0){var am=$("<div/>").addClass("param-row").appendTo(av);var ao=$("<input type='submit'/>").attr("value","Run on complete dataset").appendTo(am);var aj=this;ao.click(function(){aj.run_on_dataset()})}var aq=$("<div/>").addClass("display-controls").appendTo(this.parent_div),an=$("<span/>").addClass("elt-label").text("Transparency:").appendTo(aq),ai=$("<select/>").attr("name","alpha_dropdown").appendTo(aq);this.alpha_filter=null;$("<option/>").attr("value",-1).text("== None ==").appendTo(ai);for(var at=0;at<this.filters.length;at++){$("<option/>").attr("value",at).text(this.filters[at].name).appendTo(ai)}ai.change(function(){$(this).children("option:selected").each(function(){var aA=parseInt($(this).val());ap.alpha_filter=(aA>=0?ap.filters[aA]:null);ap.track.request_draw(true,true)})});$("<div style='clear: both;'/>").appendTo(this.parent_div)};q(ac.prototype,{reset_filters:function(){for(var ah=0;ah<this.filters.length;ah++){filter=this.filters[ah];filter.slider.slider("option","values",[filter.min,filter.max])}this.alpha_filter=null},run_on_dataset:function(){var ap=function(au,ar,at){if(!(ar in au)){au[ar]=at}return au[ar]};var aj={},ah,ai,ak;for(var al=0;al<this.filters.length;al++){ah=this.filters[al];if(ah.tool_id){if(ah.min!=ah.low){ai=ap(aj,ah.tool_id,[]);ai[ai.length]=ah.tool_exp_name+" >= "+ah.low}if(ah.max!=ah.high){ai=ap(aj,ah.tool_id,[]);ai[ai.length]=ah.tool_exp_name+" <= "+ah.high}}}var an=[];for(var aq in aj){an[an.length]=[aq,aj[aq]]}var ao=an.length;(function am(ay,av){var at=av[0],au=at[0],ax=at[1],aw="("+ax.join(") and (")+")",ar={cond:aw,input:ay,target_dataset_id:ay,tool_id:au},av=av.slice(1);$.getJSON(run_tool_url,ar,function(az){if(az.error){show_modal("Filter Dataset","Error running tool "+au,{Close:hide_modal})}else{if(av.length===0){show_modal("Filtering Dataset","Filter(s) are running on the complete dataset. Outputs are in dataset's history.",{Close:hide_modal})}else{am(az.dataset_id,av)}}})})(this.track.dataset_id,an)}});var P=function(ai,ah){M.AlphaGenerator.call(this,ah);this.filter=ai};P.prototype.gen_alpha=function(ah){if(this.filter.high===Number.MAX_VALUE||this.filter.low===-Number.MAX_VALUE||this.filter.low===this.filter.high){return this.default_alpha}return((parseFloat(ah[this.filter.index])-this.filter.low)/(this.filter.high-this.filter.low))};var ab=function(ah){this.track=ah.track;this.params=ah.params;this.values={};if(ah.saved_values){this.restore_values(ah.saved_values)}this.onchange=ah.onchange};q(ab.prototype,{restore_values:function(ah){var ai=this;$.each(this.params,function(aj,ak){if(ah[ak.key]!==undefined){ai.values[ak.key]=ah[ak.key]}else{ai.values[ak.key]=ak.default_value}})},build_form:function(){var ai=this;var ah=$("<div />");$.each(this.params,function(am,ak){if(!ak.hidden){var aj="param_"+am;var ao=ai.values[ak.key];var ar=$("<div class='form-row' />").appendTo(ah);ar.append($("<label />").attr("for",aj).text(ak.label+":"));if(ak.type==="bool"){ar.append($('<input type="checkbox" />').attr("id",aj).attr("name",aj).attr("checked",ao))}else{if(ak.type==="text"){ar.append($('<input type="text"/>').attr("id",aj).val(ao).click(function(){$(this).select()}))}else{if(ak.type==="color"){var an=$("<input />").attr("id",aj).attr("name",aj).val(ao);var ap=$("<div class='tipsy tipsy-north' style='position: absolute;' />").hide();var al=$("<div style='background-color: black; padding: 10px;'></div>").appendTo(ap);var aq=$("<div/>").appendTo(al).farbtastic({width:100,height:100,callback:an,color:ao});$("<div />").append(an).append(ap).appendTo(ar).bind("click",function(at){ap.css({left:$(this).position().left+($(an).width()/2)-60,top:$(this).position().top+$(this.height)}).show();$(document).bind("click.color-picker",function(){ap.hide();$(document).unbind("click.color-picker")});at.stopPropagation()})}else{ar.append($("<input />").attr("id",aj).attr("name",aj).val(ao))}}}}});return ah},update_from_form:function(ah){var aj=this;var ai=false;$.each(this.params,function(ak,am){if(!am.hidden){var an="param_"+ak;var al=ah.find("#"+an).val();if(am.type==="float"){al=parseFloat(al)}else{if(am.type==="int"){al=parseInt(al)}else{if(am.type==="bool"){al=ah.find("#"+an).is(":checked")}}}if(al!==aj.values[am.key]){aj.values[am.key]=al;ai=true}}});if(ai){this.onchange()}}});var b=function(aj,ai,ah,ak){this.index=aj;this.low=aj*S*ai;this.high=(aj+1)*S*ai;this.resolution=ai;this.canvas=$("<div class='track-tile'/>").append(ah);this.data=ak;this.stale=false};var l=function(aj,ai,ah,ak,al){b.call(this,aj,ai,ah,ak);this.max_val=al};var Q=function(aj,ai,ah,al,ak){b.call(this,aj,ai,ah,al);this.message=ak};var j=function(ai,ah,al,aj,ak){r.call(this,ai,ah,al,ah);this.data_url=(aj?aj:default_data_url);this.data_url_extra_params={};this.data_query_wait=(ak?ak:L);this.dataset_check_url=converted_datasets_state_url;this.drag_handle_class="draghandle";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/>").addClass(this.drag_handle_class).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)};q(j.prototype,{get_type:function(){if(this instanceof ad){return"LabelTrack"}else{if(this instanceof C){return"ReferenceTrack"}else{if(this instanceof k){return"LineTrack"}else{if(this instanceof Y){return"ReadTrack"}else{if(this instanceof W){return"ToolDataFeatureTrack"}else{if(this instanceof V){return"VcfTrack"}else{if(this instanceof e){return"FeatureTrack"}}}}}}}return""},init:function(){var ah=this;ah.enabled=false;ah.tile_cache.clear();ah.data_manager.clear();ah.initial_canvas=undefined;ah.content_div.css("height","auto");ah.container_div.removeClass("nodata error pending");if(!ah.dataset_id){return}$.getJSON(converted_datasets_state_url,{hda_ldda:ah.hda_ldda,dataset_id:ah.dataset_id,chrom:ah.view.chrom},function(ai){if(!ai||ai==="error"||ai.kind==="error"){ah.container_div.addClass("error");ah.content_div.text(p);if(ai.message){var ak=ah.view.tracks.indexOf(ah);var aj=$(" <a href='javascript:void(0);'></a>").text("View error").click(function(){show_modal("Trackster Error","<pre>"+ai.message+"</pre>",{Close:hide_modal})});ah.content_div.append(aj)}}else{if(ai==="no converter"){ah.container_div.addClass("error");ah.content_div.text(K)}else{if(ai==="no data"||(ai.data!==undefined&&(ai.data===null||ai.data.length===0))){ah.container_div.addClass("nodata");ah.content_div.text(G)}else{if(ai==="pending"){ah.container_div.addClass("pending");ah.content_div.text(u);setTimeout(function(){ah.init()},ah.data_query_wait)}else{if(ai.status==="data"){if(ai.valid_chroms){ah.valid_chroms=ai.valid_chroms;ah.make_name_popup_menu()}ah.content_div.text(aa);if(ah.view.chrom){ah.content_div.text("");ah.content_div.css("height",ah.height_px+"px");ah.enabled=true;$.when(ah.predraw_init()).done(function(){ah.container_div.removeClass("nodata error pending");ah.request_draw()})}}}}}}})},predraw_init:function(){},set_name:function(ah){this.old_name=this.name;this.name=ah;this.name_div.text(this.name)},revert_name:function(){this.name=this.old_name;this.name_div.text(this.name)}});var N=function(ao,am,ap){var ai=this,aq=ai.view;this.filters_manager=(ao!==undefined?new ac(this,ao):undefined);this.filters_available=false;this.filters_visible=false;this.tool=(am!==undefined&&obj_length(am)>0?new s(this,am):undefined);this.is_overview=false;if(ai.hidden){return}if(this.filters_manager){this.filters_div=this.filters_manager.parent_div;this.header_div.after(this.filters_div)}if(this.tool){this.dynamic_tool_div=this.tool.parent_div;this.header_div.after(this.dynamic_tool_div)}if(ai.display_modes!==undefined){if(ai.mode_div===undefined){ai.mode_div=$("<div class='right-float menubutton popup' />").appendTo(ai.header_div);var aj=(ai.track_config&&ai.track_config.values.mode?ai.track_config.values.mode:ai.display_modes[0]);ai.mode=aj;ai.mode_div.text(aj);var ah={};for(var ak=0,an=ai.display_modes.length;ak<an;ak++){var al=ai.display_modes[ak];ah[al]=function(ar){return function(){ai.change_mode(ar)}}(al)}make_popupmenu(ai.mode_div,ah)}else{ai.mode_div.hide()}}this.make_name_popup_menu()};q(N.prototype,j.prototype,{to_json:function(){return{track_type:this.get_type(),name:this.name,hda_ldda:this.hda_ldda,dataset_id:this.dataset_id,prefs:this.prefs}},change_mode:function(ai){var ah=this;ah.mode_div.text(ai);ah.mode=ai;ah.track_config.values.mode=ai;ah.tile_cache.clear();ah.request_draw()},make_name_popup_menu:function(){var ai=this;var ah={};ah[(this.is_overview?"Hide overview":"Set as overview")]=function(){if(ai.is_overview){ai.view.reset_overview()}else{ai.view.set_overview(ai)}};ah["Edit configuration"]=function(){var am=function(){hide_modal();$(window).unbind("keypress.check_enter_esc")},ak=function(){ai.track_config.update_from_form($(".dialog-box"));hide_modal();$(window).unbind("keypress.check_enter_esc")},al=function(an){if((an.keyCode||an.which)===27){am()}else{if((an.keyCode||an.which)===13){ak()}}};$(window).bind("keypress.check_enter_esc",al);show_modal("Configure Track",ai.track_config.build_form(),{Cancel:am,OK:ak})};if(ai.filters_available>0){var aj=(ai.filters_div.is(":visible")?"Hide filters":"Show filters");ah[aj]=function(){ai.filters_visible=(ai.filters_div.is(":visible"));if(ai.filters_visible){ai.filters_manager.reset_filters()}ai.filters_div.toggle();ai.make_name_popup_menu()}}if(ai.tool){var aj=(ai.dynamic_tool_div.is(":visible")?"Hide tool":"Show tool");ah[aj]=function(){if(!ai.dynamic_tool_div.is(":visible")){ai.set_name(ai.name+ai.tool_region_and_parameters_str())}else{menu_option_text="Show dynamic tool";ai.revert_name()}ai.dynamic_tool_div.toggle();ai.make_name_popup_menu()}}if(ai.valid_chroms){ah["List chrom/contigs with data"]=function(){show_modal("Chrom/contigs with data","<p>"+ai.valid_chroms.join("<br/>")+"</p>",{Close:function(){hide_modal()}})}}ah.Remove=function(){view.remove_track(ai);if(parent_obj.num_tracks===0){$("#no-tracks").show()}};make_popupmenu(ai.name_div,ah)},set_is_overview:function(ah){this.is_overview=ah;this.make_name_popup_menu()},get_overview_tile:function(){var ah=this;view=ah.view,resolution=Math.pow(E,Math.ceil(Math.log((view.max_high-view.max_low)/S)/Math.log(E))),view_width=view.container.width(),w_scale=view_width/(view.max_high-view.max_low),overview_tile=$.Deferred();$.when(ah.data_manager.get_data(view.max_low,view.max_high,"Auto",resolution,ah.data_url_extra_params)).then(function(ai){var ak=ah._gen_tile_cache_key(view_width,w_scale,0),am=ah.tile_cache.get(ak);if(!am){am=ah.draw_tile(ai,"Auto",resolution,0,w_scale);ah.tile_cache.set(ak,am)}var ap=$(am.canvas.find("canvas")),al=ap.clone(),ao=ap.get(0).getContext("2d"),aj=al.get(0).getContext("2d"),an=ao.getImageData(0,0,ao.canvas.width,ao.canvas.height);aj.putImageData(an,-ah.left_offset,(am.data.dataset_type==="summary_tree"?U:0));new_tile=new b(-1,resolution,al);overview_tile.resolve(new_tile)});return overview_tile},_gen_tile_cache_key:function(ai,aj,ah){return ai+"_"+aj+"_"+ah},request_draw:function(ai,ah){this.view.request_redraw(false,ai,ah,this)},_draw:function(aj,ar){if(!(this instanceof C)&&(!this.dataset_id)){return}var aq=this.view.low,an=this.view.high,ao=an-aq,ak=this.view.container.width(),av=ak/ao,am=this.view.resolution,au=$("<div style='position: relative;'></div>");if(!ar){this.content_div.children().remove()}this.content_div.append(au);this.max_height=0;var ai=Math.floor(aq/am/S);var ap=true;var at=[];var ah=0;while((ai*S*am)<an){tile=this.draw_helper(aj,ak,ai,am,au,av);if(tile){at.push(tile)}else{ap=false}ai+=1;ah++}var al=this;if(ap){al.postdraw_actions(at,ak,av,ar)}},postdraw_actions:function(al,am,an,ah){var aj=this;var ak=false;for(var ai=0;ai<al.length;ai++){if(al[ai].message){ak=true;break}}if(ak){for(var ai=0;ai<al.length;ai++){tile=al[ai];if(!tile.message){tile.canvas.css("padding-top",F)}}}},draw_helper:function(ai,aj,ak,an,au,ay,av,ao){var al=this,at=this._gen_tile_cache_key(aj,ay,ak),ap=ak*S*an,ax=ap+S*an;var aq=(ai?undefined:al.tile_cache.get(at));if(aq){al.show_tile(aq,au,ay);return aq}var ar=function(az){return("isResolved" in az)};var am=true;var ah=al.data_manager.get_data(ap,ax,al.mode,an,al.data_url_extra_params);if(ar(ah)){am=false}var aw;if(view.reference_track&&ay>view.canvas_manager.char_width_px){aw=view.reference_track.data_manager.get_data(ap,ax,al.mode,an,view.reference_track.data_url_extra_params);if(ar(aw)){am=false}}if(am){q(ah,ao);var aq=al.draw_tile(ah,al.mode,an,ak,ay,aw);al.tile_cache.set(at,aq);if(aq!==undefined){al.show_tile(aq,au,ay)}return aq}$.when(ah,aw).then(function(){view.request_redraw()});return null},show_tile:function(ao,aq,ar){var aj=this,ai=ao.canvas,an=ai;if(ao.message){var at=$("<div/>"),ap=$("<div/>").addClass("tile-message").text(ao.message).css({height:F-1,width:ao.canvas.width}).appendTo(at),al=$("<a href='javascript:void(0);'/>").addClass("icon more-down").appendTo(ap),ah=$("<a href='javascript:void(0);'/>").addClass("icon more-across").appendTo(ap);at.append(ai);an=at;al.click(function(){ao.stale=true;aj.data_manager.get_more_data(ao.low,ao.high,aj.mode,ao.resolution,{},aj.data_manager.DEEP_DATA_REQ);aj.request_draw()}).dblclick(function(au){au.stopPropagation()});ah.click(function(){ao.stale=true;aj.data_manager.get_more_data(ao.low,ao.high,aj.mode,ao.resolution,{},aj.data_manager.BROAD_DATA_REQ);aj.request_draw()}).dblclick(function(au){au.stopPropagation()})}var am=this.view.high-this.view.low,ak=(ao.low-this.view.low)*ar;if(this.left_offset){ak-=this.left_offset}an.css({position:"absolute",top:0,left:ak,height:""});aq.append(an);aj.max_height=Math.max(aj.max_height,an.height());aj.content_div.css("height",aj.max_height+"px");aq.children().css("height",aj.max_height+"px")},_get_tile_bounds:function(ah,ai){var ak=ah*S*ai,al=S*ai,aj=(ak+al<=this.view.max_high?ak+al:this.view.max_high);return[ak,aj]},tool_region_and_parameters_str:function(aj,ah,ak){var ai=this,al=(aj!==undefined&&ah!==undefined&&ak!==undefined?aj+":"+ah+"-"+ak:"all");return" - region=["+al+"], parameters=["+ai.tool.get_param_values().join(", ")+"]"}});var ad=function(ah,ai){this.hidden=true;j.call(this,null,ah,ai);this.container_div.addClass("label-track")};q(ad.prototype,j.prototype,{_draw:function(){var aj=this.view,ak=aj.high-aj.low,an=Math.floor(Math.pow(10,Math.floor(Math.log(ak)/Math.log(10)))),ah=Math.floor(aj.low/an)*an,al=this.view.container.width(),ai=$("<div style='position: relative; height: 1.3em;'></div>");while(ah<aj.high){var am=(ah-aj.low)/ak*al;ai.append($("<div class='label'>"+commatize(ah)+"</div>").css({position:"absolute",left:am-1}));ah+=an}this.content_div.children(":first").remove();this.content_div.append(ai)}});var C=function(ah){this.hidden=true;j.call(this,null,ah,ah.top_labeltrack);N.call(this);ah.reference_track=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_url=reference_url;this.data_url_extra_params={dbkey:ah.dbkey};this.data_manager=new I(D,this,false);this.tile_cache=new c(v)};q(C.prototype,N.prototype,{draw_tile:function(ar,an,am,ai,at){var al=this,aj=S*am;if(at>this.view.canvas_manager.char_width_px){if(ar===null){al.content_div.css("height","0px");return}var ak=this.view.canvas_manager.new_canvas();var aq=ak.getContext("2d");ak.width=Math.ceil(aj*at+al.left_offset);ak.height=al.height_px;aq.font=aq.canvas.manager.default_font;aq.textAlign="center";ar=ar.data;for(var ao=0,ap=ar.length;ao<ap;ao++){var ah=Math.round(ao*at);aq.fillText(ar[ao],ah+al.left_offset,10)}return new b(ai,am,ak,ar)}this.content_div.css("height","0px")}});var k=function(al,aj,am,ah,ak){var ai=this;this.display_modes=["Histogram","Line","Filled","Intensity"];this.mode="Histogram";j.call(this,al,aj,aj.viewport_container);N.call(this);this.min_height_px=16;this.max_height_px=400;this.height_px=80;this.hda_ldda=am;this.dataset_id=ah;this.original_dataset_id=ah;this.data_manager=new T(D,this);this.tile_cache=new c(v);this.left_offset=0;this.track_config=new ab({track:this,params:[{key:"name",label:"Name",type:"text",default_value:al},{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:ak,onchange:function(){ai.set_name(ai.prefs.name);ai.vertical_range=ai.prefs.max_value-ai.prefs.min_value;$("#linetrack_"+ai.track_id+"_minval").text(ai.prefs.min_value);$("#linetrack_"+ai.track_id+"_maxval").text(ai.prefs.max_value);ai.tile_cache.clear();ai.request_draw()}});this.prefs=this.track_config.values;this.height_px=this.track_config.values.height;this.vertical_range=this.track_config.values.max_value-this.track_config.values.min_value;this.add_resize_handle()};q(k.prototype,N.prototype,{add_resize_handle:function(){var ah=this;var ak=false;var aj=false;var ai=$("<div class='track-resize'>");$(ah.container_div).hover(function(){ak=true;ai.show()},function(){ak=false;if(!aj){ai.hide()}});ai.hide().bind("dragstart",function(al,am){aj=true;am.original_height=$(ah.content_div).height()}).bind("drag",function(am,an){var al=Math.min(Math.max(an.original_height+an.deltaY,ah.min_height_px),ah.max_height_px);$(ah.content_div).css("height",al);ah.height_px=al;ah.request_draw(true)}).bind("dragend",function(al,am){ah.tile_cache.clear();aj=false;if(!ak){ai.hide()}ah.track_config.values.height=ah.height_px}).appendTo(ah.container_div)},predraw_init:function(){var ah=this,ai=ah.view.tracks.indexOf(ah);ah.vertical_range=undefined;return $.getJSON(ah.data_url,{stats:true,chrom:ah.view.chrom,low:null,high:null,hda_ldda:ah.hda_ldda,dataset_id:ah.dataset_id},function(aj){ah.container_div.addClass("line-track");var al=aj.data;if(isNaN(parseFloat(ah.prefs.min_value))||isNaN(parseFloat(ah.prefs.max_value))){ah.prefs.min_value=al.min;ah.prefs.max_value=al.max;$("#track_"+ai+"_minval").val(ah.prefs.min_value);$("#track_"+ai+"_maxval").val(ah.prefs.max_value)}ah.vertical_range=ah.prefs.max_value-ah.prefs.min_value;ah.total_frequency=al.total_frequency;ah.container_div.find(".yaxislabel").remove();var am=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+ai+"_minval").text(y(ah.prefs.min_value));var ak=$("<div />").addClass("yaxislabel").attr("id","linetrack_"+ai+"_maxval").text(y(ah.prefs.max_value));ak.css({position:"absolute",top:"24px",left:"10px"});ak.prependTo(ah.container_div);am.css({position:"absolute",bottom:"2px",left:"10px"});am.prependTo(ah.container_div)})},draw_tile:function(au,am,al,aj,at){if(this.vertical_range===undefined){return}var ah=this._get_tile_bounds(aj,al),an=ah[0],ar=ah[1],ai=Math.ceil((ar-an)*at),ap=this.height_px;var ak=this.view.canvas_manager.new_canvas();ak.width=ai,ak.height=ap;var aq=ak.getContext("2d");var ao=new M.LinePainter(au.data,an,ar,this.prefs,am);ao.draw(aq,ai,ap);return new b(aj,al,ak,au.data)}});var e=function(ah,am,al,ap,ao,aj,ak,an){var ai=this;this.display_modes=["Auto","Histogram","Dense","Squish","Pack"];this.track_config=new ab({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ah},{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},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:ao,onchange:function(){ai.set_name(ai.prefs.name);ai.tile_cache.clear();ai.request_draw()}});this.prefs=this.track_config.values;j.call(this,ah,am,am.viewport_container);N.call(this,aj,ak,an);this.height_px=0;this.container_div.addClass("feature-track");this.hda_ldda=al;this.dataset_id=ap;this.original_dataset_id=ap;this.show_labels_scale=0.001;this.showing_details=false;this.summary_draw_height=30;this.inc_slots={};this.start_end_dct={};this.tile_cache=new c(d);this.data_manager=new T(20,this);this.left_offset=200;this.painter=M.LinkedFeaturePainter};q(e.prototype,N.prototype,{postdraw_actions:function(ax,ah,ay,aw){N.prototype.postdraw_actions.call(this,ax,aw);var ak=this;if(aw){var am=ak.content_div.children();var an=false;for(var al=am.length-1,ar=0;al>=ar;al--){var aj=$(am[al]);if(an){aj.remove()}else{if(aj.children().length!==0){an=true}}}}if(ak.mode=="Histogram"){var aq=-1;for(var al=0;al<ax.length;al++){var av=ax[al].max_val;if(av>aq){aq=av}}for(var al=0;al<ax.length;al++){var au=ax[al];if(au.max_val!==aq){au.canvas.remove();ak.draw_helper(true,ah,au.index,au.resolution,au.canvas.parent(),ay,[],{max:aq})}}}if(ak.filters_manager){var ai=ak.filters_manager.filters;for(var ap=0;ap<ai.length;ap++){ai[ap].update_ui_elt()}var ao=false,at;for(var al=0;al<ax.length;al++){if(ax[al].data.length){at=ax[al].data[0];for(var ap=0;ap<ai.length;ap++){if(ai[ap].applies_to(at)){ao=true;break}}}}if(ak.filters_available!==ao){ak.filters_available=ao;if(!ak.filters_available){ak.filters_div.hide()}ak.make_name_popup_menu()}}},update_auto_mode:function(ah){if(this.mode=="Auto"){if(ah=="no_detail"){ah="feature spans"}else{if(ah=="summary_tree"){ah="coverage histogram"}}this.mode_div.text("Auto ("+ah+")")}},incremental_slots:function(al,ai,ak){var aj=this.view.canvas_manager.dummy_context,ah=this.inc_slots[al];if(!ah||(ah.mode!==ak)){ah=new (t.FeatureSlotter)(al,ak==="Pack",B,function(am){return aj.measureText(am)});ah.mode=ak;this.inc_slots[al]=ah}return ah.slot_features(ai)},get_summary_tree_data:function(al,ao,aj,ax){if(ax>aj-ao){ax=aj-ao}var at=Math.floor((aj-ao)/ax),aw=[],ak=0;var am=0,an=0,ar,av=0,ap=[],au,aq;var ai=function(aA,az,aB,ay){aA[0]=az+aB*ay;aA[1]=az+(aB+1)*ay};while(av<ax&&am!==al.length){var ah=false;for(;av<ax&&!ah;av++){ai(ap,ao,av,at);for(an=am;an<al.length;an++){ar=al[an].slice(1,3);if(is_overlap(ar,ap)){ah=true;break}}if(ah){break}}data_start_index=an;aw[aw.length]=au=[ap[0],0];for(;an<al.length;an++){ar=al[an].slice(1,3);if(is_overlap(ar,ap)){au[1]++}else{break}}if(au[1]>ak){ak=au[1]}av++}return{max:ak,delta:at,data:aw}},draw_tile:function(aw,az,aE,aI,ar,ak){var aB=this,am=aB._get_tile_bounds(aI,aE),aK=am[0],ai=am[1],ay=ai-aK,aC=Math.ceil(ay*ar),aO=25,al=this.left_offset,ax,an;if(az==="Auto"){if(aw.dataset_type==="summary_tree"){az=aw.dataset_type}else{if(aw.extra_info==="no_detail"){az="no_detail"}else{var aN=aw.data;if(this.view.high-this.view.low>J){az="Squish"}else{az="Pack"}}}this.update_auto_mode(az)}if(az==="summary_tree"||az==="Histogram"){an=this.summary_draw_height;this.container_div.find(".yaxislabel").remove();var ah=$("<div />").addClass("yaxislabel");ah.text(aw.max);ah.css({position:"absolute",top:"24px",left:"10px",color:this.prefs.label_color});ah.prependTo(this.container_div);var aj=this.view.canvas_manager.new_canvas();aj.width=aC+al;aj.height=an+U;if(aw.dataset_type!="summary_tree"){var at=this.get_summary_tree_data(aw.data,aK,ai,200);if(aw.max){at.max=aw.max}aw=at}var aL=new M.SummaryTreePainter(aw,aK,ai,this.prefs);var aD=aj.getContext("2d");aD.translate(al,U);aL.draw(aD,aC,an);return new l(aI,aE,aj,aw.data,aw.max)}var ax,ap=1;if(az==="no_detail"||az==="Squish"||az==="Pack"){ap=this.incremental_slots(ar,aw.data,az);ax=this.inc_slots[ar].slots}var aq=[];if(aw.data){var au=this.filters_manager.filters;for(var aF=0,aH=aw.data.length;aF<aH;aF++){var ao=aw.data[aF];var aG=false;var av;for(var aJ=0,aM=au.length;aJ<aM;aJ++){av=au[aJ];av.update_attrs(ao);if(!av.keep(ao)){aG=true;break}}if(!aG){aq.push(ao)}}}var aA=(this.filters_manager.alpha_filter?new P(this.filters_manager.alpha_filter):null);var aL=new (this.painter)(aq,aK,ai,this.prefs,az,aA,ak);var an=Math.max(af,aL.get_required_height(ap));var aj=this.view.canvas_manager.new_canvas();aj.width=aC+al;aj.height=an;var aD=aj.getContext("2d");aD.fillStyle=this.prefs.block_color;aD.font=aD.canvas.manager.default_font;aD.textAlign="right";this.container_div.find(".yaxislabel").remove();if(aw.data){aD.translate(al,0);aL.draw(aD,aC,an,ax)}return new Q(aI,aE,aj,aw.data,aw.message)}});var V=function(ak,ai,am,ah,aj,al){e.call(this,ak,ai,am,ah,aj,al);this.painter=M.VariantPainter};q(V.prototype,N.prototype,e.prototype);var Y=function(ak,ai,am,ah,aj,al){e.call(this,ak,ai,am,ah,aj,al);this.track_config=new ab({track:this,params:[{key:"name",label:"Name",type:"text",default_value:ak},{key:"block_color",label:"Block color",type:"color",default_value:"#444"},{key:"label_color",label:"Label color",type:"color",default_value:"black"},{key:"show_insertions",label:"Show insertions",type:"bool",default_value:false},{key:"show_differences",label:"Show differences only",type:"bool",default_value:true},{key:"show_counts",label:"Show summary counts",type:"bool",default_value:true},{key:"mode",type:"string",default_value:this.mode,hidden:true},],saved_values:aj,onchange:function(){this.track.set_name(this.track.prefs.name);this.track.tile_cache.clear();this.track.request_draw()}});this.prefs=this.track_config.values;this.painter=M.ReadPainter;this.make_name_popup_menu()};q(Y.prototype,N.prototype,e.prototype);var W=function(al,aj,an,ah,ak,am,ai){e.call(this,al,aj,an,ah,ak,am,{},ai);this.data_url=raw_data_url;this.data_query_wait=1000;this.dataset_check_url=dataset_state_url};q(W.prototype,N.prototype,e.prototype,{predraw_init:function(){var ai=this;var ah=function(){if(ai.data_manager.size()===0){setTimeout(ah,300)}else{ai.data_url=default_data_url;ai.data_query_wait=L;ai.dataset_state_url=converted_datasets_state_url;$.getJSON(ai.dataset_state_url,{dataset_id:ai.dataset_id,hda_ldda:ai.hda_ldda},function(aj){})}};ah()}});Z.View=ae;Z.DrawableGroup=R;Z.LineTrack=k;Z.FeatureTrack=e;Z.ReadTrack=Y};var slotting_module=function(c,b){var e=c("class").extend;var d=2,a=5;b.FeatureSlotter=function(j,h,f,g){this.slots={};this.start_end_dct={};this.w_scale=j;this.include_label=h;this.max_rows=f;this.measureText=g};e(b.FeatureSlotter.prototype,{slot_features:function(m){var p=this.w_scale,s=this.slots,h=this.start_end_dct,y=[],A=[],n=0,z=this.max_rows;for(var w=0,x=m.length;w<x;w++){var l=m[w],o=l[0];if(s[o]!==undefined){n=Math.max(n,s[o]);A.push(s[o])}else{y.push(w)}}var q=function(G,H){for(var F=0;F<=z;F++){var D=false,I=h[F];if(I!==undefined){for(var C=0,E=I.length;C<E;C++){var B=I[C];if(H>B[0]&&G<B[1]){D=true;break}}}if(!D){return F}}return -1};for(var w=0,x=y.length;w<x;w++){var l=m[y[w]],o=l[0],u=l[1],f=l[2],r=l[3],g=Math.floor(u*p),k=Math.ceil(f*p),v=this.measureText(r).width,j;if(r!==undefined&&this.include_label){v+=(d+a);if(g-v>=0){g-=v;j="left"}else{k+=v;j="right"}}var t=q(g,k);if(t>=0){if(h[t]===undefined){h[t]=[]}h[t].push([g,k]);s[o]=t;n=Math.max(n,t)}else{}}return n+1}})};var painters_module=function(k,x){var u=k("class").extend;var p=function(I,A,G,z,F,D){if(D===undefined){D=4}var C=z-A;var B=F-G;var E=Math.floor(Math.sqrt(C*C+B*B)/D);var J=C/E;var H=B/E;var y;for(y=0;y<E;y++,A+=J,G+=H){if(y%2!==0){continue}I.fillRect(A,G,D,1)}};var q=function(B,A,z,E){var D=A-E/2,C=A+E/2,F=z-Math.sqrt(E*3/2);B.beginPath();B.moveTo(D,F);B.lineTo(C,F);B.lineTo(A,z);B.lineTo(D,F);B.strokeStyle=this.fillStyle;B.fill();B.stroke();B.closePath()};var g=function(y){this.default_alpha=(y?y:1)};g.prototype.gen_alpha=function(y){return this.default_alpha};var n=function(A,C,y,z,B){this.data=A;this.view_start=C;this.view_end=y;this.prefs=u({},this.default_prefs,z);this.mode=B};n.prototype.default_prefs={};var v=function(A,C,y,z,B){n.call(this,A,C,y,z,B)};v.prototype.default_prefs={show_counts:false};v.prototype.draw=function(M,z,L){var E=this.view_start,O=this.view_end-this.view_start,N=z/O;var J=this.data.data,I=this.data.delta,G=this.data.max,B=L;delta_x_px=Math.ceil(I*N);M.save();for(var C=0,D=J.length;C<D;C++){var H=Math.floor((J[C][0]-E)*N);var F=J[C][1];if(!F){continue}var K=F/G*L;if(F!==0&&K<1){K=1}M.fillStyle=this.prefs.block_color;M.fillRect(H,B-K,delta_x_px,K);var A=4;if(this.prefs.show_counts&&(M.measureText(F).width+A)<delta_x_px){M.fillStyle=this.prefs.label_color;M.textAlign="center";M.fillText(F,H+(delta_x_px/2),10)}}M.restore()};var c=function(y,C,E,F,A){n.call(this,y,C,E,F,A);if(this.prefs.min_value===undefined){var G=Infinity;for(var z=0,B=this.data.length;z<B;z++){G=Math.min(G,this.data[z][1])}this.prefs.min_value=G}if(this.prefs.max_value===undefined){var D=-Infinity;for(var z=0,B=this.data.length;z<B;z++){D=Math.max(D,this.data[z][1])}this.prefs.max_value=D}};c.prototype.default_prefs={min_value:undefined,max_value:undefined,mode:"Histogram",color:"#000",overflow_color:"#F66"};c.prototype.draw=function(N,M,K){var F=false,H=this.prefs.min_value,D=this.prefs.max_value,J=D-H,z=K,A=this.view_start,L=this.view_end-this.view_start,B=M/L,I=this.mode,T=this.data;N.save();var U=Math.round(K+H/J*K);if(I!=="Intensity"){N.fillStyle="#aaa";N.fillRect(0,U,M,1)}N.beginPath();var R,E,C;if(T.length>1){C=Math.ceil((T[1][0]-T[0][0])*B)}else{C=10}for(var O=0,P=T.length;O<P;O++){N.fillStyle=this.prefs.color;R=Math.round((T[O][0]-A)*B);E=T[O][1];var Q=false,G=false;if(E===null){if(F&&I==="Filled"){N.lineTo(R,z)}F=false;continue}if(E<H){G=true;E=H}else{if(E>D){Q=true;E=D}}if(I==="Histogram"){E=Math.round(E/J*z);N.fillRect(R,U,C,-E)}else{if(I==="Intensity"){E=255-Math.floor((E-H)/J*255);N.fillStyle="rgb("+E+","+E+","+E+")";N.fillRect(R,0,C,z)}else{E=Math.round(z-(E-H)/J*z);if(F){N.lineTo(R,E)}else{F=true;if(I==="Filled"){N.moveTo(R,z);N.lineTo(R,E)}else{N.moveTo(R,E)}}}}N.fillStyle=this.prefs.overflow_color;if(Q||G){var S;if(I==="Histogram"||I==="Intensity"){S=C}else{R-=2;S=4}if(Q){N.fillRect(R,0,S,3)}if(G){N.fillRect(R,z-3,S,3)}}N.fillStyle=this.prefs.color}if(I==="Filled"){if(F){N.lineTo(R,U);N.lineTo(0,U)}N.fill()}else{N.stroke()}N.restore()};var o=function(B,D,y,A,C,z){n.call(this,B,D,y,A,C);this.alpha_generator=(z?z:new g())};o.prototype.default_prefs={block_color:"#FFF",connector_color:"#FFF"};u(o.prototype,{get_required_height:function(z){var y=y_scale=this.get_row_height(),A=this.mode;if(A==="no_detail"||A==="Squish"||A==="Pack"){y=z*y_scale}return y+Math.max(Math.round(y_scale/2),5)},draw:function(K,B,J,G){var E=this.data,H=this.view_start,L=this.view_end;K.save();K.fillStyle=this.prefs.block_color;K.textAlign="right";var O=this.view_end-this.view_start,N=B/O,A=this.get_row_height();for(var D=0,F=E.length;D<F;D++){var M=E[D],C=M[0],y=M[1],z=M[2],I=(G&&G[C]!==undefined?G[C]:null);if((y<L&&z>H)&&(this.mode=="Dense"||I!==null)){this.draw_element(K,this.mode,M,I,H,L,N,A,B)}}K.restore()},draw_element:function(E,A,G,C,B,D,F,z,y){console.log("WARNING: Unimplemented function.")}});var d=10,j=3,m=5,w=10,f=1,s=3,e=3,a=9,l=2,h="#ccc";var r=function(B,D,y,A,C,z){o.call(this,B,D,y,A,C,z)};u(r.prototype,o.prototype,{get_row_height:function(){var z=this.mode,y;if(z==="Dense"){y=d}else{if(z==="no_detail"){y=j}else{if(z==="Squish"){y=m}else{y=w}}}return y},draw_element:function(K,D,S,F,M,ac,ag,ah,y){var P=S[0],ae=S[1],W=S[2],N=S[3],X=Math.floor(Math.max(0,(ae-M)*ag)),L=Math.ceil(Math.min(y,Math.max(0,(W-M)*ag))),V=(D==="Dense"?0:(0+F))*ah,J,aa,O=null,ai=null,B=this.prefs.block_color,Z=this.prefs.label_color;K.globalAlpha=this.alpha_generator.gen_alpha(S);if(D=="Dense"){F=1}if(D==="no_detail"){K.fillStyle=B;K.fillRect(X,V+5,L-X,f)}else{var I=S[4],U=S[5],Y=S[6],C=S[7];if(U&&Y){O=Math.floor(Math.max(0,(U-M)*ag));ai=Math.ceil(Math.min(y,Math.max(0,(Y-M)*ag)))}var af,Q;if(D==="Squish"||D==="Dense"){af=1;Q=e}else{af=5;Q=a}if(!C){if(S.strand){if(S.strand==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand_inv")}else{if(S.strand==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand_inv")}}}else{K.fillStyle=B}K.fillRect(X,V,L-X,Q)}else{var H,R;if(D==="Squish"||D==="Dense"){K.fillStyle=h;H=V+Math.floor(e/2)+1;R=1}else{if(I){var H=V;var R=Q;if(I==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand")}else{if(I==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand")}}}else{K.fillStyle=h;H+=(e/2)+1;R=1}}K.fillRect(X,H,L-X,R);for(var ad=0,A=C.length;ad<A;ad++){var E=C[ad],z=Math.floor(Math.max(0,(E[0]-M)*ag)),T=Math.ceil(Math.min(y,Math.max((E[1]-M)*ag)));if(z>T){continue}K.fillStyle=B;K.fillRect(z,V+(Q-af)/2+1,T-z,af);if(O!==undefined&&Y>U&&!(z>ai||T<O)){var ab=Math.max(z,O),G=Math.min(T,ai);K.fillRect(ab,V+1,G-ab,Q);if(C.length==1&&D=="Pack"){if(I==="+"){K.fillStyle=K.canvas.manager.get_pattern("right_strand_inv")}else{if(I==="-"){K.fillStyle=K.canvas.manager.get_pattern("left_strand_inv")}}if(ab+14<G){ab+=2;G-=2}K.fillRect(ab,V+1,G-ab,Q)}}}}if(D==="Pack"&&ae>M){K.fillStyle=Z;if(M===0&&X-K.measureText(N).width<0){K.textAlign="left";K.fillText(N,L+l,V+8)}else{K.textAlign="right";K.fillText(N,X-l,V+8)}}}K.globalAlpha=1}});var b=function(B,D,y,A,C,z){o.call(this,B,D,y,A,C,z)};u(b.prototype,o.prototype,{draw_element:function(R,M,G,C,U,A,J,S,P){var G=data[i],I=G[0],Q=G[1],B=G[2],L=G[3],E=Math.floor(Math.max(0,(Q-U)*J)),H=Math.ceil(Math.min(P,Math.max(0,(B-U)*J))),D=(M==="Dense"?0:(0+C))*S,y,V,z=null,K=null;if(no_label){R.fillStyle=block_color;R.fillRect(E+left_offset,D+5,H-E,1)}else{var T=G[4],O=G[5],F=G[6];y=9;V=1;R.fillRect(E+left_offset,D,H-E,y);if(M!=="Dense"&&L!==undefined&&Q>U){R.fillStyle=label_color;if(U===0&&E-R.measureText(L).width<0){R.textAlign="left";R.fillText(L,H+2+left_offset,D+8)}else{R.textAlign="right";R.fillText(L,E-2+left_offset,D+8)}R.fillStyle=block_color}var N=T+" / "+O;if(Q>U&&R.measureText(N).width<(H-E)){R.fillStyle="white";R.textAlign="center";R.fillText(N,left_offset+E+(H-E)/2,D+8);R.fillStyle=block_color}}}});var t=function(C,E,y,B,D,z,A){o.call(this,C,E,y,B,D,z);this.ref_seq=A};t.prototype.default_prefs=u({},o.prototype.default_prefs,{show_insertions:false});u(t.prototype,o.prototype,{get_row_height:function(){var y,z=this.mode;if(z==="Dense"){y=d}else{if(z==="Squish"){y=m}else{y=w;if(this.prefs.show_insertions){y*=2}}}return y},draw_read:function(U,P,L,Z,A,T,I,F,E){U.textAlign="center";var S=this,z=[Z,A],O=0,V=0,R=0;ref_seq=this.ref_seq,char_width_px=U.canvas.manager.char_width_px;var ae=[];if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){R=Math.round(L/2)}if(!I){I=[[0,F.length]]}for(var M=0,X=I.length;M<X;M++){var J=I[M],B="MIDNSHP=X"[J[0]],N=J[1];if(B==="H"||B==="S"){O-=N}var G=T+O,ad=Math.floor(Math.max(0,(G-Z)*L)),H=Math.floor(Math.max(0,(G+N-Z)*L));if(ad===H){H+=1}switch(B){case"H":break;case"S":case"M":case"=":if(is_overlap([G,G+N],z)){var Q=F.slice(V,V+N);if(R>0){U.fillStyle=this.prefs.block_color;U.fillRect(ad-R,E+1,H-ad,9);U.fillStyle=h;for(var ab=0,y=Q.length;ab<y;ab++){if(this.prefs.show_differences&&ref_seq){var K=ref_seq[G-Z+ab];if(!K||K.toLowerCase()===Q[ab].toLowerCase()){continue}}if(G+ab>=Z&&G+ab<=A){var ac=Math.floor(Math.max(0,(G+ab-Z)*L));U.fillText(Q[ab],ac,E+9)}}}else{U.fillStyle=this.prefs.block_color;U.fillRect(ad,E+4,H-ad,e)}}V+=N;O+=N;break;case"N":U.fillStyle=h;U.fillRect(ad-R,E+5,H-ad,1);O+=N;break;case"D":U.fillStyle="red";U.fillRect(ad-R,E+4,H-ad,3);O+=N;break;case"P":break;case"I":var Y=ad-R;if(is_overlap([G,G+N],z)){var Q=F.slice(V,V+N);if(this.prefs.show_insertions){var D=ad-(H-ad)/2;if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){U.fillStyle="yellow";U.fillRect(D-R,E-9,H-ad,9);ae[ae.length]={type:"triangle",data:[Y,E+4,5]};U.fillStyle=h;switch(seq_tile_overlap){case (OVERLAP_START):Q=Q.slice(Z-G);break;case (OVERLAP_END):Q=Q.slice(0,G-A);break;case (CONTAINED_BY):break;case (CONTAINS):Q=Q.slice(Z-G,G-A);break}for(var ab=0,y=Q.length;ab<y;ab++){var ac=Math.floor(Math.max(0,(G+ab-Z)*L));U.fillText(Q[ab],ac-(H-ad)/2,E)}}else{U.fillStyle="yellow";U.fillRect(D,E+(this.mode!=="Dense"?2:5),H-ad,(P!=="Dense"?e:s))}}else{if((P==="Pack"||this.mode==="Auto")&&F!==undefined&&L>char_width_px){ae[ae.length]={type:"text",data:[Q.length,Y,E+9]}}else{}}}V+=N;break;case"X":V+=N;break}}U.fillStyle="yellow";var aa,C,af;for(var W=0;W<ae.length;W++){aa=ae[W];C=aa.type;af=aa.data;if(C==="text"){U.save();U.font="bold "+U.font;U.fillText(af[0],af[1],af[2]);U.restore()}else{if(C=="triangle"){q(U,af[0],af[1],af[2])}}}},draw_element:function(R,M,E,B,U,z,I,S,P){var H=E[0],Q=E[1],A=E[2],J=E[3],D=Math.floor(Math.max(0,(Q-U)*I)),F=Math.ceil(Math.min(P,Math.max(0,(A-U)*I))),C=(M==="Dense"?0:(0+B))*S,V=this.prefs.block_color,G=this.prefs.label_color,O=0;if((M==="Pack"||this.mode==="Auto")&&I>R.canvas.manager.char_width_px){var O=Math.round(I/2)}R.fillStyle=V;if(E[5] instanceof Array){var N=Math.floor(Math.max(0,(E[4][0]-U)*I)),L=Math.ceil(Math.min(P,Math.max(0,(E[4][1]-U)*I))),K=Math.floor(Math.max(0,(E[5][0]-U)*I)),y=Math.ceil(Math.min(P,Math.max(0,(E[5][1]-U)*I)));if(E[4][1]>=U&&E[4][0]<=z&&E[4][2]){this.draw_read(R,M,I,U,z,E[4][0],E[4][2],E[4][3],C)}if(E[5][1]>=U&&E[5][0]<=z&&E[5][2]){this.draw_read(R,M,I,U,z,E[5][0],E[5][2],E[5][3],C)}if(K>L){R.fillStyle=h;p(R,L-O,C+5,K-O,C+5)}}else{R.fillStyle=V;this.draw_read(R,M,I,U,z,Q,E[4],E[5],C)}if(M==="Pack"&&Q>U){R.fillStyle=this.prefs.label_color;var T=1;if(T===0&&D-R.measureText(J).width<0){R.textAlign="left";R.fillText(J,F+l-O,C+8)}else{R.textAlign="right";R.fillText(J,D-l-O,C+8)}R.fillStyle=V}}});x.AlphaGenerator=g;x.SummaryTreePainter=v;x.LinePainter=c;x.LinkedFeaturePainter=r;x.ReadPainter=t;x.VariantPainter=b};(function(d){var c={};var b=function(e){return c[e]};var a=function(f,g){var e={};g(b,e);c[f]=e};a("class",class_module);a("slotting",slotting_module);a("painters",painters_module);a("trackster",trackster_module);for(key in c.trackster){d[key]=c.trackster[key]}})(window);
\ No newline at end of file
--- a/static/scripts/trackster.js Fri Sep 23 11:32:08 2011 -0400
+++ b/static/scripts/trackster.js Fri Sep 23 13:26:34 2011 -0400
@@ -142,18 +142,43 @@
// ---- Web UI specific utilities ----
+/**
+ * Dictionary of HTML element-JavaScript object relationships.
+ */
+// TODO: probably should separate moveable objects from containers.
+var html_elt_js_obj_dict = {};
+
+/**
+ * Designates an HTML as a container.
+ */
+var is_container = function(element, obj) {
+ html_elt_js_obj_dict[element.attr("id")] = obj;
+};
+
/**
* Make `element` moveable within parent and sibling elements by dragging `handle` (a selector).
+ * Function manages JS objects, containers as well.
+ *
+ * @param element HTML element to make moveable
+ * @param handle_class classname that denotes HTML element to be used as handle
+ * @param container_selector selector used to identify possible containers for this element
+ * @param element_js_obj JavaScript object associated with element; used
*/
-var moveable = function( element, handle_class, container_selector ) {
+var moveable = function(element, handle_class, container_selector, element_js_obj) {
// HACK: set default value for container selector.
container_selector = ".group";
var css_border_props = {};
+
+ // Register element with its object.
+ html_elt_js_obj_dict[element.attr("id")] = element_js_obj;
+
// Need to provide selector for handle, not class.
element.bind( "drag", { handle: "." + handle_class, relative: true }, function ( e, d ) {
+ var element = $(this);
var
parent = $(this).parent(),
children = parent.children(),
+ this_obj = html_elt_js_obj_dict[$(this).attr("id")],
child,
container,
top,
@@ -173,13 +198,19 @@
if (d.offsetY < top) {
// Moving above container.
$(this).insertBefore(container);
+ var cur_container = html_elt_js_obj_dict[container.attr("id")];
+ cur_container.remove_drawable(this_obj);
+ cur_container.container.add_drawable_before(this_obj, cur_container);
return;
}
else if (d.offsetY > bottom) {
// Moving below container.
$(this).insertAfter(container);
+ var cur_container = html_elt_js_obj_dict[container.attr("id")];
+ cur_container.remove_drawable(this_obj);
+ cur_container.container.add_drawable(this_obj);
return;
- }
+ }
}
// Handle dragging into container.
@@ -198,6 +229,9 @@
else {
child.find(".content-div").append(this);
}
+ // Update containers.
+ this_obj.container.remove_drawable(this_obj);
+ html_elt_js_obj_dict[child.attr("id")].add_drawable(this_obj);
return;
}
}
@@ -216,10 +250,15 @@
if ( i === children.length ) {
if ( this !== children.get(i - 1) ) {
parent.append(this);
+ // Update container.
+ html_elt_js_obj_dict[parent.attr("id")].move_drawable(this_obj, i);
}
}
else if ( this !== children.get(i) ) {
$(this).insertBefore( children.get(i) );
+ // Need to adjust insert position if moving down because move is changing
+ // indices of all list items.
+ html_elt_js_obj_dict[parent.attr("id")].move_drawable(this_obj, (d.deltaY > 0 ? i-1 : i) );
}
}).bind("dragstart", function() {
css_border_props["border-top"] = element.css("border-top");
@@ -523,15 +562,122 @@
});
/**
+ * Drawables hierarchy:
+ *
+ * Drawable
+ * --> DrawableCollection
+ * --> DrawableGroup
+ * --> View
+ * --> Track
+ */
+
+/**
+ * Base interface for all drawable objects.
+ */
+var Drawable = function(name, view, parent_element, container) {
+ this.name = name;
+ this.view = view;
+ this.parent_element = parent_element;
+ this.container = container;
+};
+
+Drawable.prototype.request_draw = function() {};
+Drawable.prototype.draw = function() {};
+
+/**
+ * A collection of drawable objects.
+ */
+var DrawableCollection = function(name, view, parent_element, container) {
+ Drawable.call(this, name, view, parent_element, container);
+
+ // Attribute init.
+ this.drawables = [];
+};
+extend(DrawableCollection.prototype, Drawable.prototype, {
+ to_json: function() {
+ // For now, just return list of drawables in collection.
+ var json_obj = [];
+ for (var i = 0; i < this.drawables.length; i++) {
+
+ }
+ },
+ /**
+ * Add a drawable to the end of the collection.
+ */
+ add_drawable: function(drawable) {
+ this.drawables.push(drawable);
+ drawable.container = this;
+ },
+ /**
+ * Add a drawable before another drawable.
+ */
+ add_drawable_before: function(drawable, other) {
+ var index = this.drawables.indexOf(other);
+ if (index != -1) {
+ this.drawables.splice(index, 0, drawable);
+ return true;
+ }
+ return false;
+ },
+ /**
+ * Tries to remove drawable from the collection. Returns true if drawable removed from
+ * collection, false otherwise.
+ */
+ remove_drawable: function(drawable) {
+ var index = this.drawables.indexOf(drawable);
+ if (index != -1) {
+ this.drawables.splice(index, 1);
+ drawable.container = null;
+ return true;
+ }
+ return false;
+ },
+ /**
+ * Move drawable to another location in collection.
+ */
+ move_drawable: function(drawable, new_position) {
+ var index = this.drawables.indexOf(drawable);
+ if (index != -1) {
+ // Remove from current position:
+ this.drawables.splice(index, 1);
+ // insert into new position:
+ this.drawables.splice(new_position, 0, drawable);
+ return true;
+ }
+ return false;
+ }
+});
+
+/**
+ * A group of drawables that are moveable, visible.
+ */
+var DrawableGroup = function(name, view, parent_element, container) {
+ DrawableCollection.call(this, name, view, parent_element, container);
+
+ this.drag_handle_class = "group-handle";
+
+ // HTML elements.
+ this.container_div = $("<div/>").addClass("group").appendTo(this.parent_element);
+ this.container_div.append($("<div/>").addClass(this.drag_handle_class));
+ this.name_div = $("<div/>").addClass("group-name").text(this.name).appendTo(this.container_div);
+ this.content_div = $("<div/>").addClass("content-div").appendTo(this.container_div);
+ is_container(this.container_div, this);
+};
+
+extend(DrawableGroup.prototype, DrawableCollection.prototype, Drawable.prototype);
+
+/**
* View object manages complete viz view, including tracks and user interactions.
*/
var View = function(container, title, vis_id, dbkey, callback) {
+ DrawableCollection.call(this);
this.container = container;
this.chrom = null;
this.vis_id = vis_id;
this.dbkey = dbkey;
this.title = title;
- this.tracks = [];
+ // Alias tracks to point at drawables. TODO: changes tracks to 'drawables' or something similar.
+ this.tracks = this.drawables;
this.label_tracks = [];
this.tracks_to_be_redrawn = [];
this.max_low = 0;
@@ -545,7 +691,7 @@
this.canvas_manager = new CanvasManager( container.get(0).ownerDocument );
this.reset();
};
-extend( View.prototype, {
+extend( View.prototype, DrawableCollection.prototype, {
init: function( callback ) {
// Create DOM elements
var parent_element = this.container,
@@ -559,9 +705,10 @@
// Label track fixed at top
this.top_labeltrack = $("<div/>").addClass("top-labeltrack").appendTo(this.top_container);
// Viewport for dragging tracks in center
- this.viewport_container = $("<div/>").addClass("viewport-container").addClass("viewport-container").appendTo(this.content_div);
+ this.viewport_container = $("<div/>").addClass("viewport-container").attr("id", "viewport-container").appendTo(this.content_div);
+ is_container(this.viewport_container, view);
// Introduction div shown when there are no tracks.
- this.intro_div = $("<div/>").addClass("intro").appendTo(this.viewport_container).hide();
+ this.intro_div = $("<div/>").addClass("intro");
var add_tracks_button = $("<div/>").text("Add Datasets to Visualization").addClass("action-button").appendTo(this.intro_div).click(function () {
add_tracks();
});
@@ -739,13 +886,13 @@
return jsonified_drawables;
},
- /** Show or hide intro div depending on view state. */
+ /** Add or remove intro div depending on view state. */
update_intro_div: function() {
if (this.num_tracks === 0) {
- this.intro_div.show();
+ this.intro_div.appendTo(this.viewport_container);
}
else {
- this.intro_div.hide();
+ this.intro_div.remove();
}
},
update_location: function(low, high) {
@@ -900,7 +1047,7 @@
this.tracks.push(track);
if (track.init) { track.init(); }
track.container_div.attr('id', 'track_' + track.track_id);
- moveable(track.container_div, track.drag_handle_class);
+ moveable(track.container_div, track.drag_handle_class, ".group", track);
this.track_id_counter += 1;
this.num_tracks += 1;
this.has_changes = true;
@@ -1155,12 +1302,20 @@
// Highlight value for inputs for easy replacement.
this.parent_div.find("input").click(function() { $(this).select() });
- // Add 'Go' button.
+ // Add buttons for running on dataset, region.
var run_tool_row = $("<div>").addClass("param-row").appendTo(this.parent_div);
var run_on_dataset_button = $("<input type='submit'>").attr("value", "Run on complete dataset").appendTo(run_tool_row);
var run_on_region_button = $("<input type='submit'>").attr("value", "Run on visible region").css("margin-left", "3em").appendTo(run_tool_row);
var tool = this;
run_on_region_button.click( function() {
+ // Create group for track + new tracks and put track in group.
+ var
+ parent_elt = this.track.parent_element,
+ new_group = new DrawableCollection("New Group", parent_elt);
+ //this.track.view.add_track(new_group);
+
+
+ // Run tool to create new track.
tool.run_on_region();
});
run_on_dataset_button.click( function() {
@@ -1837,44 +1992,6 @@
};
/**
- * Base interface for all drawable objects.
- * TODO: Tracks should use this interface.
- */
-var Drawable = function(name, view) {
- this.name = name;
- this.view = view;
- this.parent_element = view.viewport_container;
-};
-
-Drawable.prototype.request_draw = function() {};
-Drawable.prototype.draw = function() {};
-
-/**
- * A collection of drawable objects.
- */
-var DrawableCollection = function(name, view) {
- Drawable.call(this, name, view);
-
- // Attribute init.
- this.members = [];
- this.drag_handle_class = "group-handle";
-
- // HTML elements.
- this.container_div = $("<div/>").addClass("group").appendTo(this.parent_element);
- this.container_div.append($("<div/>").addClass(this.drag_handle_class));
- this.name_div = $("<div/>").addClass("group-name").text(this.name).appendTo(this.container_div);
- this.content_div = $("<div/>").addClass("content-div").appendTo(this.container_div);
-};
-extend(DrawableCollection.prototype, Drawable.prototype, {
- request_draw: function(force, clear_after) {
-
- },
- draw: function() {
-
- }
-});
-
-/**
* Tracks are objects can be added to the View.
*
* Track object hierarchy:
@@ -1889,12 +2006,12 @@
* -------> VcfTrack
*/
var Track = function(name, view, parent_element, data_url, data_query_wait) {
+ // For now, track's container is always view.
+ Drawable.call(this, name, view, parent_element, view);
+
//
// Attribute init.
//
- this.name = name;
- this.view = view;
- this.parent_element = parent_element;
this.data_url = (data_url ? data_url : default_data_url);
this.data_url_extra_params = {}
this.data_query_wait = (data_query_wait ? data_query_wait : DEFAULT_DATA_QUERY_WAIT);
@@ -3179,7 +3296,7 @@
// Exports
exports.View = View;
-exports.DrawableCollection = DrawableCollection;
+exports.DrawableGroup = DrawableGroup;
exports.LineTrack = LineTrack;
exports.FeatureTrack = FeatureTrack;
exports.ReadTrack = ReadTrack;
--- a/templates/tracks/browser.mako Fri Sep 23 11:32:08 2011 -0400
+++ b/templates/tracks/browser.mako Fri Sep 23 13:26:34 2011 -0400
@@ -198,7 +198,7 @@
make_popupmenu( $("#viz-actions-button"), {
"Add Tracks": add_tracks,
"Add Group": function() {
- var group = new DrawableCollection("New Group", view);
+ var group = new DrawableGroup("New Group", view, view.viewport_container, view);
view.add_track(group);
},
"Save": function() {
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
23 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/915fd558d77b/
changeset: 915fd558d77b
user: greg
date: 2011-09-23 17:32:08
summary: Render an error message on the tool form when the loaded tool includes a dynamically generated select list that is either missing an entry in the tool_data_table_conf.xml file or is missing an index file.
affected #: 1 file (-1 bytes)
--- a/templates/tool_form.mako Fri Sep 23 11:29:45 2011 -0400
+++ b/templates/tool_form.mako Fri Sep 23 11:32:08 2011 -0400
@@ -247,15 +247,35 @@
<br/>
%endif
-## handle calculating the redict url for the special case where we have nginx proxy
-## upload and need to do url_for on the redirect portion of the tool action
<%
+ # Render an error message if a dynamically generated select list is missing a required
+ # index file or entry in the tool_data_table_conf.xml file.
+ from galaxy.tools.parameters.basic import SelectToolParameter
+ message = ""
+ for input_param in tool.input_params:
+ if isinstance( input_param, SelectToolParameter ) and input_param.is_dynamic:
+ # If the tool refers to .loc files or requires an entry in the
+ # tool_data_table_conf.xml, make sure all requirements exist.
+ options = input_param.dynamic_options or input_param.options
+ if options.missing_tool_data_table_name:
+ message = "Data table named '%s' is required by tool but not configured" % options.missing_tool_data_table_name
+ break
+ if options.missing_index_file:
+ message = "Index file named '%s' is required by tool but not availble" % options.missing_index_file
+ break
+
+ # Handle calculating the redirect url for the special case where we have nginx proxy
+ # upload and need to do url_for on the redirect portion of the tool action.
try:
tool_url = h.url_for(tool.action)
except AttributeError:
assert len(tool.action) == 2
tool_url = tool.action[0] + h.url_for(tool.action[1])
%>
+%if message:
+ <div class="errormessage">${message}</div>
+ <br/>
+%endif
<div class="toolForm" id="${tool.id}">
%if tool.has_multiple_pages:
<div class="toolFormTitle">${tool.name} (step ${tool_state.page+1} of ${tool.npages})</div>
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
23 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/172a1891f751/
changeset: 172a1891f751
user: greg
date: 2011-09-23 17:29:45
summary: Fix for installing tools from a clones tool shed repository to a local Galaxy instance where tool includes a dynamically generated select list parmater that uses both an index file and a tool-data_table_conf.xml entry.
affected #: 1 file (-1 bytes)
--- a/lib/galaxy/web/base/controller.py Fri Sep 23 11:01:37 2011 -0400
+++ b/lib/galaxy/web/base/controller.py Fri Sep 23 11:29:45 2011 -0400
@@ -2456,7 +2456,7 @@
if error:
log.debug( exception_msg )
break
- elif options.missing_index_file:
+ if options.missing_index_file:
missing_head, missing_tail = os.path.split( options.missing_index_file )
# The repository must contain the required xxx.loc.sample file.
for sample_file in sample_files:
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: natefoo: BaseController -> BaseUIController fixes for webapps.
by Bitbucket 23 Sep '11
by Bitbucket 23 Sep '11
23 Sep '11
1 new changeset in galaxy-central:
http://bitbucket.org/galaxy/galaxy-central/changeset/2675699dea93/
changeset: 2675699dea93
user: natefoo
date: 2011-09-23 17:01:37
summary: BaseController -> BaseUIController fixes for webapps.
affected #: 14 files (-1 bytes)
--- a/lib/galaxy/webapps/community/buildapp.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/community/buildapp.py Fri Sep 23 11:01:37 2011 -0400
@@ -20,12 +20,12 @@
log = logging.getLogger( __name__ )
-def add_controllers( webapp, app ):
+def add_ui_controllers( webapp, app ):
"""
Search for controllers in the 'galaxy.webapps.controllers' module and add
them to the webapp.
"""
- from galaxy.web.base.controller import BaseController
+ from galaxy.web.base.controller import BaseUIController
from galaxy.web.base.controller import ControllerUnavailable
import galaxy.webapps.community.controllers
controller_dir = galaxy.webapps.community.controllers.__path__[0]
@@ -39,8 +39,8 @@
# Look for a controller inside the modules
for key in dir( module ):
T = getattr( module, key )
- if isclass( T ) and T is not BaseController and issubclass( T, BaseController ):
- webapp.add_controller( name, T( app ) )
+ if isclass( T ) and T is not BaseUIController and issubclass( T, BaseUIController ):
+ webapp.add_ui_controller( name, T( app ) )
import galaxy.web.controllers
controller_dir = galaxy.web.controllers.__path__[0]
for fname in os.listdir( controller_dir ):
@@ -54,8 +54,8 @@
# Look for a controller inside the modules
for key in dir( module ):
T = getattr( module, key )
- if isclass( T ) and T is not BaseController and issubclass( T, BaseController ):
- webapp.add_controller( name, T( app ) )
+ if isclass( T ) and T is not BaseUIController and issubclass( T, BaseUIController ):
+ webapp.add_ui_controller( name, T( app ) )
def app_factory( global_conf, **kwargs ):
"""Return a wsgi application serving the root object"""
@@ -73,7 +73,7 @@
atexit.register( app.shutdown )
# Create the universe WSGI application
webapp = galaxy.web.framework.WebApplication( app, session_cookie='galaxycommunitysession' )
- add_controllers( webapp, app )
+ add_ui_controllers( webapp, app )
webapp.add_route( '/:controller/:action', action='index' )
webapp.add_route( '/:action', controller='repository', action='index' )
webapp.add_route( '/repos/*path_info', controller='hg', action='handle_request', path_info='/' )
--- a/lib/galaxy/webapps/community/controllers/admin.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/community/controllers/admin.py Fri Sep 23 11:01:37 2011 -0400
@@ -380,7 +380,7 @@
return trans.sa_session.query( self.model_class ) \
.join( model.Repository.table )
-class AdminController( BaseController, Admin ):
+class AdminController( BaseUIController, Admin ):
user_list_grid = UserListGrid()
role_list_grid = RoleListGrid()
--- a/lib/galaxy/webapps/community/controllers/hg.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/community/controllers/hg.py Fri Sep 23 11:01:37 2011 -0400
@@ -5,7 +5,7 @@
log = logging.getLogger(__name__)
-class HgController( BaseController ):
+class HgController( BaseUIController ):
@web.expose
def handle_request( self, trans, **kwd ):
# The os command that results in this method being called will look something like
--- a/lib/galaxy/webapps/community/controllers/repository.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/community/controllers/repository.py Fri Sep 23 11:01:37 2011 -0400
@@ -220,7 +220,7 @@
.join( model.RepositoryMetadata.table ) \
.join( model.User.table )
-class RepositoryController( BaseController, ItemRatings ):
+class RepositoryController( BaseUIController, ItemRatings ):
downloadable_repository_list_grid = DownloadableRepositoryListGrid()
repository_list_grid = RepositoryListGrid()
--- a/lib/galaxy/webapps/community/controllers/upload.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/community/controllers/upload.py Fri Sep 23 11:01:37 2011 -0400
@@ -14,7 +14,7 @@
class UploadError( Exception ):
pass
-class UploadController( BaseController ):
+class UploadController( BaseUIController ):
@web.expose
@web.require_login( 'upload', use_panels=True, webapp='community' )
def upload( self, trans, **kwd ):
@@ -313,4 +313,4 @@
message = "Uploaded archives cannot contain hgrc files."
return False, message
return True, ''
-
\ No newline at end of file
+
--- a/lib/galaxy/webapps/demo_sequencer/buildapp.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/demo_sequencer/buildapp.py Fri Sep 23 11:01:37 2011 -0400
@@ -18,12 +18,12 @@
import config
import galaxy.webapps.demo_sequencer.framework
-def add_controllers( webapp, app ):
+def add_ui_controllers( webapp, app ):
"""
Search for controllers in the 'galaxy.webapps.demo_sequencer.controllers'
directory and add them to the webapp.
"""
- from galaxy.web.base.controller import BaseController
+ from galaxy.web.base.controller import BaseUIController
from galaxy.web.base.controller import ControllerUnavailable
import galaxy.webapps.demo_sequencer.controllers
controller_dir = galaxy.webapps.demo_sequencer.controllers.__path__[0]
@@ -37,8 +37,8 @@
# Look for a controller inside the modules
for key in dir( module ):
T = getattr( module, key )
- if isclass( T ) and T is not BaseController and issubclass( T, BaseController ):
- webapp.add_controller( name, T( app ) )
+ if isclass( T ) and T is not BaseUIController and issubclass( T, BaseUIController ):
+ webapp.add_ui_controller( name, T( app ) )
def app_factory( global_conf, **kwargs ):
"""Return a wsgi application serving the root object"""
@@ -56,7 +56,7 @@
atexit.register( app.shutdown )
# Create the universe WSGI application
webapp = galaxy.webapps.demo_sequencer.framework.WebApplication( app, session_cookie='galaxydemo_sequencersession' )
- add_controllers( webapp, app )
+ add_ui_controllers( webapp, app )
# These two routes handle our simple needs at the moment
webapp.add_route( '/:controller/:action', action='index' )
webapp.add_route( '/:action', controller='common', action='index' )
--- a/lib/galaxy/webapps/demo_sequencer/controllers/common.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/demo_sequencer/controllers/common.py Fri Sep 23 11:01:37 2011 -0400
@@ -8,7 +8,7 @@
import logging
log = logging.getLogger( __name__ )
-class CommonController( BaseController ):
+class CommonController( BaseUIController ):
@web.expose
def index( self, trans, **kwd ):
redirect_action = util.restore_text( kwd.get( 'redirect_action', '' ) )
--- a/lib/galaxy/webapps/reports/buildapp.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/reports/buildapp.py Fri Sep 23 11:01:37 2011 -0400
@@ -20,12 +20,12 @@
import galaxy.model.mapping
import galaxy.web.framework
-def add_controllers( webapp, app ):
+def add_ui_controllers( webapp, app ):
"""
Search for controllers in the 'galaxy.webapps.controllers' module and add
them to the webapp.
"""
- from galaxy.web.base.controller import BaseController
+ from galaxy.web.base.controller import BaseUIController
from galaxy.web.base.controller import ControllerUnavailable
import galaxy.webapps.reports.controllers
controller_dir = galaxy.webapps.reports.controllers.__path__[0]
@@ -39,8 +39,8 @@
# Look for a controller inside the modules
for key in dir( module ):
T = getattr( module, key )
- if isclass( T ) and T is not BaseController and issubclass( T, BaseController ):
- webapp.add_controller( name, T( app ) )
+ if isclass( T ) and T is not BaseUIController and issubclass( T, BaseUIController ):
+ webapp.add_ui_controller( name, T( app ) )
def app_factory( global_conf, **kwargs ):
"""Return a wsgi application serving the root object"""
@@ -53,7 +53,7 @@
atexit.register( app.shutdown )
# Create the universe WSGI application
webapp = galaxy.web.framework.WebApplication( app, session_cookie='galaxyreportssession' )
- add_controllers( webapp, app )
+ add_ui_controllers( webapp, app )
# These two routes handle our simple needs at the moment
webapp.add_route( '/:controller/:action', controller="root", action='index' )
webapp.add_route( '/:action', controller='root', action='index' )
--- a/lib/galaxy/webapps/reports/controllers/jobs.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/reports/controllers/jobs.py Fri Sep 23 11:01:37 2011 -0400
@@ -117,7 +117,7 @@
.join( model.User ) \
.enable_eagerloads( False )
-class Jobs( BaseController ):
+class Jobs( BaseUIController ):
specified_date_list_grid = SpecifiedDateListGrid()
--- a/lib/galaxy/webapps/reports/controllers/root.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/reports/controllers/root.py Fri Sep 23 11:01:37 2011 -0400
@@ -2,7 +2,7 @@
import logging
log = logging.getLogger( __name__ )
-class Report( BaseController ):
+class Report( BaseUIController ):
@web.expose
def index( self, trans, **kwd ):
return trans.fill_template( '/webapps/reports/index.mako' )
--- a/lib/galaxy/webapps/reports/controllers/sample_tracking.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/reports/controllers/sample_tracking.py Fri Sep 23 11:01:37 2011 -0400
@@ -94,7 +94,7 @@
.join( model.User ) \
.enable_eagerloads( False )
-class SampleTracking( BaseController ):
+class SampleTracking( BaseUIController ):
specified_date_list_grid = SpecifiedDateListGrid()
--- a/lib/galaxy/webapps/reports/controllers/system.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/reports/controllers/system.py Fri Sep 23 11:01:37 2011 -0400
@@ -6,7 +6,7 @@
import logging
log = logging.getLogger( __name__ )
-class System( BaseController ):
+class System( BaseUIController ):
@web.expose
def index( self, trans, **kwd ):
params = util.Params( kwd )
--- a/lib/galaxy/webapps/reports/controllers/users.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/reports/controllers/users.py Fri Sep 23 11:01:37 2011 -0400
@@ -10,7 +10,7 @@
import logging
log = logging.getLogger( __name__ )
-class Users( BaseController ):
+class Users( BaseUIController ):
@web.expose
def registered_users( self, trans, **kwd ):
message = util.restore_text( kwd.get( 'message', '' ) )
--- a/lib/galaxy/webapps/reports/controllers/workflows.py Fri Sep 23 10:38:27 2011 -0400
+++ b/lib/galaxy/webapps/reports/controllers/workflows.py Fri Sep 23 11:01:37 2011 -0400
@@ -94,7 +94,7 @@
.join( model.User ) \
.enable_eagerloads( False )
-class Workflows( BaseController ):
+class Workflows( BaseUIController ):
specified_date_list_grid = SpecifiedDateListGrid()
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